From 21580812b4a3fb3f215ea1f539c2c14e2fa123bb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:57:57 +1000 Subject: [PATCH] release: 2.0.0 (#1639) * feat(api): OpenAPI spec update via Stainless API (#1638) * feat(api): OpenAPI spec update via Stainless API (#1640) * feat(api): OpenAPI spec update via Stainless API (#1641) * feat(api): OpenAPI spec update via Stainless API (#1642) * feat(api): OpenAPI spec update via Stainless API (#1643) * feat(api): OpenAPI spec update via Stainless API (#1644) * feat(api): update via SDK Studio (#1645) * feat(api): update via SDK Studio (#1646) * feat(api): update via SDK Studio (#1647) * feat(api): update via SDK Studio (#1648) * feat(api): OpenAPI spec update via Stainless API (#1649) * feat(api): OpenAPI spec update via Stainless API (#1650) * feat(api): OpenAPI spec update via Stainless API (#1651) * feat(api): OpenAPI spec update via Stainless API (#1652) * feat(api): update via SDK Studio (#1653) * feat(api): update via SDK Studio (#1654) * feat(api): update via SDK Studio (#1655) * feat(api): update via SDK Studio (#1656) * feat(api): OpenAPI spec update via Stainless API (#1658) * feat(api): update via SDK Studio (#1659) * feat(api): update via SDK Studio (#1660) * feat(api): update via SDK Studio (#1661) * feat(api): update via SDK Studio (#1662) * feat(api): OpenAPI spec update via Stainless API (#1663) * feat(api): update via SDK Studio (#1664) * feat(api): update via SDK Studio (#1665) * feat(api): update via SDK Studio (#1666) * feat(api): update via SDK Studio (#1667) * feat(api): update via SDK Studio (#1668) * feat(api): update via SDK Studio (#1669) * feat(api): update via SDK Studio (#1670) * feat(api): update via SDK Studio (#1671) * feat(api): update via SDK Studio (#1672) * feat(api): update via SDK Studio (#1673) * feat(api): update via SDK Studio (#1674) * feat(api): update via SDK Studio (#1675) * feat(api): update via SDK Studio (#1676) * feat(api): update via SDK Studio (#1677) * feat(api): update via SDK Studio (#1678) * feat(api): update via SDK Studio (#1679) * feat(api): update via SDK Studio (#1680) * feat(api): update via SDK Studio (#1681) * feat(api): update via SDK Studio (#1682) * feat(api): update via SDK Studio (#1683) * feat(api): update via SDK Studio (#1684) * feat(api): update via SDK Studio (#1687) * feat(api): OpenAPI spec update via Stainless API (#1689) * feat(api): OpenAPI spec update via Stainless API (#1690) * feat(api): OpenAPI spec update via Stainless API (#1691) * feat(api): update via SDK Studio (#1692) * feat(api): update via SDK Studio (#1693) * feat(api): update via SDK Studio (#1694) * feat(api): update via SDK Studio (#1695) * feat(api): update via SDK Studio (#1696) * feat(api): update via SDK Studio (#1697) * feat(api): update via SDK Studio (#1698) * feat(api): update via SDK Studio (#1699) * feat(api): update via SDK Studio (#1700) * feat(api): update via SDK Studio (#1701) * feat(api): update via SDK Studio (#1702) * feat(api): update via SDK Studio (#1703) * feat(api): update via SDK Studio (#1704) * feat(api): update via SDK Studio (#1705) * feat(api): update via SDK Studio (#1706) * feat(api): update via SDK Studio (#1707) * feat(api): update via SDK Studio (#1708) * feat(api): update via SDK Studio (#1712) * feat(api): update via SDK Studio (#1713) * feat(api): update via SDK Studio (#1714) * feat(api): update via SDK Studio (#1715) * feat(api): update via SDK Studio (#1716) * feat(api): update via SDK Studio (#1717) * feat(api): update via SDK Studio (#1718) * feat(api): update via SDK Studio (#1719) * feat(api): update via SDK Studio (#1720) * feat(api): update via SDK Studio (#1721) * feat(api): update via SDK Studio (#1722) * feat(api): update via SDK Studio (#1723) * feat(api): update via SDK Studio (#1724) * feat(api): update via SDK Studio (#1725) * feat(api): update via SDK Studio (#1726) * feat(api): update via SDK Studio (#1727) * feat(api): update via SDK Studio (#1728) * feat(api): update via SDK Studio (#1729) * feat(api): update via SDK Studio (#1730) * feat(api): update via SDK Studio (#1731) * feat(api): OpenAPI spec update via Stainless API (#1732) * feat(api): update via SDK Studio (#1733) * feat(api): update via SDK Studio (#1734) * feat(api): update via SDK Studio (#1735) * feat(api): update via SDK Studio (#1736) * feat(api): OpenAPI spec update via Stainless API (#1738) * feat(api): OpenAPI spec update via Stainless API (#1739) * feat(api): OpenAPI spec update via Stainless API (#1740) * feat(api): OpenAPI spec update via Stainless API (#1741) * feat(api): OpenAPI spec update via Stainless API (#1742) * feat(api): OpenAPI spec update via Stainless API (#1743) * feat(api): update via SDK Studio (#1745) * feat(api): update via SDK Studio (#1746) * feat(api): update via SDK Studio (#1747) * feat(api): update via SDK Studio (#1748) * feat(api): update via SDK Studio (#1749) * feat(api): update via SDK Studio (#1750) * feat(api): update via SDK Studio (#1751) * feat(api): update via SDK Studio (#1752) * feat(api): update via SDK Studio (#1753) * feat(api): update via SDK Studio (#1754) * feat(api): update via SDK Studio (#1755) * feat(api): update via SDK Studio (#1756) * feat(api): update via SDK Studio (#1757) * feat(api): update via SDK Studio (#1758) * feat(api): update via SDK Studio (#1759) * feat(api): update via SDK Studio (#1760) * feat(api): update via SDK Studio (#1761) * feat(api): update via SDK Studio (#1762) * feat(api): update via SDK Studio (#1763) * feat(api): update via SDK Studio (#1764) * feat(api): OpenAPI spec update via Stainless API (#1765) * feat(api): OpenAPI spec update via Stainless API (#1766) * feat(api): OpenAPI spec update via Stainless API (#1767) * feat(api): OpenAPI spec update via Stainless API (#1768) * feat(api): OpenAPI spec update via Stainless API (#1769) * feat(api): OpenAPI spec update via Stainless API (#1771) * feat(api): update via SDK Studio (#1772) * feat(api): update via SDK Studio (#1773) * feat(api): update via SDK Studio (#1774) * feat(api): update via SDK Studio (#1775) * feat(api): OpenAPI spec update via Stainless API (#1776) * feat(api): update via SDK Studio (#1777) * feat(api): update via SDK Studio (#1778) * feat(api): update via SDK Studio (#1779) * feat(api): update via SDK Studio (#1780) * feat(api): update via SDK Studio (#1781) * release: 2.0.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- .stats.yml | 2 +- CHANGELOG.md | 140 + README.md | 2 +- accounts/account.go | 222 +- accounts/account_test.go | 15 +- accounts/aliases.go | 96 + accounts/member.go | 1247 +-- accounts/member_test.go | 18 +- accounts/role.go | 94 +- acm/aliases.go | 96 + acm/totaltls.go | 105 +- addressing/addressmap.go | 248 +- addressing/addressmap_test.go | 1 + addressing/addressmapaccount.go | 140 +- addressing/addressmapaccount_test.go | 2 + addressing/addressmapip.go | 138 +- addressing/addressmapip_test.go | 2 + addressing/addressmapzone.go | 156 +- addressing/addressmapzone_test.go | 2 + addressing/aliases.go | 96 + addressing/loadocument.go | 53 +- addressing/prefix.go | 250 +- addressing/prefix_test.go | 1 + addressing/prefixbgpbinding.go | 248 +- addressing/prefixbgpprefix.go | 170 +- addressing/prefixbgpstatus.go | 105 +- addressing/prefixdelegation.go | 135 +- addressing/prefixdelegation_test.go | 1 + alerting/aliases.go | 96 + alerting/availablealert.go | 62 +- alerting/destinationeligible.go | 63 +- alerting/destinationpagerduty.go | 235 +- alerting/destinationwebhook.go | 254 +- alerting/history.go | 34 +- alerting/policy.go | 891 +- alerting/policy_test.go | 44 +- aliases.go | 96 + api.md | 3653 ++++--- argo/aliases.go | 96 + argo/smartrouting.go | 120 +- argo/tieredcaching.go | 120 +- audit_logs/aliases.go | 96 + audit_logs/auditlog.go | 181 +- billing/aliases.go | 96 + billing/profile.go | 60 +- bot_management/aliases.go | 96 + bot_management/botmanagement.go | 1001 +- bot_management/botmanagement_test.go | 10 +- brand_protection/aliases.go | 96 + brand_protection/brandprotection.go | 299 +- cache/aliases.go | 96 + cache/cache.go | 175 +- cache/cache_test.go | 6 +- cache/cachereserve.go | 308 +- cache/cachereserve_test.go | 1 + cache/regionaltieredcache.go | 184 +- cache/smarttieredcache.go | 187 +- cache/smarttieredcache_test.go | 1 + cache/variant.go | 220 +- cache/variant_test.go | 1 + calls/aliases.go | 96 + calls/call.go | 217 +- certificate_authorities/aliases.go | 96 + .../hostnameassociation.go | 175 +- .../hostnameassociation_test.go | 8 +- challenges/aliases.go | 96 + challenges/widget.go | 410 +- challenges/widget_test.go | 4 +- client_certificates/aliases.go | 96 + client_certificates/clientcertificate.go | 211 +- cloudforce_one/aliases.go | 96 + cloudforce_one/request.go | 739 +- cloudforce_one/requestmessage.go | 240 +- cloudforce_one/requestpriority.go | 412 +- cloudforce_one/requestpriority_test.go | 20 +- custom_certificates/aliases.go | 96 + custom_certificates/customcertificate.go | 443 +- custom_certificates/customcertificate_test.go | 15 +- custom_certificates/prioritize.go | 53 +- custom_hostnames/aliases.go | 96 + custom_hostnames/customhostname.go | 575 +- custom_hostnames/customhostname_test.go | 13 +- custom_hostnames/fallbackorigin.go | 187 +- custom_hostnames/fallbackorigin_test.go | 1 + custom_nameservers/aliases.go | 96 + custom_nameservers/customnameserver.go | 284 +- custom_nameservers/customnameserver_test.go | 2 + d1/aliases.go | 96 + d1/d1.go | 33 + d1/database.go | 366 +- dcv_delegation/aliases.go | 96 + dcv_delegation/uuid.go | 53 +- diagnostics/aliases.go | 96 + diagnostics/traceroute.go | 163 +- dns/aliases.go | 96 + dns/analyticsreport.go | 108 +- dns/analyticsreportbytime.go | 161 +- dns/dns.go | 73 + dns/firewall.go | 449 +- dns/firewall_test.go | 37 +- dns/firewallanalyticsreport.go | 57 +- dns/firewallanalyticsreportbytime.go | 58 +- dns/record.go | 9119 +++-------------- dns/record_test.go | 62 +- dnssec/aliases.go | 96 + dnssec/dnssec.go | 171 +- dnssec/dnssec_test.go | 1 + durable_objects/aliases.go | 96 + durable_objects/namespace.go | 25 +- durable_objects/namespaceobject.go | 2 +- email_routing/address.go | 301 +- email_routing/aliases.go | 96 + email_routing/dns.go | 131 +- email_routing/emailrouting.go | 418 +- email_routing/emailrouting_test.go | 17 +- email_routing/rule.go | 1122 +- email_routing/rule_test.go | 44 +- email_routing/rulecatchall.go | 348 +- email_routing/rulecatchall_test.go | 16 +- filters/aliases.go | 96 + filters/filter.go | 229 +- filters/filter_test.go | 8 +- firewall/accessrule.go | 766 +- firewall/accessrule_test.go | 13 +- firewall/aliases.go | 96 + firewall/lockdown.go | 422 +- firewall/lockdown_test.go | 10 +- firewall/rule.go | 457 +- firewall/rule_test.go | 15 +- firewall/uarule.go | 252 +- firewall/uarule_test.go | 7 +- firewall/wafoverride.go | 276 +- firewall/wafoverride_test.go | 7 +- firewall/wafpackage.go | 578 +- firewall/wafpackage_test.go | 3 +- firewall/wafpackagegroup.go | 193 +- firewall/wafpackagegroup_test.go | 16 +- firewall/wafpackagerule.go | 693 +- firewall/wafpackagerule_test.go | 17 +- healthchecks/aliases.go | 96 + healthchecks/healthcheck.go | 957 +- healthchecks/healthcheck_test.go | 199 +- healthchecks/preview.go | 308 +- healthchecks/preview_test.go | 67 +- hostnames/aliases.go | 96 + hostnames/settingtls.go | 313 +- hostnames/settingtls_test.go | 2 +- hyperdrive/aliases.go | 96 + hyperdrive/config.go | 438 +- hyperdrive/config_test.go | 26 +- hyperdrive/hyperdrive.go | 148 + images/aliases.go | 96 + images/v1.go | 340 +- images/v1_test.go | 12 +- images/v1key.go | 192 +- images/v1key_test.go | 4 +- images/v1stat.go | 85 +- images/v1variant.go | 723 +- images/v1variant_test.go | 9 +- images/v2.go | 55 +- images/v2directupload.go | 53 +- intel/aliases.go | 96 + intel/asn.go | 59 +- intel/asnsubnet.go | 4 +- intel/attacksurfacereportissue.go | 688 +- intel/attacksurfacereportissue_test.go | 32 +- intel/attacksurfacereportissuetype.go | 54 +- intel/dns.go | 212 +- intel/dns_test.go | 6 +- intel/domain.go | 179 +- intel/domainbulk.go | 55 +- intel/domainhistory.go | 94 +- intel/indicatorfeed.go | 157 +- intel/indicatorfeedpermission.go | 157 +- intel/ip.go | 109 +- intel/iplist.go | 73 +- intel/miscategorization.go | 60 +- intel/sinkhole.go | 19 +- intel/whois.go | 87 +- internal/apijson/decoder.go | 4 +- internal/apijson/port.go | 94 + internal/apijson/port_test.go | 166 + internal/shared/shared.go | 577 ++ internal/shared/union.go | 490 +- internal/version.go | 2 +- ips/aliases.go | 96 + ips/ip.go | 95 +- keyless_certificates/aliases.go | 96 + keyless_certificates/keylesscertificate.go | 334 +- .../keylesscertificate_test.go | 8 +- kv/aliases.go | 96 + kv/namespace.go | 202 +- kv/namespace_test.go | 1 + kv/namespacebulk.go | 128 +- kv/namespacebulk_test.go | 6 +- kv/namespacekey.go | 20 +- kv/namespacemetadata.go | 51 +- kv/namespacevalue.go | 127 +- kv/namespacevalue_test.go | 1 + load_balancers/aliases.go | 96 + load_balancers/loadbalancer.go | 4301 +++----- load_balancers/loadbalancer_test.go | 319 +- load_balancers/monitor.go | 406 +- load_balancers/monitor_test.go | 1 + load_balancers/monitorpreview.go | 57 +- load_balancers/monitorreference.go | 51 +- load_balancers/pool.go | 1055 +- load_balancers/pool_test.go | 95 +- load_balancers/poolhealth.go | 116 +- load_balancers/poolreference.go | 51 +- load_balancers/preview.go | 58 +- load_balancers/region.go | 122 +- load_balancers/search.go | 57 +- logpush/aliases.go | 96 + logpush/datasetfield.go | 53 +- logpush/datasetjob.go | 245 +- logpush/edge.go | 105 +- logpush/job.go | 599 +- logpush/job_test.go | 13 +- logpush/ownership.go | 147 +- logpush/validate.go | 105 +- logs/aliases.go | 96 + logs/controlcmbconfig.go | 187 +- logs/controlcmbconfig_test.go | 5 +- logs/controlretentionflag.go | 105 +- logs/rayid.go | 10 +- logs/received.go | 22 +- logs/received_test.go | 4 +- magic_network_monitoring/aliases.go | 96 + magic_network_monitoring/config.go | 329 +- magic_network_monitoring/config_test.go | 4 + magic_network_monitoring/configfull.go | 55 +- magic_network_monitoring/rule.go | 300 +- magic_network_monitoring/rule_test.go | 4 + magic_network_monitoring/ruleadvertisement.go | 77 +- .../ruleadvertisement_test.go | 1 + magic_transit/aliases.go | 96 + magic_transit/cfinterconnect.go | 231 +- magic_transit/cfinterconnect_test.go | 4 +- magic_transit/gretunnel.go | 560 +- magic_transit/gretunnel_test.go | 11 +- magic_transit/ipsectunnel.go | 684 +- magic_transit/ipsectunnel_test.go | 18 +- magic_transit/magictransit.go | 124 + magic_transit/route.go | 441 +- magic_transit/route_test.go | 5 +- magic_transit/site.go | 666 +- magic_transit/site_test.go | 10 +- magic_transit/siteacl.go | 1299 +-- magic_transit/siteacl_test.go | 27 +- magic_transit/sitelan.go | 1564 +-- magic_transit/sitelan_test.go | 41 +- magic_transit/sitewan.go | 676 +- magic_transit/sitewan_test.go | 5 +- managed_headers/aliases.go | 96 + managed_headers/managedheader.go | 101 +- managed_headers/managedheader_test.go | 4 +- memberships/aliases.go | 96 + memberships/membership.go | 490 +- memberships/membership_test.go | 8 +- mtls_certificates/aliases.go | 96 + mtls_certificates/association.go | 71 +- mtls_certificates/mtlscertificate.go | 184 +- mtls_certificates/mtlscertificate_test.go | 1 + origin_ca_certificates/aliases.go | 96 + origin_ca_certificates/origincacertificate.go | 195 +- .../origincacertificate_test.go | 14 +- origin_post_quantum_encryption/aliases.go | 96 + .../originpostquantumencryption.go | 122 +- origin_tls_client_auth/aliases.go | 96 + origin_tls_client_auth/hostname.go | 169 +- origin_tls_client_auth/hostnamecertificate.go | 403 +- .../hostnamecertificate_test.go | 1 + origin_tls_client_auth/origintlsclientauth.go | 282 +- .../origintlsclientauth_test.go | 1 + origin_tls_client_auth/setting.go | 105 +- page_shield/aliases.go | 96 + page_shield/connection.go | 41 +- page_shield/pageshield.go | 122 +- page_shield/policy.go | 57 +- page_shield/script.go | 59 +- pagerules/aliases.go | 96 + pagerules/pagerule.go | 905 +- pagerules/pagerule_test.go | 49 +- pagerules/setting.go | 57 +- pages/aliases.go | 96 + pages/project.go | 1855 ++-- pages/project_test.go | 273 +- pages/projectdeployment.go | 246 +- pages/projectdeployment_test.go | 3 + pages/projectdeploymenthistorylog.go | 62 +- pages/projectdomain.go | 206 +- pages/projectdomain_test.go | 12 +- pcaps/aliases.go | 96 + pcaps/ownership.go | 192 +- pcaps/pcap.go | 1164 +-- pcaps/pcap_test.go | 28 +- plans/aliases.go | 96 + plans/plan.go | 53 +- queues/aliases.go | 96 + queues/consumer.go | 398 +- queues/consumer_test.go | 9 +- queues/message.go | 105 +- queues/queue.go | 405 +- queues/queue_test.go | 9 +- r2/aliases.go | 96 + r2/bucket.go | 130 +- r2/sippy.go | 321 +- r2/sippy_test.go | 28 +- radar/aliases.go | 96 + radar/annotationoutage.go | 4 +- radar/as112.go | 2 +- radar/as112summary.go | 16 +- radar/as112timeseriesgroup.go | 16 +- radar/as112top.go | 8 +- radar/attacklayer3.go | 8 +- radar/attacklayer3_test.go | 2 +- radar/attacklayer3summary.go | 36 +- radar/attacklayer3summary_test.go | 8 +- radar/attacklayer3timeseriesgroup.go | 40 +- radar/attacklayer3timeseriesgroup_test.go | 8 +- radar/attacklayer3top.go | 76 +- radar/attacklayer3top_test.go | 6 +- radar/attacklayer3toplocation.go | 12 +- radar/attacklayer3toplocation_test.go | 4 +- radar/attacklayer7.go | 2 +- radar/attacklayer7summary.go | 12 +- radar/attacklayer7timeseriesgroup.go | 16 +- radar/attacklayer7top.go | 64 +- radar/attacklayer7topase.go | 2 +- radar/attacklayer7toplocation.go | 4 +- radar/bgp.go | 2 +- radar/bgphijack.go | 327 +- radar/bgphijackevent.go | 362 + ...phijack_test.go => bgphijackevent_test.go} | 12 +- radar/bgpleak.go | 287 +- radar/bgpleakevent.go | 321 + .../{bgpleak_test.go => bgpleakevent_test.go} | 12 +- radar/bgproute.go | 10 +- radar/bgproute_test.go | 13 +- radar/bgptop.go | 2 +- radar/bgptopase.go | 4 +- radar/connectiontampering.go | 4 +- radar/dataset.go | 6 +- radar/dnstop.go | 4 +- radar/email.go | 51 + radar/emailroutingsummary.go | 136 +- radar/emailroutingtimeseriesgroup.go | 136 +- radar/emailsecuritysummary.go | 142 +- radar/emailsecuritytimeseriesgroup.go | 142 +- radar/emailsecuritytoptld.go | 31 +- radar/emailsecuritytoptldmalicious.go | 31 +- radar/emailsecuritytoptldspam.go | 31 +- radar/emailsecuritytoptldspoof.go | 31 +- radar/entity.go | 2 +- radar/entityasn.go | 8 +- radar/entitylocation.go | 4 +- radar/httpase.go | 2 +- radar/httpasebotclass.go | 2 +- radar/httpasedevicetype.go | 2 +- radar/httpasehttpmethod.go | 2 +- radar/httpasehttpprotocol.go | 2 +- radar/httpaseipversion.go | 2 +- radar/httpaseos.go | 2 +- radar/httpasetlsversion.go | 2 +- radar/httplocation.go | 2 +- radar/httplocationbotclass.go | 2 +- radar/httplocationdevicetype.go | 2 +- radar/httplocationhttpmethod.go | 2 +- radar/httplocationhttpprotocol.go | 2 +- radar/httplocationipversion.go | 2 +- radar/httplocationos.go | 2 +- radar/httplocationtlsversion.go | 2 +- radar/httpsummary.go | 14 +- radar/httptimeseriesgroup.go | 18 +- radar/httptop.go | 84 +- radar/netflow.go | 2 +- radar/netflowtop.go | 4 +- radar/qualityiqi.go | 4 +- radar/qualityspeed.go | 4 +- radar/qualityspeedtop.go | 4 +- radar/ranking.go | 33 +- radar/rankingdomain.go | 2 +- radar/search.go | 2 +- radar/trafficanomaly.go | 2 +- radar/trafficanomalylocation.go | 2 +- radar/verifiedbottop.go | 4 +- rate_limits/aliases.go | 96 + rate_limits/ratelimit.go | 514 +- rate_limits/ratelimit_test.go | 7 +- rate_plans/aliases.go | 96 + rate_plans/rateplan.go | 143 +- registrar/aliases.go | 96 + registrar/domain.go | 221 +- request_tracers/aliases.go | 96 + request_tracers/trace.go | 59 +- request_tracers/trace_test.go | 75 +- rules/aliases.go | 96 + rules/list.go | 319 +- rules/list_test.go | 1 + rules/listbulkoperation.go | 53 +- rules/listitem.go | 448 +- rules/listitem_test.go | 44 +- rulesets/aliases.go | 96 + rulesets/phase.go | 970 +- rulesets/phase_test.go | 33 +- rulesets/phaseversion.go | 307 +- rulesets/rule.go | 6137 +++++++++-- rulesets/rule_test.go | 38 +- rulesets/ruleset.go | 2355 ++--- rulesets/ruleset_test.go | 65 +- rulesets/version.go | 299 +- rulesets/versionbytag.go | 288 +- rum/aliases.go | 96 + rum/rule.go | 40 +- rum/siteinfo.go | 84 +- secondary_dns/acl.go | 272 +- secondary_dns/acl_test.go | 9 +- secondary_dns/aliases.go | 96 + secondary_dns/forceaxfr.go | 64 +- secondary_dns/forceaxfr_test.go | 1 + secondary_dns/incoming.go | 218 +- secondary_dns/incoming_test.go | 1 + secondary_dns/outgoing.go | 403 +- secondary_dns/outgoing_test.go | 4 + secondary_dns/outgoingstatus.go | 55 +- secondary_dns/peer.go | 289 +- secondary_dns/peer_test.go | 17 +- secondary_dns/tsig.go | 274 +- secondary_dns/tsig_test.go | 17 +- snippets/aliases.go | 96 + snippets/rule.go | 51 +- snippets/snippet.go | 162 +- spectrum/aliases.go | 96 + spectrum/analyticsaggregatecurrent.go | 55 +- spectrum/analyticsevent.go | 17 + spectrum/analyticseventbytime.go | 81 +- spectrum/analyticseventbytime_test.go | 2 +- spectrum/analyticseventsummary.go | 81 +- spectrum/analyticseventsummary_test.go | 2 +- spectrum/app.go | 1086 +- spectrum/app_test.go | 39 +- spectrum/spectrum.go | 356 + speed/aliases.go | 96 + speed/availability.go | 107 +- speed/page.go | 64 +- speed/schedule.go | 109 +- speed/speed.go | 270 +- speed/speed_test.go | 5 +- speed/test.go | 452 +- ssl/aliases.go | 96 + ssl/analyze.go | 83 +- ssl/analyze_test.go | 3 +- ssl/certificatepack.go | 190 +- ssl/certificatepack_test.go | 2 + ssl/certificatepackorder.go | 57 +- ssl/certificatepackorder_test.go | 2 +- ssl/certificatepackquota.go | 53 +- ssl/recommendation.go | 53 +- ssl/universalsetting.go | 121 +- ssl/universalsetting_test.go | 6 +- ssl/verification.go | 182 +- storage/aliases.go | 96 + storage/analytics.go | 215 +- stream/aliases.go | 96 + stream/audiotrack.go | 252 +- stream/caption.go | 197 +- stream/caption_test.go | 1 + stream/clip.go | 139 +- stream/clip_test.go | 6 +- stream/copy.go | 59 +- stream/copy_test.go | 4 +- stream/directupload.go | 63 +- stream/directupload_test.go | 4 +- stream/download.go | 187 +- stream/download_test.go | 1 + stream/key.go | 194 +- stream/key_test.go | 2 + stream/liveinput.go | 405 +- stream/liveinput_test.go | 1 + stream/liveinputoutput.go | 140 +- stream/liveinputoutput_test.go | 1 + stream/stream.go | 174 +- stream/stream_test.go | 2 + stream/token.go | 53 +- stream/video.go | 55 +- stream/watermark.go | 210 +- stream/watermark_test.go | 1 + stream/webhook.go | 187 +- stream/webhook_test.go | 1 + subscriptions/aliases.go | 96 + subscriptions/subscription.go | 631 +- subscriptions/subscription_test.go | 128 +- url_normalization/aliases.go | 96 + url_scanner/aliases.go | 96 + url_scanner/scan.go | 312 +- url_scanner/urlscanner.go | 2 +- user/aliases.go | 96 + user/auditlog.go | 181 +- user/billinghistory.go | 177 +- user/billinghistory_test.go | 15 +- user/billingprofile.go | 60 +- user/firewall.go | 26 - user/firewallaccessrule.go | 1139 -- user/firewallaccessrule_test.go | 143 - user/invite.go | 156 +- user/loadbalancer.go | 33 - user/loadbalanceranalytics.go | 27 - user/loadbalanceranalyticsevent.go | 112 - user/loadbalanceranalyticsevent_test.go | 48 - user/loadbalancermonitor.go | 1314 --- user/loadbalancermonitor_test.go | 315 - user/loadbalancerpool.go | 2372 ----- user/loadbalancerpool_test.go | 440 - user/loadbalancerpreview.go | 187 - user/loadbalancerpreview_test.go | 38 - user/organization.go | 74 +- user/organization_test.go | 8 +- user/subscription.go | 680 +- user/subscription_test.go | 132 +- user/token.go | 579 +- user/token_test.go | 90 +- user/tokenvalue.go | 60 +- user/tokenvalue_test.go | 2 +- user/user.go | 124 +- vectorize/aliases.go | 96 + vectorize/index.go | 741 +- vectorize/index_test.go | 10 +- waiting_rooms/aliases.go | 96 + waiting_rooms/event.go | 285 +- waiting_rooms/event_test.go | 107 +- waiting_rooms/eventdetail.go | 90 +- waiting_rooms/eventdetail_test.go | 5 +- waiting_rooms/page.go | 18 +- waiting_rooms/page_test.go | 11 +- waiting_rooms/rule.go | 317 +- waiting_rooms/rule_test.go | 23 +- waiting_rooms/setting.go | 78 +- waiting_rooms/setting_test.go | 26 +- waiting_rooms/status.go | 20 +- waiting_rooms/status_test.go | 5 +- waiting_rooms/waitingroom.go | 1809 +--- waiting_rooms/waitingroom_test.go | 176 +- warp_connector/aliases.go | 96 + warp_connector/warpconnector.go | 1096 +- warp_connector/warpconnector_test.go | 3 +- web3/aliases.go | 96 + web3/hostname.go | 287 +- web3/hostname_test.go | 3 + web3/hostnameipfsuniversalpathcontentlist.go | 168 +- ...stnameipfsuniversalpathcontentlist_test.go | 8 +- ...stnameipfsuniversalpathcontentlistentry.go | 473 +- ...eipfsuniversalpathcontentlistentry_test.go | 3 + workers/accountsetting.go | 107 +- workers/accountsetting_test.go | 2 +- workers/ai.go | 272 +- workers/ai_test.go | 6 +- workers/aliases.go | 96 + workers/deployment.go | 26 - workers/deploymentbyscript.go | 164 - workers/deploymentbyscript_test.go | 45 - workers/deploymentbyscriptdetail.go | 166 - workers/deploymentbyscriptdetail_test.go | 46 - workers/domain.go | 138 +- workers/domain_test.go | 1 + workers/filter.go | 462 - workers/route.go | 563 - workers/route_test.go | 161 - workers/script.go | 412 +- workers/script_test.go | 123 +- workers/scriptbinding.go | 249 - workers/scriptbinding_test.go | 41 - workers/scriptcontent.go | 93 +- workers/scriptcontent_test.go | 46 +- workers/scriptcontentv2.go | 45 - workers/scriptcontentv2_test.go | 59 - workers/scriptdeployment.go | 278 + ...model_test.go => scriptdeployment_test.go} | 17 +- workers/scriptschedule.go | 186 +- workers/scriptschedule_test.go | 2 +- workers/scriptsetting.go | 2324 +---- workers/scriptsetting_test.go | 92 +- workers/scripttail.go | 224 +- workers/scripttail_test.go | 2 + workers/scriptusagemodel.go | 294 - workers/scriptversion.go | 392 + .../{filter_test.go => scriptversion_test.go} | 82 +- workers/service.go | 26 - workers/serviceenvironment.go | 29 - workers/serviceenvironmentcontent.go | 198 - workers/serviceenvironmentcontent_test.go | 100 - workers/serviceenvironmentsetting.go | 2448 ----- workers/serviceenvironmentsetting_test.go | 157 - workers/subdomain.go | 107 +- workers/subdomain_test.go | 2 +- workers/worker.go | 1148 ++- workers_for_platforms/aliases.go | 96 + workers_for_platforms/dispatchnamespace.go | 159 +- .../dispatchnamespacescript.go | 395 +- .../dispatchnamespacescript_test.go | 122 +- .../dispatchnamespacescriptbinding.go | 523 +- .../dispatchnamespacescriptcontent.go | 81 +- .../dispatchnamespacescriptcontent_test.go | 3 +- .../dispatchnamespacescriptsecret.go | 228 + .../dispatchnamespacescriptsecret_test.go | 45 +- .../dispatchnamespacescriptsetting.go | 2432 +---- .../dispatchnamespacescriptsetting_test.go | 57 +- .../dispatchnamespacescripttag.go | 192 + .../dispatchnamespacescripttag_test.go | 75 +- zero_trust/access.go | 1397 +++ zero_trust/accessapplication.go | 2978 ++---- zero_trust/accessapplication_test.go | 140 +- zero_trust/accessapplicationca.go | 190 +- zero_trust/accessapplicationpolicy.go | 6034 +---------- zero_trust/accessapplicationpolicy_test.go | 88 +- .../accessapplicationuserpolicycheck.go | 129 +- zero_trust/accessbookmark.go | 262 +- zero_trust/accessbookmark_test.go | 10 + zero_trust/accesscertificate.go | 250 +- zero_trust/accesscertificate_test.go | 4 +- zero_trust/accesscertificatesetting.go | 131 +- zero_trust/accesscertificatesetting_test.go | 2 +- zero_trust/accesscustompage.go | 351 +- zero_trust/accesscustompage_test.go | 20 +- zero_trust/accessgroup.go | 6669 +----------- zero_trust/accessgroup_test.go | 84 +- zero_trust/accesskey.go | 180 +- zero_trust/accesslogaccessrequest.go | 74 +- zero_trust/accessservicetoken.go | 288 +- zero_trust/accesstag.go | 237 +- zero_trust/accessuser.go | 26 +- zero_trust/accessuseractivesession.go | 80 +- zero_trust/accessuserlastseenidentity.go | 236 +- zero_trust/aliases.go | 96 + zero_trust/connectivitysetting.go | 105 +- zero_trust/device.go | 118 +- zero_trust/devicedextest.go | 407 +- zero_trust/devicedextest_test.go | 68 +- zero_trust/devicenetwork.go | 269 +- zero_trust/devicenetwork_test.go | 1 + zero_trust/deviceoverridecode.go | 53 +- zero_trust/devicepolicy.go | 300 +- zero_trust/devicepolicy_test.go | 1 + zero_trust/devicepolicydefaultpolicy.go | 53 +- zero_trust/devicepolicyexclude.go | 135 +- zero_trust/devicepolicyexclude_test.go | 4 +- zero_trust/devicepolicyfallbackdomain.go | 137 +- zero_trust/devicepolicyfallbackdomain_test.go | 4 +- zero_trust/devicepolicyinclude.go | 137 +- zero_trust/devicepolicyinclude_test.go | 4 +- zero_trust/deviceposture.go | 3573 +++---- zero_trust/deviceposture_test.go | 29 +- zero_trust/devicepostureintegration.go | 390 +- zero_trust/devicepostureintegration_test.go | 9 +- zero_trust/devicerevoke.go | 62 +- zero_trust/devicerevoke_test.go | 2 +- zero_trust/devicesetting.go | 138 +- zero_trust/devicesetting_test.go | 12 +- zero_trust/deviceunrevoke.go | 62 +- zero_trust/deviceunrevoke_test.go | 2 +- zero_trust/dex.go | 208 + zero_trust/dexcolo.go | 2 +- zero_trust/dexfleetstatus.go | 210 +- zero_trust/dexfleetstatusdevice.go | 30 +- zero_trust/dexhttptest.go | 502 +- zero_trust/dexhttptestpercentile.go | 182 +- zero_trust/dextest.go | 884 +- zero_trust/dextestuniquedevice.go | 72 +- zero_trust/dextraceroutetest.go | 900 +- .../dextraceroutetestresultnetworkpath.go | 145 +- zero_trust/dlpdataset.go | 265 +- zero_trust/dlpdatasetupload.go | 137 +- zero_trust/dlpdatasetupload_test.go | 1 + zero_trust/dlppattern.go | 77 +- zero_trust/dlppayloadlog.go | 105 +- zero_trust/dlpprofile.go | 352 +- zero_trust/dlpprofilecustom.go | 461 +- zero_trust/dlpprofilecustom_test.go | 73 +- zero_trust/dlpprofilepredefined.go | 182 +- zero_trust/dlpprofilepredefined_test.go | 4 +- zero_trust/gateway.go | 105 +- zero_trust/gatewayapptype.go | 100 +- zero_trust/gatewayauditsshsetting.go | 126 +- zero_trust/gatewaycategory.go | 71 +- zero_trust/gatewayconfiguration.go | 1736 +--- zero_trust/gatewayconfiguration_test.go | 48 +- zero_trust/gatewaylist.go | 398 +- zero_trust/gatewaylist_test.go | 5 +- zero_trust/gatewaylistitem.go | 30 +- zero_trust/gatewaylocation.go | 296 +- zero_trust/gatewaylocation_test.go | 5 +- zero_trust/gatewaylogging.go | 161 +- zero_trust/gatewaylogging_test.go | 14 +- zero_trust/gatewayproxyendpoint.go | 264 +- zero_trust/gatewayproxyendpoint_test.go | 9 +- zero_trust/gatewayrule.go | 1651 ++- zero_trust/gatewayrule_test.go | 85 +- zero_trust/identityprovider.go | 8276 +++------------ zero_trust/identityprovider_test.go | 84 +- zero_trust/networkroute.go | 240 +- zero_trust/networkroute_test.go | 1 + zero_trust/networkrouteip.go | 57 +- zero_trust/networkroutenetwork.go | 173 +- zero_trust/networkroutenetwork_test.go | 6 +- zero_trust/networkvirtualnetwork.go | 216 +- zero_trust/networkvirtualnetwork_test.go | 2 + zero_trust/organization.go | 330 +- zero_trust/organization_test.go | 4 +- zero_trust/seat.go | 75 +- zero_trust/seat_test.go | 4 +- zero_trust/tunnel.go | 696 +- zero_trust/tunnel_test.go | 3 +- zero_trust/tunnelconfiguration.go | 129 +- zero_trust/tunnelconfiguration_test.go | 8 +- zero_trust/tunnelconnection.go | 153 +- zero_trust/tunnelconnection_test.go | 2 +- zero_trust/tunnelconnector.go | 55 +- zero_trust/tunnelmanagement.go | 62 +- zero_trust/tunneltoken.go | 62 +- zones/activationcheck.go | 53 +- zones/aliases.go | 96 + zones/customnameserver.go | 124 +- zones/dnssetting.go | 313 +- zones/dnssetting_test.go | 11 +- zones/hold.go | 184 +- zones/setting.go | 2152 ---- zones/settingadvancedddos.go | 124 +- zones/settingalwaysonline.go | 180 +- zones/settingalwaysusehttps.go | 178 +- zones/settingautomatichttpsrewrite.go | 179 +- zones/settingautomaticplatformoptimization.go | 137 +- ...ttingautomaticplatformoptimization_test.go | 2 +- zones/settingbrotli.go | 177 +- zones/settingbrowsercachettl.go | 231 +- zones/settingbrowsercheck.go | 180 +- zones/settingcachelevel.go | 182 +- zones/settingchallengettl.go | 204 +- zones/settingcipher.go | 165 +- zones/settingdevelopmentmode.go | 181 +- zones/settingearlyhint.go | 179 +- zones/settingemailobfuscation.go | 178 +- zones/settingfontsetting.go | 158 +- zones/settingh2prioritization.go | 177 +- zones/settingh2prioritization_test.go | 6 +- zones/settinghotlinkprotection.go | 183 +- zones/settinghttp2.go | 176 +- zones/settinghttp3.go | 176 +- zones/settingimageresizing.go | 176 +- zones/settingimageresizing_test.go | 6 +- zones/settingipgeolocation.go | 178 +- zones/settingipv6.go | 176 +- zones/settingminify.go | 245 +- zones/settingminify_test.go | 2 +- zones/settingmintlsversion.go | 182 +- zones/settingmirage.go | 179 +- zones/settingmobileredirect.go | 213 +- zones/settingnel.go | 182 +- zones/settingnel_test.go | 6 +- zones/settingopportunisticencryption.go | 181 +- zones/settingopportunisticonion.go | 178 +- zones/settingorangetoorange.go | 174 +- zones/settingorangetoorange_test.go | 6 +- zones/settingoriginerrorpagepassthru.go | 183 +- zones/settingoriginmaxhttpversion.go | 151 +- zones/settingpolish.go | 176 +- zones/settingpolish_test.go | 6 +- zones/settingprefetchpreload.go | 177 +- zones/settingproxyreadtimeout.go | 161 +- zones/settingproxyreadtimeout_test.go | 4 +- zones/settingpseudoipv4.go | 178 +- zones/settingresponsebuffering.go | 180 +- zones/settingrocketloader.go | 174 +- zones/settingrocketloader_test.go | 6 +- zones/settingsecurityheader.go | 224 +- zones/settingsecuritylevel.go | 187 +- zones/settingserversideexclude.go | 187 +- zones/settingsortquerystringforcache.go | 183 +- zones/settingssl.go | 194 +- zones/settingsslrecommender.go | 148 +- zones/settingsslrecommender_test.go | 4 +- zones/settingtls13.go | 178 +- zones/settingtlsclientauth.go | 177 +- zones/settingtrueclientipheader.go | 178 +- zones/settingwaf.go | 184 +- zones/settingwebp.go | 177 +- zones/settingwebsocket.go | 182 +- zones/settingzerortt.go | 175 +- zones/subscription.go | 424 +- zones/subscription_test.go | 63 +- zones/worker.go | 26 - zones/workerscript.go | 188 - zones/zone.go | 207 +- 793 files changed, 54796 insertions(+), 132018 deletions(-) create mode 100644 internal/apijson/port.go create mode 100644 internal/apijson/port_test.go create mode 100644 radar/bgphijackevent.go rename radar/{bgphijack_test.go => bgphijackevent_test.go} (76%) create mode 100644 radar/bgpleakevent.go rename radar/{bgpleak_test.go => bgpleakevent_test.go} (74%) delete mode 100644 user/firewall.go delete mode 100644 user/firewallaccessrule.go delete mode 100644 user/firewallaccessrule_test.go delete mode 100644 user/loadbalancer.go delete mode 100644 user/loadbalanceranalytics.go delete mode 100644 user/loadbalanceranalyticsevent.go delete mode 100644 user/loadbalanceranalyticsevent_test.go delete mode 100644 user/loadbalancermonitor.go delete mode 100644 user/loadbalancermonitor_test.go delete mode 100644 user/loadbalancerpool.go delete mode 100644 user/loadbalancerpool_test.go delete mode 100644 user/loadbalancerpreview.go delete mode 100644 user/loadbalancerpreview_test.go delete mode 100644 workers/deployment.go delete mode 100644 workers/deploymentbyscript.go delete mode 100644 workers/deploymentbyscript_test.go delete mode 100644 workers/deploymentbyscriptdetail.go delete mode 100644 workers/deploymentbyscriptdetail_test.go delete mode 100644 workers/filter.go delete mode 100644 workers/route.go delete mode 100644 workers/route_test.go delete mode 100644 workers/scriptbinding.go delete mode 100644 workers/scriptbinding_test.go delete mode 100644 workers/scriptcontentv2.go delete mode 100644 workers/scriptcontentv2_test.go create mode 100644 workers/scriptdeployment.go rename workers/{scriptusagemodel_test.go => scriptdeployment_test.go} (80%) delete mode 100644 workers/scriptusagemodel.go create mode 100644 workers/scriptversion.go rename workers/{filter_test.go => scriptversion_test.go} (55%) delete mode 100644 workers/service.go delete mode 100644 workers/serviceenvironment.go delete mode 100644 workers/serviceenvironmentcontent.go delete mode 100644 workers/serviceenvironmentcontent_test.go delete mode 100644 workers/serviceenvironmentsetting.go delete mode 100644 workers/serviceenvironmentsetting_test.go create mode 100644 workers_for_platforms/dispatchnamespacescriptsecret.go rename zones/setting_test.go => workers_for_platforms/dispatchnamespacescriptsecret_test.go (54%) create mode 100644 workers_for_platforms/dispatchnamespacescripttag.go rename zones/workerscript_test.go => workers_for_platforms/dispatchnamespacescripttag_test.go (57%) delete mode 100644 zones/worker.go delete mode 100644 zones/workerscript.go diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 217dc8e56c2..65f558e71b4 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0-beta.17" + ".": "2.0.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index de12921cd5a..d0e375fdcb3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1292 +configured_endpoints: 1256 diff --git a/CHANGELOG.md b/CHANGELOG.md index eec6df00812..205444492d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,145 @@ # Changelog +## 2.0.0 (2024-04-12) + +Full Changelog: [v2.0.0-beta.17...v2.0.0](https://github.com/cloudflare/cloudflare-go/compare/v2.0.0-beta.17...v2.0.0) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#1638](https://github.com/cloudflare/cloudflare-go/issues/1638)) ([6a29d9c](https://github.com/cloudflare/cloudflare-go/commit/6a29d9c77fa65d93b40eb8155c67f7e17dbd3d16)) +* **api:** OpenAPI spec update via Stainless API ([#1640](https://github.com/cloudflare/cloudflare-go/issues/1640)) ([41b6419](https://github.com/cloudflare/cloudflare-go/commit/41b641936e7eeeaa1726da70e192a698cb742269)) +* **api:** OpenAPI spec update via Stainless API ([#1641](https://github.com/cloudflare/cloudflare-go/issues/1641)) ([c7cceb7](https://github.com/cloudflare/cloudflare-go/commit/c7cceb70b5be65586d04664fee14e9368a2484be)) +* **api:** OpenAPI spec update via Stainless API ([#1642](https://github.com/cloudflare/cloudflare-go/issues/1642)) ([6efb9ce](https://github.com/cloudflare/cloudflare-go/commit/6efb9ce8f17ae371abf831be76902c97d71adff3)) +* **api:** OpenAPI spec update via Stainless API ([#1643](https://github.com/cloudflare/cloudflare-go/issues/1643)) ([b4819af](https://github.com/cloudflare/cloudflare-go/commit/b4819afce3acf687ac914daf876260ad6a403d77)) +* **api:** OpenAPI spec update via Stainless API ([#1644](https://github.com/cloudflare/cloudflare-go/issues/1644)) ([7b94c9e](https://github.com/cloudflare/cloudflare-go/commit/7b94c9ef67528acd247dfefa1f7690fdf8fa3d44)) +* **api:** OpenAPI spec update via Stainless API ([#1649](https://github.com/cloudflare/cloudflare-go/issues/1649)) ([dda7917](https://github.com/cloudflare/cloudflare-go/commit/dda79175008e5116afc9b629b876cbfbf5bf24f3)) +* **api:** OpenAPI spec update via Stainless API ([#1650](https://github.com/cloudflare/cloudflare-go/issues/1650)) ([40767f6](https://github.com/cloudflare/cloudflare-go/commit/40767f648140926edbdd8a24b37557eacce586e2)) +* **api:** OpenAPI spec update via Stainless API ([#1651](https://github.com/cloudflare/cloudflare-go/issues/1651)) ([d6d08c9](https://github.com/cloudflare/cloudflare-go/commit/d6d08c98cfe1d24d31e4474ec1577499d8252c49)) +* **api:** OpenAPI spec update via Stainless API ([#1652](https://github.com/cloudflare/cloudflare-go/issues/1652)) ([cdb0efe](https://github.com/cloudflare/cloudflare-go/commit/cdb0efee28d51755cc78d252503abfb4ae75c138)) +* **api:** OpenAPI spec update via Stainless API ([#1658](https://github.com/cloudflare/cloudflare-go/issues/1658)) ([ac995d6](https://github.com/cloudflare/cloudflare-go/commit/ac995d6ee4e739a61be8f8937060953ebe35b99a)) +* **api:** OpenAPI spec update via Stainless API ([#1663](https://github.com/cloudflare/cloudflare-go/issues/1663)) ([c309de1](https://github.com/cloudflare/cloudflare-go/commit/c309de125586e997b88c62ec9c661863a58aac57)) +* **api:** OpenAPI spec update via Stainless API ([#1689](https://github.com/cloudflare/cloudflare-go/issues/1689)) ([a77ec63](https://github.com/cloudflare/cloudflare-go/commit/a77ec63af9c0074c602cea4c5bf9ae6323db2f19)) +* **api:** OpenAPI spec update via Stainless API ([#1690](https://github.com/cloudflare/cloudflare-go/issues/1690)) ([42ea451](https://github.com/cloudflare/cloudflare-go/commit/42ea4518a41bc91b9d676987dd06b0e701fefa50)) +* **api:** OpenAPI spec update via Stainless API ([#1691](https://github.com/cloudflare/cloudflare-go/issues/1691)) ([04cc9b2](https://github.com/cloudflare/cloudflare-go/commit/04cc9b21f1c481ba61e50aa6bb8adb58a7a5b676)) +* **api:** OpenAPI spec update via Stainless API ([#1732](https://github.com/cloudflare/cloudflare-go/issues/1732)) ([fe73c98](https://github.com/cloudflare/cloudflare-go/commit/fe73c980b78d15c96396ba64617bad173cb96d43)) +* **api:** OpenAPI spec update via Stainless API ([#1738](https://github.com/cloudflare/cloudflare-go/issues/1738)) ([514b289](https://github.com/cloudflare/cloudflare-go/commit/514b289a793ac819af37c201a071c97e4d8285bc)) +* **api:** OpenAPI spec update via Stainless API ([#1739](https://github.com/cloudflare/cloudflare-go/issues/1739)) ([9df22fe](https://github.com/cloudflare/cloudflare-go/commit/9df22fe51be5bca587319963ce865e15eadbc8d0)) +* **api:** OpenAPI spec update via Stainless API ([#1740](https://github.com/cloudflare/cloudflare-go/issues/1740)) ([dc4600a](https://github.com/cloudflare/cloudflare-go/commit/dc4600a0cb63ed16cba4bdf3f94e1bc641797504)) +* **api:** OpenAPI spec update via Stainless API ([#1741](https://github.com/cloudflare/cloudflare-go/issues/1741)) ([0743b1d](https://github.com/cloudflare/cloudflare-go/commit/0743b1df7b676a77778ad67b089a5f641a8c46a7)) +* **api:** OpenAPI spec update via Stainless API ([#1742](https://github.com/cloudflare/cloudflare-go/issues/1742)) ([460f9fd](https://github.com/cloudflare/cloudflare-go/commit/460f9fdd8d9c6e44cf3d6ec59cc49619a88cdf81)) +* **api:** OpenAPI spec update via Stainless API ([#1743](https://github.com/cloudflare/cloudflare-go/issues/1743)) ([6d4bc04](https://github.com/cloudflare/cloudflare-go/commit/6d4bc0431fa35db268f0a5dcdbc624d46de21509)) +* **api:** OpenAPI spec update via Stainless API ([#1765](https://github.com/cloudflare/cloudflare-go/issues/1765)) ([65f5eb4](https://github.com/cloudflare/cloudflare-go/commit/65f5eb494b3a5544d9fcebbd788ccf42c4602007)) +* **api:** OpenAPI spec update via Stainless API ([#1766](https://github.com/cloudflare/cloudflare-go/issues/1766)) ([65ade52](https://github.com/cloudflare/cloudflare-go/commit/65ade52c647271909a7afdc3f77b128df0544390)) +* **api:** OpenAPI spec update via Stainless API ([#1767](https://github.com/cloudflare/cloudflare-go/issues/1767)) ([c8d2d0e](https://github.com/cloudflare/cloudflare-go/commit/c8d2d0e6313a8f37b2a5af8fe72a6754d89c6d5e)) +* **api:** OpenAPI spec update via Stainless API ([#1768](https://github.com/cloudflare/cloudflare-go/issues/1768)) ([6acbaf1](https://github.com/cloudflare/cloudflare-go/commit/6acbaf1922f556a4cadaf623bb7bca2086a7467e)) +* **api:** OpenAPI spec update via Stainless API ([#1769](https://github.com/cloudflare/cloudflare-go/issues/1769)) ([f5a5074](https://github.com/cloudflare/cloudflare-go/commit/f5a50743f2f98a9ab85128bc80ad56e475780ce4)) +* **api:** OpenAPI spec update via Stainless API ([#1771](https://github.com/cloudflare/cloudflare-go/issues/1771)) ([841e3c5](https://github.com/cloudflare/cloudflare-go/commit/841e3c5ff177460866e7c3b165d4b3b271cbcf4c)) +* **api:** OpenAPI spec update via Stainless API ([#1776](https://github.com/cloudflare/cloudflare-go/issues/1776)) ([6d825f2](https://github.com/cloudflare/cloudflare-go/commit/6d825f2af92bc7e5f25dec98851739b85157de39)) +* **api:** update via SDK Studio ([#1645](https://github.com/cloudflare/cloudflare-go/issues/1645)) ([9c48ae4](https://github.com/cloudflare/cloudflare-go/commit/9c48ae419eb0b06efe2cd5a25550ecc10eca1ae6)) +* **api:** update via SDK Studio ([#1646](https://github.com/cloudflare/cloudflare-go/issues/1646)) ([0056571](https://github.com/cloudflare/cloudflare-go/commit/00565717690d6d4482874829ca5ac4bd4165e544)) +* **api:** update via SDK Studio ([#1647](https://github.com/cloudflare/cloudflare-go/issues/1647)) ([eccfe47](https://github.com/cloudflare/cloudflare-go/commit/eccfe476e4e010ea88b3083578f5e195c1bde6ce)) +* **api:** update via SDK Studio ([#1648](https://github.com/cloudflare/cloudflare-go/issues/1648)) ([a674468](https://github.com/cloudflare/cloudflare-go/commit/a6744684649943c0aab75203c6e7ff1e0fb2e7c4)) +* **api:** update via SDK Studio ([#1653](https://github.com/cloudflare/cloudflare-go/issues/1653)) ([a9fb6ef](https://github.com/cloudflare/cloudflare-go/commit/a9fb6ef7816d506e8e232a0884a4d672a4d67815)) +* **api:** update via SDK Studio ([#1654](https://github.com/cloudflare/cloudflare-go/issues/1654)) ([faf8b4e](https://github.com/cloudflare/cloudflare-go/commit/faf8b4ea210032c61d6f5018744b4176f019e9e9)) +* **api:** update via SDK Studio ([#1655](https://github.com/cloudflare/cloudflare-go/issues/1655)) ([8515995](https://github.com/cloudflare/cloudflare-go/commit/8515995857152b736bc641c571074864c05bc280)) +* **api:** update via SDK Studio ([#1656](https://github.com/cloudflare/cloudflare-go/issues/1656)) ([87e081e](https://github.com/cloudflare/cloudflare-go/commit/87e081e76a42839b84d3b8875e4378ee7aedd78e)) +* **api:** update via SDK Studio ([#1659](https://github.com/cloudflare/cloudflare-go/issues/1659)) ([d55e8cd](https://github.com/cloudflare/cloudflare-go/commit/d55e8cdc64ec6314d4b19a7435373eefe6a642c7)) +* **api:** update via SDK Studio ([#1660](https://github.com/cloudflare/cloudflare-go/issues/1660)) ([dcc8fe5](https://github.com/cloudflare/cloudflare-go/commit/dcc8fe50bb3a02d5ffadb26d420f8e9e84e41829)) +* **api:** update via SDK Studio ([#1661](https://github.com/cloudflare/cloudflare-go/issues/1661)) ([193cef3](https://github.com/cloudflare/cloudflare-go/commit/193cef3823b38233d0dd4a0ee0ad73beab3cbc56)) +* **api:** update via SDK Studio ([#1662](https://github.com/cloudflare/cloudflare-go/issues/1662)) ([8b1bb23](https://github.com/cloudflare/cloudflare-go/commit/8b1bb23518952abd05df303fe7507464b0dc3b17)) +* **api:** update via SDK Studio ([#1664](https://github.com/cloudflare/cloudflare-go/issues/1664)) ([0f6c9da](https://github.com/cloudflare/cloudflare-go/commit/0f6c9dae68b2cac9f71e82cd256f33a155dcbb23)) +* **api:** update via SDK Studio ([#1665](https://github.com/cloudflare/cloudflare-go/issues/1665)) ([6c25472](https://github.com/cloudflare/cloudflare-go/commit/6c2547278326556bf2bdd35756a1876f397f81a0)) +* **api:** update via SDK Studio ([#1666](https://github.com/cloudflare/cloudflare-go/issues/1666)) ([777334d](https://github.com/cloudflare/cloudflare-go/commit/777334d7bf53bbc39c2c9064501260ac6dba3fd9)) +* **api:** update via SDK Studio ([#1667](https://github.com/cloudflare/cloudflare-go/issues/1667)) ([2566a69](https://github.com/cloudflare/cloudflare-go/commit/2566a6956d2ead63d634f72db20f1ad58edad6e6)) +* **api:** update via SDK Studio ([#1668](https://github.com/cloudflare/cloudflare-go/issues/1668)) ([bdd023d](https://github.com/cloudflare/cloudflare-go/commit/bdd023d4a1efa6d8a416f6cb6e0c87bfb76f2203)) +* **api:** update via SDK Studio ([#1669](https://github.com/cloudflare/cloudflare-go/issues/1669)) ([0cfe748](https://github.com/cloudflare/cloudflare-go/commit/0cfe748e333f395f9adf75ec3f8c3d600e338667)) +* **api:** update via SDK Studio ([#1670](https://github.com/cloudflare/cloudflare-go/issues/1670)) ([8b010ea](https://github.com/cloudflare/cloudflare-go/commit/8b010ea8c020009be75a5e0d00f0ce70678a3bf9)) +* **api:** update via SDK Studio ([#1671](https://github.com/cloudflare/cloudflare-go/issues/1671)) ([236771b](https://github.com/cloudflare/cloudflare-go/commit/236771b966466f9225f5c57bad6f5e5845406b6f)) +* **api:** update via SDK Studio ([#1672](https://github.com/cloudflare/cloudflare-go/issues/1672)) ([83f9859](https://github.com/cloudflare/cloudflare-go/commit/83f9859c9c1e0fc5cc7b9e00bbf5e69b6c549dd6)) +* **api:** update via SDK Studio ([#1673](https://github.com/cloudflare/cloudflare-go/issues/1673)) ([8e0f697](https://github.com/cloudflare/cloudflare-go/commit/8e0f69792b7327f856fcba8082033017b9c57714)) +* **api:** update via SDK Studio ([#1674](https://github.com/cloudflare/cloudflare-go/issues/1674)) ([f5009dd](https://github.com/cloudflare/cloudflare-go/commit/f5009ddff6ac75316b3ff5a2cab0ff7c45a8491e)) +* **api:** update via SDK Studio ([#1675](https://github.com/cloudflare/cloudflare-go/issues/1675)) ([771236a](https://github.com/cloudflare/cloudflare-go/commit/771236ae37579ec94d8c32692d4e0953c214ac83)) +* **api:** update via SDK Studio ([#1676](https://github.com/cloudflare/cloudflare-go/issues/1676)) ([3a2d0a0](https://github.com/cloudflare/cloudflare-go/commit/3a2d0a03049409fc33eb8db343f395b17f29706a)) +* **api:** update via SDK Studio ([#1677](https://github.com/cloudflare/cloudflare-go/issues/1677)) ([757f442](https://github.com/cloudflare/cloudflare-go/commit/757f442507d54084990f9f2ca62c6cbd604b3bff)) +* **api:** update via SDK Studio ([#1678](https://github.com/cloudflare/cloudflare-go/issues/1678)) ([bbabea6](https://github.com/cloudflare/cloudflare-go/commit/bbabea691c13e0903089bc30cb6d389b81608856)) +* **api:** update via SDK Studio ([#1679](https://github.com/cloudflare/cloudflare-go/issues/1679)) ([add0d9a](https://github.com/cloudflare/cloudflare-go/commit/add0d9a6cf7ac620c80fc2f91021b6a3613a3050)) +* **api:** update via SDK Studio ([#1680](https://github.com/cloudflare/cloudflare-go/issues/1680)) ([2e3b6c0](https://github.com/cloudflare/cloudflare-go/commit/2e3b6c05e9e7ed5e917db80e8c953ab071cf6ba4)) +* **api:** update via SDK Studio ([#1681](https://github.com/cloudflare/cloudflare-go/issues/1681)) ([8368a09](https://github.com/cloudflare/cloudflare-go/commit/8368a09c7115d3158808299334c0d894e4d29114)) +* **api:** update via SDK Studio ([#1682](https://github.com/cloudflare/cloudflare-go/issues/1682)) ([ad8dfff](https://github.com/cloudflare/cloudflare-go/commit/ad8dfff7aabdead3803c5543f9e1a9c9246451de)) +* **api:** update via SDK Studio ([#1683](https://github.com/cloudflare/cloudflare-go/issues/1683)) ([262d4b6](https://github.com/cloudflare/cloudflare-go/commit/262d4b60318657abd6c7b46d271d8eaeddc50c8f)) +* **api:** update via SDK Studio ([#1684](https://github.com/cloudflare/cloudflare-go/issues/1684)) ([77b5c4f](https://github.com/cloudflare/cloudflare-go/commit/77b5c4fda5470bc1b19ea8001c779f30ee268c3c)) +* **api:** update via SDK Studio ([#1687](https://github.com/cloudflare/cloudflare-go/issues/1687)) ([1085c09](https://github.com/cloudflare/cloudflare-go/commit/1085c090dece229adc33a88766e5f1b6e10f53b7)) +* **api:** update via SDK Studio ([#1692](https://github.com/cloudflare/cloudflare-go/issues/1692)) ([300bee6](https://github.com/cloudflare/cloudflare-go/commit/300bee6342409974aa3ea07a7d6c051c0e295392)) +* **api:** update via SDK Studio ([#1693](https://github.com/cloudflare/cloudflare-go/issues/1693)) ([974c062](https://github.com/cloudflare/cloudflare-go/commit/974c0621fd5651d34d64393a9ec17c5bafb959e8)) +* **api:** update via SDK Studio ([#1694](https://github.com/cloudflare/cloudflare-go/issues/1694)) ([9bcdf28](https://github.com/cloudflare/cloudflare-go/commit/9bcdf2865b64ec522dc37b33c72e48e46abfc0f2)) +* **api:** update via SDK Studio ([#1695](https://github.com/cloudflare/cloudflare-go/issues/1695)) ([dc4636f](https://github.com/cloudflare/cloudflare-go/commit/dc4636ffb171ec07e464384546f4e7b78a2073c9)) +* **api:** update via SDK Studio ([#1696](https://github.com/cloudflare/cloudflare-go/issues/1696)) ([e349ec2](https://github.com/cloudflare/cloudflare-go/commit/e349ec2c14b3cb1fd59d6bc8f7025abfae47e181)) +* **api:** update via SDK Studio ([#1697](https://github.com/cloudflare/cloudflare-go/issues/1697)) ([2b802b2](https://github.com/cloudflare/cloudflare-go/commit/2b802b27e0bef77ebcdc0a2f26a4d50dd61afac7)) +* **api:** update via SDK Studio ([#1698](https://github.com/cloudflare/cloudflare-go/issues/1698)) ([8675d09](https://github.com/cloudflare/cloudflare-go/commit/8675d0906d7fb243ed22ae3d0e9ab89f63c362f3)) +* **api:** update via SDK Studio ([#1699](https://github.com/cloudflare/cloudflare-go/issues/1699)) ([37a8467](https://github.com/cloudflare/cloudflare-go/commit/37a8467ef1d4506d1b10b2c793ebabe0968a9418)) +* **api:** update via SDK Studio ([#1700](https://github.com/cloudflare/cloudflare-go/issues/1700)) ([594b948](https://github.com/cloudflare/cloudflare-go/commit/594b948a5a64e494363132912a41bd5946a3813b)) +* **api:** update via SDK Studio ([#1701](https://github.com/cloudflare/cloudflare-go/issues/1701)) ([6d91ea7](https://github.com/cloudflare/cloudflare-go/commit/6d91ea7fd351d17250948dbfc9191bad7aefef08)) +* **api:** update via SDK Studio ([#1702](https://github.com/cloudflare/cloudflare-go/issues/1702)) ([1bd77b0](https://github.com/cloudflare/cloudflare-go/commit/1bd77b052e2380649437c2a6cca569389fb4cdf0)) +* **api:** update via SDK Studio ([#1703](https://github.com/cloudflare/cloudflare-go/issues/1703)) ([03c0d52](https://github.com/cloudflare/cloudflare-go/commit/03c0d529e57cc196086979ddcd9af1cac060e281)) +* **api:** update via SDK Studio ([#1704](https://github.com/cloudflare/cloudflare-go/issues/1704)) ([5bc8f65](https://github.com/cloudflare/cloudflare-go/commit/5bc8f656af3633eaa733c152882e5d60fd5d6139)) +* **api:** update via SDK Studio ([#1705](https://github.com/cloudflare/cloudflare-go/issues/1705)) ([32b66c2](https://github.com/cloudflare/cloudflare-go/commit/32b66c27b8c6fe8d5a3b1d045199a111175c4c6c)) +* **api:** update via SDK Studio ([#1706](https://github.com/cloudflare/cloudflare-go/issues/1706)) ([3a25535](https://github.com/cloudflare/cloudflare-go/commit/3a2553521f7a18627e9289604276773d2dff3e8d)) +* **api:** update via SDK Studio ([#1707](https://github.com/cloudflare/cloudflare-go/issues/1707)) ([a48495a](https://github.com/cloudflare/cloudflare-go/commit/a48495ad325fe8574f7b65d9f90326a13fea61ed)) +* **api:** update via SDK Studio ([#1708](https://github.com/cloudflare/cloudflare-go/issues/1708)) ([5873b5f](https://github.com/cloudflare/cloudflare-go/commit/5873b5f3f719119042741592afe9b4bbf77cedc8)) +* **api:** update via SDK Studio ([#1712](https://github.com/cloudflare/cloudflare-go/issues/1712)) ([fc54fcd](https://github.com/cloudflare/cloudflare-go/commit/fc54fcd530fbb63f38417bc3956e2118c869370f)) +* **api:** update via SDK Studio ([#1713](https://github.com/cloudflare/cloudflare-go/issues/1713)) ([3d1b5b5](https://github.com/cloudflare/cloudflare-go/commit/3d1b5b5c27a4d9ef883768b79f8d7306291994a2)) +* **api:** update via SDK Studio ([#1714](https://github.com/cloudflare/cloudflare-go/issues/1714)) ([b7db2d1](https://github.com/cloudflare/cloudflare-go/commit/b7db2d1cdcd73f970a19aaf726bf566428b7e2dc)) +* **api:** update via SDK Studio ([#1715](https://github.com/cloudflare/cloudflare-go/issues/1715)) ([c5a8f07](https://github.com/cloudflare/cloudflare-go/commit/c5a8f07cd90334acbbb38f16af6b41fa484fc39d)) +* **api:** update via SDK Studio ([#1716](https://github.com/cloudflare/cloudflare-go/issues/1716)) ([ee49602](https://github.com/cloudflare/cloudflare-go/commit/ee496028d70ee7a74ca04ced09cc8e6478f19814)) +* **api:** update via SDK Studio ([#1717](https://github.com/cloudflare/cloudflare-go/issues/1717)) ([43a6a9d](https://github.com/cloudflare/cloudflare-go/commit/43a6a9d7280702796227e51d1b2f410acc72f124)) +* **api:** update via SDK Studio ([#1718](https://github.com/cloudflare/cloudflare-go/issues/1718)) ([da0d64c](https://github.com/cloudflare/cloudflare-go/commit/da0d64cfb3a6c8846f61845a109500889377e0b0)) +* **api:** update via SDK Studio ([#1719](https://github.com/cloudflare/cloudflare-go/issues/1719)) ([efee485](https://github.com/cloudflare/cloudflare-go/commit/efee485480b171a2f4219bb8060ea93ccfc27997)) +* **api:** update via SDK Studio ([#1720](https://github.com/cloudflare/cloudflare-go/issues/1720)) ([321ee05](https://github.com/cloudflare/cloudflare-go/commit/321ee057ea5b07dc882f951429b99853c7877eaf)) +* **api:** update via SDK Studio ([#1721](https://github.com/cloudflare/cloudflare-go/issues/1721)) ([eaed6e1](https://github.com/cloudflare/cloudflare-go/commit/eaed6e1f79140ece4424c32ee84c6cb2e71d77ab)) +* **api:** update via SDK Studio ([#1722](https://github.com/cloudflare/cloudflare-go/issues/1722)) ([3a7b35a](https://github.com/cloudflare/cloudflare-go/commit/3a7b35a31c89c440e44134a59481924bf365e999)) +* **api:** update via SDK Studio ([#1723](https://github.com/cloudflare/cloudflare-go/issues/1723)) ([83dc4b2](https://github.com/cloudflare/cloudflare-go/commit/83dc4b28c5259ee29528b5233131536da4f2ba2e)) +* **api:** update via SDK Studio ([#1724](https://github.com/cloudflare/cloudflare-go/issues/1724)) ([1286934](https://github.com/cloudflare/cloudflare-go/commit/128693454dc082b398730ab71cd8fc41300defb1)) +* **api:** update via SDK Studio ([#1725](https://github.com/cloudflare/cloudflare-go/issues/1725)) ([76b3ccc](https://github.com/cloudflare/cloudflare-go/commit/76b3ccc10d63eac2eafbe8023d0c8fd3aaf713af)) +* **api:** update via SDK Studio ([#1726](https://github.com/cloudflare/cloudflare-go/issues/1726)) ([c078fa7](https://github.com/cloudflare/cloudflare-go/commit/c078fa73a65e4d6c02adb6749e8b07c9781ad2bd)) +* **api:** update via SDK Studio ([#1727](https://github.com/cloudflare/cloudflare-go/issues/1727)) ([071a670](https://github.com/cloudflare/cloudflare-go/commit/071a67090b078ccb74b6482ee265d1bbb833de2e)) +* **api:** update via SDK Studio ([#1728](https://github.com/cloudflare/cloudflare-go/issues/1728)) ([ee7b5aa](https://github.com/cloudflare/cloudflare-go/commit/ee7b5aad422fa11479e206dd0e66ddba4ac27841)) +* **api:** update via SDK Studio ([#1729](https://github.com/cloudflare/cloudflare-go/issues/1729)) ([2dcd09e](https://github.com/cloudflare/cloudflare-go/commit/2dcd09e00c3c6c96459038a6a1ce743d39e50c9f)) +* **api:** update via SDK Studio ([#1730](https://github.com/cloudflare/cloudflare-go/issues/1730)) ([b10e610](https://github.com/cloudflare/cloudflare-go/commit/b10e6105932d4536eace2af7229d1f54e1a71932)) +* **api:** update via SDK Studio ([#1731](https://github.com/cloudflare/cloudflare-go/issues/1731)) ([790181d](https://github.com/cloudflare/cloudflare-go/commit/790181d235062d4374a6a2e4f56cba5f41267c26)) +* **api:** update via SDK Studio ([#1733](https://github.com/cloudflare/cloudflare-go/issues/1733)) ([64cd2fd](https://github.com/cloudflare/cloudflare-go/commit/64cd2fd149e9570a729be6895de28699a363ed78)) +* **api:** update via SDK Studio ([#1734](https://github.com/cloudflare/cloudflare-go/issues/1734)) ([dd05a7a](https://github.com/cloudflare/cloudflare-go/commit/dd05a7ad4ab55fe09c2ef282fae6efca904a5a7c)) +* **api:** update via SDK Studio ([#1735](https://github.com/cloudflare/cloudflare-go/issues/1735)) ([13e3101](https://github.com/cloudflare/cloudflare-go/commit/13e31015d556c7ba3c2cef4350644441e5844e45)) +* **api:** update via SDK Studio ([#1736](https://github.com/cloudflare/cloudflare-go/issues/1736)) ([b0ae20e](https://github.com/cloudflare/cloudflare-go/commit/b0ae20e158c2153c71f785dea156956f4a8e162a)) +* **api:** update via SDK Studio ([#1745](https://github.com/cloudflare/cloudflare-go/issues/1745)) ([8fd3cd8](https://github.com/cloudflare/cloudflare-go/commit/8fd3cd846a7342bf21dc0397e8661e1b5b23b283)) +* **api:** update via SDK Studio ([#1746](https://github.com/cloudflare/cloudflare-go/issues/1746)) ([bf6d5c2](https://github.com/cloudflare/cloudflare-go/commit/bf6d5c27ee6f1060591169d7403f17ad9cecbb6a)) +* **api:** update via SDK Studio ([#1747](https://github.com/cloudflare/cloudflare-go/issues/1747)) ([bb22d0b](https://github.com/cloudflare/cloudflare-go/commit/bb22d0b0da56255a34163b2dd592e108919a15a1)) +* **api:** update via SDK Studio ([#1748](https://github.com/cloudflare/cloudflare-go/issues/1748)) ([b2c97cc](https://github.com/cloudflare/cloudflare-go/commit/b2c97cc38d41a0428e0ca20f975d8556d0e8571d)) +* **api:** update via SDK Studio ([#1749](https://github.com/cloudflare/cloudflare-go/issues/1749)) ([76a352e](https://github.com/cloudflare/cloudflare-go/commit/76a352ef89674ba32db359569680f3a4c794a0ca)) +* **api:** update via SDK Studio ([#1750](https://github.com/cloudflare/cloudflare-go/issues/1750)) ([d73cec1](https://github.com/cloudflare/cloudflare-go/commit/d73cec15cc4bec36b8fe411dafd0dfeb4ca42a87)) +* **api:** update via SDK Studio ([#1751](https://github.com/cloudflare/cloudflare-go/issues/1751)) ([b2deb53](https://github.com/cloudflare/cloudflare-go/commit/b2deb53375191af267d9c747dc35303dc8ca93af)) +* **api:** update via SDK Studio ([#1752](https://github.com/cloudflare/cloudflare-go/issues/1752)) ([99c1f28](https://github.com/cloudflare/cloudflare-go/commit/99c1f2877638fdf40efac7dd8a52567a8afe0323)) +* **api:** update via SDK Studio ([#1753](https://github.com/cloudflare/cloudflare-go/issues/1753)) ([9d20337](https://github.com/cloudflare/cloudflare-go/commit/9d20337757c979e803f15ee57da2066acec3fc80)) +* **api:** update via SDK Studio ([#1754](https://github.com/cloudflare/cloudflare-go/issues/1754)) ([7f3f4a3](https://github.com/cloudflare/cloudflare-go/commit/7f3f4a3d7809fd4d791956db5f9f939b053b7639)) +* **api:** update via SDK Studio ([#1755](https://github.com/cloudflare/cloudflare-go/issues/1755)) ([9065958](https://github.com/cloudflare/cloudflare-go/commit/90659584499425c14fc68a614850f6f89b0ac5ff)) +* **api:** update via SDK Studio ([#1756](https://github.com/cloudflare/cloudflare-go/issues/1756)) ([b50f50d](https://github.com/cloudflare/cloudflare-go/commit/b50f50de5d8e79d69d6a5f573a59b7a4775b85dd)) +* **api:** update via SDK Studio ([#1757](https://github.com/cloudflare/cloudflare-go/issues/1757)) ([5a50b24](https://github.com/cloudflare/cloudflare-go/commit/5a50b24c760987eb7b5d79bb2eedd539905dbc5a)) +* **api:** update via SDK Studio ([#1758](https://github.com/cloudflare/cloudflare-go/issues/1758)) ([d5a3666](https://github.com/cloudflare/cloudflare-go/commit/d5a366616cea01e9cdc6fca1906ca7838514e690)) +* **api:** update via SDK Studio ([#1759](https://github.com/cloudflare/cloudflare-go/issues/1759)) ([78c35a4](https://github.com/cloudflare/cloudflare-go/commit/78c35a44c8ee083a398ea52590b6738ed13ea201)) +* **api:** update via SDK Studio ([#1760](https://github.com/cloudflare/cloudflare-go/issues/1760)) ([eda70fa](https://github.com/cloudflare/cloudflare-go/commit/eda70fa5ec4bf8a8c49df84a9ff8b10a69e64c8a)) +* **api:** update via SDK Studio ([#1761](https://github.com/cloudflare/cloudflare-go/issues/1761)) ([eb4dfa3](https://github.com/cloudflare/cloudflare-go/commit/eb4dfa3c7360e42e0063ab8a158e6ad355a5ec0c)) +* **api:** update via SDK Studio ([#1762](https://github.com/cloudflare/cloudflare-go/issues/1762)) ([00372c0](https://github.com/cloudflare/cloudflare-go/commit/00372c0ae5b19430237f5655c205c69bc0b548d2)) +* **api:** update via SDK Studio ([#1763](https://github.com/cloudflare/cloudflare-go/issues/1763)) ([003db9d](https://github.com/cloudflare/cloudflare-go/commit/003db9d80982c78bdbcc8d4cb1087a10806f474e)) +* **api:** update via SDK Studio ([#1764](https://github.com/cloudflare/cloudflare-go/issues/1764)) ([f3db69e](https://github.com/cloudflare/cloudflare-go/commit/f3db69e498bff8ccbaf69d429151f7a9c91561f8)) +* **api:** update via SDK Studio ([#1772](https://github.com/cloudflare/cloudflare-go/issues/1772)) ([2e7c8ea](https://github.com/cloudflare/cloudflare-go/commit/2e7c8ea6216da1705cc1f5f231e4e8851acf1681)) +* **api:** update via SDK Studio ([#1773](https://github.com/cloudflare/cloudflare-go/issues/1773)) ([95b347b](https://github.com/cloudflare/cloudflare-go/commit/95b347be78b5a83af7eb57f20735f1068bd8ebd6)) +* **api:** update via SDK Studio ([#1774](https://github.com/cloudflare/cloudflare-go/issues/1774)) ([e3f2252](https://github.com/cloudflare/cloudflare-go/commit/e3f2252cc60a48eaf85e442abcdadbd8b3216a60)) +* **api:** update via SDK Studio ([#1775](https://github.com/cloudflare/cloudflare-go/issues/1775)) ([946dfa3](https://github.com/cloudflare/cloudflare-go/commit/946dfa35e6f4daa9fcde0d925f233cd350a02269)) +* **api:** update via SDK Studio ([#1777](https://github.com/cloudflare/cloudflare-go/issues/1777)) ([2f1707c](https://github.com/cloudflare/cloudflare-go/commit/2f1707ce77f265de37de20c2ca7f36bac6da63af)) +* **api:** update via SDK Studio ([#1778](https://github.com/cloudflare/cloudflare-go/issues/1778)) ([38518e7](https://github.com/cloudflare/cloudflare-go/commit/38518e7298ee58244ffe26376d081d5813cab90d)) +* **api:** update via SDK Studio ([#1779](https://github.com/cloudflare/cloudflare-go/issues/1779)) ([b5105da](https://github.com/cloudflare/cloudflare-go/commit/b5105daf92f25861d092cdfc6f0892368ea07a24)) +* **api:** update via SDK Studio ([#1780](https://github.com/cloudflare/cloudflare-go/issues/1780)) ([294f4f0](https://github.com/cloudflare/cloudflare-go/commit/294f4f02617f6a2b59254a97fbec71d3432789db)) +* **api:** update via SDK Studio ([#1781](https://github.com/cloudflare/cloudflare-go/issues/1781)) ([4506554](https://github.com/cloudflare/cloudflare-go/commit/45065547d3183ad46066cd7ff2799bbb89a1736d)) + ## 2.0.0-beta.17 (2024-04-01) Full Changelog: [v2.0.0-beta.16...v2.0.0-beta.17](https://github.com/cloudflare/cloudflare-go/compare/v2.0.0-beta.16...v2.0.0-beta.17) diff --git a/README.md b/README.md index 7821882121e..3b38d1c8e20 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Or to pin the version: ```sh -go get -u 'github.com/cloudflare/cloudflare-go/v2@v2.0.0-beta.17' +go get -u 'github.com/cloudflare/cloudflare-go/v2@v2.0.0' ``` diff --git a/accounts/account.go b/accounts/account.go index e203a314bd0..2c5c9edd162 100644 --- a/accounts/account.go +++ b/accounts/account.go @@ -42,7 +42,7 @@ func NewAccountService(opts ...option.RequestOption) (r *AccountService) { } // Update an existing account. -func (r *AccountService) Update(ctx context.Context, params AccountUpdateParams, opts ...option.RequestOption) (res *AccountUpdateResponse, err error) { +func (r *AccountService) Update(ctx context.Context, params AccountUpdateParams, opts ...option.RequestOption) (res *AccountUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccountUpdateResponseEnvelope path := fmt.Sprintf("accounts/%v", params.AccountID) @@ -78,7 +78,7 @@ func (r *AccountService) ListAutoPaging(ctx context.Context, query AccountListPa } // Get information about a specific account that you are a member of. -func (r *AccountService) Get(ctx context.Context, query AccountGetParams, opts ...option.RequestOption) (res *AccountGetResponse, err error) { +func (r *AccountService) Get(ctx context.Context, query AccountGetParams, opts ...option.RequestOption) (res *AccountGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccountGetResponseEnvelope path := fmt.Sprintf("accounts/%v", query.AccountID) @@ -187,55 +187,19 @@ func (r AccountSettingsDefaultNameservers) IsKnown() bool { return false } -// Union satisfied by [accounts.AccountUpdateResponseUnknown] or -// [shared.UnionString]. -type AccountUpdateResponse interface { - ImplementsAccountsAccountUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AccountUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AccountListResponse = interface{} - -// Union satisfied by [accounts.AccountGetResponseUnknown] or [shared.UnionString]. -type AccountGetResponse interface { - ImplementsAccountsAccountGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AccountGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AccountUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` +type AccountParam struct { // Account name Name param.Field[string] `json:"name,required"` // Account settings - Settings param.Field[AccountUpdateParamsSettings] `json:"settings"` + Settings param.Field[AccountSettingsParam] `json:"settings"` } -func (r AccountUpdateParams) MarshalJSON() (data []byte, err error) { +func (r AccountParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Account settings -type AccountUpdateParamsSettings struct { +type AccountSettingsParam struct { // Specifies the default nameservers to be used for new zones added to this // account. // @@ -246,7 +210,7 @@ type AccountUpdateParamsSettings struct { // See // [Custom Nameservers](https://developers.cloudflare.com/dns/additional-options/custom-nameservers/) // for more information. - DefaultNameservers param.Field[AccountUpdateParamsSettingsDefaultNameservers] `json:"default_nameservers"` + DefaultNameservers param.Field[AccountSettingsDefaultNameservers] `json:"default_nameservers"` // Indicates whether membership in this account requires that Two-Factor // Authentication is enabled EnforceTwofactor param.Field[bool] `json:"enforce_twofactor"` @@ -257,40 +221,58 @@ type AccountUpdateParamsSettings struct { UseAccountCustomNSByDefault param.Field[bool] `json:"use_account_custom_ns_by_default"` } -func (r AccountUpdateParamsSettings) MarshalJSON() (data []byte, err error) { +func (r AccountSettingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Specifies the default nameservers to be used for new zones added to this -// account. -// -// - `cloudflare.standard` for Cloudflare-branded nameservers -// - `custom.account` for account custom nameservers -// - `custom.tenant` for tenant custom nameservers -// -// See -// [Custom Nameservers](https://developers.cloudflare.com/dns/additional-options/custom-nameservers/) -// for more information. -type AccountUpdateParamsSettingsDefaultNameservers string +// Union satisfied by [accounts.AccountUpdateResponseUnknown] or +// [shared.UnionString]. +type AccountUpdateResponseUnion interface { + ImplementsAccountsAccountUpdateResponseUnion() +} -const ( - AccountUpdateParamsSettingsDefaultNameserversCloudflareStandard AccountUpdateParamsSettingsDefaultNameservers = "cloudflare.standard" - AccountUpdateParamsSettingsDefaultNameserversCustomAccount AccountUpdateParamsSettingsDefaultNameservers = "custom.account" - AccountUpdateParamsSettingsDefaultNameserversCustomTenant AccountUpdateParamsSettingsDefaultNameservers = "custom.tenant" -) +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccountUpdateResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} -func (r AccountUpdateParamsSettingsDefaultNameservers) IsKnown() bool { - switch r { - case AccountUpdateParamsSettingsDefaultNameserversCloudflareStandard, AccountUpdateParamsSettingsDefaultNameserversCustomAccount, AccountUpdateParamsSettingsDefaultNameserversCustomTenant: - return true - } - return false +type AccountListResponse = interface{} + +// Union satisfied by [accounts.AccountGetResponseUnknown] or [shared.UnionString]. +type AccountGetResponseUnion interface { + ImplementsAccountsAccountGetResponseUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccountGetResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AccountUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + Account AccountParam `json:"account,required"` +} + +func (r AccountUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Account) } type AccountUpdateResponseEnvelope struct { - Errors []AccountUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AccountUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccountUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success AccountUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accountUpdateResponseEnvelopeJSON `json:"-"` @@ -315,52 +297,6 @@ func (r accountUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccountUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountUpdateResponseEnvelopeErrors] -type accountUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccountUpdateResponseEnvelopeMessages] -type accountUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccountUpdateResponseEnvelopeSuccess bool @@ -379,6 +315,8 @@ func (r AccountUpdateResponseEnvelopeSuccess) IsKnown() bool { type AccountListParams struct { // Direction to order results. Direction param.Field[AccountListParamsDirection] `query:"direction"` + // Name of the account. + Name param.Field[string] `query:"name"` // Page number of paginated results. Page param.Field[float64] `query:"page"` // Maximum number of results per page. @@ -388,7 +326,7 @@ type AccountListParams struct { // URLQuery serializes [AccountListParams]'s query parameters as `url.Values`. func (r AccountListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -414,9 +352,9 @@ type AccountGetParams struct { } type AccountGetResponseEnvelope struct { - Errors []AccountGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountGetResponseEnvelopeMessages `json:"messages,required"` - Result AccountGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccountGetResponseUnion `json:"result,required"` // Whether the API call was successful Success AccountGetResponseEnvelopeSuccess `json:"success,required"` JSON accountGetResponseEnvelopeJSON `json:"-"` @@ -441,52 +379,6 @@ func (r accountGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccountGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AccountGetResponseEnvelopeErrors] -type accountGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AccountGetResponseEnvelopeMessages] -type accountGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccountGetResponseEnvelopeSuccess bool diff --git a/accounts/account_test.go b/accounts/account_test.go index 45dd10917a7..498f9e3410f 100644 --- a/accounts/account_test.go +++ b/accounts/account_test.go @@ -30,12 +30,14 @@ func TestAccountUpdateWithOptionalParams(t *testing.T) { ) _, err := client.Accounts.Update(context.TODO(), accounts.AccountUpdateParams{ AccountID: cloudflare.F[any](map[string]interface{}{}), - Name: cloudflare.F("Demo Account"), - Settings: cloudflare.F(accounts.AccountUpdateParamsSettings{ - DefaultNameservers: cloudflare.F(accounts.AccountUpdateParamsSettingsDefaultNameserversCloudflareStandard), - EnforceTwofactor: cloudflare.F(true), - UseAccountCustomNSByDefault: cloudflare.F(true), - }), + Account: accounts.AccountParam{ + Name: cloudflare.F("Demo Account"), + Settings: cloudflare.F(accounts.AccountSettingsParam{ + DefaultNameservers: cloudflare.F(accounts.AccountSettingsDefaultNameserversCloudflareStandard), + EnforceTwofactor: cloudflare.F(true), + UseAccountCustomNSByDefault: cloudflare.F(true), + }), + }, }) if err != nil { var apierr *cloudflare.Error @@ -62,6 +64,7 @@ func TestAccountListWithOptionalParams(t *testing.T) { ) _, err := client.Accounts.List(context.TODO(), accounts.AccountListParams{ Direction: cloudflare.F(accounts.AccountListParamsDirectionDesc), + Name: cloudflare.F("example.com"), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), }) diff --git a/accounts/aliases.go b/accounts/aliases.go index d91f05f5a5a..371b3e9d2ae 100644 --- a/accounts/aliases.go +++ b/accounts/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/accounts/member.go b/accounts/member.go index 0bcd49d2fb2..733f670c13a 100644 --- a/accounts/member.go +++ b/accounts/member.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -34,7 +35,7 @@ func NewMemberService(opts ...option.RequestOption) (r *MemberService) { } // Add a user to the list of members for this account. -func (r *MemberService) New(ctx context.Context, params MemberNewParams, opts ...option.RequestOption) (res *AccountMemberWithID, err error) { +func (r *MemberService) New(ctx context.Context, params MemberNewParams, opts ...option.RequestOption) (res *UserWithInviteCode, err error) { opts = append(r.Options[:], opts...) var env MemberNewResponseEnvelope path := fmt.Sprintf("accounts/%v/members", params.AccountID) @@ -47,7 +48,7 @@ func (r *MemberService) New(ctx context.Context, params MemberNewParams, opts .. } // Modify an account member. -func (r *MemberService) Update(ctx context.Context, memberID string, params MemberUpdateParams, opts ...option.RequestOption) (res *AccountMember, err error) { +func (r *MemberService) Update(ctx context.Context, memberID string, params MemberUpdateParams, opts ...option.RequestOption) (res *shared.User, err error) { opts = append(r.Options[:], opts...) var env MemberUpdateResponseEnvelope path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID) @@ -83,825 +84,137 @@ func (r *MemberService) ListAutoPaging(ctx context.Context, params MemberListPar } // Remove a member from an account. -func (r *MemberService) Delete(ctx context.Context, memberID string, body MemberDeleteParams, opts ...option.RequestOption) (res *MemberDeleteResponse, err error) { +func (r *MemberService) Delete(ctx context.Context, memberID string, params MemberDeleteParams, opts ...option.RequestOption) (res *MemberDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env MemberDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/members/%s", body.AccountID, memberID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get information about a specific member of an account. -func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGetParams, opts ...option.RequestOption) (res *AccountMember, err error) { - opts = append(r.Options[:], opts...) - var env MemberGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/members/%s", query.AccountID, memberID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AccountMember struct { - // Membership identifier tag. - ID string `json:"id,required"` - // Roles assigned to this member. - Roles []AccountMemberRole `json:"roles,required"` - Status interface{} `json:"status,required"` - User AccountMemberUser `json:"user,required"` - JSON accountMemberJSON `json:"-"` -} - -// accountMemberJSON contains the JSON metadata for the struct [AccountMember] -type accountMemberJSON struct { - ID apijson.Field - Roles apijson.Field - Status apijson.Field - User apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMember) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role name. - Name string `json:"name,required"` - Permissions AccountMemberRolesPermissions `json:"permissions,required"` - JSON accountMemberRoleJSON `json:"-"` -} - -// accountMemberRoleJSON contains the JSON metadata for the struct -// [AccountMemberRole] -type accountMemberRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRoleJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissions struct { - Analytics AccountMemberRolesPermissionsAnalytics `json:"analytics"` - Billing AccountMemberRolesPermissionsBilling `json:"billing"` - CachePurge AccountMemberRolesPermissionsCachePurge `json:"cache_purge"` - DNS AccountMemberRolesPermissionsDNS `json:"dns"` - DNSRecords AccountMemberRolesPermissionsDNSRecords `json:"dns_records"` - Lb AccountMemberRolesPermissionsLb `json:"lb"` - Logs AccountMemberRolesPermissionsLogs `json:"logs"` - Organization AccountMemberRolesPermissionsOrganization `json:"organization"` - SSL AccountMemberRolesPermissionsSSL `json:"ssl"` - WAF AccountMemberRolesPermissionsWAF `json:"waf"` - ZoneSettings AccountMemberRolesPermissionsZoneSettings `json:"zone_settings"` - Zones AccountMemberRolesPermissionsZones `json:"zones"` - JSON accountMemberRolesPermissionsJSON `json:"-"` -} - -// accountMemberRolesPermissionsJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissions] -type accountMemberRolesPermissionsJSON 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 *AccountMemberRolesPermissions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsAnalytics struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsAnalyticsJSON `json:"-"` -} - -// accountMemberRolesPermissionsAnalyticsJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsAnalytics] -type accountMemberRolesPermissionsAnalyticsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsAnalytics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsAnalyticsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsBilling struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsBillingJSON `json:"-"` -} - -// accountMemberRolesPermissionsBillingJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsBilling] -type accountMemberRolesPermissionsBillingJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsBilling) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsBillingJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsCachePurge struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsCachePurgeJSON `json:"-"` -} - -// accountMemberRolesPermissionsCachePurgeJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsCachePurge] -type accountMemberRolesPermissionsCachePurgeJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsCachePurge) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsCachePurgeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsDNS struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsDNSJSON `json:"-"` -} - -// accountMemberRolesPermissionsDNSJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsDNS] -type accountMemberRolesPermissionsDNSJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsDNSJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsDNSRecords struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsDNSRecordsJSON `json:"-"` -} - -// accountMemberRolesPermissionsDNSRecordsJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsDNSRecords] -type accountMemberRolesPermissionsDNSRecordsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsDNSRecords) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsDNSRecordsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsLb struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsLbJSON `json:"-"` -} - -// accountMemberRolesPermissionsLbJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsLb] -type accountMemberRolesPermissionsLbJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsLb) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsLbJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsLogs struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsLogsJSON `json:"-"` -} - -// accountMemberRolesPermissionsLogsJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsLogs] -type accountMemberRolesPermissionsLogsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsLogs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsLogsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsOrganization struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsOrganizationJSON `json:"-"` -} - -// accountMemberRolesPermissionsOrganizationJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsOrganization] -type accountMemberRolesPermissionsOrganizationJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsOrganizationJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsSSL struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsSSLJSON `json:"-"` -} - -// accountMemberRolesPermissionsSSLJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsSSL] -type accountMemberRolesPermissionsSSLJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsSSLJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsWAF struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsWAFJSON `json:"-"` -} - -// accountMemberRolesPermissionsWAFJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsWAF] -type accountMemberRolesPermissionsWAFJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsWAF) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsWAFJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsZoneSettings struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsZoneSettingsJSON `json:"-"` -} - -// accountMemberRolesPermissionsZoneSettingsJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsZoneSettings] -type accountMemberRolesPermissionsZoneSettingsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsZoneSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsZoneSettingsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsZones struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsZonesJSON `json:"-"` -} - -// accountMemberRolesPermissionsZonesJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsZones] -type accountMemberRolesPermissionsZonesJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsZones) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsZonesJSON) RawJSON() string { - return r.raw -} - -type AccountMemberUser struct { - // The contact email address of the user. - Email string `json:"email,required"` - // Identifier - ID string `json:"id"` - // User's first name - FirstName string `json:"first_name,nullable"` - // User's last name - LastName string `json:"last_name,nullable"` - // Indicates whether two-factor authentication is enabled for the user account. - // Does not apply to API authentication. - TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` - JSON accountMemberUserJSON `json:"-"` -} - -// accountMemberUserJSON contains the JSON metadata for the struct -// [AccountMemberUser] -type accountMemberUserJSON struct { - Email apijson.Field - ID apijson.Field - FirstName apijson.Field - LastName apijson.Field - TwoFactorAuthenticationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberUser) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberUserJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithID struct { - // Membership identifier tag. - ID string `json:"id,required"` - // Roles assigned to this member. - Roles []AccountMemberWithIDRole `json:"roles,required"` - Status interface{} `json:"status,required"` - User AccountMemberWithIDUser `json:"user,required"` - // The unique activation code for the account membership. - Code string `json:"code"` - JSON accountMemberWithIDJSON `json:"-"` -} - -// accountMemberWithIDJSON contains the JSON metadata for the struct -// [AccountMemberWithID] -type accountMemberWithIDJSON struct { - ID apijson.Field - Roles apijson.Field - Status apijson.Field - User apijson.Field - Code apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithID) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role name. - Name string `json:"name,required"` - Permissions AccountMemberWithIDRolesPermissions `json:"permissions,required"` - JSON accountMemberWithIDRoleJSON `json:"-"` -} - -// accountMemberWithIDRoleJSON contains the JSON metadata for the struct -// [AccountMemberWithIDRole] -type accountMemberWithIDRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRoleJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissions struct { - Analytics AccountMemberWithIDRolesPermissionsAnalytics `json:"analytics"` - Billing AccountMemberWithIDRolesPermissionsBilling `json:"billing"` - CachePurge AccountMemberWithIDRolesPermissionsCachePurge `json:"cache_purge"` - DNS AccountMemberWithIDRolesPermissionsDNS `json:"dns"` - DNSRecords AccountMemberWithIDRolesPermissionsDNSRecords `json:"dns_records"` - Lb AccountMemberWithIDRolesPermissionsLb `json:"lb"` - Logs AccountMemberWithIDRolesPermissionsLogs `json:"logs"` - Organization AccountMemberWithIDRolesPermissionsOrganization `json:"organization"` - SSL AccountMemberWithIDRolesPermissionsSSL `json:"ssl"` - WAF AccountMemberWithIDRolesPermissionsWAF `json:"waf"` - ZoneSettings AccountMemberWithIDRolesPermissionsZoneSettings `json:"zone_settings"` - Zones AccountMemberWithIDRolesPermissionsZones `json:"zones"` - JSON accountMemberWithIDRolesPermissionsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissions] -type accountMemberWithIDRolesPermissionsJSON 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 *AccountMemberWithIDRolesPermissions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsAnalytics struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsAnalyticsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsAnalyticsJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsAnalytics] -type accountMemberWithIDRolesPermissionsAnalyticsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsAnalytics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsAnalyticsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsBilling struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsBillingJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsBillingJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsBilling] -type accountMemberWithIDRolesPermissionsBillingJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsBilling) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsBillingJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsCachePurge struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsCachePurgeJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsCachePurgeJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsCachePurge] -type accountMemberWithIDRolesPermissionsCachePurgeJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsCachePurge) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsCachePurgeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsDNS struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsDNSJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsDNSJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsDNS] -type accountMemberWithIDRolesPermissionsDNSJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsDNSJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsDNSRecords struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsDNSRecordsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsDNSRecordsJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsDNSRecords] -type accountMemberWithIDRolesPermissionsDNSRecordsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsDNSRecords) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsDNSRecordsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsLb struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsLbJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsLbJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsLb] -type accountMemberWithIDRolesPermissionsLbJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsLb) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsLbJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsLogs struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsLogsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsLogsJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsLogs] -type accountMemberWithIDRolesPermissionsLogsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsLogs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsLogsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsOrganization struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsOrganizationJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsOrganizationJSON contains the JSON metadata -// for the struct [AccountMemberWithIDRolesPermissionsOrganization] -type accountMemberWithIDRolesPermissionsOrganizationJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsOrganizationJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsSSL struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsSSLJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsSSLJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsSSL] -type accountMemberWithIDRolesPermissionsSSLJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return } -func (r accountMemberWithIDRolesPermissionsSSLJSON) RawJSON() string { - return r.raw +// Get information about a specific member of an account. +func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGetParams, opts ...option.RequestOption) (res *shared.User, err error) { + opts = append(r.Options[:], opts...) + var env MemberGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/members/%s", query.AccountID, memberID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return } -type AccountMemberWithIDRolesPermissionsWAF struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsWAFJSON `json:"-"` +type UserWithInviteCode struct { + // Membership identifier tag. + ID string `json:"id,required"` + // Roles assigned to this member. + Roles []UserWithInviteCodeRole `json:"roles,required"` + Status interface{} `json:"status,required"` + User UserWithInviteCodeUser `json:"user,required"` + // The unique activation code for the account membership. + Code string `json:"code"` + JSON userWithInviteCodeJSON `json:"-"` } -// accountMemberWithIDRolesPermissionsWAFJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsWAF] -type accountMemberWithIDRolesPermissionsWAFJSON struct { - Read apijson.Field - Write apijson.Field +// userWithInviteCodeJSON contains the JSON metadata for the struct +// [UserWithInviteCode] +type userWithInviteCodeJSON struct { + ID apijson.Field + Roles apijson.Field + Status apijson.Field + User apijson.Field + Code apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AccountMemberWithIDRolesPermissionsWAF) UnmarshalJSON(data []byte) (err error) { +func (r *UserWithInviteCode) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r accountMemberWithIDRolesPermissionsWAFJSON) RawJSON() string { +func (r userWithInviteCodeJSON) RawJSON() string { return r.raw } -type AccountMemberWithIDRolesPermissionsZoneSettings struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsZoneSettingsJSON `json:"-"` +type UserWithInviteCodeRole struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role name. + Name string `json:"name,required"` + Permissions UserWithInviteCodeRolesPermissions `json:"permissions,required"` + JSON userWithInviteCodeRoleJSON `json:"-"` } -// accountMemberWithIDRolesPermissionsZoneSettingsJSON contains the JSON metadata -// for the struct [AccountMemberWithIDRolesPermissionsZoneSettings] -type accountMemberWithIDRolesPermissionsZoneSettingsJSON struct { - Read apijson.Field - Write apijson.Field +// userWithInviteCodeRoleJSON contains the JSON metadata for the struct +// [UserWithInviteCodeRole] +type userWithInviteCodeRoleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AccountMemberWithIDRolesPermissionsZoneSettings) UnmarshalJSON(data []byte) (err error) { +func (r *UserWithInviteCodeRole) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r accountMemberWithIDRolesPermissionsZoneSettingsJSON) RawJSON() string { +func (r userWithInviteCodeRoleJSON) RawJSON() string { return r.raw } -type AccountMemberWithIDRolesPermissionsZones struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsZonesJSON `json:"-"` +type UserWithInviteCodeRolesPermissions struct { + Analytics shared.PermissionGrant `json:"analytics"` + Billing shared.PermissionGrant `json:"billing"` + CachePurge shared.PermissionGrant `json:"cache_purge"` + DNS shared.PermissionGrant `json:"dns"` + DNSRecords shared.PermissionGrant `json:"dns_records"` + LB shared.PermissionGrant `json:"lb"` + Logs shared.PermissionGrant `json:"logs"` + Organization shared.PermissionGrant `json:"organization"` + SSL shared.PermissionGrant `json:"ssl"` + WAF shared.PermissionGrant `json:"waf"` + ZoneSettings shared.PermissionGrant `json:"zone_settings"` + Zones shared.PermissionGrant `json:"zones"` + JSON userWithInviteCodeRolesPermissionsJSON `json:"-"` } -// accountMemberWithIDRolesPermissionsZonesJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsZones] -type accountMemberWithIDRolesPermissionsZonesJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field +// userWithInviteCodeRolesPermissionsJSON contains the JSON metadata for the struct +// [UserWithInviteCodeRolesPermissions] +type userWithInviteCodeRolesPermissionsJSON 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 *AccountMemberWithIDRolesPermissionsZones) UnmarshalJSON(data []byte) (err error) { +func (r *UserWithInviteCodeRolesPermissions) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r accountMemberWithIDRolesPermissionsZonesJSON) RawJSON() string { +func (r userWithInviteCodeRolesPermissionsJSON) RawJSON() string { return r.raw } -type AccountMemberWithIDUser struct { +type UserWithInviteCodeUser struct { // The contact email address of the user. Email string `json:"email,required"` // Identifier @@ -912,13 +225,13 @@ type AccountMemberWithIDUser struct { LastName string `json:"last_name,nullable"` // Indicates whether two-factor authentication is enabled for the user account. // Does not apply to API authentication. - TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` - JSON accountMemberWithIDUserJSON `json:"-"` + TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` + JSON userWithInviteCodeUserJSON `json:"-"` } -// accountMemberWithIDUserJSON contains the JSON metadata for the struct -// [AccountMemberWithIDUser] -type accountMemberWithIDUserJSON struct { +// userWithInviteCodeUserJSON contains the JSON metadata for the struct +// [UserWithInviteCodeUser] +type userWithInviteCodeUserJSON struct { Email apijson.Field ID apijson.Field FirstName apijson.Field @@ -928,11 +241,11 @@ type accountMemberWithIDUserJSON struct { ExtraFields map[string]apijson.Field } -func (r *AccountMemberWithIDUser) UnmarshalJSON(data []byte) (err error) { +func (r *UserWithInviteCodeUser) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r accountMemberWithIDUserJSON) RawJSON() string { +func (r userWithInviteCodeUserJSON) RawJSON() string { return r.raw } @@ -944,7 +257,7 @@ type MemberListResponse struct { // Member Name. Name string `json:"name,required,nullable"` // Roles assigned to this Member. - Roles []Role `json:"roles,required"` + Roles []shared.Role `json:"roles,required"` // A member's status in the organization. Status MemberListResponseStatus `json:"status,required"` JSON memberListResponseJSON `json:"-"` @@ -1037,9 +350,9 @@ func (r MemberNewParamsStatus) IsKnown() bool { } type MemberNewResponseEnvelope struct { - Errors []MemberNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MemberNewResponseEnvelopeMessages `json:"messages,required"` - Result AccountMemberWithID `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UserWithInviteCode `json:"result,required"` // Whether the API call was successful Success MemberNewResponseEnvelopeSuccess `json:"success,required"` JSON memberNewResponseEnvelopeJSON `json:"-"` @@ -1064,52 +377,6 @@ func (r memberNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MemberNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// memberNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MemberNewResponseEnvelopeErrors] -type memberNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MemberNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// memberNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [MemberNewResponseEnvelopeMessages] -type memberNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MemberNewResponseEnvelopeSuccess bool @@ -1127,154 +394,17 @@ func (r MemberNewResponseEnvelopeSuccess) IsKnown() bool { type MemberUpdateParams struct { AccountID param.Field[interface{}] `path:"account_id,required"` - // Roles assigned to this member. - Roles param.Field[[]MemberUpdateParamsRole] `json:"roles,required"` + User shared.UserParam `json:"user,required"` } func (r MemberUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRole struct { - // Role identifier tag. - ID param.Field[string] `json:"id,required"` -} - -func (r MemberUpdateParamsRole) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissions struct { - Analytics param.Field[MemberUpdateParamsRolesPermissionsAnalytics] `json:"analytics"` - Billing param.Field[MemberUpdateParamsRolesPermissionsBilling] `json:"billing"` - CachePurge param.Field[MemberUpdateParamsRolesPermissionsCachePurge] `json:"cache_purge"` - DNS param.Field[MemberUpdateParamsRolesPermissionsDNS] `json:"dns"` - DNSRecords param.Field[MemberUpdateParamsRolesPermissionsDNSRecords] `json:"dns_records"` - Lb param.Field[MemberUpdateParamsRolesPermissionsLb] `json:"lb"` - Logs param.Field[MemberUpdateParamsRolesPermissionsLogs] `json:"logs"` - Organization param.Field[MemberUpdateParamsRolesPermissionsOrganization] `json:"organization"` - SSL param.Field[MemberUpdateParamsRolesPermissionsSSL] `json:"ssl"` - WAF param.Field[MemberUpdateParamsRolesPermissionsWAF] `json:"waf"` - ZoneSettings param.Field[MemberUpdateParamsRolesPermissionsZoneSettings] `json:"zone_settings"` - Zones param.Field[MemberUpdateParamsRolesPermissionsZones] `json:"zones"` -} - -func (r MemberUpdateParamsRolesPermissions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsAnalytics struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsAnalytics) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsBilling struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsBilling) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsCachePurge struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsCachePurge) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsDNS struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsDNSRecords struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsDNSRecords) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsLb struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsLb) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsLogs struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsLogs) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsOrganization struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsSSL struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsSSL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsWAF struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsWAF) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsZoneSettings struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsZoneSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MemberUpdateParamsRolesPermissionsZones struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r MemberUpdateParamsRolesPermissionsZones) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.User) } type MemberUpdateResponseEnvelope struct { - Errors []MemberUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MemberUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AccountMember `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result shared.User `json:"result,required"` // Whether the API call was successful Success MemberUpdateResponseEnvelopeSuccess `json:"success,required"` JSON memberUpdateResponseEnvelopeJSON `json:"-"` @@ -1299,52 +429,6 @@ func (r memberUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MemberUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// memberUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MemberUpdateResponseEnvelopeErrors] -type memberUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MemberUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// memberUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MemberUpdateResponseEnvelopeMessages] -type memberUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MemberUpdateResponseEnvelopeSuccess bool @@ -1377,7 +461,7 @@ type MemberListParams struct { // URLQuery serializes [MemberListParams]'s query parameters as `url.Values`. func (r MemberListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1435,12 +519,17 @@ func (r MemberListParamsStatus) IsKnown() bool { type MemberDeleteParams struct { AccountID param.Field[interface{}] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r MemberDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type MemberDeleteResponseEnvelope struct { - Errors []MemberDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MemberDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MemberDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MemberDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success MemberDeleteResponseEnvelopeSuccess `json:"success,required"` JSON memberDeleteResponseEnvelopeJSON `json:"-"` @@ -1465,52 +554,6 @@ func (r memberDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MemberDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// memberDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MemberDeleteResponseEnvelopeErrors] -type memberDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MemberDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// memberDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MemberDeleteResponseEnvelopeMessages] -type memberDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MemberDeleteResponseEnvelopeSuccess bool @@ -1531,9 +574,9 @@ type MemberGetParams struct { } type MemberGetResponseEnvelope struct { - Errors []MemberGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MemberGetResponseEnvelopeMessages `json:"messages,required"` - Result AccountMember `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result shared.User `json:"result,required"` // Whether the API call was successful Success MemberGetResponseEnvelopeSuccess `json:"success,required"` JSON memberGetResponseEnvelopeJSON `json:"-"` @@ -1558,52 +601,6 @@ func (r memberGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MemberGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// memberGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MemberGetResponseEnvelopeErrors] -type memberGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MemberGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON memberGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// memberGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [MemberGetResponseEnvelopeMessages] -type memberGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MemberGetResponseEnvelopeSuccess bool diff --git a/accounts/member_test.go b/accounts/member_test.go index b78f5f7ef8f..1834134f9e9 100644 --- a/accounts/member_test.go +++ b/accounts/member_test.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2" "github.com/cloudflare/cloudflare-go/v2/accounts" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -62,13 +63,15 @@ func TestMemberUpdate(t *testing.T) { "4536bcfad5faccb111b47003c79917fa", accounts.MemberUpdateParams{ AccountID: cloudflare.F[any](map[string]interface{}{}), - Roles: cloudflare.F([]accounts.MemberUpdateParamsRole{{ - ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), - }, { - ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), - }, { - ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), - }}), + User: shared.UserParam{ + Roles: cloudflare.F([]shared.UserRoleParam{{ + ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), + }, { + ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), + }, { + ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), + }}), + }, }, ) if err != nil { @@ -130,6 +133,7 @@ func TestMemberDelete(t *testing.T) { "4536bcfad5faccb111b47003c79917fa", accounts.MemberDeleteParams{ AccountID: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/accounts/role.go b/accounts/role.go index f20d031c41f..7f17cfabe52 100644 --- a/accounts/role.go +++ b/accounts/role.go @@ -35,7 +35,7 @@ func NewRoleService(opts ...option.RequestOption) (r *RoleService) { } // Get all available roles for an account. -func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Role], err error) { +func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[shared.Role], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -53,12 +53,12 @@ func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...op } // Get all available roles for an account. -func (r *RoleService) ListAutoPaging(ctx context.Context, query RoleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Role] { +func (r *RoleService) ListAutoPaging(ctx context.Context, query RoleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[shared.Role] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Get information about a specific role for an account. -func (r *RoleService) Get(ctx context.Context, roleID interface{}, query RoleGetParams, opts ...option.RequestOption) (res *RoleGetResponse, err error) { +func (r *RoleService) Get(ctx context.Context, roleID interface{}, query RoleGetParams, opts ...option.RequestOption) (res *RoleGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RoleGetResponseEnvelope path := fmt.Sprintf("accounts/%v/roles/%v", query.AccountID, roleID) @@ -70,44 +70,14 @@ func (r *RoleService) Get(ctx context.Context, roleID interface{}, query RoleGet return } -type Role struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role Name. - Name string `json:"name,required"` - // Access permissions for this User. - Permissions []string `json:"permissions,required"` - JSON roleJSON `json:"-"` -} - -// roleJSON contains the JSON metadata for the struct [Role] -type roleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Role) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r roleJSON) RawJSON() string { - return r.raw -} - // Union satisfied by [accounts.RoleGetResponseUnknown] or [shared.UnionString]. -type RoleGetResponse interface { - ImplementsAccountsRoleGetResponse() +type RoleGetResponseUnion interface { + ImplementsAccountsRoleGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RoleGetResponse)(nil)).Elem(), + reflect.TypeOf((*RoleGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -125,9 +95,9 @@ type RoleGetParams struct { } type RoleGetResponseEnvelope struct { - Errors []RoleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RoleGetResponseEnvelopeMessages `json:"messages,required"` - Result RoleGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RoleGetResponseUnion `json:"result,required"` // Whether the API call was successful Success RoleGetResponseEnvelopeSuccess `json:"success,required"` JSON roleGetResponseEnvelopeJSON `json:"-"` @@ -152,52 +122,6 @@ func (r roleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RoleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON roleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// roleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RoleGetResponseEnvelopeErrors] -type roleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RoleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r roleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RoleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON roleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// roleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RoleGetResponseEnvelopeMessages] -type roleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RoleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r roleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RoleGetResponseEnvelopeSuccess bool diff --git a/acm/aliases.go b/acm/aliases.go index e2f05d0ff02..cb3afa2b2c6 100644 --- a/acm/aliases.go +++ b/acm/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/acm/totaltls.go b/acm/totaltls.go index 079e6d43d50..67c685dd2ac 100644 --- a/acm/totaltls.go +++ b/acm/totaltls.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -207,9 +208,9 @@ func (r TotalTLSNewParamsCertificateAuthority) IsKnown() bool { } type TotalTLSNewResponseEnvelope struct { - Errors []TotalTLSNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TotalTLSNewResponseEnvelopeMessages `json:"messages,required"` - Result TotalTLSNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TotalTLSNewResponse `json:"result,required"` // Whether the API call was successful Success TotalTLSNewResponseEnvelopeSuccess `json:"success,required"` JSON totalTLSNewResponseEnvelopeJSON `json:"-"` @@ -234,52 +235,6 @@ func (r totalTLSNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TotalTLSNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON totalTLSNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// totalTLSNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TotalTLSNewResponseEnvelopeErrors] -type totalTLSNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TotalTLSNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r totalTLSNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TotalTLSNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON totalTLSNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// totalTLSNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TotalTLSNewResponseEnvelopeMessages] -type totalTLSNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TotalTLSNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r totalTLSNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TotalTLSNewResponseEnvelopeSuccess bool @@ -301,9 +256,9 @@ type TotalTLSGetParams struct { } type TotalTLSGetResponseEnvelope struct { - Errors []TotalTLSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TotalTLSGetResponseEnvelopeMessages `json:"messages,required"` - Result TotalTLSGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TotalTLSGetResponse `json:"result,required"` // Whether the API call was successful Success TotalTLSGetResponseEnvelopeSuccess `json:"success,required"` JSON totalTLSGetResponseEnvelopeJSON `json:"-"` @@ -328,52 +283,6 @@ func (r totalTLSGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TotalTLSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON totalTLSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// totalTLSGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TotalTLSGetResponseEnvelopeErrors] -type totalTLSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TotalTLSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r totalTLSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TotalTLSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON totalTLSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// totalTLSGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TotalTLSGetResponseEnvelopeMessages] -type totalTLSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TotalTLSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r totalTLSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TotalTLSGetResponseEnvelopeSuccess bool diff --git a/addressing/addressmap.go b/addressing/addressmap.go index 8644e8d297e..83e28d9eea9 100644 --- a/addressing/addressmap.go +++ b/addressing/addressmap.go @@ -55,7 +55,7 @@ func (r *AddressMapService) New(ctx context.Context, params AddressMapNewParams, } // List all address maps owned by the account. -func (r *AddressMapService) List(ctx context.Context, query AddressMapListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AddressingAddressMaps], err error) { +func (r *AddressMapService) List(ctx context.Context, query AddressMapListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AddressMap], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -73,16 +73,16 @@ func (r *AddressMapService) List(ctx context.Context, query AddressMapListParams } // List all address maps owned by the account. -func (r *AddressMapService) ListAutoPaging(ctx context.Context, query AddressMapListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AddressingAddressMaps] { +func (r *AddressMapService) ListAutoPaging(ctx context.Context, query AddressMapListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AddressMap] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete a particular address map owned by the account. An Address Map must be // disabled before it can be deleted. -func (r *AddressMapService) Delete(ctx context.Context, addressMapID string, body AddressMapDeleteParams, opts ...option.RequestOption) (res *AddressMapDeleteResponse, err error) { +func (r *AddressMapService) Delete(ctx context.Context, addressMapID string, params AddressMapDeleteParams, opts ...option.RequestOption) (res *AddressMapDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AddressMapDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", body.AccountID, addressMapID) + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", params.AccountID, addressMapID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -92,7 +92,7 @@ func (r *AddressMapService) Delete(ctx context.Context, addressMapID string, bod } // Modify properties of an address map owned by the account. -func (r *AddressMapService) Edit(ctx context.Context, addressMapID string, params AddressMapEditParams, opts ...option.RequestOption) (res *AddressingAddressMaps, err error) { +func (r *AddressMapService) Edit(ctx context.Context, addressMapID string, params AddressMapEditParams, opts ...option.RequestOption) (res *AddressMap, err error) { opts = append(r.Options[:], opts...) var env AddressMapEditResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", params.AccountID, addressMapID) @@ -117,7 +117,7 @@ func (r *AddressMapService) Get(ctx context.Context, addressMapID string, query return } -type AddressingAddressMaps struct { +type AddressMap struct { // Identifier ID string `json:"id"` // If set to false, then the Address Map cannot be deleted via API. This is true @@ -138,14 +138,13 @@ type AddressingAddressMaps struct { Description string `json:"description,nullable"` // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond // with IP addresses on an Address Map until the map is enabled. - Enabled bool `json:"enabled,nullable"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - JSON addressingAddressMapsJSON `json:"-"` + Enabled bool `json:"enabled,nullable"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + JSON addressMapJSON `json:"-"` } -// addressingAddressMapsJSON contains the JSON metadata for the struct -// [AddressingAddressMaps] -type addressingAddressMapsJSON struct { +// addressMapJSON contains the JSON metadata for the struct [AddressMap] +type addressMapJSON struct { ID apijson.Field CanDelete apijson.Field CanModifyIPs apijson.Field @@ -158,11 +157,11 @@ type addressingAddressMapsJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressingAddressMaps) UnmarshalJSON(data []byte) (err error) { +func (r *AddressMap) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingAddressMapsJSON) RawJSON() string { +func (r addressMapJSON) RawJSON() string { return r.raw } @@ -294,13 +293,13 @@ func (r AddressMapNewResponseMembershipsKind) IsKnown() bool { // Union satisfied by [addressing.AddressMapDeleteResponseUnknown], // [addressing.AddressMapDeleteResponseArray] or [shared.UnionString]. -type AddressMapDeleteResponse interface { - ImplementsAddressingAddressMapDeleteResponse() +type AddressMapDeleteResponseUnion interface { + ImplementsAddressingAddressMapDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AddressMapDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*AddressMapDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -315,7 +314,7 @@ func init() { type AddressMapDeleteResponseArray []interface{} -func (r AddressMapDeleteResponseArray) ImplementsAddressingAddressMapDeleteResponse() {} +func (r AddressMapDeleteResponseArray) ImplementsAddressingAddressMapDeleteResponseUnion() {} type AddressMapGetResponse struct { // Identifier @@ -459,9 +458,9 @@ func (r AddressMapNewParams) MarshalJSON() (data []byte, err error) { } type AddressMapNewResponseEnvelope struct { - Errors []AddressMapNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapNewResponse `json:"result,required"` // Whether the API call was successful Success AddressMapNewResponseEnvelopeSuccess `json:"success,required"` JSON addressMapNewResponseEnvelopeJSON `json:"-"` @@ -486,52 +485,6 @@ func (r addressMapNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressMapNewResponseEnvelopeErrors] -type addressMapNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AddressMapNewResponseEnvelopeMessages] -type addressMapNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapNewResponseEnvelopeSuccess bool @@ -555,12 +508,17 @@ type AddressMapListParams struct { type AddressMapDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r AddressMapDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type AddressMapDeleteResponseEnvelope struct { - Errors []AddressMapDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AddressMapDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo AddressMapDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -587,52 +545,6 @@ func (r addressMapDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressMapDeleteResponseEnvelopeErrors] -type addressMapDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AddressMapDeleteResponseEnvelopeMessages] -type addressMapDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapDeleteResponseEnvelopeSuccess bool @@ -701,9 +613,9 @@ func (r AddressMapEditParams) MarshalJSON() (data []byte, err error) { } type AddressMapEditResponseEnvelope struct { - Errors []AddressMapEditResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapEditResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMaps `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMap `json:"result,required"` // Whether the API call was successful Success AddressMapEditResponseEnvelopeSuccess `json:"success,required"` JSON addressMapEditResponseEnvelopeJSON `json:"-"` @@ -728,52 +640,6 @@ func (r addressMapEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressMapEditResponseEnvelopeErrors] -type addressMapEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AddressMapEditResponseEnvelopeMessages] -type addressMapEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapEditResponseEnvelopeSuccess bool @@ -795,9 +661,9 @@ type AddressMapGetParams struct { } type AddressMapGetResponseEnvelope struct { - Errors []AddressMapGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapGetResponse `json:"result,required"` // Whether the API call was successful Success AddressMapGetResponseEnvelopeSuccess `json:"success,required"` JSON addressMapGetResponseEnvelopeJSON `json:"-"` @@ -822,52 +688,6 @@ func (r addressMapGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressMapGetResponseEnvelopeErrors] -type addressMapGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AddressMapGetResponseEnvelopeMessages] -type addressMapGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapGetResponseEnvelopeSuccess bool diff --git a/addressing/addressmap_test.go b/addressing/addressmap_test.go index dce9f55ef0f..301c5faef90 100644 --- a/addressing/addressmap_test.go +++ b/addressing/addressmap_test.go @@ -87,6 +87,7 @@ func TestAddressMapDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", addressing.AddressMapDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/addressing/addressmapaccount.go b/addressing/addressmapaccount.go index 518492f501a..1559ef6fe0c 100644 --- a/addressing/addressmapaccount.go +++ b/addressing/addressmapaccount.go @@ -35,10 +35,10 @@ func NewAddressMapAccountService(opts ...option.RequestOption) (r *AddressMapAcc } // Add an account as a member of a particular address map. -func (r *AddressMapAccountService) Update(ctx context.Context, addressMapID string, body AddressMapAccountUpdateParams, opts ...option.RequestOption) (res *AddressMapAccountUpdateResponse, err error) { +func (r *AddressMapAccountService) Update(ctx context.Context, addressMapID string, params AddressMapAccountUpdateParams, opts ...option.RequestOption) (res *AddressMapAccountUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AddressMapAccountUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID) + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", params.AccountID, addressMapID, params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) if err != nil { return @@ -48,10 +48,10 @@ func (r *AddressMapAccountService) Update(ctx context.Context, addressMapID stri } // Remove an account as a member of a particular address map. -func (r *AddressMapAccountService) Delete(ctx context.Context, addressMapID string, body AddressMapAccountDeleteParams, opts ...option.RequestOption) (res *AddressMapAccountDeleteResponse, err error) { +func (r *AddressMapAccountService) Delete(ctx context.Context, addressMapID string, params AddressMapAccountDeleteParams, opts ...option.RequestOption) (res *AddressMapAccountDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AddressMapAccountDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID) + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", params.AccountID, addressMapID, params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -62,13 +62,13 @@ func (r *AddressMapAccountService) Delete(ctx context.Context, addressMapID stri // Union satisfied by [addressing.AddressMapAccountUpdateResponseUnknown], // [addressing.AddressMapAccountUpdateResponseArray] or [shared.UnionString]. -type AddressMapAccountUpdateResponse interface { - ImplementsAddressingAddressMapAccountUpdateResponse() +type AddressMapAccountUpdateResponseUnion interface { + ImplementsAddressingAddressMapAccountUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AddressMapAccountUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*AddressMapAccountUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -83,17 +83,18 @@ func init() { type AddressMapAccountUpdateResponseArray []interface{} -func (r AddressMapAccountUpdateResponseArray) ImplementsAddressingAddressMapAccountUpdateResponse() {} +func (r AddressMapAccountUpdateResponseArray) ImplementsAddressingAddressMapAccountUpdateResponseUnion() { +} // Union satisfied by [addressing.AddressMapAccountDeleteResponseUnknown], // [addressing.AddressMapAccountDeleteResponseArray] or [shared.UnionString]. -type AddressMapAccountDeleteResponse interface { - ImplementsAddressingAddressMapAccountDeleteResponse() +type AddressMapAccountDeleteResponseUnion interface { + ImplementsAddressingAddressMapAccountDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AddressMapAccountDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*AddressMapAccountDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -108,17 +109,23 @@ func init() { type AddressMapAccountDeleteResponseArray []interface{} -func (r AddressMapAccountDeleteResponseArray) ImplementsAddressingAddressMapAccountDeleteResponse() {} +func (r AddressMapAccountDeleteResponseArray) ImplementsAddressingAddressMapAccountDeleteResponseUnion() { +} type AddressMapAccountUpdateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r AddressMapAccountUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type AddressMapAccountUpdateResponseEnvelope struct { - Errors []AddressMapAccountUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapAccountUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapAccountUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapAccountUpdateResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AddressMapAccountUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo AddressMapAccountUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -145,52 +152,6 @@ func (r addressMapAccountUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapAccountUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapAccountUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapAccountUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressMapAccountUpdateResponseEnvelopeErrors] -type addressMapAccountUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapAccountUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapAccountUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapAccountUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapAccountUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapAccountUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressMapAccountUpdateResponseEnvelopeMessages] -type addressMapAccountUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapAccountUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapAccountUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapAccountUpdateResponseEnvelopeSuccess bool @@ -240,12 +201,17 @@ func (r addressMapAccountUpdateResponseEnvelopeResultInfoJSON) RawJSON() string type AddressMapAccountDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r AddressMapAccountDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type AddressMapAccountDeleteResponseEnvelope struct { - Errors []AddressMapAccountDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapAccountDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapAccountDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapAccountDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AddressMapAccountDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo AddressMapAccountDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -272,52 +238,6 @@ func (r addressMapAccountDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapAccountDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapAccountDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapAccountDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressMapAccountDeleteResponseEnvelopeErrors] -type addressMapAccountDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapAccountDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapAccountDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapAccountDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapAccountDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapAccountDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressMapAccountDeleteResponseEnvelopeMessages] -type addressMapAccountDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapAccountDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapAccountDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapAccountDeleteResponseEnvelopeSuccess bool diff --git a/addressing/addressmapaccount_test.go b/addressing/addressmapaccount_test.go index 391aba283a4..697d6f70988 100644 --- a/addressing/addressmapaccount_test.go +++ b/addressing/addressmapaccount_test.go @@ -33,6 +33,7 @@ func TestAddressMapAccountUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", addressing.AddressMapAccountUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -63,6 +64,7 @@ func TestAddressMapAccountDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", addressing.AddressMapAccountDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/addressing/addressmapip.go b/addressing/addressmapip.go index ded2e5bcc01..8fb1b5cf7b1 100644 --- a/addressing/addressmapip.go +++ b/addressing/addressmapip.go @@ -35,10 +35,10 @@ func NewAddressMapIPService(opts ...option.RequestOption) (r *AddressMapIPServic } // Add an IP from a prefix owned by the account to a particular address map. -func (r *AddressMapIPService) Update(ctx context.Context, addressMapID string, ipAddress string, body AddressMapIPUpdateParams, opts ...option.RequestOption) (res *AddressMapIPUpdateResponse, err error) { +func (r *AddressMapIPService) Update(ctx context.Context, addressMapID string, ipAddress string, params AddressMapIPUpdateParams, opts ...option.RequestOption) (res *AddressMapIPUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AddressMapIPUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress) + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", params.AccountID, addressMapID, ipAddress) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) if err != nil { return @@ -48,10 +48,10 @@ func (r *AddressMapIPService) Update(ctx context.Context, addressMapID string, i } // Remove an IP from a particular address map. -func (r *AddressMapIPService) Delete(ctx context.Context, addressMapID string, ipAddress string, body AddressMapIPDeleteParams, opts ...option.RequestOption) (res *AddressMapIPDeleteResponse, err error) { +func (r *AddressMapIPService) Delete(ctx context.Context, addressMapID string, ipAddress string, params AddressMapIPDeleteParams, opts ...option.RequestOption) (res *AddressMapIPDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AddressMapIPDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress) + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", params.AccountID, addressMapID, ipAddress) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -62,13 +62,13 @@ func (r *AddressMapIPService) Delete(ctx context.Context, addressMapID string, i // Union satisfied by [addressing.AddressMapIPUpdateResponseUnknown], // [addressing.AddressMapIPUpdateResponseArray] or [shared.UnionString]. -type AddressMapIPUpdateResponse interface { - ImplementsAddressingAddressMapIPUpdateResponse() +type AddressMapIPUpdateResponseUnion interface { + ImplementsAddressingAddressMapIPUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AddressMapIPUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*AddressMapIPUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -83,17 +83,17 @@ func init() { type AddressMapIPUpdateResponseArray []interface{} -func (r AddressMapIPUpdateResponseArray) ImplementsAddressingAddressMapIPUpdateResponse() {} +func (r AddressMapIPUpdateResponseArray) ImplementsAddressingAddressMapIPUpdateResponseUnion() {} // Union satisfied by [addressing.AddressMapIPDeleteResponseUnknown], // [addressing.AddressMapIPDeleteResponseArray] or [shared.UnionString]. -type AddressMapIPDeleteResponse interface { - ImplementsAddressingAddressMapIPDeleteResponse() +type AddressMapIPDeleteResponseUnion interface { + ImplementsAddressingAddressMapIPDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AddressMapIPDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*AddressMapIPDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -108,17 +108,22 @@ func init() { type AddressMapIPDeleteResponseArray []interface{} -func (r AddressMapIPDeleteResponseArray) ImplementsAddressingAddressMapIPDeleteResponse() {} +func (r AddressMapIPDeleteResponseArray) ImplementsAddressingAddressMapIPDeleteResponseUnion() {} type AddressMapIPUpdateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r AddressMapIPUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type AddressMapIPUpdateResponseEnvelope struct { - Errors []AddressMapIPUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapIPUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapIPUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapIPUpdateResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AddressMapIPUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo AddressMapIPUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -145,52 +150,6 @@ func (r addressMapIPUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapIPUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapIPUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapIPUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressMapIPUpdateResponseEnvelopeErrors] -type addressMapIPUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapIPUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapIPUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapIPUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapIPUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapIPUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressMapIPUpdateResponseEnvelopeMessages] -type addressMapIPUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapIPUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapIPUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapIPUpdateResponseEnvelopeSuccess bool @@ -240,12 +199,17 @@ func (r addressMapIPUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { type AddressMapIPDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r AddressMapIPDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type AddressMapIPDeleteResponseEnvelope struct { - Errors []AddressMapIPDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapIPDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapIPDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapIPDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AddressMapIPDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo AddressMapIPDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -272,52 +236,6 @@ func (r addressMapIPDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapIPDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapIPDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapIPDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressMapIPDeleteResponseEnvelopeErrors] -type addressMapIPDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapIPDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapIPDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapIPDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapIPDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapIPDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressMapIPDeleteResponseEnvelopeMessages] -type addressMapIPDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapIPDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapIPDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapIPDeleteResponseEnvelopeSuccess bool diff --git a/addressing/addressmapip_test.go b/addressing/addressmapip_test.go index 734467f52f6..4f0c3ebe7d3 100644 --- a/addressing/addressmapip_test.go +++ b/addressing/addressmapip_test.go @@ -34,6 +34,7 @@ func TestAddressMapIPUpdate(t *testing.T) { "192.0.2.1", addressing.AddressMapIPUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -65,6 +66,7 @@ func TestAddressMapIPDelete(t *testing.T) { "192.0.2.1", addressing.AddressMapIPDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/addressing/addressmapzone.go b/addressing/addressmapzone.go index d9e778de29f..399d72e74fe 100644 --- a/addressing/addressmapzone.go +++ b/addressing/addressmapzone.go @@ -35,19 +35,10 @@ func NewAddressMapZoneService(opts ...option.RequestOption) (r *AddressMapZoneSe } // Add a zone as a member of a particular address map. -func (r *AddressMapZoneService) Update(ctx context.Context, addressMapID string, body AddressMapZoneUpdateParams, opts ...option.RequestOption) (res *AddressMapZoneUpdateResponse, err error) { +func (r *AddressMapZoneService) Update(ctx context.Context, addressMapID string, params AddressMapZoneUpdateParams, opts ...option.RequestOption) (res *AddressMapZoneUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AddressMapZoneUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID) + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", params.AccountID, addressMapID, params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) if err != nil { return @@ -57,19 +48,10 @@ func (r *AddressMapZoneService) Update(ctx context.Context, addressMapID string, } // Remove a zone as a member of a particular address map. -func (r *AddressMapZoneService) Delete(ctx context.Context, addressMapID string, body AddressMapZoneDeleteParams, opts ...option.RequestOption) (res *AddressMapZoneDeleteResponse, err error) { +func (r *AddressMapZoneService) Delete(ctx context.Context, addressMapID string, params AddressMapZoneDeleteParams, opts ...option.RequestOption) (res *AddressMapZoneDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AddressMapZoneDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID) + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", params.AccountID, addressMapID, params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -80,13 +62,13 @@ func (r *AddressMapZoneService) Delete(ctx context.Context, addressMapID string, // Union satisfied by [addressing.AddressMapZoneUpdateResponseUnknown], // [addressing.AddressMapZoneUpdateResponseArray] or [shared.UnionString]. -type AddressMapZoneUpdateResponse interface { - ImplementsAddressingAddressMapZoneUpdateResponse() +type AddressMapZoneUpdateResponseUnion interface { + ImplementsAddressingAddressMapZoneUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AddressMapZoneUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*AddressMapZoneUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -101,17 +83,17 @@ func init() { type AddressMapZoneUpdateResponseArray []interface{} -func (r AddressMapZoneUpdateResponseArray) ImplementsAddressingAddressMapZoneUpdateResponse() {} +func (r AddressMapZoneUpdateResponseArray) ImplementsAddressingAddressMapZoneUpdateResponseUnion() {} // Union satisfied by [addressing.AddressMapZoneDeleteResponseUnknown], // [addressing.AddressMapZoneDeleteResponseArray] or [shared.UnionString]. -type AddressMapZoneDeleteResponse interface { - ImplementsAddressingAddressMapZoneDeleteResponse() +type AddressMapZoneDeleteResponseUnion interface { + ImplementsAddressingAddressMapZoneDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AddressMapZoneDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*AddressMapZoneDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -126,19 +108,24 @@ func init() { type AddressMapZoneDeleteResponseArray []interface{} -func (r AddressMapZoneDeleteResponseArray) ImplementsAddressingAddressMapZoneDeleteResponse() {} +func (r AddressMapZoneDeleteResponseArray) ImplementsAddressingAddressMapZoneDeleteResponseUnion() {} type AddressMapZoneUpdateParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r AddressMapZoneUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type AddressMapZoneUpdateResponseEnvelope struct { - Errors []AddressMapZoneUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapZoneUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapZoneUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapZoneUpdateResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AddressMapZoneUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo AddressMapZoneUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -165,52 +152,6 @@ func (r addressMapZoneUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapZoneUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapZoneUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapZoneUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressMapZoneUpdateResponseEnvelopeErrors] -type addressMapZoneUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapZoneUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapZoneUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapZoneUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapZoneUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapZoneUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressMapZoneUpdateResponseEnvelopeMessages] -type addressMapZoneUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapZoneUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapZoneUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapZoneUpdateResponseEnvelopeSuccess bool @@ -262,12 +203,17 @@ type AddressMapZoneDeleteParams struct { ZoneID param.Field[string] `path:"zone_id,required"` // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r AddressMapZoneDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type AddressMapZoneDeleteResponseEnvelope struct { - Errors []AddressMapZoneDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressMapZoneDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressMapZoneDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AddressMapZoneDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AddressMapZoneDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo AddressMapZoneDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -294,52 +240,6 @@ func (r addressMapZoneDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressMapZoneDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapZoneDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressMapZoneDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressMapZoneDeleteResponseEnvelopeErrors] -type addressMapZoneDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapZoneDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapZoneDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressMapZoneDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressMapZoneDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressMapZoneDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressMapZoneDeleteResponseEnvelopeMessages] -type addressMapZoneDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressMapZoneDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressMapZoneDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressMapZoneDeleteResponseEnvelopeSuccess bool diff --git a/addressing/addressmapzone_test.go b/addressing/addressmapzone_test.go index 9d15f0c984f..4268fa43c9d 100644 --- a/addressing/addressmapzone_test.go +++ b/addressing/addressmapzone_test.go @@ -34,6 +34,7 @@ func TestAddressMapZoneUpdate(t *testing.T) { addressing.AddressMapZoneUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -65,6 +66,7 @@ func TestAddressMapZoneDelete(t *testing.T) { addressing.AddressMapZoneDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/addressing/aliases.go b/addressing/aliases.go index ac6f6cbaff5..d53662933d2 100644 --- a/addressing/aliases.go +++ b/addressing/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/addressing/loadocument.go b/addressing/loadocument.go index 6eb14a79e90..56287c2941b 100644 --- a/addressing/loadocument.go +++ b/addressing/loadocument.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -80,9 +81,9 @@ func (r LOADocumentNewParams) MarshalJSON() (data []byte, err error) { } type LOADocumentNewResponseEnvelope struct { - Errors []LOADocumentNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LOADocumentNewResponseEnvelopeMessages `json:"messages,required"` - Result LOADocumentNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LOADocumentNewResponse `json:"result,required"` // Whether the API call was successful Success LOADocumentNewResponseEnvelopeSuccess `json:"success,required"` JSON loaDocumentNewResponseEnvelopeJSON `json:"-"` @@ -107,52 +108,6 @@ func (r loaDocumentNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LOADocumentNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loaDocumentNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loaDocumentNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LOADocumentNewResponseEnvelopeErrors] -type loaDocumentNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LOADocumentNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loaDocumentNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LOADocumentNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loaDocumentNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loaDocumentNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LOADocumentNewResponseEnvelopeMessages] -type loaDocumentNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LOADocumentNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loaDocumentNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LOADocumentNewResponseEnvelopeSuccess bool diff --git a/addressing/prefix.go b/addressing/prefix.go index 9657e25c2b8..8de13ef17d9 100644 --- a/addressing/prefix.go +++ b/addressing/prefix.go @@ -40,7 +40,7 @@ func NewPrefixService(opts ...option.RequestOption) (r *PrefixService) { } // Add a new prefix under the account. -func (r *PrefixService) New(ctx context.Context, params PrefixNewParams, opts ...option.RequestOption) (res *AddressingIpamPrefixes, err error) { +func (r *PrefixService) New(ctx context.Context, params PrefixNewParams, opts ...option.RequestOption) (res *Prefix, err error) { opts = append(r.Options[:], opts...) var env PrefixNewResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes", params.AccountID) @@ -53,7 +53,7 @@ func (r *PrefixService) New(ctx context.Context, params PrefixNewParams, opts .. } // List all prefixes owned by the account. -func (r *PrefixService) List(ctx context.Context, query PrefixListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AddressingIpamPrefixes], err error) { +func (r *PrefixService) List(ctx context.Context, query PrefixListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Prefix], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -71,15 +71,15 @@ func (r *PrefixService) List(ctx context.Context, query PrefixListParams, opts . } // List all prefixes owned by the account. -func (r *PrefixService) ListAutoPaging(ctx context.Context, query PrefixListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AddressingIpamPrefixes] { +func (r *PrefixService) ListAutoPaging(ctx context.Context, query PrefixListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Prefix] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete an unapproved prefix owned by the account. -func (r *PrefixService) Delete(ctx context.Context, prefixID string, body PrefixDeleteParams, opts ...option.RequestOption) (res *PrefixDeleteResponse, err error) { +func (r *PrefixService) Delete(ctx context.Context, prefixID string, params PrefixDeleteParams, opts ...option.RequestOption) (res *PrefixDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PrefixDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", body.AccountID, prefixID) + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", params.AccountID, prefixID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -89,7 +89,7 @@ func (r *PrefixService) Delete(ctx context.Context, prefixID string, body Prefix } // Modify the description for a prefix owned by the account. -func (r *PrefixService) Edit(ctx context.Context, prefixID string, params PrefixEditParams, opts ...option.RequestOption) (res *AddressingIpamPrefixes, err error) { +func (r *PrefixService) Edit(ctx context.Context, prefixID string, params PrefixEditParams, opts ...option.RequestOption) (res *Prefix, err error) { opts = append(r.Options[:], opts...) var env PrefixEditResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", params.AccountID, prefixID) @@ -102,7 +102,7 @@ func (r *PrefixService) Edit(ctx context.Context, prefixID string, params Prefix } // List a particular prefix owned by the account. -func (r *PrefixService) Get(ctx context.Context, prefixID string, query PrefixGetParams, opts ...option.RequestOption) (res *AddressingIpamPrefixes, err error) { +func (r *PrefixService) Get(ctx context.Context, prefixID string, query PrefixGetParams, opts ...option.RequestOption) (res *Prefix, err error) { opts = append(r.Options[:], opts...) var env PrefixGetResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", query.AccountID, prefixID) @@ -114,7 +114,7 @@ func (r *PrefixService) Get(ctx context.Context, prefixID string, query PrefixGe return } -type AddressingIpamPrefixes struct { +type Prefix struct { // Identifier ID string `json:"id"` // Identifier @@ -142,13 +142,12 @@ type AddressingIpamPrefixes struct { OnDemandEnabled bool `json:"on_demand_enabled"` // Whether advertisement status of the prefix is locked, meaning it cannot be // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingIpamPrefixesJSON `json:"-"` + OnDemandLocked bool `json:"on_demand_locked"` + JSON prefixJSON `json:"-"` } -// addressingIpamPrefixesJSON contains the JSON metadata for the struct -// [AddressingIpamPrefixes] -type addressingIpamPrefixesJSON struct { +// prefixJSON contains the JSON metadata for the struct [Prefix] +type prefixJSON struct { ID apijson.Field AccountID apijson.Field Advertised apijson.Field @@ -166,23 +165,23 @@ type addressingIpamPrefixesJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressingIpamPrefixes) UnmarshalJSON(data []byte) (err error) { +func (r *Prefix) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingIpamPrefixesJSON) RawJSON() string { +func (r prefixJSON) RawJSON() string { return r.raw } // Union satisfied by [addressing.PrefixDeleteResponseUnknown], // [addressing.PrefixDeleteResponseArray] or [shared.UnionString]. -type PrefixDeleteResponse interface { - ImplementsAddressingPrefixDeleteResponse() +type PrefixDeleteResponseUnion interface { + ImplementsAddressingPrefixDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PrefixDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*PrefixDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -197,7 +196,7 @@ func init() { type PrefixDeleteResponseArray []interface{} -func (r PrefixDeleteResponseArray) ImplementsAddressingPrefixDeleteResponse() {} +func (r PrefixDeleteResponseArray) ImplementsAddressingPrefixDeleteResponseUnion() {} type PrefixNewParams struct { // Identifier @@ -215,9 +214,9 @@ func (r PrefixNewParams) MarshalJSON() (data []byte, err error) { } type PrefixNewResponseEnvelope struct { - Errors []PrefixNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingIpamPrefixes `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Prefix `json:"result,required"` // Whether the API call was successful Success PrefixNewResponseEnvelopeSuccess `json:"success,required"` JSON prefixNewResponseEnvelopeJSON `json:"-"` @@ -242,52 +241,6 @@ func (r prefixNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PrefixNewResponseEnvelopeErrors] -type prefixNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PrefixNewResponseEnvelopeMessages] -type prefixNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixNewResponseEnvelopeSuccess bool @@ -311,12 +264,17 @@ type PrefixListParams struct { type PrefixDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r PrefixDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type PrefixDeleteResponseEnvelope struct { - Errors []PrefixDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PrefixDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PrefixDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success PrefixDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo PrefixDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -343,52 +301,6 @@ func (r prefixDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PrefixDeleteResponseEnvelopeErrors] -type prefixDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PrefixDeleteResponseEnvelopeMessages] -type prefixDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixDeleteResponseEnvelopeSuccess bool @@ -447,9 +359,9 @@ func (r PrefixEditParams) MarshalJSON() (data []byte, err error) { } type PrefixEditResponseEnvelope struct { - Errors []PrefixEditResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixEditResponseEnvelopeMessages `json:"messages,required"` - Result AddressingIpamPrefixes `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Prefix `json:"result,required"` // Whether the API call was successful Success PrefixEditResponseEnvelopeSuccess `json:"success,required"` JSON prefixEditResponseEnvelopeJSON `json:"-"` @@ -474,52 +386,6 @@ func (r prefixEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PrefixEditResponseEnvelopeErrors] -type prefixEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PrefixEditResponseEnvelopeMessages] -type prefixEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixEditResponseEnvelopeSuccess bool @@ -541,9 +407,9 @@ type PrefixGetParams struct { } type PrefixGetResponseEnvelope struct { - Errors []PrefixGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingIpamPrefixes `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Prefix `json:"result,required"` // Whether the API call was successful Success PrefixGetResponseEnvelopeSuccess `json:"success,required"` JSON prefixGetResponseEnvelopeJSON `json:"-"` @@ -568,52 +434,6 @@ func (r prefixGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PrefixGetResponseEnvelopeErrors] -type prefixGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PrefixGetResponseEnvelopeMessages] -type prefixGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixGetResponseEnvelopeSuccess bool diff --git a/addressing/prefix_test.go b/addressing/prefix_test.go index bf7ee843c81..7cee67a6a5d 100644 --- a/addressing/prefix_test.go +++ b/addressing/prefix_test.go @@ -88,6 +88,7 @@ func TestPrefixDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", addressing.PrefixDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/addressing/prefixbgpbinding.go b/addressing/prefixbgpbinding.go index 2e35e29b09e..9a682e84f4c 100644 --- a/addressing/prefixbgpbinding.go +++ b/addressing/prefixbgpbinding.go @@ -39,7 +39,7 @@ func NewPrefixBGPBindingService(opts ...option.RequestOption) (r *PrefixBGPBindi // service running on Cloudflare's network. **Note:** This API may only be used on // prefixes currently configured with a Magic Transit service binding, and only // allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. -func (r *PrefixBGPBindingService) New(ctx context.Context, prefixID string, params PrefixBGPBindingNewParams, opts ...option.RequestOption) (res *AddressingServiceBinding, err error) { +func (r *PrefixBGPBindingService) New(ctx context.Context, prefixID string, params PrefixBGPBindingNewParams, opts ...option.RequestOption) (res *ServiceBinding, err error) { opts = append(r.Options[:], opts...) var env PrefixBGPBindingNewResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings", params.AccountID, prefixID) @@ -57,7 +57,7 @@ func (r *PrefixBGPBindingService) New(ctx context.Context, prefixID string, para // `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare // CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other // IPs in the prefix to Cloudflare Magic Transit. -func (r *PrefixBGPBindingService) List(ctx context.Context, prefixID string, query PrefixBGPBindingListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AddressingServiceBinding], err error) { +func (r *PrefixBGPBindingService) List(ctx context.Context, prefixID string, query PrefixBGPBindingListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ServiceBinding], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -80,12 +80,12 @@ func (r *PrefixBGPBindingService) List(ctx context.Context, prefixID string, que // `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare // CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other // IPs in the prefix to Cloudflare Magic Transit. -func (r *PrefixBGPBindingService) ListAutoPaging(ctx context.Context, prefixID string, query PrefixBGPBindingListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AddressingServiceBinding] { +func (r *PrefixBGPBindingService) ListAutoPaging(ctx context.Context, prefixID string, query PrefixBGPBindingListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ServiceBinding] { return pagination.NewSinglePageAutoPager(r.List(ctx, prefixID, query, opts...)) } // Delete a Service Binding -func (r *PrefixBGPBindingService) Delete(ctx context.Context, prefixID string, bindingID string, body PrefixBGPBindingDeleteParams, opts ...option.RequestOption) (res *PrefixBGPBindingDeleteResponse, err error) { +func (r *PrefixBGPBindingService) Delete(ctx context.Context, prefixID string, bindingID string, body PrefixBGPBindingDeleteParams, opts ...option.RequestOption) (res *PrefixBGPBindingDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PrefixBGPBindingDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings/%s", body.AccountID, prefixID, bindingID) @@ -98,7 +98,7 @@ func (r *PrefixBGPBindingService) Delete(ctx context.Context, prefixID string, b } // Fetch a single Service Binding -func (r *PrefixBGPBindingService) Get(ctx context.Context, prefixID string, bindingID string, query PrefixBGPBindingGetParams, opts ...option.RequestOption) (res *AddressingServiceBinding, err error) { +func (r *PrefixBGPBindingService) Get(ctx context.Context, prefixID string, bindingID string, query PrefixBGPBindingGetParams, opts ...option.RequestOption) (res *ServiceBinding, err error) { opts = append(r.Options[:], opts...) var env PrefixBGPBindingGetResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings/%s", query.AccountID, prefixID, bindingID) @@ -110,23 +110,22 @@ func (r *PrefixBGPBindingService) Get(ctx context.Context, prefixID string, bind return } -type AddressingServiceBinding struct { +type ServiceBinding struct { // Identifier ID string `json:"id"` // IP Prefix in Classless Inter-Domain Routing format. CIDR string `json:"cidr"` // Status of a Service Binding's deployment to the Cloudflare network - Provisioning AddressingServiceBindingProvisioning `json:"provisioning"` + Provisioning ServiceBindingProvisioning `json:"provisioning"` // Identifier ServiceID string `json:"service_id"` // Name of a service running on the Cloudflare network - ServiceName string `json:"service_name"` - JSON addressingServiceBindingJSON `json:"-"` + ServiceName string `json:"service_name"` + JSON serviceBindingJSON `json:"-"` } -// addressingServiceBindingJSON contains the JSON metadata for the struct -// [AddressingServiceBinding] -type addressingServiceBindingJSON struct { +// serviceBindingJSON contains the JSON metadata for the struct [ServiceBinding] +type serviceBindingJSON struct { ID apijson.Field CIDR apijson.Field Provisioning apijson.Field @@ -136,64 +135,94 @@ type addressingServiceBindingJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressingServiceBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ServiceBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingServiceBindingJSON) RawJSON() string { +func (r serviceBindingJSON) RawJSON() string { return r.raw } +func (r ServiceBinding) implementsWorkersBinding() {} + // Status of a Service Binding's deployment to the Cloudflare network -type AddressingServiceBindingProvisioning struct { +type ServiceBindingProvisioning struct { // When a binding has been deployed to a majority of Cloudflare datacenters, the // binding will become active and can be used with its associated service. - State AddressingServiceBindingProvisioningState `json:"state"` - JSON addressingServiceBindingProvisioningJSON `json:"-"` + State ServiceBindingProvisioningState `json:"state"` + JSON serviceBindingProvisioningJSON `json:"-"` } -// addressingServiceBindingProvisioningJSON contains the JSON metadata for the -// struct [AddressingServiceBindingProvisioning] -type addressingServiceBindingProvisioningJSON struct { +// serviceBindingProvisioningJSON contains the JSON metadata for the struct +// [ServiceBindingProvisioning] +type serviceBindingProvisioningJSON struct { State apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AddressingServiceBindingProvisioning) UnmarshalJSON(data []byte) (err error) { +func (r *ServiceBindingProvisioning) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingServiceBindingProvisioningJSON) RawJSON() string { +func (r serviceBindingProvisioningJSON) RawJSON() string { return r.raw } // When a binding has been deployed to a majority of Cloudflare datacenters, the // binding will become active and can be used with its associated service. -type AddressingServiceBindingProvisioningState string +type ServiceBindingProvisioningState string const ( - AddressingServiceBindingProvisioningStateProvisioning AddressingServiceBindingProvisioningState = "provisioning" - AddressingServiceBindingProvisioningStateActive AddressingServiceBindingProvisioningState = "active" + ServiceBindingProvisioningStateProvisioning ServiceBindingProvisioningState = "provisioning" + ServiceBindingProvisioningStateActive ServiceBindingProvisioningState = "active" ) -func (r AddressingServiceBindingProvisioningState) IsKnown() bool { +func (r ServiceBindingProvisioningState) IsKnown() bool { switch r { - case AddressingServiceBindingProvisioningStateProvisioning, AddressingServiceBindingProvisioningStateActive: + case ServiceBindingProvisioningStateProvisioning, ServiceBindingProvisioningStateActive: return true } return false } +type ServiceBindingParam struct { + // IP Prefix in Classless Inter-Domain Routing format. + CIDR param.Field[string] `json:"cidr"` + // Status of a Service Binding's deployment to the Cloudflare network + Provisioning param.Field[ServiceBindingProvisioningParam] `json:"provisioning"` + // Identifier + ServiceID param.Field[string] `json:"service_id"` + // Name of a service running on the Cloudflare network + ServiceName param.Field[string] `json:"service_name"` +} + +func (r ServiceBindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceBindingParam) implementsWorkersBindingUnionParam() {} + +// Status of a Service Binding's deployment to the Cloudflare network +type ServiceBindingProvisioningParam struct { + // When a binding has been deployed to a majority of Cloudflare datacenters, the + // binding will become active and can be used with its associated service. + State param.Field[ServiceBindingProvisioningState] `json:"state"` +} + +func (r ServiceBindingProvisioningParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Union satisfied by [addressing.PrefixBGPBindingDeleteResponseUnknown], // [addressing.PrefixBGPBindingDeleteResponseArray] or [shared.UnionString]. -type PrefixBGPBindingDeleteResponse interface { - ImplementsAddressingPrefixBGPBindingDeleteResponse() +type PrefixBGPBindingDeleteResponseUnion interface { + ImplementsAddressingPrefixBGPBindingDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PrefixBGPBindingDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*PrefixBGPBindingDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -208,7 +237,8 @@ func init() { type PrefixBGPBindingDeleteResponseArray []interface{} -func (r PrefixBGPBindingDeleteResponseArray) ImplementsAddressingPrefixBGPBindingDeleteResponse() {} +func (r PrefixBGPBindingDeleteResponseArray) ImplementsAddressingPrefixBGPBindingDeleteResponseUnion() { +} type PrefixBGPBindingNewParams struct { // Identifier @@ -224,9 +254,9 @@ func (r PrefixBGPBindingNewParams) MarshalJSON() (data []byte, err error) { } type PrefixBGPBindingNewResponseEnvelope struct { - Errors []PrefixBGPBindingNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixBGPBindingNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingServiceBinding `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ServiceBinding `json:"result,required"` // Whether the API call was successful Success PrefixBGPBindingNewResponseEnvelopeSuccess `json:"success,required"` JSON prefixBGPBindingNewResponseEnvelopeJSON `json:"-"` @@ -251,52 +281,6 @@ func (r prefixBGPBindingNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixBGPBindingNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPBindingNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixBGPBindingNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrefixBGPBindingNewResponseEnvelopeErrors] -type prefixBGPBindingNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPBindingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPBindingNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixBGPBindingNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPBindingNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixBGPBindingNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PrefixBGPBindingNewResponseEnvelopeMessages] -type prefixBGPBindingNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPBindingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPBindingNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixBGPBindingNewResponseEnvelopeSuccess bool @@ -323,9 +307,9 @@ type PrefixBGPBindingDeleteParams struct { } type PrefixBGPBindingDeleteResponseEnvelope struct { - Errors []PrefixBGPBindingDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixBGPBindingDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PrefixBGPBindingDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PrefixBGPBindingDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success PrefixBGPBindingDeleteResponseEnvelopeSuccess `json:"success,required"` JSON prefixBGPBindingDeleteResponseEnvelopeJSON `json:"-"` @@ -350,52 +334,6 @@ func (r prefixBGPBindingDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixBGPBindingDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPBindingDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixBGPBindingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PrefixBGPBindingDeleteResponseEnvelopeErrors] -type prefixBGPBindingDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPBindingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPBindingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixBGPBindingDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPBindingDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixBGPBindingDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [PrefixBGPBindingDeleteResponseEnvelopeMessages] -type prefixBGPBindingDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPBindingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPBindingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixBGPBindingDeleteResponseEnvelopeSuccess bool @@ -417,9 +355,9 @@ type PrefixBGPBindingGetParams struct { } type PrefixBGPBindingGetResponseEnvelope struct { - Errors []PrefixBGPBindingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixBGPBindingGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingServiceBinding `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ServiceBinding `json:"result,required"` // Whether the API call was successful Success PrefixBGPBindingGetResponseEnvelopeSuccess `json:"success,required"` JSON prefixBGPBindingGetResponseEnvelopeJSON `json:"-"` @@ -444,52 +382,6 @@ func (r prefixBGPBindingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixBGPBindingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPBindingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixBGPBindingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrefixBGPBindingGetResponseEnvelopeErrors] -type prefixBGPBindingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPBindingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPBindingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixBGPBindingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPBindingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixBGPBindingGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PrefixBGPBindingGetResponseEnvelopeMessages] -type prefixBGPBindingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPBindingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPBindingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixBGPBindingGetResponseEnvelopeSuccess bool diff --git a/addressing/prefixbgpprefix.go b/addressing/prefixbgpprefix.go index fea0b312de1..211a9c9a42e 100644 --- a/addressing/prefixbgpprefix.go +++ b/addressing/prefixbgpprefix.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -37,7 +38,7 @@ func NewPrefixBGPPrefixService(opts ...option.RequestOption) (r *PrefixBGPPrefix // control which specific subnets are advertised to the Internet. It is possible to // advertise subnets more specific than an IP Prefix by creating more specific BGP // Prefixes. -func (r *PrefixBGPPrefixService) List(ctx context.Context, prefixID string, query PrefixBGPPrefixListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AddressingIpamBGPPrefixes], err error) { +func (r *PrefixBGPPrefixService) List(ctx context.Context, prefixID string, query PrefixBGPPrefixListParams, opts ...option.RequestOption) (res *pagination.SinglePage[BGPPrefix], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -58,13 +59,13 @@ func (r *PrefixBGPPrefixService) List(ctx context.Context, prefixID string, quer // control which specific subnets are advertised to the Internet. It is possible to // advertise subnets more specific than an IP Prefix by creating more specific BGP // Prefixes. -func (r *PrefixBGPPrefixService) ListAutoPaging(ctx context.Context, prefixID string, query PrefixBGPPrefixListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AddressingIpamBGPPrefixes] { +func (r *PrefixBGPPrefixService) ListAutoPaging(ctx context.Context, prefixID string, query PrefixBGPPrefixListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[BGPPrefix] { return pagination.NewSinglePageAutoPager(r.List(ctx, prefixID, query, opts...)) } // Update the properties of a BGP Prefix, such as the on demand advertisement // status (advertised or withdrawn). -func (r *PrefixBGPPrefixService) Edit(ctx context.Context, prefixID string, bgpPrefixID string, params PrefixBGPPrefixEditParams, opts ...option.RequestOption) (res *AddressingIpamBGPPrefixes, err error) { +func (r *PrefixBGPPrefixService) Edit(ctx context.Context, prefixID string, bgpPrefixID string, params PrefixBGPPrefixEditParams, opts ...option.RequestOption) (res *BGPPrefix, err error) { opts = append(r.Options[:], opts...) var env PrefixBGPPrefixEditResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes/%s", params.AccountID, prefixID, bgpPrefixID) @@ -77,7 +78,7 @@ func (r *PrefixBGPPrefixService) Edit(ctx context.Context, prefixID string, bgpP } // Retrieve a single BGP Prefix according to its identifier -func (r *PrefixBGPPrefixService) Get(ctx context.Context, prefixID string, bgpPrefixID string, query PrefixBGPPrefixGetParams, opts ...option.RequestOption) (res *AddressingIpamBGPPrefixes, err error) { +func (r *PrefixBGPPrefixService) Get(ctx context.Context, prefixID string, bgpPrefixID string, query PrefixBGPPrefixGetParams, opts ...option.RequestOption) (res *BGPPrefix, err error) { opts = append(r.Options[:], opts...) var env PrefixBGPPrefixGetResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes/%s", query.AccountID, prefixID, bgpPrefixID) @@ -89,23 +90,22 @@ func (r *PrefixBGPPrefixService) Get(ctx context.Context, prefixID string, bgpPr return } -type AddressingIpamBGPPrefixes struct { +type BGPPrefix struct { // Identifier ID string `json:"id"` // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - BGPSignalOpts AddressingIpamBGPPrefixesBGPSignalOpts `json:"bgp_signal_opts"` + ASN int64 `json:"asn,nullable"` + BGPSignalOpts BGPPrefixBGPSignalOpts `json:"bgp_signal_opts"` // IP Prefix in Classless Inter-Domain Routing format. - CIDR string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - OnDemand AddressingIpamBGPPrefixesOnDemand `json:"on_demand"` - JSON addressingIpamBGPPrefixesJSON `json:"-"` + CIDR string `json:"cidr"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + OnDemand BGPPrefixOnDemand `json:"on_demand"` + JSON bgpPrefixJSON `json:"-"` } -// addressingIpamBGPPrefixesJSON contains the JSON metadata for the struct -// [AddressingIpamBGPPrefixes] -type addressingIpamBGPPrefixesJSON struct { +// bgpPrefixJSON contains the JSON metadata for the struct [BGPPrefix] +type bgpPrefixJSON struct { ID apijson.Field ASN apijson.Field BGPSignalOpts apijson.Field @@ -117,42 +117,42 @@ type addressingIpamBGPPrefixesJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressingIpamBGPPrefixes) UnmarshalJSON(data []byte) (err error) { +func (r *BGPPrefix) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingIpamBGPPrefixesJSON) RawJSON() string { +func (r bgpPrefixJSON) RawJSON() string { return r.raw } -type AddressingIpamBGPPrefixesBGPSignalOpts struct { +type BGPPrefixBGPSignalOpts struct { // Whether control of advertisement of the prefix to the Internet is enabled to be // performed via BGP signal Enabled bool `json:"enabled"` // Last time BGP signaling control was toggled. This field is null if BGP signaling // has never been enabled. - ModifiedAt time.Time `json:"modified_at,nullable" format:"date-time"` - JSON addressingIpamBGPPrefixesBGPSignalOptsJSON `json:"-"` + ModifiedAt time.Time `json:"modified_at,nullable" format:"date-time"` + JSON bgpPrefixBGPSignalOptsJSON `json:"-"` } -// addressingIpamBGPPrefixesBGPSignalOptsJSON contains the JSON metadata for the -// struct [AddressingIpamBGPPrefixesBGPSignalOpts] -type addressingIpamBGPPrefixesBGPSignalOptsJSON struct { +// bgpPrefixBGPSignalOptsJSON contains the JSON metadata for the struct +// [BGPPrefixBGPSignalOpts] +type bgpPrefixBGPSignalOptsJSON struct { Enabled apijson.Field ModifiedAt apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AddressingIpamBGPPrefixesBGPSignalOpts) UnmarshalJSON(data []byte) (err error) { +func (r *BGPPrefixBGPSignalOpts) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingIpamBGPPrefixesBGPSignalOptsJSON) RawJSON() string { +func (r bgpPrefixBGPSignalOptsJSON) RawJSON() string { return r.raw } -type AddressingIpamBGPPrefixesOnDemand struct { +type BGPPrefixOnDemand struct { // Prefix advertisement status to the Internet. This field is only not 'null' if on // demand is enabled. Advertised bool `json:"advertised,nullable"` @@ -164,13 +164,13 @@ type AddressingIpamBGPPrefixesOnDemand struct { OnDemandEnabled bool `json:"on_demand_enabled"` // Whether advertisement status of the prefix is locked, meaning it cannot be // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingIpamBGPPrefixesOnDemandJSON `json:"-"` + OnDemandLocked bool `json:"on_demand_locked"` + JSON bgpPrefixOnDemandJSON `json:"-"` } -// addressingIpamBGPPrefixesOnDemandJSON contains the JSON metadata for the struct -// [AddressingIpamBGPPrefixesOnDemand] -type addressingIpamBGPPrefixesOnDemandJSON struct { +// bgpPrefixOnDemandJSON contains the JSON metadata for the struct +// [BGPPrefixOnDemand] +type bgpPrefixOnDemandJSON struct { Advertised apijson.Field AdvertisedModifiedAt apijson.Field OnDemandEnabled apijson.Field @@ -179,11 +179,11 @@ type addressingIpamBGPPrefixesOnDemandJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressingIpamBGPPrefixesOnDemand) UnmarshalJSON(data []byte) (err error) { +func (r *BGPPrefixOnDemand) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingIpamBGPPrefixesOnDemandJSON) RawJSON() string { +func (r bgpPrefixOnDemandJSON) RawJSON() string { return r.raw } @@ -211,9 +211,9 @@ func (r PrefixBGPPrefixEditParamsOnDemand) MarshalJSON() (data []byte, err error } type PrefixBGPPrefixEditResponseEnvelope struct { - Errors []PrefixBGPPrefixEditResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixBGPPrefixEditResponseEnvelopeMessages `json:"messages,required"` - Result AddressingIpamBGPPrefixes `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result BGPPrefix `json:"result,required"` // Whether the API call was successful Success PrefixBGPPrefixEditResponseEnvelopeSuccess `json:"success,required"` JSON prefixBGPPrefixEditResponseEnvelopeJSON `json:"-"` @@ -238,52 +238,6 @@ func (r prefixBGPPrefixEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixBGPPrefixEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPPrefixEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixBGPPrefixEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrefixBGPPrefixEditResponseEnvelopeErrors] -type prefixBGPPrefixEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPPrefixEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPPrefixEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixBGPPrefixEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPPrefixEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixBGPPrefixEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PrefixBGPPrefixEditResponseEnvelopeMessages] -type prefixBGPPrefixEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPPrefixEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPPrefixEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixBGPPrefixEditResponseEnvelopeSuccess bool @@ -305,9 +259,9 @@ type PrefixBGPPrefixGetParams struct { } type PrefixBGPPrefixGetResponseEnvelope struct { - Errors []PrefixBGPPrefixGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixBGPPrefixGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingIpamBGPPrefixes `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result BGPPrefix `json:"result,required"` // Whether the API call was successful Success PrefixBGPPrefixGetResponseEnvelopeSuccess `json:"success,required"` JSON prefixBGPPrefixGetResponseEnvelopeJSON `json:"-"` @@ -332,52 +286,6 @@ func (r prefixBGPPrefixGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixBGPPrefixGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPPrefixGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixBGPPrefixGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrefixBGPPrefixGetResponseEnvelopeErrors] -type prefixBGPPrefixGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPPrefixGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPPrefixGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixBGPPrefixGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPPrefixGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixBGPPrefixGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PrefixBGPPrefixGetResponseEnvelopeMessages] -type prefixBGPPrefixGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPPrefixGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPPrefixGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixBGPPrefixGetResponseEnvelopeSuccess bool diff --git a/addressing/prefixbgpstatus.go b/addressing/prefixbgpstatus.go index 27fde5dc029..787c7c00020 100644 --- a/addressing/prefixbgpstatus.go +++ b/addressing/prefixbgpstatus.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -122,9 +123,9 @@ func (r PrefixBGPStatusEditParams) MarshalJSON() (data []byte, err error) { } type PrefixBGPStatusEditResponseEnvelope struct { - Errors []PrefixBGPStatusEditResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixBGPStatusEditResponseEnvelopeMessages `json:"messages,required"` - Result PrefixBGPStatusEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PrefixBGPStatusEditResponse `json:"result,required"` // Whether the API call was successful Success PrefixBGPStatusEditResponseEnvelopeSuccess `json:"success,required"` JSON prefixBGPStatusEditResponseEnvelopeJSON `json:"-"` @@ -149,52 +150,6 @@ func (r prefixBGPStatusEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixBGPStatusEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPStatusEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixBGPStatusEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrefixBGPStatusEditResponseEnvelopeErrors] -type prefixBGPStatusEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPStatusEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPStatusEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixBGPStatusEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPStatusEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixBGPStatusEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PrefixBGPStatusEditResponseEnvelopeMessages] -type prefixBGPStatusEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPStatusEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPStatusEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixBGPStatusEditResponseEnvelopeSuccess bool @@ -216,9 +171,9 @@ type PrefixBGPStatusGetParams struct { } type PrefixBGPStatusGetResponseEnvelope struct { - Errors []PrefixBGPStatusGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixBGPStatusGetResponseEnvelopeMessages `json:"messages,required"` - Result PrefixBGPStatusGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PrefixBGPStatusGetResponse `json:"result,required"` // Whether the API call was successful Success PrefixBGPStatusGetResponseEnvelopeSuccess `json:"success,required"` JSON prefixBGPStatusGetResponseEnvelopeJSON `json:"-"` @@ -243,52 +198,6 @@ func (r prefixBGPStatusGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixBGPStatusGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPStatusGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixBGPStatusGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrefixBGPStatusGetResponseEnvelopeErrors] -type prefixBGPStatusGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPStatusGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPStatusGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixBGPStatusGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixBGPStatusGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixBGPStatusGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PrefixBGPStatusGetResponseEnvelopeMessages] -type prefixBGPStatusGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixBGPStatusGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixBGPStatusGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixBGPStatusGetResponseEnvelopeSuccess bool diff --git a/addressing/prefixdelegation.go b/addressing/prefixdelegation.go index 3180fdcc6e0..79d1f536dc0 100644 --- a/addressing/prefixdelegation.go +++ b/addressing/prefixdelegation.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -34,7 +35,7 @@ func NewPrefixDelegationService(opts ...option.RequestOption) (r *PrefixDelegati } // Create a new account delegation for a given IP prefix. -func (r *PrefixDelegationService) New(ctx context.Context, prefixID string, params PrefixDelegationNewParams, opts ...option.RequestOption) (res *AddressingIpamDelegations, err error) { +func (r *PrefixDelegationService) New(ctx context.Context, prefixID string, params PrefixDelegationNewParams, opts ...option.RequestOption) (res *Delegations, err error) { opts = append(r.Options[:], opts...) var env PrefixDelegationNewResponseEnvelope path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations", params.AccountID, prefixID) @@ -47,7 +48,7 @@ func (r *PrefixDelegationService) New(ctx context.Context, prefixID string, para } // List all delegations for a given account IP prefix. -func (r *PrefixDelegationService) List(ctx context.Context, prefixID string, query PrefixDelegationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AddressingIpamDelegations], err error) { +func (r *PrefixDelegationService) List(ctx context.Context, prefixID string, query PrefixDelegationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Delegations], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -65,15 +66,15 @@ func (r *PrefixDelegationService) List(ctx context.Context, prefixID string, que } // List all delegations for a given account IP prefix. -func (r *PrefixDelegationService) ListAutoPaging(ctx context.Context, prefixID string, query PrefixDelegationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AddressingIpamDelegations] { +func (r *PrefixDelegationService) ListAutoPaging(ctx context.Context, prefixID string, query PrefixDelegationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Delegations] { return pagination.NewSinglePageAutoPager(r.List(ctx, prefixID, query, opts...)) } // Delete an account delegation for a given IP prefix. -func (r *PrefixDelegationService) Delete(ctx context.Context, prefixID string, delegationID string, body PrefixDelegationDeleteParams, opts ...option.RequestOption) (res *PrefixDelegationDeleteResponse, err error) { +func (r *PrefixDelegationService) Delete(ctx context.Context, prefixID string, delegationID string, params PrefixDelegationDeleteParams, opts ...option.RequestOption) (res *PrefixDelegationDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env PrefixDelegationDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations/%s", body.AccountID, prefixID, delegationID) + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations/%s", params.AccountID, prefixID, delegationID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -82,7 +83,7 @@ func (r *PrefixDelegationService) Delete(ctx context.Context, prefixID string, d return } -type AddressingIpamDelegations struct { +type Delegations struct { // Delegation identifier tag. ID string `json:"id"` // IP Prefix in Classless Inter-Domain Routing format. @@ -92,13 +93,12 @@ type AddressingIpamDelegations struct { DelegatedAccountID string `json:"delegated_account_id"` ModifiedAt time.Time `json:"modified_at" format:"date-time"` // Identifier - ParentPrefixID string `json:"parent_prefix_id"` - JSON addressingIpamDelegationsJSON `json:"-"` + ParentPrefixID string `json:"parent_prefix_id"` + JSON delegationsJSON `json:"-"` } -// addressingIpamDelegationsJSON contains the JSON metadata for the struct -// [AddressingIpamDelegations] -type addressingIpamDelegationsJSON struct { +// delegationsJSON contains the JSON metadata for the struct [Delegations] +type delegationsJSON struct { ID apijson.Field CIDR apijson.Field CreatedAt apijson.Field @@ -109,11 +109,11 @@ type addressingIpamDelegationsJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressingIpamDelegations) UnmarshalJSON(data []byte) (err error) { +func (r *Delegations) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressingIpamDelegationsJSON) RawJSON() string { +func (r delegationsJSON) RawJSON() string { return r.raw } @@ -153,9 +153,9 @@ func (r PrefixDelegationNewParams) MarshalJSON() (data []byte, err error) { } type PrefixDelegationNewResponseEnvelope struct { - Errors []PrefixDelegationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixDelegationNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingIpamDelegations `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Delegations `json:"result,required"` // Whether the API call was successful Success PrefixDelegationNewResponseEnvelopeSuccess `json:"success,required"` JSON prefixDelegationNewResponseEnvelopeJSON `json:"-"` @@ -180,52 +180,6 @@ func (r prefixDelegationNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixDelegationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixDelegationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixDelegationNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrefixDelegationNewResponseEnvelopeErrors] -type prefixDelegationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixDelegationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixDelegationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixDelegationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixDelegationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixDelegationNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PrefixDelegationNewResponseEnvelopeMessages] -type prefixDelegationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixDelegationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixDelegationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixDelegationNewResponseEnvelopeSuccess bool @@ -249,12 +203,17 @@ type PrefixDelegationListParams struct { type PrefixDelegationDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r PrefixDelegationDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type PrefixDelegationDeleteResponseEnvelope struct { - Errors []PrefixDelegationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PrefixDelegationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PrefixDelegationDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PrefixDelegationDeleteResponse `json:"result,required"` // Whether the API call was successful Success PrefixDelegationDeleteResponseEnvelopeSuccess `json:"success,required"` JSON prefixDelegationDeleteResponseEnvelopeJSON `json:"-"` @@ -279,52 +238,6 @@ func (r prefixDelegationDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrefixDelegationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixDelegationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// prefixDelegationDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PrefixDelegationDeleteResponseEnvelopeErrors] -type prefixDelegationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixDelegationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixDelegationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrefixDelegationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prefixDelegationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// prefixDelegationDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [PrefixDelegationDeleteResponseEnvelopeMessages] -type prefixDelegationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrefixDelegationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prefixDelegationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrefixDelegationDeleteResponseEnvelopeSuccess bool diff --git a/addressing/prefixdelegation_test.go b/addressing/prefixdelegation_test.go index c5a207a9e1a..670d919c955 100644 --- a/addressing/prefixdelegation_test.go +++ b/addressing/prefixdelegation_test.go @@ -96,6 +96,7 @@ func TestPrefixDelegationDelete(t *testing.T) { "d933b1530bc56c9953cf8ce166da8004", addressing.PrefixDelegationDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/alerting/aliases.go b/alerting/aliases.go index d5b4b636c7b..712effdcf8b 100644 --- a/alerting/aliases.go +++ b/alerting/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/alerting/availablealert.go b/alerting/availablealert.go index 0d311f80dec..c836f1eee4a 100644 --- a/alerting/availablealert.go +++ b/alerting/availablealert.go @@ -35,7 +35,7 @@ func NewAvailableAlertService(opts ...option.RequestOption) (r *AvailableAlertSe } // Gets a list of all alert types for which an account is eligible. -func (r *AvailableAlertService) List(ctx context.Context, query AvailableAlertListParams, opts ...option.RequestOption) (res *AvailableAlertListResponse, err error) { +func (r *AvailableAlertService) List(ctx context.Context, query AvailableAlertListParams, opts ...option.RequestOption) (res *AvailableAlertListResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AvailableAlertListResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/available_alerts", query.AccountID) @@ -49,13 +49,13 @@ func (r *AvailableAlertService) List(ctx context.Context, query AvailableAlertLi // Union satisfied by [alerting.AvailableAlertListResponseUnknown], // [alerting.AvailableAlertListResponseArray] or [shared.UnionString]. -type AvailableAlertListResponse interface { - ImplementsAlertingAvailableAlertListResponse() +type AvailableAlertListResponseUnion interface { + ImplementsAlertingAvailableAlertListResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AvailableAlertListResponse)(nil)).Elem(), + reflect.TypeOf((*AvailableAlertListResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -70,7 +70,7 @@ func init() { type AvailableAlertListResponseArray []interface{} -func (r AvailableAlertListResponseArray) ImplementsAlertingAvailableAlertListResponse() {} +func (r AvailableAlertListResponseArray) ImplementsAlertingAvailableAlertListResponseUnion() {} type AvailableAlertListParams struct { // The account id @@ -78,9 +78,9 @@ type AvailableAlertListParams struct { } type AvailableAlertListResponseEnvelope struct { - Errors []AvailableAlertListResponseEnvelopeErrors `json:"errors,required"` - Messages []AvailableAlertListResponseEnvelopeMessages `json:"messages,required"` - Result AvailableAlertListResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AvailableAlertListResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AvailableAlertListResponseEnvelopeSuccess `json:"success,required"` ResultInfo AvailableAlertListResponseEnvelopeResultInfo `json:"result_info"` @@ -107,52 +107,6 @@ func (r availableAlertListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AvailableAlertListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON availableAlertListResponseEnvelopeErrorsJSON `json:"-"` -} - -// availableAlertListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AvailableAlertListResponseEnvelopeErrors] -type availableAlertListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailableAlertListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availableAlertListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AvailableAlertListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON availableAlertListResponseEnvelopeMessagesJSON `json:"-"` -} - -// availableAlertListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AvailableAlertListResponseEnvelopeMessages] -type availableAlertListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailableAlertListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availableAlertListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AvailableAlertListResponseEnvelopeSuccess bool diff --git a/alerting/destinationeligible.go b/alerting/destinationeligible.go index 59d4861fc5a..15b7b3bb43d 100644 --- a/alerting/destinationeligible.go +++ b/alerting/destinationeligible.go @@ -35,7 +35,7 @@ func NewDestinationEligibleService(opts ...option.RequestOption) (r *Destination } // Get a list of all delivery mechanism types for which an account is eligible. -func (r *DestinationEligibleService) Get(ctx context.Context, query DestinationEligibleGetParams, opts ...option.RequestOption) (res *DestinationEligibleGetResponse, err error) { +func (r *DestinationEligibleService) Get(ctx context.Context, query DestinationEligibleGetParams, opts ...option.RequestOption) (res *DestinationEligibleGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DestinationEligibleGetResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/eligible", query.AccountID) @@ -49,13 +49,13 @@ func (r *DestinationEligibleService) Get(ctx context.Context, query DestinationE // Union satisfied by [alerting.DestinationEligibleGetResponseUnknown], // [alerting.DestinationEligibleGetResponseArray] or [shared.UnionString]. -type DestinationEligibleGetResponse interface { - ImplementsAlertingDestinationEligibleGetResponse() +type DestinationEligibleGetResponseUnion interface { + ImplementsAlertingDestinationEligibleGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DestinationEligibleGetResponse)(nil)).Elem(), + reflect.TypeOf((*DestinationEligibleGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -70,7 +70,8 @@ func init() { type DestinationEligibleGetResponseArray []interface{} -func (r DestinationEligibleGetResponseArray) ImplementsAlertingDestinationEligibleGetResponse() {} +func (r DestinationEligibleGetResponseArray) ImplementsAlertingDestinationEligibleGetResponseUnion() { +} type DestinationEligibleGetParams struct { // The account id @@ -78,9 +79,9 @@ type DestinationEligibleGetParams struct { } type DestinationEligibleGetResponseEnvelope struct { - Errors []DestinationEligibleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationEligibleGetResponseEnvelopeMessages `json:"messages,required"` - Result DestinationEligibleGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DestinationEligibleGetResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success DestinationEligibleGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DestinationEligibleGetResponseEnvelopeResultInfo `json:"result_info"` @@ -107,52 +108,6 @@ func (r destinationEligibleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationEligibleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationEligibleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationEligibleGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DestinationEligibleGetResponseEnvelopeErrors] -type destinationEligibleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationEligibleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationEligibleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationEligibleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationEligibleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationEligibleGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DestinationEligibleGetResponseEnvelopeMessages] -type destinationEligibleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationEligibleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationEligibleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationEligibleGetResponseEnvelopeSuccess bool diff --git a/alerting/destinationpagerduty.go b/alerting/destinationpagerduty.go index 8d9ddcbe902..a177defba23 100644 --- a/alerting/destinationpagerduty.go +++ b/alerting/destinationpagerduty.go @@ -48,7 +48,7 @@ func (r *DestinationPagerdutyService) New(ctx context.Context, body DestinationP } // Deletes all the PagerDuty Services connected to the account. -func (r *DestinationPagerdutyService) Delete(ctx context.Context, body DestinationPagerdutyDeleteParams, opts ...option.RequestOption) (res *DestinationPagerdutyDeleteResponse, err error) { +func (r *DestinationPagerdutyService) Delete(ctx context.Context, body DestinationPagerdutyDeleteParams, opts ...option.RequestOption) (res *DestinationPagerdutyDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DestinationPagerdutyDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", body.AccountID) @@ -61,7 +61,7 @@ func (r *DestinationPagerdutyService) Delete(ctx context.Context, body Destinati } // Get a list of all configured PagerDuty services. -func (r *DestinationPagerdutyService) Get(ctx context.Context, query DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]AlertingPagerduty, err error) { +func (r *DestinationPagerdutyService) Get(ctx context.Context, query DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]Pagerduty, err error) { opts = append(r.Options[:], opts...) var env DestinationPagerdutyGetResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", query.AccountID) @@ -86,28 +86,27 @@ func (r *DestinationPagerdutyService) Link(ctx context.Context, tokenID string, return } -type AlertingPagerduty struct { +type Pagerduty struct { // UUID ID string `json:"id"` // The name of the pagerduty service. - Name string `json:"name"` - JSON alertingPagerdutyJSON `json:"-"` + Name string `json:"name"` + JSON pagerdutyJSON `json:"-"` } -// alertingPagerdutyJSON contains the JSON metadata for the struct -// [AlertingPagerduty] -type alertingPagerdutyJSON struct { +// pagerdutyJSON contains the JSON metadata for the struct [Pagerduty] +type pagerdutyJSON struct { ID apijson.Field Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AlertingPagerduty) UnmarshalJSON(data []byte) (err error) { +func (r *Pagerduty) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingPagerdutyJSON) RawJSON() string { +func (r pagerdutyJSON) RawJSON() string { return r.raw } @@ -135,13 +134,13 @@ func (r destinationPagerdutyNewResponseJSON) RawJSON() string { // Union satisfied by [alerting.DestinationPagerdutyDeleteResponseUnknown], // [alerting.DestinationPagerdutyDeleteResponseArray] or [shared.UnionString]. -type DestinationPagerdutyDeleteResponse interface { - ImplementsAlertingDestinationPagerdutyDeleteResponse() +type DestinationPagerdutyDeleteResponseUnion interface { + ImplementsAlertingDestinationPagerdutyDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DestinationPagerdutyDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*DestinationPagerdutyDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -156,7 +155,7 @@ func init() { type DestinationPagerdutyDeleteResponseArray []interface{} -func (r DestinationPagerdutyDeleteResponseArray) ImplementsAlertingDestinationPagerdutyDeleteResponse() { +func (r DestinationPagerdutyDeleteResponseArray) ImplementsAlertingDestinationPagerdutyDeleteResponseUnion() { } type DestinationPagerdutyLinkResponse struct { @@ -187,9 +186,9 @@ type DestinationPagerdutyNewParams struct { } type DestinationPagerdutyNewResponseEnvelope struct { - Errors []DestinationPagerdutyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationPagerdutyNewResponseEnvelopeMessages `json:"messages,required"` - Result DestinationPagerdutyNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DestinationPagerdutyNewResponse `json:"result,required"` // Whether the API call was successful Success DestinationPagerdutyNewResponseEnvelopeSuccess `json:"success,required"` JSON destinationPagerdutyNewResponseEnvelopeJSON `json:"-"` @@ -214,52 +213,6 @@ func (r destinationPagerdutyNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationPagerdutyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationPagerdutyNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DestinationPagerdutyNewResponseEnvelopeErrors] -type destinationPagerdutyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationPagerdutyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationPagerdutyNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DestinationPagerdutyNewResponseEnvelopeMessages] -type destinationPagerdutyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationPagerdutyNewResponseEnvelopeSuccess bool @@ -281,9 +234,9 @@ type DestinationPagerdutyDeleteParams struct { } type DestinationPagerdutyDeleteResponseEnvelope struct { - Errors []DestinationPagerdutyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationPagerdutyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DestinationPagerdutyDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DestinationPagerdutyDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success DestinationPagerdutyDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo DestinationPagerdutyDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -310,52 +263,6 @@ func (r destinationPagerdutyDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationPagerdutyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationPagerdutyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DestinationPagerdutyDeleteResponseEnvelopeErrors] -type destinationPagerdutyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationPagerdutyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationPagerdutyDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DestinationPagerdutyDeleteResponseEnvelopeMessages] -type destinationPagerdutyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationPagerdutyDeleteResponseEnvelopeSuccess bool @@ -408,9 +315,9 @@ type DestinationPagerdutyGetParams struct { } type DestinationPagerdutyGetResponseEnvelope struct { - Errors []DestinationPagerdutyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationPagerdutyGetResponseEnvelopeMessages `json:"messages,required"` - Result []AlertingPagerduty `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Pagerduty `json:"result,required,nullable"` // Whether the API call was successful Success DestinationPagerdutyGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DestinationPagerdutyGetResponseEnvelopeResultInfo `json:"result_info"` @@ -437,52 +344,6 @@ func (r destinationPagerdutyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationPagerdutyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationPagerdutyGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DestinationPagerdutyGetResponseEnvelopeErrors] -type destinationPagerdutyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationPagerdutyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationPagerdutyGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DestinationPagerdutyGetResponseEnvelopeMessages] -type destinationPagerdutyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationPagerdutyGetResponseEnvelopeSuccess bool @@ -535,9 +396,9 @@ type DestinationPagerdutyLinkParams struct { } type DestinationPagerdutyLinkResponseEnvelope struct { - Errors []DestinationPagerdutyLinkResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationPagerdutyLinkResponseEnvelopeMessages `json:"messages,required"` - Result DestinationPagerdutyLinkResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DestinationPagerdutyLinkResponse `json:"result,required"` // Whether the API call was successful Success DestinationPagerdutyLinkResponseEnvelopeSuccess `json:"success,required"` JSON destinationPagerdutyLinkResponseEnvelopeJSON `json:"-"` @@ -562,52 +423,6 @@ func (r destinationPagerdutyLinkResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationPagerdutyLinkResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyLinkResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationPagerdutyLinkResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DestinationPagerdutyLinkResponseEnvelopeErrors] -type destinationPagerdutyLinkResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyLinkResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyLinkResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationPagerdutyLinkResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationPagerdutyLinkResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationPagerdutyLinkResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DestinationPagerdutyLinkResponseEnvelopeMessages] -type destinationPagerdutyLinkResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationPagerdutyLinkResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationPagerdutyLinkResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationPagerdutyLinkResponseEnvelopeSuccess bool diff --git a/alerting/destinationwebhook.go b/alerting/destinationwebhook.go index f2178e989c4..060e9ede6ea 100644 --- a/alerting/destinationwebhook.go +++ b/alerting/destinationwebhook.go @@ -63,7 +63,7 @@ func (r *DestinationWebhookService) Update(ctx context.Context, webhookID string } // Gets a list of all configured webhook destinations. -func (r *DestinationWebhookService) List(ctx context.Context, query DestinationWebhookListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AlertingWebhooks], err error) { +func (r *DestinationWebhookService) List(ctx context.Context, query DestinationWebhookListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Webhooks], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -81,12 +81,12 @@ func (r *DestinationWebhookService) List(ctx context.Context, query DestinationW } // Gets a list of all configured webhook destinations. -func (r *DestinationWebhookService) ListAutoPaging(ctx context.Context, query DestinationWebhookListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AlertingWebhooks] { +func (r *DestinationWebhookService) ListAutoPaging(ctx context.Context, query DestinationWebhookListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Webhooks] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete a configured webhook destination. -func (r *DestinationWebhookService) Delete(ctx context.Context, webhookID string, body DestinationWebhookDeleteParams, opts ...option.RequestOption) (res *DestinationWebhookDeleteResponse, err error) { +func (r *DestinationWebhookService) Delete(ctx context.Context, webhookID string, body DestinationWebhookDeleteParams, opts ...option.RequestOption) (res *DestinationWebhookDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DestinationWebhookDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", body.AccountID, webhookID) @@ -99,7 +99,7 @@ func (r *DestinationWebhookService) Delete(ctx context.Context, webhookID string } // Get details for a single webhooks destination. -func (r *DestinationWebhookService) Get(ctx context.Context, webhookID string, query DestinationWebhookGetParams, opts ...option.RequestOption) (res *AlertingWebhooks, err error) { +func (r *DestinationWebhookService) Get(ctx context.Context, webhookID string, query DestinationWebhookGetParams, opts ...option.RequestOption) (res *Webhooks, err error) { opts = append(r.Options[:], opts...) var env DestinationWebhookGetResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", query.AccountID, webhookID) @@ -111,7 +111,7 @@ func (r *DestinationWebhookService) Get(ctx context.Context, webhookID string, q return } -type AlertingWebhooks struct { +type Webhooks struct { // The unique identifier of a webhook ID string `json:"id"` // Timestamp of when the webhook destination was created. @@ -130,15 +130,14 @@ type AlertingWebhooks struct { // destinations. Secrets are not returned in any API response body. Secret string `json:"secret"` // Type of webhook endpoint. - Type AlertingWebhooksType `json:"type"` + Type WebhooksType `json:"type"` // The POST endpoint to call when dispatching a notification. - URL string `json:"url"` - JSON alertingWebhooksJSON `json:"-"` + URL string `json:"url"` + JSON webhooksJSON `json:"-"` } -// alertingWebhooksJSON contains the JSON metadata for the struct -// [AlertingWebhooks] -type alertingWebhooksJSON struct { +// webhooksJSON contains the JSON metadata for the struct [Webhooks] +type webhooksJSON struct { ID apijson.Field CreatedAt apijson.Field LastFailure apijson.Field @@ -151,26 +150,26 @@ type alertingWebhooksJSON struct { ExtraFields map[string]apijson.Field } -func (r *AlertingWebhooks) UnmarshalJSON(data []byte) (err error) { +func (r *Webhooks) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingWebhooksJSON) RawJSON() string { +func (r webhooksJSON) RawJSON() string { return r.raw } // Type of webhook endpoint. -type AlertingWebhooksType string +type WebhooksType string const ( - AlertingWebhooksTypeSlack AlertingWebhooksType = "slack" - AlertingWebhooksTypeGeneric AlertingWebhooksType = "generic" - AlertingWebhooksTypeGchat AlertingWebhooksType = "gchat" + WebhooksTypeSlack WebhooksType = "slack" + WebhooksTypeGeneric WebhooksType = "generic" + WebhooksTypeGchat WebhooksType = "gchat" ) -func (r AlertingWebhooksType) IsKnown() bool { +func (r WebhooksType) IsKnown() bool { switch r { - case AlertingWebhooksTypeSlack, AlertingWebhooksTypeGeneric, AlertingWebhooksTypeGchat: + case WebhooksTypeSlack, WebhooksTypeGeneric, WebhooksTypeGchat: return true } return false @@ -222,13 +221,13 @@ func (r destinationWebhookUpdateResponseJSON) RawJSON() string { // Union satisfied by [alerting.DestinationWebhookDeleteResponseUnknown], // [alerting.DestinationWebhookDeleteResponseArray] or [shared.UnionString]. -type DestinationWebhookDeleteResponse interface { - ImplementsAlertingDestinationWebhookDeleteResponse() +type DestinationWebhookDeleteResponseUnion interface { + ImplementsAlertingDestinationWebhookDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DestinationWebhookDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*DestinationWebhookDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -243,7 +242,8 @@ func init() { type DestinationWebhookDeleteResponseArray []interface{} -func (r DestinationWebhookDeleteResponseArray) ImplementsAlertingDestinationWebhookDeleteResponse() {} +func (r DestinationWebhookDeleteResponseArray) ImplementsAlertingDestinationWebhookDeleteResponseUnion() { +} type DestinationWebhookNewParams struct { // The account id @@ -264,9 +264,9 @@ func (r DestinationWebhookNewParams) MarshalJSON() (data []byte, err error) { } type DestinationWebhookNewResponseEnvelope struct { - Errors []DestinationWebhookNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationWebhookNewResponseEnvelopeMessages `json:"messages,required"` - Result DestinationWebhookNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DestinationWebhookNewResponse `json:"result,required"` // Whether the API call was successful Success DestinationWebhookNewResponseEnvelopeSuccess `json:"success,required"` JSON destinationWebhookNewResponseEnvelopeJSON `json:"-"` @@ -291,52 +291,6 @@ func (r destinationWebhookNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationWebhookNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationWebhookNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DestinationWebhookNewResponseEnvelopeErrors] -type destinationWebhookNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationWebhookNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationWebhookNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DestinationWebhookNewResponseEnvelopeMessages] -type destinationWebhookNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationWebhookNewResponseEnvelopeSuccess bool @@ -371,9 +325,9 @@ func (r DestinationWebhookUpdateParams) MarshalJSON() (data []byte, err error) { } type DestinationWebhookUpdateResponseEnvelope struct { - Errors []DestinationWebhookUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationWebhookUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DestinationWebhookUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DestinationWebhookUpdateResponse `json:"result,required"` // Whether the API call was successful Success DestinationWebhookUpdateResponseEnvelopeSuccess `json:"success,required"` JSON destinationWebhookUpdateResponseEnvelopeJSON `json:"-"` @@ -398,52 +352,6 @@ func (r destinationWebhookUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationWebhookUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationWebhookUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DestinationWebhookUpdateResponseEnvelopeErrors] -type destinationWebhookUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationWebhookUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationWebhookUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DestinationWebhookUpdateResponseEnvelopeMessages] -type destinationWebhookUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationWebhookUpdateResponseEnvelopeSuccess bool @@ -470,9 +378,9 @@ type DestinationWebhookDeleteParams struct { } type DestinationWebhookDeleteResponseEnvelope struct { - Errors []DestinationWebhookDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationWebhookDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DestinationWebhookDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DestinationWebhookDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success DestinationWebhookDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo DestinationWebhookDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -499,52 +407,6 @@ func (r destinationWebhookDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationWebhookDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationWebhookDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DestinationWebhookDeleteResponseEnvelopeErrors] -type destinationWebhookDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationWebhookDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationWebhookDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DestinationWebhookDeleteResponseEnvelopeMessages] -type destinationWebhookDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationWebhookDeleteResponseEnvelopeSuccess bool @@ -597,9 +459,9 @@ type DestinationWebhookGetParams struct { } type DestinationWebhookGetResponseEnvelope struct { - Errors []DestinationWebhookGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DestinationWebhookGetResponseEnvelopeMessages `json:"messages,required"` - Result AlertingWebhooks `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Webhooks `json:"result,required"` // Whether the API call was successful Success DestinationWebhookGetResponseEnvelopeSuccess `json:"success,required"` JSON destinationWebhookGetResponseEnvelopeJSON `json:"-"` @@ -624,52 +486,6 @@ func (r destinationWebhookGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DestinationWebhookGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// destinationWebhookGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DestinationWebhookGetResponseEnvelopeErrors] -type destinationWebhookGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DestinationWebhookGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON destinationWebhookGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// destinationWebhookGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DestinationWebhookGetResponseEnvelopeMessages] -type destinationWebhookGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DestinationWebhookGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r destinationWebhookGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DestinationWebhookGetResponseEnvelopeSuccess bool diff --git a/alerting/history.go b/alerting/history.go index 9d2dbc8a338..a99da6fcbd8 100644 --- a/alerting/history.go +++ b/alerting/history.go @@ -37,7 +37,7 @@ func NewHistoryService(opts ...option.RequestOption) (r *HistoryService) { // Gets a list of history records for notifications sent to an account. The records // are displayed for last `x` number of days based on the zone plan (free = 30, pro // = 30, biz = 30, ent = 90). -func (r *HistoryService) List(ctx context.Context, params HistoryListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[AlertingHistory], err error) { +func (r *HistoryService) List(ctx context.Context, params HistoryListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[History], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -57,11 +57,11 @@ func (r *HistoryService) List(ctx context.Context, params HistoryListParams, opt // Gets a list of history records for notifications sent to an account. The records // are displayed for last `x` number of days based on the zone plan (free = 30, pro // = 30, biz = 30, ent = 90). -func (r *HistoryService) ListAutoPaging(ctx context.Context, params HistoryListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[AlertingHistory] { +func (r *HistoryService) ListAutoPaging(ctx context.Context, params HistoryListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[History] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } -type AlertingHistory struct { +type History struct { // UUID ID string `json:"id"` // Message body included in the notification sent. @@ -74,18 +74,18 @@ type AlertingHistory struct { Mechanism string `json:"mechanism"` // The type of mechanism to which the notification has been dispatched. This can be // email/pagerduty/webhook based on the mechanism configured. - MechanismType AlertingHistoryMechanismType `json:"mechanism_type"` + MechanismType HistoryMechanismType `json:"mechanism_type"` // Name of the policy. Name string `json:"name"` // The unique identifier of a notification policy PolicyID string `json:"policy_id"` // Timestamp of when the notification was dispatched in ISO 8601 format. - Sent time.Time `json:"sent" format:"date-time"` - JSON alertingHistoryJSON `json:"-"` + Sent time.Time `json:"sent" format:"date-time"` + JSON historyJSON `json:"-"` } -// alertingHistoryJSON contains the JSON metadata for the struct [AlertingHistory] -type alertingHistoryJSON struct { +// historyJSON contains the JSON metadata for the struct [History] +type historyJSON struct { ID apijson.Field AlertBody apijson.Field AlertType apijson.Field @@ -99,27 +99,27 @@ type alertingHistoryJSON struct { ExtraFields map[string]apijson.Field } -func (r *AlertingHistory) UnmarshalJSON(data []byte) (err error) { +func (r *History) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingHistoryJSON) RawJSON() string { +func (r historyJSON) RawJSON() string { return r.raw } // The type of mechanism to which the notification has been dispatched. This can be // email/pagerduty/webhook based on the mechanism configured. -type AlertingHistoryMechanismType string +type HistoryMechanismType string const ( - AlertingHistoryMechanismTypeEmail AlertingHistoryMechanismType = "email" - AlertingHistoryMechanismTypePagerduty AlertingHistoryMechanismType = "pagerduty" - AlertingHistoryMechanismTypeWebhook AlertingHistoryMechanismType = "webhook" + HistoryMechanismTypeEmail HistoryMechanismType = "email" + HistoryMechanismTypePagerduty HistoryMechanismType = "pagerduty" + HistoryMechanismTypeWebhook HistoryMechanismType = "webhook" ) -func (r AlertingHistoryMechanismType) IsKnown() bool { +func (r HistoryMechanismType) IsKnown() bool { switch r { - case AlertingHistoryMechanismTypeEmail, AlertingHistoryMechanismTypePagerduty, AlertingHistoryMechanismTypeWebhook: + case HistoryMechanismTypeEmail, HistoryMechanismTypePagerduty, HistoryMechanismTypeWebhook: return true } return false @@ -143,7 +143,7 @@ type HistoryListParams struct { // URLQuery serializes [HistoryListParams]'s query parameters as `url.Values`. func (r HistoryListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/alerting/policy.go b/alerting/policy.go index 37e056bf79e..cddd12190f8 100644 --- a/alerting/policy.go +++ b/alerting/policy.go @@ -62,7 +62,7 @@ func (r *PolicyService) Update(ctx context.Context, policyID string, params Poli } // Get a list of all Notification policies. -func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AlertingPolicies], err error) { +func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Policy], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -80,12 +80,12 @@ func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts . } // Get a list of all Notification policies. -func (r *PolicyService) ListAutoPaging(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AlertingPolicies] { +func (r *PolicyService) ListAutoPaging(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Policy] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete a Notification policy. -func (r *PolicyService) Delete(ctx context.Context, policyID string, body PolicyDeleteParams, opts ...option.RequestOption) (res *PolicyDeleteResponse, err error) { +func (r *PolicyService) Delete(ctx context.Context, policyID string, body PolicyDeleteParams, opts ...option.RequestOption) (res *PolicyDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PolicyDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", body.AccountID, policyID) @@ -98,7 +98,7 @@ func (r *PolicyService) Delete(ctx context.Context, policyID string, body Policy } // Get details for a single policy. -func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGetParams, opts ...option.RequestOption) (res *AlertingPolicies, err error) { +func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGetParams, opts ...option.RequestOption) (res *Policy, err error) { opts = append(r.Options[:], opts...) var env PolicyGetResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", query.AccountID, policyID) @@ -110,14 +110,18 @@ func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGe return } -type AlertingPolicies struct { +type Mechanism map[string][]Mechanism + +type MechanismParam map[string][]MechanismParam + +type Policy struct { // The unique identifier of a notification policy ID string `json:"id"` // Refers to which event will trigger a Notification dispatch. You can use the // endpoint to get available alert types which then will give you a list of // possible values. - AlertType AlertingPoliciesAlertType `json:"alert_type"` - Created time.Time `json:"created" format:"date-time"` + AlertType PolicyAlertType `json:"alert_type"` + Created time.Time `json:"created" format:"date-time"` // Optional description for the Notification policy. Description string `json:"description"` // Whether or not the Notification policy is enabled. @@ -125,19 +129,18 @@ type AlertingPolicies struct { // Optional filters that allow you to be alerted only on a subset of events for // that alert type based on some criteria. This is only available for select alert // types. See alert type documentation for more details. - Filters AlertingPoliciesFilters `json:"filters"` + Filters PolicyFilter `json:"filters"` // List of IDs that will be used when dispatching a notification. IDs for email // type will be the email address. - Mechanisms map[string][]AlertingPoliciesMechanisms `json:"mechanisms"` - Modified time.Time `json:"modified" format:"date-time"` + Mechanisms Mechanism `json:"mechanisms"` + Modified time.Time `json:"modified" format:"date-time"` // Name of the policy. - Name string `json:"name"` - JSON alertingPoliciesJSON `json:"-"` + Name string `json:"name"` + JSON policyJSON `json:"-"` } -// alertingPoliciesJSON contains the JSON metadata for the struct -// [AlertingPolicies] -type alertingPoliciesJSON struct { +// policyJSON contains the JSON metadata for the struct [Policy] +type policyJSON struct { ID apijson.Field AlertType apijson.Field Created apijson.Field @@ -151,89 +154,113 @@ type alertingPoliciesJSON struct { ExtraFields map[string]apijson.Field } -func (r *AlertingPolicies) UnmarshalJSON(data []byte) (err error) { +func (r *Policy) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingPoliciesJSON) RawJSON() string { +func (r policyJSON) RawJSON() string { return r.raw } // Refers to which event will trigger a Notification dispatch. You can use the // endpoint to get available alert types which then will give you a list of // possible values. -type AlertingPoliciesAlertType string +type PolicyAlertType string const ( - AlertingPoliciesAlertTypeAccessCustomCertificateExpirationType AlertingPoliciesAlertType = "access_custom_certificate_expiration_type" - AlertingPoliciesAlertTypeAdvancedDDoSAttackL4Alert AlertingPoliciesAlertType = "advanced_ddos_attack_l4_alert" - AlertingPoliciesAlertTypeAdvancedDDoSAttackL7Alert AlertingPoliciesAlertType = "advanced_ddos_attack_l7_alert" - AlertingPoliciesAlertTypeAdvancedHTTPAlertError AlertingPoliciesAlertType = "advanced_http_alert_error" - AlertingPoliciesAlertTypeBGPHijackNotification AlertingPoliciesAlertType = "bgp_hijack_notification" - AlertingPoliciesAlertTypeBillingUsageAlert AlertingPoliciesAlertType = "billing_usage_alert" - AlertingPoliciesAlertTypeBlockNotificationBlockRemoved AlertingPoliciesAlertType = "block_notification_block_removed" - AlertingPoliciesAlertTypeBlockNotificationNewBlock AlertingPoliciesAlertType = "block_notification_new_block" - AlertingPoliciesAlertTypeBlockNotificationReviewRejected AlertingPoliciesAlertType = "block_notification_review_rejected" - AlertingPoliciesAlertTypeBrandProtectionAlert AlertingPoliciesAlertType = "brand_protection_alert" - AlertingPoliciesAlertTypeBrandProtectionDigest AlertingPoliciesAlertType = "brand_protection_digest" - AlertingPoliciesAlertTypeClickhouseAlertFwAnomaly AlertingPoliciesAlertType = "clickhouse_alert_fw_anomaly" - AlertingPoliciesAlertTypeClickhouseAlertFwEntAnomaly AlertingPoliciesAlertType = "clickhouse_alert_fw_ent_anomaly" - AlertingPoliciesAlertTypeCustomSSLCertificateEventType AlertingPoliciesAlertType = "custom_ssl_certificate_event_type" - AlertingPoliciesAlertTypeDedicatedSSLCertificateEventType AlertingPoliciesAlertType = "dedicated_ssl_certificate_event_type" - AlertingPoliciesAlertTypeDosAttackL4 AlertingPoliciesAlertType = "dos_attack_l4" - AlertingPoliciesAlertTypeDosAttackL7 AlertingPoliciesAlertType = "dos_attack_l7" - AlertingPoliciesAlertTypeExpiringServiceTokenAlert AlertingPoliciesAlertType = "expiring_service_token_alert" - AlertingPoliciesAlertTypeFailingLogpushJobDisabledAlert AlertingPoliciesAlertType = "failing_logpush_job_disabled_alert" - AlertingPoliciesAlertTypeFbmAutoAdvertisement AlertingPoliciesAlertType = "fbm_auto_advertisement" - AlertingPoliciesAlertTypeFbmDosdAttack AlertingPoliciesAlertType = "fbm_dosd_attack" - AlertingPoliciesAlertTypeFbmVolumetricAttack AlertingPoliciesAlertType = "fbm_volumetric_attack" - AlertingPoliciesAlertTypeHealthCheckStatusNotification AlertingPoliciesAlertType = "health_check_status_notification" - AlertingPoliciesAlertTypeHostnameAopCustomCertificateExpirationType AlertingPoliciesAlertType = "hostname_aop_custom_certificate_expiration_type" - AlertingPoliciesAlertTypeHTTPAlertEdgeError AlertingPoliciesAlertType = "http_alert_edge_error" - AlertingPoliciesAlertTypeHTTPAlertOriginError AlertingPoliciesAlertType = "http_alert_origin_error" - AlertingPoliciesAlertTypeIncidentAlert AlertingPoliciesAlertType = "incident_alert" - AlertingPoliciesAlertTypeLoadBalancingHealthAlert AlertingPoliciesAlertType = "load_balancing_health_alert" - AlertingPoliciesAlertTypeLoadBalancingPoolEnablementAlert AlertingPoliciesAlertType = "load_balancing_pool_enablement_alert" - AlertingPoliciesAlertTypeLogoMatchAlert AlertingPoliciesAlertType = "logo_match_alert" - AlertingPoliciesAlertTypeMagicTunnelHealthCheckEvent AlertingPoliciesAlertType = "magic_tunnel_health_check_event" - AlertingPoliciesAlertTypeMaintenanceEventNotification AlertingPoliciesAlertType = "maintenance_event_notification" - AlertingPoliciesAlertTypeMTLSCertificateStoreCertificateExpirationType AlertingPoliciesAlertType = "mtls_certificate_store_certificate_expiration_type" - AlertingPoliciesAlertTypePagesEventAlert AlertingPoliciesAlertType = "pages_event_alert" - AlertingPoliciesAlertTypeRadarNotification AlertingPoliciesAlertType = "radar_notification" - AlertingPoliciesAlertTypeRealOriginMonitoring AlertingPoliciesAlertType = "real_origin_monitoring" - AlertingPoliciesAlertTypeScriptmonitorAlertNewCodeChangeDetections AlertingPoliciesAlertType = "scriptmonitor_alert_new_code_change_detections" - AlertingPoliciesAlertTypeScriptmonitorAlertNewHosts AlertingPoliciesAlertType = "scriptmonitor_alert_new_hosts" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousHosts AlertingPoliciesAlertType = "scriptmonitor_alert_new_malicious_hosts" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousScripts AlertingPoliciesAlertType = "scriptmonitor_alert_new_malicious_scripts" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousURL AlertingPoliciesAlertType = "scriptmonitor_alert_new_malicious_url" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaxLengthResourceURL AlertingPoliciesAlertType = "scriptmonitor_alert_new_max_length_resource_url" - AlertingPoliciesAlertTypeScriptmonitorAlertNewResources AlertingPoliciesAlertType = "scriptmonitor_alert_new_resources" - AlertingPoliciesAlertTypeSecondaryDNSAllPrimariesFailing AlertingPoliciesAlertType = "secondary_dns_all_primaries_failing" - AlertingPoliciesAlertTypeSecondaryDNSPrimariesFailing AlertingPoliciesAlertType = "secondary_dns_primaries_failing" - AlertingPoliciesAlertTypeSecondaryDNSZoneSuccessfullyUpdated AlertingPoliciesAlertType = "secondary_dns_zone_successfully_updated" - AlertingPoliciesAlertTypeSecondaryDNSZoneValidationWarning AlertingPoliciesAlertType = "secondary_dns_zone_validation_warning" - AlertingPoliciesAlertTypeSentinelAlert AlertingPoliciesAlertType = "sentinel_alert" - AlertingPoliciesAlertTypeStreamLiveNotifications AlertingPoliciesAlertType = "stream_live_notifications" - AlertingPoliciesAlertTypeTrafficAnomaliesAlert AlertingPoliciesAlertType = "traffic_anomalies_alert" - AlertingPoliciesAlertTypeTunnelHealthEvent AlertingPoliciesAlertType = "tunnel_health_event" - AlertingPoliciesAlertTypeTunnelUpdateEvent AlertingPoliciesAlertType = "tunnel_update_event" - AlertingPoliciesAlertTypeUniversalSSLEventType AlertingPoliciesAlertType = "universal_ssl_event_type" - AlertingPoliciesAlertTypeWebAnalyticsMetricsUpdate AlertingPoliciesAlertType = "web_analytics_metrics_update" - AlertingPoliciesAlertTypeZoneAopCustomCertificateExpirationType AlertingPoliciesAlertType = "zone_aop_custom_certificate_expiration_type" + PolicyAlertTypeAccessCustomCertificateExpirationType PolicyAlertType = "access_custom_certificate_expiration_type" + PolicyAlertTypeAdvancedDDoSAttackL4Alert PolicyAlertType = "advanced_ddos_attack_l4_alert" + PolicyAlertTypeAdvancedDDoSAttackL7Alert PolicyAlertType = "advanced_ddos_attack_l7_alert" + PolicyAlertTypeAdvancedHTTPAlertError PolicyAlertType = "advanced_http_alert_error" + PolicyAlertTypeBGPHijackNotification PolicyAlertType = "bgp_hijack_notification" + PolicyAlertTypeBillingUsageAlert PolicyAlertType = "billing_usage_alert" + PolicyAlertTypeBlockNotificationBlockRemoved PolicyAlertType = "block_notification_block_removed" + PolicyAlertTypeBlockNotificationNewBlock PolicyAlertType = "block_notification_new_block" + PolicyAlertTypeBlockNotificationReviewRejected PolicyAlertType = "block_notification_review_rejected" + PolicyAlertTypeBrandProtectionAlert PolicyAlertType = "brand_protection_alert" + PolicyAlertTypeBrandProtectionDigest PolicyAlertType = "brand_protection_digest" + PolicyAlertTypeClickhouseAlertFwAnomaly PolicyAlertType = "clickhouse_alert_fw_anomaly" + PolicyAlertTypeClickhouseAlertFwEntAnomaly PolicyAlertType = "clickhouse_alert_fw_ent_anomaly" + PolicyAlertTypeCustomSSLCertificateEventType PolicyAlertType = "custom_ssl_certificate_event_type" + PolicyAlertTypeDedicatedSSLCertificateEventType PolicyAlertType = "dedicated_ssl_certificate_event_type" + PolicyAlertTypeDosAttackL4 PolicyAlertType = "dos_attack_l4" + PolicyAlertTypeDosAttackL7 PolicyAlertType = "dos_attack_l7" + PolicyAlertTypeExpiringServiceTokenAlert PolicyAlertType = "expiring_service_token_alert" + PolicyAlertTypeFailingLogpushJobDisabledAlert PolicyAlertType = "failing_logpush_job_disabled_alert" + PolicyAlertTypeFbmAutoAdvertisement PolicyAlertType = "fbm_auto_advertisement" + PolicyAlertTypeFbmDosdAttack PolicyAlertType = "fbm_dosd_attack" + PolicyAlertTypeFbmVolumetricAttack PolicyAlertType = "fbm_volumetric_attack" + PolicyAlertTypeHealthCheckStatusNotification PolicyAlertType = "health_check_status_notification" + PolicyAlertTypeHostnameAopCustomCertificateExpirationType PolicyAlertType = "hostname_aop_custom_certificate_expiration_type" + PolicyAlertTypeHTTPAlertEdgeError PolicyAlertType = "http_alert_edge_error" + PolicyAlertTypeHTTPAlertOriginError PolicyAlertType = "http_alert_origin_error" + PolicyAlertTypeIncidentAlert PolicyAlertType = "incident_alert" + PolicyAlertTypeLoadBalancingHealthAlert PolicyAlertType = "load_balancing_health_alert" + PolicyAlertTypeLoadBalancingPoolEnablementAlert PolicyAlertType = "load_balancing_pool_enablement_alert" + PolicyAlertTypeLogoMatchAlert PolicyAlertType = "logo_match_alert" + PolicyAlertTypeMagicTunnelHealthCheckEvent PolicyAlertType = "magic_tunnel_health_check_event" + PolicyAlertTypeMaintenanceEventNotification PolicyAlertType = "maintenance_event_notification" + PolicyAlertTypeMTLSCertificateStoreCertificateExpirationType PolicyAlertType = "mtls_certificate_store_certificate_expiration_type" + PolicyAlertTypePagesEventAlert PolicyAlertType = "pages_event_alert" + PolicyAlertTypeRadarNotification PolicyAlertType = "radar_notification" + PolicyAlertTypeRealOriginMonitoring PolicyAlertType = "real_origin_monitoring" + PolicyAlertTypeScriptmonitorAlertNewCodeChangeDetections PolicyAlertType = "scriptmonitor_alert_new_code_change_detections" + PolicyAlertTypeScriptmonitorAlertNewHosts PolicyAlertType = "scriptmonitor_alert_new_hosts" + PolicyAlertTypeScriptmonitorAlertNewMaliciousHosts PolicyAlertType = "scriptmonitor_alert_new_malicious_hosts" + PolicyAlertTypeScriptmonitorAlertNewMaliciousScripts PolicyAlertType = "scriptmonitor_alert_new_malicious_scripts" + PolicyAlertTypeScriptmonitorAlertNewMaliciousURL PolicyAlertType = "scriptmonitor_alert_new_malicious_url" + PolicyAlertTypeScriptmonitorAlertNewMaxLengthResourceURL PolicyAlertType = "scriptmonitor_alert_new_max_length_resource_url" + PolicyAlertTypeScriptmonitorAlertNewResources PolicyAlertType = "scriptmonitor_alert_new_resources" + PolicyAlertTypeSecondaryDNSAllPrimariesFailing PolicyAlertType = "secondary_dns_all_primaries_failing" + PolicyAlertTypeSecondaryDNSPrimariesFailing PolicyAlertType = "secondary_dns_primaries_failing" + PolicyAlertTypeSecondaryDNSZoneSuccessfullyUpdated PolicyAlertType = "secondary_dns_zone_successfully_updated" + PolicyAlertTypeSecondaryDNSZoneValidationWarning PolicyAlertType = "secondary_dns_zone_validation_warning" + PolicyAlertTypeSentinelAlert PolicyAlertType = "sentinel_alert" + PolicyAlertTypeStreamLiveNotifications PolicyAlertType = "stream_live_notifications" + PolicyAlertTypeTrafficAnomaliesAlert PolicyAlertType = "traffic_anomalies_alert" + PolicyAlertTypeTunnelHealthEvent PolicyAlertType = "tunnel_health_event" + PolicyAlertTypeTunnelUpdateEvent PolicyAlertType = "tunnel_update_event" + PolicyAlertTypeUniversalSSLEventType PolicyAlertType = "universal_ssl_event_type" + PolicyAlertTypeWebAnalyticsMetricsUpdate PolicyAlertType = "web_analytics_metrics_update" + PolicyAlertTypeZoneAopCustomCertificateExpirationType PolicyAlertType = "zone_aop_custom_certificate_expiration_type" ) -func (r AlertingPoliciesAlertType) IsKnown() bool { +func (r PolicyAlertType) IsKnown() bool { switch r { - case AlertingPoliciesAlertTypeAccessCustomCertificateExpirationType, AlertingPoliciesAlertTypeAdvancedDDoSAttackL4Alert, AlertingPoliciesAlertTypeAdvancedDDoSAttackL7Alert, AlertingPoliciesAlertTypeAdvancedHTTPAlertError, AlertingPoliciesAlertTypeBGPHijackNotification, AlertingPoliciesAlertTypeBillingUsageAlert, AlertingPoliciesAlertTypeBlockNotificationBlockRemoved, AlertingPoliciesAlertTypeBlockNotificationNewBlock, AlertingPoliciesAlertTypeBlockNotificationReviewRejected, AlertingPoliciesAlertTypeBrandProtectionAlert, AlertingPoliciesAlertTypeBrandProtectionDigest, AlertingPoliciesAlertTypeClickhouseAlertFwAnomaly, AlertingPoliciesAlertTypeClickhouseAlertFwEntAnomaly, AlertingPoliciesAlertTypeCustomSSLCertificateEventType, AlertingPoliciesAlertTypeDedicatedSSLCertificateEventType, AlertingPoliciesAlertTypeDosAttackL4, AlertingPoliciesAlertTypeDosAttackL7, AlertingPoliciesAlertTypeExpiringServiceTokenAlert, AlertingPoliciesAlertTypeFailingLogpushJobDisabledAlert, AlertingPoliciesAlertTypeFbmAutoAdvertisement, AlertingPoliciesAlertTypeFbmDosdAttack, AlertingPoliciesAlertTypeFbmVolumetricAttack, AlertingPoliciesAlertTypeHealthCheckStatusNotification, AlertingPoliciesAlertTypeHostnameAopCustomCertificateExpirationType, AlertingPoliciesAlertTypeHTTPAlertEdgeError, AlertingPoliciesAlertTypeHTTPAlertOriginError, AlertingPoliciesAlertTypeIncidentAlert, AlertingPoliciesAlertTypeLoadBalancingHealthAlert, AlertingPoliciesAlertTypeLoadBalancingPoolEnablementAlert, AlertingPoliciesAlertTypeLogoMatchAlert, AlertingPoliciesAlertTypeMagicTunnelHealthCheckEvent, AlertingPoliciesAlertTypeMaintenanceEventNotification, AlertingPoliciesAlertTypeMTLSCertificateStoreCertificateExpirationType, AlertingPoliciesAlertTypePagesEventAlert, AlertingPoliciesAlertTypeRadarNotification, AlertingPoliciesAlertTypeRealOriginMonitoring, AlertingPoliciesAlertTypeScriptmonitorAlertNewCodeChangeDetections, AlertingPoliciesAlertTypeScriptmonitorAlertNewHosts, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousHosts, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousScripts, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousURL, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaxLengthResourceURL, AlertingPoliciesAlertTypeScriptmonitorAlertNewResources, AlertingPoliciesAlertTypeSecondaryDNSAllPrimariesFailing, AlertingPoliciesAlertTypeSecondaryDNSPrimariesFailing, AlertingPoliciesAlertTypeSecondaryDNSZoneSuccessfullyUpdated, AlertingPoliciesAlertTypeSecondaryDNSZoneValidationWarning, AlertingPoliciesAlertTypeSentinelAlert, AlertingPoliciesAlertTypeStreamLiveNotifications, AlertingPoliciesAlertTypeTrafficAnomaliesAlert, AlertingPoliciesAlertTypeTunnelHealthEvent, AlertingPoliciesAlertTypeTunnelUpdateEvent, AlertingPoliciesAlertTypeUniversalSSLEventType, AlertingPoliciesAlertTypeWebAnalyticsMetricsUpdate, AlertingPoliciesAlertTypeZoneAopCustomCertificateExpirationType: + case PolicyAlertTypeAccessCustomCertificateExpirationType, PolicyAlertTypeAdvancedDDoSAttackL4Alert, PolicyAlertTypeAdvancedDDoSAttackL7Alert, PolicyAlertTypeAdvancedHTTPAlertError, PolicyAlertTypeBGPHijackNotification, PolicyAlertTypeBillingUsageAlert, PolicyAlertTypeBlockNotificationBlockRemoved, PolicyAlertTypeBlockNotificationNewBlock, PolicyAlertTypeBlockNotificationReviewRejected, PolicyAlertTypeBrandProtectionAlert, PolicyAlertTypeBrandProtectionDigest, PolicyAlertTypeClickhouseAlertFwAnomaly, PolicyAlertTypeClickhouseAlertFwEntAnomaly, PolicyAlertTypeCustomSSLCertificateEventType, PolicyAlertTypeDedicatedSSLCertificateEventType, PolicyAlertTypeDosAttackL4, PolicyAlertTypeDosAttackL7, PolicyAlertTypeExpiringServiceTokenAlert, PolicyAlertTypeFailingLogpushJobDisabledAlert, PolicyAlertTypeFbmAutoAdvertisement, PolicyAlertTypeFbmDosdAttack, PolicyAlertTypeFbmVolumetricAttack, PolicyAlertTypeHealthCheckStatusNotification, PolicyAlertTypeHostnameAopCustomCertificateExpirationType, PolicyAlertTypeHTTPAlertEdgeError, PolicyAlertTypeHTTPAlertOriginError, PolicyAlertTypeIncidentAlert, PolicyAlertTypeLoadBalancingHealthAlert, PolicyAlertTypeLoadBalancingPoolEnablementAlert, PolicyAlertTypeLogoMatchAlert, PolicyAlertTypeMagicTunnelHealthCheckEvent, PolicyAlertTypeMaintenanceEventNotification, PolicyAlertTypeMTLSCertificateStoreCertificateExpirationType, PolicyAlertTypePagesEventAlert, PolicyAlertTypeRadarNotification, PolicyAlertTypeRealOriginMonitoring, PolicyAlertTypeScriptmonitorAlertNewCodeChangeDetections, PolicyAlertTypeScriptmonitorAlertNewHosts, PolicyAlertTypeScriptmonitorAlertNewMaliciousHosts, PolicyAlertTypeScriptmonitorAlertNewMaliciousScripts, PolicyAlertTypeScriptmonitorAlertNewMaliciousURL, PolicyAlertTypeScriptmonitorAlertNewMaxLengthResourceURL, PolicyAlertTypeScriptmonitorAlertNewResources, PolicyAlertTypeSecondaryDNSAllPrimariesFailing, PolicyAlertTypeSecondaryDNSPrimariesFailing, PolicyAlertTypeSecondaryDNSZoneSuccessfullyUpdated, PolicyAlertTypeSecondaryDNSZoneValidationWarning, PolicyAlertTypeSentinelAlert, PolicyAlertTypeStreamLiveNotifications, PolicyAlertTypeTrafficAnomaliesAlert, PolicyAlertTypeTunnelHealthEvent, PolicyAlertTypeTunnelUpdateEvent, PolicyAlertTypeUniversalSSLEventType, PolicyAlertTypeWebAnalyticsMetricsUpdate, PolicyAlertTypeZoneAopCustomCertificateExpirationType: return true } return false } +type PolicyParam struct { + // Refers to which event will trigger a Notification dispatch. You can use the + // endpoint to get available alert types which then will give you a list of + // possible values. + AlertType param.Field[PolicyAlertType] `json:"alert_type"` + // Optional description for the Notification policy. + Description param.Field[string] `json:"description"` + // Whether or not the Notification policy is enabled. + Enabled param.Field[bool] `json:"enabled"` + // Optional filters that allow you to be alerted only on a subset of events for + // that alert type based on some criteria. This is only available for select alert + // types. See alert type documentation for more details. + Filters param.Field[PolicyFilterParam] `json:"filters"` + // List of IDs that will be used when dispatching a notification. IDs for email + // type will be the email address. + Mechanisms param.Field[MechanismParam] `json:"mechanisms"` + // Name of the policy. + Name param.Field[string] `json:"name"` +} + +func (r PolicyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Optional filters that allow you to be alerted only on a subset of events for // that alert type based on some criteria. This is only available for select alert // types. See alert type documentation for more details. -type AlertingPoliciesFilters struct { +type PolicyFilter struct { // Usage depends on specific alert type Actions []string `json:"actions"` // Used for configuring radar_notification @@ -248,7 +275,7 @@ type AlertingPoliciesFilters struct { // Usage depends on specific alert type AlertTriggerPreferences []string `json:"alert_trigger_preferences"` // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue []AlertingPoliciesFiltersAlertTriggerPreferencesValue `json:"alert_trigger_preferences_value"` + AlertTriggerPreferencesValue []PolicyFilterAlertTriggerPreferencesValue `json:"alert_trigger_preferences_value"` // Used for configuring load_balancing_pool_enablement_alert Enabled []string `json:"enabled"` // Used for configuring pages_event_alert @@ -264,7 +291,7 @@ type AlertingPoliciesFilters struct { // Used for configuring health_check_status_notification HealthCheckID []string `json:"health_check_id"` // Used for configuring incident_alert - IncidentImpact []AlertingPoliciesFiltersIncidentImpact `json:"incident_impact"` + IncidentImpact []PolicyFilterIncidentImpact `json:"incident_impact"` // Used for configuring stream_live_notifications InputID []string `json:"input_id"` // Used for configuring billing_usage_alert @@ -306,7 +333,7 @@ type AlertingPoliciesFilters struct { // Used for configuring advanced_ddos_attack_l7_alert TargetZoneName []string `json:"target_zone_name"` // Used for configuring traffic_anomalies_alert - TrafficExclusions []AlertingPoliciesFiltersTrafficExclusion `json:"traffic_exclusions"` + TrafficExclusions []PolicyFilterTrafficExclusion `json:"traffic_exclusions"` // Used for configuring tunnel_health_event TunnelID []string `json:"tunnel_id"` // Used for configuring magic_tunnel_health_check_event @@ -314,13 +341,12 @@ type AlertingPoliciesFilters struct { // Usage depends on specific alert type Where []string `json:"where"` // Usage depends on specific alert type - Zones []string `json:"zones"` - JSON alertingPoliciesFiltersJSON `json:"-"` + Zones []string `json:"zones"` + JSON policyFilterJSON `json:"-"` } -// alertingPoliciesFiltersJSON contains the JSON metadata for the struct -// [AlertingPoliciesFilters] -type alertingPoliciesFiltersJSON struct { +// policyFilterJSON contains the JSON metadata for the struct [PolicyFilter] +type policyFilterJSON struct { Actions apijson.Field AffectedASNs apijson.Field AffectedComponents apijson.Field @@ -365,103 +391,150 @@ type alertingPoliciesFiltersJSON struct { ExtraFields map[string]apijson.Field } -func (r *AlertingPoliciesFilters) UnmarshalJSON(data []byte) (err error) { +func (r *PolicyFilter) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingPoliciesFiltersJSON) RawJSON() string { +func (r policyFilterJSON) RawJSON() string { return r.raw } -type AlertingPoliciesFiltersAlertTriggerPreferencesValue string +type PolicyFilterAlertTriggerPreferencesValue string const ( - AlertingPoliciesFiltersAlertTriggerPreferencesValue99_0 AlertingPoliciesFiltersAlertTriggerPreferencesValue = "99.0" - AlertingPoliciesFiltersAlertTriggerPreferencesValue98_0 AlertingPoliciesFiltersAlertTriggerPreferencesValue = "98.0" - AlertingPoliciesFiltersAlertTriggerPreferencesValue97_0 AlertingPoliciesFiltersAlertTriggerPreferencesValue = "97.0" + PolicyFilterAlertTriggerPreferencesValue99_0 PolicyFilterAlertTriggerPreferencesValue = "99.0" + PolicyFilterAlertTriggerPreferencesValue98_0 PolicyFilterAlertTriggerPreferencesValue = "98.0" + PolicyFilterAlertTriggerPreferencesValue97_0 PolicyFilterAlertTriggerPreferencesValue = "97.0" ) -func (r AlertingPoliciesFiltersAlertTriggerPreferencesValue) IsKnown() bool { +func (r PolicyFilterAlertTriggerPreferencesValue) IsKnown() bool { switch r { - case AlertingPoliciesFiltersAlertTriggerPreferencesValue99_0, AlertingPoliciesFiltersAlertTriggerPreferencesValue98_0, AlertingPoliciesFiltersAlertTriggerPreferencesValue97_0: + case PolicyFilterAlertTriggerPreferencesValue99_0, PolicyFilterAlertTriggerPreferencesValue98_0, PolicyFilterAlertTriggerPreferencesValue97_0: return true } return false } -type AlertingPoliciesFiltersIncidentImpact string +type PolicyFilterIncidentImpact string const ( - AlertingPoliciesFiltersIncidentImpactIncidentImpactNone AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - AlertingPoliciesFiltersIncidentImpactIncidentImpactMinor AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - AlertingPoliciesFiltersIncidentImpactIncidentImpactMajor AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - AlertingPoliciesFiltersIncidentImpactIncidentImpactCritical AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" + PolicyFilterIncidentImpactIncidentImpactNone PolicyFilterIncidentImpact = "INCIDENT_IMPACT_NONE" + PolicyFilterIncidentImpactIncidentImpactMinor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MINOR" + PolicyFilterIncidentImpactIncidentImpactMajor PolicyFilterIncidentImpact = "INCIDENT_IMPACT_MAJOR" + PolicyFilterIncidentImpactIncidentImpactCritical PolicyFilterIncidentImpact = "INCIDENT_IMPACT_CRITICAL" ) -func (r AlertingPoliciesFiltersIncidentImpact) IsKnown() bool { +func (r PolicyFilterIncidentImpact) IsKnown() bool { switch r { - case AlertingPoliciesFiltersIncidentImpactIncidentImpactNone, AlertingPoliciesFiltersIncidentImpactIncidentImpactMinor, AlertingPoliciesFiltersIncidentImpactIncidentImpactMajor, AlertingPoliciesFiltersIncidentImpactIncidentImpactCritical: + case PolicyFilterIncidentImpactIncidentImpactNone, PolicyFilterIncidentImpactIncidentImpactMinor, PolicyFilterIncidentImpactIncidentImpactMajor, PolicyFilterIncidentImpactIncidentImpactCritical: return true } return false } -type AlertingPoliciesFiltersTrafficExclusion string +type PolicyFilterTrafficExclusion string const ( - AlertingPoliciesFiltersTrafficExclusionSecurityEvents AlertingPoliciesFiltersTrafficExclusion = "security_events" + PolicyFilterTrafficExclusionSecurityEvents PolicyFilterTrafficExclusion = "security_events" ) -func (r AlertingPoliciesFiltersTrafficExclusion) IsKnown() bool { +func (r PolicyFilterTrafficExclusion) IsKnown() bool { switch r { - case AlertingPoliciesFiltersTrafficExclusionSecurityEvents: + case PolicyFilterTrafficExclusionSecurityEvents: return true } return false } -type AlertingPoliciesMechanisms struct { - // UUID - ID AlertingPoliciesMechanismsID `json:"id"` - JSON alertingPoliciesMechanismsJSON `json:"-"` -} - -// alertingPoliciesMechanismsJSON contains the JSON metadata for the struct -// [AlertingPoliciesMechanisms] -type alertingPoliciesMechanismsJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingPoliciesMechanisms) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingPoliciesMechanismsJSON) RawJSON() string { - return r.raw -} - -// UUID -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type AlertingPoliciesMechanismsID interface { - ImplementsAlertingAlertingPoliciesMechanismsID() +// Optional filters that allow you to be alerted only on a subset of events for +// that alert type based on some criteria. This is only available for select alert +// types. See alert type documentation for more details. +type PolicyFilterParam struct { + // Usage depends on specific alert type + Actions param.Field[[]string] `json:"actions"` + // Used for configuring radar_notification + AffectedASNs param.Field[[]string] `json:"affected_asns"` + // Used for configuring incident_alert. A list of identifiers for each component to + // monitor. + AffectedComponents param.Field[[]string] `json:"affected_components"` + // Used for configuring radar_notification + AffectedLocations param.Field[[]string] `json:"affected_locations"` + // Used for configuring maintenance_event_notification + AirportCode param.Field[[]string] `json:"airport_code"` + // Usage depends on specific alert type + AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` + // Used for configuring magic_tunnel_health_check_event + AlertTriggerPreferencesValue param.Field[[]PolicyFilterAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` + // Used for configuring load_balancing_pool_enablement_alert + Enabled param.Field[[]string] `json:"enabled"` + // Used for configuring pages_event_alert + Environment param.Field[[]string] `json:"environment"` + // Used for configuring pages_event_alert + Event param.Field[[]string] `json:"event"` + // Used for configuring load_balancing_health_alert + EventSource param.Field[[]string] `json:"event_source"` + // Usage depends on specific alert type + EventType param.Field[[]string] `json:"event_type"` + // Usage depends on specific alert type + GroupBy param.Field[[]string] `json:"group_by"` + // Used for configuring health_check_status_notification + HealthCheckID param.Field[[]string] `json:"health_check_id"` + // Used for configuring incident_alert + IncidentImpact param.Field[[]PolicyFilterIncidentImpact] `json:"incident_impact"` + // Used for configuring stream_live_notifications + InputID param.Field[[]string] `json:"input_id"` + // Used for configuring billing_usage_alert + Limit param.Field[[]string] `json:"limit"` + // Used for configuring logo_match_alert + LogoTag param.Field[[]string] `json:"logo_tag"` + // Used for configuring advanced_ddos_attack_l4_alert + MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` + // Used for configuring load_balancing_health_alert + NewHealth param.Field[[]string] `json:"new_health"` + // Used for configuring tunnel_health_event + NewStatus param.Field[[]string] `json:"new_status"` + // Used for configuring advanced_ddos_attack_l4_alert + PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` + // Usage depends on specific alert type + PoolID param.Field[[]string] `json:"pool_id"` + // Used for configuring billing_usage_alert + Product param.Field[[]string] `json:"product"` + // Used for configuring pages_event_alert + ProjectID param.Field[[]string] `json:"project_id"` + // Used for configuring advanced_ddos_attack_l4_alert + Protocol param.Field[[]string] `json:"protocol"` + // Usage depends on specific alert type + QueryTag param.Field[[]string] `json:"query_tag"` + // Used for configuring advanced_ddos_attack_l7_alert + RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` + // Usage depends on specific alert type + Selectors param.Field[[]string] `json:"selectors"` + // Used for configuring clickhouse_alert_fw_ent_anomaly + Services param.Field[[]string] `json:"services"` + // Usage depends on specific alert type + Slo param.Field[[]string] `json:"slo"` + // Used for configuring health_check_status_notification + Status param.Field[[]string] `json:"status"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetHostname param.Field[[]string] `json:"target_hostname"` + // Used for configuring advanced_ddos_attack_l4_alert + TargetIP param.Field[[]string] `json:"target_ip"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetZoneName param.Field[[]string] `json:"target_zone_name"` + // Used for configuring traffic_anomalies_alert + TrafficExclusions param.Field[[]PolicyFilterTrafficExclusion] `json:"traffic_exclusions"` + // Used for configuring tunnel_health_event + TunnelID param.Field[[]string] `json:"tunnel_id"` + // Used for configuring magic_tunnel_health_check_event + TunnelName param.Field[[]string] `json:"tunnel_name"` + // Usage depends on specific alert type + Where param.Field[[]string] `json:"where"` + // Usage depends on specific alert type + Zones param.Field[[]string] `json:"zones"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingPoliciesMechanismsID)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) +func (r PolicyFilterParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } type PolicyNewResponse struct { @@ -510,13 +583,13 @@ func (r policyUpdateResponseJSON) RawJSON() string { // Union satisfied by [alerting.PolicyDeleteResponseUnknown], // [alerting.PolicyDeleteResponseArray] or [shared.UnionString]. -type PolicyDeleteResponse interface { - ImplementsAlertingPolicyDeleteResponse() +type PolicyDeleteResponseUnion interface { + ImplementsAlertingPolicyDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PolicyDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*PolicyDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -531,7 +604,7 @@ func init() { type PolicyDeleteResponseArray []interface{} -func (r PolicyDeleteResponseArray) ImplementsAlertingPolicyDeleteResponse() {} +func (r PolicyDeleteResponseArray) ImplementsAlertingPolicyDeleteResponseUnion() {} type PolicyNewParams struct { // The account id @@ -544,7 +617,7 @@ type PolicyNewParams struct { Enabled param.Field[bool] `json:"enabled,required"` // List of IDs that will be used when dispatching a notification. IDs for email // type will be the email address. - Mechanisms param.Field[map[string][]PolicyNewParamsMechanisms] `json:"mechanisms,required"` + Mechanisms param.Field[MechanismParam] `json:"mechanisms,required"` // Name of the policy. Name param.Field[string] `json:"name,required"` // Optional description for the Notification policy. @@ -552,7 +625,7 @@ type PolicyNewParams struct { // Optional filters that allow you to be alerted only on a subset of events for // that alert type based on some criteria. This is only available for select alert // types. See alert type documentation for more details. - Filters param.Field[PolicyNewParamsFilters] `json:"filters"` + Filters param.Field[PolicyFilterParam] `json:"filters"` } func (r PolicyNewParams) MarshalJSON() (data []byte, err error) { @@ -630,164 +703,10 @@ func (r PolicyNewParamsAlertType) IsKnown() bool { return false } -type PolicyNewParamsMechanisms struct { - // UUID - ID param.Field[PolicyNewParamsMechanismsID] `json:"id"` -} - -func (r PolicyNewParamsMechanisms) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// UUID -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type PolicyNewParamsMechanismsID interface { - ImplementsAlertingPolicyNewParamsMechanismsID() -} - -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type PolicyNewParamsFilters struct { - // Usage depends on specific alert type - Actions param.Field[[]string] `json:"actions"` - // Used for configuring radar_notification - AffectedASNs param.Field[[]string] `json:"affected_asns"` - // Used for configuring incident_alert. A list of identifiers for each component to - // monitor. - AffectedComponents param.Field[[]string] `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations param.Field[[]string] `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode param.Field[[]string] `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue param.Field[[]PolicyNewParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled param.Field[[]string] `json:"enabled"` - // Used for configuring pages_event_alert - Environment param.Field[[]string] `json:"environment"` - // Used for configuring pages_event_alert - Event param.Field[[]string] `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource param.Field[[]string] `json:"event_source"` - // Usage depends on specific alert type - EventType param.Field[[]string] `json:"event_type"` - // Usage depends on specific alert type - GroupBy param.Field[[]string] `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID param.Field[[]string] `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact param.Field[[]PolicyNewParamsFiltersIncidentImpact] `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID param.Field[[]string] `json:"input_id"` - // Used for configuring billing_usage_alert - Limit param.Field[[]string] `json:"limit"` - // Used for configuring logo_match_alert - LogoTag param.Field[[]string] `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth param.Field[[]string] `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus param.Field[[]string] `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID param.Field[[]string] `json:"pool_id"` - // Used for configuring billing_usage_alert - Product param.Field[[]string] `json:"product"` - // Used for configuring pages_event_alert - ProjectID param.Field[[]string] `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol param.Field[[]string] `json:"protocol"` - // Usage depends on specific alert type - QueryTag param.Field[[]string] `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors param.Field[[]string] `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services param.Field[[]string] `json:"services"` - // Usage depends on specific alert type - Slo param.Field[[]string] `json:"slo"` - // Used for configuring health_check_status_notification - Status param.Field[[]string] `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname param.Field[[]string] `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP param.Field[[]string] `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName param.Field[[]string] `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions param.Field[[]PolicyNewParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID param.Field[[]string] `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName param.Field[[]string] `json:"tunnel_name"` - // Usage depends on specific alert type - Where param.Field[[]string] `json:"where"` - // Usage depends on specific alert type - Zones param.Field[[]string] `json:"zones"` -} - -func (r PolicyNewParamsFilters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PolicyNewParamsFiltersAlertTriggerPreferencesValue string - -const ( - PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0 PolicyNewParamsFiltersAlertTriggerPreferencesValue = "99.0" - PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0 PolicyNewParamsFiltersAlertTriggerPreferencesValue = "98.0" - PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0 PolicyNewParamsFiltersAlertTriggerPreferencesValue = "97.0" -) - -func (r PolicyNewParamsFiltersAlertTriggerPreferencesValue) IsKnown() bool { - switch r { - case PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0, PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0, PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0: - return true - } - return false -} - -type PolicyNewParamsFiltersIncidentImpact string - -const ( - PolicyNewParamsFiltersIncidentImpactIncidentImpactNone PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - PolicyNewParamsFiltersIncidentImpactIncidentImpactCritical PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -func (r PolicyNewParamsFiltersIncidentImpact) IsKnown() bool { - switch r { - case PolicyNewParamsFiltersIncidentImpactIncidentImpactNone, PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor, PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor, PolicyNewParamsFiltersIncidentImpactIncidentImpactCritical: - return true - } - return false -} - -type PolicyNewParamsFiltersTrafficExclusion string - -const ( - PolicyNewParamsFiltersTrafficExclusionSecurityEvents PolicyNewParamsFiltersTrafficExclusion = "security_events" -) - -func (r PolicyNewParamsFiltersTrafficExclusion) IsKnown() bool { - switch r { - case PolicyNewParamsFiltersTrafficExclusionSecurityEvents: - return true - } - return false -} - type PolicyNewResponseEnvelope struct { - Errors []PolicyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PolicyNewResponseEnvelopeMessages `json:"messages,required"` - Result PolicyNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PolicyNewResponse `json:"result,required"` // Whether the API call was successful Success PolicyNewResponseEnvelopeSuccess `json:"success,required"` JSON policyNewResponseEnvelopeJSON `json:"-"` @@ -812,52 +731,6 @@ func (r policyNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PolicyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// policyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PolicyNewResponseEnvelopeErrors] -type policyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PolicyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// policyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PolicyNewResponseEnvelopeMessages] -type policyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PolicyNewResponseEnvelopeSuccess bool @@ -887,10 +760,10 @@ type PolicyUpdateParams struct { // Optional filters that allow you to be alerted only on a subset of events for // that alert type based on some criteria. This is only available for select alert // types. See alert type documentation for more details. - Filters param.Field[PolicyUpdateParamsFilters] `json:"filters"` + Filters param.Field[PolicyFilterParam] `json:"filters"` // List of IDs that will be used when dispatching a notification. IDs for email // type will be the email address. - Mechanisms param.Field[map[string][]PolicyUpdateParamsMechanisms] `json:"mechanisms"` + Mechanisms param.Field[MechanismParam] `json:"mechanisms"` // Name of the policy. Name param.Field[string] `json:"name"` } @@ -970,164 +843,10 @@ func (r PolicyUpdateParamsAlertType) IsKnown() bool { return false } -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type PolicyUpdateParamsFilters struct { - // Usage depends on specific alert type - Actions param.Field[[]string] `json:"actions"` - // Used for configuring radar_notification - AffectedASNs param.Field[[]string] `json:"affected_asns"` - // Used for configuring incident_alert. A list of identifiers for each component to - // monitor. - AffectedComponents param.Field[[]string] `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations param.Field[[]string] `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode param.Field[[]string] `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue param.Field[[]PolicyUpdateParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled param.Field[[]string] `json:"enabled"` - // Used for configuring pages_event_alert - Environment param.Field[[]string] `json:"environment"` - // Used for configuring pages_event_alert - Event param.Field[[]string] `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource param.Field[[]string] `json:"event_source"` - // Usage depends on specific alert type - EventType param.Field[[]string] `json:"event_type"` - // Usage depends on specific alert type - GroupBy param.Field[[]string] `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID param.Field[[]string] `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact param.Field[[]PolicyUpdateParamsFiltersIncidentImpact] `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID param.Field[[]string] `json:"input_id"` - // Used for configuring billing_usage_alert - Limit param.Field[[]string] `json:"limit"` - // Used for configuring logo_match_alert - LogoTag param.Field[[]string] `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth param.Field[[]string] `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus param.Field[[]string] `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID param.Field[[]string] `json:"pool_id"` - // Used for configuring billing_usage_alert - Product param.Field[[]string] `json:"product"` - // Used for configuring pages_event_alert - ProjectID param.Field[[]string] `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol param.Field[[]string] `json:"protocol"` - // Usage depends on specific alert type - QueryTag param.Field[[]string] `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors param.Field[[]string] `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services param.Field[[]string] `json:"services"` - // Usage depends on specific alert type - Slo param.Field[[]string] `json:"slo"` - // Used for configuring health_check_status_notification - Status param.Field[[]string] `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname param.Field[[]string] `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP param.Field[[]string] `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName param.Field[[]string] `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions param.Field[[]PolicyUpdateParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID param.Field[[]string] `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName param.Field[[]string] `json:"tunnel_name"` - // Usage depends on specific alert type - Where param.Field[[]string] `json:"where"` - // Usage depends on specific alert type - Zones param.Field[[]string] `json:"zones"` -} - -func (r PolicyUpdateParamsFilters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PolicyUpdateParamsFiltersAlertTriggerPreferencesValue string - -const ( - PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0 PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "99.0" - PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0 PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "98.0" - PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0 PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "97.0" -) - -func (r PolicyUpdateParamsFiltersAlertTriggerPreferencesValue) IsKnown() bool { - switch r { - case PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0, PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0, PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0: - return true - } - return false -} - -type PolicyUpdateParamsFiltersIncidentImpact string - -const ( - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactCritical PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -func (r PolicyUpdateParamsFiltersIncidentImpact) IsKnown() bool { - switch r { - case PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone, PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor, PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor, PolicyUpdateParamsFiltersIncidentImpactIncidentImpactCritical: - return true - } - return false -} - -type PolicyUpdateParamsFiltersTrafficExclusion string - -const ( - PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents PolicyUpdateParamsFiltersTrafficExclusion = "security_events" -) - -func (r PolicyUpdateParamsFiltersTrafficExclusion) IsKnown() bool { - switch r { - case PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents: - return true - } - return false -} - -type PolicyUpdateParamsMechanisms struct { - // UUID - ID param.Field[PolicyUpdateParamsMechanismsID] `json:"id"` -} - -func (r PolicyUpdateParamsMechanisms) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// UUID -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type PolicyUpdateParamsMechanismsID interface { - ImplementsAlertingPolicyUpdateParamsMechanismsID() -} - type PolicyUpdateResponseEnvelope struct { - Errors []PolicyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []PolicyUpdateResponseEnvelopeMessages `json:"messages,required"` - Result PolicyUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PolicyUpdateResponse `json:"result,required"` // Whether the API call was successful Success PolicyUpdateResponseEnvelopeSuccess `json:"success,required"` JSON policyUpdateResponseEnvelopeJSON `json:"-"` @@ -1152,52 +871,6 @@ func (r policyUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PolicyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// policyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PolicyUpdateResponseEnvelopeErrors] -type policyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PolicyUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// policyUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PolicyUpdateResponseEnvelopeMessages] -type policyUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PolicyUpdateResponseEnvelopeSuccess bool @@ -1224,9 +897,9 @@ type PolicyDeleteParams struct { } type PolicyDeleteResponseEnvelope struct { - Errors []PolicyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PolicyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PolicyDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PolicyDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success PolicyDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo PolicyDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -1253,52 +926,6 @@ func (r policyDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PolicyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// policyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PolicyDeleteResponseEnvelopeErrors] -type policyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PolicyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// policyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PolicyDeleteResponseEnvelopeMessages] -type policyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PolicyDeleteResponseEnvelopeSuccess bool @@ -1351,9 +978,9 @@ type PolicyGetParams struct { } type PolicyGetResponseEnvelope struct { - Errors []PolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result AlertingPolicies `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Policy `json:"result,required"` // Whether the API call was successful Success PolicyGetResponseEnvelopeSuccess `json:"success,required"` JSON policyGetResponseEnvelopeJSON `json:"-"` @@ -1378,52 +1005,6 @@ func (r policyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// policyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PolicyGetResponseEnvelopeErrors] -type policyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON policyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// policyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PolicyGetResponseEnvelopeMessages] -type policyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r policyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PolicyGetResponseEnvelopeSuccess bool diff --git a/alerting/policy_test.go b/alerting/policy_test.go index b7592719b20..e42ad6ac6a8 100644 --- a/alerting/policy_test.go +++ b/alerting/policy_test.go @@ -33,27 +33,27 @@ func TestPolicyNewWithOptionalParams(t *testing.T) { AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AlertType: cloudflare.F(alerting.PolicyNewParamsAlertTypeUniversalSSLEventType), Enabled: cloudflare.F(true), - Mechanisms: cloudflare.F(map[string][]alerting.PolicyNewParamsMechanisms{ - "email": {{ - ID: cloudflare.F[alerting.PolicyNewParamsMechanismsID](shared.UnionString("test@example.com")), + Mechanisms: cloudflare.F(alerting.MechanismParam{ + "email": []alerting.MechanismParam{{ + ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("test@example.com")), }}, - "pagerduty": {{ - ID: cloudflare.F[alerting.PolicyNewParamsMechanismsID](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), + "pagerduty": []alerting.MechanismParam{{ + ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), }}, - "webhooks": {{ - ID: cloudflare.F[alerting.PolicyNewParamsMechanismsID](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), + "webhooks": []alerting.MechanismParam{{ + ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), }}, }), Name: cloudflare.F("SSL Notification Event Policy"), Description: cloudflare.F("Something describing the policy."), - Filters: cloudflare.F(alerting.PolicyNewParamsFilters{ + Filters: cloudflare.F(alerting.PolicyFilterParam{ Actions: cloudflare.F([]string{"string", "string", "string"}), AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), AirportCode: cloudflare.F([]string{"string", "string", "string"}), AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferencesValue: cloudflare.F([]alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue{alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0, alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0, alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0}), + AlertTriggerPreferencesValue: cloudflare.F([]alerting.PolicyFilterAlertTriggerPreferencesValue{alerting.PolicyFilterAlertTriggerPreferencesValue99_0, alerting.PolicyFilterAlertTriggerPreferencesValue98_0, alerting.PolicyFilterAlertTriggerPreferencesValue97_0}), Enabled: cloudflare.F([]string{"string", "string", "string"}), Environment: cloudflare.F([]string{"string", "string", "string"}), Event: cloudflare.F([]string{"string", "string", "string"}), @@ -61,7 +61,7 @@ func TestPolicyNewWithOptionalParams(t *testing.T) { EventType: cloudflare.F([]string{"string", "string", "string"}), GroupBy: cloudflare.F([]string{"string", "string", "string"}), HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), - IncidentImpact: cloudflare.F([]alerting.PolicyNewParamsFiltersIncidentImpact{alerting.PolicyNewParamsFiltersIncidentImpactIncidentImpactNone, alerting.PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor, alerting.PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor}), + IncidentImpact: cloudflare.F([]alerting.PolicyFilterIncidentImpact{alerting.PolicyFilterIncidentImpactIncidentImpactNone, alerting.PolicyFilterIncidentImpactIncidentImpactMinor, alerting.PolicyFilterIncidentImpactIncidentImpactMajor}), InputID: cloudflare.F([]string{"string", "string", "string"}), Limit: cloudflare.F([]string{"string", "string", "string"}), LogoTag: cloudflare.F([]string{"string", "string", "string"}), @@ -82,7 +82,7 @@ func TestPolicyNewWithOptionalParams(t *testing.T) { TargetHostname: cloudflare.F([]string{"string", "string", "string"}), TargetIP: cloudflare.F([]string{"string", "string", "string"}), TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), - TrafficExclusions: cloudflare.F([]alerting.PolicyNewParamsFiltersTrafficExclusion{alerting.PolicyNewParamsFiltersTrafficExclusionSecurityEvents}), + TrafficExclusions: cloudflare.F([]alerting.PolicyFilterTrafficExclusion{alerting.PolicyFilterTrafficExclusionSecurityEvents}), TunnelID: cloudflare.F([]string{"string", "string", "string"}), TunnelName: cloudflare.F([]string{"string", "string", "string"}), Where: cloudflare.F([]string{"string", "string", "string"}), @@ -120,14 +120,14 @@ func TestPolicyUpdateWithOptionalParams(t *testing.T) { AlertType: cloudflare.F(alerting.PolicyUpdateParamsAlertTypeUniversalSSLEventType), Description: cloudflare.F("Something describing the policy."), Enabled: cloudflare.F(true), - Filters: cloudflare.F(alerting.PolicyUpdateParamsFilters{ + Filters: cloudflare.F(alerting.PolicyFilterParam{ Actions: cloudflare.F([]string{"string", "string", "string"}), AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), AirportCode: cloudflare.F([]string{"string", "string", "string"}), AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferencesValue: cloudflare.F([]alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue{alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0, alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0, alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0}), + AlertTriggerPreferencesValue: cloudflare.F([]alerting.PolicyFilterAlertTriggerPreferencesValue{alerting.PolicyFilterAlertTriggerPreferencesValue99_0, alerting.PolicyFilterAlertTriggerPreferencesValue98_0, alerting.PolicyFilterAlertTriggerPreferencesValue97_0}), Enabled: cloudflare.F([]string{"string", "string", "string"}), Environment: cloudflare.F([]string{"string", "string", "string"}), Event: cloudflare.F([]string{"string", "string", "string"}), @@ -135,7 +135,7 @@ func TestPolicyUpdateWithOptionalParams(t *testing.T) { EventType: cloudflare.F([]string{"string", "string", "string"}), GroupBy: cloudflare.F([]string{"string", "string", "string"}), HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), - IncidentImpact: cloudflare.F([]alerting.PolicyUpdateParamsFiltersIncidentImpact{alerting.PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone, alerting.PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor, alerting.PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor}), + IncidentImpact: cloudflare.F([]alerting.PolicyFilterIncidentImpact{alerting.PolicyFilterIncidentImpactIncidentImpactNone, alerting.PolicyFilterIncidentImpactIncidentImpactMinor, alerting.PolicyFilterIncidentImpactIncidentImpactMajor}), InputID: cloudflare.F([]string{"string", "string", "string"}), Limit: cloudflare.F([]string{"string", "string", "string"}), LogoTag: cloudflare.F([]string{"string", "string", "string"}), @@ -156,21 +156,21 @@ func TestPolicyUpdateWithOptionalParams(t *testing.T) { TargetHostname: cloudflare.F([]string{"string", "string", "string"}), TargetIP: cloudflare.F([]string{"string", "string", "string"}), TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), - TrafficExclusions: cloudflare.F([]alerting.PolicyUpdateParamsFiltersTrafficExclusion{alerting.PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents}), + TrafficExclusions: cloudflare.F([]alerting.PolicyFilterTrafficExclusion{alerting.PolicyFilterTrafficExclusionSecurityEvents}), TunnelID: cloudflare.F([]string{"string", "string", "string"}), TunnelName: cloudflare.F([]string{"string", "string", "string"}), Where: cloudflare.F([]string{"string", "string", "string"}), Zones: cloudflare.F([]string{"string", "string", "string"}), }), - Mechanisms: cloudflare.F(map[string][]alerting.PolicyUpdateParamsMechanisms{ - "email": {{ - ID: cloudflare.F[alerting.PolicyUpdateParamsMechanismsID](shared.UnionString("test@example.com")), + Mechanisms: cloudflare.F(alerting.MechanismParam{ + "email": []alerting.MechanismParam{{ + ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("test@example.com")), }}, - "pagerduty": {{ - ID: cloudflare.F[alerting.PolicyUpdateParamsMechanismsID](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), + "pagerduty": []alerting.MechanismParam{{ + ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), }}, - "webhooks": {{ - ID: cloudflare.F[alerting.PolicyUpdateParamsMechanismsID](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), + "webhooks": []alerting.MechanismParam{{ + ID: cloudflare.F[alerting.MechanismIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), }}, }), Name: cloudflare.F("SSL Notification Event Policy"), diff --git a/aliases.go b/aliases.go index bbed8abe326..36677d72a7a 100644 --- a/aliases.go +++ b/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/api.md b/api.md index b665fa12d4b..36ffe60e7ea 100644 --- a/api.md +++ b/api.md @@ -1,66 +1,80 @@ +# Shared Params Types + +- shared.PermissionGrantParam +- shared.UserParam + # Shared Response Types +- shared.AuditLog +- shared.CloudflareTunnel - shared.ErrorData +- shared.Permission +- shared.PermissionGrant +- shared.ResponseInfo +- shared.Role +- shared.User # Accounts +Params Types: + +- accounts.AccountParam + Response Types: - accounts.Account -- accounts.AccountUpdateResponse +- accounts.AccountUpdateResponseUnion - accounts.AccountListResponse -- accounts.AccountGetResponse +- accounts.AccountGetResponseUnion Methods: -- client.Accounts.Update(ctx context.Context, params accounts.AccountUpdateParams) (accounts.AccountUpdateResponse, error) +- client.Accounts.Update(ctx context.Context, params accounts.AccountUpdateParams) (accounts.AccountUpdateResponseUnion, error) - client.Accounts.List(ctx context.Context, query accounts.AccountListParams) (pagination.V4PagePaginationArray[accounts.AccountListResponse], error) -- client.Accounts.Get(ctx context.Context, query accounts.AccountGetParams) (accounts.AccountGetResponse, error) +- client.Accounts.Get(ctx context.Context, query accounts.AccountGetParams) (accounts.AccountGetResponseUnion, error) ## Members Response Types: -- accounts.AccountMember -- accounts.AccountMemberWithID +- accounts.UserWithInviteCode - accounts.MemberListResponse - accounts.MemberDeleteResponse Methods: -- client.Accounts.Members.New(ctx context.Context, params accounts.MemberNewParams) (accounts.AccountMemberWithID, error) -- client.Accounts.Members.Update(ctx context.Context, memberID string, params accounts.MemberUpdateParams) (accounts.AccountMember, error) +- client.Accounts.Members.New(ctx context.Context, params accounts.MemberNewParams) (accounts.UserWithInviteCode, error) +- client.Accounts.Members.Update(ctx context.Context, memberID string, params accounts.MemberUpdateParams) (shared.User, error) - client.Accounts.Members.List(ctx context.Context, params accounts.MemberListParams) (pagination.V4PagePaginationArray[accounts.MemberListResponse], error) -- client.Accounts.Members.Delete(ctx context.Context, memberID string, body accounts.MemberDeleteParams) (accounts.MemberDeleteResponse, error) -- client.Accounts.Members.Get(ctx context.Context, memberID string, query accounts.MemberGetParams) (accounts.AccountMember, error) +- client.Accounts.Members.Delete(ctx context.Context, memberID string, params accounts.MemberDeleteParams) (accounts.MemberDeleteResponse, error) +- client.Accounts.Members.Get(ctx context.Context, memberID string, query accounts.MemberGetParams) (shared.User, error) ## Roles Response Types: -- accounts.Role -- accounts.RoleGetResponse +- accounts.RoleGetResponseUnion Methods: -- client.Accounts.Roles.List(ctx context.Context, query accounts.RoleListParams) (pagination.SinglePage[accounts.Role], error) -- client.Accounts.Roles.Get(ctx context.Context, roleID interface{}, query accounts.RoleGetParams) (accounts.RoleGetResponse, error) +- client.Accounts.Roles.List(ctx context.Context, query accounts.RoleListParams) (pagination.SinglePage[shared.Role], error) +- client.Accounts.Roles.Get(ctx context.Context, roleID interface{}, query accounts.RoleGetParams) (accounts.RoleGetResponseUnion, error) # OriginCACertificates Response Types: - origin_ca_certificates.OriginCACertificate -- origin_ca_certificates.OriginCACertificateNewResponse +- origin_ca_certificates.OriginCACertificateNewResponseUnion - origin_ca_certificates.OriginCACertificateDeleteResponse -- origin_ca_certificates.OriginCACertificateGetResponse +- origin_ca_certificates.OriginCACertificateGetResponseUnion Methods: -- client.OriginCACertificates.New(ctx context.Context, body origin_ca_certificates.OriginCACertificateNewParams) (origin_ca_certificates.OriginCACertificateNewResponse, error) +- client.OriginCACertificates.New(ctx context.Context, body origin_ca_certificates.OriginCACertificateNewParams) (origin_ca_certificates.OriginCACertificateNewResponseUnion, error) - client.OriginCACertificates.List(ctx context.Context, query origin_ca_certificates.OriginCACertificateListParams) (pagination.SinglePage[origin_ca_certificates.OriginCACertificate], error) -- client.OriginCACertificates.Delete(ctx context.Context, certificateID string) (origin_ca_certificates.OriginCACertificateDeleteResponse, error) -- client.OriginCACertificates.Get(ctx context.Context, certificateID string) (origin_ca_certificates.OriginCACertificateGetResponse, error) +- client.OriginCACertificates.Delete(ctx context.Context, certificateID string, body origin_ca_certificates.OriginCACertificateDeleteParams) (origin_ca_certificates.OriginCACertificateDeleteResponse, error) +- client.OriginCACertificates.Get(ctx context.Context, certificateID string) (origin_ca_certificates.OriginCACertificateGetResponseUnion, error) # IPs @@ -79,38 +93,34 @@ Methods: Response Types: - memberships.Membership -- memberships.MembershipUpdateResponse +- memberships.MembershipUpdateResponseUnion - memberships.MembershipDeleteResponse -- memberships.MembershipGetResponse +- memberships.MembershipGetResponseUnion Methods: -- client.Memberships.Update(ctx context.Context, membershipID string, body memberships.MembershipUpdateParams) (memberships.MembershipUpdateResponse, error) +- client.Memberships.Update(ctx context.Context, membershipID string, body memberships.MembershipUpdateParams) (memberships.MembershipUpdateResponseUnion, error) - client.Memberships.List(ctx context.Context, query memberships.MembershipListParams) (pagination.V4PagePaginationArray[memberships.Membership], error) -- client.Memberships.Delete(ctx context.Context, membershipID string) (memberships.MembershipDeleteResponse, error) -- client.Memberships.Get(ctx context.Context, membershipID string) (memberships.MembershipGetResponse, error) +- client.Memberships.Delete(ctx context.Context, membershipID string, body memberships.MembershipDeleteParams) (memberships.MembershipDeleteResponse, error) +- client.Memberships.Get(ctx context.Context, membershipID string) (memberships.MembershipGetResponseUnion, error) # User Response Types: -- user.UserEditResponse -- user.UserGetResponse +- user.UserEditResponseUnion +- user.UserGetResponseUnion Methods: -- client.User.Edit(ctx context.Context, body user.UserEditParams) (user.UserEditResponse, error) -- client.User.Get(ctx context.Context) (user.UserGetResponse, error) +- client.User.Edit(ctx context.Context, body user.UserEditParams) (user.UserEditResponseUnion, error) +- client.User.Get(ctx context.Context) (user.UserGetResponseUnion, error) ## AuditLogs -Response Types: - -- user.AuditLogListResponse - Methods: -- client.User.AuditLogs.List(ctx context.Context, query user.AuditLogListParams) (pagination.V4PagePaginationArray[user.AuditLogListResponse], error) +- client.User.AuditLogs.List(ctx context.Context, query user.AuditLogListParams) (pagination.V4PagePaginationArray[shared.AuditLog], error) ## Billing @@ -122,113 +132,31 @@ Response Types: Methods: -- client.User.Billing.History.Get(ctx context.Context, query user.BillingHistoryGetParams) ([]user.BillingHistory, error) +- client.User.Billing.History.List(ctx context.Context, query user.BillingHistoryListParams) (pagination.V4PagePaginationArray[user.BillingHistory], error) ### Profile Response Types: -- user.BillingProfileGetResponse - -Methods: - -- client.User.Billing.Profile.Get(ctx context.Context) (user.BillingProfileGetResponse, error) - -## Firewall - -### AccessRules - -Response Types: - -- user.FirewallRule -- user.FirewallAccessRuleDeleteResponse +- user.BillingProfileGetResponseUnion 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) (user.FirewallAccessRuleDeleteResponse, error) -- client.User.Firewall.AccessRules.Edit(ctx context.Context, identifier string, body user.FirewallAccessRuleEditParams) (user.FirewallRule, error) +- client.User.Billing.Profile.Get(ctx context.Context) (user.BillingProfileGetResponseUnion, error) ## Invites Response Types: -- user.InviteListResponse -- user.InviteEditResponse -- user.InviteGetResponse - -Methods: - -- client.User.Invites.List(ctx context.Context) (pagination.SinglePage[user.InviteListResponse], error) -- client.User.Invites.Edit(ctx context.Context, inviteID string, body user.InviteEditParams) (user.InviteEditResponse, error) -- client.User.Invites.Get(ctx context.Context, inviteID string) (user.InviteGetResponse, error) - -## LoadBalancers - -### Monitors - -Response Types: - -- user.LoadBalancingMonitor -- user.LoadBalancerMonitorDeleteResponse -- user.LoadBalancerMonitorPreviewResponse -- user.LoadBalancerMonitorReferencesResponse - -Methods: - -- client.User.LoadBalancers.Monitors.New(ctx context.Context, body user.LoadBalancerMonitorNewParams) (user.LoadBalancingMonitor, error) -- client.User.LoadBalancers.Monitors.Update(ctx context.Context, monitorID string, body user.LoadBalancerMonitorUpdateParams) (user.LoadBalancingMonitor, error) -- client.User.LoadBalancers.Monitors.List(ctx context.Context) (pagination.SinglePage[user.LoadBalancingMonitor], error) -- client.User.LoadBalancers.Monitors.Delete(ctx context.Context, monitorID string) (user.LoadBalancerMonitorDeleteResponse, error) -- client.User.LoadBalancers.Monitors.Edit(ctx context.Context, monitorID string, body user.LoadBalancerMonitorEditParams) (user.LoadBalancingMonitor, error) -- client.User.LoadBalancers.Monitors.Get(ctx context.Context, monitorID string) (user.LoadBalancingMonitor, error) -- client.User.LoadBalancers.Monitors.Preview(ctx context.Context, monitorID string, body user.LoadBalancerMonitorPreviewParams) (user.LoadBalancerMonitorPreviewResponse, error) -- client.User.LoadBalancers.Monitors.References(ctx context.Context, monitorID string) ([]user.LoadBalancerMonitorReferencesResponse, error) - -### Pools - -Response Types: - -- user.LoadBalancingPool -- user.LoadBalancerPoolDeleteResponse -- user.LoadBalancerPoolHealthResponse -- user.LoadBalancerPoolPreviewResponse -- user.LoadBalancerPoolReferencesResponse - -Methods: - -- client.User.LoadBalancers.Pools.New(ctx context.Context, body user.LoadBalancerPoolNewParams) (user.LoadBalancingPool, error) -- client.User.LoadBalancers.Pools.Update(ctx context.Context, poolID string, body user.LoadBalancerPoolUpdateParams) (user.LoadBalancingPool, error) -- client.User.LoadBalancers.Pools.List(ctx context.Context, query user.LoadBalancerPoolListParams) (pagination.SinglePage[user.LoadBalancingPool], error) -- client.User.LoadBalancers.Pools.Delete(ctx context.Context, poolID string) (user.LoadBalancerPoolDeleteResponse, error) -- client.User.LoadBalancers.Pools.Edit(ctx context.Context, poolID string, body user.LoadBalancerPoolEditParams) (user.LoadBalancingPool, error) -- client.User.LoadBalancers.Pools.Get(ctx context.Context, poolID string) (user.LoadBalancingPool, error) -- client.User.LoadBalancers.Pools.Health(ctx context.Context, poolID string) (user.LoadBalancerPoolHealthResponse, error) -- client.User.LoadBalancers.Pools.Preview(ctx context.Context, poolID string, body user.LoadBalancerPoolPreviewParams) (user.LoadBalancerPoolPreviewResponse, error) -- client.User.LoadBalancers.Pools.References(ctx context.Context, poolID string) ([]user.LoadBalancerPoolReferencesResponse, error) - -### Preview - -Response Types: - -- user.LoadBalancingPreview +- user.Invite +- user.InviteEditResponseUnion +- user.InviteGetResponseUnion Methods: -- client.User.LoadBalancers.Preview.Get(ctx context.Context, previewID string) (user.LoadBalancingPreview, error) - -### Analytics - -#### Events - -Response Types: - -- user.LoadBalancingAnalytics - -Methods: - -- client.User.LoadBalancers.Analytics.Events.List(ctx context.Context, query user.LoadBalancerAnalyticsEventListParams) (pagination.SinglePage[user.LoadBalancingAnalytics], error) +- client.User.Invites.List(ctx context.Context) (pagination.SinglePage[user.Invite], error) +- client.User.Invites.Edit(ctx context.Context, inviteID string, body user.InviteEditParams) (user.InviteEditResponseUnion, error) +- client.User.Invites.Get(ctx context.Context, inviteID string) (user.InviteGetResponseUnion, error) ## Organizations @@ -236,48 +164,65 @@ Response Types: - user.Organization - user.OrganizationDeleteResponse -- user.OrganizationGetResponse +- user.OrganizationGetResponseUnion Methods: - client.User.Organizations.List(ctx context.Context, query user.OrganizationListParams) (pagination.V4PagePaginationArray[user.Organization], error) -- client.User.Organizations.Delete(ctx context.Context, organizationID string) (user.OrganizationDeleteResponse, error) -- client.User.Organizations.Get(ctx context.Context, organizationID string) (user.OrganizationGetResponse, error) +- client.User.Organizations.Delete(ctx context.Context, organizationID string, body user.OrganizationDeleteParams) (user.OrganizationDeleteResponse, error) +- client.User.Organizations.Get(ctx context.Context, organizationID string) (user.OrganizationGetResponseUnion, error) ## Subscriptions +Params Types: + +- user.RatePlanParam +- user.SubscriptionParam +- user.SubscriptionComponentParam +- user.SubscriptionZoneParam + Response Types: -- user.SubscriptionUpdateResponse +- user.RatePlan +- user.Subscription +- user.SubscriptionComponent +- user.SubscriptionZone +- user.SubscriptionUpdateResponseUnion - user.SubscriptionDeleteResponse -- user.SubscriptionEditResponse -- user.SubscriptionGetResponse +- user.SubscriptionEditResponseUnion Methods: -- client.User.Subscriptions.Update(ctx context.Context, identifier string, body user.SubscriptionUpdateParams) (user.SubscriptionUpdateResponse, error) -- client.User.Subscriptions.Delete(ctx context.Context, identifier string) (user.SubscriptionDeleteResponse, error) -- client.User.Subscriptions.Edit(ctx context.Context, identifier string, body user.SubscriptionEditParams) (user.SubscriptionEditResponse, error) -- client.User.Subscriptions.Get(ctx context.Context) ([]user.SubscriptionGetResponse, error) +- client.User.Subscriptions.Update(ctx context.Context, identifier string, body user.SubscriptionUpdateParams) (user.SubscriptionUpdateResponseUnion, error) +- client.User.Subscriptions.Delete(ctx context.Context, identifier string, body user.SubscriptionDeleteParams) (user.SubscriptionDeleteResponse, error) +- client.User.Subscriptions.Edit(ctx context.Context, identifier string, body user.SubscriptionEditParams) (user.SubscriptionEditResponseUnion, error) +- client.User.Subscriptions.Get(ctx context.Context) ([]user.Subscription, error) ## Tokens +Params Types: + +- user.CIDRListParam +- user.PolicyParam +- user.TokenParam + Response Types: +- user.Policy - user.TokenNewResponse -- user.TokenUpdateResponse +- user.TokenUpdateResponseUnion - user.TokenListResponse - user.TokenDeleteResponse -- user.TokenGetResponse +- user.TokenGetResponseUnion - user.TokenVerifyResponse Methods: - client.User.Tokens.New(ctx context.Context, body user.TokenNewParams) (user.TokenNewResponse, error) -- client.User.Tokens.Update(ctx context.Context, tokenID interface{}, body user.TokenUpdateParams) (user.TokenUpdateResponse, error) +- client.User.Tokens.Update(ctx context.Context, tokenID interface{}, body user.TokenUpdateParams) (user.TokenUpdateResponseUnion, error) - client.User.Tokens.List(ctx context.Context, query user.TokenListParams) (pagination.V4PagePaginationArray[user.TokenListResponse], error) -- client.User.Tokens.Delete(ctx context.Context, tokenID interface{}) (user.TokenDeleteResponse, error) -- client.User.Tokens.Get(ctx context.Context, tokenID interface{}) (user.TokenGetResponse, error) +- client.User.Tokens.Delete(ctx context.Context, tokenID interface{}, body user.TokenDeleteParams) (user.TokenDeleteResponse, error) +- client.User.Tokens.Get(ctx context.Context, tokenID interface{}) (user.TokenGetResponseUnion, error) - client.User.Tokens.Verify(ctx context.Context) (user.TokenVerifyResponse, error) ### PermissionGroups @@ -294,11 +239,11 @@ Methods: Response Types: -- user.TokenValue +- user.Value Methods: -- client.User.Tokens.Value.Update(ctx context.Context, tokenID interface{}, body user.TokenValueUpdateParams) (user.TokenValue, error) +- client.User.Tokens.Value.Update(ctx context.Context, tokenID interface{}, body user.TokenValueUpdateParams) (user.Value, error) # Zones @@ -327,496 +272,388 @@ Methods: ## DNSSettings -Response Types: - -- zones.DNSSettingEditResponse -- zones.DNSSettingGetResponse - -Methods: - -- client.Zones.DNSSettings.Edit(ctx context.Context, params zones.DNSSettingEditParams) (zones.DNSSettingEditResponse, error) -- client.Zones.DNSSettings.Get(ctx context.Context, query zones.DNSSettingGetParams) (zones.DNSSettingGetResponse, error) +Params Types: -## Settings +- zones.DNSSettingParam +- zones.NameserverParam Response Types: -- zones.SettingEditResponse -- zones.SettingGetResponse +- zones.DNSSetting +- zones.Nameserver Methods: -- client.Zones.Settings.Edit(ctx context.Context, params zones.SettingEditParams) ([]zones.SettingEditResponse, error) -- client.Zones.Settings.Get(ctx context.Context, query zones.SettingGetParams) ([]zones.SettingGetResponse, error) - -### ZeroRTT +- client.Zones.DNSSettings.Edit(ctx context.Context, params zones.DNSSettingEditParams) (zones.DNSSetting, error) +- client.Zones.DNSSettings.Get(ctx context.Context, query zones.DNSSettingGetParams) (zones.DNSSetting, error) -Params Types: +## Settings -- zones.ZoneSetting0rttParam +### ZeroRTT Response Types: -- zones.ZoneSetting0rtt +- zones.ZeroRTT Methods: -- client.Zones.Settings.ZeroRTT.Edit(ctx context.Context, params zones.SettingZeroRTTEditParams) (zones.ZoneSetting0rtt, error) -- client.Zones.Settings.ZeroRTT.Get(ctx context.Context, query zones.SettingZeroRTTGetParams) (zones.ZoneSetting0rtt, error) +- client.Zones.Settings.ZeroRTT.Edit(ctx context.Context, params zones.SettingZeroRTTEditParams) (zones.ZeroRTT, error) +- client.Zones.Settings.ZeroRTT.Get(ctx context.Context, query zones.SettingZeroRTTGetParams) (zones.ZeroRTT, error) ### AdvancedDDoS -Params Types: - -- zones.ZoneSettingAdvancedDDoSParam - Response Types: -- zones.ZoneSettingAdvancedDDoS +- zones.AdvancedDDoS Methods: -- client.Zones.Settings.AdvancedDDoS.Get(ctx context.Context, query zones.SettingAdvancedDDoSGetParams) (zones.ZoneSettingAdvancedDDoS, error) +- client.Zones.Settings.AdvancedDDoS.Get(ctx context.Context, query zones.SettingAdvancedDDoSGetParams) (zones.AdvancedDDoS, error) ### AlwaysOnline -Params Types: - -- zones.ZoneSettingAlwaysOnlineParam - Response Types: -- zones.ZoneSettingAlwaysOnline +- zones.AlwaysOnline Methods: -- client.Zones.Settings.AlwaysOnline.Edit(ctx context.Context, params zones.SettingAlwaysOnlineEditParams) (zones.ZoneSettingAlwaysOnline, error) -- client.Zones.Settings.AlwaysOnline.Get(ctx context.Context, query zones.SettingAlwaysOnlineGetParams) (zones.ZoneSettingAlwaysOnline, error) +- client.Zones.Settings.AlwaysOnline.Edit(ctx context.Context, params zones.SettingAlwaysOnlineEditParams) (zones.AlwaysOnline, error) +- client.Zones.Settings.AlwaysOnline.Get(ctx context.Context, query zones.SettingAlwaysOnlineGetParams) (zones.AlwaysOnline, error) ### AlwaysUseHTTPS -Params Types: - -- zones.ZoneSettingAlwaysUseHTTPSParam - Response Types: -- zones.ZoneSettingAlwaysUseHTTPS +- zones.AlwaysUseHTTPS Methods: -- client.Zones.Settings.AlwaysUseHTTPS.Edit(ctx context.Context, params zones.SettingAlwaysUseHTTPSEditParams) (zones.ZoneSettingAlwaysUseHTTPS, error) -- client.Zones.Settings.AlwaysUseHTTPS.Get(ctx context.Context, query zones.SettingAlwaysUseHTTPSGetParams) (zones.ZoneSettingAlwaysUseHTTPS, error) +- client.Zones.Settings.AlwaysUseHTTPS.Edit(ctx context.Context, params zones.SettingAlwaysUseHTTPSEditParams) (zones.AlwaysUseHTTPS, error) +- client.Zones.Settings.AlwaysUseHTTPS.Get(ctx context.Context, query zones.SettingAlwaysUseHTTPSGetParams) (zones.AlwaysUseHTTPS, error) ### AutomaticHTTPSRewrites -Params Types: - -- zones.ZoneSettingAutomaticHTTPSRewritesParam - Response Types: -- zones.ZoneSettingAutomaticHTTPSRewrites +- zones.AutomaticHTTPSRewrites Methods: -- client.Zones.Settings.AutomaticHTTPSRewrites.Edit(ctx context.Context, params zones.SettingAutomaticHTTPSRewriteEditParams) (zones.ZoneSettingAutomaticHTTPSRewrites, error) -- client.Zones.Settings.AutomaticHTTPSRewrites.Get(ctx context.Context, query zones.SettingAutomaticHTTPSRewriteGetParams) (zones.ZoneSettingAutomaticHTTPSRewrites, error) +- client.Zones.Settings.AutomaticHTTPSRewrites.Edit(ctx context.Context, params zones.SettingAutomaticHTTPSRewriteEditParams) (zones.AutomaticHTTPSRewrites, error) +- client.Zones.Settings.AutomaticHTTPSRewrites.Get(ctx context.Context, query zones.SettingAutomaticHTTPSRewriteGetParams) (zones.AutomaticHTTPSRewrites, error) ### AutomaticPlatformOptimization Params Types: -- zones.ZoneSettingAutomaticPlatformOptimizationParam +- zones.AutomaticPlatformOptimizationParam Response Types: -- zones.ZoneSettingAutomaticPlatformOptimization +- zones.AutomaticPlatformOptimization Methods: -- client.Zones.Settings.AutomaticPlatformOptimization.Edit(ctx context.Context, params zones.SettingAutomaticPlatformOptimizationEditParams) (zones.ZoneSettingAutomaticPlatformOptimization, error) -- client.Zones.Settings.AutomaticPlatformOptimization.Get(ctx context.Context, query zones.SettingAutomaticPlatformOptimizationGetParams) (zones.ZoneSettingAutomaticPlatformOptimization, error) +- client.Zones.Settings.AutomaticPlatformOptimization.Edit(ctx context.Context, params zones.SettingAutomaticPlatformOptimizationEditParams) (zones.AutomaticPlatformOptimization, error) +- client.Zones.Settings.AutomaticPlatformOptimization.Get(ctx context.Context, query zones.SettingAutomaticPlatformOptimizationGetParams) (zones.AutomaticPlatformOptimization, error) ### Brotli -Params Types: - -- zones.ZoneSettingBrotliParam - Response Types: -- zones.ZoneSettingBrotli +- zones.Brotli Methods: -- client.Zones.Settings.Brotli.Edit(ctx context.Context, params zones.SettingBrotliEditParams) (zones.ZoneSettingBrotli, error) -- client.Zones.Settings.Brotli.Get(ctx context.Context, query zones.SettingBrotliGetParams) (zones.ZoneSettingBrotli, error) +- client.Zones.Settings.Brotli.Edit(ctx context.Context, params zones.SettingBrotliEditParams) (zones.Brotli, error) +- client.Zones.Settings.Brotli.Get(ctx context.Context, query zones.SettingBrotliGetParams) (zones.Brotli, error) ### BrowserCacheTTL -Params Types: - -- zones.ZoneSettingBrowserCacheTTLParam - Response Types: -- zones.ZoneSettingBrowserCacheTTL +- zones.BrowserCacheTTL Methods: -- client.Zones.Settings.BrowserCacheTTL.Edit(ctx context.Context, params zones.SettingBrowserCacheTTLEditParams) (zones.ZoneSettingBrowserCacheTTL, error) -- client.Zones.Settings.BrowserCacheTTL.Get(ctx context.Context, query zones.SettingBrowserCacheTTLGetParams) (zones.ZoneSettingBrowserCacheTTL, error) +- client.Zones.Settings.BrowserCacheTTL.Edit(ctx context.Context, params zones.SettingBrowserCacheTTLEditParams) (zones.BrowserCacheTTL, error) +- client.Zones.Settings.BrowserCacheTTL.Get(ctx context.Context, query zones.SettingBrowserCacheTTLGetParams) (zones.BrowserCacheTTL, error) ### BrowserCheck -Params Types: - -- zones.ZoneSettingBrowserCheckParam - Response Types: -- zones.ZoneSettingBrowserCheck +- zones.BrowserCheck Methods: -- client.Zones.Settings.BrowserCheck.Edit(ctx context.Context, params zones.SettingBrowserCheckEditParams) (zones.ZoneSettingBrowserCheck, error) -- client.Zones.Settings.BrowserCheck.Get(ctx context.Context, query zones.SettingBrowserCheckGetParams) (zones.ZoneSettingBrowserCheck, error) +- client.Zones.Settings.BrowserCheck.Edit(ctx context.Context, params zones.SettingBrowserCheckEditParams) (zones.BrowserCheck, error) +- client.Zones.Settings.BrowserCheck.Get(ctx context.Context, query zones.SettingBrowserCheckGetParams) (zones.BrowserCheck, error) ### CacheLevel -Params Types: - -- zones.ZoneSettingCacheLevelParam - Response Types: -- zones.ZoneSettingCacheLevel +- zones.CacheLevel Methods: -- client.Zones.Settings.CacheLevel.Edit(ctx context.Context, params zones.SettingCacheLevelEditParams) (zones.ZoneSettingCacheLevel, error) -- client.Zones.Settings.CacheLevel.Get(ctx context.Context, query zones.SettingCacheLevelGetParams) (zones.ZoneSettingCacheLevel, error) +- client.Zones.Settings.CacheLevel.Edit(ctx context.Context, params zones.SettingCacheLevelEditParams) (zones.CacheLevel, error) +- client.Zones.Settings.CacheLevel.Get(ctx context.Context, query zones.SettingCacheLevelGetParams) (zones.CacheLevel, error) ### ChallengeTTL -Params Types: - -- zones.ZoneSettingChallengeTTLParam - Response Types: -- zones.ZoneSettingChallengeTTL +- zones.ChallengeTTL Methods: -- client.Zones.Settings.ChallengeTTL.Edit(ctx context.Context, params zones.SettingChallengeTTLEditParams) (zones.ZoneSettingChallengeTTL, error) -- client.Zones.Settings.ChallengeTTL.Get(ctx context.Context, query zones.SettingChallengeTTLGetParams) (zones.ZoneSettingChallengeTTL, error) +- client.Zones.Settings.ChallengeTTL.Edit(ctx context.Context, params zones.SettingChallengeTTLEditParams) (zones.ChallengeTTL, error) +- client.Zones.Settings.ChallengeTTL.Get(ctx context.Context, query zones.SettingChallengeTTLGetParams) (zones.ChallengeTTL, error) ### Ciphers -Params Types: - -- zones.ZoneSettingCiphersParam - Response Types: -- zones.ZoneSettingCiphers +- zones.Ciphers Methods: -- client.Zones.Settings.Ciphers.Edit(ctx context.Context, params zones.SettingCipherEditParams) (zones.ZoneSettingCiphers, error) -- client.Zones.Settings.Ciphers.Get(ctx context.Context, query zones.SettingCipherGetParams) (zones.ZoneSettingCiphers, error) +- client.Zones.Settings.Ciphers.Edit(ctx context.Context, params zones.SettingCipherEditParams) (zones.Ciphers, error) +- client.Zones.Settings.Ciphers.Get(ctx context.Context, query zones.SettingCipherGetParams) (zones.Ciphers, error) ### DevelopmentMode -Params Types: - -- zones.ZoneSettingDevelopmentModeParam - Response Types: -- zones.ZoneSettingDevelopmentMode +- zones.DevelopmentMode Methods: -- client.Zones.Settings.DevelopmentMode.Edit(ctx context.Context, params zones.SettingDevelopmentModeEditParams) (zones.ZoneSettingDevelopmentMode, error) -- client.Zones.Settings.DevelopmentMode.Get(ctx context.Context, query zones.SettingDevelopmentModeGetParams) (zones.ZoneSettingDevelopmentMode, error) +- client.Zones.Settings.DevelopmentMode.Edit(ctx context.Context, params zones.SettingDevelopmentModeEditParams) (zones.DevelopmentMode, error) +- client.Zones.Settings.DevelopmentMode.Get(ctx context.Context, query zones.SettingDevelopmentModeGetParams) (zones.DevelopmentMode, error) ### EarlyHints -Params Types: - -- zones.ZoneSettingEarlyHintsParam - Response Types: -- zones.ZoneSettingEarlyHints +- zones.EarlyHints Methods: -- client.Zones.Settings.EarlyHints.Edit(ctx context.Context, params zones.SettingEarlyHintEditParams) (zones.ZoneSettingEarlyHints, error) -- client.Zones.Settings.EarlyHints.Get(ctx context.Context, query zones.SettingEarlyHintGetParams) (zones.ZoneSettingEarlyHints, error) +- client.Zones.Settings.EarlyHints.Edit(ctx context.Context, params zones.SettingEarlyHintEditParams) (zones.EarlyHints, error) +- client.Zones.Settings.EarlyHints.Get(ctx context.Context, query zones.SettingEarlyHintGetParams) (zones.EarlyHints, error) ### EmailObfuscation -Params Types: - -- zones.ZoneSettingEmailObfuscationParam - Response Types: -- zones.ZoneSettingEmailObfuscation +- zones.EmailObfuscation Methods: -- client.Zones.Settings.EmailObfuscation.Edit(ctx context.Context, params zones.SettingEmailObfuscationEditParams) (zones.ZoneSettingEmailObfuscation, error) -- client.Zones.Settings.EmailObfuscation.Get(ctx context.Context, query zones.SettingEmailObfuscationGetParams) (zones.ZoneSettingEmailObfuscation, error) +- client.Zones.Settings.EmailObfuscation.Edit(ctx context.Context, params zones.SettingEmailObfuscationEditParams) (zones.EmailObfuscation, error) +- client.Zones.Settings.EmailObfuscation.Get(ctx context.Context, query zones.SettingEmailObfuscationGetParams) (zones.EmailObfuscation, error) ### H2Prioritization Params Types: -- zones.ZoneSettingH2PrioritizationParam +- zones.H2PrioritizationParam Response Types: -- zones.ZoneSettingH2Prioritization +- zones.H2Prioritization Methods: -- client.Zones.Settings.H2Prioritization.Edit(ctx context.Context, params zones.SettingH2PrioritizationEditParams) (zones.ZoneSettingH2Prioritization, error) -- client.Zones.Settings.H2Prioritization.Get(ctx context.Context, query zones.SettingH2PrioritizationGetParams) (zones.ZoneSettingH2Prioritization, error) +- client.Zones.Settings.H2Prioritization.Edit(ctx context.Context, params zones.SettingH2PrioritizationEditParams) (zones.H2Prioritization, error) +- client.Zones.Settings.H2Prioritization.Get(ctx context.Context, query zones.SettingH2PrioritizationGetParams) (zones.H2Prioritization, error) ### HotlinkProtection -Params Types: - -- zones.ZoneSettingHotlinkProtectionParam - Response Types: -- zones.ZoneSettingHotlinkProtection +- zones.HotlinkProtection Methods: -- client.Zones.Settings.HotlinkProtection.Edit(ctx context.Context, params zones.SettingHotlinkProtectionEditParams) (zones.ZoneSettingHotlinkProtection, error) -- client.Zones.Settings.HotlinkProtection.Get(ctx context.Context, query zones.SettingHotlinkProtectionGetParams) (zones.ZoneSettingHotlinkProtection, error) +- client.Zones.Settings.HotlinkProtection.Edit(ctx context.Context, params zones.SettingHotlinkProtectionEditParams) (zones.HotlinkProtection, error) +- client.Zones.Settings.HotlinkProtection.Get(ctx context.Context, query zones.SettingHotlinkProtectionGetParams) (zones.HotlinkProtection, error) ### HTTP2 -Params Types: - -- zones.ZoneSettingHTTP2Param - Response Types: -- zones.ZoneSettingHTTP2 +- zones.HTTP2 Methods: -- client.Zones.Settings.HTTP2.Edit(ctx context.Context, params zones.SettingHTTP2EditParams) (zones.ZoneSettingHTTP2, error) -- client.Zones.Settings.HTTP2.Get(ctx context.Context, query zones.SettingHTTP2GetParams) (zones.ZoneSettingHTTP2, error) +- client.Zones.Settings.HTTP2.Edit(ctx context.Context, params zones.SettingHTTP2EditParams) (zones.HTTP2, error) +- client.Zones.Settings.HTTP2.Get(ctx context.Context, query zones.SettingHTTP2GetParams) (zones.HTTP2, error) ### HTTP3 -Params Types: - -- zones.ZoneSettingHTTP3Param - Response Types: -- zones.ZoneSettingHTTP3 +- zones.HTTP3 Methods: -- client.Zones.Settings.HTTP3.Edit(ctx context.Context, params zones.SettingHTTP3EditParams) (zones.ZoneSettingHTTP3, error) -- client.Zones.Settings.HTTP3.Get(ctx context.Context, query zones.SettingHTTP3GetParams) (zones.ZoneSettingHTTP3, error) +- client.Zones.Settings.HTTP3.Edit(ctx context.Context, params zones.SettingHTTP3EditParams) (zones.HTTP3, error) +- client.Zones.Settings.HTTP3.Get(ctx context.Context, query zones.SettingHTTP3GetParams) (zones.HTTP3, error) ### ImageResizing Params Types: -- zones.ZoneSettingImageResizingParam +- zones.ImageResizingParam Response Types: -- zones.ZoneSettingImageResizing +- zones.ImageResizing Methods: -- client.Zones.Settings.ImageResizing.Edit(ctx context.Context, params zones.SettingImageResizingEditParams) (zones.ZoneSettingImageResizing, error) -- client.Zones.Settings.ImageResizing.Get(ctx context.Context, query zones.SettingImageResizingGetParams) (zones.ZoneSettingImageResizing, error) +- client.Zones.Settings.ImageResizing.Edit(ctx context.Context, params zones.SettingImageResizingEditParams) (zones.ImageResizing, error) +- client.Zones.Settings.ImageResizing.Get(ctx context.Context, query zones.SettingImageResizingGetParams) (zones.ImageResizing, error) ### IPGeolocation -Params Types: - -- zones.ZoneSettingIPGeolocationParam - Response Types: -- zones.ZoneSettingIPGeolocation +- zones.IPGeolocation Methods: -- client.Zones.Settings.IPGeolocation.Edit(ctx context.Context, params zones.SettingIPGeolocationEditParams) (zones.ZoneSettingIPGeolocation, error) -- client.Zones.Settings.IPGeolocation.Get(ctx context.Context, query zones.SettingIPGeolocationGetParams) (zones.ZoneSettingIPGeolocation, error) +- client.Zones.Settings.IPGeolocation.Edit(ctx context.Context, params zones.SettingIPGeolocationEditParams) (zones.IPGeolocation, error) +- client.Zones.Settings.IPGeolocation.Get(ctx context.Context, query zones.SettingIPGeolocationGetParams) (zones.IPGeolocation, error) ### IPV6 -Params Types: - -- zones.ZoneSettingIPV6Param - Response Types: -- zones.ZoneSettingIPV6 +- zones.IPV6 Methods: -- client.Zones.Settings.IPV6.Edit(ctx context.Context, params zones.SettingIPV6EditParams) (zones.ZoneSettingIPV6, error) -- client.Zones.Settings.IPV6.Get(ctx context.Context, query zones.SettingIPV6GetParams) (zones.ZoneSettingIPV6, error) +- client.Zones.Settings.IPV6.Edit(ctx context.Context, params zones.SettingIPV6EditParams) (zones.IPV6, error) +- client.Zones.Settings.IPV6.Get(ctx context.Context, query zones.SettingIPV6GetParams) (zones.IPV6, error) ### MinTLSVersion -Params Types: - -- zones.ZoneSettingMinTLSVersionParam - Response Types: -- zones.ZoneSettingMinTLSVersion +- zones.MinTLSVersion Methods: -- client.Zones.Settings.MinTLSVersion.Edit(ctx context.Context, params zones.SettingMinTLSVersionEditParams) (zones.ZoneSettingMinTLSVersion, error) -- client.Zones.Settings.MinTLSVersion.Get(ctx context.Context, query zones.SettingMinTLSVersionGetParams) (zones.ZoneSettingMinTLSVersion, error) +- client.Zones.Settings.MinTLSVersion.Edit(ctx context.Context, params zones.SettingMinTLSVersionEditParams) (zones.MinTLSVersion, error) +- client.Zones.Settings.MinTLSVersion.Get(ctx context.Context, query zones.SettingMinTLSVersionGetParams) (zones.MinTLSVersion, error) ### Minify -Params Types: - -- zones.ZoneSettingMinifyParam - Response Types: -- zones.ZoneSettingMinify +- zones.Minify Methods: -- client.Zones.Settings.Minify.Edit(ctx context.Context, params zones.SettingMinifyEditParams) (zones.ZoneSettingMinify, error) -- client.Zones.Settings.Minify.Get(ctx context.Context, query zones.SettingMinifyGetParams) (zones.ZoneSettingMinify, error) +- client.Zones.Settings.Minify.Edit(ctx context.Context, params zones.SettingMinifyEditParams) (zones.Minify, error) +- client.Zones.Settings.Minify.Get(ctx context.Context, query zones.SettingMinifyGetParams) (zones.Minify, error) ### Mirage -Params Types: - -- zones.ZoneSettingMirageParam - Response Types: -- zones.ZoneSettingMirage +- zones.Mirage Methods: -- client.Zones.Settings.Mirage.Edit(ctx context.Context, params zones.SettingMirageEditParams) (zones.ZoneSettingMirage, error) -- client.Zones.Settings.Mirage.Get(ctx context.Context, query zones.SettingMirageGetParams) (zones.ZoneSettingMirage, error) +- client.Zones.Settings.Mirage.Edit(ctx context.Context, params zones.SettingMirageEditParams) (zones.Mirage, error) +- client.Zones.Settings.Mirage.Get(ctx context.Context, query zones.SettingMirageGetParams) (zones.Mirage, error) ### MobileRedirect -Params Types: - -- zones.ZoneSettingMobileRedirectParam - Response Types: -- zones.ZoneSettingMobileRedirect +- zones.MobileRedirect Methods: -- client.Zones.Settings.MobileRedirect.Edit(ctx context.Context, params zones.SettingMobileRedirectEditParams) (zones.ZoneSettingMobileRedirect, error) -- client.Zones.Settings.MobileRedirect.Get(ctx context.Context, query zones.SettingMobileRedirectGetParams) (zones.ZoneSettingMobileRedirect, error) +- client.Zones.Settings.MobileRedirect.Edit(ctx context.Context, params zones.SettingMobileRedirectEditParams) (zones.MobileRedirect, error) +- client.Zones.Settings.MobileRedirect.Get(ctx context.Context, query zones.SettingMobileRedirectGetParams) (zones.MobileRedirect, error) ### NEL Params Types: -- zones.ZoneSettingNELParam +- zones.NELParam Response Types: -- zones.ZoneSettingNEL +- zones.NEL Methods: -- client.Zones.Settings.NEL.Edit(ctx context.Context, params zones.SettingNELEditParams) (zones.ZoneSettingNEL, error) -- client.Zones.Settings.NEL.Get(ctx context.Context, query zones.SettingNELGetParams) (zones.ZoneSettingNEL, error) +- client.Zones.Settings.NEL.Edit(ctx context.Context, params zones.SettingNELEditParams) (zones.NEL, error) +- client.Zones.Settings.NEL.Get(ctx context.Context, query zones.SettingNELGetParams) (zones.NEL, error) ### OpportunisticEncryption -Params Types: - -- zones.ZoneSettingOpportunisticEncryptionParam - Response Types: -- zones.ZoneSettingOpportunisticEncryption +- zones.OpportunisticEncryption Methods: -- client.Zones.Settings.OpportunisticEncryption.Edit(ctx context.Context, params zones.SettingOpportunisticEncryptionEditParams) (zones.ZoneSettingOpportunisticEncryption, error) -- client.Zones.Settings.OpportunisticEncryption.Get(ctx context.Context, query zones.SettingOpportunisticEncryptionGetParams) (zones.ZoneSettingOpportunisticEncryption, error) +- client.Zones.Settings.OpportunisticEncryption.Edit(ctx context.Context, params zones.SettingOpportunisticEncryptionEditParams) (zones.OpportunisticEncryption, error) +- client.Zones.Settings.OpportunisticEncryption.Get(ctx context.Context, query zones.SettingOpportunisticEncryptionGetParams) (zones.OpportunisticEncryption, error) ### OpportunisticOnion -Params Types: - -- zones.ZoneSettingOpportunisticOnionParam - Response Types: -- zones.ZoneSettingOpportunisticOnion +- zones.OpportunisticOnion Methods: -- client.Zones.Settings.OpportunisticOnion.Edit(ctx context.Context, params zones.SettingOpportunisticOnionEditParams) (zones.ZoneSettingOpportunisticOnion, error) -- client.Zones.Settings.OpportunisticOnion.Get(ctx context.Context, query zones.SettingOpportunisticOnionGetParams) (zones.ZoneSettingOpportunisticOnion, error) +- client.Zones.Settings.OpportunisticOnion.Edit(ctx context.Context, params zones.SettingOpportunisticOnionEditParams) (zones.OpportunisticOnion, error) +- client.Zones.Settings.OpportunisticOnion.Get(ctx context.Context, query zones.SettingOpportunisticOnionGetParams) (zones.OpportunisticOnion, error) ### OrangeToOrange Params Types: -- zones.ZoneSettingOrangeToOrangeParam +- zones.OrangeToOrangeParam Response Types: -- zones.ZoneSettingOrangeToOrange +- zones.OrangeToOrange Methods: -- client.Zones.Settings.OrangeToOrange.Edit(ctx context.Context, params zones.SettingOrangeToOrangeEditParams) (zones.ZoneSettingOrangeToOrange, error) -- client.Zones.Settings.OrangeToOrange.Get(ctx context.Context, query zones.SettingOrangeToOrangeGetParams) (zones.ZoneSettingOrangeToOrange, error) +- client.Zones.Settings.OrangeToOrange.Edit(ctx context.Context, params zones.SettingOrangeToOrangeEditParams) (zones.OrangeToOrange, error) +- client.Zones.Settings.OrangeToOrange.Get(ctx context.Context, query zones.SettingOrangeToOrangeGetParams) (zones.OrangeToOrange, error) ### OriginErrorPagePassThru -Params Types: - -- zones.ZoneSettingOriginErrorPagePassThruParam - Response Types: -- zones.ZoneSettingOriginErrorPagePassThru +- zones.OriginErrorPagePassThru Methods: -- client.Zones.Settings.OriginErrorPagePassThru.Edit(ctx context.Context, params zones.SettingOriginErrorPagePassThruEditParams) (zones.ZoneSettingOriginErrorPagePassThru, error) -- client.Zones.Settings.OriginErrorPagePassThru.Get(ctx context.Context, query zones.SettingOriginErrorPagePassThruGetParams) (zones.ZoneSettingOriginErrorPagePassThru, error) +- client.Zones.Settings.OriginErrorPagePassThru.Edit(ctx context.Context, params zones.SettingOriginErrorPagePassThruEditParams) (zones.OriginErrorPagePassThru, error) +- client.Zones.Settings.OriginErrorPagePassThru.Get(ctx context.Context, query zones.SettingOriginErrorPagePassThruGetParams) (zones.OriginErrorPagePassThru, error) ### OriginMaxHTTPVersion Response Types: +- zones.OriginMaxHTTPVersion - zones.SettingOriginMaxHTTPVersionEditResponse - zones.SettingOriginMaxHTTPVersionGetResponse @@ -829,342 +666,300 @@ Methods: Params Types: -- zones.ZoneSettingPolishParam +- zones.PolishParam Response Types: -- zones.ZoneSettingPolish +- zones.Polish Methods: -- client.Zones.Settings.Polish.Edit(ctx context.Context, params zones.SettingPolishEditParams) (zones.ZoneSettingPolish, error) -- client.Zones.Settings.Polish.Get(ctx context.Context, query zones.SettingPolishGetParams) (zones.ZoneSettingPolish, error) +- client.Zones.Settings.Polish.Edit(ctx context.Context, params zones.SettingPolishEditParams) (zones.Polish, error) +- client.Zones.Settings.Polish.Get(ctx context.Context, query zones.SettingPolishGetParams) (zones.Polish, error) ### PrefetchPreload -Params Types: - -- zones.ZoneSettingPrefetchPreloadParam - Response Types: -- zones.ZoneSettingPrefetchPreload +- zones.PrefetchPreload Methods: -- client.Zones.Settings.PrefetchPreload.Edit(ctx context.Context, params zones.SettingPrefetchPreloadEditParams) (zones.ZoneSettingPrefetchPreload, error) -- client.Zones.Settings.PrefetchPreload.Get(ctx context.Context, query zones.SettingPrefetchPreloadGetParams) (zones.ZoneSettingPrefetchPreload, error) +- client.Zones.Settings.PrefetchPreload.Edit(ctx context.Context, params zones.SettingPrefetchPreloadEditParams) (zones.PrefetchPreload, error) +- client.Zones.Settings.PrefetchPreload.Get(ctx context.Context, query zones.SettingPrefetchPreloadGetParams) (zones.PrefetchPreload, error) ### ProxyReadTimeout Params Types: -- zones.ZoneSettingProxyReadTimeoutParam +- zones.ProxyReadTimeoutParam Response Types: -- zones.ZoneSettingProxyReadTimeout +- zones.ProxyReadTimeout Methods: -- client.Zones.Settings.ProxyReadTimeout.Edit(ctx context.Context, params zones.SettingProxyReadTimeoutEditParams) (zones.ZoneSettingProxyReadTimeout, error) -- client.Zones.Settings.ProxyReadTimeout.Get(ctx context.Context, query zones.SettingProxyReadTimeoutGetParams) (zones.ZoneSettingProxyReadTimeout, error) +- client.Zones.Settings.ProxyReadTimeout.Edit(ctx context.Context, params zones.SettingProxyReadTimeoutEditParams) (zones.ProxyReadTimeout, error) +- client.Zones.Settings.ProxyReadTimeout.Get(ctx context.Context, query zones.SettingProxyReadTimeoutGetParams) (zones.ProxyReadTimeout, error) ### PseudoIPV4 -Params Types: - -- zones.ZoneSettingPseudoIPV4Param - Response Types: -- zones.ZoneSettingPseudoIPV4 +- zones.PseudoIPV4 Methods: -- client.Zones.Settings.PseudoIPV4.Edit(ctx context.Context, params zones.SettingPseudoIPV4EditParams) (zones.ZoneSettingPseudoIPV4, error) -- client.Zones.Settings.PseudoIPV4.Get(ctx context.Context, query zones.SettingPseudoIPV4GetParams) (zones.ZoneSettingPseudoIPV4, error) +- client.Zones.Settings.PseudoIPV4.Edit(ctx context.Context, params zones.SettingPseudoIPV4EditParams) (zones.PseudoIPV4, error) +- client.Zones.Settings.PseudoIPV4.Get(ctx context.Context, query zones.SettingPseudoIPV4GetParams) (zones.PseudoIPV4, error) ### ResponseBuffering -Params Types: - -- zones.ZoneSettingBufferingParam - Response Types: -- zones.ZoneSettingBuffering +- zones.ResponseBuffering Methods: -- client.Zones.Settings.ResponseBuffering.Edit(ctx context.Context, params zones.SettingResponseBufferingEditParams) (zones.ZoneSettingBuffering, error) -- client.Zones.Settings.ResponseBuffering.Get(ctx context.Context, query zones.SettingResponseBufferingGetParams) (zones.ZoneSettingBuffering, error) +- client.Zones.Settings.ResponseBuffering.Edit(ctx context.Context, params zones.SettingResponseBufferingEditParams) (zones.ResponseBuffering, error) +- client.Zones.Settings.ResponseBuffering.Get(ctx context.Context, query zones.SettingResponseBufferingGetParams) (zones.ResponseBuffering, error) ### RocketLoader Params Types: -- zones.ZoneSettingRocketLoaderParam +- zones.RocketLoaderParam Response Types: -- zones.ZoneSettingRocketLoader +- zones.RocketLoader Methods: -- client.Zones.Settings.RocketLoader.Edit(ctx context.Context, params zones.SettingRocketLoaderEditParams) (zones.ZoneSettingRocketLoader, error) -- client.Zones.Settings.RocketLoader.Get(ctx context.Context, query zones.SettingRocketLoaderGetParams) (zones.ZoneSettingRocketLoader, error) +- client.Zones.Settings.RocketLoader.Edit(ctx context.Context, params zones.SettingRocketLoaderEditParams) (zones.RocketLoader, error) +- client.Zones.Settings.RocketLoader.Get(ctx context.Context, query zones.SettingRocketLoaderGetParams) (zones.RocketLoader, error) ### SecurityHeaders -Params Types: - -- zones.ZoneSettingSecurityHeaderParam - Response Types: -- zones.ZoneSettingSecurityHeader +- zones.SecurityHeaders Methods: -- client.Zones.Settings.SecurityHeaders.Edit(ctx context.Context, params zones.SettingSecurityHeaderEditParams) (zones.ZoneSettingSecurityHeader, error) -- client.Zones.Settings.SecurityHeaders.Get(ctx context.Context, query zones.SettingSecurityHeaderGetParams) (zones.ZoneSettingSecurityHeader, error) +- client.Zones.Settings.SecurityHeaders.Edit(ctx context.Context, params zones.SettingSecurityHeaderEditParams) (zones.SecurityHeaders, error) +- client.Zones.Settings.SecurityHeaders.Get(ctx context.Context, query zones.SettingSecurityHeaderGetParams) (zones.SecurityHeaders, error) ### SecurityLevel -Params Types: - -- zones.ZoneSettingSecurityLevelParam - Response Types: -- zones.ZoneSettingSecurityLevel +- zones.SecurityLevel Methods: -- client.Zones.Settings.SecurityLevel.Edit(ctx context.Context, params zones.SettingSecurityLevelEditParams) (zones.ZoneSettingSecurityLevel, error) -- client.Zones.Settings.SecurityLevel.Get(ctx context.Context, query zones.SettingSecurityLevelGetParams) (zones.ZoneSettingSecurityLevel, error) +- client.Zones.Settings.SecurityLevel.Edit(ctx context.Context, params zones.SettingSecurityLevelEditParams) (zones.SecurityLevel, error) +- client.Zones.Settings.SecurityLevel.Get(ctx context.Context, query zones.SettingSecurityLevelGetParams) (zones.SecurityLevel, error) ### ServerSideExcludes -Params Types: - -- zones.ZoneSettingServerSideExcludeParam - Response Types: -- zones.ZoneSettingServerSideExclude +- zones.ServerSideExcludes Methods: -- client.Zones.Settings.ServerSideExcludes.Edit(ctx context.Context, params zones.SettingServerSideExcludeEditParams) (zones.ZoneSettingServerSideExclude, error) -- client.Zones.Settings.ServerSideExcludes.Get(ctx context.Context, query zones.SettingServerSideExcludeGetParams) (zones.ZoneSettingServerSideExclude, error) +- client.Zones.Settings.ServerSideExcludes.Edit(ctx context.Context, params zones.SettingServerSideExcludeEditParams) (zones.ServerSideExcludes, error) +- client.Zones.Settings.ServerSideExcludes.Get(ctx context.Context, query zones.SettingServerSideExcludeGetParams) (zones.ServerSideExcludes, error) ### SortQueryStringForCache -Params Types: - -- zones.ZoneSettingSortQueryStringForCacheParam - Response Types: -- zones.ZoneSettingSortQueryStringForCache +- zones.SortQueryStringForCache Methods: -- client.Zones.Settings.SortQueryStringForCache.Edit(ctx context.Context, params zones.SettingSortQueryStringForCacheEditParams) (zones.ZoneSettingSortQueryStringForCache, error) -- client.Zones.Settings.SortQueryStringForCache.Get(ctx context.Context, query zones.SettingSortQueryStringForCacheGetParams) (zones.ZoneSettingSortQueryStringForCache, error) +- client.Zones.Settings.SortQueryStringForCache.Edit(ctx context.Context, params zones.SettingSortQueryStringForCacheEditParams) (zones.SortQueryStringForCache, error) +- client.Zones.Settings.SortQueryStringForCache.Get(ctx context.Context, query zones.SettingSortQueryStringForCacheGetParams) (zones.SortQueryStringForCache, error) ### SSL -Params Types: - -- zones.ZoneSettingSSLParam - Response Types: -- zones.ZoneSettingSSL +- zones.SSL Methods: -- client.Zones.Settings.SSL.Edit(ctx context.Context, params zones.SettingSSLEditParams) (zones.ZoneSettingSSL, error) -- client.Zones.Settings.SSL.Get(ctx context.Context, query zones.SettingSSLGetParams) (zones.ZoneSettingSSL, error) +- client.Zones.Settings.SSL.Edit(ctx context.Context, params zones.SettingSSLEditParams) (zones.SSL, error) +- client.Zones.Settings.SSL.Get(ctx context.Context, query zones.SettingSSLGetParams) (zones.SSL, error) ### SSLRecommender Params Types: -- zones.ZoneSettingSSLRecommenderParam +- zones.SSLRecommenderParam Response Types: -- zones.ZoneSettingSSLRecommender +- zones.SSLRecommender Methods: -- client.Zones.Settings.SSLRecommender.Edit(ctx context.Context, params zones.SettingSSLRecommenderEditParams) (zones.ZoneSettingSSLRecommender, error) -- client.Zones.Settings.SSLRecommender.Get(ctx context.Context, query zones.SettingSSLRecommenderGetParams) (zones.ZoneSettingSSLRecommender, error) +- client.Zones.Settings.SSLRecommender.Edit(ctx context.Context, params zones.SettingSSLRecommenderEditParams) (zones.SSLRecommender, error) +- client.Zones.Settings.SSLRecommender.Get(ctx context.Context, query zones.SettingSSLRecommenderGetParams) (zones.SSLRecommender, error) ### TLS1_3 -Params Types: - -- zones.ZoneSettingTLS1_3Param - Response Types: -- zones.ZoneSettingTLS1_3 +- zones.TLS1_3 Methods: -- client.Zones.Settings.TLS1_3.Edit(ctx context.Context, params zones.SettingTLS1_3EditParams) (zones.ZoneSettingTLS1_3, error) -- client.Zones.Settings.TLS1_3.Get(ctx context.Context, query zones.SettingTLS1_3GetParams) (zones.ZoneSettingTLS1_3, error) +- client.Zones.Settings.TLS1_3.Edit(ctx context.Context, params zones.SettingTLS1_3EditParams) (zones.TLS1_3, error) +- client.Zones.Settings.TLS1_3.Get(ctx context.Context, query zones.SettingTLS1_3GetParams) (zones.TLS1_3, error) ### TLSClientAuth -Params Types: - -- zones.ZoneSettingTLSClientAuthParam - Response Types: -- zones.ZoneSettingTLSClientAuth +- zones.TLSClientAuth Methods: -- client.Zones.Settings.TLSClientAuth.Edit(ctx context.Context, params zones.SettingTLSClientAuthEditParams) (zones.ZoneSettingTLSClientAuth, error) -- client.Zones.Settings.TLSClientAuth.Get(ctx context.Context, query zones.SettingTLSClientAuthGetParams) (zones.ZoneSettingTLSClientAuth, error) +- client.Zones.Settings.TLSClientAuth.Edit(ctx context.Context, params zones.SettingTLSClientAuthEditParams) (zones.TLSClientAuth, error) +- client.Zones.Settings.TLSClientAuth.Get(ctx context.Context, query zones.SettingTLSClientAuthGetParams) (zones.TLSClientAuth, error) ### TrueClientIPHeader -Params Types: - -- zones.ZoneSettingTrueClientIPHeaderParam - Response Types: -- zones.ZoneSettingTrueClientIPHeader +- zones.TrueClientIPHeader Methods: -- client.Zones.Settings.TrueClientIPHeader.Edit(ctx context.Context, params zones.SettingTrueClientIPHeaderEditParams) (zones.ZoneSettingTrueClientIPHeader, error) -- client.Zones.Settings.TrueClientIPHeader.Get(ctx context.Context, query zones.SettingTrueClientIPHeaderGetParams) (zones.ZoneSettingTrueClientIPHeader, error) +- client.Zones.Settings.TrueClientIPHeader.Edit(ctx context.Context, params zones.SettingTrueClientIPHeaderEditParams) (zones.TrueClientIPHeader, error) +- client.Zones.Settings.TrueClientIPHeader.Get(ctx context.Context, query zones.SettingTrueClientIPHeaderGetParams) (zones.TrueClientIPHeader, error) ### WAF -Params Types: - -- zones.ZoneSettingWAFParam - Response Types: -- zones.ZoneSettingWAF +- zones.WAF Methods: -- client.Zones.Settings.WAF.Edit(ctx context.Context, params zones.SettingWAFEditParams) (zones.ZoneSettingWAF, error) -- client.Zones.Settings.WAF.Get(ctx context.Context, query zones.SettingWAFGetParams) (zones.ZoneSettingWAF, error) +- client.Zones.Settings.WAF.Edit(ctx context.Context, params zones.SettingWAFEditParams) (zones.WAF, error) +- client.Zones.Settings.WAF.Get(ctx context.Context, query zones.SettingWAFGetParams) (zones.WAF, error) ### WebP -Params Types: - -- zones.ZoneSettingWebPParam - Response Types: -- zones.ZoneSettingWebP +- zones.WebP Methods: -- client.Zones.Settings.WebP.Edit(ctx context.Context, params zones.SettingWebPEditParams) (zones.ZoneSettingWebP, error) -- client.Zones.Settings.WebP.Get(ctx context.Context, query zones.SettingWebPGetParams) (zones.ZoneSettingWebP, error) +- client.Zones.Settings.WebP.Edit(ctx context.Context, params zones.SettingWebPEditParams) (zones.WebP, error) +- client.Zones.Settings.WebP.Get(ctx context.Context, query zones.SettingWebPGetParams) (zones.WebP, error) ### Websocket -Params Types: - -- zones.ZoneSettingWebsocketsParam - Response Types: -- zones.ZoneSettingWebsockets +- zones.Websocket Methods: -- client.Zones.Settings.Websocket.Edit(ctx context.Context, params zones.SettingWebsocketEditParams) (zones.ZoneSettingWebsockets, error) -- client.Zones.Settings.Websocket.Get(ctx context.Context, query zones.SettingWebsocketGetParams) (zones.ZoneSettingWebsockets, error) +- client.Zones.Settings.Websocket.Edit(ctx context.Context, params zones.SettingWebsocketEditParams) (zones.Websocket, error) +- client.Zones.Settings.Websocket.Get(ctx context.Context, query zones.SettingWebsocketGetParams) (zones.Websocket, error) ### FontSettings Response Types: -- zones.ZoneSettingFonts +- zones.FontSettings Methods: -- client.Zones.Settings.FontSettings.Edit(ctx context.Context, params zones.SettingFontSettingEditParams) (zones.ZoneSettingFonts, error) -- client.Zones.Settings.FontSettings.Get(ctx context.Context, query zones.SettingFontSettingGetParams) (zones.ZoneSettingFonts, error) +- client.Zones.Settings.FontSettings.Edit(ctx context.Context, params zones.SettingFontSettingEditParams) (zones.FontSettings, error) +- client.Zones.Settings.FontSettings.Get(ctx context.Context, query zones.SettingFontSettingGetParams) (zones.FontSettings, error) ## CustomNameservers Response Types: -- zones.CustomNameserverUpdateResponse -- zones.CustomNameserverGetResponse +- zones.CustomNameserverUpdateResponseUnion +- zones.CustomNameserverGetResponseUnion Methods: -- client.Zones.CustomNameservers.Update(ctx context.Context, params zones.CustomNameserverUpdateParams) (zones.CustomNameserverUpdateResponse, error) -- client.Zones.CustomNameservers.Get(ctx context.Context, query zones.CustomNameserverGetParams) (zones.CustomNameserverGetResponse, error) +- client.Zones.CustomNameservers.Update(ctx context.Context, params zones.CustomNameserverUpdateParams) (zones.CustomNameserverUpdateResponseUnion, error) +- client.Zones.CustomNameservers.Get(ctx context.Context, query zones.CustomNameserverGetParams) (zones.CustomNameserverGetResponseUnion, error) ## Holds Response Types: -- zones.HoldNewResponse -- zones.HoldDeleteResponse -- zones.HoldGetResponse - -Methods: - -- client.Zones.Holds.New(ctx context.Context, params zones.HoldNewParams) (zones.HoldNewResponse, error) -- client.Zones.Holds.Delete(ctx context.Context, params zones.HoldDeleteParams) (zones.HoldDeleteResponse, error) -- client.Zones.Holds.Get(ctx context.Context, query zones.HoldGetParams) (zones.HoldGetResponse, error) - -## Workers - -### Script - -Response Types: - -- zones.WorkerScriptUpdateResponse +- zones.ZoneHold Methods: -- client.Zones.Workers.Script.Update(ctx context.Context, body zones.WorkerScriptUpdateParams) (zones.WorkerScriptUpdateResponse, error) -- client.Zones.Workers.Script.Delete(ctx context.Context, body zones.WorkerScriptDeleteParams) error -- client.Zones.Workers.Script.Get(ctx context.Context, query zones.WorkerScriptGetParams) (http.Response, error) +- client.Zones.Holds.New(ctx context.Context, params zones.HoldNewParams) (zones.ZoneHold, error) +- client.Zones.Holds.Delete(ctx context.Context, params zones.HoldDeleteParams) (zones.ZoneHold, error) +- client.Zones.Holds.Get(ctx context.Context, query zones.HoldGetParams) (zones.ZoneHold, error) ## Subscriptions Response Types: -- zones.SubscriptionNewResponse -- zones.SubscriptionListResponse -- zones.SubscriptionGetResponse +- zones.SubscriptionNewResponseUnion +- zones.SubscriptionGetResponseUnion Methods: -- client.Zones.Subscriptions.New(ctx context.Context, identifier string, body zones.SubscriptionNewParams) (zones.SubscriptionNewResponse, error) -- client.Zones.Subscriptions.List(ctx context.Context, accountIdentifier string) (pagination.SinglePage[zones.SubscriptionListResponse], error) -- client.Zones.Subscriptions.Get(ctx context.Context, identifier string) (zones.SubscriptionGetResponse, error) +- client.Zones.Subscriptions.New(ctx context.Context, identifier string, body zones.SubscriptionNewParams) (zones.SubscriptionNewResponseUnion, error) +- client.Zones.Subscriptions.List(ctx context.Context, accountIdentifier string) (pagination.SinglePage[user.Subscription], error) +- client.Zones.Subscriptions.Get(ctx context.Context, identifier string) (zones.SubscriptionGetResponseUnion, error) # LoadBalancers -Response Types: +Params Types: +- load_balancers.AdaptiveRoutingParam +- load_balancers.CheckRegion +- load_balancers.DefaultPoolsParam +- load_balancers.FilterOptionsParam +- load_balancers.HeaderParam +- load_balancers.HostParam +- load_balancers.LoadSheddingParam +- load_balancers.LocationStrategyParam +- load_balancers.NotificationFilterParam +- load_balancers.OriginParam +- load_balancers.OriginSteeringParam +- load_balancers.RandomSteeringParam +- load_balancers.RulesParam +- load_balancers.SessionAffinityAttributesParam + +Response Types: + +- load_balancers.AdaptiveRouting +- load_balancers.CheckRegion +- load_balancers.DefaultPools +- load_balancers.FilterOptions +- load_balancers.Header +- load_balancers.Host - load_balancers.LoadBalancer +- load_balancers.LoadShedding +- load_balancers.LocationStrategy +- load_balancers.NotificationFilter +- load_balancers.Origin +- load_balancers.OriginSteering +- load_balancers.RandomSteering +- load_balancers.Rules +- load_balancers.SessionAffinityAttributes - load_balancers.LoadBalancerDeleteResponse Methods: @@ -1172,7 +967,7 @@ Methods: - client.LoadBalancers.New(ctx context.Context, params load_balancers.LoadBalancerNewParams) (load_balancers.LoadBalancer, error) - client.LoadBalancers.Update(ctx context.Context, loadBalancerID string, params load_balancers.LoadBalancerUpdateParams) (load_balancers.LoadBalancer, error) - client.LoadBalancers.List(ctx context.Context, query load_balancers.LoadBalancerListParams) (pagination.SinglePage[load_balancers.LoadBalancer], error) -- client.LoadBalancers.Delete(ctx context.Context, loadBalancerID string, body load_balancers.LoadBalancerDeleteParams) (load_balancers.LoadBalancerDeleteResponse, error) +- client.LoadBalancers.Delete(ctx context.Context, loadBalancerID string, params load_balancers.LoadBalancerDeleteParams) (load_balancers.LoadBalancerDeleteResponse, error) - client.LoadBalancers.Edit(ctx context.Context, loadBalancerID string, params load_balancers.LoadBalancerEditParams) (load_balancers.LoadBalancer, error) - client.LoadBalancers.Get(ctx context.Context, loadBalancerID string, query load_balancers.LoadBalancerGetParams) (load_balancers.LoadBalancer, error) @@ -1180,16 +975,17 @@ Methods: Response Types: +- load_balancers.Monitor - load_balancers.MonitorDeleteResponse Methods: -- client.LoadBalancers.Monitors.New(ctx context.Context, params load_balancers.MonitorNewParams) (user.LoadBalancingMonitor, error) -- client.LoadBalancers.Monitors.Update(ctx context.Context, monitorID string, params load_balancers.MonitorUpdateParams) (user.LoadBalancingMonitor, error) -- client.LoadBalancers.Monitors.List(ctx context.Context, query load_balancers.MonitorListParams) (pagination.SinglePage[user.LoadBalancingMonitor], error) -- client.LoadBalancers.Monitors.Delete(ctx context.Context, monitorID string, body load_balancers.MonitorDeleteParams) (load_balancers.MonitorDeleteResponse, error) -- client.LoadBalancers.Monitors.Edit(ctx context.Context, monitorID string, params load_balancers.MonitorEditParams) (user.LoadBalancingMonitor, error) -- client.LoadBalancers.Monitors.Get(ctx context.Context, monitorID string, query load_balancers.MonitorGetParams) (user.LoadBalancingMonitor, error) +- client.LoadBalancers.Monitors.New(ctx context.Context, params load_balancers.MonitorNewParams) (load_balancers.Monitor, error) +- client.LoadBalancers.Monitors.Update(ctx context.Context, monitorID string, params load_balancers.MonitorUpdateParams) (load_balancers.Monitor, error) +- client.LoadBalancers.Monitors.List(ctx context.Context, query load_balancers.MonitorListParams) (pagination.SinglePage[load_balancers.Monitor], error) +- client.LoadBalancers.Monitors.Delete(ctx context.Context, monitorID string, params load_balancers.MonitorDeleteParams) (load_balancers.MonitorDeleteResponse, error) +- client.LoadBalancers.Monitors.Edit(ctx context.Context, monitorID string, params load_balancers.MonitorEditParams) (load_balancers.Monitor, error) +- client.LoadBalancers.Monitors.Get(ctx context.Context, monitorID string, query load_balancers.MonitorGetParams) (load_balancers.Monitor, error) ### Previews @@ -1215,28 +1011,29 @@ Methods: Response Types: +- load_balancers.Pool - load_balancers.PoolDeleteResponse Methods: -- client.LoadBalancers.Pools.New(ctx context.Context, params load_balancers.PoolNewParams) (user.LoadBalancingPool, error) -- client.LoadBalancers.Pools.Update(ctx context.Context, poolID string, params load_balancers.PoolUpdateParams) (user.LoadBalancingPool, error) -- client.LoadBalancers.Pools.List(ctx context.Context, params load_balancers.PoolListParams) (pagination.SinglePage[user.LoadBalancingPool], error) -- client.LoadBalancers.Pools.Delete(ctx context.Context, poolID string, body load_balancers.PoolDeleteParams) (load_balancers.PoolDeleteResponse, error) -- client.LoadBalancers.Pools.Edit(ctx context.Context, poolID string, params load_balancers.PoolEditParams) (user.LoadBalancingPool, error) -- client.LoadBalancers.Pools.Get(ctx context.Context, poolID string, query load_balancers.PoolGetParams) (user.LoadBalancingPool, error) +- client.LoadBalancers.Pools.New(ctx context.Context, params load_balancers.PoolNewParams) (load_balancers.Pool, error) +- client.LoadBalancers.Pools.Update(ctx context.Context, poolID string, params load_balancers.PoolUpdateParams) (load_balancers.Pool, error) +- client.LoadBalancers.Pools.List(ctx context.Context, params load_balancers.PoolListParams) (pagination.SinglePage[load_balancers.Pool], error) +- client.LoadBalancers.Pools.Delete(ctx context.Context, poolID string, params load_balancers.PoolDeleteParams) (load_balancers.PoolDeleteResponse, error) +- client.LoadBalancers.Pools.Edit(ctx context.Context, poolID string, params load_balancers.PoolEditParams) (load_balancers.Pool, error) +- client.LoadBalancers.Pools.Get(ctx context.Context, poolID string, query load_balancers.PoolGetParams) (load_balancers.Pool, error) ### Health Response Types: - load_balancers.PoolHealthNewResponse -- load_balancers.PoolHealthGetResponse +- load_balancers.PoolHealthGetResponseUnion Methods: - client.LoadBalancers.Pools.Health.New(ctx context.Context, poolID string, params load_balancers.PoolHealthNewParams) (load_balancers.PoolHealthNewResponse, error) -- client.LoadBalancers.Pools.Health.Get(ctx context.Context, poolID string, query load_balancers.PoolHealthGetParams) (load_balancers.PoolHealthGetResponse, error) +- client.LoadBalancers.Pools.Health.Get(ctx context.Context, poolID string, query load_balancers.PoolHealthGetParams) (load_balancers.PoolHealthGetResponseUnion, error) ### References @@ -1250,21 +1047,25 @@ Methods: ## Previews +Response Types: + +- load_balancers.PreviewGetResponse + Methods: -- client.LoadBalancers.Previews.Get(ctx context.Context, previewID string, query load_balancers.PreviewGetParams) (user.LoadBalancingPreview, error) +- client.LoadBalancers.Previews.Get(ctx context.Context, previewID string, query load_balancers.PreviewGetParams) (load_balancers.PreviewGetResponse, error) ## Regions Response Types: -- load_balancers.RegionListResponse -- load_balancers.RegionGetResponse +- load_balancers.RegionListResponseUnion +- load_balancers.RegionGetResponseUnion Methods: -- client.LoadBalancers.Regions.List(ctx context.Context, params load_balancers.RegionListParams) (load_balancers.RegionListResponse, error) -- client.LoadBalancers.Regions.Get(ctx context.Context, regionID load_balancers.RegionGetParamsRegionID, query load_balancers.RegionGetParams) (load_balancers.RegionGetResponse, error) +- client.LoadBalancers.Regions.List(ctx context.Context, params load_balancers.RegionListParams) (load_balancers.RegionListResponseUnion, error) +- client.LoadBalancers.Regions.Get(ctx context.Context, regionID load_balancers.RegionGetParamsRegionID, query load_balancers.RegionGetParams) (load_balancers.RegionGetResponseUnion, error) ## Searches @@ -1290,6 +1091,8 @@ Methods: Response Types: +- cache.CacheReserve +- cache.CacheReserveClear - cache.CacheReserveClearResponse - cache.CacheReserveEditResponse - cache.CacheReserveGetResponse @@ -1297,7 +1100,7 @@ Response Types: Methods: -- client.Cache.CacheReserve.Clear(ctx context.Context, body cache.CacheReserveClearParams) (cache.CacheReserveClearResponse, error) +- client.Cache.CacheReserve.Clear(ctx context.Context, params cache.CacheReserveClearParams) (cache.CacheReserveClearResponse, error) - client.Cache.CacheReserve.Edit(ctx context.Context, params cache.CacheReserveEditParams) (cache.CacheReserveEditResponse, error) - client.Cache.CacheReserve.Get(ctx context.Context, query cache.CacheReserveGetParams) (cache.CacheReserveGetResponse, error) - client.Cache.CacheReserve.Status(ctx context.Context, query cache.CacheReserveStatusParams) (cache.CacheReserveStatusResponse, error) @@ -1306,27 +1109,28 @@ Methods: Response Types: -- cache.SmartTieredCacheDeleteResponse -- cache.SmartTieredCacheEditResponse -- cache.SmartTieredCacheGetResponse +- cache.SmartTieredCacheDeleteResponseUnion +- cache.SmartTieredCacheEditResponseUnion +- cache.SmartTieredCacheGetResponseUnion Methods: -- client.Cache.SmartTieredCache.Delete(ctx context.Context, body cache.SmartTieredCacheDeleteParams) (cache.SmartTieredCacheDeleteResponse, error) -- client.Cache.SmartTieredCache.Edit(ctx context.Context, params cache.SmartTieredCacheEditParams) (cache.SmartTieredCacheEditResponse, error) -- client.Cache.SmartTieredCache.Get(ctx context.Context, query cache.SmartTieredCacheGetParams) (cache.SmartTieredCacheGetResponse, error) +- client.Cache.SmartTieredCache.Delete(ctx context.Context, params cache.SmartTieredCacheDeleteParams) (cache.SmartTieredCacheDeleteResponseUnion, error) +- client.Cache.SmartTieredCache.Edit(ctx context.Context, params cache.SmartTieredCacheEditParams) (cache.SmartTieredCacheEditResponseUnion, error) +- client.Cache.SmartTieredCache.Get(ctx context.Context, query cache.SmartTieredCacheGetParams) (cache.SmartTieredCacheGetResponseUnion, error) ## Variants Response Types: -- cache.CacheVariants +- cache.CacheVariant +- cache.CacheVariantIdentifier - cache.VariantEditResponse - cache.VariantGetResponse Methods: -- client.Cache.Variants.Delete(ctx context.Context, body cache.VariantDeleteParams) (cache.CacheVariants, error) +- client.Cache.Variants.Delete(ctx context.Context, params cache.VariantDeleteParams) (cache.CacheVariant, error) - client.Cache.Variants.Edit(ctx context.Context, params cache.VariantEditParams) (cache.VariantEditResponse, error) - client.Cache.Variants.Get(ctx context.Context, query cache.VariantGetParams) (cache.VariantGetResponse, error) @@ -1334,6 +1138,7 @@ Methods: Response Types: +- cache.RegionalTieredCache - cache.RegionalTieredCacheEditResponse - cache.RegionalTieredCacheGetResponse @@ -1348,27 +1153,32 @@ Methods: Response Types: -- ssl.AnalyzeNewResponse +- ssl.AnalyzeNewResponseUnion Methods: -- client.SSL.Analyze.New(ctx context.Context, params ssl.AnalyzeNewParams) (ssl.AnalyzeNewResponse, error) +- client.SSL.Analyze.New(ctx context.Context, params ssl.AnalyzeNewParams) (ssl.AnalyzeNewResponseUnion, error) ## CertificatePacks +Params Types: + +- ssl.HostParam + Response Types: +- ssl.Host - ssl.CertificatePackListResponse - ssl.CertificatePackDeleteResponse - ssl.CertificatePackEditResponse -- ssl.CertificatePackGetResponse +- ssl.CertificatePackGetResponseUnion Methods: - client.SSL.CertificatePacks.List(ctx context.Context, params ssl.CertificatePackListParams) (pagination.SinglePage[ssl.CertificatePackListResponse], error) -- client.SSL.CertificatePacks.Delete(ctx context.Context, certificatePackID string, body ssl.CertificatePackDeleteParams) (ssl.CertificatePackDeleteResponse, error) -- client.SSL.CertificatePacks.Edit(ctx context.Context, certificatePackID string, body ssl.CertificatePackEditParams) (ssl.CertificatePackEditResponse, error) -- client.SSL.CertificatePacks.Get(ctx context.Context, certificatePackID string, query ssl.CertificatePackGetParams) (ssl.CertificatePackGetResponse, error) +- client.SSL.CertificatePacks.Delete(ctx context.Context, certificatePackID string, params ssl.CertificatePackDeleteParams) (ssl.CertificatePackDeleteResponse, error) +- client.SSL.CertificatePacks.Edit(ctx context.Context, certificatePackID string, params ssl.CertificatePackEditParams) (ssl.CertificatePackEditResponse, error) +- client.SSL.CertificatePacks.Get(ctx context.Context, certificatePackID string, query ssl.CertificatePackGetParams) (ssl.CertificatePackGetResponseUnion, error) ### Order @@ -1404,6 +1214,10 @@ Methods: ### Settings +Params Types: + +- ssl.UniversalSSLSettingsParam + Response Types: - ssl.UniversalSSLSettings @@ -1417,31 +1231,30 @@ Methods: Response Types: -- ssl.TLSVerificationSetting +- ssl.Verification - ssl.VerificationEditResponse Methods: - client.SSL.Verification.Edit(ctx context.Context, certificatePackID string, params ssl.VerificationEditParams) (ssl.VerificationEditResponse, error) -- client.SSL.Verification.Get(ctx context.Context, params ssl.VerificationGetParams) ([]ssl.TLSVerificationSetting, error) +- client.SSL.Verification.Get(ctx context.Context, params ssl.VerificationGetParams) ([]ssl.Verification, error) # Subscriptions Response Types: -- subscriptions.SubscriptionNewResponse -- subscriptions.SubscriptionUpdateResponse -- subscriptions.SubscriptionListResponse +- subscriptions.SubscriptionNewResponseUnion +- subscriptions.SubscriptionUpdateResponseUnion - subscriptions.SubscriptionDeleteResponse -- subscriptions.SubscriptionGetResponse +- subscriptions.SubscriptionGetResponseUnion Methods: -- client.Subscriptions.New(ctx context.Context, identifier string, body subscriptions.SubscriptionNewParams) (subscriptions.SubscriptionNewResponse, error) -- client.Subscriptions.Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body subscriptions.SubscriptionUpdateParams) (subscriptions.SubscriptionUpdateResponse, error) -- client.Subscriptions.List(ctx context.Context, accountIdentifier string) (pagination.SinglePage[subscriptions.SubscriptionListResponse], error) -- client.Subscriptions.Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string) (subscriptions.SubscriptionDeleteResponse, error) -- client.Subscriptions.Get(ctx context.Context, identifier string) (subscriptions.SubscriptionGetResponse, error) +- client.Subscriptions.New(ctx context.Context, identifier string, body subscriptions.SubscriptionNewParams) (subscriptions.SubscriptionNewResponseUnion, error) +- client.Subscriptions.Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body subscriptions.SubscriptionUpdateParams) (subscriptions.SubscriptionUpdateResponseUnion, error) +- client.Subscriptions.List(ctx context.Context, accountIdentifier string) (pagination.SinglePage[user.Subscription], error) +- client.Subscriptions.Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body subscriptions.SubscriptionDeleteParams) (subscriptions.SubscriptionDeleteResponse, error) +- client.Subscriptions.Get(ctx context.Context, identifier string) (subscriptions.SubscriptionGetResponseUnion, error) # ACM @@ -1463,25 +1276,25 @@ Methods: Response Types: -- argo.SmartRoutingEditResponse -- argo.SmartRoutingGetResponse +- argo.SmartRoutingEditResponseUnion +- argo.SmartRoutingGetResponseUnion Methods: -- client.Argo.SmartRouting.Edit(ctx context.Context, params argo.SmartRoutingEditParams) (argo.SmartRoutingEditResponse, error) -- client.Argo.SmartRouting.Get(ctx context.Context, query argo.SmartRoutingGetParams) (argo.SmartRoutingGetResponse, error) +- client.Argo.SmartRouting.Edit(ctx context.Context, params argo.SmartRoutingEditParams) (argo.SmartRoutingEditResponseUnion, error) +- client.Argo.SmartRouting.Get(ctx context.Context, query argo.SmartRoutingGetParams) (argo.SmartRoutingGetResponseUnion, error) ## TieredCaching Response Types: -- argo.TieredCachingEditResponse -- argo.TieredCachingGetResponse +- argo.TieredCachingEditResponseUnion +- argo.TieredCachingGetResponseUnion Methods: -- client.Argo.TieredCaching.Edit(ctx context.Context, params argo.TieredCachingEditParams) (argo.TieredCachingEditResponse, error) -- client.Argo.TieredCaching.Get(ctx context.Context, query argo.TieredCachingGetParams) (argo.TieredCachingGetResponse, error) +- client.Argo.TieredCaching.Edit(ctx context.Context, params argo.TieredCachingEditParams) (argo.TieredCachingEditResponseUnion, error) +- client.Argo.TieredCaching.Get(ctx context.Context, query argo.TieredCachingGetParams) (argo.TieredCachingGetResponseUnion, error) # Plans @@ -1496,26 +1309,37 @@ Methods: # RatePlans +Params Types: + +- rate_plans.RatePlanParam + Response Types: -- rate_plans.RatePlanGetResponse +- rate_plans.RatePlan Methods: -- client.RatePlans.Get(ctx context.Context, zoneIdentifier string) ([]rate_plans.RatePlanGetResponse, error) +- client.RatePlans.Get(ctx context.Context, zoneIdentifier string) ([]rate_plans.RatePlan, error) # CertificateAuthorities ## HostnameAssociations +Params Types: + +- certificate_authorities.HostnameAssociationParam +- certificate_authorities.TLSHostnameAssociationParam + Response Types: -- certificate_authorities.TLSHostnameAssociation +- certificate_authorities.HostnameAssociation +- certificate_authorities.HostnameAssociationUpdateResponse +- certificate_authorities.HostnameAssociationGetResponse Methods: -- client.CertificateAuthorities.HostnameAssociations.Update(ctx context.Context, params certificate_authorities.HostnameAssociationUpdateParams) (certificate_authorities.TLSHostnameAssociation, error) -- client.CertificateAuthorities.HostnameAssociations.Get(ctx context.Context, params certificate_authorities.HostnameAssociationGetParams) (certificate_authorities.TLSHostnameAssociation, error) +- client.CertificateAuthorities.HostnameAssociations.Update(ctx context.Context, params certificate_authorities.HostnameAssociationUpdateParams) (certificate_authorities.HostnameAssociationUpdateResponse, error) +- client.CertificateAuthorities.HostnameAssociations.Get(ctx context.Context, params certificate_authorities.HostnameAssociationGetParams) (certificate_authorities.HostnameAssociationGetResponse, error) # ClientCertificates @@ -1533,21 +1357,26 @@ Methods: # CustomCertificates +Params Types: + +- custom_certificates.GeoRestrictionsParam + Response Types: - custom_certificates.CustomCertificate -- custom_certificates.CustomCertificateNewResponse +- custom_certificates.GeoRestrictions +- custom_certificates.CustomCertificateNewResponseUnion - custom_certificates.CustomCertificateDeleteResponse -- custom_certificates.CustomCertificateEditResponse -- custom_certificates.CustomCertificateGetResponse +- custom_certificates.CustomCertificateEditResponseUnion +- custom_certificates.CustomCertificateGetResponseUnion Methods: -- client.CustomCertificates.New(ctx context.Context, params custom_certificates.CustomCertificateNewParams) (custom_certificates.CustomCertificateNewResponse, error) +- client.CustomCertificates.New(ctx context.Context, params custom_certificates.CustomCertificateNewParams) (custom_certificates.CustomCertificateNewResponseUnion, error) - client.CustomCertificates.List(ctx context.Context, params custom_certificates.CustomCertificateListParams) (pagination.V4PagePaginationArray[custom_certificates.CustomCertificate], error) -- client.CustomCertificates.Delete(ctx context.Context, customCertificateID string, body custom_certificates.CustomCertificateDeleteParams) (custom_certificates.CustomCertificateDeleteResponse, error) -- client.CustomCertificates.Edit(ctx context.Context, customCertificateID string, params custom_certificates.CustomCertificateEditParams) (custom_certificates.CustomCertificateEditResponse, error) -- client.CustomCertificates.Get(ctx context.Context, customCertificateID string, query custom_certificates.CustomCertificateGetParams) (custom_certificates.CustomCertificateGetResponse, error) +- client.CustomCertificates.Delete(ctx context.Context, customCertificateID string, params custom_certificates.CustomCertificateDeleteParams) (custom_certificates.CustomCertificateDeleteResponse, error) +- client.CustomCertificates.Edit(ctx context.Context, customCertificateID string, params custom_certificates.CustomCertificateEditParams) (custom_certificates.CustomCertificateEditResponseUnion, error) +- client.CustomCertificates.Get(ctx context.Context, customCertificateID string, query custom_certificates.CustomCertificateGetParams) (custom_certificates.CustomCertificateGetResponseUnion, error) ## Prioritize @@ -1557,8 +1386,17 @@ Methods: # CustomHostnames +Params Types: + +- custom_hostnames.BundleMethod +- custom_hostnames.DCVMethod +- custom_hostnames.DomainValidationType + Response Types: +- custom_hostnames.BundleMethod +- custom_hostnames.DCVMethod +- custom_hostnames.DomainValidationType - custom_hostnames.CustomHostnameNewResponse - custom_hostnames.CustomHostnameListResponse - custom_hostnames.CustomHostnameDeleteResponse @@ -1569,7 +1407,7 @@ Methods: - client.CustomHostnames.New(ctx context.Context, params custom_hostnames.CustomHostnameNewParams) (custom_hostnames.CustomHostnameNewResponse, error) - client.CustomHostnames.List(ctx context.Context, params custom_hostnames.CustomHostnameListParams) (pagination.V4PagePaginationArray[custom_hostnames.CustomHostnameListResponse], error) -- client.CustomHostnames.Delete(ctx context.Context, customHostnameID string, body custom_hostnames.CustomHostnameDeleteParams) (custom_hostnames.CustomHostnameDeleteResponse, error) +- client.CustomHostnames.Delete(ctx context.Context, customHostnameID string, params custom_hostnames.CustomHostnameDeleteParams) (custom_hostnames.CustomHostnameDeleteResponse, error) - client.CustomHostnames.Edit(ctx context.Context, customHostnameID string, params custom_hostnames.CustomHostnameEditParams) (custom_hostnames.CustomHostnameEditResponse, error) - client.CustomHostnames.Get(ctx context.Context, customHostnameID string, query custom_hostnames.CustomHostnameGetParams) (custom_hostnames.CustomHostnameGetResponse, error) @@ -1577,53 +1415,109 @@ Methods: Response Types: -- custom_hostnames.FallbackOriginUpdateResponse -- custom_hostnames.FallbackOriginDeleteResponse -- custom_hostnames.FallbackOriginGetResponse +- custom_hostnames.FallbackOriginUpdateResponseUnion +- custom_hostnames.FallbackOriginDeleteResponseUnion +- custom_hostnames.FallbackOriginGetResponseUnion Methods: -- client.CustomHostnames.FallbackOrigin.Update(ctx context.Context, params custom_hostnames.FallbackOriginUpdateParams) (custom_hostnames.FallbackOriginUpdateResponse, error) -- client.CustomHostnames.FallbackOrigin.Delete(ctx context.Context, body custom_hostnames.FallbackOriginDeleteParams) (custom_hostnames.FallbackOriginDeleteResponse, error) -- client.CustomHostnames.FallbackOrigin.Get(ctx context.Context, query custom_hostnames.FallbackOriginGetParams) (custom_hostnames.FallbackOriginGetResponse, error) +- client.CustomHostnames.FallbackOrigin.Update(ctx context.Context, params custom_hostnames.FallbackOriginUpdateParams) (custom_hostnames.FallbackOriginUpdateResponseUnion, error) +- client.CustomHostnames.FallbackOrigin.Delete(ctx context.Context, params custom_hostnames.FallbackOriginDeleteParams) (custom_hostnames.FallbackOriginDeleteResponseUnion, error) +- client.CustomHostnames.FallbackOrigin.Get(ctx context.Context, query custom_hostnames.FallbackOriginGetParams) (custom_hostnames.FallbackOriginGetResponseUnion, error) # CustomNameservers Response Types: - custom_nameservers.CustomNameserver -- custom_nameservers.CustomNameserverDeleteResponse +- custom_nameservers.CustomNameserverDeleteResponseUnion Methods: - client.CustomNameservers.New(ctx context.Context, params custom_nameservers.CustomNameserverNewParams) (custom_nameservers.CustomNameserver, error) -- client.CustomNameservers.Delete(ctx context.Context, customNSID string, body custom_nameservers.CustomNameserverDeleteParams) (custom_nameservers.CustomNameserverDeleteResponse, error) +- client.CustomNameservers.Delete(ctx context.Context, customNSID string, params custom_nameservers.CustomNameserverDeleteParams) (custom_nameservers.CustomNameserverDeleteResponseUnion, error) - client.CustomNameservers.Availabilty(ctx context.Context, query custom_nameservers.CustomNameserverAvailabiltyParams) ([]string, error) - client.CustomNameservers.Get(ctx context.Context, query custom_nameservers.CustomNameserverGetParams) ([]custom_nameservers.CustomNameserver, error) -- client.CustomNameservers.Verify(ctx context.Context, body custom_nameservers.CustomNameserverVerifyParams) ([]custom_nameservers.CustomNameserver, error) +- client.CustomNameservers.Verify(ctx context.Context, params custom_nameservers.CustomNameserverVerifyParams) ([]custom_nameservers.CustomNameserver, error) # DNS +Response Types: + +- dns.DNSAnalyticsNominalMetric +- dns.DNSAnalyticsQuery + ## Records -Response Types: +Params Types: -- dns.DNSRecord +- dns.ARecordParam +- dns.AAAARecordParam +- dns.CAARecordParam +- dns.CERTRecordParam +- dns.CNAMERecordParam +- dns.DNSKEYRecordParam +- dns.DSRecordParam +- dns.HTTPSRecordParam +- dns.LOCRecordParam +- dns.MXRecordParam +- dns.NAPTRRecordParam +- dns.NSRecordParam +- dns.PTRRecordParam +- dns.RecordUnionParam +- dns.RecordMetadataParam +- dns.RecordTagsParam +- dns.SMIMEARecordParam +- dns.SRVRecordParam +- dns.SSHFPRecordParam +- dns.SVCBRecordParam +- dns.TLSARecordParam +- dns.TTLUnionParam +- dns.TXTRecordParam +- dns.URIRecordParam + +Response Types: + +- dns.ARecord +- dns.AAAARecord +- dns.CAARecord +- dns.CERTRecord +- dns.CNAMERecord +- dns.DNSKEYRecord +- dns.DSRecord +- dns.HTTPSRecord +- dns.LOCRecord +- dns.MXRecord +- dns.NAPTRRecord +- dns.NSRecord +- dns.PTRRecord +- dns.Record +- dns.RecordMetadata +- dns.RecordProcessTiming +- dns.RecordTags +- dns.SMIMEARecord +- dns.SRVRecord +- dns.SSHFPRecord +- dns.SVCBRecord +- dns.TLSARecord +- dns.TTLUnion +- dns.TXTRecord +- dns.URIRecord - dns.RecordDeleteResponse - dns.RecordImportResponse - dns.RecordScanResponse Methods: -- client.DNS.Records.New(ctx context.Context, params dns.RecordNewParams) (dns.DNSRecord, error) -- client.DNS.Records.Update(ctx context.Context, dnsRecordID string, params dns.RecordUpdateParams) (dns.DNSRecord, error) -- client.DNS.Records.List(ctx context.Context, params dns.RecordListParams) (pagination.V4PagePaginationArray[dns.DNSRecord], error) -- client.DNS.Records.Delete(ctx context.Context, dnsRecordID string, body dns.RecordDeleteParams) (dns.RecordDeleteResponse, error) -- client.DNS.Records.Edit(ctx context.Context, dnsRecordID string, params dns.RecordEditParams) (dns.DNSRecord, error) +- client.DNS.Records.New(ctx context.Context, params dns.RecordNewParams) (dns.Record, error) +- client.DNS.Records.Update(ctx context.Context, dnsRecordID string, params dns.RecordUpdateParams) (dns.Record, error) +- client.DNS.Records.List(ctx context.Context, params dns.RecordListParams) (pagination.V4PagePaginationArray[dns.Record], error) +- client.DNS.Records.Delete(ctx context.Context, dnsRecordID string, params dns.RecordDeleteParams) (dns.RecordDeleteResponse, error) +- client.DNS.Records.Edit(ctx context.Context, dnsRecordID string, params dns.RecordEditParams) (dns.Record, error) - client.DNS.Records.Export(ctx context.Context, query dns.RecordExportParams) (string, error) -- client.DNS.Records.Get(ctx context.Context, dnsRecordID string, query dns.RecordGetParams) (dns.DNSRecord, error) +- client.DNS.Records.Get(ctx context.Context, dnsRecordID string, query dns.RecordGetParams) (dns.Record, error) - client.DNS.Records.Import(ctx context.Context, params dns.RecordImportParams) (dns.RecordImportResponse, error) -- client.DNS.Records.Scan(ctx context.Context, body dns.RecordScanParams) (dns.RecordScanResponse, error) +- client.DNS.Records.Scan(ctx context.Context, params dns.RecordScanParams) (dns.RecordScanResponse, error) ## Analytics @@ -1631,36 +1525,46 @@ Methods: Response Types: -- dns.DNSAnalyticsReport +- dns.Report Methods: -- client.DNS.Analytics.Reports.Get(ctx context.Context, params dns.AnalyticsReportGetParams) (dns.DNSAnalyticsReport, error) +- client.DNS.Analytics.Reports.Get(ctx context.Context, params dns.AnalyticsReportGetParams) (dns.Report, error) #### Bytimes Response Types: -- dns.DNSAnalyticsReportByTime +- dns.ByTime Methods: -- client.DNS.Analytics.Reports.Bytimes.Get(ctx context.Context, params dns.AnalyticsReportBytimeGetParams) (dns.DNSAnalyticsReportByTime, error) +- client.DNS.Analytics.Reports.Bytimes.Get(ctx context.Context, params dns.AnalyticsReportBytimeGetParams) (dns.ByTime, error) ## Firewall +Params Types: + +- dns.AttackMitigationParam +- dns.FirewallParam +- dns.FirewallIPsUnionParam +- dns.UpstreamIPsUnionParam + Response Types: -- dns.DNSFirewall +- dns.AttackMitigation +- dns.Firewall +- dns.FirewallIPsUnion +- dns.UpstreamIPsUnion - dns.FirewallDeleteResponse Methods: -- client.DNS.Firewall.New(ctx context.Context, params dns.FirewallNewParams) (dns.DNSFirewall, error) -- client.DNS.Firewall.List(ctx context.Context, params dns.FirewallListParams) (pagination.V4PagePaginationArray[dns.DNSFirewall], error) -- client.DNS.Firewall.Delete(ctx context.Context, dnsFirewallID string, body dns.FirewallDeleteParams) (dns.FirewallDeleteResponse, error) -- client.DNS.Firewall.Edit(ctx context.Context, dnsFirewallID string, params dns.FirewallEditParams) (dns.DNSFirewall, error) -- client.DNS.Firewall.Get(ctx context.Context, dnsFirewallID string, query dns.FirewallGetParams) (dns.DNSFirewall, error) +- client.DNS.Firewall.New(ctx context.Context, params dns.FirewallNewParams) (dns.Firewall, error) +- client.DNS.Firewall.List(ctx context.Context, params dns.FirewallListParams) (pagination.V4PagePaginationArray[dns.Firewall], error) +- client.DNS.Firewall.Delete(ctx context.Context, dnsFirewallID string, params dns.FirewallDeleteParams) (dns.FirewallDeleteResponse, error) +- client.DNS.Firewall.Edit(ctx context.Context, dnsFirewallID string, params dns.FirewallEditParams) (dns.Firewall, error) +- client.DNS.Firewall.Get(ctx context.Context, dnsFirewallID string, query dns.FirewallGetParams) (dns.Firewall, error) ### Analytics @@ -1668,24 +1572,24 @@ Methods: Methods: -- client.DNS.Firewall.Analytics.Reports.Get(ctx context.Context, dnsFirewallID string, params dns.FirewallAnalyticsReportGetParams) (dns.DNSAnalyticsReport, error) +- client.DNS.Firewall.Analytics.Reports.Get(ctx context.Context, dnsFirewallID string, params dns.FirewallAnalyticsReportGetParams) (dns.Report, error) ##### Bytimes Methods: -- client.DNS.Firewall.Analytics.Reports.Bytimes.Get(ctx context.Context, dnsFirewallID string, params dns.FirewallAnalyticsReportBytimeGetParams) (dns.DNSAnalyticsReportByTime, error) +- client.DNS.Firewall.Analytics.Reports.Bytimes.Get(ctx context.Context, dnsFirewallID string, params dns.FirewallAnalyticsReportBytimeGetParams) (dns.ByTime, error) # DNSSEC Response Types: - dnssec.DNSSEC -- dnssec.DNSSECDeleteResponse +- dnssec.DNSSECDeleteResponseUnion Methods: -- client.DNSSEC.Delete(ctx context.Context, body dnssec.DNSSECDeleteParams) (dnssec.DNSSECDeleteResponse, error) +- client.DNSSEC.Delete(ctx context.Context, params dnssec.DNSSECDeleteParams) (dnssec.DNSSECDeleteResponseUnion, error) - client.DNSSEC.Edit(ctx context.Context, params dnssec.DNSSECEditParams) (dnssec.DNSSEC, error) - client.DNSSEC.Get(ctx context.Context, query dnssec.DNSSECGetParams) (dnssec.DNSSEC, error) @@ -1693,70 +1597,76 @@ Methods: Response Types: -- email_routing.EmailRoutingDisableResponse -- email_routing.EmailRoutingEnableResponse -- email_routing.EmailRoutingGetResponse +- email_routing.Settings Methods: -- client.EmailRouting.Disable(ctx context.Context, zoneIdentifier string) (email_routing.EmailRoutingDisableResponse, error) -- client.EmailRouting.Enable(ctx context.Context, zoneIdentifier string) (email_routing.EmailRoutingEnableResponse, error) -- client.EmailRouting.Get(ctx context.Context, zoneIdentifier string) (email_routing.EmailRoutingGetResponse, error) +- client.EmailRouting.Disable(ctx context.Context, zoneIdentifier string, body email_routing.EmailRoutingDisableParams) (email_routing.Settings, error) +- client.EmailRouting.Enable(ctx context.Context, zoneIdentifier string, body email_routing.EmailRoutingEnableParams) (email_routing.Settings, error) +- client.EmailRouting.Get(ctx context.Context, zoneIdentifier string) (email_routing.Settings, error) ## DNS Response Types: -- email_routing.EmailDNSRecord +- email_routing.DNSRecord Methods: -- client.EmailRouting.DNS.Get(ctx context.Context, zoneIdentifier string) ([]email_routing.EmailDNSRecord, error) +- client.EmailRouting.DNS.Get(ctx context.Context, zoneIdentifier string) ([]email_routing.DNSRecord, error) ## Rules +Params Types: + +- email_routing.ActionParam +- email_routing.MatcherParam + Response Types: -- email_routing.RuleNewResponse -- email_routing.RuleUpdateResponse -- email_routing.RuleListResponse -- email_routing.RuleDeleteResponse -- email_routing.RuleGetResponse +- email_routing.Action +- email_routing.EmailRoutingRule +- email_routing.Matcher Methods: -- client.EmailRouting.Rules.New(ctx context.Context, zoneIdentifier string, body email_routing.RuleNewParams) (email_routing.RuleNewResponse, error) -- client.EmailRouting.Rules.Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body email_routing.RuleUpdateParams) (email_routing.RuleUpdateResponse, error) -- client.EmailRouting.Rules.List(ctx context.Context, zoneIdentifier string, query email_routing.RuleListParams) (pagination.V4PagePaginationArray[email_routing.RuleListResponse], error) -- client.EmailRouting.Rules.Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.RuleDeleteResponse, error) -- client.EmailRouting.Rules.Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.RuleGetResponse, error) +- client.EmailRouting.Rules.New(ctx context.Context, zoneIdentifier string, body email_routing.RuleNewParams) (email_routing.EmailRoutingRule, error) +- client.EmailRouting.Rules.Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body email_routing.RuleUpdateParams) (email_routing.EmailRoutingRule, error) +- client.EmailRouting.Rules.List(ctx context.Context, zoneIdentifier string, query email_routing.RuleListParams) (pagination.V4PagePaginationArray[email_routing.EmailRoutingRule], error) +- client.EmailRouting.Rules.Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.EmailRoutingRule, error) +- client.EmailRouting.Rules.Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.EmailRoutingRule, error) ### CatchAlls +Params Types: + +- email_routing.CatchAllActionParam +- email_routing.CatchAllMatcherParam + Response Types: -- email_routing.EmailCatchAllRule +- email_routing.CatchAllAction +- email_routing.CatchAllMatcher +- email_routing.RuleCatchAllUpdateResponse +- email_routing.RuleCatchAllGetResponse Methods: -- client.EmailRouting.Rules.CatchAlls.Update(ctx context.Context, zoneIdentifier string, body email_routing.RuleCatchAllUpdateParams) (email_routing.EmailCatchAllRule, error) -- client.EmailRouting.Rules.CatchAlls.Get(ctx context.Context, zoneIdentifier string) (email_routing.EmailCatchAllRule, error) +- client.EmailRouting.Rules.CatchAlls.Update(ctx context.Context, zoneIdentifier string, body email_routing.RuleCatchAllUpdateParams) (email_routing.RuleCatchAllUpdateResponse, error) +- client.EmailRouting.Rules.CatchAlls.Get(ctx context.Context, zoneIdentifier string) (email_routing.RuleCatchAllGetResponse, error) ## Addresses Response Types: -- email_routing.AddressNewResponse -- email_routing.AddressListResponse -- email_routing.AddressDeleteResponse -- email_routing.AddressGetResponse +- email_routing.Address Methods: -- client.EmailRouting.Addresses.New(ctx context.Context, accountIdentifier string, body email_routing.AddressNewParams) (email_routing.AddressNewResponse, error) -- client.EmailRouting.Addresses.List(ctx context.Context, accountIdentifier string, query email_routing.AddressListParams) (pagination.V4PagePaginationArray[email_routing.AddressListResponse], error) -- client.EmailRouting.Addresses.Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.AddressDeleteResponse, error) -- client.EmailRouting.Addresses.Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.AddressGetResponse, error) +- client.EmailRouting.Addresses.New(ctx context.Context, accountIdentifier string, body email_routing.AddressNewParams) (email_routing.Address, error) +- client.EmailRouting.Addresses.List(ctx context.Context, accountIdentifier string, query email_routing.AddressListParams) (pagination.V4PagePaginationArray[email_routing.Address], error) +- client.EmailRouting.Addresses.Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.Address, error) +- client.EmailRouting.Addresses.Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.Address, error) # Filters @@ -1769,76 +1679,94 @@ Methods: - client.Filters.New(ctx context.Context, zoneIdentifier string, body filters.FilterNewParams) ([]filters.FirewallFilter, error) - client.Filters.Update(ctx context.Context, zoneIdentifier string, id string, body filters.FilterUpdateParams) (filters.FirewallFilter, error) - client.Filters.List(ctx context.Context, zoneIdentifier string, query filters.FilterListParams) (pagination.V4PagePaginationArray[filters.FirewallFilter], error) -- client.Filters.Delete(ctx context.Context, zoneIdentifier string, id string) (filters.FirewallFilter, error) +- client.Filters.Delete(ctx context.Context, zoneIdentifier string, id string, body filters.FilterDeleteParams) (filters.FirewallFilter, error) - client.Filters.Get(ctx context.Context, zoneIdentifier string, id string) (filters.FirewallFilter, error) # Firewall ## Lockdowns +Params Types: + +- firewall.ConfigurationUnionParam + Response Types: -- firewall.FirewallZoneLockdown +- firewall.Configuration +- firewall.Lockdown +- firewall.LockdownCIDRConfiguration +- firewall.LockdownIPConfiguration +- firewall.LockdownURL - firewall.LockdownDeleteResponse Methods: -- client.Firewall.Lockdowns.New(ctx context.Context, zoneIdentifier string, body firewall.LockdownNewParams) (firewall.FirewallZoneLockdown, error) -- client.Firewall.Lockdowns.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.LockdownUpdateParams) (firewall.FirewallZoneLockdown, error) -- client.Firewall.Lockdowns.List(ctx context.Context, zoneIdentifier string, query firewall.LockdownListParams) (pagination.V4PagePaginationArray[firewall.FirewallZoneLockdown], error) -- client.Firewall.Lockdowns.Delete(ctx context.Context, zoneIdentifier string, id string) (firewall.LockdownDeleteResponse, error) -- client.Firewall.Lockdowns.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.FirewallZoneLockdown, error) +- client.Firewall.Lockdowns.New(ctx context.Context, zoneIdentifier string, body firewall.LockdownNewParams) (firewall.Lockdown, error) +- client.Firewall.Lockdowns.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.LockdownUpdateParams) (firewall.Lockdown, error) +- client.Firewall.Lockdowns.List(ctx context.Context, zoneIdentifier string, query firewall.LockdownListParams) (pagination.V4PagePaginationArray[firewall.Lockdown], error) +- client.Firewall.Lockdowns.Delete(ctx context.Context, zoneIdentifier string, id string, body firewall.LockdownDeleteParams) (firewall.LockdownDeleteResponse, error) +- client.Firewall.Lockdowns.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.Lockdown, error) ## Rules Response Types: -- firewall.FirewallFilterRule +- firewall.FirewallRule +- firewall.Products +- firewall.DeletedFilter Methods: -- client.Firewall.Rules.New(ctx context.Context, zoneIdentifier string, body firewall.RuleNewParams) ([]firewall.FirewallFilterRule, error) -- client.Firewall.Rules.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleUpdateParams) (firewall.FirewallFilterRule, error) -- client.Firewall.Rules.List(ctx context.Context, zoneIdentifier string, query firewall.RuleListParams) (pagination.V4PagePaginationArray[firewall.FirewallFilterRule], error) -- client.Firewall.Rules.Delete(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleDeleteParams) (firewall.FirewallFilterRule, error) -- client.Firewall.Rules.Edit(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleEditParams) ([]firewall.FirewallFilterRule, error) -- client.Firewall.Rules.Get(ctx context.Context, zoneIdentifier string, id string, query firewall.RuleGetParams) (firewall.FirewallFilterRule, error) +- client.Firewall.Rules.New(ctx context.Context, zoneIdentifier string, body firewall.RuleNewParams) ([]firewall.FirewallRule, error) +- client.Firewall.Rules.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleUpdateParams) (firewall.FirewallRule, error) +- client.Firewall.Rules.List(ctx context.Context, zoneIdentifier string, query firewall.RuleListParams) (pagination.V4PagePaginationArray[firewall.FirewallRule], error) +- client.Firewall.Rules.Delete(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleDeleteParams) (firewall.FirewallRule, error) +- client.Firewall.Rules.Edit(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleEditParams) ([]firewall.FirewallRule, error) +- client.Firewall.Rules.Get(ctx context.Context, zoneIdentifier string, params firewall.RuleGetParams) (firewall.FirewallRule, error) ## AccessRules +Params Types: + +- firewall.AccessRuleCIDRConfigurationParam +- firewall.AccessRuleIPConfigurationParam +- firewall.ASNConfigurationParam +- firewall.CountryConfigurationParam +- firewall.IPV6ConfigurationParam + Response Types: -- firewall.AccessRuleNewResponse +- firewall.AccessRuleNewResponseUnion - firewall.AccessRuleListResponse - firewall.AccessRuleDeleteResponse -- firewall.AccessRuleEditResponse -- firewall.AccessRuleGetResponse +- firewall.AccessRuleEditResponseUnion +- firewall.AccessRuleGetResponseUnion Methods: -- client.Firewall.AccessRules.New(ctx context.Context, params firewall.AccessRuleNewParams) (firewall.AccessRuleNewResponse, error) +- client.Firewall.AccessRules.New(ctx context.Context, params firewall.AccessRuleNewParams) (firewall.AccessRuleNewResponseUnion, error) - client.Firewall.AccessRules.List(ctx context.Context, params firewall.AccessRuleListParams) (pagination.V4PagePaginationArray[firewall.AccessRuleListResponse], error) -- client.Firewall.AccessRules.Delete(ctx context.Context, identifier interface{}, body firewall.AccessRuleDeleteParams) (firewall.AccessRuleDeleteResponse, error) -- client.Firewall.AccessRules.Edit(ctx context.Context, identifier interface{}, params firewall.AccessRuleEditParams) (firewall.AccessRuleEditResponse, error) -- client.Firewall.AccessRules.Get(ctx context.Context, identifier interface{}, query firewall.AccessRuleGetParams) (firewall.AccessRuleGetResponse, error) +- client.Firewall.AccessRules.Delete(ctx context.Context, identifier interface{}, params firewall.AccessRuleDeleteParams) (firewall.AccessRuleDeleteResponse, error) +- client.Firewall.AccessRules.Edit(ctx context.Context, identifier interface{}, params firewall.AccessRuleEditParams) (firewall.AccessRuleEditResponseUnion, error) +- client.Firewall.AccessRules.Get(ctx context.Context, identifier interface{}, query firewall.AccessRuleGetParams) (firewall.AccessRuleGetResponseUnion, error) ## UARules Response Types: -- firewall.UARuleNewResponse -- firewall.UARuleUpdateResponse +- firewall.UARuleNewResponseUnion +- firewall.UARuleUpdateResponseUnion - firewall.UARuleListResponse - firewall.UARuleDeleteResponse -- firewall.UARuleGetResponse +- firewall.UARuleGetResponseUnion Methods: -- client.Firewall.UARules.New(ctx context.Context, zoneIdentifier string, body firewall.UARuleNewParams) (firewall.UARuleNewResponse, error) -- client.Firewall.UARules.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.UARuleUpdateParams) (firewall.UARuleUpdateResponse, error) +- client.Firewall.UARules.New(ctx context.Context, zoneIdentifier string, body firewall.UARuleNewParams) (firewall.UARuleNewResponseUnion, error) +- client.Firewall.UARules.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.UARuleUpdateParams) (firewall.UARuleUpdateResponseUnion, error) - client.Firewall.UARules.List(ctx context.Context, zoneIdentifier string, query firewall.UARuleListParams) (pagination.V4PagePaginationArray[firewall.UARuleListResponse], error) -- client.Firewall.UARules.Delete(ctx context.Context, zoneIdentifier string, id string) (firewall.UARuleDeleteResponse, error) -- client.Firewall.UARules.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.UARuleGetResponse, error) +- client.Firewall.UARules.Delete(ctx context.Context, zoneIdentifier string, id string, body firewall.UARuleDeleteParams) (firewall.UARuleDeleteResponse, error) +- client.Firewall.UARules.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.UARuleGetResponseUnion, error) ## WAF @@ -1846,16 +1774,19 @@ Methods: Response Types: -- firewall.WAFOverride +- firewall.Override +- firewall.OverrideURL +- firewall.RewriteAction +- firewall.WAFRule - firewall.WAFOverrideDeleteResponse Methods: -- client.Firewall.WAF.Overrides.New(ctx context.Context, zoneIdentifier string, body firewall.WAFOverrideNewParams) (firewall.WAFOverride, error) -- client.Firewall.WAF.Overrides.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.WAFOverrideUpdateParams) (firewall.WAFOverride, error) -- client.Firewall.WAF.Overrides.List(ctx context.Context, zoneIdentifier string, query firewall.WAFOverrideListParams) (pagination.V4PagePaginationArray[firewall.WAFOverride], error) -- client.Firewall.WAF.Overrides.Delete(ctx context.Context, zoneIdentifier string, id string) (firewall.WAFOverrideDeleteResponse, error) -- client.Firewall.WAF.Overrides.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.WAFOverride, error) +- client.Firewall.WAF.Overrides.New(ctx context.Context, zoneIdentifier string, body firewall.WAFOverrideNewParams) (firewall.Override, error) +- client.Firewall.WAF.Overrides.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.WAFOverrideUpdateParams) (firewall.Override, error) +- client.Firewall.WAF.Overrides.List(ctx context.Context, zoneIdentifier string, query firewall.WAFOverrideListParams) (pagination.V4PagePaginationArray[firewall.Override], error) +- client.Firewall.WAF.Overrides.Delete(ctx context.Context, zoneIdentifier string, id string, body firewall.WAFOverrideDeleteParams) (firewall.WAFOverrideDeleteResponse, error) +- client.Firewall.WAF.Overrides.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.Override, error) ### Packages @@ -1873,35 +1804,47 @@ Methods: Response Types: -- firewall.WAFManagedRulesGroup -- firewall.WAFPackageGroupEditResponse -- firewall.WAFPackageGroupGetResponse +- firewall.Group +- firewall.WAFPackageGroupEditResponseUnion +- firewall.WAFPackageGroupGetResponseUnion Methods: -- client.Firewall.WAF.Packages.Groups.List(ctx context.Context, packageID string, params firewall.WAFPackageGroupListParams) (pagination.V4PagePaginationArray[firewall.WAFManagedRulesGroup], error) -- client.Firewall.WAF.Packages.Groups.Edit(ctx context.Context, packageID string, groupID string, params firewall.WAFPackageGroupEditParams) (firewall.WAFPackageGroupEditResponse, error) -- client.Firewall.WAF.Packages.Groups.Get(ctx context.Context, packageID string, groupID string, query firewall.WAFPackageGroupGetParams) (firewall.WAFPackageGroupGetResponse, error) +- client.Firewall.WAF.Packages.Groups.List(ctx context.Context, packageID string, params firewall.WAFPackageGroupListParams) (pagination.V4PagePaginationArray[firewall.Group], error) +- client.Firewall.WAF.Packages.Groups.Edit(ctx context.Context, packageID string, groupID string, params firewall.WAFPackageGroupEditParams) (firewall.WAFPackageGroupEditResponseUnion, error) +- client.Firewall.WAF.Packages.Groups.Get(ctx context.Context, packageID string, groupID string, query firewall.WAFPackageGroupGetParams) (firewall.WAFPackageGroupGetResponseUnion, error) #### Rules Response Types: -- firewall.WAFManagedRulesRule +- firewall.AllowedModesAnomaly +- firewall.WAFRuleGroup +- firewall.WAFPackageRuleListResponse - firewall.WAFPackageRuleEditResponse -- firewall.WAFPackageRuleGetResponse +- firewall.WAFPackageRuleGetResponseUnion Methods: -- client.Firewall.WAF.Packages.Rules.List(ctx context.Context, packageID string, params firewall.WAFPackageRuleListParams) (pagination.V4PagePaginationArray[firewall.WAFManagedRulesRule], error) +- client.Firewall.WAF.Packages.Rules.List(ctx context.Context, packageID string, params firewall.WAFPackageRuleListParams) (pagination.V4PagePaginationArray[firewall.WAFPackageRuleListResponse], error) - client.Firewall.WAF.Packages.Rules.Edit(ctx context.Context, packageID string, ruleID string, params firewall.WAFPackageRuleEditParams) (firewall.WAFPackageRuleEditResponse, error) -- client.Firewall.WAF.Packages.Rules.Get(ctx context.Context, packageID string, ruleID string, query firewall.WAFPackageRuleGetParams) (firewall.WAFPackageRuleGetResponse, error) +- client.Firewall.WAF.Packages.Rules.Get(ctx context.Context, packageID string, ruleID string, query firewall.WAFPackageRuleGetParams) (firewall.WAFPackageRuleGetResponseUnion, error) # Healthchecks +Params Types: + +- healthchecks.CheckRegion +- healthchecks.HTTPConfigurationParam +- healthchecks.QueryHealthcheckParam +- healthchecks.TCPConfigurationParam + Response Types: +- healthchecks.CheckRegion - healthchecks.Healthcheck +- healthchecks.HTTPConfiguration +- healthchecks.TCPConfiguration - healthchecks.HealthcheckDeleteResponse Methods: @@ -1909,7 +1852,7 @@ Methods: - client.Healthchecks.New(ctx context.Context, params healthchecks.HealthcheckNewParams) (healthchecks.Healthcheck, error) - client.Healthchecks.Update(ctx context.Context, healthcheckID string, params healthchecks.HealthcheckUpdateParams) (healthchecks.Healthcheck, error) - client.Healthchecks.List(ctx context.Context, query healthchecks.HealthcheckListParams) (pagination.SinglePage[healthchecks.Healthcheck], error) -- client.Healthchecks.Delete(ctx context.Context, healthcheckID string, body healthchecks.HealthcheckDeleteParams) (healthchecks.HealthcheckDeleteResponse, error) +- client.Healthchecks.Delete(ctx context.Context, healthcheckID string, params healthchecks.HealthcheckDeleteParams) (healthchecks.HealthcheckDeleteResponse, error) - client.Healthchecks.Edit(ctx context.Context, healthcheckID string, params healthchecks.HealthcheckEditParams) (healthchecks.Healthcheck, error) - client.Healthchecks.Get(ctx context.Context, healthcheckID string, query healthchecks.HealthcheckGetParams) (healthchecks.Healthcheck, error) @@ -1922,23 +1865,28 @@ Response Types: Methods: - client.Healthchecks.Previews.New(ctx context.Context, params healthchecks.PreviewNewParams) (healthchecks.Healthcheck, error) -- client.Healthchecks.Previews.Delete(ctx context.Context, healthcheckID string, body healthchecks.PreviewDeleteParams) (healthchecks.PreviewDeleteResponse, error) +- client.Healthchecks.Previews.Delete(ctx context.Context, healthcheckID string, params healthchecks.PreviewDeleteParams) (healthchecks.PreviewDeleteResponse, error) - client.Healthchecks.Previews.Get(ctx context.Context, healthcheckID string, query healthchecks.PreviewGetParams) (healthchecks.Healthcheck, error) # KeylessCertificates +Params Types: + +- keyless_certificates.TunnelParam + Response Types: -- keyless_certificates.KeylessCertificateHostname +- keyless_certificates.KeylessCertificate +- keyless_certificates.Tunnel - keyless_certificates.KeylessCertificateDeleteResponse Methods: -- client.KeylessCertificates.New(ctx context.Context, params keyless_certificates.KeylessCertificateNewParams) (keyless_certificates.KeylessCertificateHostname, error) -- client.KeylessCertificates.List(ctx context.Context, query keyless_certificates.KeylessCertificateListParams) (pagination.SinglePage[keyless_certificates.KeylessCertificateHostname], error) -- client.KeylessCertificates.Delete(ctx context.Context, keylessCertificateID string, body keyless_certificates.KeylessCertificateDeleteParams) (keyless_certificates.KeylessCertificateDeleteResponse, error) -- client.KeylessCertificates.Edit(ctx context.Context, keylessCertificateID string, params keyless_certificates.KeylessCertificateEditParams) (keyless_certificates.KeylessCertificateHostname, error) -- client.KeylessCertificates.Get(ctx context.Context, keylessCertificateID string, query keyless_certificates.KeylessCertificateGetParams) (keyless_certificates.KeylessCertificateHostname, error) +- client.KeylessCertificates.New(ctx context.Context, params keyless_certificates.KeylessCertificateNewParams) (keyless_certificates.KeylessCertificate, error) +- client.KeylessCertificates.List(ctx context.Context, query keyless_certificates.KeylessCertificateListParams) (pagination.SinglePage[keyless_certificates.KeylessCertificate], error) +- client.KeylessCertificates.Delete(ctx context.Context, keylessCertificateID string, params keyless_certificates.KeylessCertificateDeleteParams) (keyless_certificates.KeylessCertificateDeleteResponse, error) +- client.KeylessCertificates.Edit(ctx context.Context, keylessCertificateID string, params keyless_certificates.KeylessCertificateEditParams) (keyless_certificates.KeylessCertificate, error) +- client.KeylessCertificates.Get(ctx context.Context, keylessCertificateID string, query keyless_certificates.KeylessCertificateGetParams) (keyless_certificates.KeylessCertificate, error) # Logpush @@ -1956,10 +1904,6 @@ Methods: ### Jobs -Response Types: - -- logpush.LogpushJob - Methods: - client.Logpush.Datasets.Jobs.Get(ctx context.Context, datasetID string, query logpush.DatasetJobGetParams) ([]logpush.LogpushJob, error) @@ -1977,29 +1921,35 @@ Methods: ## Jobs +Params Types: + +- logpush.OutputOptionsParam + Response Types: -- logpush.JobDeleteResponse +- logpush.LogpushJob +- logpush.OutputOptions +- logpush.JobDeleteResponseUnion Methods: - client.Logpush.Jobs.New(ctx context.Context, params logpush.JobNewParams) (logpush.LogpushJob, error) - client.Logpush.Jobs.Update(ctx context.Context, jobID int64, params logpush.JobUpdateParams) (logpush.LogpushJob, error) - client.Logpush.Jobs.List(ctx context.Context, query logpush.JobListParams) (pagination.SinglePage[logpush.LogpushJob], error) -- client.Logpush.Jobs.Delete(ctx context.Context, jobID int64, body logpush.JobDeleteParams) (logpush.JobDeleteResponse, error) +- client.Logpush.Jobs.Delete(ctx context.Context, jobID int64, params logpush.JobDeleteParams) (logpush.JobDeleteResponseUnion, error) - client.Logpush.Jobs.Get(ctx context.Context, jobID int64, query logpush.JobGetParams) (logpush.LogpushJob, error) ## Ownership Response Types: +- logpush.OwnershipValidation - logpush.OwnershipNewResponse -- logpush.OwnershipValidateResponse Methods: - client.Logpush.Ownership.New(ctx context.Context, params logpush.OwnershipNewParams) (logpush.OwnershipNewResponse, error) -- client.Logpush.Ownership.Validate(ctx context.Context, params logpush.OwnershipValidateParams) (logpush.OwnershipValidateResponse, error) +- client.Logpush.Ownership.Validate(ctx context.Context, params logpush.OwnershipValidateParams) (logpush.OwnershipValidation, error) ## Validate @@ -2035,36 +1985,40 @@ Methods: #### Config +Params Types: + +- logs.CmbConfigParam + Response Types: - logs.CmbConfig -- logs.ControlCmbConfigDeleteResponse +- logs.ControlCmbConfigDeleteResponseUnion Methods: - client.Logs.Control.Cmb.Config.New(ctx context.Context, params logs.ControlCmbConfigNewParams) (logs.CmbConfig, error) -- client.Logs.Control.Cmb.Config.Delete(ctx context.Context, body logs.ControlCmbConfigDeleteParams) (logs.ControlCmbConfigDeleteResponse, error) +- client.Logs.Control.Cmb.Config.Delete(ctx context.Context, params logs.ControlCmbConfigDeleteParams) (logs.ControlCmbConfigDeleteResponseUnion, error) - client.Logs.Control.Cmb.Config.Get(ctx context.Context, query logs.ControlCmbConfigGetParams) (logs.CmbConfig, error) ## RayID Response Types: -- logs.RayIDGetResponse +- logs.RayIDGetResponseUnion Methods: -- client.Logs.RayID.Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query logs.RayIDGetParams) (logs.RayIDGetResponse, error) +- client.Logs.RayID.Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query logs.RayIDGetParams) (logs.RayIDGetResponseUnion, error) ## Received Response Types: -- logs.ReceivedGetResponse +- logs.ReceivedGetResponseUnion Methods: -- client.Logs.Received.Get(ctx context.Context, zoneIdentifier string, query logs.ReceivedGetParams) (logs.ReceivedGetResponse, error) +- client.Logs.Received.Get(ctx context.Context, zoneIdentifier string, query logs.ReceivedGetParams) (logs.ReceivedGetResponseUnion, error) ### Fields @@ -2080,41 +2034,44 @@ Methods: Response Types: -- origin_tls_client_auth.OriginTLSClientAuthNewResponse -- origin_tls_client_auth.OriginTLSClientAuthListResponse -- origin_tls_client_auth.OriginTLSClientAuthDeleteResponse -- origin_tls_client_auth.OriginTLSClientAuthGetResponse +- origin_tls_client_auth.ZoneAuthenticatedOriginPull +- origin_tls_client_auth.OriginTLSClientAuthNewResponseUnion +- origin_tls_client_auth.OriginTLSClientAuthDeleteResponseUnion +- origin_tls_client_auth.OriginTLSClientAuthGetResponseUnion Methods: -- client.OriginTLSClientAuth.New(ctx context.Context, params origin_tls_client_auth.OriginTLSClientAuthNewParams) (origin_tls_client_auth.OriginTLSClientAuthNewResponse, error) -- client.OriginTLSClientAuth.List(ctx context.Context, query origin_tls_client_auth.OriginTLSClientAuthListParams) (pagination.SinglePage[origin_tls_client_auth.OriginTLSClientAuthListResponse], error) -- client.OriginTLSClientAuth.Delete(ctx context.Context, certificateID string, body origin_tls_client_auth.OriginTLSClientAuthDeleteParams) (origin_tls_client_auth.OriginTLSClientAuthDeleteResponse, error) -- client.OriginTLSClientAuth.Get(ctx context.Context, certificateID string, query origin_tls_client_auth.OriginTLSClientAuthGetParams) (origin_tls_client_auth.OriginTLSClientAuthGetResponse, error) +- client.OriginTLSClientAuth.New(ctx context.Context, params origin_tls_client_auth.OriginTLSClientAuthNewParams) (origin_tls_client_auth.OriginTLSClientAuthNewResponseUnion, error) +- client.OriginTLSClientAuth.List(ctx context.Context, query origin_tls_client_auth.OriginTLSClientAuthListParams) (pagination.SinglePage[origin_tls_client_auth.ZoneAuthenticatedOriginPull], error) +- client.OriginTLSClientAuth.Delete(ctx context.Context, certificateID string, params origin_tls_client_auth.OriginTLSClientAuthDeleteParams) (origin_tls_client_auth.OriginTLSClientAuthDeleteResponseUnion, error) +- client.OriginTLSClientAuth.Get(ctx context.Context, certificateID string, query origin_tls_client_auth.OriginTLSClientAuthGetParams) (origin_tls_client_auth.OriginTLSClientAuthGetResponseUnion, error) ## Hostnames Response Types: -- origin_tls_client_auth.OriginTLSClientCertificateID +- origin_tls_client_auth.AuthenticatedOriginPull Methods: -- client.OriginTLSClientAuth.Hostnames.Update(ctx context.Context, params origin_tls_client_auth.HostnameUpdateParams) ([]origin_tls_client_auth.OriginTLSClientCertificateID, error) -- client.OriginTLSClientAuth.Hostnames.Get(ctx context.Context, hostname string, query origin_tls_client_auth.HostnameGetParams) (origin_tls_client_auth.OriginTLSClientCertificateID, error) +- client.OriginTLSClientAuth.Hostnames.Update(ctx context.Context, params origin_tls_client_auth.HostnameUpdateParams) ([]origin_tls_client_auth.AuthenticatedOriginPull, error) +- client.OriginTLSClientAuth.Hostnames.Get(ctx context.Context, hostname string, query origin_tls_client_auth.HostnameGetParams) (origin_tls_client_auth.AuthenticatedOriginPull, error) ### Certificates Response Types: -- origin_tls_client_auth.OriginTLSClientCertificate +- origin_tls_client_auth.Certificate +- origin_tls_client_auth.HostnameCertificateNewResponse +- origin_tls_client_auth.HostnameCertificateDeleteResponse +- origin_tls_client_auth.HostnameCertificateGetResponse Methods: -- client.OriginTLSClientAuth.Hostnames.Certificates.New(ctx context.Context, params origin_tls_client_auth.HostnameCertificateNewParams) (origin_tls_client_auth.OriginTLSClientCertificate, error) -- client.OriginTLSClientAuth.Hostnames.Certificates.List(ctx context.Context, query origin_tls_client_auth.HostnameCertificateListParams) (pagination.SinglePage[origin_tls_client_auth.OriginTLSClientCertificateID], error) -- client.OriginTLSClientAuth.Hostnames.Certificates.Delete(ctx context.Context, certificateID string, body origin_tls_client_auth.HostnameCertificateDeleteParams) (origin_tls_client_auth.OriginTLSClientCertificate, error) -- client.OriginTLSClientAuth.Hostnames.Certificates.Get(ctx context.Context, certificateID string, query origin_tls_client_auth.HostnameCertificateGetParams) (origin_tls_client_auth.OriginTLSClientCertificate, error) +- client.OriginTLSClientAuth.Hostnames.Certificates.New(ctx context.Context, params origin_tls_client_auth.HostnameCertificateNewParams) (origin_tls_client_auth.HostnameCertificateNewResponse, error) +- client.OriginTLSClientAuth.Hostnames.Certificates.List(ctx context.Context, query origin_tls_client_auth.HostnameCertificateListParams) (pagination.SinglePage[origin_tls_client_auth.AuthenticatedOriginPull], error) +- client.OriginTLSClientAuth.Hostnames.Certificates.Delete(ctx context.Context, certificateID string, params origin_tls_client_auth.HostnameCertificateDeleteParams) (origin_tls_client_auth.HostnameCertificateDeleteResponse, error) +- client.OriginTLSClientAuth.Hostnames.Certificates.Get(ctx context.Context, certificateID string, query origin_tls_client_auth.HostnameCertificateGetParams) (origin_tls_client_auth.HostnameCertificateGetResponse, error) ## Settings @@ -2130,52 +2087,64 @@ Methods: # Pagerules +Params Types: + +- pagerules.RouteParam +- pagerules.TargetParam + Response Types: -- pagerules.ZonesPagerule -- pagerules.PageruleNewResponse -- pagerules.PageruleUpdateResponse +- pagerules.PageRule +- pagerules.Route +- pagerules.Target +- pagerules.PageruleNewResponseUnion +- pagerules.PageruleUpdateResponseUnion - pagerules.PageruleDeleteResponse -- pagerules.PageruleEditResponse -- pagerules.PageruleGetResponse +- pagerules.PageruleEditResponseUnion +- pagerules.PageruleGetResponseUnion Methods: -- client.Pagerules.New(ctx context.Context, params pagerules.PageruleNewParams) (pagerules.PageruleNewResponse, error) -- client.Pagerules.Update(ctx context.Context, pageruleID string, params pagerules.PageruleUpdateParams) (pagerules.PageruleUpdateResponse, error) -- client.Pagerules.List(ctx context.Context, params pagerules.PageruleListParams) ([]pagerules.ZonesPagerule, error) -- client.Pagerules.Delete(ctx context.Context, pageruleID string, body pagerules.PageruleDeleteParams) (pagerules.PageruleDeleteResponse, error) -- client.Pagerules.Edit(ctx context.Context, pageruleID string, params pagerules.PageruleEditParams) (pagerules.PageruleEditResponse, error) -- client.Pagerules.Get(ctx context.Context, pageruleID string, query pagerules.PageruleGetParams) (pagerules.PageruleGetResponse, error) +- client.Pagerules.New(ctx context.Context, params pagerules.PageruleNewParams) (pagerules.PageruleNewResponseUnion, error) +- client.Pagerules.Update(ctx context.Context, pageruleID string, params pagerules.PageruleUpdateParams) (pagerules.PageruleUpdateResponseUnion, error) +- client.Pagerules.List(ctx context.Context, params pagerules.PageruleListParams) ([]pagerules.PageRule, error) +- client.Pagerules.Delete(ctx context.Context, pageruleID string, params pagerules.PageruleDeleteParams) (pagerules.PageruleDeleteResponse, error) +- client.Pagerules.Edit(ctx context.Context, pageruleID string, params pagerules.PageruleEditParams) (pagerules.PageruleEditResponseUnion, error) +- client.Pagerules.Get(ctx context.Context, pageruleID string, query pagerules.PageruleGetParams) (pagerules.PageruleGetResponseUnion, error) ## Settings Response Types: -- pagerules.ZonePageruleSettings - pagerules.SettingListResponse Methods: -- client.Pagerules.Settings.List(ctx context.Context, query pagerules.SettingListParams) (pagerules.ZonePageruleSettings, error) +- client.Pagerules.Settings.List(ctx context.Context, query pagerules.SettingListParams) ([]pagerules.SettingListResponse, error) # RateLimits +Params Types: + +- rate_limits.Action + Response Types: -- rate_limits.RateLimitNewResponse -- rate_limits.RateLimitListResponse +- rate_limits.Action +- rate_limits.Methods +- rate_limits.RateLimit +- rate_limits.RateLimitNewResponseUnion - rate_limits.RateLimitDeleteResponse -- rate_limits.RateLimitEditResponse -- rate_limits.RateLimitGetResponse +- rate_limits.RateLimitEditResponseUnion +- rate_limits.RateLimitGetResponseUnion Methods: -- client.RateLimits.New(ctx context.Context, zoneIdentifier string, body rate_limits.RateLimitNewParams) (rate_limits.RateLimitNewResponse, error) -- client.RateLimits.List(ctx context.Context, zoneIdentifier string, query rate_limits.RateLimitListParams) (pagination.V4PagePaginationArray[rate_limits.RateLimitListResponse], error) -- client.RateLimits.Delete(ctx context.Context, zoneIdentifier string, id string) (rate_limits.RateLimitDeleteResponse, error) -- client.RateLimits.Edit(ctx context.Context, zoneIdentifier string, id string, body rate_limits.RateLimitEditParams) (rate_limits.RateLimitEditResponse, error) -- client.RateLimits.Get(ctx context.Context, zoneIdentifier string, id string) (rate_limits.RateLimitGetResponse, error) +- client.RateLimits.New(ctx context.Context, zoneIdentifier string, body rate_limits.RateLimitNewParams) (rate_limits.RateLimitNewResponseUnion, error) +- client.RateLimits.List(ctx context.Context, zoneIdentifier string, query rate_limits.RateLimitListParams) (pagination.V4PagePaginationArray[rate_limits.RateLimit], error) +- client.RateLimits.Delete(ctx context.Context, zoneIdentifier string, id string, body rate_limits.RateLimitDeleteParams) (rate_limits.RateLimitDeleteResponse, error) +- client.RateLimits.Edit(ctx context.Context, zoneIdentifier string, id string, body rate_limits.RateLimitEditParams) (rate_limits.RateLimitEditResponseUnion, error) +- client.RateLimits.Get(ctx context.Context, zoneIdentifier string, id string) (rate_limits.RateLimitGetResponseUnion, error) # SecondaryDNS @@ -2183,11 +2152,11 @@ Methods: Response Types: -- secondary_dns.SecondaryDNSForce +- secondary_dns.ForceAXFR Methods: -- client.SecondaryDNS.ForceAXFR.New(ctx context.Context, body secondary_dns.ForceAXFRNewParams) (secondary_dns.SecondaryDNSForce, error) +- client.SecondaryDNS.ForceAXFR.New(ctx context.Context, params secondary_dns.ForceAXFRNewParams) (secondary_dns.ForceAXFR, error) ## Incoming @@ -2202,15 +2171,15 @@ Methods: - client.SecondaryDNS.Incoming.New(ctx context.Context, params secondary_dns.IncomingNewParams) (secondary_dns.IncomingNewResponse, error) - client.SecondaryDNS.Incoming.Update(ctx context.Context, params secondary_dns.IncomingUpdateParams) (secondary_dns.IncomingUpdateResponse, error) -- client.SecondaryDNS.Incoming.Delete(ctx context.Context, body secondary_dns.IncomingDeleteParams) (secondary_dns.IncomingDeleteResponse, error) +- client.SecondaryDNS.Incoming.Delete(ctx context.Context, params secondary_dns.IncomingDeleteParams) (secondary_dns.IncomingDeleteResponse, error) - client.SecondaryDNS.Incoming.Get(ctx context.Context, query secondary_dns.IncomingGetParams) (secondary_dns.IncomingGetResponse, error) ## Outgoing Response Types: -- secondary_dns.SecondaryDNSDisableTransfer -- secondary_dns.SecondaryDNSEnableTransfer +- secondary_dns.DisableTransfer +- secondary_dns.EnableTransfer - secondary_dns.OutgoingNewResponse - secondary_dns.OutgoingUpdateResponse - secondary_dns.OutgoingDeleteResponse @@ -2220,78 +2189,98 @@ Methods: - client.SecondaryDNS.Outgoing.New(ctx context.Context, params secondary_dns.OutgoingNewParams) (secondary_dns.OutgoingNewResponse, error) - client.SecondaryDNS.Outgoing.Update(ctx context.Context, params secondary_dns.OutgoingUpdateParams) (secondary_dns.OutgoingUpdateResponse, error) -- client.SecondaryDNS.Outgoing.Delete(ctx context.Context, body secondary_dns.OutgoingDeleteParams) (secondary_dns.OutgoingDeleteResponse, error) -- client.SecondaryDNS.Outgoing.Disable(ctx context.Context, body secondary_dns.OutgoingDisableParams) (secondary_dns.SecondaryDNSDisableTransfer, error) -- client.SecondaryDNS.Outgoing.Enable(ctx context.Context, body secondary_dns.OutgoingEnableParams) (secondary_dns.SecondaryDNSEnableTransfer, error) -- client.SecondaryDNS.Outgoing.ForceNotify(ctx context.Context, body secondary_dns.OutgoingForceNotifyParams) (string, error) +- client.SecondaryDNS.Outgoing.Delete(ctx context.Context, params secondary_dns.OutgoingDeleteParams) (secondary_dns.OutgoingDeleteResponse, error) +- client.SecondaryDNS.Outgoing.Disable(ctx context.Context, params secondary_dns.OutgoingDisableParams) (secondary_dns.DisableTransfer, error) +- client.SecondaryDNS.Outgoing.Enable(ctx context.Context, params secondary_dns.OutgoingEnableParams) (secondary_dns.EnableTransfer, error) +- client.SecondaryDNS.Outgoing.ForceNotify(ctx context.Context, params secondary_dns.OutgoingForceNotifyParams) (string, error) - client.SecondaryDNS.Outgoing.Get(ctx context.Context, query secondary_dns.OutgoingGetParams) (secondary_dns.OutgoingGetResponse, error) ### Status Methods: -- client.SecondaryDNS.Outgoing.Status.Get(ctx context.Context, query secondary_dns.OutgoingStatusGetParams) (secondary_dns.SecondaryDNSEnableTransfer, error) +- client.SecondaryDNS.Outgoing.Status.Get(ctx context.Context, query secondary_dns.OutgoingStatusGetParams) (secondary_dns.EnableTransfer, error) ## ACLs +Params Types: + +- secondary_dns.ACLParam + Response Types: -- secondary_dns.SecondaryDNSACL +- secondary_dns.ACL - secondary_dns.ACLDeleteResponse Methods: -- client.SecondaryDNS.ACLs.New(ctx context.Context, params secondary_dns.ACLNewParams) (secondary_dns.SecondaryDNSACL, error) -- client.SecondaryDNS.ACLs.Update(ctx context.Context, aclID string, params secondary_dns.ACLUpdateParams) (secondary_dns.SecondaryDNSACL, error) -- client.SecondaryDNS.ACLs.List(ctx context.Context, query secondary_dns.ACLListParams) (pagination.SinglePage[secondary_dns.SecondaryDNSACL], error) -- client.SecondaryDNS.ACLs.Delete(ctx context.Context, aclID string, body secondary_dns.ACLDeleteParams) (secondary_dns.ACLDeleteResponse, error) -- client.SecondaryDNS.ACLs.Get(ctx context.Context, aclID string, query secondary_dns.ACLGetParams) (secondary_dns.SecondaryDNSACL, error) +- client.SecondaryDNS.ACLs.New(ctx context.Context, params secondary_dns.ACLNewParams) (secondary_dns.ACL, error) +- client.SecondaryDNS.ACLs.Update(ctx context.Context, aclID string, params secondary_dns.ACLUpdateParams) (secondary_dns.ACL, error) +- client.SecondaryDNS.ACLs.List(ctx context.Context, query secondary_dns.ACLListParams) (pagination.SinglePage[secondary_dns.ACL], error) +- client.SecondaryDNS.ACLs.Delete(ctx context.Context, aclID string, params secondary_dns.ACLDeleteParams) (secondary_dns.ACLDeleteResponse, error) +- client.SecondaryDNS.ACLs.Get(ctx context.Context, aclID string, query secondary_dns.ACLGetParams) (secondary_dns.ACL, error) ## Peers +Params Types: + +- secondary_dns.PeerParam + Response Types: -- secondary_dns.SecondaryDNSPeer +- secondary_dns.Peer - secondary_dns.PeerDeleteResponse Methods: -- client.SecondaryDNS.Peers.New(ctx context.Context, params secondary_dns.PeerNewParams) (secondary_dns.SecondaryDNSPeer, error) -- client.SecondaryDNS.Peers.Update(ctx context.Context, peerID string, params secondary_dns.PeerUpdateParams) (secondary_dns.SecondaryDNSPeer, error) -- client.SecondaryDNS.Peers.List(ctx context.Context, query secondary_dns.PeerListParams) (pagination.SinglePage[secondary_dns.SecondaryDNSPeer], error) -- client.SecondaryDNS.Peers.Delete(ctx context.Context, peerID string, body secondary_dns.PeerDeleteParams) (secondary_dns.PeerDeleteResponse, error) -- client.SecondaryDNS.Peers.Get(ctx context.Context, peerID string, query secondary_dns.PeerGetParams) (secondary_dns.SecondaryDNSPeer, error) +- client.SecondaryDNS.Peers.New(ctx context.Context, params secondary_dns.PeerNewParams) (secondary_dns.Peer, error) +- client.SecondaryDNS.Peers.Update(ctx context.Context, peerID string, params secondary_dns.PeerUpdateParams) (secondary_dns.Peer, error) +- client.SecondaryDNS.Peers.List(ctx context.Context, query secondary_dns.PeerListParams) (pagination.SinglePage[secondary_dns.Peer], error) +- client.SecondaryDNS.Peers.Delete(ctx context.Context, peerID string, params secondary_dns.PeerDeleteParams) (secondary_dns.PeerDeleteResponse, error) +- client.SecondaryDNS.Peers.Get(ctx context.Context, peerID string, query secondary_dns.PeerGetParams) (secondary_dns.Peer, error) ## TSIGs +Params Types: + +- secondary_dns.TSIGParam + Response Types: -- secondary_dns.SecondaryDNSTSIG +- secondary_dns.TSIG - secondary_dns.TSIGDeleteResponse Methods: -- client.SecondaryDNS.TSIGs.New(ctx context.Context, params secondary_dns.TSIGNewParams) (secondary_dns.SecondaryDNSTSIG, error) -- client.SecondaryDNS.TSIGs.Update(ctx context.Context, tsigID string, params secondary_dns.TSIGUpdateParams) (secondary_dns.SecondaryDNSTSIG, error) -- client.SecondaryDNS.TSIGs.List(ctx context.Context, query secondary_dns.TSIGListParams) (pagination.SinglePage[secondary_dns.SecondaryDNSTSIG], error) -- client.SecondaryDNS.TSIGs.Delete(ctx context.Context, tsigID string, body secondary_dns.TSIGDeleteParams) (secondary_dns.TSIGDeleteResponse, error) -- client.SecondaryDNS.TSIGs.Get(ctx context.Context, tsigID string, query secondary_dns.TSIGGetParams) (secondary_dns.SecondaryDNSTSIG, error) +- client.SecondaryDNS.TSIGs.New(ctx context.Context, params secondary_dns.TSIGNewParams) (secondary_dns.TSIG, error) +- client.SecondaryDNS.TSIGs.Update(ctx context.Context, tsigID string, params secondary_dns.TSIGUpdateParams) (secondary_dns.TSIG, error) +- client.SecondaryDNS.TSIGs.List(ctx context.Context, query secondary_dns.TSIGListParams) (pagination.SinglePage[secondary_dns.TSIG], error) +- client.SecondaryDNS.TSIGs.Delete(ctx context.Context, tsigID string, params secondary_dns.TSIGDeleteParams) (secondary_dns.TSIGDeleteResponse, error) +- client.SecondaryDNS.TSIGs.Get(ctx context.Context, tsigID string, query secondary_dns.TSIGGetParams) (secondary_dns.TSIG, error) # WaitingRooms +Params Types: + +- waiting_rooms.AdditionalRoutesParam +- waiting_rooms.CookieAttributesParam +- waiting_rooms.QueryParam + Response Types: +- waiting_rooms.AdditionalRoutes +- waiting_rooms.CookieAttributes - waiting_rooms.WaitingRoom - waiting_rooms.WaitingRoomDeleteResponse Methods: -- client.WaitingRooms.New(ctx context.Context, zoneIdentifier string, body waiting_rooms.WaitingRoomNewParams) (waiting_rooms.WaitingRoom, error) -- client.WaitingRooms.Update(ctx context.Context, zoneIdentifier string, waitingRoomID string, body waiting_rooms.WaitingRoomUpdateParams) (waiting_rooms.WaitingRoom, error) -- client.WaitingRooms.List(ctx context.Context, zoneIdentifier string) (pagination.SinglePage[waiting_rooms.WaitingRoom], error) -- client.WaitingRooms.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID string) (waiting_rooms.WaitingRoomDeleteResponse, error) -- client.WaitingRooms.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID string, body waiting_rooms.WaitingRoomEditParams) (waiting_rooms.WaitingRoom, error) -- client.WaitingRooms.Get(ctx context.Context, zoneIdentifier string, waitingRoomID string) (waiting_rooms.WaitingRoom, error) +- client.WaitingRooms.New(ctx context.Context, params waiting_rooms.WaitingRoomNewParams) (waiting_rooms.WaitingRoom, error) +- client.WaitingRooms.Update(ctx context.Context, waitingRoomID string, params waiting_rooms.WaitingRoomUpdateParams) (waiting_rooms.WaitingRoom, error) +- client.WaitingRooms.List(ctx context.Context, params waiting_rooms.WaitingRoomListParams) (pagination.SinglePage[waiting_rooms.WaitingRoom], error) +- client.WaitingRooms.Delete(ctx context.Context, waitingRoomID string, params waiting_rooms.WaitingRoomDeleteParams) (waiting_rooms.WaitingRoomDeleteResponse, error) +- client.WaitingRooms.Edit(ctx context.Context, waitingRoomID string, params waiting_rooms.WaitingRoomEditParams) (waiting_rooms.WaitingRoom, error) +- client.WaitingRooms.Get(ctx context.Context, waitingRoomID string, query waiting_rooms.WaitingRoomGetParams) (waiting_rooms.WaitingRoom, error) ## Page @@ -2301,47 +2290,51 @@ Response Types: Methods: -- client.WaitingRooms.Page.Preview(ctx context.Context, zoneIdentifier string, body waiting_rooms.PagePreviewParams) (waiting_rooms.PagePreviewResponse, error) +- client.WaitingRooms.Page.Preview(ctx context.Context, params waiting_rooms.PagePreviewParams) (waiting_rooms.PagePreviewResponse, error) ## Events Response Types: -- waiting_rooms.WaitingroomEvent +- waiting_rooms.Event - waiting_rooms.EventDeleteResponse Methods: -- client.WaitingRooms.Events.New(ctx context.Context, zoneIdentifier string, waitingRoomID string, body waiting_rooms.EventNewParams) (waiting_rooms.WaitingroomEvent, error) -- client.WaitingRooms.Events.Update(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string, body waiting_rooms.EventUpdateParams) (waiting_rooms.WaitingroomEvent, error) -- client.WaitingRooms.Events.List(ctx context.Context, zoneIdentifier string, waitingRoomID string) (pagination.SinglePage[waiting_rooms.WaitingroomEvent], error) -- client.WaitingRooms.Events.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string) (waiting_rooms.EventDeleteResponse, error) -- client.WaitingRooms.Events.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string, body waiting_rooms.EventEditParams) (waiting_rooms.WaitingroomEvent, error) -- client.WaitingRooms.Events.Get(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string) (waiting_rooms.WaitingroomEvent, error) +- client.WaitingRooms.Events.New(ctx context.Context, waitingRoomID string, params waiting_rooms.EventNewParams) (waiting_rooms.Event, error) +- client.WaitingRooms.Events.Update(ctx context.Context, waitingRoomID string, eventID string, params waiting_rooms.EventUpdateParams) (waiting_rooms.Event, error) +- client.WaitingRooms.Events.List(ctx context.Context, waitingRoomID string, params waiting_rooms.EventListParams) (pagination.SinglePage[waiting_rooms.Event], error) +- client.WaitingRooms.Events.Delete(ctx context.Context, waitingRoomID string, eventID string, params waiting_rooms.EventDeleteParams) (waiting_rooms.EventDeleteResponse, error) +- client.WaitingRooms.Events.Edit(ctx context.Context, waitingRoomID string, eventID string, params waiting_rooms.EventEditParams) (waiting_rooms.Event, error) +- client.WaitingRooms.Events.Get(ctx context.Context, waitingRoomID string, eventID string, query waiting_rooms.EventGetParams) (waiting_rooms.Event, error) ### Details +Params Types: + +- waiting_rooms.EventQueryParam + Response Types: -- waiting_rooms.WaitingroomEventDetails +- waiting_rooms.EventDetailGetResponse Methods: -- client.WaitingRooms.Events.Details.Get(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string) (waiting_rooms.WaitingroomEventDetails, error) +- client.WaitingRooms.Events.Details.Get(ctx context.Context, waitingRoomID string, eventID string, query waiting_rooms.EventDetailGetParams) (waiting_rooms.EventDetailGetResponse, error) ## Rules Response Types: -- waiting_rooms.WaitingroomRule +- waiting_rooms.WaitingRoomRule Methods: -- client.WaitingRooms.Rules.New(ctx context.Context, zoneIdentifier string, waitingRoomID string, body waiting_rooms.RuleNewParams) ([]waiting_rooms.WaitingroomRule, error) -- client.WaitingRooms.Rules.Update(ctx context.Context, zoneIdentifier string, waitingRoomID string, body waiting_rooms.RuleUpdateParams) ([]waiting_rooms.WaitingroomRule, error) -- client.WaitingRooms.Rules.List(ctx context.Context, zoneIdentifier string, waitingRoomID string) (pagination.SinglePage[waiting_rooms.WaitingroomRule], error) -- client.WaitingRooms.Rules.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID string, ruleID string) ([]waiting_rooms.WaitingroomRule, error) -- client.WaitingRooms.Rules.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID string, ruleID string, body waiting_rooms.RuleEditParams) ([]waiting_rooms.WaitingroomRule, error) +- client.WaitingRooms.Rules.New(ctx context.Context, waitingRoomID string, params waiting_rooms.RuleNewParams) ([]waiting_rooms.WaitingRoomRule, error) +- client.WaitingRooms.Rules.Update(ctx context.Context, waitingRoomID string, params waiting_rooms.RuleUpdateParams) ([]waiting_rooms.WaitingRoomRule, error) +- client.WaitingRooms.Rules.List(ctx context.Context, waitingRoomID string, query waiting_rooms.RuleListParams) (pagination.SinglePage[waiting_rooms.WaitingRoomRule], error) +- client.WaitingRooms.Rules.Delete(ctx context.Context, waitingRoomID string, ruleID string, params waiting_rooms.RuleDeleteParams) ([]waiting_rooms.WaitingRoomRule, error) +- client.WaitingRooms.Rules.Edit(ctx context.Context, waitingRoomID string, ruleID string, params waiting_rooms.RuleEditParams) ([]waiting_rooms.WaitingRoomRule, error) ## Statuses @@ -2351,38 +2344,43 @@ Response Types: Methods: -- client.WaitingRooms.Statuses.Get(ctx context.Context, zoneIdentifier string, waitingRoomID string) (waiting_rooms.StatusGetResponse, error) +- client.WaitingRooms.Statuses.Get(ctx context.Context, waitingRoomID string, query waiting_rooms.StatusGetParams) (waiting_rooms.StatusGetResponse, error) ## Settings Response Types: +- waiting_rooms.Setting - waiting_rooms.SettingUpdateResponse - waiting_rooms.SettingEditResponse - waiting_rooms.SettingGetResponse Methods: -- client.WaitingRooms.Settings.Update(ctx context.Context, zoneIdentifier string, body waiting_rooms.SettingUpdateParams) (waiting_rooms.SettingUpdateResponse, error) -- client.WaitingRooms.Settings.Edit(ctx context.Context, zoneIdentifier string, body waiting_rooms.SettingEditParams) (waiting_rooms.SettingEditResponse, error) -- client.WaitingRooms.Settings.Get(ctx context.Context, zoneIdentifier string) (waiting_rooms.SettingGetResponse, error) +- client.WaitingRooms.Settings.Update(ctx context.Context, params waiting_rooms.SettingUpdateParams) (waiting_rooms.SettingUpdateResponse, error) +- client.WaitingRooms.Settings.Edit(ctx context.Context, params waiting_rooms.SettingEditParams) (waiting_rooms.SettingEditResponse, error) +- client.WaitingRooms.Settings.Get(ctx context.Context, query waiting_rooms.SettingGetParams) (waiting_rooms.SettingGetResponse, error) # Web3 ## Hostnames +Params Types: + +- web3.HostnameParam + Response Types: -- web3.DistributedWebHostname +- web3.Hostname - web3.HostnameDeleteResponse Methods: -- client.Web3.Hostnames.New(ctx context.Context, zoneIdentifier string, body web3.HostnameNewParams) (web3.DistributedWebHostname, error) -- client.Web3.Hostnames.List(ctx context.Context, zoneIdentifier string) (pagination.SinglePage[web3.DistributedWebHostname], error) -- client.Web3.Hostnames.Delete(ctx context.Context, zoneIdentifier string, identifier string) (web3.HostnameDeleteResponse, error) -- client.Web3.Hostnames.Edit(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameEditParams) (web3.DistributedWebHostname, error) -- client.Web3.Hostnames.Get(ctx context.Context, zoneIdentifier string, identifier string) (web3.DistributedWebHostname, error) +- client.Web3.Hostnames.New(ctx context.Context, zoneIdentifier string, body web3.HostnameNewParams) (web3.Hostname, error) +- client.Web3.Hostnames.List(ctx context.Context, zoneIdentifier string) (pagination.SinglePage[web3.Hostname], error) +- client.Web3.Hostnames.Delete(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameDeleteParams) (web3.HostnameDeleteResponse, error) +- client.Web3.Hostnames.Edit(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameEditParams) (web3.Hostname, error) +- client.Web3.Hostnames.Get(ctx context.Context, zoneIdentifier string, identifier string) (web3.Hostname, error) ### IPFSUniversalPaths @@ -2390,72 +2388,101 @@ Methods: Response Types: -- web3.DistributedWebConfigContentList +- web3.ContentList Methods: -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Update(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListUpdateParams) (web3.DistributedWebConfigContentList, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Get(ctx context.Context, zoneIdentifier string, identifier string) (web3.DistributedWebConfigContentList, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Update(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListUpdateParams) (web3.ContentList, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Get(ctx context.Context, zoneIdentifier string, identifier string) (web3.ContentList, error) ##### Entries -Params Types: - -- web3.DistributedWebConfigContentListEntryParam - Response Types: -- web3.DistributedWebConfigContentListEntry +- web3.HostnameIPFSUniversalPathContentListEntryNewResponse +- web3.HostnameIPFSUniversalPathContentListEntryUpdateResponse - web3.HostnameIPFSUniversalPathContentListEntryListResponse - web3.HostnameIPFSUniversalPathContentListEntryDeleteResponse +- web3.HostnameIPFSUniversalPathContentListEntryGetResponse Methods: -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListEntryNewParams) (web3.DistributedWebConfigContentListEntry, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body web3.HostnameIPFSUniversalPathContentListEntryUpdateParams) (web3.DistributedWebConfigContentListEntry, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListEntryNewParams) (web3.HostnameIPFSUniversalPathContentListEntryNewResponse, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body web3.HostnameIPFSUniversalPathContentListEntryUpdateParams) (web3.HostnameIPFSUniversalPathContentListEntryUpdateResponse, 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) (web3.HostnameIPFSUniversalPathContentListEntryDeleteResponse, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string) (web3.DistributedWebConfigContentListEntry, 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.HostnameIPFSUniversalPathContentListEntryGetResponse, error) # Workers +Params Types: + +- workers.BindingUnionParam +- workers.D1BindingParam +- workers.DispatchNamespaceBindingParam +- workers.DurableObjectBindingParam +- workers.KVNamespaceBindingParam +- workers.MigrationStepParam +- workers.MTLSCERTBindingParam +- workers.PlacementConfigurationParam +- workers.R2BindingParam +- workers.ServiceBindingParam +- workers.SingleStepMigrationParam +- workers.SteppedMigrationParam +- workers.WorkerMetadataParam + +Response Types: + +- workers.Binding +- workers.D1Binding +- workers.DispatchNamespaceBinding +- workers.DurableObjectBinding +- workers.KVNamespaceBinding +- workers.MigrationStep +- workers.MTLSCERTBinding +- workers.PlacementConfiguration +- workers.R2Binding +- workers.ServiceBinding +- workers.SingleStepMigration +- workers.SteppedMigration + ## AI Response Types: -- workers.AIRunResponse +- workers.AIRunResponseUnion Methods: -- client.Workers.AI.Run(ctx context.Context, modelName string, params workers.AIRunParams) (workers.AIRunResponse, error) +- client.Workers.AI.Run(ctx context.Context, modelName string, params workers.AIRunParams) (workers.AIRunResponseUnion, error) ## Scripts +Params Types: + +- workers.ScriptSettingParam + Response Types: -- workers.WorkersScript +- workers.Script +- workers.ScriptSetting Methods: -- client.Workers.Scripts.Update(ctx context.Context, scriptName string, params workers.ScriptUpdateParams) (workers.WorkersScript, error) -- client.Workers.Scripts.List(ctx context.Context, query workers.ScriptListParams) (pagination.SinglePage[workers.WorkersScript], error) +- client.Workers.Scripts.Update(ctx context.Context, scriptName string, params workers.ScriptUpdateParams) (workers.Script, error) +- client.Workers.Scripts.List(ctx context.Context, query workers.ScriptListParams) (pagination.SinglePage[workers.Script], error) - client.Workers.Scripts.Delete(ctx context.Context, scriptName string, params workers.ScriptDeleteParams) error - client.Workers.Scripts.Get(ctx context.Context, scriptName string, query workers.ScriptGetParams) (http.Response, error) -### Bindings - -Response Types: - -- workers.WorkersBinding - -Methods: +### Schedules -- client.Workers.Scripts.Bindings.Get(ctx context.Context, query workers.ScriptBindingGetParams) ([]workers.WorkersBinding, error) +Params Types: -### Schedules +- workers.ScheduleParam Response Types: +- workers.Schedule - workers.ScriptScheduleUpdateResponse - workers.ScriptScheduleGetResponse @@ -2466,84 +2493,67 @@ Methods: ### Tail +Params Types: + +- workers.ConsumerScriptParam + Response Types: +- workers.ConsumerScript - workers.ScriptTailNewResponse -- workers.ScriptTailDeleteResponse +- workers.ScriptTailDeleteResponseUnion - workers.ScriptTailGetResponse Methods: -- client.Workers.Scripts.Tail.New(ctx context.Context, scriptName string, body workers.ScriptTailNewParams) (workers.ScriptTailNewResponse, error) -- client.Workers.Scripts.Tail.Delete(ctx context.Context, scriptName string, id string, body workers.ScriptTailDeleteParams) (workers.ScriptTailDeleteResponse, error) +- client.Workers.Scripts.Tail.New(ctx context.Context, scriptName string, params workers.ScriptTailNewParams) (workers.ScriptTailNewResponse, error) +- client.Workers.Scripts.Tail.Delete(ctx context.Context, scriptName string, id string, params workers.ScriptTailDeleteParams) (workers.ScriptTailDeleteResponseUnion, error) - client.Workers.Scripts.Tail.Get(ctx context.Context, scriptName string, query workers.ScriptTailGetParams) (workers.ScriptTailGetResponse, error) -### UsageModel - -Response Types: - -- workers.ScriptUsageModelUpdateResponse -- workers.ScriptUsageModelGetResponse - -Methods: - -- client.Workers.Scripts.UsageModel.Update(ctx context.Context, scriptName string, params workers.ScriptUsageModelUpdateParams) (workers.ScriptUsageModelUpdateResponse, error) -- client.Workers.Scripts.UsageModel.Get(ctx context.Context, scriptName string, query workers.ScriptUsageModelGetParams) (workers.ScriptUsageModelGetResponse, error) - ### Content Methods: -- client.Workers.Scripts.Content.Update(ctx context.Context, scriptName string, params workers.ScriptContentUpdateParams) (workers.WorkersScript, error) - -### ContentV2 - -Methods: - -- client.Workers.Scripts.ContentV2.Get(ctx context.Context, scriptName string, query workers.ScriptContentV2GetParams) (http.Response, error) +- client.Workers.Scripts.Content.Update(ctx context.Context, scriptName string, params workers.ScriptContentUpdateParams) (workers.Script, error) +- client.Workers.Scripts.Content.Get(ctx context.Context, scriptName string, query workers.ScriptContentGetParams) (http.Response, error) ### Settings -Response Types: +Methods: -- workers.ScriptSettingEditResponse -- workers.ScriptSettingGetResponse +- client.Workers.Scripts.Settings.Edit(ctx context.Context, scriptName string, params workers.ScriptSettingEditParams) (workers.ScriptSetting, error) +- client.Workers.Scripts.Settings.Get(ctx context.Context, scriptName string, query workers.ScriptSettingGetParams) (workers.ScriptSetting, error) -Methods: +### Deployments -- client.Workers.Scripts.Settings.Edit(ctx context.Context, scriptName string, params workers.ScriptSettingEditParams) (workers.ScriptSettingEditResponse, error) -- client.Workers.Scripts.Settings.Get(ctx context.Context, scriptName string, query workers.ScriptSettingGetParams) (workers.ScriptSettingGetResponse, error) +Params Types: -## Filters +- workers.DeploymentParam Response Types: -- workers.WorkersFilter -- workers.FilterNewResponse -- workers.FilterDeleteResponse +- workers.Deployment +- workers.ScriptDeploymentNewResponse +- workers.ScriptDeploymentGetResponse Methods: -- client.Workers.Filters.New(ctx context.Context, params workers.FilterNewParams) (workers.FilterNewResponse, error) -- client.Workers.Filters.Update(ctx context.Context, filterID string, params workers.FilterUpdateParams) (workers.WorkersFilter, error) -- client.Workers.Filters.List(ctx context.Context, query workers.FilterListParams) (pagination.SinglePage[workers.WorkersFilter], error) -- client.Workers.Filters.Delete(ctx context.Context, filterID string, body workers.FilterDeleteParams) (workers.FilterDeleteResponse, error) +- client.Workers.Scripts.Deployments.New(ctx context.Context, scriptName string, params workers.ScriptDeploymentNewParams) (workers.ScriptDeploymentNewResponse, error) +- client.Workers.Scripts.Deployments.Get(ctx context.Context, scriptName string, query workers.ScriptDeploymentGetParams) (workers.ScriptDeploymentGetResponse, error) -## Routes +### Versions Response Types: -- workers.WorkersRoute -- workers.RouteNewResponse -- workers.RouteDeleteResponse +- workers.ScriptVersionNewResponse +- workers.ScriptVersionListResponse +- workers.ScriptVersionGetResponse Methods: -- client.Workers.Routes.New(ctx context.Context, params workers.RouteNewParams) (workers.RouteNewResponse, error) -- client.Workers.Routes.Update(ctx context.Context, routeID string, params workers.RouteUpdateParams) (workers.WorkersRoute, error) -- client.Workers.Routes.List(ctx context.Context, query workers.RouteListParams) (pagination.SinglePage[workers.WorkersRoute], error) -- client.Workers.Routes.Delete(ctx context.Context, routeID string, body workers.RouteDeleteParams) (workers.RouteDeleteResponse, error) -- client.Workers.Routes.Get(ctx context.Context, routeID string, query workers.RouteGetParams) (workers.WorkersRoute, error) +- client.Workers.Scripts.Versions.New(ctx context.Context, scriptName string, params workers.ScriptVersionNewParams) (workers.ScriptVersionNewResponse, error) +- client.Workers.Scripts.Versions.List(ctx context.Context, scriptName string, query workers.ScriptVersionListParams) (workers.ScriptVersionListResponse, error) +- client.Workers.Scripts.Versions.Get(ctx context.Context, scriptName string, versionID string, query workers.ScriptVersionGetParams) (workers.ScriptVersionGetResponse, error) ## AccountSettings @@ -2557,40 +2567,18 @@ Methods: - client.Workers.AccountSettings.Update(ctx context.Context, params workers.AccountSettingUpdateParams) (workers.AccountSettingUpdateResponse, error) - client.Workers.AccountSettings.Get(ctx context.Context, query workers.AccountSettingGetParams) (workers.AccountSettingGetResponse, error) -## Deployments - -### ByScripts - -Response Types: - -- workers.DeploymentByScriptGetResponse - -Methods: - -- client.Workers.Deployments.ByScripts.Get(ctx context.Context, scriptID string, query workers.DeploymentByScriptGetParams) (workers.DeploymentByScriptGetResponse, error) - -#### Details - -Response Types: - -- workers.DeploymentByScriptDetailGetResponse - -Methods: - -- client.Workers.Deployments.ByScripts.Details.Get(ctx context.Context, scriptID string, deploymentID string, query workers.DeploymentByScriptDetailGetParams) (workers.DeploymentByScriptDetailGetResponse, error) - ## Domains Response Types: -- workers.WorkersDomain +- workers.Domain Methods: -- client.Workers.Domains.Update(ctx context.Context, params workers.DomainUpdateParams) (workers.WorkersDomain, error) -- client.Workers.Domains.List(ctx context.Context, params workers.DomainListParams) (pagination.SinglePage[workers.WorkersDomain], error) -- client.Workers.Domains.Delete(ctx context.Context, domainID string, body workers.DomainDeleteParams) error -- client.Workers.Domains.Get(ctx context.Context, domainID string, query workers.DomainGetParams) (workers.WorkersDomain, error) +- client.Workers.Domains.Update(ctx context.Context, params workers.DomainUpdateParams) (workers.Domain, error) +- client.Workers.Domains.List(ctx context.Context, params workers.DomainListParams) (pagination.SinglePage[workers.Domain], error) +- client.Workers.Domains.Delete(ctx context.Context, domainID string, params workers.DomainDeleteParams) error +- client.Workers.Domains.Get(ctx context.Context, domainID string, query workers.DomainGetParams) (workers.Domain, error) ## Subdomains @@ -2604,67 +2592,44 @@ Methods: - client.Workers.Subdomains.Update(ctx context.Context, params workers.SubdomainUpdateParams) (workers.SubdomainUpdateResponse, error) - client.Workers.Subdomains.Get(ctx context.Context, query workers.SubdomainGetParams) (workers.SubdomainGetResponse, error) -## Services - -### Environments - -#### Content - -Methods: - -- client.Workers.Services.Environments.Content.Update(ctx context.Context, serviceName string, environmentName string, params workers.ServiceEnvironmentContentUpdateParams) (workers.WorkersScript, error) -- client.Workers.Services.Environments.Content.Get(ctx context.Context, serviceName string, environmentName string, query workers.ServiceEnvironmentContentGetParams) (http.Response, error) - -#### Settings - -Response Types: - -- workers.ServiceEnvironmentSettingEditResponse -- workers.ServiceEnvironmentSettingGetResponse - -Methods: - -- client.Workers.Services.Environments.Settings.Edit(ctx context.Context, serviceName string, environmentName string, params workers.ServiceEnvironmentSettingEditParams) (workers.ServiceEnvironmentSettingEditResponse, error) -- client.Workers.Services.Environments.Settings.Get(ctx context.Context, serviceName string, environmentName string, query workers.ServiceEnvironmentSettingGetParams) (workers.ServiceEnvironmentSettingGetResponse, error) - # KV ## Namespaces Response Types: -- kv.WorkersKVNamespace -- kv.NamespaceUpdateResponse -- kv.NamespaceDeleteResponse +- kv.Namespace +- kv.NamespaceUpdateResponseUnion +- kv.NamespaceDeleteResponseUnion Methods: -- client.KV.Namespaces.New(ctx context.Context, params kv.NamespaceNewParams) (kv.WorkersKVNamespace, error) -- client.KV.Namespaces.Update(ctx context.Context, namespaceID string, params kv.NamespaceUpdateParams) (kv.NamespaceUpdateResponse, error) -- client.KV.Namespaces.List(ctx context.Context, params kv.NamespaceListParams) (pagination.V4PagePaginationArray[kv.WorkersKVNamespace], error) -- client.KV.Namespaces.Delete(ctx context.Context, namespaceID string, body kv.NamespaceDeleteParams) (kv.NamespaceDeleteResponse, error) +- client.KV.Namespaces.New(ctx context.Context, params kv.NamespaceNewParams) (kv.Namespace, error) +- client.KV.Namespaces.Update(ctx context.Context, namespaceID string, params kv.NamespaceUpdateParams) (kv.NamespaceUpdateResponseUnion, error) +- client.KV.Namespaces.List(ctx context.Context, params kv.NamespaceListParams) (pagination.V4PagePaginationArray[kv.Namespace], error) +- client.KV.Namespaces.Delete(ctx context.Context, namespaceID string, params kv.NamespaceDeleteParams) (kv.NamespaceDeleteResponseUnion, error) ### Bulk Response Types: -- kv.NamespaceBulkUpdateResponse -- kv.NamespaceBulkDeleteResponse +- kv.NamespaceBulkUpdateResponseUnion +- kv.NamespaceBulkDeleteResponseUnion Methods: -- client.KV.Namespaces.Bulk.Update(ctx context.Context, namespaceID string, params kv.NamespaceBulkUpdateParams) (kv.NamespaceBulkUpdateResponse, error) -- client.KV.Namespaces.Bulk.Delete(ctx context.Context, namespaceID string, params kv.NamespaceBulkDeleteParams) (kv.NamespaceBulkDeleteResponse, error) +- client.KV.Namespaces.Bulk.Update(ctx context.Context, namespaceID string, params kv.NamespaceBulkUpdateParams) (kv.NamespaceBulkUpdateResponseUnion, error) +- client.KV.Namespaces.Bulk.Delete(ctx context.Context, namespaceID string, params kv.NamespaceBulkDeleteParams) (kv.NamespaceBulkDeleteResponseUnion, error) ### Keys Response Types: -- kv.WorkersKVKey +- kv.Key Methods: -- client.KV.Namespaces.Keys.List(ctx context.Context, namespaceID string, params kv.NamespaceKeyListParams) (pagination.CursorLimitPagination[kv.WorkersKVKey], error) +- client.KV.Namespaces.Keys.List(ctx context.Context, namespaceID string, params kv.NamespaceKeyListParams) (pagination.CursorLimitPagination[kv.Key], error) ### Metadata @@ -2680,13 +2645,13 @@ Methods: Response Types: -- kv.NamespaceValueUpdateResponse -- kv.NamespaceValueDeleteResponse +- kv.NamespaceValueUpdateResponseUnion +- kv.NamespaceValueDeleteResponseUnion Methods: -- client.KV.Namespaces.Values.Update(ctx context.Context, namespaceID string, keyName string, params kv.NamespaceValueUpdateParams) (kv.NamespaceValueUpdateResponse, error) -- client.KV.Namespaces.Values.Delete(ctx context.Context, namespaceID string, keyName string, body kv.NamespaceValueDeleteParams) (kv.NamespaceValueDeleteResponse, error) +- client.KV.Namespaces.Values.Update(ctx context.Context, namespaceID string, keyName string, params kv.NamespaceValueUpdateParams) (kv.NamespaceValueUpdateResponseUnion, error) +- client.KV.Namespaces.Values.Delete(ctx context.Context, namespaceID string, keyName string, params kv.NamespaceValueDeleteParams) (kv.NamespaceValueDeleteResponseUnion, error) - client.KV.Namespaces.Values.Get(ctx context.Context, namespaceID string, keyName string, query kv.NamespaceValueGetParams) (string, error) # DurableObjects @@ -2695,11 +2660,11 @@ Methods: Response Types: -- durable_objects.DurableObjectNamespace +- durable_objects.Namespace Methods: -- client.DurableObjects.Namespaces.List(ctx context.Context, query durable_objects.NamespaceListParams) (pagination.SinglePage[durable_objects.DurableObjectNamespace], error) +- client.DurableObjects.Namespaces.List(ctx context.Context, query durable_objects.NamespaceListParams) (pagination.SinglePage[durable_objects.Namespace], error) ### Objects @@ -2715,35 +2680,34 @@ Methods: Response Types: -- queues.QueueNewResponse -- queues.QueueUpdateResponse -- queues.QueueListResponse -- queues.QueueDeleteResponse -- queues.QueueGetResponse +- queues.Queue +- queues.QueueCreated +- queues.QueueUpdated +- queues.QueueDeleteResponseUnion Methods: -- client.Queues.New(ctx context.Context, params queues.QueueNewParams) (queues.QueueNewResponse, error) -- client.Queues.Update(ctx context.Context, queueID string, params queues.QueueUpdateParams) (queues.QueueUpdateResponse, error) -- client.Queues.List(ctx context.Context, query queues.QueueListParams) (pagination.SinglePage[queues.QueueListResponse], error) -- client.Queues.Delete(ctx context.Context, queueID string, body queues.QueueDeleteParams) (queues.QueueDeleteResponse, error) -- client.Queues.Get(ctx context.Context, queueID string, query queues.QueueGetParams) (queues.QueueGetResponse, error) +- client.Queues.New(ctx context.Context, params queues.QueueNewParams) (queues.QueueCreated, error) +- client.Queues.Update(ctx context.Context, queueID string, params queues.QueueUpdateParams) (queues.QueueUpdated, error) +- client.Queues.List(ctx context.Context, query queues.QueueListParams) (pagination.SinglePage[queues.Queue], error) +- client.Queues.Delete(ctx context.Context, queueID string, params queues.QueueDeleteParams) (queues.QueueDeleteResponseUnion, error) +- client.Queues.Get(ctx context.Context, queueID string, query queues.QueueGetParams) (queues.Queue, error) ## Consumers Response Types: +- queues.Consumer - queues.ConsumerNewResponse - queues.ConsumerUpdateResponse -- queues.ConsumerDeleteResponse -- queues.ConsumerGetResponse +- queues.ConsumerDeleteResponseUnion Methods: - client.Queues.Consumers.New(ctx context.Context, queueID string, params queues.ConsumerNewParams) (queues.ConsumerNewResponse, error) - client.Queues.Consumers.Update(ctx context.Context, queueID string, consumerID string, params queues.ConsumerUpdateParams) (queues.ConsumerUpdateResponse, error) -- client.Queues.Consumers.Delete(ctx context.Context, queueID string, consumerID string, body queues.ConsumerDeleteParams) (queues.ConsumerDeleteResponse, error) -- client.Queues.Consumers.Get(ctx context.Context, queueID string, query queues.ConsumerGetParams) ([]queues.ConsumerGetResponse, error) +- client.Queues.Consumers.Delete(ctx context.Context, queueID string, consumerID string, params queues.ConsumerDeleteParams) (queues.ConsumerDeleteResponseUnion, error) +- client.Queues.Consumers.Get(ctx context.Context, queueID string, query queues.ConsumerGetParams) ([]queues.Consumer, error) ## Messages @@ -2759,8 +2723,13 @@ Methods: # ManagedHeaders +Params Types: + +- managed_headers.RequestModelParam + Response Types: +- managed_headers.RequestModel - managed_headers.ManagedHeaderListResponse - managed_headers.ManagedHeaderEditResponse @@ -2773,49 +2742,53 @@ Methods: Response Types: -- page_shield.PageShieldSetting +- page_shield.Setting - page_shield.PageShieldUpdateResponse Methods: - client.PageShield.Update(ctx context.Context, params page_shield.PageShieldUpdateParams) (page_shield.PageShieldUpdateResponse, error) -- client.PageShield.Get(ctx context.Context, query page_shield.PageShieldGetParams) (page_shield.PageShieldSetting, error) +- client.PageShield.Get(ctx context.Context, query page_shield.PageShieldGetParams) (page_shield.Setting, error) ## Policies +Params Types: + +- page_shield.PolicyParam + Response Types: -- page_shield.PageShieldPolicy +- page_shield.Policy Methods: -- client.PageShield.Policies.New(ctx context.Context, params page_shield.PolicyNewParams) (page_shield.PageShieldPolicy, error) -- client.PageShield.Policies.Update(ctx context.Context, policyID string, params page_shield.PolicyUpdateParams) (page_shield.PageShieldPolicy, error) -- client.PageShield.Policies.List(ctx context.Context, query page_shield.PolicyListParams) (pagination.SinglePage[page_shield.PageShieldPolicy], error) +- client.PageShield.Policies.New(ctx context.Context, params page_shield.PolicyNewParams) (page_shield.Policy, error) +- client.PageShield.Policies.Update(ctx context.Context, policyID string, params page_shield.PolicyUpdateParams) (page_shield.Policy, error) +- client.PageShield.Policies.List(ctx context.Context, query page_shield.PolicyListParams) (pagination.SinglePage[page_shield.Policy], error) - client.PageShield.Policies.Delete(ctx context.Context, policyID string, body page_shield.PolicyDeleteParams) error -- client.PageShield.Policies.Get(ctx context.Context, policyID string, query page_shield.PolicyGetParams) (page_shield.PageShieldPolicy, error) +- client.PageShield.Policies.Get(ctx context.Context, policyID string, query page_shield.PolicyGetParams) (page_shield.Policy, error) ## Connections Response Types: -- page_shield.PageShieldConnection +- page_shield.Connection Methods: -- client.PageShield.Connections.List(ctx context.Context, params page_shield.ConnectionListParams) (pagination.SinglePage[page_shield.PageShieldConnection], error) -- client.PageShield.Connections.Get(ctx context.Context, connectionID string, query page_shield.ConnectionGetParams) (page_shield.PageShieldConnection, error) +- client.PageShield.Connections.List(ctx context.Context, params page_shield.ConnectionListParams) (pagination.SinglePage[page_shield.Connection], error) +- client.PageShield.Connections.Get(ctx context.Context, connectionID string, query page_shield.ConnectionGetParams) (page_shield.Connection, error) ## Scripts Response Types: -- page_shield.PageShieldScript +- page_shield.Script - page_shield.ScriptGetResponse Methods: -- client.PageShield.Scripts.List(ctx context.Context, params page_shield.ScriptListParams) (pagination.SinglePage[page_shield.PageShieldScript], error) +- client.PageShield.Scripts.List(ctx context.Context, params page_shield.ScriptListParams) (pagination.SinglePage[page_shield.Script], error) - client.PageShield.Scripts.Get(ctx context.Context, scriptID string, query page_shield.ScriptGetParams) (page_shield.ScriptGetResponse, error) # Rulesets @@ -2823,59 +2796,113 @@ Methods: Response Types: - rulesets.Ruleset -- rulesets.RulesetListResponse +- rulesets.RulesetNewResponse +- rulesets.RulesetUpdateResponse +- rulesets.RulesetGetResponse Methods: -- client.Rulesets.New(ctx context.Context, params rulesets.RulesetNewParams) (rulesets.Ruleset, error) -- client.Rulesets.Update(ctx context.Context, rulesetID string, params rulesets.RulesetUpdateParams) (rulesets.Ruleset, error) -- client.Rulesets.List(ctx context.Context, query rulesets.RulesetListParams) (pagination.SinglePage[rulesets.RulesetListResponse], error) +- client.Rulesets.New(ctx context.Context, params rulesets.RulesetNewParams) (rulesets.RulesetNewResponse, error) +- client.Rulesets.Update(ctx context.Context, rulesetID string, params rulesets.RulesetUpdateParams) (rulesets.RulesetUpdateResponse, error) +- client.Rulesets.List(ctx context.Context, query rulesets.RulesetListParams) (pagination.SinglePage[rulesets.Ruleset], error) - client.Rulesets.Delete(ctx context.Context, rulesetID string, body rulesets.RulesetDeleteParams) error -- client.Rulesets.Get(ctx context.Context, rulesetID string, query rulesets.RulesetGetParams) (rulesets.Ruleset, error) +- client.Rulesets.Get(ctx context.Context, rulesetID string, query rulesets.RulesetGetParams) (rulesets.RulesetGetResponse, error) ## Phases +Response Types: + +- rulesets.PhaseUpdateResponse +- rulesets.PhaseGetResponse + Methods: -- client.Rulesets.Phases.Update(ctx context.Context, rulesetPhase rulesets.PhaseUpdateParamsRulesetPhase, params rulesets.PhaseUpdateParams) (rulesets.Ruleset, error) -- client.Rulesets.Phases.Get(ctx context.Context, rulesetPhase rulesets.PhaseGetParamsRulesetPhase, query rulesets.PhaseGetParams) (rulesets.Ruleset, error) +- client.Rulesets.Phases.Update(ctx context.Context, rulesetPhase rulesets.PhaseUpdateParamsRulesetPhase, params rulesets.PhaseUpdateParams) (rulesets.PhaseUpdateResponse, error) +- client.Rulesets.Phases.Get(ctx context.Context, rulesetPhase rulesets.PhaseGetParamsRulesetPhase, query rulesets.PhaseGetParams) (rulesets.PhaseGetResponse, error) ### Versions Response Types: -- rulesets.PhaseVersionListResponse +- rulesets.PhaseVersionGetResponse Methods: -- client.Rulesets.Phases.Versions.List(ctx context.Context, rulesetPhase rulesets.PhaseVersionListParamsRulesetPhase, query rulesets.PhaseVersionListParams) (pagination.SinglePage[rulesets.PhaseVersionListResponse], error) -- client.Rulesets.Phases.Versions.Get(ctx context.Context, rulesetPhase rulesets.PhaseVersionGetParamsRulesetPhase, rulesetVersion string, query rulesets.PhaseVersionGetParams) (rulesets.Ruleset, error) +- client.Rulesets.Phases.Versions.List(ctx context.Context, rulesetPhase rulesets.PhaseVersionListParamsRulesetPhase, query rulesets.PhaseVersionListParams) (pagination.SinglePage[rulesets.Ruleset], error) +- client.Rulesets.Phases.Versions.Get(ctx context.Context, rulesetPhase rulesets.PhaseVersionGetParamsRulesetPhase, rulesetVersion string, query rulesets.PhaseVersionGetParams) (rulesets.PhaseVersionGetResponse, error) ## Rules -Methods: +Params Types: -- client.Rulesets.Rules.New(ctx context.Context, rulesetID string, params rulesets.RuleNewParams) (rulesets.Ruleset, error) -- client.Rulesets.Rules.Delete(ctx context.Context, rulesetID string, ruleID string, body rulesets.RuleDeleteParams) (rulesets.Ruleset, error) -- client.Rulesets.Rules.Edit(ctx context.Context, rulesetID string, ruleID string, params rulesets.RuleEditParams) (rulesets.Ruleset, error) +- rulesets.BlockRuleParam +- rulesets.ChallengeRuleParam +- rulesets.CompressResponseRuleParam +- rulesets.ExecuteRuleParam +- rulesets.JSChallengeRuleParam +- rulesets.LogRuleParam +- rulesets.LoggingParam +- rulesets.ManagedChallengeRuleParam +- rulesets.RedirectRuleParam +- rulesets.RewriteRuleParam +- rulesets.RewriteURIPartUnionParam +- rulesets.RouteRuleParam +- rulesets.ScoreRuleParam +- rulesets.ServeErrorRuleParam +- rulesets.SetCacheSettingsRuleParam +- rulesets.SetConfigRuleParam +- rulesets.SkipRuleParam + +Response Types: + +- rulesets.BlockRule +- rulesets.ChallengeRule +- rulesets.CompressResponseRule +- rulesets.ExecuteRule +- rulesets.JSChallengeRule +- rulesets.LogRule +- rulesets.Logging +- rulesets.ManagedChallengeRule +- rulesets.RedirectRule +- rulesets.RewriteRule +- rulesets.RewriteURIPart +- rulesets.RouteRule +- rulesets.ScoreRule +- rulesets.ServeErrorRule +- rulesets.SetCacheSettingsRule +- rulesets.SetConfigRule +- rulesets.SkipRule +- rulesets.RuleNewResponse +- rulesets.RuleDeleteResponse +- rulesets.RuleEditResponse + +Methods: + +- client.Rulesets.Rules.New(ctx context.Context, rulesetID string, params rulesets.RuleNewParams) (rulesets.RuleNewResponse, error) +- client.Rulesets.Rules.Delete(ctx context.Context, rulesetID string, ruleID string, body rulesets.RuleDeleteParams) (rulesets.RuleDeleteResponse, error) +- client.Rulesets.Rules.Edit(ctx context.Context, rulesetID string, ruleID string, params rulesets.RuleEditParams) (rulesets.RuleEditResponse, error) ## Versions Response Types: -- rulesets.VersionListResponse +- rulesets.VersionGetResponse Methods: -- client.Rulesets.Versions.List(ctx context.Context, rulesetID string, query rulesets.VersionListParams) (pagination.SinglePage[rulesets.VersionListResponse], error) +- client.Rulesets.Versions.List(ctx context.Context, rulesetID string, query rulesets.VersionListParams) (pagination.SinglePage[rulesets.Ruleset], error) - client.Rulesets.Versions.Delete(ctx context.Context, rulesetID string, rulesetVersion string, body rulesets.VersionDeleteParams) error -- client.Rulesets.Versions.Get(ctx context.Context, rulesetID string, rulesetVersion string, query rulesets.VersionGetParams) (rulesets.Ruleset, error) +- client.Rulesets.Versions.Get(ctx context.Context, rulesetID string, rulesetVersion string, query rulesets.VersionGetParams) (rulesets.VersionGetResponse, error) ### ByTag +Response Types: + +- rulesets.VersionByTagGetResponse + Methods: -- client.Rulesets.Versions.ByTag.Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query rulesets.VersionByTagGetParams) (rulesets.Ruleset, error) +- client.Rulesets.Versions.ByTag.Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query rulesets.VersionByTagGetParams) (rulesets.VersionByTagGetResponse, error) # URLNormalization @@ -2891,6 +2918,20 @@ Methods: # Spectrum +Params Types: + +- spectrum.DNSParam +- spectrum.EdgeIPsUnionParam +- spectrum.OriginDNSParam +- spectrum.OriginPortUnionParam + +Response Types: + +- spectrum.DNS +- spectrum.EdgeIPs +- spectrum.OriginDNS +- spectrum.OriginPortUnion + ## Analytics ### Aggregates @@ -2907,25 +2948,29 @@ Methods: ### Events +Params Types: + +- spectrum.Dimension + #### Bytimes Response Types: -- spectrum.AnalyticsEventBytimeGetResponse +- spectrum.AnalyticsEventBytimeGetResponseUnion Methods: -- client.Spectrum.Analytics.Events.Bytimes.Get(ctx context.Context, zone string, query spectrum.AnalyticsEventBytimeGetParams) (spectrum.AnalyticsEventBytimeGetResponse, error) +- client.Spectrum.Analytics.Events.Bytimes.Get(ctx context.Context, zone string, query spectrum.AnalyticsEventBytimeGetParams) (spectrum.AnalyticsEventBytimeGetResponseUnion, error) #### Summaries Response Types: -- spectrum.AnalyticsEventSummaryGetResponse +- spectrum.AnalyticsEventSummaryGetResponseUnion Methods: -- client.Spectrum.Analytics.Events.Summaries.Get(ctx context.Context, zone string, query spectrum.AnalyticsEventSummaryGetParams) (spectrum.AnalyticsEventSummaryGetResponse, error) +- client.Spectrum.Analytics.Events.Summaries.Get(ctx context.Context, zone string, query spectrum.AnalyticsEventSummaryGetParams) (spectrum.AnalyticsEventSummaryGetResponseUnion, error) ## Apps @@ -2935,15 +2980,15 @@ Response Types: - spectrum.AppUpdateResponse - spectrum.AppListResponse - spectrum.AppDeleteResponse -- spectrum.AppGetResponse +- spectrum.AppGetResponseUnion Methods: - client.Spectrum.Apps.New(ctx context.Context, zone string, body spectrum.AppNewParams) (spectrum.AppNewResponse, error) - client.Spectrum.Apps.Update(ctx context.Context, zone string, appID string, body spectrum.AppUpdateParams) (spectrum.AppUpdateResponse, error) - client.Spectrum.Apps.List(ctx context.Context, zone string, query spectrum.AppListParams) (pagination.V4PagePaginationArray[spectrum.AppListResponse], error) -- client.Spectrum.Apps.Delete(ctx context.Context, zone string, appID string) (spectrum.AppDeleteResponse, error) -- client.Spectrum.Apps.Get(ctx context.Context, zone string, appID string) (spectrum.AppGetResponse, error) +- client.Spectrum.Apps.Delete(ctx context.Context, zone string, appID string, body spectrum.AppDeleteParams) (spectrum.AppDeleteResponse, error) +- client.Spectrum.Apps.Get(ctx context.Context, zone string, appID string) (spectrum.AppGetResponseUnion, error) # Addressing @@ -2961,54 +3006,54 @@ Methods: Response Types: -- addressing.AddressingAddressMaps +- addressing.AddressMap - addressing.AddressMapNewResponse -- addressing.AddressMapDeleteResponse +- addressing.AddressMapDeleteResponseUnion - addressing.AddressMapGetResponse Methods: - client.Addressing.AddressMaps.New(ctx context.Context, params addressing.AddressMapNewParams) (addressing.AddressMapNewResponse, error) -- client.Addressing.AddressMaps.List(ctx context.Context, query addressing.AddressMapListParams) (pagination.SinglePage[addressing.AddressingAddressMaps], error) -- client.Addressing.AddressMaps.Delete(ctx context.Context, addressMapID string, body addressing.AddressMapDeleteParams) (addressing.AddressMapDeleteResponse, error) -- client.Addressing.AddressMaps.Edit(ctx context.Context, addressMapID string, params addressing.AddressMapEditParams) (addressing.AddressingAddressMaps, error) +- client.Addressing.AddressMaps.List(ctx context.Context, query addressing.AddressMapListParams) (pagination.SinglePage[addressing.AddressMap], error) +- client.Addressing.AddressMaps.Delete(ctx context.Context, addressMapID string, params addressing.AddressMapDeleteParams) (addressing.AddressMapDeleteResponseUnion, error) +- client.Addressing.AddressMaps.Edit(ctx context.Context, addressMapID string, params addressing.AddressMapEditParams) (addressing.AddressMap, error) - client.Addressing.AddressMaps.Get(ctx context.Context, addressMapID string, query addressing.AddressMapGetParams) (addressing.AddressMapGetResponse, error) ### Accounts Response Types: -- addressing.AddressMapAccountUpdateResponse -- addressing.AddressMapAccountDeleteResponse +- addressing.AddressMapAccountUpdateResponseUnion +- addressing.AddressMapAccountDeleteResponseUnion Methods: -- client.Addressing.AddressMaps.Accounts.Update(ctx context.Context, addressMapID string, body addressing.AddressMapAccountUpdateParams) (addressing.AddressMapAccountUpdateResponse, error) -- client.Addressing.AddressMaps.Accounts.Delete(ctx context.Context, addressMapID string, body addressing.AddressMapAccountDeleteParams) (addressing.AddressMapAccountDeleteResponse, error) +- client.Addressing.AddressMaps.Accounts.Update(ctx context.Context, addressMapID string, params addressing.AddressMapAccountUpdateParams) (addressing.AddressMapAccountUpdateResponseUnion, error) +- client.Addressing.AddressMaps.Accounts.Delete(ctx context.Context, addressMapID string, params addressing.AddressMapAccountDeleteParams) (addressing.AddressMapAccountDeleteResponseUnion, error) ### IPs Response Types: -- addressing.AddressMapIPUpdateResponse -- addressing.AddressMapIPDeleteResponse +- addressing.AddressMapIPUpdateResponseUnion +- addressing.AddressMapIPDeleteResponseUnion Methods: -- client.Addressing.AddressMaps.IPs.Update(ctx context.Context, addressMapID string, ipAddress string, body addressing.AddressMapIPUpdateParams) (addressing.AddressMapIPUpdateResponse, error) -- client.Addressing.AddressMaps.IPs.Delete(ctx context.Context, addressMapID string, ipAddress string, body addressing.AddressMapIPDeleteParams) (addressing.AddressMapIPDeleteResponse, error) +- client.Addressing.AddressMaps.IPs.Update(ctx context.Context, addressMapID string, ipAddress string, params addressing.AddressMapIPUpdateParams) (addressing.AddressMapIPUpdateResponseUnion, error) +- client.Addressing.AddressMaps.IPs.Delete(ctx context.Context, addressMapID string, ipAddress string, params addressing.AddressMapIPDeleteParams) (addressing.AddressMapIPDeleteResponseUnion, error) ### Zones Response Types: -- addressing.AddressMapZoneUpdateResponse -- addressing.AddressMapZoneDeleteResponse +- addressing.AddressMapZoneUpdateResponseUnion +- addressing.AddressMapZoneDeleteResponseUnion Methods: -- client.Addressing.AddressMaps.Zones.Update(ctx context.Context, addressMapID string, body addressing.AddressMapZoneUpdateParams) (addressing.AddressMapZoneUpdateResponse, error) -- client.Addressing.AddressMaps.Zones.Delete(ctx context.Context, addressMapID string, body addressing.AddressMapZoneDeleteParams) (addressing.AddressMapZoneDeleteResponse, error) +- client.Addressing.AddressMaps.Zones.Update(ctx context.Context, addressMapID string, params addressing.AddressMapZoneUpdateParams) (addressing.AddressMapZoneUpdateResponseUnion, error) +- client.Addressing.AddressMaps.Zones.Delete(ctx context.Context, addressMapID string, params addressing.AddressMapZoneDeleteParams) (addressing.AddressMapZoneDeleteResponseUnion, error) ## LOADocuments @@ -3034,44 +3079,48 @@ Methods: Response Types: -- addressing.AddressingIpamPrefixes -- addressing.PrefixDeleteResponse +- addressing.Prefix +- addressing.PrefixDeleteResponseUnion Methods: -- client.Addressing.Prefixes.New(ctx context.Context, params addressing.PrefixNewParams) (addressing.AddressingIpamPrefixes, error) -- client.Addressing.Prefixes.List(ctx context.Context, query addressing.PrefixListParams) (pagination.SinglePage[addressing.AddressingIpamPrefixes], error) -- client.Addressing.Prefixes.Delete(ctx context.Context, prefixID string, body addressing.PrefixDeleteParams) (addressing.PrefixDeleteResponse, error) -- client.Addressing.Prefixes.Edit(ctx context.Context, prefixID string, params addressing.PrefixEditParams) (addressing.AddressingIpamPrefixes, error) -- client.Addressing.Prefixes.Get(ctx context.Context, prefixID string, query addressing.PrefixGetParams) (addressing.AddressingIpamPrefixes, error) +- client.Addressing.Prefixes.New(ctx context.Context, params addressing.PrefixNewParams) (addressing.Prefix, error) +- client.Addressing.Prefixes.List(ctx context.Context, query addressing.PrefixListParams) (pagination.SinglePage[addressing.Prefix], error) +- client.Addressing.Prefixes.Delete(ctx context.Context, prefixID string, params addressing.PrefixDeleteParams) (addressing.PrefixDeleteResponseUnion, error) +- client.Addressing.Prefixes.Edit(ctx context.Context, prefixID string, params addressing.PrefixEditParams) (addressing.Prefix, error) +- client.Addressing.Prefixes.Get(ctx context.Context, prefixID string, query addressing.PrefixGetParams) (addressing.Prefix, error) ### BGP #### Bindings +Params Types: + +- addressing.ServiceBindingParam + Response Types: -- addressing.AddressingServiceBinding -- addressing.PrefixBGPBindingDeleteResponse +- addressing.ServiceBinding +- addressing.PrefixBGPBindingDeleteResponseUnion Methods: -- client.Addressing.Prefixes.BGP.Bindings.New(ctx context.Context, prefixID string, params addressing.PrefixBGPBindingNewParams) (addressing.AddressingServiceBinding, error) -- client.Addressing.Prefixes.BGP.Bindings.List(ctx context.Context, prefixID string, query addressing.PrefixBGPBindingListParams) (pagination.SinglePage[addressing.AddressingServiceBinding], error) -- client.Addressing.Prefixes.BGP.Bindings.Delete(ctx context.Context, prefixID string, bindingID string, body addressing.PrefixBGPBindingDeleteParams) (addressing.PrefixBGPBindingDeleteResponse, error) -- client.Addressing.Prefixes.BGP.Bindings.Get(ctx context.Context, prefixID string, bindingID string, query addressing.PrefixBGPBindingGetParams) (addressing.AddressingServiceBinding, error) +- client.Addressing.Prefixes.BGP.Bindings.New(ctx context.Context, prefixID string, params addressing.PrefixBGPBindingNewParams) (addressing.ServiceBinding, error) +- client.Addressing.Prefixes.BGP.Bindings.List(ctx context.Context, prefixID string, query addressing.PrefixBGPBindingListParams) (pagination.SinglePage[addressing.ServiceBinding], error) +- client.Addressing.Prefixes.BGP.Bindings.Delete(ctx context.Context, prefixID string, bindingID string, body addressing.PrefixBGPBindingDeleteParams) (addressing.PrefixBGPBindingDeleteResponseUnion, error) +- client.Addressing.Prefixes.BGP.Bindings.Get(ctx context.Context, prefixID string, bindingID string, query addressing.PrefixBGPBindingGetParams) (addressing.ServiceBinding, error) #### Prefixes Response Types: -- addressing.AddressingIpamBGPPrefixes +- addressing.BGPPrefix Methods: -- client.Addressing.Prefixes.BGP.Prefixes.List(ctx context.Context, prefixID string, query addressing.PrefixBGPPrefixListParams) (pagination.SinglePage[addressing.AddressingIpamBGPPrefixes], error) -- client.Addressing.Prefixes.BGP.Prefixes.Edit(ctx context.Context, prefixID string, bgpPrefixID string, params addressing.PrefixBGPPrefixEditParams) (addressing.AddressingIpamBGPPrefixes, error) -- client.Addressing.Prefixes.BGP.Prefixes.Get(ctx context.Context, prefixID string, bgpPrefixID string, query addressing.PrefixBGPPrefixGetParams) (addressing.AddressingIpamBGPPrefixes, error) +- client.Addressing.Prefixes.BGP.Prefixes.List(ctx context.Context, prefixID string, query addressing.PrefixBGPPrefixListParams) (pagination.SinglePage[addressing.BGPPrefix], error) +- client.Addressing.Prefixes.BGP.Prefixes.Edit(ctx context.Context, prefixID string, bgpPrefixID string, params addressing.PrefixBGPPrefixEditParams) (addressing.BGPPrefix, error) +- client.Addressing.Prefixes.BGP.Prefixes.Get(ctx context.Context, prefixID string, bgpPrefixID string, query addressing.PrefixBGPPrefixGetParams) (addressing.BGPPrefix, error) #### Statuses @@ -3089,24 +3138,20 @@ Methods: Response Types: -- addressing.AddressingIpamDelegations +- addressing.Delegations - addressing.PrefixDelegationDeleteResponse Methods: -- client.Addressing.Prefixes.Delegations.New(ctx context.Context, prefixID string, params addressing.PrefixDelegationNewParams) (addressing.AddressingIpamDelegations, error) -- client.Addressing.Prefixes.Delegations.List(ctx context.Context, prefixID string, query addressing.PrefixDelegationListParams) (pagination.SinglePage[addressing.AddressingIpamDelegations], error) -- client.Addressing.Prefixes.Delegations.Delete(ctx context.Context, prefixID string, delegationID string, body addressing.PrefixDelegationDeleteParams) (addressing.PrefixDelegationDeleteResponse, error) +- client.Addressing.Prefixes.Delegations.New(ctx context.Context, prefixID string, params addressing.PrefixDelegationNewParams) (addressing.Delegations, error) +- client.Addressing.Prefixes.Delegations.List(ctx context.Context, prefixID string, query addressing.PrefixDelegationListParams) (pagination.SinglePage[addressing.Delegations], error) +- client.Addressing.Prefixes.Delegations.Delete(ctx context.Context, prefixID string, delegationID string, params addressing.PrefixDelegationDeleteParams) (addressing.PrefixDelegationDeleteResponse, error) # AuditLogs -Response Types: - -- audit_logs.AuditLogListResponse - Methods: -- client.AuditLogs.List(ctx context.Context, params audit_logs.AuditLogListParams) (pagination.V4PagePaginationArray[audit_logs.AuditLogListResponse], error) +- client.AuditLogs.List(ctx context.Context, params audit_logs.AuditLogListParams) (pagination.V4PagePaginationArray[shared.AuditLog], error) # Billing @@ -3114,23 +3159,26 @@ Methods: Response Types: -- billing.ProfileGetResponse +- billing.ProfileGetResponseUnion Methods: -- client.Billing.Profiles.Get(ctx context.Context, accountIdentifier interface{}) (billing.ProfileGetResponse, error) +- client.Billing.Profiles.Get(ctx context.Context, accountIdentifier interface{}) (billing.ProfileGetResponseUnion, error) # BrandProtection Response Types: -- brand_protection.IntelPhishingURLInfo -- brand_protection.IntelPhishingURLSubmit +- brand_protection.Info +- brand_protection.RuleMatch +- brand_protection.ScanStatus +- brand_protection.Submit +- brand_protection.URLInfoModelResults Methods: -- client.BrandProtection.Submit(ctx context.Context, params brand_protection.BrandProtectionSubmitParams) (brand_protection.IntelPhishingURLSubmit, error) -- client.BrandProtection.URLInfo(ctx context.Context, params brand_protection.BrandProtectionURLInfoParams) (brand_protection.IntelPhishingURLInfo, error) +- client.BrandProtection.Submit(ctx context.Context, params brand_protection.BrandProtectionSubmitParams) (brand_protection.Submit, error) +- client.BrandProtection.URLInfo(ctx context.Context, params brand_protection.BrandProtectionURLInfoParams) (brand_protection.Info, error) # Diagnostics @@ -3138,11 +3186,11 @@ Methods: Response Types: -- diagnostics.MagicTransitTargetResult +- diagnostics.Traceroute Methods: -- client.Diagnostics.Traceroutes.New(ctx context.Context, params diagnostics.TracerouteNewParams) ([]diagnostics.MagicTransitTargetResult, error) +- client.Diagnostics.Traceroutes.New(ctx context.Context, params diagnostics.TracerouteNewParams) ([]diagnostics.Traceroute, error) # Images @@ -3152,13 +3200,13 @@ Response Types: - images.Image - images.V1ListResponse -- images.V1DeleteResponse +- images.V1DeleteResponseUnion Methods: - client.Images.V1.New(ctx context.Context, params images.V1NewParams) (images.Image, error) - client.Images.V1.List(ctx context.Context, params images.V1ListParams) (pagination.V4PagePagination[images.V1ListResponse], error) -- client.Images.V1.Delete(ctx context.Context, imageID string, body images.V1DeleteParams) (images.V1DeleteResponse, error) +- client.Images.V1.Delete(ctx context.Context, imageID string, params images.V1DeleteParams) (images.V1DeleteResponseUnion, error) - client.Images.V1.Edit(ctx context.Context, imageID string, params images.V1EditParams) (images.Image, error) - client.Images.V1.Get(ctx context.Context, imageID string, query images.V1GetParams) (images.Image, error) @@ -3166,39 +3214,41 @@ Methods: Response Types: -- images.ImagesImageKeys +- images.Key Methods: -- client.Images.V1.Keys.Update(ctx context.Context, signingKeyName string, body images.V1KeyUpdateParams) (images.ImagesImageKeys, error) -- client.Images.V1.Keys.List(ctx context.Context, query images.V1KeyListParams) (images.ImagesImageKeys, error) -- client.Images.V1.Keys.Delete(ctx context.Context, signingKeyName string, body images.V1KeyDeleteParams) (images.ImagesImageKeys, error) +- client.Images.V1.Keys.Update(ctx context.Context, signingKeyName string, body images.V1KeyUpdateParams) (images.Key, error) +- client.Images.V1.Keys.List(ctx context.Context, query images.V1KeyListParams) (images.Key, error) +- client.Images.V1.Keys.Delete(ctx context.Context, signingKeyName string, body images.V1KeyDeleteParams) (images.Key, error) ### Stats Response Types: -- images.ImagesImagesStats +- images.Stat Methods: -- client.Images.V1.Stats.Get(ctx context.Context, query images.V1StatGetParams) (images.ImagesImagesStats, error) +- client.Images.V1.Stats.Get(ctx context.Context, query images.V1StatGetParams) (images.Stat, error) ### Variants Response Types: -- images.V1ImageVariant -- images.V1ImageVariants -- images.V1VariantDeleteResponse +- images.Variant +- images.V1VariantNewResponse +- images.V1VariantDeleteResponseUnion +- images.V1VariantEditResponse +- images.V1VariantGetResponse Methods: -- client.Images.V1.Variants.New(ctx context.Context, params images.V1VariantNewParams) (images.V1ImageVariant, error) -- client.Images.V1.Variants.List(ctx context.Context, query images.V1VariantListParams) (images.V1ImageVariants, error) -- client.Images.V1.Variants.Delete(ctx context.Context, variantID string, body images.V1VariantDeleteParams) (images.V1VariantDeleteResponse, error) -- client.Images.V1.Variants.Edit(ctx context.Context, variantID string, params images.V1VariantEditParams) (images.V1ImageVariant, error) -- client.Images.V1.Variants.Get(ctx context.Context, variantID string, query images.V1VariantGetParams) (images.V1ImageVariant, error) +- client.Images.V1.Variants.New(ctx context.Context, params images.V1VariantNewParams) (images.V1VariantNewResponse, error) +- client.Images.V1.Variants.List(ctx context.Context, query images.V1VariantListParams) (images.Variant, error) +- client.Images.V1.Variants.Delete(ctx context.Context, variantID string, params images.V1VariantDeleteParams) (images.V1VariantDeleteResponseUnion, error) +- client.Images.V1.Variants.Edit(ctx context.Context, variantID string, params images.V1VariantEditParams) (images.V1VariantEditResponse, error) +- client.Images.V1.Variants.Get(ctx context.Context, variantID string, query images.V1VariantGetParams) (images.V1VariantGetResponse, error) ### Blobs @@ -3232,15 +3282,15 @@ Methods: Params Types: -- intel.IntelASNParam +- intel.ASNParam Response Types: -- intel.IntelASN +- intel.ASN Methods: -- client.Intel.ASN.Get(ctx context.Context, asn intel.IntelASNParam, query intel.ASNGetParams) (intel.IntelASN, error) +- client.Intel.ASN.Get(ctx context.Context, asn intel.ASNParam, query intel.ASNGetParams) (intel.ASN, error) ### Subnets @@ -3250,27 +3300,32 @@ Response Types: Methods: -- client.Intel.ASN.Subnets.Get(ctx context.Context, asn intel.IntelASNParam, query intel.ASNSubnetGetParams) (intel.ASNSubnetGetResponse, error) +- client.Intel.ASN.Subnets.Get(ctx context.Context, asn intel.ASNParam, query intel.ASNSubnetGetParams) (intel.ASNSubnetGetResponse, error) ## DNS +Params Types: + +- intel.DNSParam + Response Types: -- intel.IntelPassiveDNSByIP +- intel.DNS +- intel.DNSListResponse Methods: -- client.Intel.DNS.Get(ctx context.Context, params intel.DNSGetParams) (intel.IntelPassiveDNSByIP, error) +- client.Intel.DNS.List(ctx context.Context, params intel.DNSListParams) (pagination.V4PagePagination[intel.DNSListResponse], error) ## Domains Response Types: -- intel.IntelDomain +- intel.Domain Methods: -- client.Intel.Domains.Get(ctx context.Context, params intel.DomainGetParams) (intel.IntelDomain, error) +- client.Intel.Domains.Get(ctx context.Context, params intel.DomainGetParams) (intel.Domain, error) ### Bulks @@ -3286,51 +3341,51 @@ Methods: Response Types: -- intel.IntelDomainHistory +- intel.DomainHistory Methods: -- client.Intel.DomainHistory.Get(ctx context.Context, params intel.DomainHistoryGetParams) ([]intel.IntelDomainHistory, error) +- client.Intel.DomainHistory.Get(ctx context.Context, params intel.DomainHistoryGetParams) ([]intel.DomainHistory, error) ## IPs Response Types: -- intel.IntelSchemasIP +- intel.IP Methods: -- client.Intel.IPs.Get(ctx context.Context, params intel.IPGetParams) ([]intel.IntelSchemasIP, error) +- client.Intel.IPs.Get(ctx context.Context, params intel.IPGetParams) ([]intel.IP, error) ## IPLists Response Types: -- intel.IntelIPList +- intel.IPList Methods: -- client.Intel.IPLists.Get(ctx context.Context, query intel.IPListGetParams) ([]intel.IntelIPList, error) +- client.Intel.IPLists.Get(ctx context.Context, query intel.IPListGetParams) ([]intel.IPList, error) ## Miscategorizations Response Types: -- intel.MiscategorizationNewResponse +- intel.MiscategorizationNewResponseUnion Methods: -- client.Intel.Miscategorizations.New(ctx context.Context, params intel.MiscategorizationNewParams) (intel.MiscategorizationNewResponse, error) +- client.Intel.Miscategorizations.New(ctx context.Context, params intel.MiscategorizationNewParams) (intel.MiscategorizationNewResponseUnion, error) ## Whois Response Types: -- intel.IntelWhois +- intel.Whois Methods: -- client.Intel.Whois.Get(ctx context.Context, params intel.WhoisGetParams) (intel.IntelWhois, error) +- client.Intel.Whois.Get(ctx context.Context, params intel.WhoisGetParams) (intel.Whois, error) ## IndicatorFeeds @@ -3367,11 +3422,11 @@ Methods: Response Types: -- intel.IntelSinkholeItem +- intel.Sinkhole Methods: -- client.Intel.Sinkholes.List(ctx context.Context, query intel.SinkholeListParams) (pagination.SinglePage[intel.IntelSinkholeItem], error) +- client.Intel.Sinkholes.List(ctx context.Context, query intel.SinkholeListParams) (pagination.SinglePage[intel.Sinkhole], error) ## AttackSurfaceReport @@ -3383,11 +3438,19 @@ Methods: ### Issues +Params Types: + +- intel.IssueClassParam +- intel.IssueType +- intel.ProductParam +- intel.SeverityQueryParam +- intel.SubjectParam + Response Types: - intel.AttackSurfaceReportIssueListResponse - intel.AttackSurfaceReportIssueClassResponse -- intel.AttackSurfaceReportIssueDismissResponse +- intel.AttackSurfaceReportIssueDismissResponseUnion - intel.AttackSurfaceReportIssueSeverityResponse - intel.AttackSurfaceReportIssueTypeResponse @@ -3395,12 +3458,24 @@ Methods: - client.Intel.AttackSurfaceReport.Issues.List(ctx context.Context, params intel.AttackSurfaceReportIssueListParams) (pagination.V4PagePagination[intel.AttackSurfaceReportIssueListResponse], error) - client.Intel.AttackSurfaceReport.Issues.Class(ctx context.Context, params intel.AttackSurfaceReportIssueClassParams) ([]intel.AttackSurfaceReportIssueClassResponse, error) -- client.Intel.AttackSurfaceReport.Issues.Dismiss(ctx context.Context, issueID string, params intel.AttackSurfaceReportIssueDismissParams) (intel.AttackSurfaceReportIssueDismissResponse, error) +- client.Intel.AttackSurfaceReport.Issues.Dismiss(ctx context.Context, issueID string, params intel.AttackSurfaceReportIssueDismissParams) (intel.AttackSurfaceReportIssueDismissResponseUnion, error) - client.Intel.AttackSurfaceReport.Issues.Severity(ctx context.Context, params intel.AttackSurfaceReportIssueSeverityParams) ([]intel.AttackSurfaceReportIssueSeverityResponse, error) - client.Intel.AttackSurfaceReport.Issues.Type(ctx context.Context, params intel.AttackSurfaceReportIssueTypeParams) ([]intel.AttackSurfaceReportIssueTypeResponse, error) # MagicTransit +Params Types: + +- magic_transit.HealthCheckParam +- magic_transit.HealthCheckRate +- magic_transit.HealthCheckType + +Response Types: + +- magic_transit.HealthCheck +- magic_transit.HealthCheckRate +- magic_transit.HealthCheckType + ## CfInterconnects Response Types: @@ -3430,13 +3505,14 @@ Methods: - client.MagicTransit.GRETunnels.New(ctx context.Context, params magic_transit.GRETunnelNewParams) (magic_transit.GRETunnelNewResponse, error) - client.MagicTransit.GRETunnels.Update(ctx context.Context, tunnelIdentifier string, params magic_transit.GRETunnelUpdateParams) (magic_transit.GRETunnelUpdateResponse, error) - client.MagicTransit.GRETunnels.List(ctx context.Context, query magic_transit.GRETunnelListParams) (magic_transit.GRETunnelListResponse, error) -- client.MagicTransit.GRETunnels.Delete(ctx context.Context, tunnelIdentifier string, body magic_transit.GRETunnelDeleteParams) (magic_transit.GRETunnelDeleteResponse, error) +- client.MagicTransit.GRETunnels.Delete(ctx context.Context, tunnelIdentifier string, params magic_transit.GRETunnelDeleteParams) (magic_transit.GRETunnelDeleteResponse, error) - client.MagicTransit.GRETunnels.Get(ctx context.Context, tunnelIdentifier string, query magic_transit.GRETunnelGetParams) (magic_transit.GRETunnelGetResponse, error) ## IPSECTunnels Response Types: +- magic_transit.PSKMetadata - magic_transit.IPSECTunnelNewResponse - magic_transit.IPSECTunnelUpdateResponse - magic_transit.IPSECTunnelListResponse @@ -3449,14 +3525,23 @@ Methods: - client.MagicTransit.IPSECTunnels.New(ctx context.Context, params magic_transit.IPSECTunnelNewParams) (magic_transit.IPSECTunnelNewResponse, error) - client.MagicTransit.IPSECTunnels.Update(ctx context.Context, tunnelIdentifier string, params magic_transit.IPSECTunnelUpdateParams) (magic_transit.IPSECTunnelUpdateResponse, error) - client.MagicTransit.IPSECTunnels.List(ctx context.Context, query magic_transit.IPSECTunnelListParams) (magic_transit.IPSECTunnelListResponse, error) -- client.MagicTransit.IPSECTunnels.Delete(ctx context.Context, tunnelIdentifier string, body magic_transit.IPSECTunnelDeleteParams) (magic_transit.IPSECTunnelDeleteResponse, error) +- client.MagicTransit.IPSECTunnels.Delete(ctx context.Context, tunnelIdentifier string, params magic_transit.IPSECTunnelDeleteParams) (magic_transit.IPSECTunnelDeleteResponse, error) - client.MagicTransit.IPSECTunnels.Get(ctx context.Context, tunnelIdentifier string, query magic_transit.IPSECTunnelGetParams) (magic_transit.IPSECTunnelGetResponse, error) -- client.MagicTransit.IPSECTunnels.PSKGenerate(ctx context.Context, tunnelIdentifier string, body magic_transit.IPSECTunnelPSKGenerateParams) (magic_transit.IPSECTunnelPSKGenerateResponse, error) +- client.MagicTransit.IPSECTunnels.PSKGenerate(ctx context.Context, tunnelIdentifier string, params magic_transit.IPSECTunnelPSKGenerateParams) (magic_transit.IPSECTunnelPSKGenerateResponse, error) ## Routes +Params Types: + +- magic_transit.ColoNameParam +- magic_transit.ColoRegionParam +- magic_transit.ScopeParam + Response Types: +- magic_transit.ColoName +- magic_transit.ColoRegion +- magic_transit.Scope - magic_transit.RouteNewResponse - magic_transit.RouteUpdateResponse - magic_transit.RouteListResponse @@ -3469,14 +3554,20 @@ Methods: - client.MagicTransit.Routes.New(ctx context.Context, params magic_transit.RouteNewParams) (magic_transit.RouteNewResponse, error) - client.MagicTransit.Routes.Update(ctx context.Context, routeIdentifier string, params magic_transit.RouteUpdateParams) (magic_transit.RouteUpdateResponse, error) - client.MagicTransit.Routes.List(ctx context.Context, query magic_transit.RouteListParams) (magic_transit.RouteListResponse, error) -- client.MagicTransit.Routes.Delete(ctx context.Context, routeIdentifier string, body magic_transit.RouteDeleteParams) (magic_transit.RouteDeleteResponse, error) +- client.MagicTransit.Routes.Delete(ctx context.Context, routeIdentifier string, params magic_transit.RouteDeleteParams) (magic_transit.RouteDeleteResponse, error) - client.MagicTransit.Routes.Empty(ctx context.Context, params magic_transit.RouteEmptyParams) (magic_transit.RouteEmptyResponse, error) - client.MagicTransit.Routes.Get(ctx context.Context, routeIdentifier string, query magic_transit.RouteGetParams) (magic_transit.RouteGetResponse, error) ## Sites +Params Types: + +- magic_transit.SiteLocationParam + Response Types: +- magic_transit.Site +- magic_transit.SiteLocation - magic_transit.SiteNewResponse - magic_transit.SiteUpdateResponse - magic_transit.SiteListResponse @@ -3487,14 +3578,25 @@ Methods: - client.MagicTransit.Sites.New(ctx context.Context, params magic_transit.SiteNewParams) (magic_transit.SiteNewResponse, error) - client.MagicTransit.Sites.Update(ctx context.Context, siteID string, params magic_transit.SiteUpdateParams) (magic_transit.SiteUpdateResponse, error) -- client.MagicTransit.Sites.List(ctx context.Context, query magic_transit.SiteListParams) (magic_transit.SiteListResponse, error) -- client.MagicTransit.Sites.Delete(ctx context.Context, siteID string, body magic_transit.SiteDeleteParams) (magic_transit.SiteDeleteResponse, error) +- client.MagicTransit.Sites.List(ctx context.Context, params magic_transit.SiteListParams) (magic_transit.SiteListResponse, error) +- client.MagicTransit.Sites.Delete(ctx context.Context, siteID string, params magic_transit.SiteDeleteParams) (magic_transit.SiteDeleteResponse, error) - client.MagicTransit.Sites.Get(ctx context.Context, siteID string, query magic_transit.SiteGetParams) (magic_transit.SiteGetResponse, error) ### ACLs +Params Types: + +- magic_transit.ACLParam +- magic_transit.ACLConfigurationParam +- magic_transit.AllowedProtocol +- magic_transit.SubnetUnionParam + Response Types: +- magic_transit.ACL +- magic_transit.ACLConfiguration +- magic_transit.AllowedProtocol +- magic_transit.SubnetUnion - magic_transit.SiteACLNewResponse - magic_transit.SiteACLUpdateResponse - magic_transit.SiteACLListResponse @@ -3506,13 +3608,27 @@ Methods: - client.MagicTransit.Sites.ACLs.New(ctx context.Context, siteID string, params magic_transit.SiteACLNewParams) (magic_transit.SiteACLNewResponse, error) - client.MagicTransit.Sites.ACLs.Update(ctx context.Context, siteID string, aclIdentifier string, params magic_transit.SiteACLUpdateParams) (magic_transit.SiteACLUpdateResponse, error) - client.MagicTransit.Sites.ACLs.List(ctx context.Context, siteID string, query magic_transit.SiteACLListParams) (magic_transit.SiteACLListResponse, error) -- client.MagicTransit.Sites.ACLs.Delete(ctx context.Context, siteID string, aclIdentifier string, body magic_transit.SiteACLDeleteParams) (magic_transit.SiteACLDeleteResponse, error) +- client.MagicTransit.Sites.ACLs.Delete(ctx context.Context, siteID string, aclIdentifier string, params magic_transit.SiteACLDeleteParams) (magic_transit.SiteACLDeleteResponse, error) - client.MagicTransit.Sites.ACLs.Get(ctx context.Context, siteID string, aclIdentifier string, query magic_transit.SiteACLGetParams) (magic_transit.SiteACLGetResponse, error) ### LANs +Params Types: + +- magic_transit.DHCPRelayParam +- magic_transit.DHCPServerParam +- magic_transit.LANStaticAddressingParam +- magic_transit.NatParam +- magic_transit.RoutedSubnetParam + Response Types: +- magic_transit.DHCPRelay +- magic_transit.DHCPServer +- magic_transit.LAN +- magic_transit.LANStaticAddressing +- magic_transit.Nat +- magic_transit.RoutedSubnet - magic_transit.SiteLANNewResponse - magic_transit.SiteLANUpdateResponse - magic_transit.SiteLANListResponse @@ -3524,13 +3640,19 @@ Methods: - client.MagicTransit.Sites.LANs.New(ctx context.Context, siteID string, params magic_transit.SiteLANNewParams) (magic_transit.SiteLANNewResponse, error) - client.MagicTransit.Sites.LANs.Update(ctx context.Context, siteID string, lanID string, params magic_transit.SiteLANUpdateParams) (magic_transit.SiteLANUpdateResponse, error) - client.MagicTransit.Sites.LANs.List(ctx context.Context, siteID string, query magic_transit.SiteLANListParams) (magic_transit.SiteLANListResponse, error) -- client.MagicTransit.Sites.LANs.Delete(ctx context.Context, siteID string, lanID string, body magic_transit.SiteLANDeleteParams) (magic_transit.SiteLANDeleteResponse, error) +- client.MagicTransit.Sites.LANs.Delete(ctx context.Context, siteID string, lanID string, params magic_transit.SiteLANDeleteParams) (magic_transit.SiteLANDeleteResponse, error) - client.MagicTransit.Sites.LANs.Get(ctx context.Context, siteID string, lanID string, query magic_transit.SiteLANGetParams) (magic_transit.SiteLANGetResponse, error) ### WANs +Params Types: + +- magic_transit.WANStaticAddressingParam + Response Types: +- magic_transit.WAN +- magic_transit.WANStaticAddressing - magic_transit.SiteWANNewResponse - magic_transit.SiteWANUpdateResponse - magic_transit.SiteWANListResponse @@ -3542,30 +3664,34 @@ Methods: - client.MagicTransit.Sites.WANs.New(ctx context.Context, siteID string, params magic_transit.SiteWANNewParams) (magic_transit.SiteWANNewResponse, error) - client.MagicTransit.Sites.WANs.Update(ctx context.Context, siteID string, wanID string, params magic_transit.SiteWANUpdateParams) (magic_transit.SiteWANUpdateResponse, error) - client.MagicTransit.Sites.WANs.List(ctx context.Context, siteID string, query magic_transit.SiteWANListParams) (magic_transit.SiteWANListResponse, error) -- client.MagicTransit.Sites.WANs.Delete(ctx context.Context, siteID string, wanID string, body magic_transit.SiteWANDeleteParams) (magic_transit.SiteWANDeleteResponse, error) +- client.MagicTransit.Sites.WANs.Delete(ctx context.Context, siteID string, wanID string, params magic_transit.SiteWANDeleteParams) (magic_transit.SiteWANDeleteResponse, error) - client.MagicTransit.Sites.WANs.Get(ctx context.Context, siteID string, wanID string, query magic_transit.SiteWANGetParams) (magic_transit.SiteWANGetResponse, error) # MagicNetworkMonitoring ## Configs +Params Types: + +- magic_network_monitoring.ConfigurationParam + Response Types: -- magic_network_monitoring.MagicNetworkMonitoringConfig +- magic_network_monitoring.Configuration Methods: -- client.MagicNetworkMonitoring.Configs.New(ctx context.Context, body magic_network_monitoring.ConfigNewParams) (magic_network_monitoring.MagicNetworkMonitoringConfig, error) -- client.MagicNetworkMonitoring.Configs.Update(ctx context.Context, body magic_network_monitoring.ConfigUpdateParams) (magic_network_monitoring.MagicNetworkMonitoringConfig, error) -- client.MagicNetworkMonitoring.Configs.Delete(ctx context.Context, body magic_network_monitoring.ConfigDeleteParams) (magic_network_monitoring.MagicNetworkMonitoringConfig, error) -- client.MagicNetworkMonitoring.Configs.Edit(ctx context.Context, body magic_network_monitoring.ConfigEditParams) (magic_network_monitoring.MagicNetworkMonitoringConfig, error) -- client.MagicNetworkMonitoring.Configs.Get(ctx context.Context, query magic_network_monitoring.ConfigGetParams) (magic_network_monitoring.MagicNetworkMonitoringConfig, error) +- client.MagicNetworkMonitoring.Configs.New(ctx context.Context, params magic_network_monitoring.ConfigNewParams) (magic_network_monitoring.Configuration, error) +- client.MagicNetworkMonitoring.Configs.Update(ctx context.Context, params magic_network_monitoring.ConfigUpdateParams) (magic_network_monitoring.Configuration, error) +- client.MagicNetworkMonitoring.Configs.Delete(ctx context.Context, params magic_network_monitoring.ConfigDeleteParams) (magic_network_monitoring.Configuration, error) +- client.MagicNetworkMonitoring.Configs.Edit(ctx context.Context, params magic_network_monitoring.ConfigEditParams) (magic_network_monitoring.Configuration, error) +- client.MagicNetworkMonitoring.Configs.Get(ctx context.Context, query magic_network_monitoring.ConfigGetParams) (magic_network_monitoring.Configuration, error) ### Full Methods: -- client.MagicNetworkMonitoring.Configs.Full.Get(ctx context.Context, query magic_network_monitoring.ConfigFullGetParams) (magic_network_monitoring.MagicNetworkMonitoringConfig, error) +- client.MagicNetworkMonitoring.Configs.Full.Get(ctx context.Context, query magic_network_monitoring.ConfigFullGetParams) (magic_network_monitoring.Configuration, error) ## Rules @@ -3575,46 +3701,46 @@ Response Types: Methods: -- client.MagicNetworkMonitoring.Rules.New(ctx context.Context, body magic_network_monitoring.RuleNewParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) -- client.MagicNetworkMonitoring.Rules.Update(ctx context.Context, body magic_network_monitoring.RuleUpdateParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) +- client.MagicNetworkMonitoring.Rules.New(ctx context.Context, params magic_network_monitoring.RuleNewParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) +- client.MagicNetworkMonitoring.Rules.Update(ctx context.Context, params magic_network_monitoring.RuleUpdateParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) - client.MagicNetworkMonitoring.Rules.List(ctx context.Context, query magic_network_monitoring.RuleListParams) (pagination.SinglePage[magic_network_monitoring.MagicNetworkMonitoringRule], error) -- client.MagicNetworkMonitoring.Rules.Delete(ctx context.Context, ruleID string, body magic_network_monitoring.RuleDeleteParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) -- client.MagicNetworkMonitoring.Rules.Edit(ctx context.Context, ruleID string, body magic_network_monitoring.RuleEditParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) +- client.MagicNetworkMonitoring.Rules.Delete(ctx context.Context, ruleID string, params magic_network_monitoring.RuleDeleteParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) +- client.MagicNetworkMonitoring.Rules.Edit(ctx context.Context, ruleID string, params magic_network_monitoring.RuleEditParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) - client.MagicNetworkMonitoring.Rules.Get(ctx context.Context, ruleID string, query magic_network_monitoring.RuleGetParams) (magic_network_monitoring.MagicNetworkMonitoringRule, error) ### Advertisements Response Types: -- magic_network_monitoring.MagicNetworkMonitoringRuleAdvertisable +- magic_network_monitoring.Advertisement Methods: -- client.MagicNetworkMonitoring.Rules.Advertisements.Edit(ctx context.Context, ruleID string, body magic_network_monitoring.RuleAdvertisementEditParams) (magic_network_monitoring.MagicNetworkMonitoringRuleAdvertisable, error) +- client.MagicNetworkMonitoring.Rules.Advertisements.Edit(ctx context.Context, ruleID string, params magic_network_monitoring.RuleAdvertisementEditParams) (magic_network_monitoring.Advertisement, error) # MTLSCertificates Response Types: - mtls_certificates.MTLSCertificate -- mtls_certificates.MTLSCertificateUpdate +- mtls_certificates.MTLSCertificateNewResponse Methods: -- client.MTLSCertificates.New(ctx context.Context, params mtls_certificates.MTLSCertificateNewParams) (mtls_certificates.MTLSCertificateUpdate, error) +- client.MTLSCertificates.New(ctx context.Context, params mtls_certificates.MTLSCertificateNewParams) (mtls_certificates.MTLSCertificateNewResponse, error) - client.MTLSCertificates.List(ctx context.Context, query mtls_certificates.MTLSCertificateListParams) (pagination.SinglePage[mtls_certificates.MTLSCertificate], error) -- client.MTLSCertificates.Delete(ctx context.Context, mtlsCertificateID string, body mtls_certificates.MTLSCertificateDeleteParams) (mtls_certificates.MTLSCertificate, error) +- client.MTLSCertificates.Delete(ctx context.Context, mtlsCertificateID string, params mtls_certificates.MTLSCertificateDeleteParams) (mtls_certificates.MTLSCertificate, error) - client.MTLSCertificates.Get(ctx context.Context, mtlsCertificateID string, query mtls_certificates.MTLSCertificateGetParams) (mtls_certificates.MTLSCertificate, error) ## Associations Response Types: -- mtls_certificates.MTLSCertificateAsssociation +- mtls_certificates.CertificateAsssociation Methods: -- client.MTLSCertificates.Associations.Get(ctx context.Context, mtlsCertificateID string, query mtls_certificates.AssociationGetParams) ([]mtls_certificates.MTLSCertificateAsssociation, error) +- client.MTLSCertificates.Associations.Get(ctx context.Context, mtlsCertificateID string, query mtls_certificates.AssociationGetParams) ([]mtls_certificates.CertificateAsssociation, error) # Pages @@ -3622,24 +3748,27 @@ Methods: Params Types: -- pages.PagesDeploymentsParam +- pages.DeploymentParam +- pages.ProjectParam +- pages.StageParam Response Types: -- pages.PagesDeployments -- pages.PagesProjects -- pages.ProjectNewResponse +- pages.Deployment +- pages.Project +- pages.Stage +- pages.ProjectNewResponseUnion - pages.ProjectDeleteResponse -- pages.ProjectEditResponse +- pages.ProjectEditResponseUnion - pages.ProjectPurgeBuildCacheResponse Methods: -- client.Pages.Projects.New(ctx context.Context, params pages.ProjectNewParams) (pages.ProjectNewResponse, error) -- client.Pages.Projects.List(ctx context.Context, query pages.ProjectListParams) (pagination.SinglePage[pages.PagesDeployments], error) -- client.Pages.Projects.Delete(ctx context.Context, projectName string, body pages.ProjectDeleteParams) (pages.ProjectDeleteResponse, error) -- client.Pages.Projects.Edit(ctx context.Context, projectName string, params pages.ProjectEditParams) (pages.ProjectEditResponse, error) -- client.Pages.Projects.Get(ctx context.Context, projectName string, query pages.ProjectGetParams) (pages.PagesProjects, error) +- client.Pages.Projects.New(ctx context.Context, params pages.ProjectNewParams) (pages.ProjectNewResponseUnion, error) +- client.Pages.Projects.List(ctx context.Context, query pages.ProjectListParams) (pagination.SinglePage[pages.Deployment], error) +- client.Pages.Projects.Delete(ctx context.Context, projectName string, params pages.ProjectDeleteParams) (pages.ProjectDeleteResponse, error) +- client.Pages.Projects.Edit(ctx context.Context, projectName string, params pages.ProjectEditParams) (pages.ProjectEditResponseUnion, error) +- client.Pages.Projects.Get(ctx context.Context, projectName string, query pages.ProjectGetParams) (pages.Project, error) - client.Pages.Projects.PurgeBuildCache(ctx context.Context, projectName string, body pages.ProjectPurgeBuildCacheParams) (pages.ProjectPurgeBuildCacheResponse, error) ### Deployments @@ -3650,12 +3779,12 @@ Response Types: Methods: -- client.Pages.Projects.Deployments.New(ctx context.Context, projectName string, params pages.ProjectDeploymentNewParams) (pages.PagesDeployments, error) -- client.Pages.Projects.Deployments.List(ctx context.Context, projectName string, params pages.ProjectDeploymentListParams) (pagination.SinglePage[pages.PagesDeployments], error) -- client.Pages.Projects.Deployments.Delete(ctx context.Context, projectName string, deploymentID string, body pages.ProjectDeploymentDeleteParams) (pages.ProjectDeploymentDeleteResponse, error) -- client.Pages.Projects.Deployments.Get(ctx context.Context, projectName string, deploymentID string, query pages.ProjectDeploymentGetParams) (pages.PagesDeployments, error) -- client.Pages.Projects.Deployments.Retry(ctx context.Context, projectName string, deploymentID string, body pages.ProjectDeploymentRetryParams) (pages.PagesDeployments, error) -- client.Pages.Projects.Deployments.Rollback(ctx context.Context, projectName string, deploymentID string, body pages.ProjectDeploymentRollbackParams) (pages.PagesDeployments, error) +- client.Pages.Projects.Deployments.New(ctx context.Context, projectName string, params pages.ProjectDeploymentNewParams) (pages.Deployment, error) +- client.Pages.Projects.Deployments.List(ctx context.Context, projectName string, params pages.ProjectDeploymentListParams) (pagination.SinglePage[pages.Deployment], error) +- client.Pages.Projects.Deployments.Delete(ctx context.Context, projectName string, deploymentID string, params pages.ProjectDeploymentDeleteParams) (pages.ProjectDeploymentDeleteResponse, error) +- client.Pages.Projects.Deployments.Get(ctx context.Context, projectName string, deploymentID string, query pages.ProjectDeploymentGetParams) (pages.Deployment, error) +- client.Pages.Projects.Deployments.Retry(ctx context.Context, projectName string, deploymentID string, params pages.ProjectDeploymentRetryParams) (pages.Deployment, error) +- client.Pages.Projects.Deployments.Rollback(ctx context.Context, projectName string, deploymentID string, params pages.ProjectDeploymentRollbackParams) (pages.Deployment, error) #### History @@ -3663,34 +3792,40 @@ Methods: Response Types: -- pages.ProjectDeploymentHistoryLogGetResponse +- pages.ProjectDeploymentHistoryLogGetResponseUnion Methods: -- client.Pages.Projects.Deployments.History.Logs.Get(ctx context.Context, projectName string, deploymentID string, query pages.ProjectDeploymentHistoryLogGetParams) (pages.ProjectDeploymentHistoryLogGetResponse, error) +- client.Pages.Projects.Deployments.History.Logs.Get(ctx context.Context, projectName string, deploymentID string, query pages.ProjectDeploymentHistoryLogGetParams) (pages.ProjectDeploymentHistoryLogGetResponseUnion, error) ### Domains Response Types: -- pages.ProjectDomainNewResponse +- pages.ProjectDomainNewResponseUnion - pages.ProjectDomainListResponse - pages.ProjectDomainDeleteResponse -- pages.ProjectDomainEditResponse -- pages.ProjectDomainGetResponse +- pages.ProjectDomainEditResponseUnion +- pages.ProjectDomainGetResponseUnion Methods: -- client.Pages.Projects.Domains.New(ctx context.Context, projectName string, params pages.ProjectDomainNewParams) (pages.ProjectDomainNewResponse, error) +- client.Pages.Projects.Domains.New(ctx context.Context, projectName string, params pages.ProjectDomainNewParams) (pages.ProjectDomainNewResponseUnion, error) - client.Pages.Projects.Domains.List(ctx context.Context, projectName string, query pages.ProjectDomainListParams) (pagination.SinglePage[pages.ProjectDomainListResponse], error) -- client.Pages.Projects.Domains.Delete(ctx context.Context, projectName string, domainName string, body pages.ProjectDomainDeleteParams) (pages.ProjectDomainDeleteResponse, error) -- client.Pages.Projects.Domains.Edit(ctx context.Context, projectName string, domainName string, body pages.ProjectDomainEditParams) (pages.ProjectDomainEditResponse, error) -- client.Pages.Projects.Domains.Get(ctx context.Context, projectName string, domainName string, query pages.ProjectDomainGetParams) (pages.ProjectDomainGetResponse, error) +- client.Pages.Projects.Domains.Delete(ctx context.Context, projectName string, domainName string, params pages.ProjectDomainDeleteParams) (pages.ProjectDomainDeleteResponse, error) +- client.Pages.Projects.Domains.Edit(ctx context.Context, projectName string, domainName string, params pages.ProjectDomainEditParams) (pages.ProjectDomainEditResponseUnion, error) +- client.Pages.Projects.Domains.Get(ctx context.Context, projectName string, domainName string, query pages.ProjectDomainGetParams) (pages.ProjectDomainGetResponseUnion, error) # PCAPs +Params Types: + +- pcaps.PCAPFilterParam + Response Types: +- pcaps.PCAP +- pcaps.PCAPFilter - pcaps.PCAPNewResponse - pcaps.PCAPListResponse - pcaps.PCAPGetResponse @@ -3705,14 +3840,14 @@ Methods: Response Types: -- pcaps.MagicVisibilityPCAPsOwnership +- pcaps.Ownership Methods: -- client.PCAPs.Ownership.New(ctx context.Context, params pcaps.OwnershipNewParams) (pcaps.MagicVisibilityPCAPsOwnership, error) +- client.PCAPs.Ownership.New(ctx context.Context, params pcaps.OwnershipNewParams) (pcaps.Ownership, error) - client.PCAPs.Ownership.Delete(ctx context.Context, ownershipID string, body pcaps.OwnershipDeleteParams) error -- client.PCAPs.Ownership.Get(ctx context.Context, query pcaps.OwnershipGetParams) ([]pcaps.MagicVisibilityPCAPsOwnership, error) -- client.PCAPs.Ownership.Validate(ctx context.Context, params pcaps.OwnershipValidateParams) (pcaps.MagicVisibilityPCAPsOwnership, error) +- client.PCAPs.Ownership.Get(ctx context.Context, query pcaps.OwnershipGetParams) ([]pcaps.Ownership, error) +- client.PCAPs.Ownership.Validate(ctx context.Context, params pcaps.OwnershipValidateParams) (pcaps.Ownership, error) ## Download @@ -3726,15 +3861,15 @@ Methods: Response Types: -- registrar.DomainUpdateResponse -- registrar.DomainListResponse -- registrar.DomainGetResponse +- registrar.Domain +- registrar.DomainUpdateResponseUnion +- registrar.DomainGetResponseUnion Methods: -- client.Registrar.Domains.Update(ctx context.Context, domainName string, params registrar.DomainUpdateParams) (registrar.DomainUpdateResponse, error) -- client.Registrar.Domains.List(ctx context.Context, query registrar.DomainListParams) (pagination.SinglePage[registrar.DomainListResponse], error) -- client.Registrar.Domains.Get(ctx context.Context, domainName string, query registrar.DomainGetParams) (registrar.DomainGetResponse, error) +- client.Registrar.Domains.Update(ctx context.Context, domainName string, params registrar.DomainUpdateParams) (registrar.DomainUpdateResponseUnion, error) +- client.Registrar.Domains.List(ctx context.Context, query registrar.DomainListParams) (pagination.SinglePage[registrar.Domain], error) +- client.Registrar.Domains.Get(ctx context.Context, domainName string, query registrar.DomainGetParams) (registrar.DomainGetResponseUnion, error) # RequestTracers @@ -3748,15 +3883,22 @@ Response Types: Methods: -- client.RequestTracers.Traces.New(ctx context.Context, accountIdentifier string, body request_tracers.TraceNewParams) (request_tracers.TraceNewResponse, error) +- client.RequestTracers.Traces.New(ctx context.Context, params request_tracers.TraceNewParams) (request_tracers.TraceNewResponse, error) # Rules ## Lists +Params Types: + +- rules.HostnameParam +- rules.RedirectParam + Response Types: +- rules.Hostname - rules.ListsList +- rules.Redirect - rules.ListNewResponse - rules.ListUpdateResponse - rules.ListDeleteResponse @@ -3767,7 +3909,7 @@ Methods: - client.Rules.Lists.New(ctx context.Context, params rules.ListNewParams) (rules.ListsList, error) - client.Rules.Lists.Update(ctx context.Context, listID string, params rules.ListUpdateParams) (rules.ListsList, error) - client.Rules.Lists.List(ctx context.Context, query rules.ListListParams) (pagination.SinglePage[rules.ListsList], error) -- client.Rules.Lists.Delete(ctx context.Context, listID string, body rules.ListDeleteParams) (rules.ListDeleteResponse, error) +- client.Rules.Lists.Delete(ctx context.Context, listID string, params rules.ListDeleteParams) (rules.ListDeleteResponse, error) - client.Rules.Lists.Get(ctx context.Context, listID string, query rules.ListGetParams) (rules.ListsList, error) ### BulkOperations @@ -3784,11 +3926,13 @@ Methods: Response Types: +- rules.ListCursor +- rules.ListItem - rules.ListItemNewResponse - rules.ListItemUpdateResponse - rules.ListItemListResponse - rules.ListItemDeleteResponse -- rules.ListItemGetResponse +- rules.ListItemGetResponseUnion Methods: @@ -3796,7 +3940,7 @@ Methods: - client.Rules.Lists.Items.Update(ctx context.Context, listID string, params rules.ListItemUpdateParams) (rules.ListItemUpdateResponse, error) - client.Rules.Lists.Items.List(ctx context.Context, listID string, params rules.ListItemListParams) (pagination.CursorPagination[rules.ListItemListResponse], error) - client.Rules.Lists.Items.Delete(ctx context.Context, listID string, params rules.ListItemDeleteParams) (rules.ListItemDeleteResponse, error) -- client.Rules.Lists.Items.Get(ctx context.Context, accountIdentifier string, listID string, itemID string) (rules.ListItemGetResponse, error) +- client.Rules.Lists.Items.Get(ctx context.Context, accountIdentifier string, listID string, itemID string) (rules.ListItemGetResponseUnion, error) # Storage @@ -3804,40 +3948,45 @@ Methods: Response Types: -- storage.WorkersKVComponentsSchemasResult -- storage.WorkersKVSchemasResult +- storage.Components +- storage.Schema Methods: -- client.Storage.Analytics.List(ctx context.Context, params storage.AnalyticsListParams) (storage.WorkersKVSchemasResult, error) -- client.Storage.Analytics.Stored(ctx context.Context, params storage.AnalyticsStoredParams) (storage.WorkersKVComponentsSchemasResult, error) +- client.Storage.Analytics.List(ctx context.Context, params storage.AnalyticsListParams) (storage.Schema, error) +- client.Storage.Analytics.Stored(ctx context.Context, params storage.AnalyticsStoredParams) (storage.Components, error) # Stream +Params Types: + +- stream.AllowedOriginsParam + Response Types: -- stream.StreamVideos +- stream.AllowedOrigins +- stream.Video Methods: - client.Stream.New(ctx context.Context, params stream.StreamNewParams) error -- client.Stream.List(ctx context.Context, params stream.StreamListParams) (pagination.SinglePage[stream.StreamVideos], error) -- client.Stream.Delete(ctx context.Context, identifier string, body stream.StreamDeleteParams) error -- client.Stream.Get(ctx context.Context, identifier string, query stream.StreamGetParams) (stream.StreamVideos, error) +- client.Stream.List(ctx context.Context, params stream.StreamListParams) (pagination.SinglePage[stream.Video], error) +- client.Stream.Delete(ctx context.Context, identifier string, params stream.StreamDeleteParams) error +- client.Stream.Get(ctx context.Context, identifier string, query stream.StreamGetParams) (stream.Video, error) ## AudioTracks Response Types: -- stream.StreamAudio -- stream.AudioTrackDeleteResponse +- stream.Audio +- stream.AudioTrackDeleteResponseUnion Methods: -- client.Stream.AudioTracks.Delete(ctx context.Context, identifier string, audioIdentifier string, body stream.AudioTrackDeleteParams) (stream.AudioTrackDeleteResponse, error) -- client.Stream.AudioTracks.Copy(ctx context.Context, identifier string, params stream.AudioTrackCopyParams) (stream.StreamAudio, error) -- client.Stream.AudioTracks.Edit(ctx context.Context, identifier string, audioIdentifier string, params stream.AudioTrackEditParams) (stream.StreamAudio, error) -- client.Stream.AudioTracks.Get(ctx context.Context, identifier string, query stream.AudioTrackGetParams) ([]stream.StreamAudio, error) +- client.Stream.AudioTracks.Delete(ctx context.Context, identifier string, audioIdentifier string, body stream.AudioTrackDeleteParams) (stream.AudioTrackDeleteResponseUnion, error) +- client.Stream.AudioTracks.Copy(ctx context.Context, identifier string, params stream.AudioTrackCopyParams) (stream.Audio, error) +- client.Stream.AudioTracks.Edit(ctx context.Context, identifier string, audioIdentifier string, params stream.AudioTrackEditParams) (stream.Audio, error) +- client.Stream.AudioTracks.Get(ctx context.Context, identifier string, query stream.AudioTrackGetParams) ([]stream.Audio, error) ## Videos @@ -3853,17 +4002,17 @@ Methods: Response Types: -- stream.StreamClipping +- stream.Clip Methods: -- client.Stream.Clip.New(ctx context.Context, params stream.ClipNewParams) (stream.StreamClipping, error) +- client.Stream.Clip.New(ctx context.Context, params stream.ClipNewParams) (stream.Clip, error) ## Copy Methods: -- client.Stream.Copy.New(ctx context.Context, params stream.CopyNewParams) (stream.StreamVideos, error) +- client.Stream.Copy.New(ctx context.Context, params stream.CopyNewParams) (stream.Video, error) ## DirectUpload @@ -3879,101 +4028,101 @@ Methods: Response Types: -- stream.StreamKeys -- stream.KeyDeleteResponse +- stream.Keys +- stream.KeyDeleteResponseUnion - stream.KeyGetResponse Methods: -- client.Stream.Keys.New(ctx context.Context, body stream.KeyNewParams) (stream.StreamKeys, error) -- client.Stream.Keys.Delete(ctx context.Context, identifier string, body stream.KeyDeleteParams) (stream.KeyDeleteResponse, error) +- client.Stream.Keys.New(ctx context.Context, params stream.KeyNewParams) (stream.Keys, error) +- client.Stream.Keys.Delete(ctx context.Context, identifier string, params stream.KeyDeleteParams) (stream.KeyDeleteResponseUnion, error) - client.Stream.Keys.Get(ctx context.Context, query stream.KeyGetParams) ([]stream.KeyGetResponse, error) ## LiveInputs Response Types: -- stream.StreamLiveInput +- stream.LiveInput - stream.LiveInputListResponse Methods: -- client.Stream.LiveInputs.New(ctx context.Context, params stream.LiveInputNewParams) (stream.StreamLiveInput, error) -- client.Stream.LiveInputs.Update(ctx context.Context, liveInputIdentifier string, params stream.LiveInputUpdateParams) (stream.StreamLiveInput, error) +- client.Stream.LiveInputs.New(ctx context.Context, params stream.LiveInputNewParams) (stream.LiveInput, error) +- client.Stream.LiveInputs.Update(ctx context.Context, liveInputIdentifier string, params stream.LiveInputUpdateParams) (stream.LiveInput, error) - client.Stream.LiveInputs.List(ctx context.Context, params stream.LiveInputListParams) (stream.LiveInputListResponse, error) -- client.Stream.LiveInputs.Delete(ctx context.Context, liveInputIdentifier string, body stream.LiveInputDeleteParams) error -- client.Stream.LiveInputs.Get(ctx context.Context, liveInputIdentifier string, query stream.LiveInputGetParams) (stream.StreamLiveInput, error) +- client.Stream.LiveInputs.Delete(ctx context.Context, liveInputIdentifier string, params stream.LiveInputDeleteParams) error +- client.Stream.LiveInputs.Get(ctx context.Context, liveInputIdentifier string, query stream.LiveInputGetParams) (stream.LiveInput, error) ### Outputs Response Types: -- stream.StreamOutput +- stream.Output Methods: -- client.Stream.LiveInputs.Outputs.New(ctx context.Context, liveInputIdentifier string, params stream.LiveInputOutputNewParams) (stream.StreamOutput, error) -- client.Stream.LiveInputs.Outputs.Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params stream.LiveInputOutputUpdateParams) (stream.StreamOutput, error) -- client.Stream.LiveInputs.Outputs.List(ctx context.Context, liveInputIdentifier string, query stream.LiveInputOutputListParams) (pagination.SinglePage[stream.StreamOutput], error) -- client.Stream.LiveInputs.Outputs.Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, body stream.LiveInputOutputDeleteParams) error +- client.Stream.LiveInputs.Outputs.New(ctx context.Context, liveInputIdentifier string, params stream.LiveInputOutputNewParams) (stream.Output, error) +- client.Stream.LiveInputs.Outputs.Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params stream.LiveInputOutputUpdateParams) (stream.Output, error) +- client.Stream.LiveInputs.Outputs.List(ctx context.Context, liveInputIdentifier string, query stream.LiveInputOutputListParams) (pagination.SinglePage[stream.Output], error) +- client.Stream.LiveInputs.Outputs.Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params stream.LiveInputOutputDeleteParams) error ## Watermarks Response Types: -- stream.StreamWatermarks -- stream.WatermarkNewResponse -- stream.WatermarkDeleteResponse -- stream.WatermarkGetResponse +- stream.Watermaks +- stream.WatermarkNewResponseUnion +- stream.WatermarkDeleteResponseUnion +- stream.WatermarkGetResponseUnion Methods: -- client.Stream.Watermarks.New(ctx context.Context, params stream.WatermarkNewParams) (stream.WatermarkNewResponse, error) -- client.Stream.Watermarks.List(ctx context.Context, query stream.WatermarkListParams) (pagination.SinglePage[stream.StreamWatermarks], error) -- client.Stream.Watermarks.Delete(ctx context.Context, identifier string, body stream.WatermarkDeleteParams) (stream.WatermarkDeleteResponse, error) -- client.Stream.Watermarks.Get(ctx context.Context, identifier string, query stream.WatermarkGetParams) (stream.WatermarkGetResponse, error) +- client.Stream.Watermarks.New(ctx context.Context, params stream.WatermarkNewParams) (stream.WatermarkNewResponseUnion, error) +- client.Stream.Watermarks.List(ctx context.Context, query stream.WatermarkListParams) (pagination.SinglePage[stream.Watermaks], error) +- client.Stream.Watermarks.Delete(ctx context.Context, identifier string, params stream.WatermarkDeleteParams) (stream.WatermarkDeleteResponseUnion, error) +- client.Stream.Watermarks.Get(ctx context.Context, identifier string, query stream.WatermarkGetParams) (stream.WatermarkGetResponseUnion, error) ## Webhooks Response Types: -- stream.WebhookUpdateResponse -- stream.WebhookDeleteResponse -- stream.WebhookGetResponse +- stream.WebhookUpdateResponseUnion +- stream.WebhookDeleteResponseUnion +- stream.WebhookGetResponseUnion Methods: -- client.Stream.Webhooks.Update(ctx context.Context, params stream.WebhookUpdateParams) (stream.WebhookUpdateResponse, error) -- client.Stream.Webhooks.Delete(ctx context.Context, body stream.WebhookDeleteParams) (stream.WebhookDeleteResponse, error) -- client.Stream.Webhooks.Get(ctx context.Context, query stream.WebhookGetParams) (stream.WebhookGetResponse, error) +- client.Stream.Webhooks.Update(ctx context.Context, params stream.WebhookUpdateParams) (stream.WebhookUpdateResponseUnion, error) +- client.Stream.Webhooks.Delete(ctx context.Context, params stream.WebhookDeleteParams) (stream.WebhookDeleteResponseUnion, error) +- client.Stream.Webhooks.Get(ctx context.Context, query stream.WebhookGetParams) (stream.WebhookGetResponseUnion, error) ## Captions Response Types: -- stream.StreamCaptions -- stream.CaptionUpdateResponse -- stream.CaptionDeleteResponse +- stream.Caption +- stream.CaptionUpdateResponseUnion +- stream.CaptionDeleteResponseUnion Methods: -- client.Stream.Captions.Update(ctx context.Context, identifier string, language string, params stream.CaptionUpdateParams) (stream.CaptionUpdateResponse, error) -- client.Stream.Captions.Delete(ctx context.Context, identifier string, language string, body stream.CaptionDeleteParams) (stream.CaptionDeleteResponse, error) -- client.Stream.Captions.Get(ctx context.Context, identifier string, query stream.CaptionGetParams) ([]stream.StreamCaptions, error) +- client.Stream.Captions.Update(ctx context.Context, identifier string, language string, params stream.CaptionUpdateParams) (stream.CaptionUpdateResponseUnion, error) +- client.Stream.Captions.Delete(ctx context.Context, identifier string, language string, params stream.CaptionDeleteParams) (stream.CaptionDeleteResponseUnion, error) +- client.Stream.Captions.Get(ctx context.Context, identifier string, query stream.CaptionGetParams) ([]stream.Caption, error) ## Downloads Response Types: -- stream.DownloadNewResponse -- stream.DownloadDeleteResponse -- stream.DownloadGetResponse +- stream.DownloadNewResponseUnion +- stream.DownloadDeleteResponseUnion +- stream.DownloadGetResponseUnion Methods: -- client.Stream.Downloads.New(ctx context.Context, identifier string, body stream.DownloadNewParams) (stream.DownloadNewResponse, error) -- client.Stream.Downloads.Delete(ctx context.Context, identifier string, body stream.DownloadDeleteParams) (stream.DownloadDeleteResponse, error) -- client.Stream.Downloads.Get(ctx context.Context, identifier string, query stream.DownloadGetParams) (stream.DownloadGetResponse, error) +- client.Stream.Downloads.New(ctx context.Context, identifier string, params stream.DownloadNewParams) (stream.DownloadNewResponseUnion, error) +- client.Stream.Downloads.Delete(ctx context.Context, identifier string, body stream.DownloadDeleteParams) (stream.DownloadDeleteResponseUnion, error) +- client.Stream.Downloads.Get(ctx context.Context, identifier string, query stream.DownloadGetParams) (stream.DownloadGetResponseUnion, error) ## Embed @@ -3997,11 +4146,11 @@ Methods: Response Types: -- alerting.AvailableAlertListResponse +- alerting.AvailableAlertListResponseUnion Methods: -- client.Alerting.AvailableAlerts.List(ctx context.Context, query alerting.AvailableAlertListParams) (alerting.AvailableAlertListResponse, error) +- client.Alerting.AvailableAlerts.List(ctx context.Context, query alerting.AvailableAlertListParams) (alerting.AvailableAlertListResponseUnion, error) ## Destinations @@ -4009,90 +4158,102 @@ Methods: Response Types: -- alerting.DestinationEligibleGetResponse +- alerting.DestinationEligibleGetResponseUnion Methods: -- client.Alerting.Destinations.Eligible.Get(ctx context.Context, query alerting.DestinationEligibleGetParams) (alerting.DestinationEligibleGetResponse, error) +- client.Alerting.Destinations.Eligible.Get(ctx context.Context, query alerting.DestinationEligibleGetParams) (alerting.DestinationEligibleGetResponseUnion, error) ### Pagerduty Response Types: -- alerting.AlertingPagerduty +- alerting.Pagerduty - alerting.DestinationPagerdutyNewResponse -- alerting.DestinationPagerdutyDeleteResponse +- alerting.DestinationPagerdutyDeleteResponseUnion - alerting.DestinationPagerdutyLinkResponse Methods: - client.Alerting.Destinations.Pagerduty.New(ctx context.Context, body alerting.DestinationPagerdutyNewParams) (alerting.DestinationPagerdutyNewResponse, error) -- client.Alerting.Destinations.Pagerduty.Delete(ctx context.Context, body alerting.DestinationPagerdutyDeleteParams) (alerting.DestinationPagerdutyDeleteResponse, error) -- client.Alerting.Destinations.Pagerduty.Get(ctx context.Context, query alerting.DestinationPagerdutyGetParams) ([]alerting.AlertingPagerduty, error) +- client.Alerting.Destinations.Pagerduty.Delete(ctx context.Context, body alerting.DestinationPagerdutyDeleteParams) (alerting.DestinationPagerdutyDeleteResponseUnion, error) +- client.Alerting.Destinations.Pagerduty.Get(ctx context.Context, query alerting.DestinationPagerdutyGetParams) ([]alerting.Pagerduty, error) - client.Alerting.Destinations.Pagerduty.Link(ctx context.Context, tokenID string, query alerting.DestinationPagerdutyLinkParams) (alerting.DestinationPagerdutyLinkResponse, error) ### Webhooks Response Types: -- alerting.AlertingWebhooks +- alerting.Webhooks - alerting.DestinationWebhookNewResponse - alerting.DestinationWebhookUpdateResponse -- alerting.DestinationWebhookDeleteResponse +- alerting.DestinationWebhookDeleteResponseUnion Methods: - client.Alerting.Destinations.Webhooks.New(ctx context.Context, params alerting.DestinationWebhookNewParams) (alerting.DestinationWebhookNewResponse, error) - client.Alerting.Destinations.Webhooks.Update(ctx context.Context, webhookID string, params alerting.DestinationWebhookUpdateParams) (alerting.DestinationWebhookUpdateResponse, error) -- client.Alerting.Destinations.Webhooks.List(ctx context.Context, query alerting.DestinationWebhookListParams) (pagination.SinglePage[alerting.AlertingWebhooks], error) -- client.Alerting.Destinations.Webhooks.Delete(ctx context.Context, webhookID string, body alerting.DestinationWebhookDeleteParams) (alerting.DestinationWebhookDeleteResponse, error) -- client.Alerting.Destinations.Webhooks.Get(ctx context.Context, webhookID string, query alerting.DestinationWebhookGetParams) (alerting.AlertingWebhooks, error) +- client.Alerting.Destinations.Webhooks.List(ctx context.Context, query alerting.DestinationWebhookListParams) (pagination.SinglePage[alerting.Webhooks], error) +- client.Alerting.Destinations.Webhooks.Delete(ctx context.Context, webhookID string, body alerting.DestinationWebhookDeleteParams) (alerting.DestinationWebhookDeleteResponseUnion, error) +- client.Alerting.Destinations.Webhooks.Get(ctx context.Context, webhookID string, query alerting.DestinationWebhookGetParams) (alerting.Webhooks, error) ## History Response Types: -- alerting.AlertingHistory +- alerting.History Methods: -- client.Alerting.History.List(ctx context.Context, params alerting.HistoryListParams) (pagination.V4PagePaginationArray[alerting.AlertingHistory], error) +- client.Alerting.History.List(ctx context.Context, params alerting.HistoryListParams) (pagination.V4PagePaginationArray[alerting.History], error) ## Policies +Params Types: + +- alerting.MechanismParam +- alerting.PolicyParam +- alerting.PolicyFilterParam + Response Types: -- alerting.AlertingPolicies +- alerting.Mechanism +- alerting.Policy +- alerting.PolicyFilter - alerting.PolicyNewResponse - alerting.PolicyUpdateResponse -- alerting.PolicyDeleteResponse +- alerting.PolicyDeleteResponseUnion Methods: - client.Alerting.Policies.New(ctx context.Context, params alerting.PolicyNewParams) (alerting.PolicyNewResponse, error) - client.Alerting.Policies.Update(ctx context.Context, policyID string, params alerting.PolicyUpdateParams) (alerting.PolicyUpdateResponse, error) -- client.Alerting.Policies.List(ctx context.Context, query alerting.PolicyListParams) (pagination.SinglePage[alerting.AlertingPolicies], error) -- client.Alerting.Policies.Delete(ctx context.Context, policyID string, body alerting.PolicyDeleteParams) (alerting.PolicyDeleteResponse, error) -- client.Alerting.Policies.Get(ctx context.Context, policyID string, query alerting.PolicyGetParams) (alerting.AlertingPolicies, error) +- client.Alerting.Policies.List(ctx context.Context, query alerting.PolicyListParams) (pagination.SinglePage[alerting.Policy], error) +- client.Alerting.Policies.Delete(ctx context.Context, policyID string, body alerting.PolicyDeleteParams) (alerting.PolicyDeleteResponseUnion, error) +- client.Alerting.Policies.Get(ctx context.Context, policyID string, query alerting.PolicyGetParams) (alerting.Policy, error) # D1 +Response Types: + +- d1.D1 + ## Database Response Types: -- d1.D1CreateDatabase -- d1.D1DatabaseDetails -- d1.D1QueryResult -- d1.DatabaseDeleteResponse +- d1.QueryResult +- d1.DatabaseNewResponse +- d1.DatabaseListResponse +- d1.DatabaseDeleteResponseUnion Methods: -- client.D1.Database.New(ctx context.Context, params d1.DatabaseNewParams) (d1.D1CreateDatabase, error) -- client.D1.Database.List(ctx context.Context, params d1.DatabaseListParams) (pagination.V4PagePaginationArray[d1.D1CreateDatabase], error) -- client.D1.Database.Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string) (d1.DatabaseDeleteResponse, error) -- client.D1.Database.Get(ctx context.Context, accountIdentifier string, databaseIdentifier string) (d1.D1DatabaseDetails, error) -- client.D1.Database.Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body d1.DatabaseQueryParams) ([]d1.D1QueryResult, error) +- client.D1.Database.New(ctx context.Context, params d1.DatabaseNewParams) (d1.DatabaseNewResponse, error) +- client.D1.Database.List(ctx context.Context, params d1.DatabaseListParams) (pagination.V4PagePaginationArray[d1.DatabaseListResponse], error) +- client.D1.Database.Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string) (d1.DatabaseDeleteResponseUnion, error) +- client.D1.Database.Get(ctx context.Context, accountIdentifier string, databaseIdentifier string) (d1.D1, error) +- client.D1.Database.Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body d1.DatabaseQueryParams) ([]d1.QueryResult, error) # R2 @@ -4100,28 +4261,33 @@ Methods: Response Types: -- r2.R2Bucket +- r2.Bucket - r2.BucketDeleteResponse Methods: -- client.R2.Buckets.New(ctx context.Context, params r2.BucketNewParams) (r2.R2Bucket, error) -- client.R2.Buckets.List(ctx context.Context, params r2.BucketListParams) (pagination.CursorPagination[r2.R2Bucket], error) +- client.R2.Buckets.New(ctx context.Context, params r2.BucketNewParams) (r2.Bucket, error) +- client.R2.Buckets.List(ctx context.Context, params r2.BucketListParams) (pagination.CursorPagination[r2.Bucket], error) - client.R2.Buckets.Delete(ctx context.Context, bucketName string, body r2.BucketDeleteParams) (r2.BucketDeleteResponse, error) -- client.R2.Buckets.Get(ctx context.Context, bucketName string, query r2.BucketGetParams) (r2.R2Bucket, error) +- client.R2.Buckets.Get(ctx context.Context, bucketName string, query r2.BucketGetParams) (r2.Bucket, error) ## Sippy +Params Types: + +- r2.Provider + Response Types: -- r2.R2Sippy +- r2.Provider +- r2.Sippy - r2.SippyDeleteResponse Methods: -- client.R2.Sippy.Update(ctx context.Context, bucketName string, params r2.SippyUpdateParams) (r2.R2Sippy, error) +- client.R2.Sippy.Update(ctx context.Context, bucketName string, params r2.SippyUpdateParams) (r2.Sippy, error) - client.R2.Sippy.Delete(ctx context.Context, bucketName string, body r2.SippyDeleteParams) (r2.SippyDeleteResponse, error) -- client.R2.Sippy.Get(ctx context.Context, bucketName string, query r2.SippyGetParams) (r2.R2Sippy, error) +- client.R2.Sippy.Get(ctx context.Context, bucketName string, query r2.SippyGetParams) (r2.Sippy, error) # WARPConnector @@ -4132,7 +4298,7 @@ Response Types: - warp_connector.WARPConnectorDeleteResponse - warp_connector.WARPConnectorEditResponse - warp_connector.WARPConnectorGetResponse -- warp_connector.WARPConnectorTokenResponse +- warp_connector.WARPConnectorTokenResponseUnion Methods: @@ -4141,7 +4307,7 @@ Methods: - client.WARPConnector.Delete(ctx context.Context, tunnelID string, params warp_connector.WARPConnectorDeleteParams) (warp_connector.WARPConnectorDeleteResponse, error) - client.WARPConnector.Edit(ctx context.Context, tunnelID string, params warp_connector.WARPConnectorEditParams) (warp_connector.WARPConnectorEditResponse, error) - client.WARPConnector.Get(ctx context.Context, tunnelID string, query warp_connector.WARPConnectorGetParams) (warp_connector.WARPConnectorGetResponse, error) -- client.WARPConnector.Token(ctx context.Context, tunnelID string, query warp_connector.WARPConnectorTokenParams) (warp_connector.WARPConnectorTokenResponse, error) +- client.WARPConnector.Token(ctx context.Context, tunnelID string, query warp_connector.WARPConnectorTokenParams) (warp_connector.WARPConnectorTokenResponseUnion, error) # WorkersForPlatforms @@ -4167,19 +4333,19 @@ Methods: Response Types: -- workers_for_platforms.WorkersForPlatformsNamespaceScript +- workers_for_platforms.Script Methods: -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptUpdateParams) (workers.WorkersScript, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptUpdateParams) (workers.Script, error) - client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Delete(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptDeleteParams) error -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptGetParams) (workers_for_platforms.WorkersForPlatformsNamespaceScript, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptGetParams) (workers_for_platforms.Script, error) ##### Content Methods: -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptContentUpdateParams) (workers.WorkersScript, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptContentUpdateParams) (workers.Script, error) - client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptContentGetParams) (http.Response, error) ##### Settings @@ -4196,13 +4362,33 @@ Methods: ##### Bindings +Methods: + +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Bindings.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptBindingGetParams) ([]workers.Binding, error) + +##### Secrets + +Response Types: + +- workers_for_platforms.DispatchNamespaceScriptSecretUpdateResponse +- workers_for_platforms.DispatchNamespaceScriptSecretListResponse + +Methods: + +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Secrets.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptSecretUpdateParams) (workers_for_platforms.DispatchNamespaceScriptSecretUpdateResponse, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Secrets.List(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptSecretListParams) (pagination.SinglePage[workers_for_platforms.DispatchNamespaceScriptSecretListResponse], error) + +##### Tags + Response Types: -- workers_for_platforms.DispatchNamespaceScriptBindingGetResponse +- workers_for_platforms.DispatchNamespaceScriptTagDeleteResponse Methods: -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Bindings.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptBindingGetParams) (workers_for_platforms.DispatchNamespaceScriptBindingGetResponse, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Tags.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptTagUpdateParams) ([]string, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Tags.List(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptTagListParams) (pagination.SinglePage[string], error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Tags.Delete(ctx context.Context, dispatchNamespace string, scriptName string, tag string, body workers_for_platforms.DispatchNamespaceScriptTagDeleteParams) (workers_for_platforms.DispatchNamespaceScriptTagDeleteResponse, error) # ZeroTrust @@ -4210,58 +4396,64 @@ Methods: Response Types: -- zero_trust.ZeroTrustDevices -- zero_trust.DeviceGetResponse +- zero_trust.Device +- zero_trust.DeviceGetResponseUnion Methods: -- client.ZeroTrust.Devices.List(ctx context.Context, query zero_trust.DeviceListParams) (pagination.SinglePage[zero_trust.ZeroTrustDevices], error) -- client.ZeroTrust.Devices.Get(ctx context.Context, deviceID string, query zero_trust.DeviceGetParams) (zero_trust.DeviceGetResponse, error) +- client.ZeroTrust.Devices.List(ctx context.Context, query zero_trust.DeviceListParams) (pagination.SinglePage[zero_trust.Device], error) +- client.ZeroTrust.Devices.Get(ctx context.Context, deviceID string, query zero_trust.DeviceGetParams) (zero_trust.DeviceGetResponseUnion, error) ### DEXTests +Params Types: + +- zero_trust.SchemaDataParam +- zero_trust.SchemaHTTPParam + Response Types: -- zero_trust.DEXTestSchemasHTTP +- zero_trust.SchemaData +- zero_trust.SchemaHTTP Methods: -- client.ZeroTrust.Devices.DEXTests.New(ctx context.Context, params zero_trust.DeviceDEXTestNewParams) (zero_trust.DEXTestSchemasHTTP, error) -- client.ZeroTrust.Devices.DEXTests.Update(ctx context.Context, dexTestID string, params zero_trust.DeviceDEXTestUpdateParams) (zero_trust.DEXTestSchemasHTTP, error) -- client.ZeroTrust.Devices.DEXTests.List(ctx context.Context, query zero_trust.DeviceDEXTestListParams) (pagination.SinglePage[zero_trust.DEXTestSchemasHTTP], error) -- client.ZeroTrust.Devices.DEXTests.Delete(ctx context.Context, dexTestID string, body zero_trust.DeviceDEXTestDeleteParams) ([]zero_trust.DEXTestSchemasHTTP, error) -- client.ZeroTrust.Devices.DEXTests.Get(ctx context.Context, dexTestID string, query zero_trust.DeviceDEXTestGetParams) (zero_trust.DEXTestSchemasHTTP, error) +- client.ZeroTrust.Devices.DEXTests.New(ctx context.Context, params zero_trust.DeviceDEXTestNewParams) (zero_trust.SchemaHTTP, error) +- client.ZeroTrust.Devices.DEXTests.Update(ctx context.Context, dexTestID string, params zero_trust.DeviceDEXTestUpdateParams) (zero_trust.SchemaHTTP, error) +- client.ZeroTrust.Devices.DEXTests.List(ctx context.Context, query zero_trust.DeviceDEXTestListParams) (pagination.SinglePage[zero_trust.SchemaHTTP], error) +- client.ZeroTrust.Devices.DEXTests.Delete(ctx context.Context, dexTestID string, body zero_trust.DeviceDEXTestDeleteParams) ([]zero_trust.SchemaHTTP, error) +- client.ZeroTrust.Devices.DEXTests.Get(ctx context.Context, dexTestID string, query zero_trust.DeviceDEXTestGetParams) (zero_trust.SchemaHTTP, error) ### Networks Response Types: -- zero_trust.DeviceManagedNetworks +- zero_trust.DeviceNetwork Methods: -- client.ZeroTrust.Devices.Networks.New(ctx context.Context, params zero_trust.DeviceNetworkNewParams) (zero_trust.DeviceManagedNetworks, error) -- client.ZeroTrust.Devices.Networks.Update(ctx context.Context, networkID string, params zero_trust.DeviceNetworkUpdateParams) (zero_trust.DeviceManagedNetworks, error) -- client.ZeroTrust.Devices.Networks.List(ctx context.Context, query zero_trust.DeviceNetworkListParams) (pagination.SinglePage[zero_trust.DeviceManagedNetworks], error) -- client.ZeroTrust.Devices.Networks.Delete(ctx context.Context, networkID string, body zero_trust.DeviceNetworkDeleteParams) ([]zero_trust.DeviceManagedNetworks, error) -- client.ZeroTrust.Devices.Networks.Get(ctx context.Context, networkID string, query zero_trust.DeviceNetworkGetParams) (zero_trust.DeviceManagedNetworks, error) +- client.ZeroTrust.Devices.Networks.New(ctx context.Context, params zero_trust.DeviceNetworkNewParams) (zero_trust.DeviceNetwork, error) +- client.ZeroTrust.Devices.Networks.Update(ctx context.Context, networkID string, params zero_trust.DeviceNetworkUpdateParams) (zero_trust.DeviceNetwork, error) +- client.ZeroTrust.Devices.Networks.List(ctx context.Context, query zero_trust.DeviceNetworkListParams) (pagination.SinglePage[zero_trust.DeviceNetwork], error) +- client.ZeroTrust.Devices.Networks.Delete(ctx context.Context, networkID string, params zero_trust.DeviceNetworkDeleteParams) ([]zero_trust.DeviceNetwork, error) +- client.ZeroTrust.Devices.Networks.Get(ctx context.Context, networkID string, query zero_trust.DeviceNetworkGetParams) (zero_trust.DeviceNetwork, error) ### Policies Response Types: -- zero_trust.DevicesDeviceSettingsPolicy +- zero_trust.SettingsPolicy - zero_trust.DevicePolicyNewResponse - zero_trust.DevicePolicyEditResponse - zero_trust.DevicePolicyGetResponse Methods: -- client.ZeroTrust.Devices.Policies.New(ctx context.Context, params zero_trust.DevicePolicyNewParams) (zero_trust.DevicesDeviceSettingsPolicy, error) -- client.ZeroTrust.Devices.Policies.List(ctx context.Context, query zero_trust.DevicePolicyListParams) (pagination.SinglePage[zero_trust.DevicesDeviceSettingsPolicy], error) -- client.ZeroTrust.Devices.Policies.Delete(ctx context.Context, policyID string, body zero_trust.DevicePolicyDeleteParams) ([]zero_trust.DevicesDeviceSettingsPolicy, error) -- client.ZeroTrust.Devices.Policies.Edit(ctx context.Context, policyID string, params zero_trust.DevicePolicyEditParams) (zero_trust.DevicesDeviceSettingsPolicy, error) -- client.ZeroTrust.Devices.Policies.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyGetParams) (zero_trust.DevicesDeviceSettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.New(ctx context.Context, params zero_trust.DevicePolicyNewParams) (zero_trust.SettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.List(ctx context.Context, query zero_trust.DevicePolicyListParams) (pagination.SinglePage[zero_trust.SettingsPolicy], error) +- client.ZeroTrust.Devices.Policies.Delete(ctx context.Context, policyID string, params zero_trust.DevicePolicyDeleteParams) ([]zero_trust.SettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.Edit(ctx context.Context, policyID string, params zero_trust.DevicePolicyEditParams) (zero_trust.SettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyGetParams) (zero_trust.SettingsPolicy, error) #### DefaultPolicy @@ -4277,110 +4469,151 @@ Methods: Params Types: -- zero_trust.DevicesSplitTunnelParam +- zero_trust.SplitTunnelExcludeParam Response Types: -- zero_trust.DevicesSplitTunnel +- zero_trust.SplitTunnelExclude Methods: -- client.ZeroTrust.Devices.Policies.Excludes.Update(ctx context.Context, params zero_trust.DevicePolicyExcludeUpdateParams) ([]zero_trust.DevicesSplitTunnel, error) -- client.ZeroTrust.Devices.Policies.Excludes.List(ctx context.Context, query zero_trust.DevicePolicyExcludeListParams) (pagination.SinglePage[zero_trust.DevicesSplitTunnel], error) -- client.ZeroTrust.Devices.Policies.Excludes.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyExcludeGetParams) ([]zero_trust.DevicesSplitTunnel, error) +- client.ZeroTrust.Devices.Policies.Excludes.Update(ctx context.Context, params zero_trust.DevicePolicyExcludeUpdateParams) ([]zero_trust.SplitTunnelExclude, error) +- client.ZeroTrust.Devices.Policies.Excludes.List(ctx context.Context, query zero_trust.DevicePolicyExcludeListParams) (pagination.SinglePage[zero_trust.SplitTunnelExclude], error) +- client.ZeroTrust.Devices.Policies.Excludes.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyExcludeGetParams) ([]zero_trust.SplitTunnelExclude, error) #### FallbackDomains Params Types: -- zero_trust.DevicesFallbackDomainParam +- zero_trust.FallbackDomainParam Response Types: -- zero_trust.DevicesFallbackDomain +- zero_trust.FallbackDomain Methods: -- client.ZeroTrust.Devices.Policies.FallbackDomains.Update(ctx context.Context, policyID string, params zero_trust.DevicePolicyFallbackDomainUpdateParams) ([]zero_trust.DevicesFallbackDomain, error) -- client.ZeroTrust.Devices.Policies.FallbackDomains.List(ctx context.Context, query zero_trust.DevicePolicyFallbackDomainListParams) (pagination.SinglePage[zero_trust.DevicesFallbackDomain], error) -- client.ZeroTrust.Devices.Policies.FallbackDomains.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyFallbackDomainGetParams) ([]zero_trust.DevicesFallbackDomain, error) +- client.ZeroTrust.Devices.Policies.FallbackDomains.Update(ctx context.Context, policyID string, params zero_trust.DevicePolicyFallbackDomainUpdateParams) ([]zero_trust.FallbackDomain, error) +- client.ZeroTrust.Devices.Policies.FallbackDomains.List(ctx context.Context, query zero_trust.DevicePolicyFallbackDomainListParams) (pagination.SinglePage[zero_trust.FallbackDomain], error) +- client.ZeroTrust.Devices.Policies.FallbackDomains.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyFallbackDomainGetParams) ([]zero_trust.FallbackDomain, error) #### Includes Params Types: -- zero_trust.DevicesSplitTunnelIncludeParam +- zero_trust.SplitTunnelIncludeParam Response Types: -- zero_trust.DevicesSplitTunnelInclude +- zero_trust.SplitTunnelInclude Methods: -- client.ZeroTrust.Devices.Policies.Includes.Update(ctx context.Context, params zero_trust.DevicePolicyIncludeUpdateParams) ([]zero_trust.DevicesSplitTunnelInclude, error) -- client.ZeroTrust.Devices.Policies.Includes.List(ctx context.Context, query zero_trust.DevicePolicyIncludeListParams) (pagination.SinglePage[zero_trust.DevicesSplitTunnelInclude], error) -- client.ZeroTrust.Devices.Policies.Includes.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyIncludeGetParams) ([]zero_trust.DevicesSplitTunnelInclude, error) +- client.ZeroTrust.Devices.Policies.Includes.Update(ctx context.Context, params zero_trust.DevicePolicyIncludeUpdateParams) ([]zero_trust.SplitTunnelInclude, error) +- client.ZeroTrust.Devices.Policies.Includes.List(ctx context.Context, query zero_trust.DevicePolicyIncludeListParams) (pagination.SinglePage[zero_trust.SplitTunnelInclude], error) +- client.ZeroTrust.Devices.Policies.Includes.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyIncludeGetParams) ([]zero_trust.SplitTunnelInclude, error) ### Posture -Response Types: +Params Types: -- zero_trust.DevicePostureRules +- zero_trust.CarbonblackInputParam +- zero_trust.ClientCertificateInputParam +- zero_trust.CrowdstrikeInputParam +- zero_trust.DeviceInputUnionParam +- zero_trust.DeviceMatchParam +- zero_trust.DiskEncryptionInputParam +- zero_trust.DomainJoinedInputParam +- zero_trust.FileInputParam +- zero_trust.FirewallInputParam +- zero_trust.IntuneInputParam +- zero_trust.KolideInputParam +- zero_trust.OSVersionInputParam +- zero_trust.SentineloneInputParam +- zero_trust.SentineloneS2sInputParam +- zero_trust.TaniumInputParam +- zero_trust.UniqueClientIDInputParam +- zero_trust.WorkspaceOneInputParam + +Response Types: + +- zero_trust.CarbonblackInput +- zero_trust.ClientCertificateInput +- zero_trust.CrowdstrikeInput +- zero_trust.DeviceInput +- zero_trust.DeviceMatch +- zero_trust.DevicePostureRule +- zero_trust.DiskEncryptionInput +- zero_trust.DomainJoinedInput +- zero_trust.FileInput +- zero_trust.FirewallInput +- zero_trust.IntuneInput +- zero_trust.KolideInput +- zero_trust.OSVersionInput +- zero_trust.SentineloneInput +- zero_trust.SentineloneS2sInput +- zero_trust.TaniumInput +- zero_trust.UniqueClientIDInput +- zero_trust.WorkspaceOneInput - zero_trust.DevicePostureDeleteResponse Methods: -- client.ZeroTrust.Devices.Posture.New(ctx context.Context, params zero_trust.DevicePostureNewParams) (zero_trust.DevicePostureRules, error) -- client.ZeroTrust.Devices.Posture.Update(ctx context.Context, ruleID string, params zero_trust.DevicePostureUpdateParams) (zero_trust.DevicePostureRules, error) -- client.ZeroTrust.Devices.Posture.List(ctx context.Context, query zero_trust.DevicePostureListParams) (pagination.SinglePage[zero_trust.DevicePostureRules], error) -- client.ZeroTrust.Devices.Posture.Delete(ctx context.Context, ruleID string, body zero_trust.DevicePostureDeleteParams) (zero_trust.DevicePostureDeleteResponse, error) -- client.ZeroTrust.Devices.Posture.Get(ctx context.Context, ruleID string, query zero_trust.DevicePostureGetParams) (zero_trust.DevicePostureRules, error) +- client.ZeroTrust.Devices.Posture.New(ctx context.Context, params zero_trust.DevicePostureNewParams) (zero_trust.DevicePostureRule, error) +- client.ZeroTrust.Devices.Posture.Update(ctx context.Context, ruleID string, params zero_trust.DevicePostureUpdateParams) (zero_trust.DevicePostureRule, error) +- client.ZeroTrust.Devices.Posture.List(ctx context.Context, query zero_trust.DevicePostureListParams) (pagination.SinglePage[zero_trust.DevicePostureRule], error) +- client.ZeroTrust.Devices.Posture.Delete(ctx context.Context, ruleID string, params zero_trust.DevicePostureDeleteParams) (zero_trust.DevicePostureDeleteResponse, error) +- client.ZeroTrust.Devices.Posture.Get(ctx context.Context, ruleID string, query zero_trust.DevicePostureGetParams) (zero_trust.DevicePostureRule, error) #### Integrations Response Types: -- zero_trust.DevicePostureIntegrations -- zero_trust.DevicePostureIntegrationDeleteResponse +- zero_trust.Integration +- zero_trust.DevicePostureIntegrationDeleteResponseUnion Methods: -- client.ZeroTrust.Devices.Posture.Integrations.New(ctx context.Context, params zero_trust.DevicePostureIntegrationNewParams) (zero_trust.DevicePostureIntegrations, error) -- client.ZeroTrust.Devices.Posture.Integrations.List(ctx context.Context, query zero_trust.DevicePostureIntegrationListParams) (pagination.SinglePage[zero_trust.DevicePostureIntegrations], error) -- client.ZeroTrust.Devices.Posture.Integrations.Delete(ctx context.Context, integrationID string, body zero_trust.DevicePostureIntegrationDeleteParams) (zero_trust.DevicePostureIntegrationDeleteResponse, error) -- client.ZeroTrust.Devices.Posture.Integrations.Edit(ctx context.Context, integrationID string, params zero_trust.DevicePostureIntegrationEditParams) (zero_trust.DevicePostureIntegrations, error) -- client.ZeroTrust.Devices.Posture.Integrations.Get(ctx context.Context, integrationID string, query zero_trust.DevicePostureIntegrationGetParams) (zero_trust.DevicePostureIntegrations, error) +- client.ZeroTrust.Devices.Posture.Integrations.New(ctx context.Context, params zero_trust.DevicePostureIntegrationNewParams) (zero_trust.Integration, error) +- client.ZeroTrust.Devices.Posture.Integrations.List(ctx context.Context, query zero_trust.DevicePostureIntegrationListParams) (pagination.SinglePage[zero_trust.Integration], error) +- client.ZeroTrust.Devices.Posture.Integrations.Delete(ctx context.Context, integrationID string, params zero_trust.DevicePostureIntegrationDeleteParams) (zero_trust.DevicePostureIntegrationDeleteResponseUnion, error) +- client.ZeroTrust.Devices.Posture.Integrations.Edit(ctx context.Context, integrationID string, params zero_trust.DevicePostureIntegrationEditParams) (zero_trust.Integration, error) +- client.ZeroTrust.Devices.Posture.Integrations.Get(ctx context.Context, integrationID string, query zero_trust.DevicePostureIntegrationGetParams) (zero_trust.Integration, error) ### Revoke Response Types: -- zero_trust.DeviceRevokeNewResponse +- zero_trust.DeviceRevokeNewResponseUnion Methods: -- client.ZeroTrust.Devices.Revoke.New(ctx context.Context, params zero_trust.DeviceRevokeNewParams) (zero_trust.DeviceRevokeNewResponse, error) +- client.ZeroTrust.Devices.Revoke.New(ctx context.Context, params zero_trust.DeviceRevokeNewParams) (zero_trust.DeviceRevokeNewResponseUnion, error) ### Settings +Params Types: + +- zero_trust.DeviceSettingsParam + Response Types: -- zero_trust.ZeroTrustAccountDeviceSettings +- zero_trust.DeviceSettings Methods: -- client.ZeroTrust.Devices.Settings.Update(ctx context.Context, params zero_trust.DeviceSettingUpdateParams) (zero_trust.ZeroTrustAccountDeviceSettings, error) -- client.ZeroTrust.Devices.Settings.List(ctx context.Context, query zero_trust.DeviceSettingListParams) (zero_trust.ZeroTrustAccountDeviceSettings, error) +- client.ZeroTrust.Devices.Settings.Update(ctx context.Context, params zero_trust.DeviceSettingUpdateParams) (zero_trust.DeviceSettings, error) +- client.ZeroTrust.Devices.Settings.List(ctx context.Context, query zero_trust.DeviceSettingListParams) (zero_trust.DeviceSettings, error) ### Unrevoke Response Types: -- zero_trust.DeviceUnrevokeNewResponse +- zero_trust.DeviceUnrevokeNewResponseUnion Methods: -- client.ZeroTrust.Devices.Unrevoke.New(ctx context.Context, params zero_trust.DeviceUnrevokeNewParams) (zero_trust.DeviceUnrevokeNewResponse, error) +- client.ZeroTrust.Devices.Unrevoke.New(ctx context.Context, params zero_trust.DeviceUnrevokeNewParams) (zero_trust.DeviceUnrevokeNewResponseUnion, error) ### OverrideCodes @@ -4394,194 +4627,296 @@ Methods: ## IdentityProviders +Params Types: + +- zero_trust.AzureADParam +- zero_trust.GenericOAuthConfigParam +- zero_trust.IdentityProviderUnionParam +- zero_trust.IdentityProviderType +- zero_trust.ScimConfigParam + Response Types: -- zero_trust.ZeroTrustIdentityProviders +- zero_trust.AzureAD +- zero_trust.GenericOAuthConfig +- zero_trust.IdentityProvider +- zero_trust.IdentityProviderType +- zero_trust.ScimConfig - zero_trust.IdentityProviderListResponse - zero_trust.IdentityProviderDeleteResponse Methods: -- client.ZeroTrust.IdentityProviders.New(ctx context.Context, params zero_trust.IdentityProviderNewParams) (zero_trust.ZeroTrustIdentityProviders, error) -- client.ZeroTrust.IdentityProviders.Update(ctx context.Context, uuid string, params zero_trust.IdentityProviderUpdateParams) (zero_trust.ZeroTrustIdentityProviders, error) +- client.ZeroTrust.IdentityProviders.New(ctx context.Context, params zero_trust.IdentityProviderNewParams) (zero_trust.IdentityProvider, error) +- client.ZeroTrust.IdentityProviders.Update(ctx context.Context, uuid string, params zero_trust.IdentityProviderUpdateParams) (zero_trust.IdentityProvider, error) - client.ZeroTrust.IdentityProviders.List(ctx context.Context, query zero_trust.IdentityProviderListParams) (pagination.SinglePage[zero_trust.IdentityProviderListResponse], error) - client.ZeroTrust.IdentityProviders.Delete(ctx context.Context, uuid string, body zero_trust.IdentityProviderDeleteParams) (zero_trust.IdentityProviderDeleteResponse, error) -- client.ZeroTrust.IdentityProviders.Get(ctx context.Context, uuid string, query zero_trust.IdentityProviderGetParams) (zero_trust.ZeroTrustIdentityProviders, error) +- client.ZeroTrust.IdentityProviders.Get(ctx context.Context, uuid string, query zero_trust.IdentityProviderGetParams) (zero_trust.IdentityProvider, error) ## Organizations +Params Types: + +- zero_trust.LoginDesignParam + Response Types: -- zero_trust.ZeroTrustOrganizations +- zero_trust.LoginDesign +- zero_trust.Organization - zero_trust.OrganizationRevokeUsersResponse Methods: -- client.ZeroTrust.Organizations.New(ctx context.Context, params zero_trust.OrganizationNewParams) (zero_trust.ZeroTrustOrganizations, error) -- client.ZeroTrust.Organizations.Update(ctx context.Context, params zero_trust.OrganizationUpdateParams) (zero_trust.ZeroTrustOrganizations, error) -- client.ZeroTrust.Organizations.List(ctx context.Context, query zero_trust.OrganizationListParams) (zero_trust.ZeroTrustOrganizations, error) +- client.ZeroTrust.Organizations.New(ctx context.Context, params zero_trust.OrganizationNewParams) (zero_trust.Organization, error) +- client.ZeroTrust.Organizations.Update(ctx context.Context, params zero_trust.OrganizationUpdateParams) (zero_trust.Organization, error) +- client.ZeroTrust.Organizations.List(ctx context.Context, query zero_trust.OrganizationListParams) (zero_trust.Organization, error) - client.ZeroTrust.Organizations.RevokeUsers(ctx context.Context, params zero_trust.OrganizationRevokeUsersParams) (zero_trust.OrganizationRevokeUsersResponse, error) ## Seats Response Types: -- zero_trust.ZeroTrustSeats +- zero_trust.Seat Methods: -- client.ZeroTrust.Seats.Edit(ctx context.Context, identifier string, body zero_trust.SeatEditParams) ([]zero_trust.ZeroTrustSeats, error) +- client.ZeroTrust.Seats.Edit(ctx context.Context, identifier string, body zero_trust.SeatEditParams) ([]zero_trust.Seat, error) ## Access +Params Types: + +- zero_trust.AccessDevicePostureRuleParam +- zero_trust.AccessRuleUnionParam +- zero_trust.AnyValidServiceTokenRuleParam +- zero_trust.AuthenticationMethodRuleParam +- zero_trust.AzureGroupRuleParam +- zero_trust.CertificateRuleParam +- zero_trust.CountryRuleParam +- zero_trust.DomainRuleParam +- zero_trust.EmailListRuleParam +- zero_trust.EmailRuleParam +- zero_trust.EveryoneRuleParam +- zero_trust.ExternalEvaluationRuleParam +- zero_trust.GitHubOrganizationRuleParam +- zero_trust.GroupRuleParam +- zero_trust.GSuiteGroupRuleParam +- zero_trust.IPListRuleParam +- zero_trust.IPRuleParam +- zero_trust.OktaGroupRuleParam +- zero_trust.SAMLGroupRuleParam +- zero_trust.ServiceTokenRuleParam + +Response Types: + +- zero_trust.AccessDevicePostureRule +- zero_trust.AccessRule +- zero_trust.AnyValidServiceTokenRule +- zero_trust.AuthenticationMethodRule +- zero_trust.AzureGroupRule +- zero_trust.CertificateRule +- zero_trust.CountryRule +- zero_trust.DomainRule +- zero_trust.EmailListRule +- zero_trust.EmailRule +- zero_trust.EveryoneRule +- zero_trust.ExternalEvaluationRule +- zero_trust.GitHubOrganizationRule +- zero_trust.GroupRule +- zero_trust.GSuiteGroupRule +- zero_trust.IPListRule +- zero_trust.IPRule +- zero_trust.OktaGroupRule +- zero_trust.SAMLGroupRule +- zero_trust.ServiceTokenRule + ### Applications -Response Types: +Params Types: -- zero_trust.ZeroTrustApps +- zero_trust.AllowedHeadershParam +- zero_trust.AllowedIdpshParam +- zero_trust.AllowedMethodsh +- zero_trust.AllowedOriginshParam +- zero_trust.AppIDUnionParam +- zero_trust.ApplicationUnionParam +- zero_trust.CorsHeadersParam +- zero_trust.CustomPageshParam +- zero_trust.SaasAppNameFormat +- zero_trust.SaasAppNameIDFormat +- zero_trust.SaasAppSourceParam +- zero_trust.SAMLSaasAppParam +- zero_trust.SelfHostedDomainshParam + +Response Types: + +- zero_trust.AllowedHeadersh +- zero_trust.AllowedIdpsh +- zero_trust.AllowedMethodsh +- zero_trust.AllowedOriginsh +- zero_trust.Application +- zero_trust.CorsHeaders +- zero_trust.CustomPagesh +- zero_trust.SaasAppNameFormat +- zero_trust.SaasAppNameIDFormat +- zero_trust.SaasAppSource +- zero_trust.SAMLSaasApp +- zero_trust.SelfHostedDomainsh - zero_trust.AccessApplicationDeleteResponse - zero_trust.AccessApplicationRevokeTokensResponse Methods: -- client.ZeroTrust.Access.Applications.New(ctx context.Context, params zero_trust.AccessApplicationNewParams) (zero_trust.ZeroTrustApps, error) -- client.ZeroTrust.Access.Applications.Update(ctx context.Context, appID zero_trust.AccessApplicationUpdateParamsSelfHostedApplicationAppID, params zero_trust.AccessApplicationUpdateParams) (zero_trust.ZeroTrustApps, error) -- client.ZeroTrust.Access.Applications.List(ctx context.Context, query zero_trust.AccessApplicationListParams) (pagination.SinglePage[zero_trust.ZeroTrustApps], error) -- client.ZeroTrust.Access.Applications.Delete(ctx context.Context, appID zero_trust.AccessApplicationDeleteParamsAppID, body zero_trust.AccessApplicationDeleteParams) (zero_trust.AccessApplicationDeleteResponse, error) -- client.ZeroTrust.Access.Applications.Get(ctx context.Context, appID zero_trust.AccessApplicationGetParamsAppID, query zero_trust.AccessApplicationGetParams) (zero_trust.ZeroTrustApps, error) -- client.ZeroTrust.Access.Applications.RevokeTokens(ctx context.Context, appID zero_trust.AccessApplicationRevokeTokensParamsAppID, body zero_trust.AccessApplicationRevokeTokensParams) (zero_trust.AccessApplicationRevokeTokensResponse, error) +- client.ZeroTrust.Access.Applications.New(ctx context.Context, params zero_trust.AccessApplicationNewParams) (zero_trust.Application, error) +- client.ZeroTrust.Access.Applications.Update(ctx context.Context, appID zero_trust.AppIDUnionParam, params zero_trust.AccessApplicationUpdateParams) (zero_trust.Application, error) +- client.ZeroTrust.Access.Applications.List(ctx context.Context, query zero_trust.AccessApplicationListParams) (pagination.SinglePage[zero_trust.Application], error) +- client.ZeroTrust.Access.Applications.Delete(ctx context.Context, appID zero_trust.AppIDUnionParam, body zero_trust.AccessApplicationDeleteParams) (zero_trust.AccessApplicationDeleteResponse, error) +- client.ZeroTrust.Access.Applications.Get(ctx context.Context, appID zero_trust.AppIDUnionParam, query zero_trust.AccessApplicationGetParams) (zero_trust.Application, error) +- client.ZeroTrust.Access.Applications.RevokeTokens(ctx context.Context, appID zero_trust.AppIDUnionParam, body zero_trust.AccessApplicationRevokeTokensParams) (zero_trust.AccessApplicationRevokeTokensResponse, error) #### CAs Response Types: -- zero_trust.ZeroTrustCA -- zero_trust.AccessApplicationCANewResponse +- zero_trust.CA +- zero_trust.AccessApplicationCANewResponseUnion - zero_trust.AccessApplicationCADeleteResponse -- zero_trust.AccessApplicationCAGetResponse +- zero_trust.AccessApplicationCAGetResponseUnion Methods: -- client.ZeroTrust.Access.Applications.CAs.New(ctx context.Context, uuid string, body zero_trust.AccessApplicationCANewParams) (zero_trust.AccessApplicationCANewResponse, error) -- client.ZeroTrust.Access.Applications.CAs.List(ctx context.Context, query zero_trust.AccessApplicationCAListParams) (pagination.SinglePage[zero_trust.ZeroTrustCA], error) +- client.ZeroTrust.Access.Applications.CAs.New(ctx context.Context, uuid string, body zero_trust.AccessApplicationCANewParams) (zero_trust.AccessApplicationCANewResponseUnion, error) +- client.ZeroTrust.Access.Applications.CAs.List(ctx context.Context, query zero_trust.AccessApplicationCAListParams) (pagination.SinglePage[zero_trust.CA], error) - client.ZeroTrust.Access.Applications.CAs.Delete(ctx context.Context, uuid string, body zero_trust.AccessApplicationCADeleteParams) (zero_trust.AccessApplicationCADeleteResponse, error) -- client.ZeroTrust.Access.Applications.CAs.Get(ctx context.Context, uuid string, query zero_trust.AccessApplicationCAGetParams) (zero_trust.AccessApplicationCAGetResponse, error) +- client.ZeroTrust.Access.Applications.CAs.Get(ctx context.Context, uuid string, query zero_trust.AccessApplicationCAGetParams) (zero_trust.AccessApplicationCAGetResponseUnion, error) #### UserPolicyChecks Response Types: +- zero_trust.UserPolicyCheckGeo - zero_trust.AccessApplicationUserPolicyCheckListResponse Methods: -- client.ZeroTrust.Access.Applications.UserPolicyChecks.List(ctx context.Context, appID zero_trust.AccessApplicationUserPolicyCheckListParamsAppID, query zero_trust.AccessApplicationUserPolicyCheckListParams) (zero_trust.AccessApplicationUserPolicyCheckListResponse, error) +- client.ZeroTrust.Access.Applications.UserPolicyChecks.List(ctx context.Context, appID zero_trust.AppIDUnionParam, query zero_trust.AccessApplicationUserPolicyCheckListParams) (zero_trust.AccessApplicationUserPolicyCheckListResponse, error) #### Policies +Params Types: + +- zero_trust.ApprovalGroupParam +- zero_trust.PolicyParam + Response Types: -- zero_trust.ZeroTrustPolicies +- zero_trust.ApprovalGroup +- zero_trust.Policy - zero_trust.AccessApplicationPolicyDeleteResponse Methods: -- client.ZeroTrust.Access.Applications.Policies.New(ctx context.Context, uuid string, params zero_trust.AccessApplicationPolicyNewParams) (zero_trust.ZeroTrustPolicies, error) -- client.ZeroTrust.Access.Applications.Policies.Update(ctx context.Context, uuid1 string, uuid string, params zero_trust.AccessApplicationPolicyUpdateParams) (zero_trust.ZeroTrustPolicies, error) -- client.ZeroTrust.Access.Applications.Policies.List(ctx context.Context, uuid string, query zero_trust.AccessApplicationPolicyListParams) (pagination.SinglePage[zero_trust.ZeroTrustPolicies], error) +- client.ZeroTrust.Access.Applications.Policies.New(ctx context.Context, uuid string, params zero_trust.AccessApplicationPolicyNewParams) (zero_trust.Policy, error) +- client.ZeroTrust.Access.Applications.Policies.Update(ctx context.Context, uuid1 string, uuid string, params zero_trust.AccessApplicationPolicyUpdateParams) (zero_trust.Policy, error) +- client.ZeroTrust.Access.Applications.Policies.List(ctx context.Context, uuid string, query zero_trust.AccessApplicationPolicyListParams) (pagination.SinglePage[zero_trust.Policy], error) - client.ZeroTrust.Access.Applications.Policies.Delete(ctx context.Context, uuid1 string, uuid string, body zero_trust.AccessApplicationPolicyDeleteParams) (zero_trust.AccessApplicationPolicyDeleteResponse, error) -- client.ZeroTrust.Access.Applications.Policies.Get(ctx context.Context, uuid1 string, uuid string, query zero_trust.AccessApplicationPolicyGetParams) (zero_trust.ZeroTrustPolicies, error) +- client.ZeroTrust.Access.Applications.Policies.Get(ctx context.Context, uuid1 string, uuid string, query zero_trust.AccessApplicationPolicyGetParams) (zero_trust.Policy, error) ### Certificates +Params Types: + +- zero_trust.AssociatedHostnamesParam + Response Types: -- zero_trust.ZeroTrustCertificates +- zero_trust.AssociatedHostnames +- zero_trust.Certificate - zero_trust.AccessCertificateDeleteResponse Methods: -- client.ZeroTrust.Access.Certificates.New(ctx context.Context, params zero_trust.AccessCertificateNewParams) (zero_trust.ZeroTrustCertificates, error) -- client.ZeroTrust.Access.Certificates.Update(ctx context.Context, uuid string, params zero_trust.AccessCertificateUpdateParams) (zero_trust.ZeroTrustCertificates, error) -- client.ZeroTrust.Access.Certificates.List(ctx context.Context, query zero_trust.AccessCertificateListParams) (pagination.SinglePage[zero_trust.ZeroTrustCertificates], error) +- client.ZeroTrust.Access.Certificates.New(ctx context.Context, params zero_trust.AccessCertificateNewParams) (zero_trust.Certificate, error) +- client.ZeroTrust.Access.Certificates.Update(ctx context.Context, uuid string, params zero_trust.AccessCertificateUpdateParams) (zero_trust.Certificate, error) +- client.ZeroTrust.Access.Certificates.List(ctx context.Context, query zero_trust.AccessCertificateListParams) (pagination.SinglePage[zero_trust.Certificate], error) - client.ZeroTrust.Access.Certificates.Delete(ctx context.Context, uuid string, body zero_trust.AccessCertificateDeleteParams) (zero_trust.AccessCertificateDeleteResponse, error) -- client.ZeroTrust.Access.Certificates.Get(ctx context.Context, uuid string, query zero_trust.AccessCertificateGetParams) (zero_trust.ZeroTrustCertificates, error) +- client.ZeroTrust.Access.Certificates.Get(ctx context.Context, uuid string, query zero_trust.AccessCertificateGetParams) (zero_trust.Certificate, error) #### Settings Params Types: -- zero_trust.ZeroTrustSettingsParam +- zero_trust.CertificateSettingsParam Response Types: -- zero_trust.ZeroTrustSettings +- zero_trust.CertificateSettings Methods: -- client.ZeroTrust.Access.Certificates.Settings.Update(ctx context.Context, params zero_trust.AccessCertificateSettingUpdateParams) ([]zero_trust.ZeroTrustSettings, error) -- client.ZeroTrust.Access.Certificates.Settings.Get(ctx context.Context, query zero_trust.AccessCertificateSettingGetParams) ([]zero_trust.ZeroTrustSettings, error) +- client.ZeroTrust.Access.Certificates.Settings.Update(ctx context.Context, params zero_trust.AccessCertificateSettingUpdateParams) ([]zero_trust.CertificateSettings, error) +- client.ZeroTrust.Access.Certificates.Settings.Get(ctx context.Context, query zero_trust.AccessCertificateSettingGetParams) ([]zero_trust.CertificateSettings, error) ### Groups Response Types: -- zero_trust.ZeroTrustGroups +- zero_trust.ZeroTrustGroup - zero_trust.AccessGroupDeleteResponse Methods: -- client.ZeroTrust.Access.Groups.New(ctx context.Context, params zero_trust.AccessGroupNewParams) (zero_trust.ZeroTrustGroups, error) -- client.ZeroTrust.Access.Groups.Update(ctx context.Context, uuid string, params zero_trust.AccessGroupUpdateParams) (zero_trust.ZeroTrustGroups, error) -- client.ZeroTrust.Access.Groups.List(ctx context.Context, query zero_trust.AccessGroupListParams) (pagination.SinglePage[zero_trust.ZeroTrustGroups], error) +- client.ZeroTrust.Access.Groups.New(ctx context.Context, params zero_trust.AccessGroupNewParams) (zero_trust.ZeroTrustGroup, error) +- client.ZeroTrust.Access.Groups.Update(ctx context.Context, uuid string, params zero_trust.AccessGroupUpdateParams) (zero_trust.ZeroTrustGroup, error) +- client.ZeroTrust.Access.Groups.List(ctx context.Context, query zero_trust.AccessGroupListParams) (pagination.SinglePage[zero_trust.ZeroTrustGroup], error) - client.ZeroTrust.Access.Groups.Delete(ctx context.Context, uuid string, body zero_trust.AccessGroupDeleteParams) (zero_trust.AccessGroupDeleteResponse, error) -- client.ZeroTrust.Access.Groups.Get(ctx context.Context, uuid string, query zero_trust.AccessGroupGetParams) (zero_trust.ZeroTrustGroups, error) +- client.ZeroTrust.Access.Groups.Get(ctx context.Context, uuid string, query zero_trust.AccessGroupGetParams) (zero_trust.ZeroTrustGroup, error) ### ServiceTokens Response Types: -- zero_trust.ZeroTrustServiceTokens +- zero_trust.ServiceToken - zero_trust.AccessServiceTokenNewResponse - zero_trust.AccessServiceTokenRotateResponse Methods: - client.ZeroTrust.Access.ServiceTokens.New(ctx context.Context, params zero_trust.AccessServiceTokenNewParams) (zero_trust.AccessServiceTokenNewResponse, error) -- client.ZeroTrust.Access.ServiceTokens.Update(ctx context.Context, uuid string, params zero_trust.AccessServiceTokenUpdateParams) (zero_trust.ZeroTrustServiceTokens, error) -- client.ZeroTrust.Access.ServiceTokens.List(ctx context.Context, query zero_trust.AccessServiceTokenListParams) (pagination.SinglePage[zero_trust.ZeroTrustServiceTokens], error) -- client.ZeroTrust.Access.ServiceTokens.Delete(ctx context.Context, uuid string, body zero_trust.AccessServiceTokenDeleteParams) (zero_trust.ZeroTrustServiceTokens, error) -- client.ZeroTrust.Access.ServiceTokens.Refresh(ctx context.Context, identifier string, uuid string) (zero_trust.ZeroTrustServiceTokens, error) +- client.ZeroTrust.Access.ServiceTokens.Update(ctx context.Context, uuid string, params zero_trust.AccessServiceTokenUpdateParams) (zero_trust.ServiceToken, error) +- client.ZeroTrust.Access.ServiceTokens.List(ctx context.Context, query zero_trust.AccessServiceTokenListParams) (pagination.SinglePage[zero_trust.ServiceToken], error) +- client.ZeroTrust.Access.ServiceTokens.Delete(ctx context.Context, uuid string, body zero_trust.AccessServiceTokenDeleteParams) (zero_trust.ServiceToken, error) +- client.ZeroTrust.Access.ServiceTokens.Refresh(ctx context.Context, identifier string, uuid string) (zero_trust.ServiceToken, error) - client.ZeroTrust.Access.ServiceTokens.Rotate(ctx context.Context, identifier string, uuid string) (zero_trust.AccessServiceTokenRotateResponse, error) ### Bookmarks Response Types: -- zero_trust.ZeroTrustBookmarks +- zero_trust.Bookmark - zero_trust.AccessBookmarkDeleteResponse Methods: -- client.ZeroTrust.Access.Bookmarks.New(ctx context.Context, identifier string, uuid string) (zero_trust.ZeroTrustBookmarks, error) -- client.ZeroTrust.Access.Bookmarks.Update(ctx context.Context, identifier string, uuid string) (zero_trust.ZeroTrustBookmarks, error) -- client.ZeroTrust.Access.Bookmarks.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.ZeroTrustBookmarks], error) -- client.ZeroTrust.Access.Bookmarks.Delete(ctx context.Context, identifier string, uuid string) (zero_trust.AccessBookmarkDeleteResponse, error) -- client.ZeroTrust.Access.Bookmarks.Get(ctx context.Context, identifier string, uuid string) (zero_trust.ZeroTrustBookmarks, error) +- client.ZeroTrust.Access.Bookmarks.New(ctx context.Context, identifier string, uuid string, body zero_trust.AccessBookmarkNewParams) (zero_trust.Bookmark, error) +- client.ZeroTrust.Access.Bookmarks.Update(ctx context.Context, identifier string, uuid string, body zero_trust.AccessBookmarkUpdateParams) (zero_trust.Bookmark, error) +- client.ZeroTrust.Access.Bookmarks.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.Bookmark], error) +- client.ZeroTrust.Access.Bookmarks.Delete(ctx context.Context, identifier string, uuid string, body zero_trust.AccessBookmarkDeleteParams) (zero_trust.AccessBookmarkDeleteResponse, error) +- client.ZeroTrust.Access.Bookmarks.Get(ctx context.Context, identifier string, uuid string) (zero_trust.Bookmark, error) ### Keys Response Types: -- zero_trust.AccessKeyUpdateResponse -- zero_trust.AccessKeyGetResponse -- zero_trust.AccessKeyRotateResponse +- zero_trust.AccessKeyUpdateResponseUnion +- zero_trust.AccessKeyGetResponseUnion +- zero_trust.AccessKeyRotateResponseUnion Methods: -- client.ZeroTrust.Access.Keys.Update(ctx context.Context, identifier string, body zero_trust.AccessKeyUpdateParams) (zero_trust.AccessKeyUpdateResponse, error) -- client.ZeroTrust.Access.Keys.Get(ctx context.Context, identifier string) (zero_trust.AccessKeyGetResponse, error) -- client.ZeroTrust.Access.Keys.Rotate(ctx context.Context, identifier string) (zero_trust.AccessKeyRotateResponse, error) +- client.ZeroTrust.Access.Keys.Update(ctx context.Context, identifier string, body zero_trust.AccessKeyUpdateParams) (zero_trust.AccessKeyUpdateResponseUnion, error) +- client.ZeroTrust.Access.Keys.Get(ctx context.Context, identifier string) (zero_trust.AccessKeyGetResponseUnion, error) +- client.ZeroTrust.Access.Keys.Rotate(ctx context.Context, identifier string) (zero_trust.AccessKeyRotateResponseUnion, error) ### Logs @@ -4589,21 +4924,21 @@ Methods: Response Types: -- zero_trust.ZeroTrustAccessRequests +- zero_trust.AccessRequests Methods: -- client.ZeroTrust.Access.Logs.AccessRequests.List(ctx context.Context, identifier string) ([]zero_trust.ZeroTrustAccessRequests, error) +- client.ZeroTrust.Access.Logs.AccessRequests.List(ctx context.Context, identifier string) ([]zero_trust.AccessRequests, error) ### Users Response Types: -- zero_trust.ZeroTrustUsers +- zero_trust.AccessUser Methods: -- client.ZeroTrust.Access.Users.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.ZeroTrustUsers], error) +- client.ZeroTrust.Access.Users.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.AccessUser], error) #### ActiveSessions @@ -4621,11 +4956,11 @@ Methods: Response Types: -- zero_trust.ZeroTrustIdentity +- zero_trust.Identity Methods: -- client.ZeroTrust.Access.Users.LastSeenIdentity.Get(ctx context.Context, identifier string, id string) (zero_trust.ZeroTrustIdentity, error) +- client.ZeroTrust.Access.Users.LastSeenIdentity.Get(ctx context.Context, identifier string, id string) (zero_trust.Identity, error) #### FailedLogins @@ -4639,37 +4974,47 @@ Methods: ### CustomPages +Params Types: + +- zero_trust.CustomPageParam + Response Types: -- zero_trust.ZeroTrustCustomPage -- zero_trust.ZeroTrustCustomPageWithoutHTML +- zero_trust.CustomPage +- zero_trust.CustomPageWithoutHTML - zero_trust.AccessCustomPageDeleteResponse Methods: -- client.ZeroTrust.Access.CustomPages.New(ctx context.Context, identifier string, body zero_trust.AccessCustomPageNewParams) (zero_trust.ZeroTrustCustomPageWithoutHTML, error) -- client.ZeroTrust.Access.CustomPages.Update(ctx context.Context, identifier string, uuid string, body zero_trust.AccessCustomPageUpdateParams) (zero_trust.ZeroTrustCustomPageWithoutHTML, error) -- client.ZeroTrust.Access.CustomPages.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.ZeroTrustCustomPageWithoutHTML], error) +- client.ZeroTrust.Access.CustomPages.New(ctx context.Context, identifier string, body zero_trust.AccessCustomPageNewParams) (zero_trust.CustomPageWithoutHTML, error) +- client.ZeroTrust.Access.CustomPages.Update(ctx context.Context, identifier string, uuid string, body zero_trust.AccessCustomPageUpdateParams) (zero_trust.CustomPageWithoutHTML, error) +- client.ZeroTrust.Access.CustomPages.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.CustomPageWithoutHTML], error) - client.ZeroTrust.Access.CustomPages.Delete(ctx context.Context, identifier string, uuid string) (zero_trust.AccessCustomPageDeleteResponse, error) -- client.ZeroTrust.Access.CustomPages.Get(ctx context.Context, identifier string, uuid string) (zero_trust.ZeroTrustCustomPage, error) +- client.ZeroTrust.Access.CustomPages.Get(ctx context.Context, identifier string, uuid string) (zero_trust.CustomPage, error) ### Tags Response Types: -- zero_trust.ZeroTrustTag +- zero_trust.Tag - zero_trust.AccessTagDeleteResponse Methods: -- client.ZeroTrust.Access.Tags.New(ctx context.Context, identifier string, body zero_trust.AccessTagNewParams) (zero_trust.ZeroTrustTag, error) -- client.ZeroTrust.Access.Tags.Update(ctx context.Context, identifier string, tagName string, body zero_trust.AccessTagUpdateParams) (zero_trust.ZeroTrustTag, error) -- client.ZeroTrust.Access.Tags.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.ZeroTrustTag], error) +- client.ZeroTrust.Access.Tags.New(ctx context.Context, identifier string, body zero_trust.AccessTagNewParams) (zero_trust.Tag, error) +- client.ZeroTrust.Access.Tags.Update(ctx context.Context, identifier string, tagName string, body zero_trust.AccessTagUpdateParams) (zero_trust.Tag, error) +- client.ZeroTrust.Access.Tags.List(ctx context.Context, identifier string) (pagination.SinglePage[zero_trust.Tag], error) - client.ZeroTrust.Access.Tags.Delete(ctx context.Context, identifier string, name string) (zero_trust.AccessTagDeleteResponse, error) -- client.ZeroTrust.Access.Tags.Get(ctx context.Context, identifier string, name string) (zero_trust.ZeroTrustTag, error) +- client.ZeroTrust.Access.Tags.Get(ctx context.Context, identifier string, name string) (zero_trust.Tag, error) ## DEX +Response Types: + +- zero_trust.DeviceExperienceMonitor +- zero_trust.NetworkPath +- zero_trust.Percentiles + ### Colos Response Types: @@ -4684,6 +5029,7 @@ Methods: Response Types: +- zero_trust.LiveStat - zero_trust.DEXFleetStatusLiveResponse Methods: @@ -4695,37 +5041,39 @@ Methods: Response Types: -- zero_trust.DigitalExperienceMonitoringDevice +- zero_trust.DEXFleetStatusDeviceListResponse Methods: -- client.ZeroTrust.DEX.FleetStatus.Devices.List(ctx context.Context, params zero_trust.DEXFleetStatusDeviceListParams) (pagination.V4PagePaginationArray[zero_trust.DigitalExperienceMonitoringDevice], error) +- client.ZeroTrust.DEX.FleetStatus.Devices.List(ctx context.Context, params zero_trust.DEXFleetStatusDeviceListParams) (pagination.V4PagePaginationArray[zero_trust.DEXFleetStatusDeviceListResponse], error) ### HTTPTests Response Types: -- zero_trust.DigitalExperienceMonitoringHTTPDetails +- zero_trust.HTTPDetails Methods: -- client.ZeroTrust.DEX.HTTPTests.Get(ctx context.Context, testID string, params zero_trust.DEXHTTPTestGetParams) (zero_trust.DigitalExperienceMonitoringHTTPDetails, error) +- client.ZeroTrust.DEX.HTTPTests.Get(ctx context.Context, testID string, params zero_trust.DEXHTTPTestGetParams) (zero_trust.HTTPDetails, error) #### Percentiles Response Types: -- zero_trust.DigitalExperienceMonitoringHTTPDetailsPercentiles +- zero_trust.HTTPDetailsPercentiles +- zero_trust.TestStatOverTime Methods: -- client.ZeroTrust.DEX.HTTPTests.Percentiles.Get(ctx context.Context, testID string, params zero_trust.DEXHTTPTestPercentileGetParams) (zero_trust.DigitalExperienceMonitoringHTTPDetailsPercentiles, error) +- client.ZeroTrust.DEX.HTTPTests.Percentiles.Get(ctx context.Context, testID string, params zero_trust.DEXHTTPTestPercentileGetParams) (zero_trust.HTTPDetailsPercentiles, error) ### Tests Response Types: -- zero_trust.DigitalExperienceMonitoringTests +- zero_trust.AggregateTimePeriod +- zero_trust.Tests - zero_trust.DEXTestListResponse Methods: @@ -4736,11 +5084,11 @@ Methods: Response Types: -- zero_trust.DigitalExperienceMonitoringUniqueDevices +- zero_trust.UniqueDevices Methods: -- client.ZeroTrust.DEX.Tests.UniqueDevices.List(ctx context.Context, params zero_trust.DEXTestUniqueDeviceListParams) (zero_trust.DigitalExperienceMonitoringUniqueDevices, error) +- client.ZeroTrust.DEX.Tests.UniqueDevices.List(ctx context.Context, params zero_trust.DEXTestUniqueDeviceListParams) (zero_trust.UniqueDevices, error) ### TracerouteTestResults @@ -4748,91 +5096,93 @@ Methods: Response Types: -- zero_trust.DigitalExperienceMonitoringTracerouteTestResultNetworkPath +- zero_trust.DEXTracerouteTestResultNetworkPathGetResponse Methods: -- client.ZeroTrust.DEX.TracerouteTestResults.NetworkPath.Get(ctx context.Context, testResultID string, query zero_trust.DEXTracerouteTestResultNetworkPathGetParams) (zero_trust.DigitalExperienceMonitoringTracerouteTestResultNetworkPath, error) +- client.ZeroTrust.DEX.TracerouteTestResults.NetworkPath.Get(ctx context.Context, testResultID string, query zero_trust.DEXTracerouteTestResultNetworkPathGetParams) (zero_trust.DEXTracerouteTestResultNetworkPathGetResponse, error) ### TracerouteTests Response Types: -- zero_trust.DigitalExperienceMonitoringTracerouteDetails -- zero_trust.DigitalExperienceMonitoringTracerouteDetailsPercentiles -- zero_trust.DigitalExperienceMonitoringTracerouteTestNetworkPath +- zero_trust.Traceroute +- zero_trust.DEXTracerouteTestPercentilesResponse Methods: -- client.ZeroTrust.DEX.TracerouteTests.Get(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestGetParams) (zero_trust.DigitalExperienceMonitoringTracerouteDetails, error) -- client.ZeroTrust.DEX.TracerouteTests.NetworkPath(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestNetworkPathParams) (zero_trust.DigitalExperienceMonitoringTracerouteTestNetworkPath, error) -- client.ZeroTrust.DEX.TracerouteTests.Percentiles(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestPercentilesParams) (zero_trust.DigitalExperienceMonitoringTracerouteDetailsPercentiles, error) +- client.ZeroTrust.DEX.TracerouteTests.Get(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestGetParams) (zero_trust.Traceroute, error) +- client.ZeroTrust.DEX.TracerouteTests.NetworkPath(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestNetworkPathParams) (zero_trust.NetworkPath, error) +- client.ZeroTrust.DEX.TracerouteTests.Percentiles(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestPercentilesParams) (zero_trust.DEXTracerouteTestPercentilesResponse, error) ## Tunnels Response Types: -- zero_trust.TunnelArgoTunnel +- zero_trust.Connection +- zero_trust.TunnelNewResponse - zero_trust.TunnelListResponse +- zero_trust.TunnelDeleteResponse - zero_trust.TunnelEditResponse +- zero_trust.TunnelGetResponse Methods: -- client.ZeroTrust.Tunnels.New(ctx context.Context, params zero_trust.TunnelNewParams) (zero_trust.TunnelArgoTunnel, error) +- client.ZeroTrust.Tunnels.New(ctx context.Context, params zero_trust.TunnelNewParams) (zero_trust.TunnelNewResponse, error) - client.ZeroTrust.Tunnels.List(ctx context.Context, params zero_trust.TunnelListParams) (pagination.V4PagePaginationArray[zero_trust.TunnelListResponse], error) -- client.ZeroTrust.Tunnels.Delete(ctx context.Context, tunnelID string, params zero_trust.TunnelDeleteParams) (zero_trust.TunnelArgoTunnel, error) +- client.ZeroTrust.Tunnels.Delete(ctx context.Context, tunnelID string, params zero_trust.TunnelDeleteParams) (zero_trust.TunnelDeleteResponse, error) - client.ZeroTrust.Tunnels.Edit(ctx context.Context, tunnelID string, params zero_trust.TunnelEditParams) (zero_trust.TunnelEditResponse, error) -- client.ZeroTrust.Tunnels.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelGetParams) (zero_trust.TunnelArgoTunnel, error) +- client.ZeroTrust.Tunnels.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelGetParams) (zero_trust.TunnelGetResponse, error) ### Configurations Response Types: -- zero_trust.TunnelConfigurationUpdateResponse -- zero_trust.TunnelConfigurationGetResponse +- zero_trust.TunnelConfigurationUpdateResponseUnion +- zero_trust.TunnelConfigurationGetResponseUnion Methods: -- client.ZeroTrust.Tunnels.Configurations.Update(ctx context.Context, tunnelID string, params zero_trust.TunnelConfigurationUpdateParams) (zero_trust.TunnelConfigurationUpdateResponse, error) -- client.ZeroTrust.Tunnels.Configurations.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelConfigurationGetParams) (zero_trust.TunnelConfigurationGetResponse, error) +- client.ZeroTrust.Tunnels.Configurations.Update(ctx context.Context, tunnelID string, params zero_trust.TunnelConfigurationUpdateParams) (zero_trust.TunnelConfigurationUpdateResponseUnion, error) +- client.ZeroTrust.Tunnels.Configurations.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelConfigurationGetParams) (zero_trust.TunnelConfigurationGetResponseUnion, error) ### Connections Response Types: -- zero_trust.TunnelTunnelClient -- zero_trust.TunnelConnectionDeleteResponse +- zero_trust.Client +- zero_trust.TunnelConnectionDeleteResponseUnion Methods: -- client.ZeroTrust.Tunnels.Connections.Delete(ctx context.Context, tunnelID string, params zero_trust.TunnelConnectionDeleteParams) (zero_trust.TunnelConnectionDeleteResponse, error) -- client.ZeroTrust.Tunnels.Connections.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelConnectionGetParams) ([]zero_trust.TunnelTunnelClient, error) +- client.ZeroTrust.Tunnels.Connections.Delete(ctx context.Context, tunnelID string, params zero_trust.TunnelConnectionDeleteParams) (zero_trust.TunnelConnectionDeleteResponseUnion, error) +- client.ZeroTrust.Tunnels.Connections.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelConnectionGetParams) ([]zero_trust.Client, error) ### Token Response Types: -- zero_trust.TunnelTokenGetResponse +- zero_trust.TunnelTokenGetResponseUnion Methods: -- client.ZeroTrust.Tunnels.Token.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelTokenGetParams) (zero_trust.TunnelTokenGetResponse, error) +- client.ZeroTrust.Tunnels.Token.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelTokenGetParams) (zero_trust.TunnelTokenGetResponseUnion, error) ### Connectors Methods: -- client.ZeroTrust.Tunnels.Connectors.Get(ctx context.Context, tunnelID string, connectorID string, query zero_trust.TunnelConnectorGetParams) (zero_trust.TunnelTunnelClient, error) +- client.ZeroTrust.Tunnels.Connectors.Get(ctx context.Context, tunnelID string, connectorID string, query zero_trust.TunnelConnectorGetParams) (zero_trust.Client, error) ### Management Response Types: -- zero_trust.TunnelManagementNewResponse +- zero_trust.TunnelManagementNewResponseUnion Methods: -- client.ZeroTrust.Tunnels.Management.New(ctx context.Context, tunnelID string, params zero_trust.TunnelManagementNewParams) (zero_trust.TunnelManagementNewResponse, error) +- client.ZeroTrust.Tunnels.Management.New(ctx context.Context, tunnelID string, params zero_trust.TunnelManagementNewParams) (zero_trust.TunnelManagementNewResponseUnion, error) ## ConnectivitySettings @@ -4852,38 +5202,34 @@ Methods: Response Types: -- zero_trust.DLPDataset -- zero_trust.DLPDatasetArray -- zero_trust.DLPDatasetCreation +- zero_trust.Dataset +- zero_trust.DatasetArray +- zero_trust.DatasetCreation Methods: -- client.ZeroTrust.DLP.Datasets.New(ctx context.Context, params zero_trust.DLPDatasetNewParams) (zero_trust.DLPDatasetCreation, error) -- client.ZeroTrust.DLP.Datasets.Update(ctx context.Context, datasetID string, params zero_trust.DLPDatasetUpdateParams) (zero_trust.DLPDataset, error) -- client.ZeroTrust.DLP.Datasets.List(ctx context.Context, query zero_trust.DLPDatasetListParams) (pagination.SinglePage[zero_trust.DLPDataset], error) +- client.ZeroTrust.DLP.Datasets.New(ctx context.Context, params zero_trust.DLPDatasetNewParams) (zero_trust.DatasetCreation, error) +- client.ZeroTrust.DLP.Datasets.Update(ctx context.Context, datasetID string, params zero_trust.DLPDatasetUpdateParams) (zero_trust.Dataset, error) +- client.ZeroTrust.DLP.Datasets.List(ctx context.Context, query zero_trust.DLPDatasetListParams) (pagination.SinglePage[zero_trust.Dataset], error) - client.ZeroTrust.DLP.Datasets.Delete(ctx context.Context, datasetID string, body zero_trust.DLPDatasetDeleteParams) error -- client.ZeroTrust.DLP.Datasets.Get(ctx context.Context, datasetID string, query zero_trust.DLPDatasetGetParams) (zero_trust.DLPDataset, error) +- client.ZeroTrust.DLP.Datasets.Get(ctx context.Context, datasetID string, query zero_trust.DLPDatasetGetParams) (zero_trust.Dataset, error) #### Upload Response Types: -- zero_trust.DLPDatasetNewVersion +- zero_trust.NewVersion Methods: -- client.ZeroTrust.DLP.Datasets.Upload.New(ctx context.Context, datasetID string, body zero_trust.DLPDatasetUploadNewParams) (zero_trust.DLPDatasetNewVersion, error) -- client.ZeroTrust.DLP.Datasets.Upload.Edit(ctx context.Context, datasetID string, version int64, body zero_trust.DLPDatasetUploadEditParams) (zero_trust.DLPDataset, error) +- client.ZeroTrust.DLP.Datasets.Upload.New(ctx context.Context, datasetID string, body zero_trust.DLPDatasetUploadNewParams) (zero_trust.NewVersion, error) +- client.ZeroTrust.DLP.Datasets.Upload.Edit(ctx context.Context, datasetID string, version int64, params zero_trust.DLPDatasetUploadEditParams) (zero_trust.Dataset, error) ### Patterns -Response Types: - -- zero_trust.DLPPatternValidateResponse - Methods: -- client.ZeroTrust.DLP.Patterns.Validate(ctx context.Context, params zero_trust.DLPPatternValidateParams) (zero_trust.DLPPatternValidateResponse, error) +- client.ZeroTrust.DLP.Patterns.Validate(ctx context.Context, params zero_trust.DLPPatternValidateParams) (logpush.OwnershipValidation, error) ### PayloadLogs @@ -4899,40 +5245,52 @@ Methods: ### Profiles +Params Types: + +- zero_trust.ContextAwarenessParam +- zero_trust.SkipConfigurationParam + Response Types: -- zero_trust.DLPProfiles +- zero_trust.ContextAwareness +- zero_trust.Profile +- zero_trust.SkipConfiguration - zero_trust.DLPProfileGetResponse Methods: -- client.ZeroTrust.DLP.Profiles.List(ctx context.Context, query zero_trust.DLPProfileListParams) (pagination.SinglePage[zero_trust.DLPProfiles], error) +- client.ZeroTrust.DLP.Profiles.List(ctx context.Context, query zero_trust.DLPProfileListParams) (pagination.SinglePage[zero_trust.Profile], error) - client.ZeroTrust.DLP.Profiles.Get(ctx context.Context, profileID string, query zero_trust.DLPProfileGetParams) (zero_trust.DLPProfileGetResponse, error) #### Custom +Params Types: + +- zero_trust.PatternParam + Response Types: -- zero_trust.DLPCustomProfile -- zero_trust.DLPProfileCustomDeleteResponse +- zero_trust.CustomProfile +- zero_trust.Pattern +- zero_trust.DLPProfileCustomDeleteResponseUnion Methods: -- client.ZeroTrust.DLP.Profiles.Custom.New(ctx context.Context, params zero_trust.DLPProfileCustomNewParams) ([]zero_trust.DLPCustomProfile, error) -- client.ZeroTrust.DLP.Profiles.Custom.Update(ctx context.Context, profileID string, params zero_trust.DLPProfileCustomUpdateParams) (zero_trust.DLPCustomProfile, error) -- client.ZeroTrust.DLP.Profiles.Custom.Delete(ctx context.Context, profileID string, body zero_trust.DLPProfileCustomDeleteParams) (zero_trust.DLPProfileCustomDeleteResponse, error) -- client.ZeroTrust.DLP.Profiles.Custom.Get(ctx context.Context, profileID string, query zero_trust.DLPProfileCustomGetParams) (zero_trust.DLPCustomProfile, error) +- client.ZeroTrust.DLP.Profiles.Custom.New(ctx context.Context, params zero_trust.DLPProfileCustomNewParams) ([]zero_trust.CustomProfile, error) +- client.ZeroTrust.DLP.Profiles.Custom.Update(ctx context.Context, profileID string, params zero_trust.DLPProfileCustomUpdateParams) (zero_trust.CustomProfile, error) +- client.ZeroTrust.DLP.Profiles.Custom.Delete(ctx context.Context, profileID string, params zero_trust.DLPProfileCustomDeleteParams) (zero_trust.DLPProfileCustomDeleteResponseUnion, error) +- client.ZeroTrust.DLP.Profiles.Custom.Get(ctx context.Context, profileID string, query zero_trust.DLPProfileCustomGetParams) (zero_trust.CustomProfile, error) #### Predefined Response Types: -- zero_trust.DLPPredefinedProfile +- zero_trust.PredefinedProfile Methods: -- client.ZeroTrust.DLP.Profiles.Predefined.Update(ctx context.Context, profileID string, params zero_trust.DLPProfilePredefinedUpdateParams) (zero_trust.DLPPredefinedProfile, error) -- client.ZeroTrust.DLP.Profiles.Predefined.Get(ctx context.Context, profileID string, query zero_trust.DLPProfilePredefinedGetParams) (zero_trust.DLPPredefinedProfile, error) +- client.ZeroTrust.DLP.Profiles.Predefined.Update(ctx context.Context, profileID string, params zero_trust.DLPProfilePredefinedUpdateParams) (zero_trust.PredefinedProfile, error) +- client.ZeroTrust.DLP.Profiles.Predefined.Get(ctx context.Context, profileID string, query zero_trust.DLPProfilePredefinedGetParams) (zero_trust.PredefinedProfile, error) ## Gateway @@ -4950,37 +5308,64 @@ Methods: Response Types: -- zero_trust.ZeroTrustGatewaySettings +- zero_trust.GatewaySettings Methods: -- client.ZeroTrust.Gateway.AuditSSHSettings.Update(ctx context.Context, params zero_trust.GatewayAuditSSHSettingUpdateParams) (zero_trust.ZeroTrustGatewaySettings, error) -- client.ZeroTrust.Gateway.AuditSSHSettings.Get(ctx context.Context, query zero_trust.GatewayAuditSSHSettingGetParams) (zero_trust.ZeroTrustGatewaySettings, error) +- client.ZeroTrust.Gateway.AuditSSHSettings.Update(ctx context.Context, params zero_trust.GatewayAuditSSHSettingUpdateParams) (zero_trust.GatewaySettings, error) +- client.ZeroTrust.Gateway.AuditSSHSettings.Get(ctx context.Context, query zero_trust.GatewayAuditSSHSettingGetParams) (zero_trust.GatewaySettings, error) ### Categories Response Types: -- zero_trust.ZeroTrustGatewayCategories +- zero_trust.Category Methods: -- client.ZeroTrust.Gateway.Categories.List(ctx context.Context, query zero_trust.GatewayCategoryListParams) (pagination.SinglePage[zero_trust.ZeroTrustGatewayCategories], error) +- client.ZeroTrust.Gateway.Categories.List(ctx context.Context, query zero_trust.GatewayCategoryListParams) (pagination.SinglePage[zero_trust.Category], error) ### AppTypes Response Types: -- zero_trust.ZeroTrustGatewayAppTypes +- zero_trust.AppType Methods: -- client.ZeroTrust.Gateway.AppTypes.List(ctx context.Context, query zero_trust.GatewayAppTypeListParams) (pagination.SinglePage[zero_trust.ZeroTrustGatewayAppTypes], error) +- client.ZeroTrust.Gateway.AppTypes.List(ctx context.Context, query zero_trust.GatewayAppTypeListParams) (pagination.SinglePage[zero_trust.AppType], error) ### Configurations -Response Types: +Params Types: +- zero_trust.ActivityLogSettingsParam +- zero_trust.AntiVirusSettingsParam +- zero_trust.BlockPageSettingsParam +- zero_trust.BodyScanningSettingsParam +- zero_trust.BrowserIsolationSettingsParam +- zero_trust.CustomCertificateSettingsParam +- zero_trust.ExtendedEmailMatchingParam +- zero_trust.FipsSettingsParam +- zero_trust.GatewayConfigurationSettingsParam +- zero_trust.NotificationSettingsParam +- zero_trust.ProtocolDetectionParam +- zero_trust.TLSSettingsParam + +Response Types: + +- zero_trust.ActivityLogSettings +- zero_trust.AntiVirusSettings +- zero_trust.BlockPageSettings +- zero_trust.BodyScanningSettings +- zero_trust.BrowserIsolationSettings +- zero_trust.CustomCertificateSettings +- zero_trust.ExtendedEmailMatching +- zero_trust.FipsSettings +- zero_trust.GatewayConfigurationSettings +- zero_trust.NotificationSettings +- zero_trust.ProtocolDetection +- zero_trust.TLSSettings - zero_trust.GatewayConfigurationUpdateResponse - zero_trust.GatewayConfigurationEditResponse - zero_trust.GatewayConfigurationGetResponse @@ -4993,172 +5378,214 @@ Methods: ### Lists +Params Types: + +- zero_trust.GatewayItemParam + Response Types: -- zero_trust.ZeroTrustGatewayLists +- zero_trust.GatewayItem +- zero_trust.GatewayList - zero_trust.GatewayListNewResponse -- zero_trust.GatewayListDeleteResponse +- zero_trust.GatewayListDeleteResponseUnion Methods: - client.ZeroTrust.Gateway.Lists.New(ctx context.Context, params zero_trust.GatewayListNewParams) (zero_trust.GatewayListNewResponse, error) -- client.ZeroTrust.Gateway.Lists.Update(ctx context.Context, listID string, params zero_trust.GatewayListUpdateParams) (zero_trust.ZeroTrustGatewayLists, error) -- client.ZeroTrust.Gateway.Lists.List(ctx context.Context, query zero_trust.GatewayListListParams) (pagination.SinglePage[zero_trust.ZeroTrustGatewayLists], error) -- client.ZeroTrust.Gateway.Lists.Delete(ctx context.Context, listID string, body zero_trust.GatewayListDeleteParams) (zero_trust.GatewayListDeleteResponse, error) -- client.ZeroTrust.Gateway.Lists.Edit(ctx context.Context, listID string, params zero_trust.GatewayListEditParams) (zero_trust.ZeroTrustGatewayLists, error) -- client.ZeroTrust.Gateway.Lists.Get(ctx context.Context, listID string, query zero_trust.GatewayListGetParams) (zero_trust.ZeroTrustGatewayLists, error) +- client.ZeroTrust.Gateway.Lists.Update(ctx context.Context, listID string, params zero_trust.GatewayListUpdateParams) (zero_trust.GatewayList, error) +- client.ZeroTrust.Gateway.Lists.List(ctx context.Context, query zero_trust.GatewayListListParams) (pagination.SinglePage[zero_trust.GatewayList], error) +- client.ZeroTrust.Gateway.Lists.Delete(ctx context.Context, listID string, params zero_trust.GatewayListDeleteParams) (zero_trust.GatewayListDeleteResponseUnion, error) +- client.ZeroTrust.Gateway.Lists.Edit(ctx context.Context, listID string, params zero_trust.GatewayListEditParams) (zero_trust.GatewayList, error) +- client.ZeroTrust.Gateway.Lists.Get(ctx context.Context, listID string, query zero_trust.GatewayListGetParams) (zero_trust.GatewayList, error) #### Items -Response Types: - -- zero_trust.GatewayListItemListResponse - Methods: -- client.ZeroTrust.Gateway.Lists.Items.List(ctx context.Context, listID string, query zero_trust.GatewayListItemListParams) (pagination.SinglePage[[]zero_trust.GatewayListItemListResponse], error) +- client.ZeroTrust.Gateway.Lists.Items.List(ctx context.Context, listID string, query zero_trust.GatewayListItemListParams) (pagination.SinglePage[[]zero_trust.GatewayItem], error) ### Locations +Params Types: + +- zero_trust.LocationNetworkParam + Response Types: -- zero_trust.ZeroTrustGatewayLocations -- zero_trust.GatewayLocationDeleteResponse +- zero_trust.Location +- zero_trust.LocationNetwork +- zero_trust.GatewayLocationDeleteResponseUnion Methods: -- client.ZeroTrust.Gateway.Locations.New(ctx context.Context, params zero_trust.GatewayLocationNewParams) (zero_trust.ZeroTrustGatewayLocations, error) -- client.ZeroTrust.Gateway.Locations.Update(ctx context.Context, locationID string, params zero_trust.GatewayLocationUpdateParams) (zero_trust.ZeroTrustGatewayLocations, error) -- client.ZeroTrust.Gateway.Locations.List(ctx context.Context, query zero_trust.GatewayLocationListParams) (pagination.SinglePage[zero_trust.ZeroTrustGatewayLocations], error) -- client.ZeroTrust.Gateway.Locations.Delete(ctx context.Context, locationID string, body zero_trust.GatewayLocationDeleteParams) (zero_trust.GatewayLocationDeleteResponse, error) -- client.ZeroTrust.Gateway.Locations.Get(ctx context.Context, locationID string, query zero_trust.GatewayLocationGetParams) (zero_trust.ZeroTrustGatewayLocations, error) +- client.ZeroTrust.Gateway.Locations.New(ctx context.Context, params zero_trust.GatewayLocationNewParams) (zero_trust.Location, error) +- client.ZeroTrust.Gateway.Locations.Update(ctx context.Context, locationID string, params zero_trust.GatewayLocationUpdateParams) (zero_trust.Location, error) +- client.ZeroTrust.Gateway.Locations.List(ctx context.Context, query zero_trust.GatewayLocationListParams) (pagination.SinglePage[zero_trust.Location], error) +- client.ZeroTrust.Gateway.Locations.Delete(ctx context.Context, locationID string, params zero_trust.GatewayLocationDeleteParams) (zero_trust.GatewayLocationDeleteResponseUnion, error) +- client.ZeroTrust.Gateway.Locations.Get(ctx context.Context, locationID string, query zero_trust.GatewayLocationGetParams) (zero_trust.Location, error) ### Logging +Params Types: + +- zero_trust.LoggingSettingParam + Response Types: -- zero_trust.ZeroTrustGatewayGatewayAccountLoggingSettings +- zero_trust.LoggingSetting Methods: -- client.ZeroTrust.Gateway.Logging.Update(ctx context.Context, params zero_trust.GatewayLoggingUpdateParams) (zero_trust.ZeroTrustGatewayGatewayAccountLoggingSettings, error) -- client.ZeroTrust.Gateway.Logging.Get(ctx context.Context, query zero_trust.GatewayLoggingGetParams) (zero_trust.ZeroTrustGatewayGatewayAccountLoggingSettings, error) +- client.ZeroTrust.Gateway.Logging.Update(ctx context.Context, params zero_trust.GatewayLoggingUpdateParams) (zero_trust.LoggingSetting, error) +- client.ZeroTrust.Gateway.Logging.Get(ctx context.Context, query zero_trust.GatewayLoggingGetParams) (zero_trust.LoggingSetting, error) ### ProxyEndpoints +Params Types: + +- zero_trust.GatewayIPsParam + Response Types: -- zero_trust.ZeroTrustGatewayProxyEndpoints -- zero_trust.GatewayProxyEndpointDeleteResponse +- zero_trust.GatewayIPs +- zero_trust.ProxyEndpoint +- zero_trust.GatewayProxyEndpointDeleteResponseUnion Methods: -- client.ZeroTrust.Gateway.ProxyEndpoints.New(ctx context.Context, params zero_trust.GatewayProxyEndpointNewParams) (zero_trust.ZeroTrustGatewayProxyEndpoints, error) -- client.ZeroTrust.Gateway.ProxyEndpoints.List(ctx context.Context, query zero_trust.GatewayProxyEndpointListParams) (pagination.SinglePage[zero_trust.ZeroTrustGatewayProxyEndpoints], error) -- client.ZeroTrust.Gateway.ProxyEndpoints.Delete(ctx context.Context, proxyEndpointID string, body zero_trust.GatewayProxyEndpointDeleteParams) (zero_trust.GatewayProxyEndpointDeleteResponse, error) -- client.ZeroTrust.Gateway.ProxyEndpoints.Edit(ctx context.Context, proxyEndpointID string, params zero_trust.GatewayProxyEndpointEditParams) (zero_trust.ZeroTrustGatewayProxyEndpoints, error) -- client.ZeroTrust.Gateway.ProxyEndpoints.Get(ctx context.Context, proxyEndpointID string, query zero_trust.GatewayProxyEndpointGetParams) (zero_trust.ZeroTrustGatewayProxyEndpoints, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.New(ctx context.Context, params zero_trust.GatewayProxyEndpointNewParams) (zero_trust.ProxyEndpoint, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.List(ctx context.Context, query zero_trust.GatewayProxyEndpointListParams) (pagination.SinglePage[zero_trust.ProxyEndpoint], error) +- client.ZeroTrust.Gateway.ProxyEndpoints.Delete(ctx context.Context, proxyEndpointID string, params zero_trust.GatewayProxyEndpointDeleteParams) (zero_trust.GatewayProxyEndpointDeleteResponseUnion, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.Edit(ctx context.Context, proxyEndpointID string, params zero_trust.GatewayProxyEndpointEditParams) (zero_trust.ProxyEndpoint, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.Get(ctx context.Context, proxyEndpointID string, query zero_trust.GatewayProxyEndpointGetParams) (zero_trust.ProxyEndpoint, error) ### Rules +Params Types: + +- zero_trust.DNSResolverSettingsV4Param +- zero_trust.DNSResolverSettingsV6Param +- zero_trust.GatewayFilter +- zero_trust.RuleSettingParam +- zero_trust.ScheduleParam + Response Types: -- zero_trust.ZeroTrustGatewayRules -- zero_trust.GatewayRuleDeleteResponse +- zero_trust.DNSResolverSettingsV4 +- zero_trust.DNSResolverSettingsV6 +- zero_trust.GatewayFilter +- zero_trust.GatewayRule +- zero_trust.RuleSetting +- zero_trust.Schedule +- zero_trust.GatewayRuleDeleteResponseUnion Methods: -- client.ZeroTrust.Gateway.Rules.New(ctx context.Context, params zero_trust.GatewayRuleNewParams) (zero_trust.ZeroTrustGatewayRules, error) -- client.ZeroTrust.Gateway.Rules.Update(ctx context.Context, ruleID string, params zero_trust.GatewayRuleUpdateParams) (zero_trust.ZeroTrustGatewayRules, error) -- client.ZeroTrust.Gateway.Rules.List(ctx context.Context, query zero_trust.GatewayRuleListParams) (pagination.SinglePage[zero_trust.ZeroTrustGatewayRules], error) -- client.ZeroTrust.Gateway.Rules.Delete(ctx context.Context, ruleID string, body zero_trust.GatewayRuleDeleteParams) (zero_trust.GatewayRuleDeleteResponse, error) -- client.ZeroTrust.Gateway.Rules.Get(ctx context.Context, ruleID string, query zero_trust.GatewayRuleGetParams) (zero_trust.ZeroTrustGatewayRules, error) +- client.ZeroTrust.Gateway.Rules.New(ctx context.Context, params zero_trust.GatewayRuleNewParams) (zero_trust.GatewayRule, error) +- client.ZeroTrust.Gateway.Rules.Update(ctx context.Context, ruleID string, params zero_trust.GatewayRuleUpdateParams) (zero_trust.GatewayRule, error) +- client.ZeroTrust.Gateway.Rules.List(ctx context.Context, query zero_trust.GatewayRuleListParams) (pagination.SinglePage[zero_trust.GatewayRule], error) +- client.ZeroTrust.Gateway.Rules.Delete(ctx context.Context, ruleID string, params zero_trust.GatewayRuleDeleteParams) (zero_trust.GatewayRuleDeleteResponseUnion, error) +- client.ZeroTrust.Gateway.Rules.Get(ctx context.Context, ruleID string, query zero_trust.GatewayRuleGetParams) (zero_trust.GatewayRule, error) ## Networks ### Routes +Params Types: + +- zero_trust.RouteParam + Response Types: -- zero_trust.TunnelRoute -- zero_trust.TunnelTeamnet +- zero_trust.Route +- zero_trust.Teamnet Methods: -- client.ZeroTrust.Networks.Routes.New(ctx context.Context, params zero_trust.NetworkRouteNewParams) (zero_trust.TunnelRoute, error) -- client.ZeroTrust.Networks.Routes.List(ctx context.Context, params zero_trust.NetworkRouteListParams) (pagination.V4PagePaginationArray[zero_trust.TunnelTeamnet], error) -- client.ZeroTrust.Networks.Routes.Delete(ctx context.Context, routeID string, body zero_trust.NetworkRouteDeleteParams) (zero_trust.TunnelRoute, error) -- client.ZeroTrust.Networks.Routes.Edit(ctx context.Context, routeID string, params zero_trust.NetworkRouteEditParams) (zero_trust.TunnelRoute, error) +- client.ZeroTrust.Networks.Routes.New(ctx context.Context, params zero_trust.NetworkRouteNewParams) (zero_trust.Route, error) +- client.ZeroTrust.Networks.Routes.List(ctx context.Context, params zero_trust.NetworkRouteListParams) (pagination.V4PagePaginationArray[zero_trust.Teamnet], error) +- client.ZeroTrust.Networks.Routes.Delete(ctx context.Context, routeID string, body zero_trust.NetworkRouteDeleteParams) (zero_trust.Route, error) +- client.ZeroTrust.Networks.Routes.Edit(ctx context.Context, routeID string, params zero_trust.NetworkRouteEditParams) (zero_trust.Route, error) #### IPs Methods: -- client.ZeroTrust.Networks.Routes.IPs.Get(ctx context.Context, ip string, params zero_trust.NetworkRouteIPGetParams) (zero_trust.TunnelTeamnet, error) +- client.ZeroTrust.Networks.Routes.IPs.Get(ctx context.Context, ip string, params zero_trust.NetworkRouteIPGetParams) (zero_trust.Teamnet, error) #### Networks Methods: -- client.ZeroTrust.Networks.Routes.Networks.New(ctx context.Context, ipNetworkEncoded string, params zero_trust.NetworkRouteNetworkNewParams) (zero_trust.TunnelRoute, error) -- client.ZeroTrust.Networks.Routes.Networks.Delete(ctx context.Context, ipNetworkEncoded string, params zero_trust.NetworkRouteNetworkDeleteParams) (zero_trust.TunnelRoute, error) -- client.ZeroTrust.Networks.Routes.Networks.Edit(ctx context.Context, ipNetworkEncoded string, body zero_trust.NetworkRouteNetworkEditParams) (zero_trust.TunnelRoute, error) +- client.ZeroTrust.Networks.Routes.Networks.New(ctx context.Context, ipNetworkEncoded string, params zero_trust.NetworkRouteNetworkNewParams) (zero_trust.Route, error) +- client.ZeroTrust.Networks.Routes.Networks.Delete(ctx context.Context, ipNetworkEncoded string, params zero_trust.NetworkRouteNetworkDeleteParams) (zero_trust.Route, error) +- client.ZeroTrust.Networks.Routes.Networks.Edit(ctx context.Context, ipNetworkEncoded string, body zero_trust.NetworkRouteNetworkEditParams) (zero_trust.Route, error) ### VirtualNetworks Response Types: -- zero_trust.TunnelVirtualNetwork -- zero_trust.NetworkVirtualNetworkNewResponse -- zero_trust.NetworkVirtualNetworkDeleteResponse -- zero_trust.NetworkVirtualNetworkEditResponse +- zero_trust.VirtualNetwork +- zero_trust.NetworkVirtualNetworkNewResponseUnion +- zero_trust.NetworkVirtualNetworkDeleteResponseUnion +- zero_trust.NetworkVirtualNetworkEditResponseUnion Methods: -- client.ZeroTrust.Networks.VirtualNetworks.New(ctx context.Context, params zero_trust.NetworkVirtualNetworkNewParams) (zero_trust.NetworkVirtualNetworkNewResponse, error) -- client.ZeroTrust.Networks.VirtualNetworks.List(ctx context.Context, params zero_trust.NetworkVirtualNetworkListParams) (pagination.SinglePage[zero_trust.TunnelVirtualNetwork], error) -- client.ZeroTrust.Networks.VirtualNetworks.Delete(ctx context.Context, virtualNetworkID string, body zero_trust.NetworkVirtualNetworkDeleteParams) (zero_trust.NetworkVirtualNetworkDeleteResponse, error) -- client.ZeroTrust.Networks.VirtualNetworks.Edit(ctx context.Context, virtualNetworkID string, params zero_trust.NetworkVirtualNetworkEditParams) (zero_trust.NetworkVirtualNetworkEditResponse, error) +- client.ZeroTrust.Networks.VirtualNetworks.New(ctx context.Context, params zero_trust.NetworkVirtualNetworkNewParams) (zero_trust.NetworkVirtualNetworkNewResponseUnion, error) +- client.ZeroTrust.Networks.VirtualNetworks.List(ctx context.Context, params zero_trust.NetworkVirtualNetworkListParams) (pagination.SinglePage[zero_trust.VirtualNetwork], error) +- client.ZeroTrust.Networks.VirtualNetworks.Delete(ctx context.Context, virtualNetworkID string, params zero_trust.NetworkVirtualNetworkDeleteParams) (zero_trust.NetworkVirtualNetworkDeleteResponseUnion, error) +- client.ZeroTrust.Networks.VirtualNetworks.Edit(ctx context.Context, virtualNetworkID string, params zero_trust.NetworkVirtualNetworkEditParams) (zero_trust.NetworkVirtualNetworkEditResponseUnion, error) # Challenges ## Widgets +Params Types: + +- challenges.WidgetDomainParam + Response Types: -- challenges.ChallengesWidget -- challenges.ChallengesWidgetList +- challenges.Widget +- challenges.WidgetDomain +- challenges.WidgetListResponse Methods: -- client.Challenges.Widgets.New(ctx context.Context, params challenges.WidgetNewParams) (challenges.ChallengesWidget, error) -- client.Challenges.Widgets.Update(ctx context.Context, sitekey string, params challenges.WidgetUpdateParams) (challenges.ChallengesWidget, error) -- client.Challenges.Widgets.List(ctx context.Context, params challenges.WidgetListParams) (pagination.V4PagePaginationArray[challenges.ChallengesWidgetList], error) -- client.Challenges.Widgets.Delete(ctx context.Context, sitekey string, body challenges.WidgetDeleteParams) (challenges.ChallengesWidget, error) -- client.Challenges.Widgets.Get(ctx context.Context, sitekey string, query challenges.WidgetGetParams) (challenges.ChallengesWidget, error) -- client.Challenges.Widgets.RotateSecret(ctx context.Context, sitekey string, params challenges.WidgetRotateSecretParams) (challenges.ChallengesWidget, error) +- 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.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) # Hyperdrive +Params Types: + +- hyperdrive.ConfigurationParam +- hyperdrive.HyperdriveParam + +Response Types: + +- hyperdrive.Configuration +- hyperdrive.Hyperdrive + ## Configs Response Types: -- hyperdrive.ConfigNewResponse -- hyperdrive.ConfigUpdateResponse -- hyperdrive.ConfigListResponse -- hyperdrive.ConfigDeleteResponse -- hyperdrive.ConfigEditResponse -- hyperdrive.ConfigGetResponse +- hyperdrive.ConfigDeleteResponseUnion Methods: -- client.Hyperdrive.Configs.New(ctx context.Context, params hyperdrive.ConfigNewParams) (hyperdrive.ConfigNewResponse, error) -- client.Hyperdrive.Configs.Update(ctx context.Context, hyperdriveID string, params hyperdrive.ConfigUpdateParams) (hyperdrive.ConfigUpdateResponse, error) -- client.Hyperdrive.Configs.List(ctx context.Context, query hyperdrive.ConfigListParams) (pagination.SinglePage[hyperdrive.ConfigListResponse], error) -- client.Hyperdrive.Configs.Delete(ctx context.Context, hyperdriveID string, body hyperdrive.ConfigDeleteParams) (hyperdrive.ConfigDeleteResponse, error) -- client.Hyperdrive.Configs.Edit(ctx context.Context, hyperdriveID string, params hyperdrive.ConfigEditParams) (hyperdrive.ConfigEditResponse, error) -- client.Hyperdrive.Configs.Get(ctx context.Context, hyperdriveID string, query hyperdrive.ConfigGetParams) (hyperdrive.ConfigGetResponse, error) +- client.Hyperdrive.Configs.New(ctx context.Context, params hyperdrive.ConfigNewParams) (hyperdrive.Hyperdrive, error) +- client.Hyperdrive.Configs.Update(ctx context.Context, hyperdriveID string, params hyperdrive.ConfigUpdateParams) (hyperdrive.Hyperdrive, error) +- client.Hyperdrive.Configs.List(ctx context.Context, query hyperdrive.ConfigListParams) (pagination.SinglePage[hyperdrive.Hyperdrive], error) +- client.Hyperdrive.Configs.Delete(ctx context.Context, hyperdriveID string, body hyperdrive.ConfigDeleteParams) (hyperdrive.ConfigDeleteResponseUnion, error) +- client.Hyperdrive.Configs.Edit(ctx context.Context, hyperdriveID string, params hyperdrive.ConfigEditParams) (hyperdrive.Hyperdrive, error) +- client.Hyperdrive.Configs.Get(ctx context.Context, hyperdriveID string, query hyperdrive.ConfigGetParams) (hyperdrive.Hyperdrive, error) # RUM @@ -5166,16 +5593,16 @@ Methods: Response Types: -- rum.RUMSite +- rum.Site - rum.SiteInfoDeleteResponse Methods: -- client.RUM.SiteInfo.New(ctx context.Context, params rum.SiteInfoNewParams) (rum.RUMSite, error) -- client.RUM.SiteInfo.Update(ctx context.Context, siteID string, params rum.SiteInfoUpdateParams) (rum.RUMSite, error) -- client.RUM.SiteInfo.List(ctx context.Context, params rum.SiteInfoListParams) (pagination.V4PagePaginationArray[rum.RUMSite], error) +- client.RUM.SiteInfo.New(ctx context.Context, params rum.SiteInfoNewParams) (rum.Site, error) +- client.RUM.SiteInfo.Update(ctx context.Context, siteID string, params rum.SiteInfoUpdateParams) (rum.Site, error) +- client.RUM.SiteInfo.List(ctx context.Context, params rum.SiteInfoListParams) (pagination.V4PagePaginationArray[rum.Site], error) - client.RUM.SiteInfo.Delete(ctx context.Context, siteID string, body rum.SiteInfoDeleteParams) (rum.SiteInfoDeleteResponse, error) -- client.RUM.SiteInfo.Get(ctx context.Context, siteID string, query rum.SiteInfoGetParams) (rum.RUMSite, error) +- client.RUM.SiteInfo.Get(ctx context.Context, siteID string, query rum.SiteInfoGetParams) (rum.Site, error) ## Rules @@ -5196,28 +5623,33 @@ Methods: ## Indexes +Params Types: + +- vectorize.IndexDimensionConfigurationParam + Response Types: -- vectorize.VectorizeCreateIndex -- vectorize.VectorizeIndexDeleteVectorsByID -- vectorize.VectorizeIndexInsert -- vectorize.VectorizeIndexQuery -- vectorize.VectorizeIndexUpsert -- vectorize.IndexDeleteResponse +- vectorize.CreateIndex +- vectorize.IndexDeleteVectorsByID +- vectorize.IndexDimensionConfiguration +- vectorize.IndexInsert +- vectorize.IndexQuery +- vectorize.IndexUpsert +- vectorize.IndexDeleteResponseUnion - vectorize.IndexGetByIDsResponse Methods: -- client.Vectorize.Indexes.New(ctx context.Context, accountIdentifier string, body vectorize.IndexNewParams) (vectorize.VectorizeCreateIndex, error) -- client.Vectorize.Indexes.Update(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexUpdateParams) (vectorize.VectorizeCreateIndex, error) -- client.Vectorize.Indexes.List(ctx context.Context, accountIdentifier string) (pagination.SinglePage[vectorize.VectorizeCreateIndex], error) -- client.Vectorize.Indexes.Delete(ctx context.Context, accountIdentifier string, indexName string) (vectorize.IndexDeleteResponse, error) -- client.Vectorize.Indexes.DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexDeleteByIDsParams) (vectorize.VectorizeIndexDeleteVectorsByID, error) -- client.Vectorize.Indexes.Get(ctx context.Context, accountIdentifier string, indexName string) (vectorize.VectorizeCreateIndex, error) +- client.Vectorize.Indexes.New(ctx context.Context, accountIdentifier string, body vectorize.IndexNewParams) (vectorize.CreateIndex, error) +- client.Vectorize.Indexes.Update(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexUpdateParams) (vectorize.CreateIndex, error) +- client.Vectorize.Indexes.List(ctx context.Context, accountIdentifier string) (pagination.SinglePage[vectorize.CreateIndex], error) +- client.Vectorize.Indexes.Delete(ctx context.Context, accountIdentifier string, indexName string) (vectorize.IndexDeleteResponseUnion, error) +- client.Vectorize.Indexes.DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexDeleteByIDsParams) (vectorize.IndexDeleteVectorsByID, error) +- client.Vectorize.Indexes.Get(ctx context.Context, accountIdentifier string, indexName string) (vectorize.CreateIndex, error) - client.Vectorize.Indexes.GetByIDs(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexGetByIDsParams) (vectorize.IndexGetByIDsResponse, error) -- client.Vectorize.Indexes.Insert(ctx context.Context, accountIdentifier string, indexName string) (vectorize.VectorizeIndexInsert, error) -- client.Vectorize.Indexes.Query(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexQueryParams) (vectorize.VectorizeIndexQuery, error) -- client.Vectorize.Indexes.Upsert(ctx context.Context, accountIdentifier string, indexName string) (vectorize.VectorizeIndexUpsert, error) +- client.Vectorize.Indexes.Insert(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexInsertParams) (vectorize.IndexInsert, error) +- client.Vectorize.Indexes.Query(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexQueryParams) (vectorize.IndexQuery, error) +- client.Vectorize.Indexes.Upsert(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexUpsertParams) (vectorize.IndexUpsert, error) # URLScanner @@ -5233,6 +5665,7 @@ Methods: Response Types: +- url_scanner.URLScannerDomain - url_scanner.ScanNewResponse - url_scanner.ScanGetResponse - url_scanner.ScanHarResponse @@ -5272,13 +5705,15 @@ Methods: ### Leaks +#### Events + Response Types: -- radar.BGPLeakEventsResponse +- radar.BGPLeakEventListResponse Methods: -- client.Radar.BGP.Leaks.Events(ctx context.Context, query radar.BGPLeakEventsParams) (radar.BGPLeakEventsResponse, error) +- client.Radar.BGP.Leaks.Events.List(ctx context.Context, query radar.BGPLeakEventListParams) (pagination.V4PagePagination[radar.BGPLeakEventListResponse], error) ### Top @@ -5304,13 +5739,15 @@ Methods: ### Hijacks +#### Events + Response Types: -- radar.BGPHijackEventsResponse +- radar.BGPHijackEventListResponse Methods: -- client.Radar.BGP.Hijacks.Events(ctx context.Context, query radar.BGPHijackEventsParams) (radar.BGPHijackEventsResponse, error) +- client.Radar.BGP.Hijacks.Events.List(ctx context.Context, query radar.BGPHijackEventListParams) (pagination.V4PagePagination[radar.BGPHijackEventListResponse], error) ### Routes @@ -5481,6 +5918,11 @@ Methods: ## Email +Response Types: + +- radar.RadarEmailSeries +- radar.RadarEmailSummary + ### Routing #### Summary @@ -5835,6 +6277,7 @@ Methods: Response Types: +- radar.Browser - radar.HTTPTopBrowserFamiliesResponse - radar.HTTPTopBrowsersResponse @@ -6133,8 +6576,19 @@ Methods: # BotManagement +Params Types: + +- bot_management.BotFightModeConfigurationParam +- bot_management.SubscriptionConfigurationParam +- bot_management.SuperBotFightModeDefinitelyConfigurationParam +- bot_management.SuperBotFightModeLikelyConfigurationParam + Response Types: +- bot_management.BotFightModeConfiguration +- bot_management.SubscriptionConfiguration +- bot_management.SuperBotFightModeDefinitelyConfiguration +- bot_management.SuperBotFightModeLikelyConfiguration - bot_management.BotManagementUpdateResponse - bot_management.BotManagementGetResponse @@ -6147,47 +6601,53 @@ Methods: Response Types: -- origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponse -- origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponse +- origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponseUnion +- origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponseUnion Methods: -- client.OriginPostQuantumEncryption.Update(ctx context.Context, params origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateParams) (origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponse, error) -- client.OriginPostQuantumEncryption.Get(ctx context.Context, query origin_post_quantum_encryption.OriginPostQuantumEncryptionGetParams) (origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponse, error) +- client.OriginPostQuantumEncryption.Update(ctx context.Context, params origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateParams) (origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponseUnion, error) +- client.OriginPostQuantumEncryption.Get(ctx context.Context, query origin_post_quantum_encryption.OriginPostQuantumEncryptionGetParams) (origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponseUnion, error) # Speed Response Types: -- speed.ObservatorySchedule -- speed.ObservatoryTrend +- speed.LabeledRegion +- speed.LighthouseReport +- speed.Trend - speed.SpeedDeleteResponse Methods: - client.Speed.Delete(ctx context.Context, url string, params speed.SpeedDeleteParams) (speed.SpeedDeleteResponse, error) -- client.Speed.ScheduleGet(ctx context.Context, url string, params speed.SpeedScheduleGetParams) (speed.ObservatorySchedule, error) -- client.Speed.TrendsList(ctx context.Context, url string, params speed.SpeedTrendsListParams) (speed.ObservatoryTrend, error) +- client.Speed.ScheduleGet(ctx context.Context, url string, params speed.SpeedScheduleGetParams) (speed.Schedule, error) +- client.Speed.TrendsList(ctx context.Context, url string, params speed.SpeedTrendsListParams) (speed.Trend, error) ## Tests Response Types: -- speed.ObservatoryPageTest +- speed.Test - speed.TestListResponse - speed.TestDeleteResponse Methods: -- client.Speed.Tests.New(ctx context.Context, url string, params speed.TestNewParams) (speed.ObservatoryPageTest, error) +- client.Speed.Tests.New(ctx context.Context, url string, params speed.TestNewParams) (speed.Test, error) - client.Speed.Tests.List(ctx context.Context, url string, params speed.TestListParams) (speed.TestListResponse, error) - client.Speed.Tests.Delete(ctx context.Context, url string, params speed.TestDeleteParams) (speed.TestDeleteResponse, error) -- client.Speed.Tests.Get(ctx context.Context, url string, testID string, query speed.TestGetParams) (speed.ObservatoryPageTest, error) +- client.Speed.Tests.Get(ctx context.Context, url string, testID string, query speed.TestGetParams) (speed.Test, error) ## Schedule +Params Types: + +- speed.ScheduleParam + Response Types: +- speed.Schedule - speed.ScheduleNewResponse Methods: @@ -6198,11 +6658,11 @@ Methods: Response Types: -- speed.ObservatoryAvailabilities +- speed.Availability Methods: -- client.Speed.Availabilities.List(ctx context.Context, query speed.AvailabilityListParams) (speed.ObservatoryAvailabilities, error) +- client.Speed.Availabilities.List(ctx context.Context, query speed.AvailabilityListParams) (speed.Availability, error) ## Pages @@ -6232,16 +6692,21 @@ Methods: ### TLS +Params Types: + +- hostnames.SettingValueUnionParam + Response Types: -- hostnames.HostnameSettingDelete -- hostnames.HostnameStting +- hostnames.Setting +- hostnames.SettingValueUnion +- hostnames.SettingTLSDeleteResponse - hostnames.SettingTLSGetResponse Methods: -- client.Hostnames.Settings.TLS.Update(ctx context.Context, settingID hostnames.SettingTLSUpdateParamsSettingID, hostname string, params hostnames.SettingTLSUpdateParams) (hostnames.HostnameStting, error) -- client.Hostnames.Settings.TLS.Delete(ctx context.Context, settingID hostnames.SettingTLSDeleteParamsSettingID, hostname string, body hostnames.SettingTLSDeleteParams) (hostnames.HostnameSettingDelete, error) +- client.Hostnames.Settings.TLS.Update(ctx context.Context, settingID hostnames.SettingTLSUpdateParamsSettingID, hostname string, params hostnames.SettingTLSUpdateParams) (hostnames.Setting, error) +- client.Hostnames.Settings.TLS.Delete(ctx context.Context, settingID hostnames.SettingTLSDeleteParamsSettingID, hostname string, body hostnames.SettingTLSDeleteParams) (hostnames.SettingTLSDeleteResponse, error) - client.Hostnames.Settings.TLS.Get(ctx context.Context, settingID hostnames.SettingTLSGetParamsSettingID, query hostnames.SettingTLSGetParams) ([]hostnames.SettingTLSGetResponse, error) # Snippets @@ -6249,13 +6714,13 @@ Methods: Response Types: - snippets.Snippet -- snippets.SnippetDeleteResponse +- snippets.SnippetDeleteResponseUnion Methods: - client.Snippets.Update(ctx context.Context, zoneIdentifier string, snippetName string, body snippets.SnippetUpdateParams) (snippets.Snippet, error) - client.Snippets.List(ctx context.Context, zoneIdentifier string) (pagination.SinglePage[snippets.Snippet], error) -- client.Snippets.Delete(ctx context.Context, zoneIdentifier string, snippetName string) (snippets.SnippetDeleteResponse, error) +- client.Snippets.Delete(ctx context.Context, zoneIdentifier string, snippetName string) (snippets.SnippetDeleteResponseUnion, error) - client.Snippets.Get(ctx context.Context, zoneIdentifier string, snippetName string) (snippets.Snippet, error) ## Content @@ -6297,49 +6762,55 @@ Methods: Response Types: -- cloudforce_one.CloudforceOneQuota -- cloudforce_one.CloudforceOneRequestConstants -- cloudforce_one.CloudforceOneRequestItem -- cloudforce_one.CloudforceOneRequestListItem -- cloudforce_one.CloudforceOneRequestTypes -- cloudforce_one.RequestDeleteResponse +- cloudforce_one.Item +- cloudforce_one.ListItem +- cloudforce_one.Quota +- cloudforce_one.RequestConstants +- cloudforce_one.RequestTypes +- cloudforce_one.RequestDeleteResponseUnion Methods: -- client.CloudforceOne.Requests.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestNewParams) (cloudforce_one.CloudforceOneRequestItem, error) -- client.CloudforceOne.Requests.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestUpdateParams) (cloudforce_one.CloudforceOneRequestItem, error) -- client.CloudforceOne.Requests.List(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestListParams) (pagination.V4PagePaginationArray[cloudforce_one.CloudforceOneRequestListItem], error) -- client.CloudforceOne.Requests.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.RequestDeleteResponse, error) -- client.CloudforceOne.Requests.Constants(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneRequestConstants, error) -- client.CloudforceOne.Requests.Get(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.CloudforceOneRequestItem, error) -- client.CloudforceOne.Requests.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneQuota, error) -- client.CloudforceOne.Requests.Types(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneRequestTypes, error) +- 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.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) +- client.CloudforceOne.Requests.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.Quota, error) +- client.CloudforceOne.Requests.Types(ctx context.Context, accountIdentifier string) (cloudforce_one.RequestTypes, error) ### Message Response Types: -- cloudforce_one.CloudforceOneRequestMessageItem -- cloudforce_one.RequestMessageDeleteResponse +- cloudforce_one.Message +- cloudforce_one.RequestMessageDeleteResponseUnion Methods: -- client.CloudforceOne.Requests.Message.New(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageNewParams) (cloudforce_one.CloudforceOneRequestMessageItem, error) -- client.CloudforceOne.Requests.Message.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body cloudforce_one.RequestMessageUpdateParams) (cloudforce_one.CloudforceOneRequestMessageItem, error) -- client.CloudforceOne.Requests.Message.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64) (cloudforce_one.RequestMessageDeleteResponse, error) -- client.CloudforceOne.Requests.Message.Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageGetParams) ([]cloudforce_one.CloudforceOneRequestMessageItem, error) +- client.CloudforceOne.Requests.Message.New(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageNewParams) (cloudforce_one.Message, error) +- client.CloudforceOne.Requests.Message.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body cloudforce_one.RequestMessageUpdateParams) (cloudforce_one.Message, error) +- client.CloudforceOne.Requests.Message.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64) (cloudforce_one.RequestMessageDeleteResponseUnion, error) +- client.CloudforceOne.Requests.Message.Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageGetParams) ([]cloudforce_one.Message, error) ### Priority +Params Types: + +- cloudforce_one.LabelParam +- cloudforce_one.PriorityEditParam + Response Types: -- cloudforce_one.CloudforceOnePriorityItem -- cloudforce_one.RequestPriorityDeleteResponse +- cloudforce_one.Label +- cloudforce_one.Priority +- cloudforce_one.RequestPriorityDeleteResponseUnion Methods: -- client.CloudforceOne.Requests.Priority.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestPriorityNewParams) (cloudforce_one.CloudforceOnePriorityItem, error) -- client.CloudforceOne.Requests.Priority.Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body cloudforce_one.RequestPriorityUpdateParams) (cloudforce_one.CloudforceOneRequestItem, error) -- client.CloudforceOne.Requests.Priority.Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.RequestPriorityDeleteResponse, error) -- client.CloudforceOne.Requests.Priority.Get(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.CloudforceOneRequestItem, error) -- client.CloudforceOne.Requests.Priority.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneQuota, error) +- client.CloudforceOne.Requests.Priority.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestPriorityNewParams) (cloudforce_one.Priority, error) +- client.CloudforceOne.Requests.Priority.Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body cloudforce_one.RequestPriorityUpdateParams) (cloudforce_one.Item, error) +- client.CloudforceOne.Requests.Priority.Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.RequestPriorityDeleteResponseUnion, error) +- client.CloudforceOne.Requests.Priority.Get(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.Item, error) +- client.CloudforceOne.Requests.Priority.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.Quota, error) diff --git a/argo/aliases.go b/argo/aliases.go index 7dc877405fd..01696364798 100644 --- a/argo/aliases.go +++ b/argo/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/argo/smartrouting.go b/argo/smartrouting.go index cf665a893aa..35fea9775b0 100644 --- a/argo/smartrouting.go +++ b/argo/smartrouting.go @@ -35,7 +35,7 @@ func NewSmartRoutingService(opts ...option.RequestOption) (r *SmartRoutingServic } // Updates enablement of Argo Smart Routing. -func (r *SmartRoutingService) Edit(ctx context.Context, params SmartRoutingEditParams, opts ...option.RequestOption) (res *SmartRoutingEditResponse, err error) { +func (r *SmartRoutingService) Edit(ctx context.Context, params SmartRoutingEditParams, opts ...option.RequestOption) (res *SmartRoutingEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SmartRoutingEditResponseEnvelope path := fmt.Sprintf("zones/%s/argo/smart_routing", params.ZoneID) @@ -48,7 +48,7 @@ func (r *SmartRoutingService) Edit(ctx context.Context, params SmartRoutingEditP } // Get Argo Smart Routing setting -func (r *SmartRoutingService) Get(ctx context.Context, query SmartRoutingGetParams, opts ...option.RequestOption) (res *SmartRoutingGetResponse, err error) { +func (r *SmartRoutingService) Get(ctx context.Context, query SmartRoutingGetParams, opts ...option.RequestOption) (res *SmartRoutingGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SmartRoutingGetResponseEnvelope path := fmt.Sprintf("zones/%s/argo/smart_routing", query.ZoneID) @@ -62,13 +62,13 @@ func (r *SmartRoutingService) Get(ctx context.Context, query SmartRoutingGetPara // Union satisfied by [argo.SmartRoutingEditResponseUnknown] or // [shared.UnionString]. -type SmartRoutingEditResponse interface { - ImplementsArgoSmartRoutingEditResponse() +type SmartRoutingEditResponseUnion interface { + ImplementsArgoSmartRoutingEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SmartRoutingEditResponse)(nil)).Elem(), + reflect.TypeOf((*SmartRoutingEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -79,13 +79,13 @@ func init() { // Union satisfied by [argo.SmartRoutingGetResponseUnknown] or // [shared.UnionString]. -type SmartRoutingGetResponse interface { - ImplementsArgoSmartRoutingGetResponse() +type SmartRoutingGetResponseUnion interface { + ImplementsArgoSmartRoutingGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SmartRoutingGetResponse)(nil)).Elem(), + reflect.TypeOf((*SmartRoutingGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -122,9 +122,9 @@ func (r SmartRoutingEditParamsValue) IsKnown() bool { } type SmartRoutingEditResponseEnvelope struct { - Errors []SmartRoutingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SmartRoutingEditResponseEnvelopeMessages `json:"messages,required"` - Result SmartRoutingEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SmartRoutingEditResponseUnion `json:"result,required"` // Whether the API call was successful Success SmartRoutingEditResponseEnvelopeSuccess `json:"success,required"` JSON smartRoutingEditResponseEnvelopeJSON `json:"-"` @@ -149,52 +149,6 @@ func (r smartRoutingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SmartRoutingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartRoutingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// smartRoutingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SmartRoutingEditResponseEnvelopeErrors] -type smartRoutingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartRoutingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartRoutingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SmartRoutingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartRoutingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// smartRoutingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SmartRoutingEditResponseEnvelopeMessages] -type smartRoutingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartRoutingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartRoutingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SmartRoutingEditResponseEnvelopeSuccess bool @@ -216,9 +170,9 @@ type SmartRoutingGetParams struct { } type SmartRoutingGetResponseEnvelope struct { - Errors []SmartRoutingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SmartRoutingGetResponseEnvelopeMessages `json:"messages,required"` - Result SmartRoutingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SmartRoutingGetResponseUnion `json:"result,required"` // Whether the API call was successful Success SmartRoutingGetResponseEnvelopeSuccess `json:"success,required"` JSON smartRoutingGetResponseEnvelopeJSON `json:"-"` @@ -243,52 +197,6 @@ func (r smartRoutingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SmartRoutingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartRoutingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// smartRoutingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SmartRoutingGetResponseEnvelopeErrors] -type smartRoutingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartRoutingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartRoutingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SmartRoutingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartRoutingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// smartRoutingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SmartRoutingGetResponseEnvelopeMessages] -type smartRoutingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartRoutingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartRoutingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SmartRoutingGetResponseEnvelopeSuccess bool diff --git a/argo/tieredcaching.go b/argo/tieredcaching.go index f9d96b19f5e..1d146682416 100644 --- a/argo/tieredcaching.go +++ b/argo/tieredcaching.go @@ -35,7 +35,7 @@ func NewTieredCachingService(opts ...option.RequestOption) (r *TieredCachingServ } // Updates enablement of Tiered Caching -func (r *TieredCachingService) Edit(ctx context.Context, params TieredCachingEditParams, opts ...option.RequestOption) (res *TieredCachingEditResponse, err error) { +func (r *TieredCachingService) Edit(ctx context.Context, params TieredCachingEditParams, opts ...option.RequestOption) (res *TieredCachingEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TieredCachingEditResponseEnvelope path := fmt.Sprintf("zones/%s/argo/tiered_caching", params.ZoneID) @@ -48,7 +48,7 @@ func (r *TieredCachingService) Edit(ctx context.Context, params TieredCachingEdi } // Get Tiered Caching setting -func (r *TieredCachingService) Get(ctx context.Context, query TieredCachingGetParams, opts ...option.RequestOption) (res *TieredCachingGetResponse, err error) { +func (r *TieredCachingService) Get(ctx context.Context, query TieredCachingGetParams, opts ...option.RequestOption) (res *TieredCachingGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TieredCachingGetResponseEnvelope path := fmt.Sprintf("zones/%s/argo/tiered_caching", query.ZoneID) @@ -62,13 +62,13 @@ func (r *TieredCachingService) Get(ctx context.Context, query TieredCachingGetPa // Union satisfied by [argo.TieredCachingEditResponseUnknown] or // [shared.UnionString]. -type TieredCachingEditResponse interface { - ImplementsArgoTieredCachingEditResponse() +type TieredCachingEditResponseUnion interface { + ImplementsArgoTieredCachingEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TieredCachingEditResponse)(nil)).Elem(), + reflect.TypeOf((*TieredCachingEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -79,13 +79,13 @@ func init() { // Union satisfied by [argo.TieredCachingGetResponseUnknown] or // [shared.UnionString]. -type TieredCachingGetResponse interface { - ImplementsArgoTieredCachingGetResponse() +type TieredCachingGetResponseUnion interface { + ImplementsArgoTieredCachingGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TieredCachingGetResponse)(nil)).Elem(), + reflect.TypeOf((*TieredCachingGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -122,9 +122,9 @@ func (r TieredCachingEditParamsValue) IsKnown() bool { } type TieredCachingEditResponseEnvelope struct { - Errors []TieredCachingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []TieredCachingEditResponseEnvelopeMessages `json:"messages,required"` - Result TieredCachingEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TieredCachingEditResponseUnion `json:"result,required"` // Whether the API call was successful Success TieredCachingEditResponseEnvelopeSuccess `json:"success,required"` JSON tieredCachingEditResponseEnvelopeJSON `json:"-"` @@ -149,52 +149,6 @@ func (r tieredCachingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TieredCachingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tieredCachingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// tieredCachingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TieredCachingEditResponseEnvelopeErrors] -type tieredCachingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TieredCachingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tieredCachingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TieredCachingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tieredCachingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// tieredCachingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TieredCachingEditResponseEnvelopeMessages] -type tieredCachingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TieredCachingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tieredCachingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TieredCachingEditResponseEnvelopeSuccess bool @@ -216,9 +170,9 @@ type TieredCachingGetParams struct { } type TieredCachingGetResponseEnvelope struct { - Errors []TieredCachingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TieredCachingGetResponseEnvelopeMessages `json:"messages,required"` - Result TieredCachingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TieredCachingGetResponseUnion `json:"result,required"` // Whether the API call was successful Success TieredCachingGetResponseEnvelopeSuccess `json:"success,required"` JSON tieredCachingGetResponseEnvelopeJSON `json:"-"` @@ -243,52 +197,6 @@ func (r tieredCachingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TieredCachingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tieredCachingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tieredCachingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TieredCachingGetResponseEnvelopeErrors] -type tieredCachingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TieredCachingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tieredCachingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TieredCachingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tieredCachingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tieredCachingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TieredCachingGetResponseEnvelopeMessages] -type tieredCachingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TieredCachingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tieredCachingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TieredCachingGetResponseEnvelopeSuccess bool diff --git a/audit_logs/aliases.go b/audit_logs/aliases.go index 0305720399f..f2bdfc5ac77 100644 --- a/audit_logs/aliases.go +++ b/audit_logs/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/audit_logs/auditlog.go b/audit_logs/auditlog.go index 6feaf9c1fb5..d203c9f73ec 100644 --- a/audit_logs/auditlog.go +++ b/audit_logs/auditlog.go @@ -9,11 +9,11 @@ import ( "net/url" "time" - "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" ) @@ -36,7 +36,7 @@ func NewAuditLogService(opts ...option.RequestOption) (r *AuditLogService) { // Gets a list of audit logs for an account. Can be filtered by who made the // change, on which zone, and the timeframe of the change. -func (r *AuditLogService) List(ctx context.Context, params AuditLogListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[AuditLogListResponse], err error) { +func (r *AuditLogService) List(ctx context.Context, params AuditLogListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[shared.AuditLog], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -55,177 +55,10 @@ func (r *AuditLogService) List(ctx context.Context, params AuditLogListParams, o // Gets a list of audit logs for an account. Can be filtered by who made the // change, on which zone, and the timeframe of the change. -func (r *AuditLogService) ListAutoPaging(ctx context.Context, params AuditLogListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[AuditLogListResponse] { +func (r *AuditLogService) ListAutoPaging(ctx context.Context, params AuditLogListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[shared.AuditLog] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } -type AuditLogListResponse struct { - // A string that uniquely identifies the audit log. - ID string `json:"id"` - Action AuditLogListResponseAction `json:"action"` - Actor AuditLogListResponseActor `json:"actor"` - // The source of the event. - Interface string `json:"interface"` - // An object which can lend more context to the action being logged. This is a - // flexible value and varies between different actions. - Metadata interface{} `json:"metadata"` - // The new value of the resource that was modified. - NewValue string `json:"newValue"` - // The value of the resource before it was modified. - OldValue string `json:"oldValue"` - Owner AuditLogListResponseOwner `json:"owner"` - Resource AuditLogListResponseResource `json:"resource"` - // A UTC RFC3339 timestamp that specifies when the action being logged occured. - When time.Time `json:"when" format:"date-time"` - JSON auditLogListResponseJSON `json:"-"` -} - -// auditLogListResponseJSON contains the JSON metadata for the struct -// [AuditLogListResponse] -type auditLogListResponseJSON struct { - ID apijson.Field - Action apijson.Field - Actor apijson.Field - Interface apijson.Field - Metadata apijson.Field - NewValue apijson.Field - OldValue apijson.Field - Owner apijson.Field - Resource apijson.Field - When apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseAction struct { - // A boolean that indicates if the action attempted was successful. - Result bool `json:"result"` - // A short string that describes the action that was performed. - Type string `json:"type"` - JSON auditLogListResponseActionJSON `json:"-"` -} - -// auditLogListResponseActionJSON contains the JSON metadata for the struct -// [AuditLogListResponseAction] -type auditLogListResponseActionJSON struct { - Result apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseActionJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseActor struct { - // The ID of the actor that performed the action. If a user performed the action, - // this will be their User ID. - ID string `json:"id"` - // The email of the user that performed the action. - Email string `json:"email" format:"email"` - // The IP address of the request that performed the action. - IP string `json:"ip"` - // The type of actor, whether a User, Cloudflare Admin, or an Automated System. - Type AuditLogListResponseActorType `json:"type"` - JSON auditLogListResponseActorJSON `json:"-"` -} - -// auditLogListResponseActorJSON contains the JSON metadata for the struct -// [AuditLogListResponseActor] -type auditLogListResponseActorJSON struct { - ID apijson.Field - Email apijson.Field - IP apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseActor) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseActorJSON) RawJSON() string { - return r.raw -} - -// The type of actor, whether a User, Cloudflare Admin, or an Automated System. -type AuditLogListResponseActorType string - -const ( - AuditLogListResponseActorTypeUser AuditLogListResponseActorType = "user" - AuditLogListResponseActorTypeAdmin AuditLogListResponseActorType = "admin" - AuditLogListResponseActorTypeCloudflare AuditLogListResponseActorType = "Cloudflare" -) - -func (r AuditLogListResponseActorType) IsKnown() bool { - switch r { - case AuditLogListResponseActorTypeUser, AuditLogListResponseActorTypeAdmin, AuditLogListResponseActorTypeCloudflare: - return true - } - return false -} - -type AuditLogListResponseOwner struct { - // Identifier - ID string `json:"id"` - JSON auditLogListResponseOwnerJSON `json:"-"` -} - -// auditLogListResponseOwnerJSON contains the JSON metadata for the struct -// [AuditLogListResponseOwner] -type auditLogListResponseOwnerJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseOwner) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseOwnerJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseResource struct { - // An identifier for the resource that was affected by the action. - ID string `json:"id"` - // A short string that describes the resource that was affected by the action. - Type string `json:"type"` - JSON auditLogListResponseResourceJSON `json:"-"` -} - -// auditLogListResponseResourceJSON contains the JSON metadata for the struct -// [AuditLogListResponseResource] -type auditLogListResponseResourceJSON struct { - ID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseResource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseResourceJSON) RawJSON() string { - return r.raw -} - type AuditLogListParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -255,7 +88,7 @@ type AuditLogListParams struct { // URLQuery serializes [AuditLogListParams]'s query parameters as `url.Values`. func (r AuditLogListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -269,7 +102,7 @@ type AuditLogListParamsAction struct { // `url.Values`. func (r AuditLogListParamsAction) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -286,7 +119,7 @@ type AuditLogListParamsActor struct { // `url.Values`. func (r AuditLogListParamsActor) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -315,7 +148,7 @@ type AuditLogListParamsZone struct { // URLQuery serializes [AuditLogListParamsZone]'s query parameters as `url.Values`. func (r AuditLogListParamsZone) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/billing/aliases.go b/billing/aliases.go index 0c9d5c13c0b..734dcbfb28e 100644 --- a/billing/aliases.go +++ b/billing/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/billing/profile.go b/billing/profile.go index 0799a089458..1e8861be59e 100644 --- a/billing/profile.go +++ b/billing/profile.go @@ -33,7 +33,7 @@ func NewProfileService(opts ...option.RequestOption) (r *ProfileService) { } // Gets the current billing profile for the account. -func (r *ProfileService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *ProfileGetResponse, err error) { +func (r *ProfileService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *ProfileGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ProfileGetResponseEnvelope path := fmt.Sprintf("accounts/%v/billing/profile", accountIdentifier) @@ -46,13 +46,13 @@ func (r *ProfileService) Get(ctx context.Context, accountIdentifier interface{}, } // Union satisfied by [billing.ProfileGetResponseUnknown] or [shared.UnionString]. -type ProfileGetResponse interface { - ImplementsBillingProfileGetResponse() +type ProfileGetResponseUnion interface { + ImplementsBillingProfileGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ProfileGetResponse)(nil)).Elem(), + reflect.TypeOf((*ProfileGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -62,9 +62,9 @@ func init() { } type ProfileGetResponseEnvelope struct { - Errors []ProfileGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ProfileGetResponseEnvelopeMessages `json:"messages,required"` - Result ProfileGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProfileGetResponseUnion `json:"result,required"` // Whether the API call was successful Success ProfileGetResponseEnvelopeSuccess `json:"success,required"` JSON profileGetResponseEnvelopeJSON `json:"-"` @@ -89,52 +89,6 @@ func (r profileGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProfileGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON profileGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// profileGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ProfileGetResponseEnvelopeErrors] -type profileGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProfileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r profileGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProfileGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON profileGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// profileGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ProfileGetResponseEnvelopeMessages] -type profileGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProfileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r profileGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProfileGetResponseEnvelopeSuccess bool diff --git a/bot_management/aliases.go b/bot_management/aliases.go index 99dc681f242..bc7a6ccb903 100644 --- a/bot_management/aliases.go +++ b/bot_management/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/bot_management/botmanagement.go b/bot_management/botmanagement.go index ccadef8667e..a1f392c1425 100644 --- a/bot_management/botmanagement.go +++ b/bot_management/botmanagement.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -46,7 +47,7 @@ func NewBotManagementService(opts ...option.RequestOption) (r *BotManagementServ func (r *BotManagementService) Update(ctx context.Context, params BotManagementUpdateParams, opts ...option.RequestOption) (res *BotManagementUpdateResponse, err error) { opts = append(r.Options[:], opts...) var env BotManagementUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/bot_management", params.getZoneID()) + path := fmt.Sprintf("zones/%s/bot_management", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return @@ -68,778 +69,736 @@ func (r *BotManagementService) Get(ctx context.Context, query BotManagementGetPa return } -// Union satisfied by -// [bot_management.BotManagementUpdateResponseBotManagementBotFightModeConfig], -// [bot_management.BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig], -// [bot_management.BotManagementUpdateResponseBotManagementSbfmLikelyConfig] or -// [bot_management.BotManagementUpdateResponseBotManagementBmSubscriptionConfig]. -type BotManagementUpdateResponse interface { - implementsBotManagementBotManagementUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*BotManagementUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementBotFightModeConfig{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementSbfmLikelyConfig{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementBmSubscriptionConfig{}), - }, - ) -} - -type BotManagementUpdateResponseBotManagementBotFightModeConfig struct { +type BotFightModeConfiguration struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` + EnableJS bool `json:"enable_js"` // Whether to enable Bot Fight Mode. FightMode bool `json:"fight_mode"` // A read-only field that indicates whether the zone currently is running the // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementBotFightModeConfigJSON `json:"-"` + UsingLatestModel bool `json:"using_latest_model"` + JSON botFightModeConfigurationJSON `json:"-"` } -// botManagementUpdateResponseBotManagementBotFightModeConfigJSON contains the JSON -// metadata for the struct -// [BotManagementUpdateResponseBotManagementBotFightModeConfig] -type botManagementUpdateResponseBotManagementBotFightModeConfigJSON struct { - EnableJs apijson.Field +// botFightModeConfigurationJSON contains the JSON metadata for the struct +// [BotFightModeConfiguration] +type botFightModeConfigurationJSON struct { + EnableJS apijson.Field FightMode apijson.Field UsingLatestModel apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementBotFightModeConfig) UnmarshalJSON(data []byte) (err error) { +func (r *BotFightModeConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r botFightModeConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r BotFightModeConfiguration) implementsBotManagementBotManagementUpdateResponse() {} + +func (r BotFightModeConfiguration) implementsBotManagementBotManagementGetResponse() {} + +type BotFightModeConfigurationParam struct { + // Use lightweight, invisible JavaScript detections to improve Bot Management. + // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + EnableJS param.Field[bool] `json:"enable_js"` + // Whether to enable Bot Fight Mode. + FightMode param.Field[bool] `json:"fight_mode"` +} + +func (r BotFightModeConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r BotFightModeConfigurationParam) implementsBotManagementBotManagementUpdateParamsBodyUnion() {} + +type SubscriptionConfiguration struct { + // Automatically update to the newest bot detection models created by Cloudflare as + // they are released. + // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + AutoUpdateModel bool `json:"auto_update_model"` + // Use lightweight, invisible JavaScript detections to improve Bot Management. + // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + EnableJS bool `json:"enable_js"` + // Whether to disable tracking the highest bot score for a session in the Bot + // Management cookie. + SuppressSessionScore bool `json:"suppress_session_score"` + // A read-only field that indicates whether the zone currently is running the + // latest ML model. + UsingLatestModel bool `json:"using_latest_model"` + JSON subscriptionConfigurationJSON `json:"-"` +} + +// subscriptionConfigurationJSON contains the JSON metadata for the struct +// [SubscriptionConfiguration] +type subscriptionConfigurationJSON struct { + AutoUpdateModel apijson.Field + EnableJS apijson.Field + SuppressSessionScore apijson.Field + UsingLatestModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r botManagementUpdateResponseBotManagementBotFightModeConfigJSON) RawJSON() string { +func (r subscriptionConfigurationJSON) RawJSON() string { return r.raw } -func (r BotManagementUpdateResponseBotManagementBotFightModeConfig) implementsBotManagementBotManagementUpdateResponse() { +func (r SubscriptionConfiguration) implementsBotManagementBotManagementUpdateResponse() {} + +func (r SubscriptionConfiguration) implementsBotManagementBotManagementGetResponse() {} + +type SubscriptionConfigurationParam struct { + // Automatically update to the newest bot detection models created by Cloudflare as + // they are released. + // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + AutoUpdateModel param.Field[bool] `json:"auto_update_model"` + // Use lightweight, invisible JavaScript detections to improve Bot Management. + // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + EnableJS param.Field[bool] `json:"enable_js"` + // Whether to disable tracking the highest bot score for a session in the Bot + // Management cookie. + SuppressSessionScore param.Field[bool] `json:"suppress_session_score"` +} + +func (r SubscriptionConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig struct { +func (r SubscriptionConfigurationParam) implementsBotManagementBotManagementUpdateParamsBodyUnion() {} + +type SuperBotFightModeDefinitelyConfiguration struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` + EnableJS bool `json:"enable_js"` // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress bool `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` + SBFMDefinitelyAutomated SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomated `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` + SBFMStaticResourceProtection bool `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` + SBFMVerifiedBots SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBots `json:"sbfm_verified_bots"` // A read-only field that indicates whether the zone currently is running the // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON `json:"-"` + UsingLatestModel bool `json:"using_latest_model"` + JSON superBotFightModeDefinitelyConfigurationJSON `json:"-"` } -// botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON contains the -// JSON metadata for the struct -// [BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig] -type botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON struct { - EnableJs apijson.Field +// superBotFightModeDefinitelyConfigurationJSON contains the JSON metadata for the +// struct [SuperBotFightModeDefinitelyConfiguration] +type superBotFightModeDefinitelyConfigurationJSON struct { + EnableJS apijson.Field OptimizeWordpress apijson.Field - SbfmDefinitelyAutomated apijson.Field - SbfmStaticResourceProtection apijson.Field - SbfmVerifiedBots apijson.Field + SBFMDefinitelyAutomated apijson.Field + SBFMStaticResourceProtection apijson.Field + SBFMVerifiedBots apijson.Field UsingLatestModel apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig) UnmarshalJSON(data []byte) (err error) { +func (r *SuperBotFightModeDefinitelyConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON) RawJSON() string { +func (r superBotFightModeDefinitelyConfigurationJSON) RawJSON() string { return r.raw } -func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementBotManagementUpdateResponse() { +func (r SuperBotFightModeDefinitelyConfiguration) implementsBotManagementBotManagementUpdateResponse() { } +func (r SuperBotFightModeDefinitelyConfiguration) implementsBotManagementBotManagementGetResponse() {} + // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated string +type SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomated string const ( - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "managed_challenge" + SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomatedAllow SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomated = "allow" + SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomatedBlock SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomated = "block" + SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomatedManagedChallenge SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomatedAllow, SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomatedBlock, SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots string +type SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBots string const ( - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "block" + SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBotsAllow SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBots = "allow" + SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBotsBlock SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBots = "block" ) -func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBots) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock: + case SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBotsAllow, SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBotsBlock: return true } return false } -type BotManagementUpdateResponseBotManagementSbfmLikelyConfig struct { +type SuperBotFightModeDefinitelyConfigurationParam struct { + // Use lightweight, invisible JavaScript detections to improve Bot Management. + // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + EnableJS param.Field[bool] `json:"enable_js"` + // Whether to optimize Super Bot Fight Mode protections for Wordpress. + OptimizeWordpress param.Field[bool] `json:"optimize_wordpress"` + // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. + SBFMDefinitelyAutomated param.Field[SuperBotFightModeDefinitelyConfigurationSBFMDefinitelyAutomated] `json:"sbfm_definitely_automated"` + // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if + // static resources on your application need bot protection. Note: Static resource + // protection can also result in legitimate traffic being blocked. + SBFMStaticResourceProtection param.Field[bool] `json:"sbfm_static_resource_protection"` + // Super Bot Fight Mode (SBFM) action to take on verified bots requests. + SBFMVerifiedBots param.Field[SuperBotFightModeDefinitelyConfigurationSBFMVerifiedBots] `json:"sbfm_verified_bots"` +} + +func (r SuperBotFightModeDefinitelyConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SuperBotFightModeDefinitelyConfigurationParam) implementsBotManagementBotManagementUpdateParamsBodyUnion() { +} + +type SuperBotFightModeLikelyConfiguration struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` + EnableJS bool `json:"enable_js"` // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress bool `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` + SBFMDefinitelyAutomated SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomated `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) action to take on likely automated requests. - SbfmLikelyAutomated BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated `json:"sbfm_likely_automated"` + SBFMLikelyAutomated SuperBotFightModeLikelyConfigurationSBFMLikelyAutomated `json:"sbfm_likely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` + SBFMStaticResourceProtection bool `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` + SBFMVerifiedBots SuperBotFightModeLikelyConfigurationSBFMVerifiedBots `json:"sbfm_verified_bots"` // A read-only field that indicates whether the zone currently is running the // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON `json:"-"` + UsingLatestModel bool `json:"using_latest_model"` + JSON superBotFightModeLikelyConfigurationJSON `json:"-"` } -// botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON contains the JSON -// metadata for the struct -// [BotManagementUpdateResponseBotManagementSbfmLikelyConfig] -type botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON struct { - EnableJs apijson.Field +// superBotFightModeLikelyConfigurationJSON contains the JSON metadata for the +// struct [SuperBotFightModeLikelyConfiguration] +type superBotFightModeLikelyConfigurationJSON struct { + EnableJS apijson.Field OptimizeWordpress apijson.Field - SbfmDefinitelyAutomated apijson.Field - SbfmLikelyAutomated apijson.Field - SbfmStaticResourceProtection apijson.Field - SbfmVerifiedBots apijson.Field + SBFMDefinitelyAutomated apijson.Field + SBFMLikelyAutomated apijson.Field + SBFMStaticResourceProtection apijson.Field + SBFMVerifiedBots apijson.Field UsingLatestModel apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementSbfmLikelyConfig) UnmarshalJSON(data []byte) (err error) { +func (r *SuperBotFightModeLikelyConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON) RawJSON() string { +func (r superBotFightModeLikelyConfigurationJSON) RawJSON() string { return r.raw } -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfig) implementsBotManagementBotManagementUpdateResponse() { -} +func (r SuperBotFightModeLikelyConfiguration) implementsBotManagementBotManagementUpdateResponse() {} + +func (r SuperBotFightModeLikelyConfiguration) implementsBotManagementBotManagementGetResponse() {} // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated string +type SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomated string const ( - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" + SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomatedAllow SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomated = "allow" + SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomatedBlock SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomated = "block" + SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomatedManagedChallenge SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomatedAllow, SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomatedBlock, SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on likely automated requests. -type BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated string +type SuperBotFightModeLikelyConfigurationSBFMLikelyAutomated string const ( - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "allow" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "block" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "managed_challenge" + SuperBotFightModeLikelyConfigurationSBFMLikelyAutomatedAllow SuperBotFightModeLikelyConfigurationSBFMLikelyAutomated = "allow" + SuperBotFightModeLikelyConfigurationSBFMLikelyAutomatedBlock SuperBotFightModeLikelyConfigurationSBFMLikelyAutomated = "block" + SuperBotFightModeLikelyConfigurationSBFMLikelyAutomatedManagedChallenge SuperBotFightModeLikelyConfigurationSBFMLikelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated) IsKnown() bool { +func (r SuperBotFightModeLikelyConfigurationSBFMLikelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge: + case SuperBotFightModeLikelyConfigurationSBFMLikelyAutomatedAllow, SuperBotFightModeLikelyConfigurationSBFMLikelyAutomatedBlock, SuperBotFightModeLikelyConfigurationSBFMLikelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots string +type SuperBotFightModeLikelyConfigurationSBFMVerifiedBots string const ( - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "block" + SuperBotFightModeLikelyConfigurationSBFMVerifiedBotsAllow SuperBotFightModeLikelyConfigurationSBFMVerifiedBots = "allow" + SuperBotFightModeLikelyConfigurationSBFMVerifiedBotsBlock SuperBotFightModeLikelyConfigurationSBFMVerifiedBots = "block" ) -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r SuperBotFightModeLikelyConfigurationSBFMVerifiedBots) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock: + case SuperBotFightModeLikelyConfigurationSBFMVerifiedBotsAllow, SuperBotFightModeLikelyConfigurationSBFMVerifiedBotsBlock: return true } return false } -type BotManagementUpdateResponseBotManagementBmSubscriptionConfig struct { +type SuperBotFightModeLikelyConfigurationParam struct { + // Use lightweight, invisible JavaScript detections to improve Bot Management. + // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + EnableJS param.Field[bool] `json:"enable_js"` + // Whether to optimize Super Bot Fight Mode protections for Wordpress. + OptimizeWordpress param.Field[bool] `json:"optimize_wordpress"` + // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. + SBFMDefinitelyAutomated param.Field[SuperBotFightModeLikelyConfigurationSBFMDefinitelyAutomated] `json:"sbfm_definitely_automated"` + // Super Bot Fight Mode (SBFM) action to take on likely automated requests. + SBFMLikelyAutomated param.Field[SuperBotFightModeLikelyConfigurationSBFMLikelyAutomated] `json:"sbfm_likely_automated"` + // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if + // static resources on your application need bot protection. Note: Static resource + // protection can also result in legitimate traffic being blocked. + SBFMStaticResourceProtection param.Field[bool] `json:"sbfm_static_resource_protection"` + // Super Bot Fight Mode (SBFM) action to take on verified bots requests. + SBFMVerifiedBots param.Field[SuperBotFightModeLikelyConfigurationSBFMVerifiedBots] `json:"sbfm_verified_bots"` +} + +func (r SuperBotFightModeLikelyConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SuperBotFightModeLikelyConfigurationParam) implementsBotManagementBotManagementUpdateParamsBodyUnion() { +} + +type BotManagementUpdateResponse struct { + // Use lightweight, invisible JavaScript detections to improve Bot Management. + // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + EnableJS bool `json:"enable_js"` + // A read-only field that indicates whether the zone currently is running the + // latest ML model. + UsingLatestModel bool `json:"using_latest_model"` + // Whether to enable Bot Fight Mode. + FightMode bool `json:"fight_mode"` + // Whether to optimize Super Bot Fight Mode protections for Wordpress. + OptimizeWordpress bool `json:"optimize_wordpress"` + // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. + SBFMDefinitelyAutomated BotManagementUpdateResponseSBFMDefinitelyAutomated `json:"sbfm_definitely_automated"` + // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if + // static resources on your application need bot protection. Note: Static resource + // protection can also result in legitimate traffic being blocked. + SBFMStaticResourceProtection bool `json:"sbfm_static_resource_protection"` + // Super Bot Fight Mode (SBFM) action to take on verified bots requests. + SBFMVerifiedBots BotManagementUpdateResponseSBFMVerifiedBots `json:"sbfm_verified_bots"` + // Super Bot Fight Mode (SBFM) action to take on likely automated requests. + SBFMLikelyAutomated BotManagementUpdateResponseSBFMLikelyAutomated `json:"sbfm_likely_automated"` // Automatically update to the newest bot detection models created by Cloudflare as // they are released. // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) AutoUpdateModel bool `json:"auto_update_model"` - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` // Whether to disable tracking the highest bot score for a session in the Bot // Management cookie. - SuppressSessionScore bool `json:"suppress_session_score"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON `json:"-"` + SuppressSessionScore bool `json:"suppress_session_score"` + JSON botManagementUpdateResponseJSON `json:"-"` + union BotManagementUpdateResponseUnion } -// botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON contains the -// JSON metadata for the struct -// [BotManagementUpdateResponseBotManagementBmSubscriptionConfig] -type botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON struct { - AutoUpdateModel apijson.Field - EnableJs apijson.Field - SuppressSessionScore apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field +// botManagementUpdateResponseJSON contains the JSON metadata for the struct +// [BotManagementUpdateResponse] +type botManagementUpdateResponseJSON struct { + EnableJS apijson.Field + UsingLatestModel apijson.Field + FightMode apijson.Field + OptimizeWordpress apijson.Field + SBFMDefinitelyAutomated apijson.Field + SBFMStaticResourceProtection apijson.Field + SBFMVerifiedBots apijson.Field + SBFMLikelyAutomated apijson.Field + AutoUpdateModel apijson.Field + SuppressSessionScore apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementBmSubscriptionConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r botManagementUpdateResponseJSON) RawJSON() string { + return r.raw } -func (r botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON) RawJSON() string { - return r.raw +func (r *BotManagementUpdateResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r BotManagementUpdateResponseBotManagementBmSubscriptionConfig) implementsBotManagementBotManagementUpdateResponse() { +func (r BotManagementUpdateResponse) AsUnion() BotManagementUpdateResponseUnion { + return r.union } -// Union satisfied by -// [bot_management.BotManagementGetResponseBotManagementBotFightModeConfig], -// [bot_management.BotManagementGetResponseBotManagementSbfmDefinitelyConfig], -// [bot_management.BotManagementGetResponseBotManagementSbfmLikelyConfig] or -// [bot_management.BotManagementGetResponseBotManagementBmSubscriptionConfig]. -type BotManagementGetResponse interface { - implementsBotManagementBotManagementGetResponse() +// Union satisfied by [bot_management.BotFightModeConfiguration], +// [bot_management.SuperBotFightModeDefinitelyConfiguration], +// [bot_management.SuperBotFightModeLikelyConfiguration] or +// [bot_management.SubscriptionConfiguration]. +type BotManagementUpdateResponseUnion interface { + implementsBotManagementBotManagementUpdateResponse() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*BotManagementGetResponse)(nil)).Elem(), + reflect.TypeOf((*BotManagementUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementBotFightModeConfig{}), + Type: reflect.TypeOf(BotFightModeConfiguration{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementSbfmDefinitelyConfig{}), + Type: reflect.TypeOf(SuperBotFightModeDefinitelyConfiguration{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementSbfmLikelyConfig{}), + Type: reflect.TypeOf(SuperBotFightModeLikelyConfiguration{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementBmSubscriptionConfig{}), + Type: reflect.TypeOf(SubscriptionConfiguration{}), }, ) } -type BotManagementGetResponseBotManagementBotFightModeConfig struct { - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` - // Whether to enable Bot Fight Mode. - FightMode bool `json:"fight_mode"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementBotFightModeConfigJSON `json:"-"` -} - -// botManagementGetResponseBotManagementBotFightModeConfigJSON contains the JSON -// metadata for the struct -// [BotManagementGetResponseBotManagementBotFightModeConfig] -type botManagementGetResponseBotManagementBotFightModeConfigJSON struct { - EnableJs apijson.Field - FightMode apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseBotManagementBotFightModeConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseBotManagementBotFightModeConfigJSON) RawJSON() string { - return r.raw -} - -func (r BotManagementGetResponseBotManagementBotFightModeConfig) implementsBotManagementBotManagementGetResponse() { -} - -type BotManagementGetResponseBotManagementSbfmDefinitelyConfig struct { - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` - // Whether to optimize Super Bot Fight Mode protections for Wordpress. - OptimizeWordpress bool `json:"optimize_wordpress"` - // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` - // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if - // static resources on your application need bot protection. Note: Static resource - // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` - // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON `json:"-"` -} - -// botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON contains the JSON -// metadata for the struct -// [BotManagementGetResponseBotManagementSbfmDefinitelyConfig] -type botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON struct { - EnableJs apijson.Field - OptimizeWordpress apijson.Field - SbfmDefinitelyAutomated apijson.Field - SbfmStaticResourceProtection apijson.Field - SbfmVerifiedBots apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseBotManagementSbfmDefinitelyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +// Super Bot Fight Mode (SBFM) action to take on definitely automated requests. +type BotManagementUpdateResponseSBFMDefinitelyAutomated string -func (r botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON) RawJSON() string { - return r.raw -} +const ( + BotManagementUpdateResponseSBFMDefinitelyAutomatedAllow BotManagementUpdateResponseSBFMDefinitelyAutomated = "allow" + BotManagementUpdateResponseSBFMDefinitelyAutomatedBlock BotManagementUpdateResponseSBFMDefinitelyAutomated = "block" + BotManagementUpdateResponseSBFMDefinitelyAutomatedManagedChallenge BotManagementUpdateResponseSBFMDefinitelyAutomated = "managed_challenge" +) -func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementBotManagementGetResponse() { +func (r BotManagementUpdateResponseSBFMDefinitelyAutomated) IsKnown() bool { + switch r { + case BotManagementUpdateResponseSBFMDefinitelyAutomatedAllow, BotManagementUpdateResponseSBFMDefinitelyAutomatedBlock, BotManagementUpdateResponseSBFMDefinitelyAutomatedManagedChallenge: + return true + } + return false } -// Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated string +// Super Bot Fight Mode (SBFM) action to take on verified bots requests. +type BotManagementUpdateResponseSBFMVerifiedBots string const ( - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "block" - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "managed_challenge" + BotManagementUpdateResponseSBFMVerifiedBotsAllow BotManagementUpdateResponseSBFMVerifiedBots = "allow" + BotManagementUpdateResponseSBFMVerifiedBotsBlock BotManagementUpdateResponseSBFMVerifiedBots = "block" ) -func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r BotManagementUpdateResponseSBFMVerifiedBots) IsKnown() bool { switch r { - case BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow, BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock, BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case BotManagementUpdateResponseSBFMVerifiedBotsAllow, BotManagementUpdateResponseSBFMVerifiedBotsBlock: return true } return false } -// Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots string +// Super Bot Fight Mode (SBFM) action to take on likely automated requests. +type BotManagementUpdateResponseSBFMLikelyAutomated string const ( - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "allow" - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "block" + BotManagementUpdateResponseSBFMLikelyAutomatedAllow BotManagementUpdateResponseSBFMLikelyAutomated = "allow" + BotManagementUpdateResponseSBFMLikelyAutomatedBlock BotManagementUpdateResponseSBFMLikelyAutomated = "block" + BotManagementUpdateResponseSBFMLikelyAutomatedManagedChallenge BotManagementUpdateResponseSBFMLikelyAutomated = "managed_challenge" ) -func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r BotManagementUpdateResponseSBFMLikelyAutomated) IsKnown() bool { switch r { - case BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow, BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock: + case BotManagementUpdateResponseSBFMLikelyAutomatedAllow, BotManagementUpdateResponseSBFMLikelyAutomatedBlock, BotManagementUpdateResponseSBFMLikelyAutomatedManagedChallenge: return true } return false } -type BotManagementGetResponseBotManagementSbfmLikelyConfig struct { +type BotManagementGetResponse struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` + EnableJS bool `json:"enable_js"` + // A read-only field that indicates whether the zone currently is running the + // latest ML model. + UsingLatestModel bool `json:"using_latest_model"` + // Whether to enable Bot Fight Mode. + FightMode bool `json:"fight_mode"` // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress bool `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` - // Super Bot Fight Mode (SBFM) action to take on likely automated requests. - SbfmLikelyAutomated BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated `json:"sbfm_likely_automated"` + SBFMDefinitelyAutomated BotManagementGetResponseSBFMDefinitelyAutomated `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` + SBFMStaticResourceProtection bool `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementSbfmLikelyConfigJSON `json:"-"` + SBFMVerifiedBots BotManagementGetResponseSBFMVerifiedBots `json:"sbfm_verified_bots"` + // Super Bot Fight Mode (SBFM) action to take on likely automated requests. + SBFMLikelyAutomated BotManagementGetResponseSBFMLikelyAutomated `json:"sbfm_likely_automated"` + // Automatically update to the newest bot detection models created by Cloudflare as + // they are released. + // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + AutoUpdateModel bool `json:"auto_update_model"` + // Whether to disable tracking the highest bot score for a session in the Bot + // Management cookie. + SuppressSessionScore bool `json:"suppress_session_score"` + JSON botManagementGetResponseJSON `json:"-"` + union BotManagementGetResponseUnion } -// botManagementGetResponseBotManagementSbfmLikelyConfigJSON contains the JSON -// metadata for the struct [BotManagementGetResponseBotManagementSbfmLikelyConfig] -type botManagementGetResponseBotManagementSbfmLikelyConfigJSON struct { - EnableJs apijson.Field - OptimizeWordpress apijson.Field - SbfmDefinitelyAutomated apijson.Field - SbfmLikelyAutomated apijson.Field - SbfmStaticResourceProtection apijson.Field - SbfmVerifiedBots apijson.Field +// botManagementGetResponseJSON contains the JSON metadata for the struct +// [BotManagementGetResponse] +type botManagementGetResponseJSON struct { + EnableJS apijson.Field UsingLatestModel apijson.Field + FightMode apijson.Field + OptimizeWordpress apijson.Field + SBFMDefinitelyAutomated apijson.Field + SBFMStaticResourceProtection apijson.Field + SBFMVerifiedBots apijson.Field + SBFMLikelyAutomated apijson.Field + AutoUpdateModel apijson.Field + SuppressSessionScore apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *BotManagementGetResponseBotManagementSbfmLikelyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r botManagementGetResponseJSON) RawJSON() string { + return r.raw } -func (r botManagementGetResponseBotManagementSbfmLikelyConfigJSON) RawJSON() string { - return r.raw +func (r *BotManagementGetResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r BotManagementGetResponse) AsUnion() BotManagementGetResponseUnion { + return r.union +} + +// Union satisfied by [bot_management.BotFightModeConfiguration], +// [bot_management.SuperBotFightModeDefinitelyConfiguration], +// [bot_management.SuperBotFightModeLikelyConfiguration] or +// [bot_management.SubscriptionConfiguration]. +type BotManagementGetResponseUnion interface { + implementsBotManagementBotManagementGetResponse() } -func (r BotManagementGetResponseBotManagementSbfmLikelyConfig) implementsBotManagementBotManagementGetResponse() { +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*BotManagementGetResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BotFightModeConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SuperBotFightModeDefinitelyConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SuperBotFightModeLikelyConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SubscriptionConfiguration{}), + }, + ) } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated string +type BotManagementGetResponseSBFMDefinitelyAutomated string const ( - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "block" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" + BotManagementGetResponseSBFMDefinitelyAutomatedAllow BotManagementGetResponseSBFMDefinitelyAutomated = "allow" + BotManagementGetResponseSBFMDefinitelyAutomatedBlock BotManagementGetResponseSBFMDefinitelyAutomated = "block" + BotManagementGetResponseSBFMDefinitelyAutomatedManagedChallenge BotManagementGetResponseSBFMDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r BotManagementGetResponseSBFMDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case BotManagementGetResponseSBFMDefinitelyAutomatedAllow, BotManagementGetResponseSBFMDefinitelyAutomatedBlock, BotManagementGetResponseSBFMDefinitelyAutomatedManagedChallenge: return true } return false } -// Super Bot Fight Mode (SBFM) action to take on likely automated requests. -type BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated string +// Super Bot Fight Mode (SBFM) action to take on verified bots requests. +type BotManagementGetResponseSBFMVerifiedBots string const ( - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "allow" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "block" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "managed_challenge" + BotManagementGetResponseSBFMVerifiedBotsAllow BotManagementGetResponseSBFMVerifiedBots = "allow" + BotManagementGetResponseSBFMVerifiedBotsBlock BotManagementGetResponseSBFMVerifiedBots = "block" ) -func (r BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated) IsKnown() bool { +func (r BotManagementGetResponseSBFMVerifiedBots) IsKnown() bool { switch r { - case BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge: + case BotManagementGetResponseSBFMVerifiedBotsAllow, BotManagementGetResponseSBFMVerifiedBotsBlock: return true } return false } -// Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots string +// Super Bot Fight Mode (SBFM) action to take on likely automated requests. +type BotManagementGetResponseSBFMLikelyAutomated string const ( - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "allow" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "block" + BotManagementGetResponseSBFMLikelyAutomatedAllow BotManagementGetResponseSBFMLikelyAutomated = "allow" + BotManagementGetResponseSBFMLikelyAutomatedBlock BotManagementGetResponseSBFMLikelyAutomated = "block" + BotManagementGetResponseSBFMLikelyAutomatedManagedChallenge BotManagementGetResponseSBFMLikelyAutomated = "managed_challenge" ) -func (r BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r BotManagementGetResponseSBFMLikelyAutomated) IsKnown() bool { switch r { - case BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock: + case BotManagementGetResponseSBFMLikelyAutomatedAllow, BotManagementGetResponseSBFMLikelyAutomatedBlock, BotManagementGetResponseSBFMLikelyAutomatedManagedChallenge: return true } return false } -type BotManagementGetResponseBotManagementBmSubscriptionConfig struct { - // Automatically update to the newest bot detection models created by Cloudflare as - // they are released. - // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) - AutoUpdateModel bool `json:"auto_update_model"` - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` - // Whether to disable tracking the highest bot score for a session in the Bot - // Management cookie. - SuppressSessionScore bool `json:"suppress_session_score"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementBmSubscriptionConfigJSON `json:"-"` -} - -// botManagementGetResponseBotManagementBmSubscriptionConfigJSON contains the JSON -// metadata for the struct -// [BotManagementGetResponseBotManagementBmSubscriptionConfig] -type botManagementGetResponseBotManagementBmSubscriptionConfigJSON struct { - AutoUpdateModel apijson.Field - EnableJs apijson.Field - SuppressSessionScore apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseBotManagementBmSubscriptionConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseBotManagementBmSubscriptionConfigJSON) RawJSON() string { - return r.raw -} - -func (r BotManagementGetResponseBotManagementBmSubscriptionConfig) implementsBotManagementBotManagementGetResponse() { +type BotManagementUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Body BotManagementUpdateParamsBodyUnion `json:"body,required"` } -// This interface is a union satisfied by one of the following: -// [BotManagementUpdateParamsBotManagementBotFightModeConfig], -// [BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig], -// [BotManagementUpdateParamsBotManagementSbfmLikelyConfig], -// [BotManagementUpdateParamsBotManagementBmSubscriptionConfig]. -type BotManagementUpdateParams interface { - ImplementsBotManagementUpdateParams() - - getZoneID() param.Field[string] +func (r BotManagementUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -type BotManagementUpdateParamsBotManagementBotFightModeConfig struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` +type BotManagementUpdateParamsBody struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs param.Field[bool] `json:"enable_js"` + EnableJS param.Field[bool] `json:"enable_js"` // Whether to enable Bot Fight Mode. FightMode param.Field[bool] `json:"fight_mode"` -} - -func (r BotManagementUpdateParamsBotManagementBotFightModeConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r BotManagementUpdateParamsBotManagementBotFightModeConfig) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (BotManagementUpdateParamsBotManagementBotFightModeConfig) ImplementsBotManagementUpdateParams() { - -} - -type BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs param.Field[bool] `json:"enable_js"` // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress param.Field[bool] `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated param.Field[BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated] `json:"sbfm_definitely_automated"` + SBFMDefinitelyAutomated param.Field[BotManagementUpdateParamsBodySBFMDefinitelyAutomated] `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection param.Field[bool] `json:"sbfm_static_resource_protection"` + SBFMStaticResourceProtection param.Field[bool] `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots param.Field[BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots] `json:"sbfm_verified_bots"` + SBFMVerifiedBots param.Field[BotManagementUpdateParamsBodySBFMVerifiedBots] `json:"sbfm_verified_bots"` + // Super Bot Fight Mode (SBFM) action to take on likely automated requests. + SBFMLikelyAutomated param.Field[BotManagementUpdateParamsBodySBFMLikelyAutomated] `json:"sbfm_likely_automated"` + // Automatically update to the newest bot detection models created by Cloudflare as + // they are released. + // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + AutoUpdateModel param.Field[bool] `json:"auto_update_model"` + // Whether to disable tracking the highest bot score for a session in the Bot + // Management cookie. + SuppressSessionScore param.Field[bool] `json:"suppress_session_score"` } -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig) MarshalJSON() (data []byte, err error) { +func (r BotManagementUpdateParamsBody) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig) ImplementsBotManagementUpdateParams() { +func (r BotManagementUpdateParamsBody) implementsBotManagementBotManagementUpdateParamsBodyUnion() {} +// Satisfied by [bot_management.BotFightModeConfigurationParam], +// [bot_management.SuperBotFightModeDefinitelyConfigurationParam], +// [bot_management.SuperBotFightModeLikelyConfigurationParam], +// [bot_management.SubscriptionConfigurationParam], +// [BotManagementUpdateParamsBody]. +type BotManagementUpdateParamsBodyUnion interface { + implementsBotManagementBotManagementUpdateParamsBodyUnion() } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated string +type BotManagementUpdateParamsBodySBFMDefinitelyAutomated string const ( - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "managed_challenge" + BotManagementUpdateParamsBodySBFMDefinitelyAutomatedAllow BotManagementUpdateParamsBodySBFMDefinitelyAutomated = "allow" + BotManagementUpdateParamsBodySBFMDefinitelyAutomatedBlock BotManagementUpdateParamsBodySBFMDefinitelyAutomated = "block" + BotManagementUpdateParamsBodySBFMDefinitelyAutomatedManagedChallenge BotManagementUpdateParamsBodySBFMDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r BotManagementUpdateParamsBodySBFMDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case BotManagementUpdateParamsBodySBFMDefinitelyAutomatedAllow, BotManagementUpdateParamsBodySBFMDefinitelyAutomatedBlock, BotManagementUpdateParamsBodySBFMDefinitelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots string +type BotManagementUpdateParamsBodySBFMVerifiedBots string const ( - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "block" + BotManagementUpdateParamsBodySBFMVerifiedBotsAllow BotManagementUpdateParamsBodySBFMVerifiedBots = "allow" + BotManagementUpdateParamsBodySBFMVerifiedBotsBlock BotManagementUpdateParamsBodySBFMVerifiedBots = "block" ) -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r BotManagementUpdateParamsBodySBFMVerifiedBots) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock: - return true - } - return false -} - -type BotManagementUpdateParamsBotManagementSbfmLikelyConfig struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs param.Field[bool] `json:"enable_js"` - // Whether to optimize Super Bot Fight Mode protections for Wordpress. - OptimizeWordpress param.Field[bool] `json:"optimize_wordpress"` - // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated param.Field[BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated] `json:"sbfm_definitely_automated"` - // Super Bot Fight Mode (SBFM) action to take on likely automated requests. - SbfmLikelyAutomated param.Field[BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated] `json:"sbfm_likely_automated"` - // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if - // static resources on your application need bot protection. Note: Static resource - // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection param.Field[bool] `json:"sbfm_static_resource_protection"` - // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots param.Field[BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots] `json:"sbfm_verified_bots"` -} - -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfig) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (BotManagementUpdateParamsBotManagementSbfmLikelyConfig) ImplementsBotManagementUpdateParams() { - -} - -// Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated string - -const ( - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" -) - -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { - switch r { - case BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case BotManagementUpdateParamsBodySBFMVerifiedBotsAllow, BotManagementUpdateParamsBodySBFMVerifiedBotsBlock: return true } return false } // Super Bot Fight Mode (SBFM) action to take on likely automated requests. -type BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated string - -const ( - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "allow" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "block" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "managed_challenge" -) - -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated) IsKnown() bool { - switch r { - case BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge: - return true - } - return false -} - -// Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots string +type BotManagementUpdateParamsBodySBFMLikelyAutomated string const ( - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots = "block" + BotManagementUpdateParamsBodySBFMLikelyAutomatedAllow BotManagementUpdateParamsBodySBFMLikelyAutomated = "allow" + BotManagementUpdateParamsBodySBFMLikelyAutomatedBlock BotManagementUpdateParamsBodySBFMLikelyAutomated = "block" + BotManagementUpdateParamsBodySBFMLikelyAutomatedManagedChallenge BotManagementUpdateParamsBodySBFMLikelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r BotManagementUpdateParamsBodySBFMLikelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock: + case BotManagementUpdateParamsBodySBFMLikelyAutomatedAllow, BotManagementUpdateParamsBodySBFMLikelyAutomatedBlock, BotManagementUpdateParamsBodySBFMLikelyAutomatedManagedChallenge: return true } return false } -type BotManagementUpdateParamsBotManagementBmSubscriptionConfig struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Automatically update to the newest bot detection models created by Cloudflare as - // they are released. - // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) - AutoUpdateModel param.Field[bool] `json:"auto_update_model"` - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs param.Field[bool] `json:"enable_js"` - // Whether to disable tracking the highest bot score for a session in the Bot - // Management cookie. - SuppressSessionScore param.Field[bool] `json:"suppress_session_score"` -} - -func (r BotManagementUpdateParamsBotManagementBmSubscriptionConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r BotManagementUpdateParamsBotManagementBmSubscriptionConfig) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (BotManagementUpdateParamsBotManagementBmSubscriptionConfig) ImplementsBotManagementUpdateParams() { - -} - type BotManagementUpdateResponseEnvelope struct { - Errors []BotManagementUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []BotManagementUpdateResponseEnvelopeMessages `json:"messages,required"` - Result BotManagementUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result BotManagementUpdateResponse `json:"result,required"` // Whether the API call was successful Success BotManagementUpdateResponseEnvelopeSuccess `json:"success,required"` JSON botManagementUpdateResponseEnvelopeJSON `json:"-"` @@ -864,52 +823,6 @@ func (r botManagementUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BotManagementUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON botManagementUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// botManagementUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [BotManagementUpdateResponseEnvelopeErrors] -type botManagementUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BotManagementUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON botManagementUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// botManagementUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [BotManagementUpdateResponseEnvelopeMessages] -type botManagementUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BotManagementUpdateResponseEnvelopeSuccess bool @@ -931,9 +844,9 @@ type BotManagementGetParams struct { } type BotManagementGetResponseEnvelope struct { - Errors []BotManagementGetResponseEnvelopeErrors `json:"errors,required"` - Messages []BotManagementGetResponseEnvelopeMessages `json:"messages,required"` - Result BotManagementGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result BotManagementGetResponse `json:"result,required"` // Whether the API call was successful Success BotManagementGetResponseEnvelopeSuccess `json:"success,required"` JSON botManagementGetResponseEnvelopeJSON `json:"-"` @@ -958,52 +871,6 @@ func (r botManagementGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BotManagementGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON botManagementGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// botManagementGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [BotManagementGetResponseEnvelopeErrors] -type botManagementGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BotManagementGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON botManagementGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// botManagementGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [BotManagementGetResponseEnvelopeMessages] -type botManagementGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BotManagementGetResponseEnvelopeSuccess bool diff --git a/bot_management/botmanagement_test.go b/bot_management/botmanagement_test.go index 6037541dbc7..c8b5b09395f 100644 --- a/bot_management/botmanagement_test.go +++ b/bot_management/botmanagement_test.go @@ -28,10 +28,12 @@ func TestBotManagementUpdateWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.BotManagement.Update(context.TODO(), bot_management.BotManagementUpdateParamsBotManagementBotFightModeConfig{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - EnableJs: cloudflare.F(true), - FightMode: cloudflare.F(true), + _, err := client.BotManagement.Update(context.TODO(), bot_management.BotManagementUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: bot_management.BotFightModeConfigurationParam{ + EnableJS: cloudflare.F(true), + FightMode: cloudflare.F(true), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/brand_protection/aliases.go b/brand_protection/aliases.go index d5cb54a1c08..dc9e848f761 100644 --- a/brand_protection/aliases.go +++ b/brand_protection/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/brand_protection/brandprotection.go b/brand_protection/brandprotection.go index de0bd28a2c9..607899dbc7a 100644 --- a/brand_protection/brandprotection.go +++ b/brand_protection/brandprotection.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -34,7 +35,7 @@ func NewBrandProtectionService(opts ...option.RequestOption) (r *BrandProtection } // Submit suspicious URL for scanning -func (r *BrandProtectionService) Submit(ctx context.Context, params BrandProtectionSubmitParams, opts ...option.RequestOption) (res *IntelPhishingURLSubmit, err error) { +func (r *BrandProtectionService) Submit(ctx context.Context, params BrandProtectionSubmitParams, opts ...option.RequestOption) (res *Submit, err error) { opts = append(r.Options[:], opts...) var env BrandProtectionSubmitResponseEnvelope path := fmt.Sprintf("accounts/%s/brand-protection/submit", params.AccountID) @@ -47,7 +48,7 @@ func (r *BrandProtectionService) Submit(ctx context.Context, params BrandProtect } // Get results for a URL scan -func (r *BrandProtectionService) URLInfo(ctx context.Context, params BrandProtectionURLInfoParams, opts ...option.RequestOption) (res *IntelPhishingURLInfo, err error) { +func (r *BrandProtectionService) URLInfo(ctx context.Context, params BrandProtectionURLInfoParams, opts ...option.RequestOption) (res *Info, err error) { opts = append(r.Options[:], opts...) var env BrandProtectionURLInfoResponseEnvelope path := fmt.Sprintf("accounts/%s/brand-protection/url-info", params.AccountID) @@ -59,28 +60,27 @@ func (r *BrandProtectionService) URLInfo(ctx context.Context, params BrandProtec return } -type IntelPhishingURLInfo struct { +type Info struct { // List of categorizations applied to this submission. - Categorizations []IntelPhishingURLInfoCategorization `json:"categorizations"` + Categorizations []InfoCategorization `json:"categorizations"` // List of model results for completed scans. - ModelResults []IntelPhishingURLInfoModelResult `json:"model_results"` + ModelResults []URLInfoModelResults `json:"model_results"` // List of signatures that matched against site content found when crawling the // URL. - RuleMatches []IntelPhishingURLInfoRuleMatch `json:"rule_matches"` + RuleMatches []RuleMatch `json:"rule_matches"` // Status of the most recent scan found. - ScanStatus IntelPhishingURLInfoScanStatus `json:"scan_status"` + ScanStatus ScanStatus `json:"scan_status"` // For internal use. ScreenshotDownloadSignature string `json:"screenshot_download_signature"` // For internal use. ScreenshotPath string `json:"screenshot_path"` // URL that was submitted. - URL string `json:"url"` - JSON intelPhishingURLInfoJSON `json:"-"` + URL string `json:"url"` + JSON infoJSON `json:"-"` } -// intelPhishingURLInfoJSON contains the JSON metadata for the struct -// [IntelPhishingURLInfo] -type intelPhishingURLInfoJSON struct { +// infoJSON contains the JSON metadata for the struct [Info] +type infoJSON struct { Categorizations apijson.Field ModelResults apijson.Field RuleMatches apijson.Field @@ -92,65 +92,40 @@ type intelPhishingURLInfoJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLInfo) UnmarshalJSON(data []byte) (err error) { +func (r *Info) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLInfoJSON) RawJSON() string { +func (r infoJSON) RawJSON() string { return r.raw } -type IntelPhishingURLInfoCategorization struct { +type InfoCategorization struct { // Name of the category applied. Category string `json:"category"` // Result of human review for this categorization. - VerificationStatus string `json:"verification_status"` - JSON intelPhishingURLInfoCategorizationJSON `json:"-"` + VerificationStatus string `json:"verification_status"` + JSON infoCategorizationJSON `json:"-"` } -// intelPhishingURLInfoCategorizationJSON contains the JSON metadata for the struct -// [IntelPhishingURLInfoCategorization] -type intelPhishingURLInfoCategorizationJSON struct { +// infoCategorizationJSON contains the JSON metadata for the struct +// [InfoCategorization] +type infoCategorizationJSON struct { Category apijson.Field VerificationStatus apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLInfoCategorization) UnmarshalJSON(data []byte) (err error) { +func (r *InfoCategorization) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLInfoCategorizationJSON) RawJSON() string { +func (r infoCategorizationJSON) RawJSON() string { return r.raw } -type IntelPhishingURLInfoModelResult struct { - // Name of the model. - ModelName string `json:"model_name"` - // Score output by the model for this submission. - ModelScore float64 `json:"model_score"` - JSON intelPhishingURLInfoModelResultJSON `json:"-"` -} - -// intelPhishingURLInfoModelResultJSON contains the JSON metadata for the struct -// [IntelPhishingURLInfoModelResult] -type intelPhishingURLInfoModelResultJSON struct { - ModelName apijson.Field - ModelScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelPhishingURLInfoModelResult) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelPhishingURLInfoModelResultJSON) RawJSON() string { - return r.raw -} - -type IntelPhishingURLInfoRuleMatch struct { +type RuleMatch struct { // For internal use. Banning bool `json:"banning"` // For internal use. @@ -158,13 +133,12 @@ type IntelPhishingURLInfoRuleMatch struct { // Description of the signature that matched. Description string `json:"description"` // Name of the signature that matched. - Name string `json:"name"` - JSON intelPhishingURLInfoRuleMatchJSON `json:"-"` + Name string `json:"name"` + JSON ruleMatchJSON `json:"-"` } -// intelPhishingURLInfoRuleMatchJSON contains the JSON metadata for the struct -// [IntelPhishingURLInfoRuleMatch] -type intelPhishingURLInfoRuleMatchJSON struct { +// ruleMatchJSON contains the JSON metadata for the struct [RuleMatch] +type ruleMatchJSON struct { Banning apijson.Field Blocking apijson.Field Description apijson.Field @@ -173,16 +147,16 @@ type intelPhishingURLInfoRuleMatchJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLInfoRuleMatch) UnmarshalJSON(data []byte) (err error) { +func (r *RuleMatch) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLInfoRuleMatchJSON) RawJSON() string { +func (r ruleMatchJSON) RawJSON() string { return r.raw } // Status of the most recent scan found. -type IntelPhishingURLInfoScanStatus struct { +type ScanStatus struct { // Timestamp of when the submission was processed. LastProcessed string `json:"last_processed"` // For internal use. @@ -190,13 +164,12 @@ type IntelPhishingURLInfoScanStatus struct { // Status code that the crawler received when loading the submitted URL. StatusCode int64 `json:"status_code"` // ID of the most recent submission. - SubmissionID int64 `json:"submission_id"` - JSON intelPhishingURLInfoScanStatusJSON `json:"-"` + SubmissionID int64 `json:"submission_id"` + JSON scanStatusJSON `json:"-"` } -// intelPhishingURLInfoScanStatusJSON contains the JSON metadata for the struct -// [IntelPhishingURLInfoScanStatus] -type intelPhishingURLInfoScanStatusJSON struct { +// scanStatusJSON contains the JSON metadata for the struct [ScanStatus] +type scanStatusJSON struct { LastProcessed apijson.Field ScanComplete apijson.Field StatusCode apijson.Field @@ -205,28 +178,27 @@ type intelPhishingURLInfoScanStatusJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLInfoScanStatus) UnmarshalJSON(data []byte) (err error) { +func (r *ScanStatus) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLInfoScanStatusJSON) RawJSON() string { +func (r scanStatusJSON) RawJSON() string { return r.raw } -type IntelPhishingURLSubmit struct { +type Submit struct { // URLs that were excluded from scanning because their domain is in our no-scan // list. - ExcludedURLs []IntelPhishingURLSubmitExcludedURL `json:"excluded_urls"` + ExcludedURLs []SubmitExcludedURL `json:"excluded_urls"` // URLs that were skipped because the same URL is currently being scanned - SkippedURLs []IntelPhishingURLSubmitSkippedURL `json:"skipped_urls"` + SkippedURLs []SubmitSkippedURL `json:"skipped_urls"` // URLs that were successfully submitted for scanning. - SubmittedURLs []IntelPhishingURLSubmitSubmittedURL `json:"submitted_urls"` - JSON intelPhishingURLSubmitJSON `json:"-"` + SubmittedURLs []SubmitSubmittedURL `json:"submitted_urls"` + JSON submitJSON `json:"-"` } -// intelPhishingURLSubmitJSON contains the JSON metadata for the struct -// [IntelPhishingURLSubmit] -type intelPhishingURLSubmitJSON struct { +// submitJSON contains the JSON metadata for the struct [Submit] +type submitJSON struct { ExcludedURLs apijson.Field SkippedURLs apijson.Field SubmittedURLs apijson.Field @@ -234,83 +206,108 @@ type intelPhishingURLSubmitJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLSubmit) UnmarshalJSON(data []byte) (err error) { +func (r *Submit) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLSubmitJSON) RawJSON() string { +func (r submitJSON) RawJSON() string { return r.raw } -type IntelPhishingURLSubmitExcludedURL struct { +type SubmitExcludedURL struct { // URL that was excluded. - URL string `json:"url"` - JSON intelPhishingURLSubmitExcludedURLJSON `json:"-"` + URL string `json:"url"` + JSON submitExcludedURLJSON `json:"-"` } -// intelPhishingURLSubmitExcludedURLJSON contains the JSON metadata for the struct -// [IntelPhishingURLSubmitExcludedURL] -type intelPhishingURLSubmitExcludedURLJSON struct { +// submitExcludedURLJSON contains the JSON metadata for the struct +// [SubmitExcludedURL] +type submitExcludedURLJSON struct { URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLSubmitExcludedURL) UnmarshalJSON(data []byte) (err error) { +func (r *SubmitExcludedURL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLSubmitExcludedURLJSON) RawJSON() string { +func (r submitExcludedURLJSON) RawJSON() string { return r.raw } -type IntelPhishingURLSubmitSkippedURL struct { +type SubmitSkippedURL struct { // URL that was skipped. URL string `json:"url"` // ID of the submission of that URL that is currently scanning. - URLID int64 `json:"url_id"` - JSON intelPhishingURLSubmitSkippedURLJSON `json:"-"` + URLID int64 `json:"url_id"` + JSON submitSkippedURLJSON `json:"-"` } -// intelPhishingURLSubmitSkippedURLJSON contains the JSON metadata for the struct -// [IntelPhishingURLSubmitSkippedURL] -type intelPhishingURLSubmitSkippedURLJSON struct { +// submitSkippedURLJSON contains the JSON metadata for the struct +// [SubmitSkippedURL] +type submitSkippedURLJSON struct { URL apijson.Field URLID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLSubmitSkippedURL) UnmarshalJSON(data []byte) (err error) { +func (r *SubmitSkippedURL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLSubmitSkippedURLJSON) RawJSON() string { +func (r submitSkippedURLJSON) RawJSON() string { return r.raw } -type IntelPhishingURLSubmitSubmittedURL struct { +type SubmitSubmittedURL struct { // URL that was submitted. URL string `json:"url"` // ID assigned to this URL submission. Used to retrieve scanning results. - URLID int64 `json:"url_id"` - JSON intelPhishingURLSubmitSubmittedURLJSON `json:"-"` + URLID int64 `json:"url_id"` + JSON submitSubmittedURLJSON `json:"-"` } -// intelPhishingURLSubmitSubmittedURLJSON contains the JSON metadata for the struct -// [IntelPhishingURLSubmitSubmittedURL] -type intelPhishingURLSubmitSubmittedURLJSON struct { +// submitSubmittedURLJSON contains the JSON metadata for the struct +// [SubmitSubmittedURL] +type submitSubmittedURLJSON struct { URL apijson.Field URLID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelPhishingURLSubmitSubmittedURL) UnmarshalJSON(data []byte) (err error) { +func (r *SubmitSubmittedURL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPhishingURLSubmitSubmittedURLJSON) RawJSON() string { +func (r submitSubmittedURLJSON) RawJSON() string { + return r.raw +} + +type URLInfoModelResults struct { + // Name of the model. + ModelName string `json:"model_name"` + // Score output by the model for this submission. + ModelScore float64 `json:"model_score"` + JSON urlInfoModelResultsJSON `json:"-"` +} + +// urlInfoModelResultsJSON contains the JSON metadata for the struct +// [URLInfoModelResults] +type urlInfoModelResultsJSON struct { + ModelName apijson.Field + ModelScore apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *URLInfoModelResults) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r urlInfoModelResultsJSON) RawJSON() string { return r.raw } @@ -326,9 +323,9 @@ func (r BrandProtectionSubmitParams) MarshalJSON() (data []byte, err error) { } type BrandProtectionSubmitResponseEnvelope struct { - Errors []BrandProtectionSubmitResponseEnvelopeErrors `json:"errors,required"` - Messages []BrandProtectionSubmitResponseEnvelopeMessages `json:"messages,required"` - Result IntelPhishingURLSubmit `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Submit `json:"result,required"` // Whether the API call was successful Success BrandProtectionSubmitResponseEnvelopeSuccess `json:"success,required"` JSON brandProtectionSubmitResponseEnvelopeJSON `json:"-"` @@ -353,52 +350,6 @@ func (r brandProtectionSubmitResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BrandProtectionSubmitResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionSubmitResponseEnvelopeErrorsJSON `json:"-"` -} - -// brandProtectionSubmitResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [BrandProtectionSubmitResponseEnvelopeErrors] -type brandProtectionSubmitResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionSubmitResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionSubmitResponseEnvelopeMessagesJSON `json:"-"` -} - -// brandProtectionSubmitResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [BrandProtectionSubmitResponseEnvelopeMessages] -type brandProtectionSubmitResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BrandProtectionSubmitResponseEnvelopeSuccess bool @@ -425,7 +376,7 @@ type BrandProtectionURLInfoParams struct { // `url.Values`. func (r BrandProtectionURLInfoParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -439,15 +390,15 @@ type BrandProtectionURLInfoParamsURLIDParam struct { // as `url.Values`. func (r BrandProtectionURLInfoParamsURLIDParam) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type BrandProtectionURLInfoResponseEnvelope struct { - Errors []BrandProtectionURLInfoResponseEnvelopeErrors `json:"errors,required"` - Messages []BrandProtectionURLInfoResponseEnvelopeMessages `json:"messages,required"` - Result IntelPhishingURLInfo `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Info `json:"result,required"` // Whether the API call was successful Success BrandProtectionURLInfoResponseEnvelopeSuccess `json:"success,required"` JSON brandProtectionURLInfoResponseEnvelopeJSON `json:"-"` @@ -472,52 +423,6 @@ func (r brandProtectionURLInfoResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BrandProtectionURLInfoResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionURLInfoResponseEnvelopeErrorsJSON `json:"-"` -} - -// brandProtectionURLInfoResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [BrandProtectionURLInfoResponseEnvelopeErrors] -type brandProtectionURLInfoResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionURLInfoResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionURLInfoResponseEnvelopeMessagesJSON `json:"-"` -} - -// brandProtectionURLInfoResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [BrandProtectionURLInfoResponseEnvelopeMessages] -type brandProtectionURLInfoResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BrandProtectionURLInfoResponseEnvelopeSuccess bool diff --git a/cache/aliases.go b/cache/aliases.go index 4b6330d4a45..3e01e0786e4 100644 --- a/cache/aliases.go +++ b/cache/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/cache/cache.go b/cache/cache.go index d68228c47f6..78bc7dadcd4 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -54,7 +55,9 @@ func NewCacheService(opts ...option.RequestOption) (r *CacheService) { // // **NB:** When including the Origin header, be sure to include the **scheme** and // **hostname**. The port number can be omitted if it is the default port (80 for -// http, 443 for https), but must be included otherwise. +// http, 443 for https), but must be included otherwise. **NB:** For Zones on +// Free/Pro/Business plan, you may purge up to 30 URLs in one API call. For Zones +// on Enterprise plan, you may purge up to 500 URLs in one API call. // // ### Purge Cached Content by Tag, Host or Prefix // @@ -69,7 +72,7 @@ func NewCacheService(opts ...option.RequestOption) (r *CacheService) { func (r *CacheService) Purge(ctx context.Context, params CachePurgeParams, opts ...option.RequestOption) (res *CachePurgeResponse, err error) { opts = append(r.Options[:], opts...) var env CachePurgeResponseEnvelope - path := fmt.Sprintf("zones/%s/purge_cache", params.getZoneID()) + path := fmt.Sprintf("zones/%s/purge_cache", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return @@ -100,123 +103,123 @@ func (r cachePurgeResponseJSON) RawJSON() string { return r.raw } -// This interface is a union satisfied by one of the following: -// [CachePurgeParamsCachePurgeTags], [CachePurgeParamsCachePurgeHosts], -// [CachePurgeParamsCachePurgePrefixes], [CachePurgeParamsCachePurgeEverything], -// [CachePurgeParamsCachePurgeFiles]. -type CachePurgeParams interface { - ImplementsCachePurgeParams() - - getZoneID() param.Field[string] +type CachePurgeParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` + Body CachePurgeParamsBodyUnion `json:"body,required"` } -type CachePurgeParamsCachePurgeTags struct { - ZoneID param.Field[string] `path:"zone_id,required"` - Tags param.Field[[]string] `json:"tags"` +func (r CachePurgeParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -func (r CachePurgeParamsCachePurgeTags) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type CachePurgeParamsBody struct { + Tags param.Field[interface{}] `json:"tags,required"` + Hosts param.Field[interface{}] `json:"hosts,required"` + Prefixes param.Field[interface{}] `json:"prefixes,required"` + PurgeEverything param.Field[bool] `json:"purge_everything"` + Files param.Field[interface{}] `json:"files,required"` } -func (r CachePurgeParamsCachePurgeTags) getZoneID() param.Field[string] { - return r.ZoneID +func (r CachePurgeParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (CachePurgeParamsCachePurgeTags) ImplementsCachePurgeParams() { +func (r CachePurgeParamsBody) implementsCacheCachePurgeParamsBodyUnion() {} +// Satisfied by [cache.CachePurgeParamsBodyCachePurgeTags], +// [cache.CachePurgeParamsBodyCachePurgeHosts], +// [cache.CachePurgeParamsBodyCachePurgePrefixes], +// [cache.CachePurgeParamsBodyCachePurgeEverything], +// [cache.CachePurgeParamsBodyCachePurgeFiles], [CachePurgeParamsBody]. +type CachePurgeParamsBodyUnion interface { + implementsCacheCachePurgeParamsBodyUnion() } -type CachePurgeParamsCachePurgeHosts struct { - ZoneID param.Field[string] `path:"zone_id,required"` - Hosts param.Field[[]string] `json:"hosts"` +type CachePurgeParamsBodyCachePurgeTags struct { + Tags param.Field[[]string] `json:"tags"` } -func (r CachePurgeParamsCachePurgeHosts) MarshalJSON() (data []byte, err error) { +func (r CachePurgeParamsBodyCachePurgeTags) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r CachePurgeParamsCachePurgeHosts) getZoneID() param.Field[string] { - return r.ZoneID -} +func (r CachePurgeParamsBodyCachePurgeTags) implementsCacheCachePurgeParamsBodyUnion() {} -func (CachePurgeParamsCachePurgeHosts) ImplementsCachePurgeParams() { +type CachePurgeParamsBodyCachePurgeHosts struct { + Hosts param.Field[[]string] `json:"hosts"` +} +func (r CachePurgeParamsBodyCachePurgeHosts) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type CachePurgeParamsCachePurgePrefixes struct { - ZoneID param.Field[string] `path:"zone_id,required"` +func (r CachePurgeParamsBodyCachePurgeHosts) implementsCacheCachePurgeParamsBodyUnion() {} + +type CachePurgeParamsBodyCachePurgePrefixes struct { Prefixes param.Field[[]string] `json:"prefixes"` } -func (r CachePurgeParamsCachePurgePrefixes) MarshalJSON() (data []byte, err error) { +func (r CachePurgeParamsBodyCachePurgePrefixes) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r CachePurgeParamsCachePurgePrefixes) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (CachePurgeParamsCachePurgePrefixes) ImplementsCachePurgeParams() { - -} +func (r CachePurgeParamsBodyCachePurgePrefixes) implementsCacheCachePurgeParamsBodyUnion() {} -type CachePurgeParamsCachePurgeEverything struct { - ZoneID param.Field[string] `path:"zone_id,required"` - PurgeEverything param.Field[bool] `json:"purge_everything"` +type CachePurgeParamsBodyCachePurgeEverything struct { + PurgeEverything param.Field[bool] `json:"purge_everything"` } -func (r CachePurgeParamsCachePurgeEverything) MarshalJSON() (data []byte, err error) { +func (r CachePurgeParamsBodyCachePurgeEverything) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r CachePurgeParamsCachePurgeEverything) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (CachePurgeParamsCachePurgeEverything) ImplementsCachePurgeParams() { - -} +func (r CachePurgeParamsBodyCachePurgeEverything) implementsCacheCachePurgeParamsBodyUnion() {} -type CachePurgeParamsCachePurgeFiles struct { - ZoneID param.Field[string] `path:"zone_id,required"` - Files param.Field[[]CachePurgeParamsCachePurgeFilesFile] `json:"files"` +type CachePurgeParamsBodyCachePurgeFiles struct { + Files param.Field[[]CachePurgeParamsBodyCachePurgeFilesFileUnion] `json:"files"` } -func (r CachePurgeParamsCachePurgeFiles) MarshalJSON() (data []byte, err error) { +func (r CachePurgeParamsBodyCachePurgeFiles) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r CachePurgeParamsCachePurgeFiles) getZoneID() param.Field[string] { - return r.ZoneID +func (r CachePurgeParamsBodyCachePurgeFiles) implementsCacheCachePurgeParamsBodyUnion() {} + +type CachePurgeParamsBodyCachePurgeFilesFile struct { + Headers param.Field[interface{}] `json:"headers,required"` + URL param.Field[string] `json:"url"` } -func (CachePurgeParamsCachePurgeFiles) ImplementsCachePurgeParams() { +func (r CachePurgeParamsBodyCachePurgeFilesFile) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} +func (r CachePurgeParamsBodyCachePurgeFilesFile) ImplementsCacheCachePurgeParamsBodyCachePurgeFilesFileUnion() { } // Satisfied by [shared.UnionString], -// [cache.CachePurgeParamsCachePurgeFilesFilesCachePurgeURLAndHeaders]. -type CachePurgeParamsCachePurgeFilesFile interface { - ImplementsCacheCachePurgeParamsCachePurgeFilesFile() +// [cache.CachePurgeParamsBodyCachePurgeFilesFilesCachePurgeURLAndHeaders], +// [CachePurgeParamsBodyCachePurgeFilesFile]. +type CachePurgeParamsBodyCachePurgeFilesFileUnion interface { + ImplementsCacheCachePurgeParamsBodyCachePurgeFilesFileUnion() } -type CachePurgeParamsCachePurgeFilesFilesCachePurgeURLAndHeaders struct { +type CachePurgeParamsBodyCachePurgeFilesFilesCachePurgeURLAndHeaders struct { Headers param.Field[interface{}] `json:"headers"` URL param.Field[string] `json:"url"` } -func (r CachePurgeParamsCachePurgeFilesFilesCachePurgeURLAndHeaders) MarshalJSON() (data []byte, err error) { +func (r CachePurgeParamsBodyCachePurgeFilesFilesCachePurgeURLAndHeaders) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r CachePurgeParamsCachePurgeFilesFilesCachePurgeURLAndHeaders) ImplementsCacheCachePurgeParamsCachePurgeFilesFile() { +func (r CachePurgeParamsBodyCachePurgeFilesFilesCachePurgeURLAndHeaders) ImplementsCacheCachePurgeParamsBodyCachePurgeFilesFileUnion() { } type CachePurgeResponseEnvelope struct { - Errors []CachePurgeResponseEnvelopeErrors `json:"errors,required"` - Messages []CachePurgeResponseEnvelopeMessages `json:"messages,required"` - Result CachePurgeResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CachePurgeResponse `json:"result,required,nullable"` // Whether the API call was successful Success CachePurgeResponseEnvelopeSuccess `json:"success,required"` JSON cachePurgeResponseEnvelopeJSON `json:"-"` @@ -241,52 +244,6 @@ func (r cachePurgeResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CachePurgeResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cachePurgeResponseEnvelopeErrorsJSON `json:"-"` -} - -// cachePurgeResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [CachePurgeResponseEnvelopeErrors] -type cachePurgeResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CachePurgeResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cachePurgeResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CachePurgeResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cachePurgeResponseEnvelopeMessagesJSON `json:"-"` -} - -// cachePurgeResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [CachePurgeResponseEnvelopeMessages] -type cachePurgeResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CachePurgeResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cachePurgeResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CachePurgeResponseEnvelopeSuccess bool diff --git a/cache/cache_test.go b/cache/cache_test.go index 046335c679b..d452bb279fd 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -28,9 +28,11 @@ func TestCachePurgeWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Cache.Purge(context.TODO(), cache.CachePurgeParamsCachePurgeTags{ + _, err := client.Cache.Purge(context.TODO(), cache.CachePurgeParams{ ZoneID: cloudflare.F("string"), - Tags: cloudflare.F([]string{"some-tag", "another-tag"}), + Body: cache.CachePurgeParamsBodyCachePurgeTags{ + Tags: cloudflare.F([]string{"some-tag", "another-tag"}), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/cache/cachereserve.go b/cache/cachereserve.go index 172166ebe2b..030d60b4f52 100644 --- a/cache/cachereserve.go +++ b/cache/cachereserve.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,10 +37,10 @@ func NewCacheReserveService(opts ...option.RequestOption) (r *CacheReserveServic // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind // that you cannot undo or cancel this operation. -func (r *CacheReserveService) Clear(ctx context.Context, body CacheReserveClearParams, opts ...option.RequestOption) (res *CacheReserveClearResponse, err error) { +func (r *CacheReserveService) Clear(ctx context.Context, params CacheReserveClearParams, opts ...option.RequestOption) (res *CacheReserveClearResponse, err error) { opts = append(r.Options[:], opts...) var env CacheReserveClearResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", body.ZoneID) + path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -100,13 +101,43 @@ func (r *CacheReserveService) Status(ctx context.Context, query CacheReserveStat return } +// ID of the zone setting. +type CacheReserve string + +const ( + CacheReserveCacheReserve CacheReserve = "cache_reserve" +) + +func (r CacheReserve) IsKnown() bool { + switch r { + case CacheReserveCacheReserve: + return true + } + return false +} + +// ID of the zone setting. +type CacheReserveClear string + +const ( + CacheReserveClearCacheReserveClear CacheReserveClear = "cache_reserve_clear" +) + +func (r CacheReserveClear) IsKnown() bool { + switch r { + case CacheReserveClearCacheReserveClear: + return true + } + return false +} + // You can use Cache Reserve Clear to clear your Cache Reserve, but you must first // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind // that you cannot undo or cancel this operation. type CacheReserveClearResponse struct { // ID of the zone setting. - ID CacheReserveClearResponseID `json:"id,required"` + ID CacheReserveClear `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // The time that the latest Cache Reserve Clear operation started. @@ -138,21 +169,6 @@ func (r cacheReserveClearResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type CacheReserveClearResponseID string - -const ( - CacheReserveClearResponseIDCacheReserveClear CacheReserveClearResponseID = "cache_reserve_clear" -) - -func (r CacheReserveClearResponseID) IsKnown() bool { - switch r { - case CacheReserveClearResponseIDCacheReserveClear: - return true - } - return false -} - // The current state of the Cache Reserve Clear operation. type CacheReserveClearResponseState string @@ -177,7 +193,7 @@ func (r CacheReserveClearResponseState) IsKnown() bool { // for more information. type CacheReserveEditResponse struct { // ID of the zone setting. - ID CacheReserveEditResponseID `json:"id,required"` + ID CacheReserve `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the Cache Reserve zone setting. @@ -203,21 +219,6 @@ func (r cacheReserveEditResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type CacheReserveEditResponseID string - -const ( - CacheReserveEditResponseIDCacheReserve CacheReserveEditResponseID = "cache_reserve" -) - -func (r CacheReserveEditResponseID) IsKnown() bool { - switch r { - case CacheReserveEditResponseIDCacheReserve: - return true - } - return false -} - // Value of the Cache Reserve zone setting. type CacheReserveEditResponseValue string @@ -242,7 +243,7 @@ func (r CacheReserveEditResponseValue) IsKnown() bool { // for more information. type CacheReserveGetResponse struct { // ID of the zone setting. - ID CacheReserveGetResponseID `json:"id,required"` + ID CacheReserve `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the Cache Reserve zone setting. @@ -268,21 +269,6 @@ func (r cacheReserveGetResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type CacheReserveGetResponseID string - -const ( - CacheReserveGetResponseIDCacheReserve CacheReserveGetResponseID = "cache_reserve" -) - -func (r CacheReserveGetResponseID) IsKnown() bool { - switch r { - case CacheReserveGetResponseIDCacheReserve: - return true - } - return false -} - // Value of the Cache Reserve zone setting. type CacheReserveGetResponseValue string @@ -305,7 +291,7 @@ func (r CacheReserveGetResponseValue) IsKnown() bool { // that you cannot undo or cancel this operation. type CacheReserveStatusResponse struct { // ID of the zone setting. - ID CacheReserveStatusResponseID `json:"id,required"` + ID CacheReserveClear `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // The time that the latest Cache Reserve Clear operation started. @@ -337,21 +323,6 @@ func (r cacheReserveStatusResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type CacheReserveStatusResponseID string - -const ( - CacheReserveStatusResponseIDCacheReserveClear CacheReserveStatusResponseID = "cache_reserve_clear" -) - -func (r CacheReserveStatusResponseID) IsKnown() bool { - switch r { - case CacheReserveStatusResponseIDCacheReserveClear: - return true - } - return false -} - // The current state of the Cache Reserve Clear operation. type CacheReserveStatusResponseState string @@ -371,11 +342,16 @@ func (r CacheReserveStatusResponseState) IsKnown() bool { type CacheReserveClearParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CacheReserveClearParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CacheReserveClearResponseEnvelope struct { - Errors []CacheReserveClearResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheReserveClearResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // You can use Cache Reserve Clear to clear your Cache Reserve, but you must first // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind @@ -405,52 +381,6 @@ func (r cacheReserveClearResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CacheReserveClearResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveClearResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheReserveClearResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CacheReserveClearResponseEnvelopeErrors] -type cacheReserveClearResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveClearResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveClearResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheReserveClearResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveClearResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheReserveClearResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CacheReserveClearResponseEnvelopeMessages] -type cacheReserveClearResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveClearResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveClearResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CacheReserveClearResponseEnvelopeSuccess bool @@ -494,8 +424,8 @@ func (r CacheReserveEditParamsValue) IsKnown() bool { } type CacheReserveEditResponseEnvelope struct { - Errors []CacheReserveEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheReserveEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Increase cache lifetimes by automatically storing all cacheable files into // Cloudflare's persistent object storage buckets. Requires Cache Reserve // subscription. Note: using Tiered Cache with Cache Reserve is highly recommended @@ -527,52 +457,6 @@ func (r cacheReserveEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CacheReserveEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheReserveEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CacheReserveEditResponseEnvelopeErrors] -type cacheReserveEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheReserveEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheReserveEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CacheReserveEditResponseEnvelopeMessages] -type cacheReserveEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CacheReserveEditResponseEnvelopeSuccess bool @@ -594,8 +478,8 @@ type CacheReserveGetParams struct { } type CacheReserveGetResponseEnvelope struct { - Errors []CacheReserveGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheReserveGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Increase cache lifetimes by automatically storing all cacheable files into // Cloudflare's persistent object storage buckets. Requires Cache Reserve // subscription. Note: using Tiered Cache with Cache Reserve is highly recommended @@ -627,52 +511,6 @@ func (r cacheReserveGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CacheReserveGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheReserveGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CacheReserveGetResponseEnvelopeErrors] -type cacheReserveGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheReserveGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheReserveGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CacheReserveGetResponseEnvelopeMessages] -type cacheReserveGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CacheReserveGetResponseEnvelopeSuccess bool @@ -694,8 +532,8 @@ type CacheReserveStatusParams struct { } type CacheReserveStatusResponseEnvelope struct { - Errors []CacheReserveStatusResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheReserveStatusResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // You can use Cache Reserve Clear to clear your Cache Reserve, but you must first // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind @@ -725,52 +563,6 @@ func (r cacheReserveStatusResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CacheReserveStatusResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveStatusResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheReserveStatusResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CacheReserveStatusResponseEnvelopeErrors] -type cacheReserveStatusResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveStatusResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveStatusResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheReserveStatusResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheReserveStatusResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheReserveStatusResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CacheReserveStatusResponseEnvelopeMessages] -type cacheReserveStatusResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheReserveStatusResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheReserveStatusResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CacheReserveStatusResponseEnvelopeSuccess bool diff --git a/cache/cachereserve_test.go b/cache/cachereserve_test.go index fe4d416d3cc..af51eb1a1a0 100644 --- a/cache/cachereserve_test.go +++ b/cache/cachereserve_test.go @@ -30,6 +30,7 @@ func TestCacheReserveClear(t *testing.T) { ) _, err := client.Cache.CacheReserve.Clear(context.TODO(), cache.CacheReserveClearParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: "{}", }) if err != nil { var apierr *cloudflare.Error diff --git a/cache/regionaltieredcache.go b/cache/regionaltieredcache.go index f328aa8b9f7..ac03f6bf3e2 100644 --- a/cache/regionaltieredcache.go +++ b/cache/regionaltieredcache.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -62,12 +63,27 @@ func (r *RegionalTieredCacheService) Get(ctx context.Context, query RegionalTier return } +// ID of the zone setting. +type RegionalTieredCache string + +const ( + RegionalTieredCacheTcRegional RegionalTieredCache = "tc_regional" +) + +func (r RegionalTieredCache) IsKnown() bool { + switch r { + case RegionalTieredCacheTcRegional: + return true + } + return false +} + // Instructs Cloudflare to check a regional hub data center on the way to your // upper tier. This can help improve performance for smart and custom tiered cache // topologies. type RegionalTieredCacheEditResponse struct { // ID of the zone setting. - ID RegionalTieredCacheEditResponseID `json:"id,required"` + ID RegionalTieredCache `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Instructs Cloudflare to check a regional hub data center on the way to your @@ -95,27 +111,12 @@ func (r regionalTieredCacheEditResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type RegionalTieredCacheEditResponseID string - -const ( - RegionalTieredCacheEditResponseIDTcRegional RegionalTieredCacheEditResponseID = "tc_regional" -) - -func (r RegionalTieredCacheEditResponseID) IsKnown() bool { - switch r { - case RegionalTieredCacheEditResponseIDTcRegional: - return true - } - return false -} - // Instructs Cloudflare to check a regional hub data center on the way to your // upper tier. This can help improve performance for smart and custom tiered cache // topologies. type RegionalTieredCacheEditResponseValue struct { // ID of the zone setting. - ID RegionalTieredCacheEditResponseValueID `json:"id,required"` + ID RegionalTieredCache `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` JSON regionalTieredCacheEditResponseValueJSON `json:"-"` @@ -138,27 +139,12 @@ func (r regionalTieredCacheEditResponseValueJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type RegionalTieredCacheEditResponseValueID string - -const ( - RegionalTieredCacheEditResponseValueIDTcRegional RegionalTieredCacheEditResponseValueID = "tc_regional" -) - -func (r RegionalTieredCacheEditResponseValueID) IsKnown() bool { - switch r { - case RegionalTieredCacheEditResponseValueIDTcRegional: - return true - } - return false -} - // Instructs Cloudflare to check a regional hub data center on the way to your // upper tier. This can help improve performance for smart and custom tiered cache // topologies. type RegionalTieredCacheGetResponse struct { // ID of the zone setting. - ID RegionalTieredCacheGetResponseID `json:"id,required"` + ID RegionalTieredCache `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Instructs Cloudflare to check a regional hub data center on the way to your @@ -186,27 +172,12 @@ func (r regionalTieredCacheGetResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type RegionalTieredCacheGetResponseID string - -const ( - RegionalTieredCacheGetResponseIDTcRegional RegionalTieredCacheGetResponseID = "tc_regional" -) - -func (r RegionalTieredCacheGetResponseID) IsKnown() bool { - switch r { - case RegionalTieredCacheGetResponseIDTcRegional: - return true - } - return false -} - // Instructs Cloudflare to check a regional hub data center on the way to your // upper tier. This can help improve performance for smart and custom tiered cache // topologies. type RegionalTieredCacheGetResponseValue struct { // ID of the zone setting. - ID RegionalTieredCacheGetResponseValueID `json:"id,required"` + ID RegionalTieredCache `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` JSON regionalTieredCacheGetResponseValueJSON `json:"-"` @@ -229,21 +200,6 @@ func (r regionalTieredCacheGetResponseValueJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type RegionalTieredCacheGetResponseValueID string - -const ( - RegionalTieredCacheGetResponseValueIDTcRegional RegionalTieredCacheGetResponseValueID = "tc_regional" -) - -func (r RegionalTieredCacheGetResponseValueID) IsKnown() bool { - switch r { - case RegionalTieredCacheGetResponseValueIDTcRegional: - return true - } - return false -} - type RegionalTieredCacheEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -272,8 +228,8 @@ func (r RegionalTieredCacheEditParamsValue) IsKnown() bool { } type RegionalTieredCacheEditResponseEnvelope struct { - Errors []RegionalTieredCacheEditResponseEnvelopeErrors `json:"errors,required"` - Messages []RegionalTieredCacheEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Instructs Cloudflare to check a regional hub data center on the way to your // upper tier. This can help improve performance for smart and custom tiered cache // topologies. @@ -302,52 +258,6 @@ func (r regionalTieredCacheEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RegionalTieredCacheEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionalTieredCacheEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// regionalTieredCacheEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RegionalTieredCacheEditResponseEnvelopeErrors] -type regionalTieredCacheEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionalTieredCacheEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionalTieredCacheEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RegionalTieredCacheEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionalTieredCacheEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// regionalTieredCacheEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [RegionalTieredCacheEditResponseEnvelopeMessages] -type regionalTieredCacheEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionalTieredCacheEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionalTieredCacheEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RegionalTieredCacheEditResponseEnvelopeSuccess bool @@ -369,8 +279,8 @@ type RegionalTieredCacheGetParams struct { } type RegionalTieredCacheGetResponseEnvelope struct { - Errors []RegionalTieredCacheGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RegionalTieredCacheGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Instructs Cloudflare to check a regional hub data center on the way to your // upper tier. This can help improve performance for smart and custom tiered cache // topologies. @@ -399,52 +309,6 @@ func (r regionalTieredCacheGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RegionalTieredCacheGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionalTieredCacheGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// regionalTieredCacheGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RegionalTieredCacheGetResponseEnvelopeErrors] -type regionalTieredCacheGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionalTieredCacheGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionalTieredCacheGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RegionalTieredCacheGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionalTieredCacheGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// regionalTieredCacheGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [RegionalTieredCacheGetResponseEnvelopeMessages] -type regionalTieredCacheGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionalTieredCacheGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionalTieredCacheGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RegionalTieredCacheGetResponseEnvelopeSuccess bool diff --git a/cache/smarttieredcache.go b/cache/smarttieredcache.go index 3ea7875f2c7..dbbbec55ad7 100644 --- a/cache/smarttieredcache.go +++ b/cache/smarttieredcache.go @@ -35,10 +35,10 @@ func NewSmartTieredCacheService(opts ...option.RequestOption) (r *SmartTieredCac } // Remvoves enablement of Smart Tiered Cache -func (r *SmartTieredCacheService) Delete(ctx context.Context, body SmartTieredCacheDeleteParams, opts ...option.RequestOption) (res *SmartTieredCacheDeleteResponse, err error) { +func (r *SmartTieredCacheService) Delete(ctx context.Context, params SmartTieredCacheDeleteParams, opts ...option.RequestOption) (res *SmartTieredCacheDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SmartTieredCacheDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", body.ZoneID) + path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -48,7 +48,7 @@ func (r *SmartTieredCacheService) Delete(ctx context.Context, body SmartTieredCa } // Updates enablement of Tiered Cache -func (r *SmartTieredCacheService) Edit(ctx context.Context, params SmartTieredCacheEditParams, opts ...option.RequestOption) (res *SmartTieredCacheEditResponse, err error) { +func (r *SmartTieredCacheService) Edit(ctx context.Context, params SmartTieredCacheEditParams, opts ...option.RequestOption) (res *SmartTieredCacheEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SmartTieredCacheEditResponseEnvelope path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", params.ZoneID) @@ -61,7 +61,7 @@ func (r *SmartTieredCacheService) Edit(ctx context.Context, params SmartTieredCa } // Get Smart Tiered Cache setting -func (r *SmartTieredCacheService) Get(ctx context.Context, query SmartTieredCacheGetParams, opts ...option.RequestOption) (res *SmartTieredCacheGetResponse, err error) { +func (r *SmartTieredCacheService) Get(ctx context.Context, query SmartTieredCacheGetParams, opts ...option.RequestOption) (res *SmartTieredCacheGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SmartTieredCacheGetResponseEnvelope path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", query.ZoneID) @@ -75,13 +75,13 @@ func (r *SmartTieredCacheService) Get(ctx context.Context, query SmartTieredCach // Union satisfied by [cache.SmartTieredCacheDeleteResponseUnknown] or // [shared.UnionString]. -type SmartTieredCacheDeleteResponse interface { - ImplementsCacheSmartTieredCacheDeleteResponse() +type SmartTieredCacheDeleteResponseUnion interface { + ImplementsCacheSmartTieredCacheDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SmartTieredCacheDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*SmartTieredCacheDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -92,13 +92,13 @@ func init() { // Union satisfied by [cache.SmartTieredCacheEditResponseUnknown] or // [shared.UnionString]. -type SmartTieredCacheEditResponse interface { - ImplementsCacheSmartTieredCacheEditResponse() +type SmartTieredCacheEditResponseUnion interface { + ImplementsCacheSmartTieredCacheEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SmartTieredCacheEditResponse)(nil)).Elem(), + reflect.TypeOf((*SmartTieredCacheEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -109,13 +109,13 @@ func init() { // Union satisfied by [cache.SmartTieredCacheGetResponseUnknown] or // [shared.UnionString]. -type SmartTieredCacheGetResponse interface { - ImplementsCacheSmartTieredCacheGetResponse() +type SmartTieredCacheGetResponseUnion interface { + ImplementsCacheSmartTieredCacheGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SmartTieredCacheGetResponse)(nil)).Elem(), + reflect.TypeOf((*SmartTieredCacheGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -127,12 +127,17 @@ func init() { type SmartTieredCacheDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r SmartTieredCacheDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type SmartTieredCacheDeleteResponseEnvelope struct { - Errors []SmartTieredCacheDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SmartTieredCacheDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SmartTieredCacheDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SmartTieredCacheDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success SmartTieredCacheDeleteResponseEnvelopeSuccess `json:"success,required"` JSON smartTieredCacheDeleteResponseEnvelopeJSON `json:"-"` @@ -157,52 +162,6 @@ func (r smartTieredCacheDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SmartTieredCacheDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartTieredCacheDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// smartTieredCacheDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SmartTieredCacheDeleteResponseEnvelopeErrors] -type smartTieredCacheDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartTieredCacheDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartTieredCacheDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SmartTieredCacheDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartTieredCacheDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// smartTieredCacheDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SmartTieredCacheDeleteResponseEnvelopeMessages] -type smartTieredCacheDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartTieredCacheDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartTieredCacheDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SmartTieredCacheDeleteResponseEnvelopeSuccess bool @@ -246,9 +205,9 @@ func (r SmartTieredCacheEditParamsValue) IsKnown() bool { } type SmartTieredCacheEditResponseEnvelope struct { - Errors []SmartTieredCacheEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SmartTieredCacheEditResponseEnvelopeMessages `json:"messages,required"` - Result SmartTieredCacheEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SmartTieredCacheEditResponseUnion `json:"result,required"` // Whether the API call was successful Success SmartTieredCacheEditResponseEnvelopeSuccess `json:"success,required"` JSON smartTieredCacheEditResponseEnvelopeJSON `json:"-"` @@ -273,52 +232,6 @@ func (r smartTieredCacheEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SmartTieredCacheEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartTieredCacheEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// smartTieredCacheEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SmartTieredCacheEditResponseEnvelopeErrors] -type smartTieredCacheEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartTieredCacheEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartTieredCacheEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SmartTieredCacheEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartTieredCacheEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// smartTieredCacheEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SmartTieredCacheEditResponseEnvelopeMessages] -type smartTieredCacheEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartTieredCacheEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartTieredCacheEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SmartTieredCacheEditResponseEnvelopeSuccess bool @@ -340,9 +253,9 @@ type SmartTieredCacheGetParams struct { } type SmartTieredCacheGetResponseEnvelope struct { - Errors []SmartTieredCacheGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SmartTieredCacheGetResponseEnvelopeMessages `json:"messages,required"` - Result SmartTieredCacheGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SmartTieredCacheGetResponseUnion `json:"result,required"` // Whether the API call was successful Success SmartTieredCacheGetResponseEnvelopeSuccess `json:"success,required"` JSON smartTieredCacheGetResponseEnvelopeJSON `json:"-"` @@ -367,52 +280,6 @@ func (r smartTieredCacheGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SmartTieredCacheGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartTieredCacheGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// smartTieredCacheGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SmartTieredCacheGetResponseEnvelopeErrors] -type smartTieredCacheGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartTieredCacheGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartTieredCacheGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SmartTieredCacheGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON smartTieredCacheGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// smartTieredCacheGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SmartTieredCacheGetResponseEnvelopeMessages] -type smartTieredCacheGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SmartTieredCacheGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r smartTieredCacheGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SmartTieredCacheGetResponseEnvelopeSuccess bool diff --git a/cache/smarttieredcache_test.go b/cache/smarttieredcache_test.go index cc24d46ab81..661bf82872f 100644 --- a/cache/smarttieredcache_test.go +++ b/cache/smarttieredcache_test.go @@ -30,6 +30,7 @@ func TestSmartTieredCacheDelete(t *testing.T) { ) _, err := client.Cache.SmartTieredCache.Delete(context.TODO(), cache.SmartTieredCacheDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/cache/variant.go b/cache/variant.go index 8510c354296..ff9d012756d 100644 --- a/cache/variant.go +++ b/cache/variant.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,10 +37,10 @@ func NewVariantService(opts ...option.RequestOption) (r *VariantService) { // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but // does not serve the variant requested, the response will not be cached. This will // be indicated with BYPASS cache status in the response headers. -func (r *VariantService) Delete(ctx context.Context, body VariantDeleteParams, opts ...option.RequestOption) (res *CacheVariants, err error) { +func (r *VariantService) Delete(ctx context.Context, params VariantDeleteParams, opts ...option.RequestOption) (res *CacheVariant, err error) { opts = append(r.Options[:], opts...) var env VariantDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/variants", body.ZoneID) + path := fmt.Sprintf("zones/%s/cache/variants", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -87,40 +88,40 @@ func (r *VariantService) Get(ctx context.Context, query VariantGetParams, opts . // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but // does not serve the variant requested, the response will not be cached. This will // be indicated with BYPASS cache status in the response headers. -type CacheVariants struct { +type CacheVariant struct { // ID of the zone setting. - ID CacheVariantsID `json:"id,required"` + ID CacheVariantIdentifier `json:"id,required"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - JSON cacheVariantsJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + JSON cacheVariantJSON `json:"-"` } -// cacheVariantsJSON contains the JSON metadata for the struct [CacheVariants] -type cacheVariantsJSON struct { +// cacheVariantJSON contains the JSON metadata for the struct [CacheVariant] +type cacheVariantJSON struct { ID apijson.Field ModifiedOn apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *CacheVariants) UnmarshalJSON(data []byte) (err error) { +func (r *CacheVariant) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r cacheVariantsJSON) RawJSON() string { +func (r cacheVariantJSON) RawJSON() string { return r.raw } // ID of the zone setting. -type CacheVariantsID string +type CacheVariantIdentifier string const ( - CacheVariantsIDVariants CacheVariantsID = "variants" + CacheVariantIdentifierVariants CacheVariantIdentifier = "variants" ) -func (r CacheVariantsID) IsKnown() bool { +func (r CacheVariantIdentifier) IsKnown() bool { switch r { - case CacheVariantsIDVariants: + case CacheVariantIdentifierVariants: return true } return false @@ -133,7 +134,7 @@ func (r CacheVariantsID) IsKnown() bool { // be indicated with BYPASS cache status in the response headers. type VariantEditResponse struct { // ID of the zone setting. - ID VariantEditResponseID `json:"id,required"` + ID CacheVariantIdentifier `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the zone setting. @@ -159,21 +160,6 @@ func (r variantEditResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type VariantEditResponseID string - -const ( - VariantEditResponseIDVariants VariantEditResponseID = "variants" -) - -func (r VariantEditResponseID) IsKnown() bool { - switch r { - case VariantEditResponseIDVariants: - return true - } - return false -} - // Value of the zone setting. type VariantEditResponseValue struct { // List of strings with the MIME types of all the variants that should be served @@ -245,7 +231,7 @@ func (r variantEditResponseValueJSON) RawJSON() string { // be indicated with BYPASS cache status in the response headers. type VariantGetResponse struct { // ID of the zone setting. - ID VariantGetResponseID `json:"id,required"` + ID CacheVariantIdentifier `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the zone setting. @@ -271,21 +257,6 @@ func (r variantGetResponseJSON) RawJSON() string { return r.raw } -// ID of the zone setting. -type VariantGetResponseID string - -const ( - VariantGetResponseIDVariants VariantGetResponseID = "variants" -) - -func (r VariantGetResponseID) IsKnown() bool { - switch r { - case VariantGetResponseIDVariants: - return true - } - return false -} - // Value of the zone setting. type VariantGetResponseValue struct { // List of strings with the MIME types of all the variants that should be served @@ -353,17 +324,22 @@ func (r variantGetResponseValueJSON) RawJSON() string { type VariantDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r VariantDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type VariantDeleteResponseEnvelope struct { - Errors []VariantDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []VariantDeleteResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Variant support enables caching variants of images with certain file extensions // in addition to the original. This only applies when the origin server sends the // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but // does not serve the variant requested, the response will not be cached. This will // be indicated with BYPASS cache status in the response headers. - Result CacheVariants `json:"result,required"` + Result CacheVariant `json:"result,required"` // Whether the API call was successful Success VariantDeleteResponseEnvelopeSuccess `json:"success,required"` JSON variantDeleteResponseEnvelopeJSON `json:"-"` @@ -388,52 +364,6 @@ func (r variantDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type VariantDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON variantDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// variantDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [VariantDeleteResponseEnvelopeErrors] -type variantDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VariantDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r variantDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VariantDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON variantDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// variantDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [VariantDeleteResponseEnvelopeMessages] -type variantDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VariantDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r variantDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type VariantDeleteResponseEnvelopeSuccess bool @@ -502,8 +432,8 @@ func (r VariantEditParamsValue) MarshalJSON() (data []byte, err error) { } type VariantEditResponseEnvelope struct { - Errors []VariantEditResponseEnvelopeErrors `json:"errors,required"` - Messages []VariantEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Variant support enables caching variants of images with certain file extensions // in addition to the original. This only applies when the origin server sends the // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but @@ -534,52 +464,6 @@ func (r variantEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type VariantEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON variantEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// variantEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [VariantEditResponseEnvelopeErrors] -type variantEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VariantEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r variantEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VariantEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON variantEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// variantEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [VariantEditResponseEnvelopeMessages] -type variantEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VariantEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r variantEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type VariantEditResponseEnvelopeSuccess bool @@ -601,8 +485,8 @@ type VariantGetParams struct { } type VariantGetResponseEnvelope struct { - Errors []VariantGetResponseEnvelopeErrors `json:"errors,required"` - Messages []VariantGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Variant support enables caching variants of images with certain file extensions // in addition to the original. This only applies when the origin server sends the // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but @@ -633,52 +517,6 @@ func (r variantGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type VariantGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON variantGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// variantGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [VariantGetResponseEnvelopeErrors] -type variantGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VariantGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r variantGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VariantGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON variantGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// variantGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [VariantGetResponseEnvelopeMessages] -type variantGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VariantGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r variantGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type VariantGetResponseEnvelopeSuccess bool diff --git a/cache/variant_test.go b/cache/variant_test.go index 867cf1df817..fc9b3f6b763 100644 --- a/cache/variant_test.go +++ b/cache/variant_test.go @@ -30,6 +30,7 @@ func TestVariantDelete(t *testing.T) { ) _, err := client.Cache.Variants.Delete(context.TODO(), cache.VariantDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/calls/aliases.go b/calls/aliases.go index 55eb385a675..eb71c1958dc 100644 --- a/calls/aliases.go +++ b/calls/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/calls/call.go b/calls/call.go index 37f98c214f1..229706855cd 100644 --- a/calls/call.go +++ b/calls/call.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -116,7 +117,7 @@ type CallsApp struct { // A short description of Calls app, not shown to end users. Name string `json:"name"` // A Cloudflare-generated unique identifier for a item. - Uid string `json:"uid"` + UID string `json:"uid"` JSON callsAppJSON `json:"-"` } @@ -125,7 +126,7 @@ type callsAppJSON struct { Created apijson.Field Modified apijson.Field Name apijson.Field - Uid apijson.Field + UID apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -148,7 +149,7 @@ type CallsAppWithSecret struct { // Bearer token to use the Calls API. Secret string `json:"secret"` // A Cloudflare-generated unique identifier for a item. - Uid string `json:"uid"` + UID string `json:"uid"` JSON callsAppWithSecretJSON `json:"-"` } @@ -159,7 +160,7 @@ type callsAppWithSecretJSON struct { Modified apijson.Field Name apijson.Field Secret apijson.Field - Uid apijson.Field + UID apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -184,9 +185,9 @@ func (r CallNewParams) MarshalJSON() (data []byte, err error) { } type CallNewResponseEnvelope struct { - Errors []CallNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CallNewResponseEnvelopeMessages `json:"messages,required"` - Result CallsAppWithSecret `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CallsAppWithSecret `json:"result,required"` // Whether the API call was successful Success CallNewResponseEnvelopeSuccess `json:"success,required"` JSON callNewResponseEnvelopeJSON `json:"-"` @@ -211,52 +212,6 @@ func (r callNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CallNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// callNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [CallNewResponseEnvelopeErrors] -type callNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CallNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// callNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [CallNewResponseEnvelopeMessages] -type callNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CallNewResponseEnvelopeSuccess bool @@ -284,9 +239,9 @@ func (r CallUpdateParams) MarshalJSON() (data []byte, err error) { } type CallUpdateResponseEnvelope struct { - Errors []CallUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CallUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CallsApp `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CallsApp `json:"result,required"` // Whether the API call was successful Success CallUpdateResponseEnvelopeSuccess `json:"success,required"` JSON callUpdateResponseEnvelopeJSON `json:"-"` @@ -311,52 +266,6 @@ func (r callUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CallUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// callUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [CallUpdateResponseEnvelopeErrors] -type callUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CallUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// callUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [CallUpdateResponseEnvelopeMessages] -type callUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CallUpdateResponseEnvelopeSuccess bool @@ -383,9 +292,9 @@ type CallDeleteParams struct { } type CallDeleteResponseEnvelope struct { - Errors []CallDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CallDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CallsApp `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CallsApp `json:"result,required"` // Whether the API call was successful Success CallDeleteResponseEnvelopeSuccess `json:"success,required"` JSON callDeleteResponseEnvelopeJSON `json:"-"` @@ -410,52 +319,6 @@ func (r callDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CallDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// callDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [CallDeleteResponseEnvelopeErrors] -type callDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CallDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// callDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [CallDeleteResponseEnvelopeMessages] -type callDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CallDeleteResponseEnvelopeSuccess bool @@ -477,9 +340,9 @@ type CallGetParams struct { } type CallGetResponseEnvelope struct { - Errors []CallGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CallGetResponseEnvelopeMessages `json:"messages,required"` - Result CallsApp `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CallsApp `json:"result,required"` // Whether the API call was successful Success CallGetResponseEnvelopeSuccess `json:"success,required"` JSON callGetResponseEnvelopeJSON `json:"-"` @@ -504,52 +367,6 @@ func (r callGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CallGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// callGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [CallGetResponseEnvelopeErrors] -type callGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CallGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON callGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// callGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [CallGetResponseEnvelopeMessages] -type callGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CallGetResponseEnvelopeSuccess bool diff --git a/certificate_authorities/aliases.go b/certificate_authorities/aliases.go index a31d998058d..b179e90a28d 100644 --- a/certificate_authorities/aliases.go +++ b/certificate_authorities/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/certificate_authorities/hostnameassociation.go b/certificate_authorities/hostnameassociation.go index 28c0042f169..9ac2362bd9e 100644 --- a/certificate_authorities/hostnameassociation.go +++ b/certificate_authorities/hostnameassociation.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -34,7 +35,7 @@ func NewHostnameAssociationService(opts ...option.RequestOption) (r *HostnameAss } // Replace Hostname Associations -func (r *HostnameAssociationService) Update(ctx context.Context, params HostnameAssociationUpdateParams, opts ...option.RequestOption) (res *TLSHostnameAssociation, err error) { +func (r *HostnameAssociationService) Update(ctx context.Context, params HostnameAssociationUpdateParams, opts ...option.RequestOption) (res *HostnameAssociationUpdateResponse, err error) { opts = append(r.Options[:], opts...) var env HostnameAssociationUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/certificate_authorities/hostname_associations", params.ZoneID) @@ -47,7 +48,7 @@ func (r *HostnameAssociationService) Update(ctx context.Context, params Hostname } // List Hostname Associations -func (r *HostnameAssociationService) Get(ctx context.Context, params HostnameAssociationGetParams, opts ...option.RequestOption) (res *TLSHostnameAssociation, err error) { +func (r *HostnameAssociationService) Get(ctx context.Context, params HostnameAssociationGetParams, opts ...option.RequestOption) (res *HostnameAssociationGetResponse, err error) { opts = append(r.Options[:], opts...) var env HostnameAssociationGetResponseEnvelope path := fmt.Sprintf("zones/%s/certificate_authorities/hostname_associations", params.ZoneID) @@ -59,117 +60,99 @@ func (r *HostnameAssociationService) Get(ctx context.Context, params HostnameAss return } -type TLSHostnameAssociation struct { - Hostnames []string `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. - MTLSCertificateID string `json:"mtls_certificate_id"` - JSON tlsHostnameAssociationJSON `json:"-"` -} - -// tlsHostnameAssociationJSON contains the JSON metadata for the struct -// [TLSHostnameAssociation] -type tlsHostnameAssociationJSON struct { - Hostnames apijson.Field - MTLSCertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TLSHostnameAssociation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +type HostnameAssociation = string -func (r tlsHostnameAssociationJSON) RawJSON() string { - return r.raw -} +type HostnameAssociationParam = string -type HostnameAssociationUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Hostnames param.Field[[]string] `json:"hostnames"` +type TLSHostnameAssociationParam struct { + 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. MTLSCertificateID param.Field[string] `json:"mtls_certificate_id"` } -func (r HostnameAssociationUpdateParams) MarshalJSON() (data []byte, err error) { +func (r TLSHostnameAssociationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type HostnameAssociationUpdateResponseEnvelope struct { - Errors []HostnameAssociationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameAssociationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result TLSHostnameAssociation `json:"result,required"` - // Whether the API call was successful - Success HostnameAssociationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON hostnameAssociationUpdateResponseEnvelopeJSON `json:"-"` +type HostnameAssociationUpdateResponse struct { + Hostnames []HostnameAssociation `json:"hostnames"` + JSON hostnameAssociationUpdateResponseJSON `json:"-"` } -// hostnameAssociationUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [HostnameAssociationUpdateResponseEnvelope] -type hostnameAssociationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field +// hostnameAssociationUpdateResponseJSON contains the JSON metadata for the struct +// [HostnameAssociationUpdateResponse] +type hostnameAssociationUpdateResponseJSON struct { + Hostnames apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *HostnameAssociationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *HostnameAssociationUpdateResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r hostnameAssociationUpdateResponseEnvelopeJSON) RawJSON() string { +func (r hostnameAssociationUpdateResponseJSON) RawJSON() string { return r.raw } -type HostnameAssociationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameAssociationUpdateResponseEnvelopeErrorsJSON `json:"-"` +type HostnameAssociationGetResponse struct { + Hostnames []HostnameAssociation `json:"hostnames"` + JSON hostnameAssociationGetResponseJSON `json:"-"` } -// hostnameAssociationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [HostnameAssociationUpdateResponseEnvelopeErrors] -type hostnameAssociationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field +// hostnameAssociationGetResponseJSON contains the JSON metadata for the struct +// [HostnameAssociationGetResponse] +type hostnameAssociationGetResponseJSON struct { + Hostnames apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *HostnameAssociationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { +func (r *HostnameAssociationGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r hostnameAssociationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { +func (r hostnameAssociationGetResponseJSON) RawJSON() string { return r.raw } -type HostnameAssociationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameAssociationUpdateResponseEnvelopeMessagesJSON `json:"-"` +type HostnameAssociationUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + TLSHostnameAssociation TLSHostnameAssociationParam `json:"tls_hostname_association,required"` +} + +func (r HostnameAssociationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.TLSHostnameAssociation) } -// hostnameAssociationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HostnameAssociationUpdateResponseEnvelopeMessages] -type hostnameAssociationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field +type HostnameAssociationUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameAssociationUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success HostnameAssociationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameAssociationUpdateResponseEnvelopeJSON `json:"-"` +} + +// hostnameAssociationUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameAssociationUpdateResponseEnvelope] +type hostnameAssociationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *HostnameAssociationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *HostnameAssociationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r hostnameAssociationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { +func (r hostnameAssociationUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } @@ -201,15 +184,15 @@ type HostnameAssociationGetParams struct { // `url.Values`. func (r HostnameAssociationGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type HostnameAssociationGetResponseEnvelope struct { - Errors []HostnameAssociationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameAssociationGetResponseEnvelopeMessages `json:"messages,required"` - Result TLSHostnameAssociation `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameAssociationGetResponse `json:"result,required"` // Whether the API call was successful Success HostnameAssociationGetResponseEnvelopeSuccess `json:"success,required"` JSON hostnameAssociationGetResponseEnvelopeJSON `json:"-"` @@ -234,52 +217,6 @@ func (r hostnameAssociationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameAssociationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameAssociationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameAssociationGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HostnameAssociationGetResponseEnvelopeErrors] -type hostnameAssociationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameAssociationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameAssociationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameAssociationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameAssociationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameAssociationGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HostnameAssociationGetResponseEnvelopeMessages] -type hostnameAssociationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameAssociationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameAssociationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameAssociationGetResponseEnvelopeSuccess bool diff --git a/certificate_authorities/hostnameassociation_test.go b/certificate_authorities/hostnameassociation_test.go index a155eeb3020..fb40cc9e557 100644 --- a/certificate_authorities/hostnameassociation_test.go +++ b/certificate_authorities/hostnameassociation_test.go @@ -29,9 +29,11 @@ func TestHostnameAssociationUpdateWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.CertificateAuthorities.HostnameAssociations.Update(context.TODO(), certificate_authorities.HostnameAssociationUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Hostnames: cloudflare.F([]string{"api.example.com", "api.example.com", "api.example.com"}), - MTLSCertificateID: cloudflare.F("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + TLSHostnameAssociation: certificate_authorities.TLSHostnameAssociationParam{ + Hostnames: cloudflare.F([]certificate_authorities.HostnameAssociationParam{"api.example.com", "api.example.com", "api.example.com"}), + MTLSCertificateID: cloudflare.F("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/challenges/aliases.go b/challenges/aliases.go index c328261dc1c..0a08b216299 100644 --- a/challenges/aliases.go +++ b/challenges/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/challenges/widget.go b/challenges/widget.go index 65cd238a415..f90f2aa08d5 100644 --- a/challenges/widget.go +++ b/challenges/widget.go @@ -14,6 +14,7 @@ import ( "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" ) @@ -35,7 +36,7 @@ func NewWidgetService(opts ...option.RequestOption) (r *WidgetService) { } // Lists challenge widgets. -func (r *WidgetService) New(ctx context.Context, params WidgetNewParams, opts ...option.RequestOption) (res *ChallengesWidget, err error) { +func (r *WidgetService) New(ctx context.Context, params WidgetNewParams, opts ...option.RequestOption) (res *Widget, err error) { opts = append(r.Options[:], opts...) var env WidgetNewResponseEnvelope path := fmt.Sprintf("accounts/%s/challenges/widgets", params.AccountID) @@ -48,7 +49,7 @@ func (r *WidgetService) New(ctx context.Context, params WidgetNewParams, opts .. } // Update the configuration of a widget. -func (r *WidgetService) Update(ctx context.Context, sitekey string, params WidgetUpdateParams, opts ...option.RequestOption) (res *ChallengesWidget, err error) { +func (r *WidgetService) Update(ctx context.Context, sitekey string, params WidgetUpdateParams, opts ...option.RequestOption) (res *Widget, err error) { opts = append(r.Options[:], opts...) var env WidgetUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", params.AccountID, sitekey) @@ -61,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[ChallengesWidgetList], 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...) @@ -79,12 +80,12 @@ 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[ChallengesWidgetList] { +func (r *WidgetService) ListAutoPaging(ctx context.Context, params WidgetListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WidgetListResponse] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } // Destroy a Turnstile Widget. -func (r *WidgetService) Delete(ctx context.Context, sitekey string, body WidgetDeleteParams, opts ...option.RequestOption) (res *ChallengesWidget, err error) { +func (r *WidgetService) Delete(ctx context.Context, sitekey string, body WidgetDeleteParams, opts ...option.RequestOption) (res *Widget, err error) { opts = append(r.Options[:], opts...) var env WidgetDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", body.AccountID, sitekey) @@ -97,7 +98,7 @@ func (r *WidgetService) Delete(ctx context.Context, sitekey string, body WidgetD } // Show a single challenge widget configuration. -func (r *WidgetService) Get(ctx context.Context, sitekey string, query WidgetGetParams, opts ...option.RequestOption) (res *ChallengesWidget, err error) { +func (r *WidgetService) Get(ctx context.Context, sitekey string, query WidgetGetParams, opts ...option.RequestOption) (res *Widget, err error) { opts = append(r.Options[:], opts...) var env WidgetGetResponseEnvelope path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", query.AccountID, sitekey) @@ -113,7 +114,7 @@ func (r *WidgetService) Get(ctx context.Context, sitekey string, query WidgetGet // `false`, the previous secret remains valid for 2 hours. // // Note that secrets cannot be rotated again during the grace period. -func (r *WidgetService) RotateSecret(ctx context.Context, sitekey string, params WidgetRotateSecretParams, opts ...option.RequestOption) (res *ChallengesWidget, err error) { +func (r *WidgetService) RotateSecret(ctx context.Context, sitekey string, params WidgetRotateSecretParams, opts ...option.RequestOption) (res *Widget, err error) { opts = append(r.Options[:], opts...) var env WidgetRotateSecretResponseEnvelope path := fmt.Sprintf("accounts/%s/challenges/widgets/%s/rotate_secret", params.AccountID, sitekey) @@ -126,18 +127,18 @@ func (r *WidgetService) RotateSecret(ctx context.Context, sitekey string, params } // A Turnstile widget's detailed configuration -type ChallengesWidget struct { +type Widget 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 ChallengesWidgetClearanceLevel `json:"clearance_level,required"` + ClearanceLevel WidgetClearanceLevel `json:"clearance_level,required"` // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []string `json:"domains,required"` + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + Domains []WidgetDomain `json:"domains,required"` // Widget Mode - Mode ChallengesWidgetMode `json:"mode,required"` + Mode WidgetMode `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 @@ -147,17 +148,16 @@ type ChallengesWidget 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 ChallengesWidgetRegion `json:"region,required"` + Region WidgetRegion `json:"region,required"` // Secret key for this widget. Secret string `json:"secret,required"` // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengesWidgetJSON `json:"-"` + Sitekey string `json:"sitekey,required"` + JSON widgetJSON `json:"-"` } -// challengesWidgetJSON contains the JSON metadata for the struct -// [ChallengesWidget] -type challengesWidgetJSON struct { +// widgetJSON contains the JSON metadata for the struct [Widget] +type widgetJSON struct { BotFightMode apijson.Field ClearanceLevel apijson.Field CreatedOn apijson.Field @@ -173,78 +173,82 @@ type challengesWidgetJSON struct { ExtraFields map[string]apijson.Field } -func (r *ChallengesWidget) UnmarshalJSON(data []byte) (err error) { +func (r *Widget) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r challengesWidgetJSON) RawJSON() string { +func (r widgetJSON) 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 ChallengesWidgetClearanceLevel string +type WidgetClearanceLevel string const ( - ChallengesWidgetClearanceLevelNoClearance ChallengesWidgetClearanceLevel = "no_clearance" - ChallengesWidgetClearanceLevelJschallenge ChallengesWidgetClearanceLevel = "jschallenge" - ChallengesWidgetClearanceLevelManaged ChallengesWidgetClearanceLevel = "managed" - ChallengesWidgetClearanceLevelInteractive ChallengesWidgetClearanceLevel = "interactive" + WidgetClearanceLevelNoClearance WidgetClearanceLevel = "no_clearance" + WidgetClearanceLevelJschallenge WidgetClearanceLevel = "jschallenge" + WidgetClearanceLevelManaged WidgetClearanceLevel = "managed" + WidgetClearanceLevelInteractive WidgetClearanceLevel = "interactive" ) -func (r ChallengesWidgetClearanceLevel) IsKnown() bool { +func (r WidgetClearanceLevel) IsKnown() bool { switch r { - case ChallengesWidgetClearanceLevelNoClearance, ChallengesWidgetClearanceLevelJschallenge, ChallengesWidgetClearanceLevelManaged, ChallengesWidgetClearanceLevelInteractive: + case WidgetClearanceLevelNoClearance, WidgetClearanceLevelJschallenge, WidgetClearanceLevelManaged, WidgetClearanceLevelInteractive: return true } return false } // Widget Mode -type ChallengesWidgetMode string +type WidgetMode string const ( - ChallengesWidgetModeNonInteractive ChallengesWidgetMode = "non-interactive" - ChallengesWidgetModeInvisible ChallengesWidgetMode = "invisible" - ChallengesWidgetModeManaged ChallengesWidgetMode = "managed" + WidgetModeNonInteractive WidgetMode = "non-interactive" + WidgetModeInvisible WidgetMode = "invisible" + WidgetModeManaged WidgetMode = "managed" ) -func (r ChallengesWidgetMode) IsKnown() bool { +func (r WidgetMode) IsKnown() bool { switch r { - case ChallengesWidgetModeNonInteractive, ChallengesWidgetModeInvisible, ChallengesWidgetModeManaged: + case WidgetModeNonInteractive, WidgetModeInvisible, WidgetModeManaged: return true } return false } // Region where this widget can be used. -type ChallengesWidgetRegion string +type WidgetRegion string const ( - ChallengesWidgetRegionWorld ChallengesWidgetRegion = "world" + WidgetRegionWorld WidgetRegion = "world" ) -func (r ChallengesWidgetRegion) IsKnown() bool { +func (r WidgetRegion) IsKnown() bool { switch r { - case ChallengesWidgetRegionWorld: + case WidgetRegionWorld: return true } return false } +type WidgetDomain = string + +type WidgetDomainParam = string + // A Turnstile Widgets configuration as it appears in listings -type ChallengesWidgetList 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 ChallengesWidgetListClearanceLevel `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 []string `json:"domains,required"` + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + Domains []WidgetDomain `json:"domains,required"` // Widget Mode - Mode ChallengesWidgetListMode `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,15 +258,15 @@ type ChallengesWidgetList 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 ChallengesWidgetListRegion `json:"region,required"` + Region WidgetListResponseRegion `json:"region,required"` // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengesWidgetListJSON `json:"-"` + Sitekey string `json:"sitekey,required"` + JSON widgetListResponseJSON `json:"-"` } -// challengesWidgetListJSON contains the JSON metadata for the struct -// [ChallengesWidgetList] -type challengesWidgetListJSON struct { +// widgetListResponseJSON contains the JSON metadata for the struct +// [WidgetListResponse] +type widgetListResponseJSON struct { BotFightMode apijson.Field ClearanceLevel apijson.Field CreatedOn apijson.Field @@ -277,60 +281,60 @@ type challengesWidgetListJSON struct { ExtraFields map[string]apijson.Field } -func (r *ChallengesWidgetList) UnmarshalJSON(data []byte) (err error) { +func (r *WidgetListResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r challengesWidgetListJSON) 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 ChallengesWidgetListClearanceLevel string +type WidgetListResponseClearanceLevel string const ( - ChallengesWidgetListClearanceLevelNoClearance ChallengesWidgetListClearanceLevel = "no_clearance" - ChallengesWidgetListClearanceLevelJschallenge ChallengesWidgetListClearanceLevel = "jschallenge" - ChallengesWidgetListClearanceLevelManaged ChallengesWidgetListClearanceLevel = "managed" - ChallengesWidgetListClearanceLevelInteractive ChallengesWidgetListClearanceLevel = "interactive" + WidgetListResponseClearanceLevelNoClearance WidgetListResponseClearanceLevel = "no_clearance" + WidgetListResponseClearanceLevelJschallenge WidgetListResponseClearanceLevel = "jschallenge" + WidgetListResponseClearanceLevelManaged WidgetListResponseClearanceLevel = "managed" + WidgetListResponseClearanceLevelInteractive WidgetListResponseClearanceLevel = "interactive" ) -func (r ChallengesWidgetListClearanceLevel) IsKnown() bool { +func (r WidgetListResponseClearanceLevel) IsKnown() bool { switch r { - case ChallengesWidgetListClearanceLevelNoClearance, ChallengesWidgetListClearanceLevelJschallenge, ChallengesWidgetListClearanceLevelManaged, ChallengesWidgetListClearanceLevelInteractive: + case WidgetListResponseClearanceLevelNoClearance, WidgetListResponseClearanceLevelJschallenge, WidgetListResponseClearanceLevelManaged, WidgetListResponseClearanceLevelInteractive: return true } return false } // Widget Mode -type ChallengesWidgetListMode string +type WidgetListResponseMode string const ( - ChallengesWidgetListModeNonInteractive ChallengesWidgetListMode = "non-interactive" - ChallengesWidgetListModeInvisible ChallengesWidgetListMode = "invisible" - ChallengesWidgetListModeManaged ChallengesWidgetListMode = "managed" + WidgetListResponseModeNonInteractive WidgetListResponseMode = "non-interactive" + WidgetListResponseModeInvisible WidgetListResponseMode = "invisible" + WidgetListResponseModeManaged WidgetListResponseMode = "managed" ) -func (r ChallengesWidgetListMode) IsKnown() bool { +func (r WidgetListResponseMode) IsKnown() bool { switch r { - case ChallengesWidgetListModeNonInteractive, ChallengesWidgetListModeInvisible, ChallengesWidgetListModeManaged: + case WidgetListResponseModeNonInteractive, WidgetListResponseModeInvisible, WidgetListResponseModeManaged: return true } return false } // Region where this widget can be used. -type ChallengesWidgetListRegion string +type WidgetListResponseRegion string const ( - ChallengesWidgetListRegionWorld ChallengesWidgetListRegion = "world" + WidgetListResponseRegionWorld WidgetListResponseRegion = "world" ) -func (r ChallengesWidgetListRegion) IsKnown() bool { +func (r WidgetListResponseRegion) IsKnown() bool { switch r { - case ChallengesWidgetListRegionWorld: + case WidgetListResponseRegionWorld: return true } return false @@ -338,8 +342,8 @@ func (r ChallengesWidgetListRegion) IsKnown() bool { type WidgetNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domains param.Field[[]string] `json:"domains,required"` + AccountID param.Field[string] `path:"account_id,required"` + Domains param.Field[[]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 @@ -373,7 +377,7 @@ func (r WidgetNewParams) MarshalJSON() (data []byte, err error) { // URLQuery serializes [WidgetNewParams]'s query parameters as `url.Values`. func (r WidgetNewParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -465,12 +469,12 @@ func (r WidgetNewParamsRegion) IsKnown() bool { } type WidgetNewResponseEnvelope struct { - Errors []WidgetNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WidgetNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // A Turnstile widget's detailed configuration - Result ChallengesWidget `json:"result"` + Result Widget `json:"result"` ResultInfo WidgetNewResponseEnvelopeResultInfo `json:"result_info"` JSON widgetNewResponseEnvelopeJSON `json:"-"` } @@ -495,52 +499,6 @@ func (r widgetNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WidgetNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// widgetNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WidgetNewResponseEnvelopeErrors] -type widgetNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WidgetNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// widgetNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [WidgetNewResponseEnvelopeMessages] -type widgetNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type WidgetNewResponseEnvelopeResultInfo struct { // Total number of results for the requested service Count float64 `json:"count,required"` @@ -574,8 +532,8 @@ func (r widgetNewResponseEnvelopeResultInfoJSON) RawJSON() string { type WidgetUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domains param.Field[[]string] `json:"domains,required"` + AccountID param.Field[string] `path:"account_id,required"` + Domains param.Field[[]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 @@ -633,12 +591,12 @@ func (r WidgetUpdateParamsClearanceLevel) IsKnown() bool { } type WidgetUpdateResponseEnvelope struct { - Errors []WidgetUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WidgetUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // A Turnstile widget's detailed configuration - Result ChallengesWidget `json:"result"` + Result Widget `json:"result"` JSON widgetUpdateResponseEnvelopeJSON `json:"-"` } @@ -661,52 +619,6 @@ func (r widgetUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WidgetUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// widgetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WidgetUpdateResponseEnvelopeErrors] -type widgetUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WidgetUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// widgetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WidgetUpdateResponseEnvelopeMessages] -type widgetUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type WidgetListParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -723,7 +635,7 @@ type WidgetListParams struct { // URLQuery serializes [WidgetListParams]'s query parameters as `url.Values`. func (r WidgetListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -769,12 +681,12 @@ type WidgetDeleteParams struct { } type WidgetDeleteResponseEnvelope struct { - Errors []WidgetDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WidgetDeleteResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // A Turnstile widget's detailed configuration - Result ChallengesWidget `json:"result"` + Result Widget `json:"result"` JSON widgetDeleteResponseEnvelopeJSON `json:"-"` } @@ -797,64 +709,18 @@ func (r widgetDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WidgetDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// widgetDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WidgetDeleteResponseEnvelopeErrors] -type widgetDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WidgetDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// widgetDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WidgetDeleteResponseEnvelopeMessages] -type widgetDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type WidgetGetParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` } type WidgetGetResponseEnvelope struct { - Errors []WidgetGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WidgetGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // A Turnstile widget's detailed configuration - Result ChallengesWidget `json:"result"` + Result Widget `json:"result"` JSON widgetGetResponseEnvelopeJSON `json:"-"` } @@ -877,52 +743,6 @@ func (r widgetGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WidgetGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// widgetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WidgetGetResponseEnvelopeErrors] -type widgetGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WidgetGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// widgetGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [WidgetGetResponseEnvelopeMessages] -type widgetGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type WidgetRotateSecretParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -937,12 +757,12 @@ func (r WidgetRotateSecretParams) MarshalJSON() (data []byte, err error) { } type WidgetRotateSecretResponseEnvelope struct { - Errors []WidgetRotateSecretResponseEnvelopeErrors `json:"errors,required"` - Messages []WidgetRotateSecretResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // A Turnstile widget's detailed configuration - Result ChallengesWidget `json:"result"` + Result Widget `json:"result"` JSON widgetRotateSecretResponseEnvelopeJSON `json:"-"` } @@ -964,49 +784,3 @@ func (r *WidgetRotateSecretResponseEnvelope) UnmarshalJSON(data []byte) (err err func (r widgetRotateSecretResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type WidgetRotateSecretResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetRotateSecretResponseEnvelopeErrorsJSON `json:"-"` -} - -// widgetRotateSecretResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WidgetRotateSecretResponseEnvelopeErrors] -type widgetRotateSecretResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetRotateSecretResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetRotateSecretResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WidgetRotateSecretResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON widgetRotateSecretResponseEnvelopeMessagesJSON `json:"-"` -} - -// widgetRotateSecretResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WidgetRotateSecretResponseEnvelopeMessages] -type widgetRotateSecretResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WidgetRotateSecretResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r widgetRotateSecretResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/challenges/widget_test.go b/challenges/widget_test.go index 547baf57da9..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([]string{"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([]string{"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/client_certificates/aliases.go b/client_certificates/aliases.go index 679d35a4b60..00623700f9b 100644 --- a/client_certificates/aliases.go +++ b/client_certificates/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/client_certificates/clientcertificate.go b/client_certificates/clientcertificate.go index f60f6d58ad0..f606f442ab8 100644 --- a/client_certificates/clientcertificate.go +++ b/client_certificates/clientcertificate.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -244,9 +245,9 @@ func (r ClientCertificateNewParams) MarshalJSON() (data []byte, err error) { } type ClientCertificateNewResponseEnvelope struct { - Errors []ClientCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ClientCertificate `json:"result,required"` // Whether the API call was successful Success ClientCertificateNewResponseEnvelopeSuccess `json:"success,required"` JSON clientCertificateNewResponseEnvelopeJSON `json:"-"` @@ -271,52 +272,6 @@ func (r clientCertificateNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ClientCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateNewResponseEnvelopeErrors] -type clientCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ClientCertificateNewResponseEnvelopeMessages] -type clientCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ClientCertificateNewResponseEnvelopeSuccess bool @@ -351,7 +306,7 @@ type ClientCertificateListParams struct { // `url.Values`. func (r ClientCertificateListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -381,9 +336,9 @@ type ClientCertificateDeleteParams struct { } type ClientCertificateDeleteResponseEnvelope struct { - Errors []ClientCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ClientCertificate `json:"result,required"` // Whether the API call was successful Success ClientCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON clientCertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -408,52 +363,6 @@ func (r clientCertificateDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ClientCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateDeleteResponseEnvelopeErrors] -type clientCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ClientCertificateDeleteResponseEnvelopeMessages] -type clientCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ClientCertificateDeleteResponseEnvelopeSuccess bool @@ -475,9 +384,9 @@ type ClientCertificateEditParams struct { } type ClientCertificateEditResponseEnvelope struct { - Errors []ClientCertificateEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateEditResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ClientCertificate `json:"result,required"` // Whether the API call was successful Success ClientCertificateEditResponseEnvelopeSuccess `json:"success,required"` JSON clientCertificateEditResponseEnvelopeJSON `json:"-"` @@ -502,52 +411,6 @@ func (r clientCertificateEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ClientCertificateEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateEditResponseEnvelopeErrors] -type clientCertificateEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ClientCertificateEditResponseEnvelopeMessages] -type clientCertificateEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ClientCertificateEditResponseEnvelopeSuccess bool @@ -569,9 +432,9 @@ type ClientCertificateGetParams struct { } type ClientCertificateGetResponseEnvelope struct { - Errors []ClientCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ClientCertificate `json:"result,required"` // Whether the API call was successful Success ClientCertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON clientCertificateGetResponseEnvelopeJSON `json:"-"` @@ -596,52 +459,6 @@ func (r clientCertificateGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ClientCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateGetResponseEnvelopeErrors] -type clientCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ClientCertificateGetResponseEnvelopeMessages] -type clientCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ClientCertificateGetResponseEnvelopeSuccess bool diff --git a/cloudforce_one/aliases.go b/cloudforce_one/aliases.go index 81426d96e28..0ba61456f06 100644 --- a/cloudforce_one/aliases.go +++ b/cloudforce_one/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/cloudforce_one/request.go b/cloudforce_one/request.go index 05e5e3d91b3..34545b10e2e 100644 --- a/cloudforce_one/request.go +++ b/cloudforce_one/request.go @@ -42,7 +42,7 @@ func NewRequestService(opts ...option.RequestOption) (r *RequestService) { // Creating a request adds the request into the Cloudforce One queue for analysis. // In addition to the content, a short title, type, priority, and releasability // should be provided. If one is not provided a default will be assigned. -func (r *RequestService) New(ctx context.Context, accountIdentifier string, body RequestNewParams, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { +func (r *RequestService) New(ctx context.Context, accountIdentifier string, body RequestNewParams, opts ...option.RequestOption) (res *Item, err error) { opts = append(r.Options[:], opts...) var env RequestNewResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/new", accountIdentifier) @@ -57,7 +57,7 @@ func (r *RequestService) New(ctx context.Context, accountIdentifier string, body // Updating a request alters the request in the Cloudforce One queue. This API may // be used to update any attributes of the request after the initial submission. // Only fields that you choose to update need to be add to the request body -func (r *RequestService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { +func (r *RequestService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestUpdateParams, opts ...option.RequestOption) (res *Item, err error) { opts = append(r.Options[:], opts...) var env RequestUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) @@ -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[CloudforceOneRequestListItem], err error) { +func (r *RequestService) List(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[ListItem], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -88,12 +88,12 @@ 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[CloudforceOneRequestListItem] { +func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[ListItem] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, body, opts...)) } // Delete a Request -func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestDeleteResponse, err error) { +func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RequestDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) @@ -106,7 +106,7 @@ func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, r } // Get Request Priority, Status, and TLP constants -func (r *RequestService) Constants(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestConstants, err error) { +func (r *RequestService) Constants(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RequestConstants, err error) { opts = append(r.Options[:], opts...) var env RequestConstantsResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/constants", accountIdentifier) @@ -119,7 +119,7 @@ func (r *RequestService) Constants(ctx context.Context, accountIdentifier string } // Get a Request -func (r *RequestService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { +func (r *RequestService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *Item, err error) { opts = append(r.Options[:], opts...) var env RequestGetResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) @@ -132,7 +132,7 @@ func (r *RequestService) Get(ctx context.Context, accountIdentifier string, requ } // Get Request Quota -func (r *RequestService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneQuota, err error) { +func (r *RequestService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *Quota, err error) { opts = append(r.Options[:], opts...) var env RequestQuotaResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/quota", accountIdentifier) @@ -145,7 +145,7 @@ func (r *RequestService) Quota(ctx context.Context, accountIdentifier string, op } // Get Request Types -func (r *RequestService) Types(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestTypes, err error) { +func (r *RequestService) Types(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RequestTypes, err error) { opts = append(r.Options[:], opts...) var env RequestTypesResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/types", accountIdentifier) @@ -157,118 +157,7 @@ func (r *RequestService) Types(ctx context.Context, accountIdentifier string, op return } -type CloudforceOneQuota struct { - // Anniversary date is when annual quota limit is refresh - AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` - // Quater anniversary date is when quota limit is refreshed each quarter - QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` - // Tokens for the quarter - Quota int64 `json:"quota"` - // Tokens remaining for the quarter - Remaining int64 `json:"remaining"` - JSON cloudforceOneQuotaJSON `json:"-"` -} - -// cloudforceOneQuotaJSON contains the JSON metadata for the struct -// [CloudforceOneQuota] -type cloudforceOneQuotaJSON struct { - AnniversaryDate apijson.Field - QuarterAnniversaryDate apijson.Field - Quota apijson.Field - Remaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneQuota) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneQuotaJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestConstants struct { - Priority []CloudforceOneRequestConstantsPriority `json:"priority"` - Status []CloudforceOneRequestConstantsStatus `json:"status"` - Tlp []CloudforceOneRequestConstantsTlp `json:"tlp"` - JSON cloudforceOneRequestConstantsJSON `json:"-"` -} - -// cloudforceOneRequestConstantsJSON contains the JSON metadata for the struct -// [CloudforceOneRequestConstants] -type cloudforceOneRequestConstantsJSON struct { - Priority apijson.Field - Status apijson.Field - Tlp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestConstants) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestConstantsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestConstantsPriority string - -const ( - CloudforceOneRequestConstantsPriorityRoutine CloudforceOneRequestConstantsPriority = "routine" - CloudforceOneRequestConstantsPriorityHigh CloudforceOneRequestConstantsPriority = "high" - CloudforceOneRequestConstantsPriorityUrgent CloudforceOneRequestConstantsPriority = "urgent" -) - -func (r CloudforceOneRequestConstantsPriority) IsKnown() bool { - switch r { - case CloudforceOneRequestConstantsPriorityRoutine, CloudforceOneRequestConstantsPriorityHigh, CloudforceOneRequestConstantsPriorityUrgent: - return true - } - return false -} - -// Request Status -type CloudforceOneRequestConstantsStatus string - -const ( - CloudforceOneRequestConstantsStatusOpen CloudforceOneRequestConstantsStatus = "open" - CloudforceOneRequestConstantsStatusAccepted CloudforceOneRequestConstantsStatus = "accepted" - CloudforceOneRequestConstantsStatusReported CloudforceOneRequestConstantsStatus = "reported" - CloudforceOneRequestConstantsStatusApproved CloudforceOneRequestConstantsStatus = "approved" - CloudforceOneRequestConstantsStatusCompleted CloudforceOneRequestConstantsStatus = "completed" - CloudforceOneRequestConstantsStatusDeclined CloudforceOneRequestConstantsStatus = "declined" -) - -func (r CloudforceOneRequestConstantsStatus) IsKnown() bool { - switch r { - case CloudforceOneRequestConstantsStatusOpen, CloudforceOneRequestConstantsStatusAccepted, CloudforceOneRequestConstantsStatusReported, CloudforceOneRequestConstantsStatusApproved, CloudforceOneRequestConstantsStatusCompleted, CloudforceOneRequestConstantsStatusDeclined: - return true - } - return false -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestConstantsTlp string - -const ( - CloudforceOneRequestConstantsTlpClear CloudforceOneRequestConstantsTlp = "clear" - CloudforceOneRequestConstantsTlpAmber CloudforceOneRequestConstantsTlp = "amber" - CloudforceOneRequestConstantsTlpAmberStrict CloudforceOneRequestConstantsTlp = "amber-strict" - CloudforceOneRequestConstantsTlpGreen CloudforceOneRequestConstantsTlp = "green" - CloudforceOneRequestConstantsTlpRed CloudforceOneRequestConstantsTlp = "red" -) - -func (r CloudforceOneRequestConstantsTlp) IsKnown() bool { - switch r { - case CloudforceOneRequestConstantsTlpClear, CloudforceOneRequestConstantsTlpAmber, CloudforceOneRequestConstantsTlpAmberStrict, CloudforceOneRequestConstantsTlpGreen, CloudforceOneRequestConstantsTlpRed: - return true - } - return false -} - -type CloudforceOneRequestItem struct { +type Item struct { // UUID ID string `json:"id,required"` // Request content @@ -280,23 +169,22 @@ type CloudforceOneRequestItem struct { // Brief description of the request Summary string `json:"summary,required"` // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestItemTlp `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` + Tlp ItemTlp `json:"tlp,required"` + Updated time.Time `json:"updated,required" format:"date-time"` + Completed time.Time `json:"completed" format:"date-time"` // Tokens for the request messages MessageTokens int64 `json:"message_tokens"` // Readable Request ID ReadableID string `json:"readable_id"` // Request Status - Status CloudforceOneRequestItemStatus `json:"status"` + Status ItemStatus `json:"status"` // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestItemJSON `json:"-"` + Tokens int64 `json:"tokens"` + JSON itemJSON `json:"-"` } -// cloudforceOneRequestItemJSON contains the JSON metadata for the struct -// [CloudforceOneRequestItem] -type cloudforceOneRequestItemJSON struct { +// itemJSON contains the JSON metadata for the struct [Item] +type itemJSON struct { ID apijson.Field Content apijson.Field Created apijson.Field @@ -314,65 +202,65 @@ type cloudforceOneRequestItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *CloudforceOneRequestItem) UnmarshalJSON(data []byte) (err error) { +func (r *Item) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r cloudforceOneRequestItemJSON) RawJSON() string { +func (r itemJSON) RawJSON() string { return r.raw } // The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestItemTlp string +type ItemTlp string const ( - CloudforceOneRequestItemTlpClear CloudforceOneRequestItemTlp = "clear" - CloudforceOneRequestItemTlpAmber CloudforceOneRequestItemTlp = "amber" - CloudforceOneRequestItemTlpAmberStrict CloudforceOneRequestItemTlp = "amber-strict" - CloudforceOneRequestItemTlpGreen CloudforceOneRequestItemTlp = "green" - CloudforceOneRequestItemTlpRed CloudforceOneRequestItemTlp = "red" + ItemTlpClear ItemTlp = "clear" + ItemTlpAmber ItemTlp = "amber" + ItemTlpAmberStrict ItemTlp = "amber-strict" + ItemTlpGreen ItemTlp = "green" + ItemTlpRed ItemTlp = "red" ) -func (r CloudforceOneRequestItemTlp) IsKnown() bool { +func (r ItemTlp) IsKnown() bool { switch r { - case CloudforceOneRequestItemTlpClear, CloudforceOneRequestItemTlpAmber, CloudforceOneRequestItemTlpAmberStrict, CloudforceOneRequestItemTlpGreen, CloudforceOneRequestItemTlpRed: + case ItemTlpClear, ItemTlpAmber, ItemTlpAmberStrict, ItemTlpGreen, ItemTlpRed: return true } return false } // Request Status -type CloudforceOneRequestItemStatus string +type ItemStatus string const ( - CloudforceOneRequestItemStatusOpen CloudforceOneRequestItemStatus = "open" - CloudforceOneRequestItemStatusAccepted CloudforceOneRequestItemStatus = "accepted" - CloudforceOneRequestItemStatusReported CloudforceOneRequestItemStatus = "reported" - CloudforceOneRequestItemStatusApproved CloudforceOneRequestItemStatus = "approved" - CloudforceOneRequestItemStatusCompleted CloudforceOneRequestItemStatus = "completed" - CloudforceOneRequestItemStatusDeclined CloudforceOneRequestItemStatus = "declined" + ItemStatusOpen ItemStatus = "open" + ItemStatusAccepted ItemStatus = "accepted" + ItemStatusReported ItemStatus = "reported" + ItemStatusApproved ItemStatus = "approved" + ItemStatusCompleted ItemStatus = "completed" + ItemStatusDeclined ItemStatus = "declined" ) -func (r CloudforceOneRequestItemStatus) IsKnown() bool { +func (r ItemStatus) IsKnown() bool { switch r { - case CloudforceOneRequestItemStatusOpen, CloudforceOneRequestItemStatusAccepted, CloudforceOneRequestItemStatusReported, CloudforceOneRequestItemStatusApproved, CloudforceOneRequestItemStatusCompleted, CloudforceOneRequestItemStatusDeclined: + case ItemStatusOpen, ItemStatusAccepted, ItemStatusReported, ItemStatusApproved, ItemStatusCompleted, ItemStatusDeclined: return true } return false } -type CloudforceOneRequestListItem struct { +type ListItem struct { // UUID ID string `json:"id,required"` // Request creation time - Created time.Time `json:"created,required" format:"date-time"` - Priority CloudforceOneRequestListItemPriority `json:"priority,required"` + Created time.Time `json:"created,required" format:"date-time"` + Priority ListItemPriority `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 CloudforceOneRequestListItemTlp `json:"tlp,required"` + Tlp ListItemTlp `json:"tlp,required"` // Request last updated time Updated time.Time `json:"updated,required" format:"date-time"` // Request completion time @@ -382,15 +270,14 @@ type CloudforceOneRequestListItem struct { // Readable Request ID ReadableID string `json:"readable_id"` // Request Status - Status CloudforceOneRequestListItemStatus `json:"status"` + Status ListItemStatus `json:"status"` // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestListItemJSON `json:"-"` + Tokens int64 `json:"tokens"` + JSON listItemJSON `json:"-"` } -// cloudforceOneRequestListItemJSON contains the JSON metadata for the struct -// [CloudforceOneRequestListItem] -type cloudforceOneRequestListItemJSON struct { +// listItemJSON contains the JSON metadata for the struct [ListItem] +type listItemJSON struct { ID apijson.Field Created apijson.Field Priority apijson.Field @@ -407,80 +294,190 @@ type cloudforceOneRequestListItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *CloudforceOneRequestListItem) UnmarshalJSON(data []byte) (err error) { +func (r *ListItem) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r cloudforceOneRequestListItemJSON) RawJSON() string { +func (r listItemJSON) RawJSON() string { return r.raw } -type CloudforceOneRequestListItemPriority string +type ListItemPriority string const ( - CloudforceOneRequestListItemPriorityRoutine CloudforceOneRequestListItemPriority = "routine" - CloudforceOneRequestListItemPriorityHigh CloudforceOneRequestListItemPriority = "high" - CloudforceOneRequestListItemPriorityUrgent CloudforceOneRequestListItemPriority = "urgent" + ListItemPriorityRoutine ListItemPriority = "routine" + ListItemPriorityHigh ListItemPriority = "high" + ListItemPriorityUrgent ListItemPriority = "urgent" ) -func (r CloudforceOneRequestListItemPriority) IsKnown() bool { +func (r ListItemPriority) IsKnown() bool { switch r { - case CloudforceOneRequestListItemPriorityRoutine, CloudforceOneRequestListItemPriorityHigh, CloudforceOneRequestListItemPriorityUrgent: + case ListItemPriorityRoutine, ListItemPriorityHigh, ListItemPriorityUrgent: return true } return false } // The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestListItemTlp string +type ListItemTlp string const ( - CloudforceOneRequestListItemTlpClear CloudforceOneRequestListItemTlp = "clear" - CloudforceOneRequestListItemTlpAmber CloudforceOneRequestListItemTlp = "amber" - CloudforceOneRequestListItemTlpAmberStrict CloudforceOneRequestListItemTlp = "amber-strict" - CloudforceOneRequestListItemTlpGreen CloudforceOneRequestListItemTlp = "green" - CloudforceOneRequestListItemTlpRed CloudforceOneRequestListItemTlp = "red" + ListItemTlpClear ListItemTlp = "clear" + ListItemTlpAmber ListItemTlp = "amber" + ListItemTlpAmberStrict ListItemTlp = "amber-strict" + ListItemTlpGreen ListItemTlp = "green" + ListItemTlpRed ListItemTlp = "red" ) -func (r CloudforceOneRequestListItemTlp) IsKnown() bool { +func (r ListItemTlp) IsKnown() bool { switch r { - case CloudforceOneRequestListItemTlpClear, CloudforceOneRequestListItemTlpAmber, CloudforceOneRequestListItemTlpAmberStrict, CloudforceOneRequestListItemTlpGreen, CloudforceOneRequestListItemTlpRed: + case ListItemTlpClear, ListItemTlpAmber, ListItemTlpAmberStrict, ListItemTlpGreen, ListItemTlpRed: return true } return false } // Request Status -type CloudforceOneRequestListItemStatus string +type ListItemStatus string const ( - CloudforceOneRequestListItemStatusOpen CloudforceOneRequestListItemStatus = "open" - CloudforceOneRequestListItemStatusAccepted CloudforceOneRequestListItemStatus = "accepted" - CloudforceOneRequestListItemStatusReported CloudforceOneRequestListItemStatus = "reported" - CloudforceOneRequestListItemStatusApproved CloudforceOneRequestListItemStatus = "approved" - CloudforceOneRequestListItemStatusCompleted CloudforceOneRequestListItemStatus = "completed" - CloudforceOneRequestListItemStatusDeclined CloudforceOneRequestListItemStatus = "declined" + ListItemStatusOpen ListItemStatus = "open" + ListItemStatusAccepted ListItemStatus = "accepted" + ListItemStatusReported ListItemStatus = "reported" + ListItemStatusApproved ListItemStatus = "approved" + ListItemStatusCompleted ListItemStatus = "completed" + ListItemStatusDeclined ListItemStatus = "declined" ) -func (r CloudforceOneRequestListItemStatus) IsKnown() bool { +func (r ListItemStatus) IsKnown() bool { switch r { - case CloudforceOneRequestListItemStatusOpen, CloudforceOneRequestListItemStatusAccepted, CloudforceOneRequestListItemStatusReported, CloudforceOneRequestListItemStatusApproved, CloudforceOneRequestListItemStatusCompleted, CloudforceOneRequestListItemStatusDeclined: + case ListItemStatusOpen, ListItemStatusAccepted, ListItemStatusReported, ListItemStatusApproved, ListItemStatusCompleted, ListItemStatusDeclined: return true } return false } -type CloudforceOneRequestTypes []string +type Quota struct { + // Anniversary date is when annual quota limit is refresh + AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` + // Quater anniversary date is when quota limit is refreshed each quarter + QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` + // Tokens for the quarter + Quota int64 `json:"quota"` + // Tokens remaining for the quarter + Remaining int64 `json:"remaining"` + JSON quotaJSON `json:"-"` +} + +// quotaJSON contains the JSON metadata for the struct [Quota] +type quotaJSON struct { + AnniversaryDate apijson.Field + QuarterAnniversaryDate apijson.Field + Quota apijson.Field + Remaining apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Quota) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r quotaJSON) RawJSON() string { + return r.raw +} + +type RequestConstants struct { + Priority []RequestConstantsPriority `json:"priority"` + Status []RequestConstantsStatus `json:"status"` + Tlp []RequestConstantsTlp `json:"tlp"` + JSON requestConstantsJSON `json:"-"` +} + +// requestConstantsJSON contains the JSON metadata for the struct +// [RequestConstants] +type requestConstantsJSON struct { + Priority apijson.Field + Status apijson.Field + Tlp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestConstants) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestConstantsJSON) RawJSON() string { + return r.raw +} + +type RequestConstantsPriority string + +const ( + RequestConstantsPriorityRoutine RequestConstantsPriority = "routine" + RequestConstantsPriorityHigh RequestConstantsPriority = "high" + RequestConstantsPriorityUrgent RequestConstantsPriority = "urgent" +) + +func (r RequestConstantsPriority) IsKnown() bool { + switch r { + case RequestConstantsPriorityRoutine, RequestConstantsPriorityHigh, RequestConstantsPriorityUrgent: + return true + } + return false +} + +// Request Status +type RequestConstantsStatus string + +const ( + RequestConstantsStatusOpen RequestConstantsStatus = "open" + RequestConstantsStatusAccepted RequestConstantsStatus = "accepted" + RequestConstantsStatusReported RequestConstantsStatus = "reported" + RequestConstantsStatusApproved RequestConstantsStatus = "approved" + RequestConstantsStatusCompleted RequestConstantsStatus = "completed" + RequestConstantsStatusDeclined RequestConstantsStatus = "declined" +) + +func (r RequestConstantsStatus) IsKnown() bool { + switch r { + case RequestConstantsStatusOpen, RequestConstantsStatusAccepted, RequestConstantsStatusReported, RequestConstantsStatusApproved, RequestConstantsStatusCompleted, RequestConstantsStatusDeclined: + return true + } + return false +} + +// The CISA defined Traffic Light Protocol (TLP) +type RequestConstantsTlp string + +const ( + RequestConstantsTlpClear RequestConstantsTlp = "clear" + RequestConstantsTlpAmber RequestConstantsTlp = "amber" + RequestConstantsTlpAmberStrict RequestConstantsTlp = "amber-strict" + RequestConstantsTlpGreen RequestConstantsTlp = "green" + RequestConstantsTlpRed RequestConstantsTlp = "red" +) + +func (r RequestConstantsTlp) IsKnown() bool { + switch r { + case RequestConstantsTlpClear, RequestConstantsTlpAmber, RequestConstantsTlpAmberStrict, RequestConstantsTlpGreen, RequestConstantsTlpRed: + return true + } + return false +} + +type RequestTypes []string // Union satisfied by [cloudforce_one.RequestDeleteResponseUnknown], // [cloudforce_one.RequestDeleteResponseArray] or [shared.UnionString]. -type RequestDeleteResponse interface { - ImplementsCloudforceOneRequestDeleteResponse() +type RequestDeleteResponseUnion interface { + ImplementsCloudforceOneRequestDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RequestDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*RequestDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -495,7 +492,7 @@ func init() { type RequestDeleteResponseArray []interface{} -func (r RequestDeleteResponseArray) ImplementsCloudforceOneRequestDeleteResponse() {} +func (r RequestDeleteResponseArray) ImplementsCloudforceOneRequestDeleteResponseUnion() {} type RequestNewParams struct { // Request content @@ -534,9 +531,9 @@ func (r RequestNewParamsTlp) IsKnown() bool { } type RequestNewResponseEnvelope struct { - Errors []RequestNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestNewResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestNewResponseEnvelopeSuccess `json:"success,required"` JSON requestNewResponseEnvelopeJSON `json:"-"` @@ -561,52 +558,6 @@ func (r requestNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RequestNewResponseEnvelopeErrors] -type requestNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RequestNewResponseEnvelopeMessages] -type requestNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestNewResponseEnvelopeSuccess bool @@ -659,9 +610,9 @@ func (r RequestUpdateParamsTlp) IsKnown() bool { } type RequestUpdateResponseEnvelope struct { - Errors []RequestUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestUpdateResponseEnvelopeSuccess `json:"success,required"` JSON requestUpdateResponseEnvelopeJSON `json:"-"` @@ -686,52 +637,6 @@ func (r requestUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RequestUpdateResponseEnvelopeErrors] -type requestUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RequestUpdateResponseEnvelopeMessages] -type requestUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestUpdateResponseEnvelopeSuccess bool @@ -811,9 +716,9 @@ func (r RequestListParamsStatus) IsKnown() bool { } type RequestDeleteResponseEnvelope struct { - Errors []RequestDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestDeleteResponseEnvelopeMessages `json:"messages,required"` - Result RequestDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success RequestDeleteResponseEnvelopeSuccess `json:"success,required"` JSON requestDeleteResponseEnvelopeJSON `json:"-"` @@ -838,52 +743,6 @@ func (r requestDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RequestDeleteResponseEnvelopeErrors] -type requestDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RequestDeleteResponseEnvelopeMessages] -type requestDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestDeleteResponseEnvelopeSuccess bool @@ -900,9 +759,9 @@ func (r RequestDeleteResponseEnvelopeSuccess) IsKnown() bool { } type RequestConstantsResponseEnvelope struct { - Errors []RequestConstantsResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestConstantsResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestConstants `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestConstants `json:"result,required"` // Whether the API call was successful Success RequestConstantsResponseEnvelopeSuccess `json:"success,required"` JSON requestConstantsResponseEnvelopeJSON `json:"-"` @@ -927,52 +786,6 @@ func (r requestConstantsResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestConstantsResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestConstantsResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestConstantsResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RequestConstantsResponseEnvelopeErrors] -type requestConstantsResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestConstantsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestConstantsResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestConstantsResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestConstantsResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestConstantsResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RequestConstantsResponseEnvelopeMessages] -type requestConstantsResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestConstantsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestConstantsResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestConstantsResponseEnvelopeSuccess bool @@ -989,9 +802,9 @@ func (r RequestConstantsResponseEnvelopeSuccess) IsKnown() bool { } type RequestGetResponseEnvelope struct { - Errors []RequestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestGetResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestGetResponseEnvelopeSuccess `json:"success,required"` JSON requestGetResponseEnvelopeJSON `json:"-"` @@ -1016,52 +829,6 @@ func (r requestGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RequestGetResponseEnvelopeErrors] -type requestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RequestGetResponseEnvelopeMessages] -type requestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestGetResponseEnvelopeSuccess bool @@ -1078,9 +845,9 @@ func (r RequestGetResponseEnvelopeSuccess) IsKnown() bool { } type RequestQuotaResponseEnvelope struct { - Errors []RequestQuotaResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestQuotaResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneQuota `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Quota `json:"result,required"` // Whether the API call was successful Success RequestQuotaResponseEnvelopeSuccess `json:"success,required"` JSON requestQuotaResponseEnvelopeJSON `json:"-"` @@ -1105,52 +872,6 @@ func (r requestQuotaResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestQuotaResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestQuotaResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestQuotaResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RequestQuotaResponseEnvelopeErrors] -type requestQuotaResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestQuotaResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestQuotaResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestQuotaResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestQuotaResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestQuotaResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RequestQuotaResponseEnvelopeMessages] -type requestQuotaResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestQuotaResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestQuotaResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestQuotaResponseEnvelopeSuccess bool @@ -1167,9 +888,9 @@ func (r RequestQuotaResponseEnvelopeSuccess) IsKnown() bool { } type RequestTypesResponseEnvelope struct { - Errors []RequestTypesResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestTypesResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestTypes `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestTypes `json:"result,required"` // Whether the API call was successful Success RequestTypesResponseEnvelopeSuccess `json:"success,required"` JSON requestTypesResponseEnvelopeJSON `json:"-"` @@ -1194,52 +915,6 @@ func (r requestTypesResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestTypesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestTypesResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestTypesResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RequestTypesResponseEnvelopeErrors] -type requestTypesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestTypesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestTypesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestTypesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestTypesResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestTypesResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RequestTypesResponseEnvelopeMessages] -type requestTypesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestTypesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestTypesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestTypesResponseEnvelopeSuccess bool diff --git a/cloudforce_one/requestmessage.go b/cloudforce_one/requestmessage.go index 73b0e8faa1d..1d1fd458289 100644 --- a/cloudforce_one/requestmessage.go +++ b/cloudforce_one/requestmessage.go @@ -38,7 +38,7 @@ func NewRequestMessageService(opts ...option.RequestOption) (r *RequestMessageSe // Creating a request adds the request into the Cloudforce One queue for analysis. // In addition to the content, a short title, type, priority, and releasability // should be provided. If one is not provided a default will be assigned. -func (r *RequestMessageService) New(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageNewParams, opts ...option.RequestOption) (res *CloudforceOneRequestMessageItem, err error) { +func (r *RequestMessageService) New(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageNewParams, opts ...option.RequestOption) (res *Message, err error) { opts = append(r.Options[:], opts...) var env RequestMessageNewResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/new", accountIdentifier, requestIdentifier) @@ -51,7 +51,7 @@ func (r *RequestMessageService) New(ctx context.Context, accountIdentifier strin } // Update a Request Message -func (r *RequestMessageService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body RequestMessageUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestMessageItem, err error) { +func (r *RequestMessageService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body RequestMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) { opts = append(r.Options[:], opts...) var env RequestMessageUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/%v", accountIdentifier, requestIdentifier, messageIdentifer) @@ -64,7 +64,7 @@ func (r *RequestMessageService) Update(ctx context.Context, accountIdentifier st } // Delete a Request Message -func (r *RequestMessageService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, opts ...option.RequestOption) (res *RequestMessageDeleteResponse, err error) { +func (r *RequestMessageService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, opts ...option.RequestOption) (res *RequestMessageDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RequestMessageDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/%v", accountIdentifier, requestIdentifier, messageIdentifer) @@ -77,7 +77,7 @@ func (r *RequestMessageService) Delete(ctx context.Context, accountIdentifier st } // List Request Messages -func (r *RequestMessageService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageGetParams, opts ...option.RequestOption) (res *[]CloudforceOneRequestMessageItem, err error) { +func (r *RequestMessageService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageGetParams, opts ...option.RequestOption) (res *[]Message, err error) { opts = append(r.Options[:], opts...) var env RequestMessageGetResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message", accountIdentifier, requestIdentifier) @@ -89,7 +89,7 @@ func (r *RequestMessageService) Get(ctx context.Context, accountIdentifier strin return } -type CloudforceOneRequestMessageItem struct { +type Message struct { // Message ID ID int64 `json:"id,required"` // Author of message @@ -101,13 +101,12 @@ type CloudforceOneRequestMessageItem struct { // Message last updated time Updated time.Time `json:"updated,required" format:"date-time"` // Message creation time - Created time.Time `json:"created" format:"date-time"` - JSON cloudforceOneRequestMessageItemJSON `json:"-"` + Created time.Time `json:"created" format:"date-time"` + JSON messageJSON `json:"-"` } -// cloudforceOneRequestMessageItemJSON contains the JSON metadata for the struct -// [CloudforceOneRequestMessageItem] -type cloudforceOneRequestMessageItemJSON struct { +// messageJSON contains the JSON metadata for the struct [Message] +type messageJSON struct { ID apijson.Field Author apijson.Field Content apijson.Field @@ -118,23 +117,23 @@ type cloudforceOneRequestMessageItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *CloudforceOneRequestMessageItem) UnmarshalJSON(data []byte) (err error) { +func (r *Message) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r cloudforceOneRequestMessageItemJSON) RawJSON() string { +func (r messageJSON) RawJSON() string { return r.raw } // Union satisfied by [cloudforce_one.RequestMessageDeleteResponseUnknown], // [cloudforce_one.RequestMessageDeleteResponseArray] or [shared.UnionString]. -type RequestMessageDeleteResponse interface { - ImplementsCloudforceOneRequestMessageDeleteResponse() +type RequestMessageDeleteResponseUnion interface { + ImplementsCloudforceOneRequestMessageDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RequestMessageDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*RequestMessageDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -149,7 +148,8 @@ func init() { type RequestMessageDeleteResponseArray []interface{} -func (r RequestMessageDeleteResponseArray) ImplementsCloudforceOneRequestMessageDeleteResponse() {} +func (r RequestMessageDeleteResponseArray) ImplementsCloudforceOneRequestMessageDeleteResponseUnion() { +} type RequestMessageNewParams struct { // Content of message @@ -161,9 +161,9 @@ func (r RequestMessageNewParams) MarshalJSON() (data []byte, err error) { } type RequestMessageNewResponseEnvelope struct { - Errors []RequestMessageNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestMessageNewResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestMessageItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Message `json:"result,required"` // Whether the API call was successful Success RequestMessageNewResponseEnvelopeSuccess `json:"success,required"` JSON requestMessageNewResponseEnvelopeJSON `json:"-"` @@ -188,52 +188,6 @@ func (r requestMessageNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestMessageNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestMessageNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RequestMessageNewResponseEnvelopeErrors] -type requestMessageNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestMessageNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestMessageNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RequestMessageNewResponseEnvelopeMessages] -type requestMessageNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestMessageNewResponseEnvelopeSuccess bool @@ -286,9 +240,9 @@ func (r RequestMessageUpdateParamsTlp) IsKnown() bool { } type RequestMessageUpdateResponseEnvelope struct { - Errors []RequestMessageUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestMessageUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestMessageItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Message `json:"result,required"` // Whether the API call was successful Success RequestMessageUpdateResponseEnvelopeSuccess `json:"success,required"` JSON requestMessageUpdateResponseEnvelopeJSON `json:"-"` @@ -313,52 +267,6 @@ func (r requestMessageUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestMessageUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestMessageUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RequestMessageUpdateResponseEnvelopeErrors] -type requestMessageUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestMessageUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestMessageUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestMessageUpdateResponseEnvelopeMessages] -type requestMessageUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestMessageUpdateResponseEnvelopeSuccess bool @@ -375,9 +283,9 @@ func (r RequestMessageUpdateResponseEnvelopeSuccess) IsKnown() bool { } type RequestMessageDeleteResponseEnvelope struct { - Errors []RequestMessageDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestMessageDeleteResponseEnvelopeMessages `json:"messages,required"` - Result RequestMessageDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestMessageDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success RequestMessageDeleteResponseEnvelopeSuccess `json:"success,required"` JSON requestMessageDeleteResponseEnvelopeJSON `json:"-"` @@ -402,52 +310,6 @@ func (r requestMessageDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestMessageDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestMessageDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RequestMessageDeleteResponseEnvelopeErrors] -type requestMessageDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestMessageDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestMessageDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestMessageDeleteResponseEnvelopeMessages] -type requestMessageDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestMessageDeleteResponseEnvelopeSuccess bool @@ -499,9 +361,9 @@ func (r RequestMessageGetParamsSortOrder) IsKnown() bool { } type RequestMessageGetResponseEnvelope struct { - Errors []RequestMessageGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestMessageGetResponseEnvelopeMessages `json:"messages,required"` - Result []CloudforceOneRequestMessageItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Message `json:"result,required"` // Whether the API call was successful Success RequestMessageGetResponseEnvelopeSuccess `json:"success,required"` JSON requestMessageGetResponseEnvelopeJSON `json:"-"` @@ -526,52 +388,6 @@ func (r requestMessageGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestMessageGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestMessageGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RequestMessageGetResponseEnvelopeErrors] -type requestMessageGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestMessageGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestMessageGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestMessageGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RequestMessageGetResponseEnvelopeMessages] -type requestMessageGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestMessageGetResponseEnvelopeSuccess bool diff --git a/cloudforce_one/requestpriority.go b/cloudforce_one/requestpriority.go index 5ec6277069d..c11633c7654 100644 --- a/cloudforce_one/requestpriority.go +++ b/cloudforce_one/requestpriority.go @@ -36,7 +36,7 @@ func NewRequestPriorityService(opts ...option.RequestOption) (r *RequestPriority } // Create a New Priority Requirement -func (r *RequestPriorityService) New(ctx context.Context, accountIdentifier string, body RequestPriorityNewParams, opts ...option.RequestOption) (res *CloudforceOnePriorityItem, err error) { +func (r *RequestPriorityService) New(ctx context.Context, accountIdentifier string, body RequestPriorityNewParams, opts ...option.RequestOption) (res *Priority, err error) { opts = append(r.Options[:], opts...) var env RequestPriorityNewResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/new", accountIdentifier) @@ -49,7 +49,7 @@ func (r *RequestPriorityService) New(ctx context.Context, accountIdentifier stri } // Update a Priority Intelligence Requirement -func (r *RequestPriorityService) Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body RequestPriorityUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { +func (r *RequestPriorityService) Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body RequestPriorityUpdateParams, opts ...option.RequestOption) (res *Item, err error) { opts = append(r.Options[:], opts...) var env RequestPriorityUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) @@ -62,7 +62,7 @@ func (r *RequestPriorityService) Update(ctx context.Context, accountIdentifier s } // Delete a Priority Intelligence Report -func (r *RequestPriorityService) Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *RequestPriorityDeleteResponse, err error) { +func (r *RequestPriorityService) Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *RequestPriorityDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RequestPriorityDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) @@ -75,7 +75,7 @@ func (r *RequestPriorityService) Delete(ctx context.Context, accountIdentifier s } // Get a Priority Intelligence Requirement -func (r *RequestPriorityService) Get(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { +func (r *RequestPriorityService) Get(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *Item, err error) { opts = append(r.Options[:], opts...) var env RequestPriorityGetResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) @@ -88,7 +88,7 @@ func (r *RequestPriorityService) Get(ctx context.Context, accountIdentifier stri } // Get Priority Intelligence Requirement Quota -func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneQuota, err error) { +func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *Quota, err error) { opts = append(r.Options[:], opts...) var env RequestPriorityQuotaResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/quota", accountIdentifier) @@ -100,27 +100,30 @@ func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier st return } -type CloudforceOnePriorityItem struct { +type Label = string + +type LabelParam = string + +type Priority struct { // UUID ID string `json:"id,required"` // Priority creation time Created time.Time `json:"created,required" format:"date-time"` // List of labels - Labels []string `json:"labels,required"` + Labels []Label `json:"labels,required"` // Priority Priority int64 `json:"priority,required"` // Requirement Requirement string `json:"requirement,required"` // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOnePriorityItemTlp `json:"tlp,required"` + Tlp PriorityTlp `json:"tlp,required"` // Priority last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - JSON cloudforceOnePriorityItemJSON `json:"-"` + Updated time.Time `json:"updated,required" format:"date-time"` + JSON priorityJSON `json:"-"` } -// cloudforceOnePriorityItemJSON contains the JSON metadata for the struct -// [CloudforceOnePriorityItem] -type cloudforceOnePriorityItemJSON struct { +// priorityJSON contains the JSON metadata for the struct [Priority] +type priorityJSON struct { ID apijson.Field Created apijson.Field Labels apijson.Field @@ -132,28 +135,62 @@ type cloudforceOnePriorityItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *CloudforceOnePriorityItem) UnmarshalJSON(data []byte) (err error) { +func (r *Priority) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r cloudforceOnePriorityItemJSON) RawJSON() string { +func (r priorityJSON) RawJSON() string { return r.raw } // The CISA defined Traffic Light Protocol (TLP) -type CloudforceOnePriorityItemTlp string +type PriorityTlp string + +const ( + PriorityTlpClear PriorityTlp = "clear" + PriorityTlpAmber PriorityTlp = "amber" + PriorityTlpAmberStrict PriorityTlp = "amber-strict" + PriorityTlpGreen PriorityTlp = "green" + PriorityTlpRed PriorityTlp = "red" +) + +func (r PriorityTlp) IsKnown() bool { + switch r { + case PriorityTlpClear, PriorityTlpAmber, PriorityTlpAmberStrict, PriorityTlpGreen, PriorityTlpRed: + return true + } + return false +} + +type PriorityEditParam struct { + // List of labels + Labels param.Field[[]LabelParam] `json:"labels,required"` + // Priority + Priority param.Field[int64] `json:"priority,required"` + // Requirement + Requirement param.Field[string] `json:"requirement,required"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp param.Field[PriorityEditTlp] `json:"tlp,required"` +} + +func (r PriorityEditParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The CISA defined Traffic Light Protocol (TLP) +type PriorityEditTlp string const ( - CloudforceOnePriorityItemTlpClear CloudforceOnePriorityItemTlp = "clear" - CloudforceOnePriorityItemTlpAmber CloudforceOnePriorityItemTlp = "amber" - CloudforceOnePriorityItemTlpAmberStrict CloudforceOnePriorityItemTlp = "amber-strict" - CloudforceOnePriorityItemTlpGreen CloudforceOnePriorityItemTlp = "green" - CloudforceOnePriorityItemTlpRed CloudforceOnePriorityItemTlp = "red" + PriorityEditTlpClear PriorityEditTlp = "clear" + PriorityEditTlpAmber PriorityEditTlp = "amber" + PriorityEditTlpAmberStrict PriorityEditTlp = "amber-strict" + PriorityEditTlpGreen PriorityEditTlp = "green" + PriorityEditTlpRed PriorityEditTlp = "red" ) -func (r CloudforceOnePriorityItemTlp) IsKnown() bool { +func (r PriorityEditTlp) IsKnown() bool { switch r { - case CloudforceOnePriorityItemTlpClear, CloudforceOnePriorityItemTlpAmber, CloudforceOnePriorityItemTlpAmberStrict, CloudforceOnePriorityItemTlpGreen, CloudforceOnePriorityItemTlpRed: + case PriorityEditTlpClear, PriorityEditTlpAmber, PriorityEditTlpAmberStrict, PriorityEditTlpGreen, PriorityEditTlpRed: return true } return false @@ -161,13 +198,13 @@ func (r CloudforceOnePriorityItemTlp) IsKnown() bool { // Union satisfied by [cloudforce_one.RequestPriorityDeleteResponseUnknown], // [cloudforce_one.RequestPriorityDeleteResponseArray] or [shared.UnionString]. -type RequestPriorityDeleteResponse interface { - ImplementsCloudforceOneRequestPriorityDeleteResponse() +type RequestPriorityDeleteResponseUnion interface { + ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RequestPriorityDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*RequestPriorityDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -182,46 +219,21 @@ func init() { type RequestPriorityDeleteResponseArray []interface{} -func (r RequestPriorityDeleteResponseArray) ImplementsCloudforceOneRequestPriorityDeleteResponse() {} +func (r RequestPriorityDeleteResponseArray) ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() { +} type RequestPriorityNewParams struct { - // List of labels - Labels param.Field[[]string] `json:"labels,required"` - // Priority - Priority param.Field[int64] `json:"priority,required"` - // Requirement - Requirement param.Field[string] `json:"requirement,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp param.Field[RequestPriorityNewParamsTlp] `json:"tlp,required"` + PriorityEdit PriorityEditParam `json:"priority_edit,required"` } func (r RequestPriorityNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type RequestPriorityNewParamsTlp string - -const ( - RequestPriorityNewParamsTlpClear RequestPriorityNewParamsTlp = "clear" - RequestPriorityNewParamsTlpAmber RequestPriorityNewParamsTlp = "amber" - RequestPriorityNewParamsTlpAmberStrict RequestPriorityNewParamsTlp = "amber-strict" - RequestPriorityNewParamsTlpGreen RequestPriorityNewParamsTlp = "green" - RequestPriorityNewParamsTlpRed RequestPriorityNewParamsTlp = "red" -) - -func (r RequestPriorityNewParamsTlp) IsKnown() bool { - switch r { - case RequestPriorityNewParamsTlpClear, RequestPriorityNewParamsTlpAmber, RequestPriorityNewParamsTlpAmberStrict, RequestPriorityNewParamsTlpGreen, RequestPriorityNewParamsTlpRed: - return true - } - return false + return apijson.MarshalRoot(r.PriorityEdit) } type RequestPriorityNewResponseEnvelope struct { - Errors []RequestPriorityNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestPriorityNewResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOnePriorityItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Priority `json:"result,required"` // Whether the API call was successful Success RequestPriorityNewResponseEnvelopeSuccess `json:"success,required"` JSON requestPriorityNewResponseEnvelopeJSON `json:"-"` @@ -246,52 +258,6 @@ func (r requestPriorityNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestPriorityNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestPriorityNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RequestPriorityNewResponseEnvelopeErrors] -type requestPriorityNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestPriorityNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestPriorityNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestPriorityNewResponseEnvelopeMessages] -type requestPriorityNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestPriorityNewResponseEnvelopeSuccess bool @@ -308,43 +274,17 @@ func (r RequestPriorityNewResponseEnvelopeSuccess) IsKnown() bool { } type RequestPriorityUpdateParams struct { - // List of labels - Labels param.Field[[]string] `json:"labels,required"` - // Priority - Priority param.Field[int64] `json:"priority,required"` - // Requirement - Requirement param.Field[string] `json:"requirement,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp param.Field[RequestPriorityUpdateParamsTlp] `json:"tlp,required"` + PriorityEdit PriorityEditParam `json:"priority_edit,required"` } func (r RequestPriorityUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type RequestPriorityUpdateParamsTlp string - -const ( - RequestPriorityUpdateParamsTlpClear RequestPriorityUpdateParamsTlp = "clear" - RequestPriorityUpdateParamsTlpAmber RequestPriorityUpdateParamsTlp = "amber" - RequestPriorityUpdateParamsTlpAmberStrict RequestPriorityUpdateParamsTlp = "amber-strict" - RequestPriorityUpdateParamsTlpGreen RequestPriorityUpdateParamsTlp = "green" - RequestPriorityUpdateParamsTlpRed RequestPriorityUpdateParamsTlp = "red" -) - -func (r RequestPriorityUpdateParamsTlp) IsKnown() bool { - switch r { - case RequestPriorityUpdateParamsTlpClear, RequestPriorityUpdateParamsTlpAmber, RequestPriorityUpdateParamsTlpAmberStrict, RequestPriorityUpdateParamsTlpGreen, RequestPriorityUpdateParamsTlpRed: - return true - } - return false + return apijson.MarshalRoot(r.PriorityEdit) } type RequestPriorityUpdateResponseEnvelope struct { - Errors []RequestPriorityUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestPriorityUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestPriorityUpdateResponseEnvelopeSuccess `json:"success,required"` JSON requestPriorityUpdateResponseEnvelopeJSON `json:"-"` @@ -369,52 +309,6 @@ func (r requestPriorityUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestPriorityUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestPriorityUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RequestPriorityUpdateResponseEnvelopeErrors] -type requestPriorityUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestPriorityUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestPriorityUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestPriorityUpdateResponseEnvelopeMessages] -type requestPriorityUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestPriorityUpdateResponseEnvelopeSuccess bool @@ -431,9 +325,9 @@ func (r RequestPriorityUpdateResponseEnvelopeSuccess) IsKnown() bool { } type RequestPriorityDeleteResponseEnvelope struct { - Errors []RequestPriorityDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestPriorityDeleteResponseEnvelopeMessages `json:"messages,required"` - Result RequestPriorityDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestPriorityDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success RequestPriorityDeleteResponseEnvelopeSuccess `json:"success,required"` JSON requestPriorityDeleteResponseEnvelopeJSON `json:"-"` @@ -458,52 +352,6 @@ func (r requestPriorityDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestPriorityDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestPriorityDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RequestPriorityDeleteResponseEnvelopeErrors] -type requestPriorityDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestPriorityDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestPriorityDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestPriorityDeleteResponseEnvelopeMessages] -type requestPriorityDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestPriorityDeleteResponseEnvelopeSuccess bool @@ -520,9 +368,9 @@ func (r RequestPriorityDeleteResponseEnvelopeSuccess) IsKnown() bool { } type RequestPriorityGetResponseEnvelope struct { - Errors []RequestPriorityGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestPriorityGetResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestItem `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestPriorityGetResponseEnvelopeSuccess `json:"success,required"` JSON requestPriorityGetResponseEnvelopeJSON `json:"-"` @@ -547,52 +395,6 @@ func (r requestPriorityGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestPriorityGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestPriorityGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RequestPriorityGetResponseEnvelopeErrors] -type requestPriorityGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestPriorityGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestPriorityGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestPriorityGetResponseEnvelopeMessages] -type requestPriorityGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestPriorityGetResponseEnvelopeSuccess bool @@ -609,9 +411,9 @@ func (r RequestPriorityGetResponseEnvelopeSuccess) IsKnown() bool { } type RequestPriorityQuotaResponseEnvelope struct { - Errors []RequestPriorityQuotaResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestPriorityQuotaResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneQuota `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Quota `json:"result,required"` // Whether the API call was successful Success RequestPriorityQuotaResponseEnvelopeSuccess `json:"success,required"` JSON requestPriorityQuotaResponseEnvelopeJSON `json:"-"` @@ -636,52 +438,6 @@ func (r requestPriorityQuotaResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RequestPriorityQuotaResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityQuotaResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestPriorityQuotaResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RequestPriorityQuotaResponseEnvelopeErrors] -type requestPriorityQuotaResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityQuotaResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityQuotaResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestPriorityQuotaResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestPriorityQuotaResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestPriorityQuotaResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestPriorityQuotaResponseEnvelopeMessages] -type requestPriorityQuotaResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityQuotaResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityQuotaResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RequestPriorityQuotaResponseEnvelopeSuccess bool diff --git a/cloudforce_one/requestpriority_test.go b/cloudforce_one/requestpriority_test.go index f406e2986b7..4888c2d1deb 100644 --- a/cloudforce_one/requestpriority_test.go +++ b/cloudforce_one/requestpriority_test.go @@ -32,10 +32,12 @@ func TestRequestPriorityNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", cloudforce_one.RequestPriorityNewParams{ - Labels: cloudflare.F([]string{"DoS", "CVE"}), - Priority: cloudflare.F(int64(1)), - Requirement: cloudflare.F("DoS attacks carried out by CVEs"), - Tlp: cloudflare.F(cloudforce_one.RequestPriorityNewParamsTlpClear), + PriorityEdit: cloudforce_one.PriorityEditParam{ + 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.PriorityEditTlpClear), + }, }, ) if err != nil { @@ -66,10 +68,12 @@ func TestRequestPriorityUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", cloudforce_one.RequestPriorityUpdateParams{ - Labels: cloudflare.F([]string{"DoS", "CVE"}), - Priority: cloudflare.F(int64(1)), - Requirement: cloudflare.F("DoS attacks carried out by CVEs"), - Tlp: cloudflare.F(cloudforce_one.RequestPriorityUpdateParamsTlpClear), + PriorityEdit: cloudforce_one.PriorityEditParam{ + 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.PriorityEditTlpClear), + }, }, ) if err != nil { diff --git a/custom_certificates/aliases.go b/custom_certificates/aliases.go index 38a1ed0c9b7..6b2559f0297 100644 --- a/custom_certificates/aliases.go +++ b/custom_certificates/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/custom_certificates/customcertificate.go b/custom_certificates/customcertificate.go index 7cd7db80714..5f1cd33ce6b 100644 --- a/custom_certificates/customcertificate.go +++ b/custom_certificates/customcertificate.go @@ -10,6 +10,7 @@ import ( "reflect" "time" + "github.com/cloudflare/cloudflare-go/v2/custom_hostnames" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" @@ -42,7 +43,7 @@ func NewCustomCertificateService(opts ...option.RequestOption) (r *CustomCertifi } // Upload a new SSL certificate for a zone. -func (r *CustomCertificateService) New(ctx context.Context, params CustomCertificateNewParams, opts ...option.RequestOption) (res *CustomCertificateNewResponse, err error) { +func (r *CustomCertificateService) New(ctx context.Context, params CustomCertificateNewParams, opts ...option.RequestOption) (res *CustomCertificateNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CustomCertificateNewResponseEnvelope path := fmt.Sprintf("zones/%s/custom_certificates", params.ZoneID) @@ -82,10 +83,10 @@ func (r *CustomCertificateService) ListAutoPaging(ctx context.Context, params Cu } // Remove a SSL certificate from a zone. -func (r *CustomCertificateService) Delete(ctx context.Context, customCertificateID string, body CustomCertificateDeleteParams, opts ...option.RequestOption) (res *CustomCertificateDeleteResponse, err error) { +func (r *CustomCertificateService) Delete(ctx context.Context, customCertificateID string, params CustomCertificateDeleteParams, opts ...option.RequestOption) (res *CustomCertificateDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env CustomCertificateDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_certificates/%s", body.ZoneID, customCertificateID) + path := fmt.Sprintf("zones/%s/custom_certificates/%s", params.ZoneID, customCertificateID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -97,7 +98,7 @@ func (r *CustomCertificateService) Delete(ctx context.Context, customCertificate // Upload a new private key and/or PEM/CRT for the SSL certificate. Note: PATCHing // a configuration for sni_custom certificates will result in a new resource id // being returned, and the previous one being deleted. -func (r *CustomCertificateService) Edit(ctx context.Context, customCertificateID string, params CustomCertificateEditParams, opts ...option.RequestOption) (res *CustomCertificateEditResponse, err error) { +func (r *CustomCertificateService) Edit(ctx context.Context, customCertificateID string, params CustomCertificateEditParams, opts ...option.RequestOption) (res *CustomCertificateEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CustomCertificateEditResponseEnvelope path := fmt.Sprintf("zones/%s/custom_certificates/%s", params.ZoneID, customCertificateID) @@ -110,7 +111,7 @@ func (r *CustomCertificateService) Edit(ctx context.Context, customCertificateID } // SSL Configuration Details -func (r *CustomCertificateService) Get(ctx context.Context, customCertificateID string, query CustomCertificateGetParams, opts ...option.RequestOption) (res *CustomCertificateGetResponse, err error) { +func (r *CustomCertificateService) Get(ctx context.Context, customCertificateID string, query CustomCertificateGetParams, opts ...option.RequestOption) (res *CustomCertificateGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CustomCertificateGetResponseEnvelope path := fmt.Sprintf("zones/%s/custom_certificates/%s", query.ZoneID, customCertificateID) @@ -129,7 +130,7 @@ type CustomCertificate struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod CustomCertificateBundleMethod `json:"bundle_method,required"` + BundleMethod custom_hostnames.BundleMethod `json:"bundle_method,required"` // When the certificate from the authority expires. ExpiresOn time.Time `json:"expires_on,required" format:"date-time"` Hosts []string `json:"hosts,required"` @@ -157,8 +158,8 @@ type CustomCertificate struct { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. - GeoRestrictions CustomCertificateGeoRestrictions `json:"geo_restrictions"` - KeylessServer keyless_certificates.KeylessCertificateHostname `json:"keyless_server"` + GeoRestrictions GeoRestrictions `json:"geo_restrictions"` + KeylessServer keyless_certificates.KeylessCertificate `json:"keyless_server"` // Specify the policy that determines the region where your private key will be // held locally. HTTPS connections to any excluded data center will still be fully // encrypted, but will incur some latency while Keyless SSL is used to complete the @@ -201,26 +202,6 @@ func (r customCertificateJSON) RawJSON() string { return r.raw } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomCertificateBundleMethod string - -const ( - CustomCertificateBundleMethodUbiquitous CustomCertificateBundleMethod = "ubiquitous" - CustomCertificateBundleMethodOptimal CustomCertificateBundleMethod = "optimal" - CustomCertificateBundleMethodForce CustomCertificateBundleMethod = "force" -) - -func (r CustomCertificateBundleMethod) IsKnown() bool { - switch r { - case CustomCertificateBundleMethodUbiquitous, CustomCertificateBundleMethodOptimal, CustomCertificateBundleMethodForce: - return true - } - return false -} - // Status of the zone's custom SSL. type CustomCertificateStatus string @@ -247,52 +228,66 @@ func (r CustomCertificateStatus) IsKnown() bool { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. -type CustomCertificateGeoRestrictions struct { - Label CustomCertificateGeoRestrictionsLabel `json:"label"` - JSON customCertificateGeoRestrictionsJSON `json:"-"` +type GeoRestrictions struct { + Label GeoRestrictionsLabel `json:"label"` + JSON geoRestrictionsJSON `json:"-"` } -// customCertificateGeoRestrictionsJSON contains the JSON metadata for the struct -// [CustomCertificateGeoRestrictions] -type customCertificateGeoRestrictionsJSON struct { +// geoRestrictionsJSON contains the JSON metadata for the struct [GeoRestrictions] +type geoRestrictionsJSON struct { Label apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *CustomCertificateGeoRestrictions) UnmarshalJSON(data []byte) (err error) { +func (r *GeoRestrictions) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customCertificateGeoRestrictionsJSON) RawJSON() string { +func (r geoRestrictionsJSON) RawJSON() string { return r.raw } -type CustomCertificateGeoRestrictionsLabel string +type GeoRestrictionsLabel string const ( - CustomCertificateGeoRestrictionsLabelUs CustomCertificateGeoRestrictionsLabel = "us" - CustomCertificateGeoRestrictionsLabelEu CustomCertificateGeoRestrictionsLabel = "eu" - CustomCertificateGeoRestrictionsLabelHighestSecurity CustomCertificateGeoRestrictionsLabel = "highest_security" + GeoRestrictionsLabelUs GeoRestrictionsLabel = "us" + GeoRestrictionsLabelEu GeoRestrictionsLabel = "eu" + GeoRestrictionsLabelHighestSecurity GeoRestrictionsLabel = "highest_security" ) -func (r CustomCertificateGeoRestrictionsLabel) IsKnown() bool { +func (r GeoRestrictionsLabel) IsKnown() bool { switch r { - case CustomCertificateGeoRestrictionsLabelUs, CustomCertificateGeoRestrictionsLabelEu, CustomCertificateGeoRestrictionsLabelHighestSecurity: + case GeoRestrictionsLabelUs, GeoRestrictionsLabelEu, GeoRestrictionsLabelHighestSecurity: return true } return false } +// Specify the region where your private key can be held locally for optimal TLS +// performance. HTTPS connections to any excluded data center will still be fully +// encrypted, but will incur some latency while Keyless SSL is used to complete the +// handshake with the nearest allowed data center. Options allow distribution to +// only to U.S. data centers, only to E.U. data centers, or only to highest +// security data centers. Default distribution is to all Cloudflare datacenters, +// for optimal performance. +type GeoRestrictionsParam struct { + Label param.Field[GeoRestrictionsLabel] `json:"label"` +} + +func (r GeoRestrictionsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Union satisfied by [custom_certificates.CustomCertificateNewResponseUnknown] or // [shared.UnionString]. -type CustomCertificateNewResponse interface { - ImplementsCustomCertificatesCustomCertificateNewResponse() +type CustomCertificateNewResponseUnion interface { + ImplementsCustomCertificatesCustomCertificateNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CustomCertificateNewResponse)(nil)).Elem(), + reflect.TypeOf((*CustomCertificateNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -325,13 +320,13 @@ func (r customCertificateDeleteResponseJSON) RawJSON() string { // Union satisfied by [custom_certificates.CustomCertificateEditResponseUnknown] or // [shared.UnionString]. -type CustomCertificateEditResponse interface { - ImplementsCustomCertificatesCustomCertificateEditResponse() +type CustomCertificateEditResponseUnion interface { + ImplementsCustomCertificatesCustomCertificateEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CustomCertificateEditResponse)(nil)).Elem(), + reflect.TypeOf((*CustomCertificateEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -342,13 +337,13 @@ func init() { // Union satisfied by [custom_certificates.CustomCertificateGetResponseUnknown] or // [shared.UnionString]. -type CustomCertificateGetResponse interface { - ImplementsCustomCertificatesCustomCertificateGetResponse() +type CustomCertificateGetResponseUnion interface { + ImplementsCustomCertificatesCustomCertificateGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CustomCertificateGetResponse)(nil)).Elem(), + reflect.TypeOf((*CustomCertificateGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -368,7 +363,7 @@ type CustomCertificateNewParams struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod param.Field[CustomCertificateNewParamsBundleMethod] `json:"bundle_method"` + BundleMethod param.Field[custom_hostnames.BundleMethod] `json:"bundle_method"` // Specify the region where your private key can be held locally for optimal TLS // performance. HTTPS connections to any excluded data center will still be fully // encrypted, but will incur some latency while Keyless SSL is used to complete the @@ -376,7 +371,7 @@ type CustomCertificateNewParams struct { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. - GeoRestrictions param.Field[CustomCertificateNewParamsGeoRestrictions] `json:"geo_restrictions"` + GeoRestrictions param.Field[GeoRestrictionsParam] `json:"geo_restrictions"` // Specify the policy that determines the region where your private key will be // held locally. HTTPS connections to any excluded data center will still be fully // encrypted, but will incur some latency while Keyless SSL is used to complete the @@ -396,57 +391,6 @@ func (r CustomCertificateNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomCertificateNewParamsBundleMethod string - -const ( - CustomCertificateNewParamsBundleMethodUbiquitous CustomCertificateNewParamsBundleMethod = "ubiquitous" - CustomCertificateNewParamsBundleMethodOptimal CustomCertificateNewParamsBundleMethod = "optimal" - CustomCertificateNewParamsBundleMethodForce CustomCertificateNewParamsBundleMethod = "force" -) - -func (r CustomCertificateNewParamsBundleMethod) IsKnown() bool { - switch r { - case CustomCertificateNewParamsBundleMethodUbiquitous, CustomCertificateNewParamsBundleMethodOptimal, CustomCertificateNewParamsBundleMethodForce: - return true - } - return false -} - -// Specify the region where your private key can be held locally for optimal TLS -// performance. HTTPS connections to any excluded data center will still be fully -// encrypted, but will incur some latency while Keyless SSL is used to complete the -// handshake with the nearest allowed data center. Options allow distribution to -// only to U.S. data centers, only to E.U. data centers, or only to highest -// security data centers. Default distribution is to all Cloudflare datacenters, -// for optimal performance. -type CustomCertificateNewParamsGeoRestrictions struct { - Label param.Field[CustomCertificateNewParamsGeoRestrictionsLabel] `json:"label"` -} - -func (r CustomCertificateNewParamsGeoRestrictions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomCertificateNewParamsGeoRestrictionsLabel string - -const ( - CustomCertificateNewParamsGeoRestrictionsLabelUs CustomCertificateNewParamsGeoRestrictionsLabel = "us" - CustomCertificateNewParamsGeoRestrictionsLabelEu CustomCertificateNewParamsGeoRestrictionsLabel = "eu" - CustomCertificateNewParamsGeoRestrictionsLabelHighestSecurity CustomCertificateNewParamsGeoRestrictionsLabel = "highest_security" -) - -func (r CustomCertificateNewParamsGeoRestrictionsLabel) IsKnown() bool { - switch r { - case CustomCertificateNewParamsGeoRestrictionsLabelUs, CustomCertificateNewParamsGeoRestrictionsLabelEu, CustomCertificateNewParamsGeoRestrictionsLabelHighestSecurity: - return true - } - return false -} - // The type 'legacy_custom' enables support for legacy clients which do not include // SNI in the TLS handshake. type CustomCertificateNewParamsType string @@ -465,9 +409,9 @@ func (r CustomCertificateNewParamsType) IsKnown() bool { } type CustomCertificateNewResponseEnvelope struct { - Errors []CustomCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result CustomCertificateNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomCertificateNewResponseUnion `json:"result,required"` // Whether the API call was successful Success CustomCertificateNewResponseEnvelopeSuccess `json:"success,required"` JSON customCertificateNewResponseEnvelopeJSON `json:"-"` @@ -492,52 +436,6 @@ func (r customCertificateNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// customCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomCertificateNewResponseEnvelopeErrors] -type customCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// customCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomCertificateNewResponseEnvelopeMessages] -type customCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomCertificateNewResponseEnvelopeSuccess bool @@ -562,13 +460,15 @@ type CustomCertificateListParams struct { Page param.Field[float64] `query:"page"` // Number of zones per page. PerPage param.Field[float64] `query:"per_page"` + // Status of the zone's custom SSL. + Status param.Field[CustomCertificateListParamsStatus] `query:"status"` } // URLQuery serializes [CustomCertificateListParams]'s query parameters as // `url.Values`. func (r CustomCertificateListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -589,15 +489,39 @@ func (r CustomCertificateListParamsMatch) IsKnown() bool { return false } +// Status of the zone's custom SSL. +type CustomCertificateListParamsStatus string + +const ( + CustomCertificateListParamsStatusActive CustomCertificateListParamsStatus = "active" + CustomCertificateListParamsStatusExpired CustomCertificateListParamsStatus = "expired" + CustomCertificateListParamsStatusDeleted CustomCertificateListParamsStatus = "deleted" + CustomCertificateListParamsStatusPending CustomCertificateListParamsStatus = "pending" + CustomCertificateListParamsStatusInitializing CustomCertificateListParamsStatus = "initializing" +) + +func (r CustomCertificateListParamsStatus) IsKnown() bool { + switch r { + case CustomCertificateListParamsStatusActive, CustomCertificateListParamsStatusExpired, CustomCertificateListParamsStatusDeleted, CustomCertificateListParamsStatusPending, CustomCertificateListParamsStatusInitializing: + return true + } + return false +} + type CustomCertificateDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CustomCertificateDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CustomCertificateDeleteResponseEnvelope struct { - Errors []CustomCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CustomCertificateDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomCertificateDeleteResponse `json:"result,required"` // Whether the API call was successful Success CustomCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON customCertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -622,52 +546,6 @@ func (r customCertificateDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// customCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomCertificateDeleteResponseEnvelopeErrors] -type customCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// customCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CustomCertificateDeleteResponseEnvelopeMessages] -type customCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomCertificateDeleteResponseEnvelopeSuccess bool @@ -690,7 +568,7 @@ type CustomCertificateEditParams struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod param.Field[CustomCertificateEditParamsBundleMethod] `json:"bundle_method"` + BundleMethod param.Field[custom_hostnames.BundleMethod] `json:"bundle_method"` // The zone's SSL certificate or certificate and the intermediate(s). Certificate param.Field[string] `json:"certificate"` // Specify the region where your private key can be held locally for optimal TLS @@ -700,7 +578,7 @@ type CustomCertificateEditParams struct { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. - GeoRestrictions param.Field[CustomCertificateEditParamsGeoRestrictions] `json:"geo_restrictions"` + GeoRestrictions param.Field[GeoRestrictionsParam] `json:"geo_restrictions"` // Specify the policy that determines the region where your private key will be // held locally. HTTPS connections to any excluded data center will still be fully // encrypted, but will incur some latency while Keyless SSL is used to complete the @@ -719,61 +597,10 @@ func (r CustomCertificateEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomCertificateEditParamsBundleMethod string - -const ( - CustomCertificateEditParamsBundleMethodUbiquitous CustomCertificateEditParamsBundleMethod = "ubiquitous" - CustomCertificateEditParamsBundleMethodOptimal CustomCertificateEditParamsBundleMethod = "optimal" - CustomCertificateEditParamsBundleMethodForce CustomCertificateEditParamsBundleMethod = "force" -) - -func (r CustomCertificateEditParamsBundleMethod) IsKnown() bool { - switch r { - case CustomCertificateEditParamsBundleMethodUbiquitous, CustomCertificateEditParamsBundleMethodOptimal, CustomCertificateEditParamsBundleMethodForce: - return true - } - return false -} - -// Specify the region where your private key can be held locally for optimal TLS -// performance. HTTPS connections to any excluded data center will still be fully -// encrypted, but will incur some latency while Keyless SSL is used to complete the -// handshake with the nearest allowed data center. Options allow distribution to -// only to U.S. data centers, only to E.U. data centers, or only to highest -// security data centers. Default distribution is to all Cloudflare datacenters, -// for optimal performance. -type CustomCertificateEditParamsGeoRestrictions struct { - Label param.Field[CustomCertificateEditParamsGeoRestrictionsLabel] `json:"label"` -} - -func (r CustomCertificateEditParamsGeoRestrictions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomCertificateEditParamsGeoRestrictionsLabel string - -const ( - CustomCertificateEditParamsGeoRestrictionsLabelUs CustomCertificateEditParamsGeoRestrictionsLabel = "us" - CustomCertificateEditParamsGeoRestrictionsLabelEu CustomCertificateEditParamsGeoRestrictionsLabel = "eu" - CustomCertificateEditParamsGeoRestrictionsLabelHighestSecurity CustomCertificateEditParamsGeoRestrictionsLabel = "highest_security" -) - -func (r CustomCertificateEditParamsGeoRestrictionsLabel) IsKnown() bool { - switch r { - case CustomCertificateEditParamsGeoRestrictionsLabelUs, CustomCertificateEditParamsGeoRestrictionsLabelEu, CustomCertificateEditParamsGeoRestrictionsLabelHighestSecurity: - return true - } - return false -} - type CustomCertificateEditResponseEnvelope struct { - Errors []CustomCertificateEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomCertificateEditResponseEnvelopeMessages `json:"messages,required"` - Result CustomCertificateEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomCertificateEditResponseUnion `json:"result,required"` // Whether the API call was successful Success CustomCertificateEditResponseEnvelopeSuccess `json:"success,required"` JSON customCertificateEditResponseEnvelopeJSON `json:"-"` @@ -798,52 +625,6 @@ func (r customCertificateEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomCertificateEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// customCertificateEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomCertificateEditResponseEnvelopeErrors] -type customCertificateEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomCertificateEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// customCertificateEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomCertificateEditResponseEnvelopeMessages] -type customCertificateEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomCertificateEditResponseEnvelopeSuccess bool @@ -865,9 +646,9 @@ type CustomCertificateGetParams struct { } type CustomCertificateGetResponseEnvelope struct { - Errors []CustomCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result CustomCertificateGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomCertificateGetResponseUnion `json:"result,required"` // Whether the API call was successful Success CustomCertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON customCertificateGetResponseEnvelopeJSON `json:"-"` @@ -892,52 +673,6 @@ func (r customCertificateGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// customCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomCertificateGetResponseEnvelopeErrors] -type customCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// customCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomCertificateGetResponseEnvelopeMessages] -type customCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomCertificateGetResponseEnvelopeSuccess bool diff --git a/custom_certificates/customcertificate_test.go b/custom_certificates/customcertificate_test.go index 65fb6147d42..ba46385c715 100644 --- a/custom_certificates/customcertificate_test.go +++ b/custom_certificates/customcertificate_test.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2" "github.com/cloudflare/cloudflare-go/v2/custom_certificates" + "github.com/cloudflare/cloudflare-go/v2/custom_hostnames" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -32,9 +33,9 @@ func TestCustomCertificateNewWithOptionalParams(t *testing.T) { ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), - BundleMethod: cloudflare.F(custom_certificates.CustomCertificateNewParamsBundleMethodUbiquitous), - GeoRestrictions: cloudflare.F(custom_certificates.CustomCertificateNewParamsGeoRestrictions{ - Label: cloudflare.F(custom_certificates.CustomCertificateNewParamsGeoRestrictionsLabelUs), + BundleMethod: cloudflare.F(custom_hostnames.BundleMethodUbiquitous), + GeoRestrictions: cloudflare.F(custom_certificates.GeoRestrictionsParam{ + Label: cloudflare.F(custom_certificates.GeoRestrictionsLabelUs), }), Policy: cloudflare.F("(country: US) or (region: EU)"), Type: cloudflare.F(custom_certificates.CustomCertificateNewParamsTypeSniCustom), @@ -67,6 +68,7 @@ func TestCustomCertificateListWithOptionalParams(t *testing.T) { Match: cloudflare.F(custom_certificates.CustomCertificateListParamsMatchAny), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), + Status: cloudflare.F(custom_certificates.CustomCertificateListParamsStatusActive), }) if err != nil { var apierr *cloudflare.Error @@ -96,6 +98,7 @@ func TestCustomCertificateDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", custom_certificates.CustomCertificateDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -126,10 +129,10 @@ func TestCustomCertificateEditWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", custom_certificates.CustomCertificateEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - BundleMethod: cloudflare.F(custom_certificates.CustomCertificateEditParamsBundleMethodUbiquitous), + BundleMethod: cloudflare.F(custom_hostnames.BundleMethodUbiquitous), Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), - GeoRestrictions: cloudflare.F(custom_certificates.CustomCertificateEditParamsGeoRestrictions{ - Label: cloudflare.F(custom_certificates.CustomCertificateEditParamsGeoRestrictionsLabelUs), + GeoRestrictions: cloudflare.F(custom_certificates.GeoRestrictionsParam{ + Label: cloudflare.F(custom_certificates.GeoRestrictionsLabelUs), }), Policy: cloudflare.F("(country: US) or (region: EU)"), PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), diff --git a/custom_certificates/prioritize.go b/custom_certificates/prioritize.go index e695ee2449a..e482e723871 100644 --- a/custom_certificates/prioritize.go +++ b/custom_certificates/prioritize.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -69,9 +70,9 @@ func (r PrioritizeUpdateParamsCertificate) MarshalJSON() (data []byte, err error } type PrioritizeUpdateResponseEnvelope struct { - Errors []PrioritizeUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []PrioritizeUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []CustomCertificate `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []CustomCertificate `json:"result,required,nullable"` // Whether the API call was successful Success PrioritizeUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo PrioritizeUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -98,52 +99,6 @@ func (r prioritizeUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PrioritizeUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prioritizeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// prioritizeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PrioritizeUpdateResponseEnvelopeErrors] -type prioritizeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrioritizeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prioritizeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PrioritizeUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON prioritizeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// prioritizeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PrioritizeUpdateResponseEnvelopeMessages] -type prioritizeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PrioritizeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r prioritizeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PrioritizeUpdateResponseEnvelopeSuccess bool diff --git a/custom_hostnames/aliases.go b/custom_hostnames/aliases.go index dfafeae1084..4ad39d37f42 100644 --- a/custom_hostnames/aliases.go +++ b/custom_hostnames/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/custom_hostnames/customhostname.go b/custom_hostnames/customhostname.go index 941739be3ba..fe8506a80a0 100644 --- a/custom_hostnames/customhostname.go +++ b/custom_hostnames/customhostname.go @@ -14,6 +14,7 @@ import ( "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" ) @@ -80,9 +81,9 @@ func (r *CustomHostnameService) ListAutoPaging(ctx context.Context, params Custo } // Delete Custom Hostname (and any issued SSL certificates) -func (r *CustomHostnameService) Delete(ctx context.Context, customHostnameID string, body CustomHostnameDeleteParams, opts ...option.RequestOption) (res *CustomHostnameDeleteResponse, err error) { +func (r *CustomHostnameService) Delete(ctx context.Context, customHostnameID string, params CustomHostnameDeleteParams, opts ...option.RequestOption) (res *CustomHostnameDeleteResponse, err error) { opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/custom_hostnames/%s", body.ZoneID, customHostnameID) + path := fmt.Sprintf("zones/%s/custom_hostnames/%s", params.ZoneID, customHostnameID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) return } @@ -116,6 +117,59 @@ func (r *CustomHostnameService) Get(ctx context.Context, customHostnameID string return } +// A ubiquitous bundle has the highest probability of being verified everywhere, +// even by clients using outdated or unusual trust stores. An optimal bundle uses +// the shortest chain and newest intermediates. And the force bundle verifies the +// chain, but does not otherwise modify it. +type BundleMethod string + +const ( + BundleMethodUbiquitous BundleMethod = "ubiquitous" + BundleMethodOptimal BundleMethod = "optimal" + BundleMethodForce BundleMethod = "force" +) + +func (r BundleMethod) IsKnown() bool { + switch r { + case BundleMethodUbiquitous, BundleMethodOptimal, BundleMethodForce: + return true + } + return false +} + +// Domain control validation (DCV) method used for this hostname. +type DCVMethod string + +const ( + DCVMethodHTTP DCVMethod = "http" + DCVMethodTXT DCVMethod = "txt" + DCVMethodEmail DCVMethod = "email" +) + +func (r DCVMethod) IsKnown() bool { + switch r { + case DCVMethodHTTP, DCVMethodTXT, DCVMethodEmail: + return true + } + return false +} + +// Level of validation to be used for this hostname. Domain validation (dv) must be +// used. +type DomainValidationType string + +const ( + DomainValidationTypeDv DomainValidationType = "dv" +) + +func (r DomainValidationType) IsKnown() bool { + switch r { + case DomainValidationTypeDv: + return true + } + return false +} + type CustomHostnameNewResponse struct { // Identifier ID string `json:"id,required"` @@ -152,7 +206,7 @@ type CustomHostnameNewResponseSSL struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod CustomHostnameNewResponseSSLBundleMethod `json:"bundle_method"` + BundleMethod BundleMethod `json:"bundle_method"` // The Certificate Authority that will issue the certificate CertificateAuthority CustomHostnameNewResponseSSLCertificateAuthority `json:"certificate_authority"` // If a custom uploaded certificate is used. @@ -168,7 +222,7 @@ type CustomHostnameNewResponseSSL struct { // The issuer on a custom uploaded certificate. Issuer string `json:"issuer"` // Domain control validation (DCV) method used for this hostname. - Method CustomHostnameNewResponseSSLMethod `json:"method"` + Method DCVMethod `json:"method"` // The serial number on a custom uploaded certificate. SerialNumber string `json:"serial_number"` // SSL specific settings. @@ -179,7 +233,7 @@ type CustomHostnameNewResponseSSL struct { Status CustomHostnameNewResponseSSLStatus `json:"status"` // Level of validation to be used for this hostname. Domain validation (dv) must be // used. - Type CustomHostnameNewResponseSSLType `json:"type"` + Type DomainValidationType `json:"type"` // The time the custom certificate was uploaded. UploadedOn time.Time `json:"uploaded_on" format:"date-time"` // Domain validation errors that have been received by the certificate authority @@ -225,26 +279,6 @@ func (r customHostnameNewResponseSSLJSON) RawJSON() string { return r.raw } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomHostnameNewResponseSSLBundleMethod string - -const ( - CustomHostnameNewResponseSSLBundleMethodUbiquitous CustomHostnameNewResponseSSLBundleMethod = "ubiquitous" - CustomHostnameNewResponseSSLBundleMethodOptimal CustomHostnameNewResponseSSLBundleMethod = "optimal" - CustomHostnameNewResponseSSLBundleMethodForce CustomHostnameNewResponseSSLBundleMethod = "force" -) - -func (r CustomHostnameNewResponseSSLBundleMethod) IsKnown() bool { - switch r { - case CustomHostnameNewResponseSSLBundleMethodUbiquitous, CustomHostnameNewResponseSSLBundleMethodOptimal, CustomHostnameNewResponseSSLBundleMethodForce: - return true - } - return false -} - // The Certificate Authority that will issue the certificate type CustomHostnameNewResponseSSLCertificateAuthority string @@ -262,23 +296,6 @@ func (r CustomHostnameNewResponseSSLCertificateAuthority) IsKnown() bool { return false } -// Domain control validation (DCV) method used for this hostname. -type CustomHostnameNewResponseSSLMethod string - -const ( - CustomHostnameNewResponseSSLMethodHTTP CustomHostnameNewResponseSSLMethod = "http" - CustomHostnameNewResponseSSLMethodTXT CustomHostnameNewResponseSSLMethod = "txt" - CustomHostnameNewResponseSSLMethodEmail CustomHostnameNewResponseSSLMethod = "email" -) - -func (r CustomHostnameNewResponseSSLMethod) IsKnown() bool { - switch r { - case CustomHostnameNewResponseSSLMethodHTTP, CustomHostnameNewResponseSSLMethodTXT, CustomHostnameNewResponseSSLMethodEmail: - return true - } - return false -} - // SSL specific settings. type CustomHostnameNewResponseSSLSettings struct { // An allowlist of ciphers for TLS termination. These ciphers must be in the @@ -416,22 +433,6 @@ func (r CustomHostnameNewResponseSSLStatus) IsKnown() bool { return false } -// Level of validation to be used for this hostname. Domain validation (dv) must be -// used. -type CustomHostnameNewResponseSSLType string - -const ( - CustomHostnameNewResponseSSLTypeDv CustomHostnameNewResponseSSLType = "dv" -) - -func (r CustomHostnameNewResponseSSLType) IsKnown() bool { - switch r { - case CustomHostnameNewResponseSSLTypeDv: - return true - } - return false -} - type CustomHostnameNewResponseSSLValidationError struct { // A domain validation error. Message string `json:"message"` @@ -529,7 +530,7 @@ type CustomHostnameListResponseSSL struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod CustomHostnameListResponseSSLBundleMethod `json:"bundle_method"` + BundleMethod BundleMethod `json:"bundle_method"` // The Certificate Authority that will issue the certificate CertificateAuthority CustomHostnameListResponseSSLCertificateAuthority `json:"certificate_authority"` // If a custom uploaded certificate is used. @@ -545,7 +546,7 @@ type CustomHostnameListResponseSSL struct { // The issuer on a custom uploaded certificate. Issuer string `json:"issuer"` // Domain control validation (DCV) method used for this hostname. - Method CustomHostnameListResponseSSLMethod `json:"method"` + Method DCVMethod `json:"method"` // The serial number on a custom uploaded certificate. SerialNumber string `json:"serial_number"` // SSL specific settings. @@ -556,7 +557,7 @@ type CustomHostnameListResponseSSL struct { Status CustomHostnameListResponseSSLStatus `json:"status"` // Level of validation to be used for this hostname. Domain validation (dv) must be // used. - Type CustomHostnameListResponseSSLType `json:"type"` + Type DomainValidationType `json:"type"` // The time the custom certificate was uploaded. UploadedOn time.Time `json:"uploaded_on" format:"date-time"` // Domain validation errors that have been received by the certificate authority @@ -602,26 +603,6 @@ func (r customHostnameListResponseSSLJSON) RawJSON() string { return r.raw } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomHostnameListResponseSSLBundleMethod string - -const ( - CustomHostnameListResponseSSLBundleMethodUbiquitous CustomHostnameListResponseSSLBundleMethod = "ubiquitous" - CustomHostnameListResponseSSLBundleMethodOptimal CustomHostnameListResponseSSLBundleMethod = "optimal" - CustomHostnameListResponseSSLBundleMethodForce CustomHostnameListResponseSSLBundleMethod = "force" -) - -func (r CustomHostnameListResponseSSLBundleMethod) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLBundleMethodUbiquitous, CustomHostnameListResponseSSLBundleMethodOptimal, CustomHostnameListResponseSSLBundleMethodForce: - return true - } - return false -} - // The Certificate Authority that will issue the certificate type CustomHostnameListResponseSSLCertificateAuthority string @@ -639,23 +620,6 @@ func (r CustomHostnameListResponseSSLCertificateAuthority) IsKnown() bool { return false } -// Domain control validation (DCV) method used for this hostname. -type CustomHostnameListResponseSSLMethod string - -const ( - CustomHostnameListResponseSSLMethodHTTP CustomHostnameListResponseSSLMethod = "http" - CustomHostnameListResponseSSLMethodTXT CustomHostnameListResponseSSLMethod = "txt" - CustomHostnameListResponseSSLMethodEmail CustomHostnameListResponseSSLMethod = "email" -) - -func (r CustomHostnameListResponseSSLMethod) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLMethodHTTP, CustomHostnameListResponseSSLMethodTXT, CustomHostnameListResponseSSLMethodEmail: - return true - } - return false -} - // SSL specific settings. type CustomHostnameListResponseSSLSettings struct { // An allowlist of ciphers for TLS termination. These ciphers must be in the @@ -793,22 +757,6 @@ func (r CustomHostnameListResponseSSLStatus) IsKnown() bool { return false } -// Level of validation to be used for this hostname. Domain validation (dv) must be -// used. -type CustomHostnameListResponseSSLType string - -const ( - CustomHostnameListResponseSSLTypeDv CustomHostnameListResponseSSLType = "dv" -) - -func (r CustomHostnameListResponseSSLType) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLTypeDv: - return true - } - return false -} - type CustomHostnameListResponseSSLValidationError struct { // A domain validation error. Message string `json:"message"` @@ -928,7 +876,7 @@ type CustomHostnameEditResponseSSL struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod CustomHostnameEditResponseSSLBundleMethod `json:"bundle_method"` + BundleMethod BundleMethod `json:"bundle_method"` // The Certificate Authority that will issue the certificate CertificateAuthority CustomHostnameEditResponseSSLCertificateAuthority `json:"certificate_authority"` // If a custom uploaded certificate is used. @@ -944,7 +892,7 @@ type CustomHostnameEditResponseSSL struct { // The issuer on a custom uploaded certificate. Issuer string `json:"issuer"` // Domain control validation (DCV) method used for this hostname. - Method CustomHostnameEditResponseSSLMethod `json:"method"` + Method DCVMethod `json:"method"` // The serial number on a custom uploaded certificate. SerialNumber string `json:"serial_number"` // SSL specific settings. @@ -955,7 +903,7 @@ type CustomHostnameEditResponseSSL struct { Status CustomHostnameEditResponseSSLStatus `json:"status"` // Level of validation to be used for this hostname. Domain validation (dv) must be // used. - Type CustomHostnameEditResponseSSLType `json:"type"` + Type DomainValidationType `json:"type"` // The time the custom certificate was uploaded. UploadedOn time.Time `json:"uploaded_on" format:"date-time"` // Domain validation errors that have been received by the certificate authority @@ -1001,26 +949,6 @@ func (r customHostnameEditResponseSSLJSON) RawJSON() string { return r.raw } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomHostnameEditResponseSSLBundleMethod string - -const ( - CustomHostnameEditResponseSSLBundleMethodUbiquitous CustomHostnameEditResponseSSLBundleMethod = "ubiquitous" - CustomHostnameEditResponseSSLBundleMethodOptimal CustomHostnameEditResponseSSLBundleMethod = "optimal" - CustomHostnameEditResponseSSLBundleMethodForce CustomHostnameEditResponseSSLBundleMethod = "force" -) - -func (r CustomHostnameEditResponseSSLBundleMethod) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLBundleMethodUbiquitous, CustomHostnameEditResponseSSLBundleMethodOptimal, CustomHostnameEditResponseSSLBundleMethodForce: - return true - } - return false -} - // The Certificate Authority that will issue the certificate type CustomHostnameEditResponseSSLCertificateAuthority string @@ -1038,23 +966,6 @@ func (r CustomHostnameEditResponseSSLCertificateAuthority) IsKnown() bool { return false } -// Domain control validation (DCV) method used for this hostname. -type CustomHostnameEditResponseSSLMethod string - -const ( - CustomHostnameEditResponseSSLMethodHTTP CustomHostnameEditResponseSSLMethod = "http" - CustomHostnameEditResponseSSLMethodTXT CustomHostnameEditResponseSSLMethod = "txt" - CustomHostnameEditResponseSSLMethodEmail CustomHostnameEditResponseSSLMethod = "email" -) - -func (r CustomHostnameEditResponseSSLMethod) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLMethodHTTP, CustomHostnameEditResponseSSLMethodTXT, CustomHostnameEditResponseSSLMethodEmail: - return true - } - return false -} - // SSL specific settings. type CustomHostnameEditResponseSSLSettings struct { // An allowlist of ciphers for TLS termination. These ciphers must be in the @@ -1192,22 +1103,6 @@ func (r CustomHostnameEditResponseSSLStatus) IsKnown() bool { return false } -// Level of validation to be used for this hostname. Domain validation (dv) must be -// used. -type CustomHostnameEditResponseSSLType string - -const ( - CustomHostnameEditResponseSSLTypeDv CustomHostnameEditResponseSSLType = "dv" -) - -func (r CustomHostnameEditResponseSSLType) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLTypeDv: - return true - } - return false -} - type CustomHostnameEditResponseSSLValidationError struct { // A domain validation error. Message string `json:"message"` @@ -1305,7 +1200,7 @@ type CustomHostnameGetResponseSSL struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod CustomHostnameGetResponseSSLBundleMethod `json:"bundle_method"` + BundleMethod BundleMethod `json:"bundle_method"` // The Certificate Authority that will issue the certificate CertificateAuthority CustomHostnameGetResponseSSLCertificateAuthority `json:"certificate_authority"` // If a custom uploaded certificate is used. @@ -1321,7 +1216,7 @@ type CustomHostnameGetResponseSSL struct { // The issuer on a custom uploaded certificate. Issuer string `json:"issuer"` // Domain control validation (DCV) method used for this hostname. - Method CustomHostnameGetResponseSSLMethod `json:"method"` + Method DCVMethod `json:"method"` // The serial number on a custom uploaded certificate. SerialNumber string `json:"serial_number"` // SSL specific settings. @@ -1332,7 +1227,7 @@ type CustomHostnameGetResponseSSL struct { Status CustomHostnameGetResponseSSLStatus `json:"status"` // Level of validation to be used for this hostname. Domain validation (dv) must be // used. - Type CustomHostnameGetResponseSSLType `json:"type"` + Type DomainValidationType `json:"type"` // The time the custom certificate was uploaded. UploadedOn time.Time `json:"uploaded_on" format:"date-time"` // Domain validation errors that have been received by the certificate authority @@ -1378,26 +1273,6 @@ func (r customHostnameGetResponseSSLJSON) RawJSON() string { return r.raw } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomHostnameGetResponseSSLBundleMethod string - -const ( - CustomHostnameGetResponseSSLBundleMethodUbiquitous CustomHostnameGetResponseSSLBundleMethod = "ubiquitous" - CustomHostnameGetResponseSSLBundleMethodOptimal CustomHostnameGetResponseSSLBundleMethod = "optimal" - CustomHostnameGetResponseSSLBundleMethodForce CustomHostnameGetResponseSSLBundleMethod = "force" -) - -func (r CustomHostnameGetResponseSSLBundleMethod) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLBundleMethodUbiquitous, CustomHostnameGetResponseSSLBundleMethodOptimal, CustomHostnameGetResponseSSLBundleMethodForce: - return true - } - return false -} - // The Certificate Authority that will issue the certificate type CustomHostnameGetResponseSSLCertificateAuthority string @@ -1415,23 +1290,6 @@ func (r CustomHostnameGetResponseSSLCertificateAuthority) IsKnown() bool { return false } -// Domain control validation (DCV) method used for this hostname. -type CustomHostnameGetResponseSSLMethod string - -const ( - CustomHostnameGetResponseSSLMethodHTTP CustomHostnameGetResponseSSLMethod = "http" - CustomHostnameGetResponseSSLMethodTXT CustomHostnameGetResponseSSLMethod = "txt" - CustomHostnameGetResponseSSLMethodEmail CustomHostnameGetResponseSSLMethod = "email" -) - -func (r CustomHostnameGetResponseSSLMethod) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLMethodHTTP, CustomHostnameGetResponseSSLMethodTXT, CustomHostnameGetResponseSSLMethodEmail: - return true - } - return false -} - // SSL specific settings. type CustomHostnameGetResponseSSLSettings struct { // An allowlist of ciphers for TLS termination. These ciphers must be in the @@ -1569,22 +1427,6 @@ func (r CustomHostnameGetResponseSSLStatus) IsKnown() bool { return false } -// Level of validation to be used for this hostname. Domain validation (dv) must be -// used. -type CustomHostnameGetResponseSSLType string - -const ( - CustomHostnameGetResponseSSLTypeDv CustomHostnameGetResponseSSLType = "dv" -) - -func (r CustomHostnameGetResponseSSLType) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLTypeDv: - return true - } - return false -} - type CustomHostnameGetResponseSSLValidationError struct { // A domain validation error. Message string `json:"message"` @@ -1667,7 +1509,7 @@ type CustomHostnameNewParamsSSL struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod param.Field[CustomHostnameNewParamsSSLBundleMethod] `json:"bundle_method"` + BundleMethod param.Field[BundleMethod] `json:"bundle_method"` // The Certificate Authority that will issue the certificate CertificateAuthority param.Field[CustomHostnameNewParamsSSLCertificateAuthority] `json:"certificate_authority"` // If a custom uploaded certificate is used. @@ -1675,12 +1517,12 @@ type CustomHostnameNewParamsSSL struct { // The key for a custom uploaded certificate. CustomKey param.Field[string] `json:"custom_key"` // Domain control validation (DCV) method used for this hostname. - Method param.Field[CustomHostnameNewParamsSSLMethod] `json:"method"` + Method param.Field[DCVMethod] `json:"method"` // SSL specific settings. Settings param.Field[CustomHostnameNewParamsSSLSettings] `json:"settings"` // Level of validation to be used for this hostname. Domain validation (dv) must be // used. - Type param.Field[CustomHostnameNewParamsSSLType] `json:"type"` + Type param.Field[DomainValidationType] `json:"type"` // Indicates whether the certificate covers a wildcard. Wildcard param.Field[bool] `json:"wildcard"` } @@ -1689,26 +1531,6 @@ func (r CustomHostnameNewParamsSSL) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomHostnameNewParamsSSLBundleMethod string - -const ( - CustomHostnameNewParamsSSLBundleMethodUbiquitous CustomHostnameNewParamsSSLBundleMethod = "ubiquitous" - CustomHostnameNewParamsSSLBundleMethodOptimal CustomHostnameNewParamsSSLBundleMethod = "optimal" - CustomHostnameNewParamsSSLBundleMethodForce CustomHostnameNewParamsSSLBundleMethod = "force" -) - -func (r CustomHostnameNewParamsSSLBundleMethod) IsKnown() bool { - switch r { - case CustomHostnameNewParamsSSLBundleMethodUbiquitous, CustomHostnameNewParamsSSLBundleMethodOptimal, CustomHostnameNewParamsSSLBundleMethodForce: - return true - } - return false -} - // The Certificate Authority that will issue the certificate type CustomHostnameNewParamsSSLCertificateAuthority string @@ -1726,23 +1548,6 @@ func (r CustomHostnameNewParamsSSLCertificateAuthority) IsKnown() bool { return false } -// Domain control validation (DCV) method used for this hostname. -type CustomHostnameNewParamsSSLMethod string - -const ( - CustomHostnameNewParamsSSLMethodHTTP CustomHostnameNewParamsSSLMethod = "http" - CustomHostnameNewParamsSSLMethodTXT CustomHostnameNewParamsSSLMethod = "txt" - CustomHostnameNewParamsSSLMethodEmail CustomHostnameNewParamsSSLMethod = "email" -) - -func (r CustomHostnameNewParamsSSLMethod) IsKnown() bool { - switch r { - case CustomHostnameNewParamsSSLMethodHTTP, CustomHostnameNewParamsSSLMethodTXT, CustomHostnameNewParamsSSLMethodEmail: - return true - } - return false -} - // SSL specific settings. type CustomHostnameNewParamsSSLSettings struct { // An allowlist of ciphers for TLS termination. These ciphers must be in the @@ -1828,22 +1633,6 @@ func (r CustomHostnameNewParamsSSLSettingsTLS1_3) IsKnown() bool { return false } -// Level of validation to be used for this hostname. Domain validation (dv) must be -// used. -type CustomHostnameNewParamsSSLType string - -const ( - CustomHostnameNewParamsSSLTypeDv CustomHostnameNewParamsSSLType = "dv" -) - -func (r CustomHostnameNewParamsSSLType) IsKnown() bool { - switch r { - case CustomHostnameNewParamsSSLTypeDv: - return true - } - return false -} - // These are per-hostname (customer) settings. type CustomHostnameNewParamsCustomMetadata struct { // Unique metadata for this hostname. @@ -1855,9 +1644,9 @@ func (r CustomHostnameNewParamsCustomMetadata) MarshalJSON() (data []byte, err e } type CustomHostnameNewResponseEnvelope struct { - Errors []CustomHostnameNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomHostnameNewResponseEnvelopeMessages `json:"messages,required"` - Result CustomHostnameNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomHostnameNewResponse `json:"result,required"` // Whether the API call was successful Success CustomHostnameNewResponseEnvelopeSuccess `json:"success,required"` JSON customHostnameNewResponseEnvelopeJSON `json:"-"` @@ -1882,52 +1671,6 @@ func (r customHostnameNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomHostnameNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// customHostnameNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomHostnameNewResponseEnvelopeErrors] -type customHostnameNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// customHostnameNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CustomHostnameNewResponseEnvelopeMessages] -type customHostnameNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomHostnameNewResponseEnvelopeSuccess bool @@ -1969,7 +1712,7 @@ type CustomHostnameListParams struct { // `url.Values`. func (r CustomHostnameListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2025,6 +1768,11 @@ func (r CustomHostnameListParamsSSL) IsKnown() bool { type CustomHostnameDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CustomHostnameDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CustomHostnameEditParams struct { @@ -2065,7 +1813,7 @@ type CustomHostnameEditParamsSSL struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod param.Field[CustomHostnameEditParamsSSLBundleMethod] `json:"bundle_method"` + BundleMethod param.Field[BundleMethod] `json:"bundle_method"` // The Certificate Authority that will issue the certificate CertificateAuthority param.Field[CustomHostnameEditParamsSSLCertificateAuthority] `json:"certificate_authority"` // If a custom uploaded certificate is used. @@ -2073,12 +1821,12 @@ type CustomHostnameEditParamsSSL struct { // The key for a custom uploaded certificate. CustomKey param.Field[string] `json:"custom_key"` // Domain control validation (DCV) method used for this hostname. - Method param.Field[CustomHostnameEditParamsSSLMethod] `json:"method"` + Method param.Field[DCVMethod] `json:"method"` // SSL specific settings. Settings param.Field[CustomHostnameEditParamsSSLSettings] `json:"settings"` // Level of validation to be used for this hostname. Domain validation (dv) must be // used. - Type param.Field[CustomHostnameEditParamsSSLType] `json:"type"` + Type param.Field[DomainValidationType] `json:"type"` // Indicates whether the certificate covers a wildcard. Wildcard param.Field[bool] `json:"wildcard"` } @@ -2087,26 +1835,6 @@ func (r CustomHostnameEditParamsSSL) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomHostnameEditParamsSSLBundleMethod string - -const ( - CustomHostnameEditParamsSSLBundleMethodUbiquitous CustomHostnameEditParamsSSLBundleMethod = "ubiquitous" - CustomHostnameEditParamsSSLBundleMethodOptimal CustomHostnameEditParamsSSLBundleMethod = "optimal" - CustomHostnameEditParamsSSLBundleMethodForce CustomHostnameEditParamsSSLBundleMethod = "force" -) - -func (r CustomHostnameEditParamsSSLBundleMethod) IsKnown() bool { - switch r { - case CustomHostnameEditParamsSSLBundleMethodUbiquitous, CustomHostnameEditParamsSSLBundleMethodOptimal, CustomHostnameEditParamsSSLBundleMethodForce: - return true - } - return false -} - // The Certificate Authority that will issue the certificate type CustomHostnameEditParamsSSLCertificateAuthority string @@ -2124,23 +1852,6 @@ func (r CustomHostnameEditParamsSSLCertificateAuthority) IsKnown() bool { return false } -// Domain control validation (DCV) method used for this hostname. -type CustomHostnameEditParamsSSLMethod string - -const ( - CustomHostnameEditParamsSSLMethodHTTP CustomHostnameEditParamsSSLMethod = "http" - CustomHostnameEditParamsSSLMethodTXT CustomHostnameEditParamsSSLMethod = "txt" - CustomHostnameEditParamsSSLMethodEmail CustomHostnameEditParamsSSLMethod = "email" -) - -func (r CustomHostnameEditParamsSSLMethod) IsKnown() bool { - switch r { - case CustomHostnameEditParamsSSLMethodHTTP, CustomHostnameEditParamsSSLMethodTXT, CustomHostnameEditParamsSSLMethodEmail: - return true - } - return false -} - // SSL specific settings. type CustomHostnameEditParamsSSLSettings struct { // An allowlist of ciphers for TLS termination. These ciphers must be in the @@ -2226,26 +1937,10 @@ func (r CustomHostnameEditParamsSSLSettingsTLS1_3) IsKnown() bool { return false } -// Level of validation to be used for this hostname. Domain validation (dv) must be -// used. -type CustomHostnameEditParamsSSLType string - -const ( - CustomHostnameEditParamsSSLTypeDv CustomHostnameEditParamsSSLType = "dv" -) - -func (r CustomHostnameEditParamsSSLType) IsKnown() bool { - switch r { - case CustomHostnameEditParamsSSLTypeDv: - return true - } - return false -} - type CustomHostnameEditResponseEnvelope struct { - Errors []CustomHostnameEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomHostnameEditResponseEnvelopeMessages `json:"messages,required"` - Result CustomHostnameEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomHostnameEditResponse `json:"result,required"` // Whether the API call was successful Success CustomHostnameEditResponseEnvelopeSuccess `json:"success,required"` JSON customHostnameEditResponseEnvelopeJSON `json:"-"` @@ -2270,52 +1965,6 @@ func (r customHostnameEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomHostnameEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// customHostnameEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomHostnameEditResponseEnvelopeErrors] -type customHostnameEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// customHostnameEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomHostnameEditResponseEnvelopeMessages] -type customHostnameEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomHostnameEditResponseEnvelopeSuccess bool @@ -2337,9 +1986,9 @@ type CustomHostnameGetParams struct { } type CustomHostnameGetResponseEnvelope struct { - Errors []CustomHostnameGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomHostnameGetResponseEnvelopeMessages `json:"messages,required"` - Result CustomHostnameGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomHostnameGetResponse `json:"result,required"` // Whether the API call was successful Success CustomHostnameGetResponseEnvelopeSuccess `json:"success,required"` JSON customHostnameGetResponseEnvelopeJSON `json:"-"` @@ -2364,52 +2013,6 @@ func (r customHostnameGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomHostnameGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// customHostnameGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomHostnameGetResponseEnvelopeErrors] -type customHostnameGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// customHostnameGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CustomHostnameGetResponseEnvelopeMessages] -type customHostnameGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomHostnameGetResponseEnvelopeSuccess bool diff --git a/custom_hostnames/customhostname_test.go b/custom_hostnames/customhostname_test.go index fe1e67665c6..6ae3aeefb07 100644 --- a/custom_hostnames/customhostname_test.go +++ b/custom_hostnames/customhostname_test.go @@ -32,11 +32,11 @@ func TestCustomHostnameNewWithOptionalParams(t *testing.T) { ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Hostname: cloudflare.F("app.example.com"), SSL: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSL{ - BundleMethod: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLBundleMethodUbiquitous), + BundleMethod: cloudflare.F(custom_hostnames.BundleMethodUbiquitous), CertificateAuthority: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLCertificateAuthorityGoogle), CustomCertificate: cloudflare.F("-----BEGIN CERTIFICATE-----\\nMIIFJDCCBAygAwIBAgIQD0ifmj/Yi5NP/2gdUySbfzANBgkqhkiG9w0BAQsFADBN\\nMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E...SzSHfXp5lnu/3V08I72q1QNzOCgY1XeL4GKVcj4or6cT6tX6oJH7ePPmfrBfqI/O\\nOeH8gMJ+FuwtXYEPa4hBf38M5eU5xWG7\\n-----END CERTIFICATE-----\\n"), CustomKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), - Method: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLMethodHTTP), + Method: cloudflare.F(custom_hostnames.DCVMethodHTTP), Settings: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettings{ Ciphers: cloudflare.F([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"}), EarlyHints: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsEarlyHintsOn), @@ -44,7 +44,7 @@ func TestCustomHostnameNewWithOptionalParams(t *testing.T) { MinTLSVersion: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsMinTLSVersion1_2), TLS1_3: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsTLS1_3On), }), - Type: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLTypeDv), + Type: cloudflare.F(custom_hostnames.DomainValidationTypeDv), Wildcard: cloudflare.F(false), }), CustomMetadata: cloudflare.F(custom_hostnames.CustomHostnameNewParamsCustomMetadata{ @@ -112,6 +112,7 @@ func TestCustomHostnameDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", custom_hostnames.CustomHostnameDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -148,11 +149,11 @@ func TestCustomHostnameEditWithOptionalParams(t *testing.T) { CustomOriginServer: cloudflare.F("origin2.example.com"), CustomOriginSni: cloudflare.F("sni.example.com"), SSL: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSL{ - BundleMethod: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLBundleMethodUbiquitous), + BundleMethod: cloudflare.F(custom_hostnames.BundleMethodUbiquitous), CertificateAuthority: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLCertificateAuthorityGoogle), CustomCertificate: cloudflare.F("-----BEGIN CERTIFICATE-----\\nMIIFJDCCBAygAwIBAgIQD0ifmj/Yi5NP/2gdUySbfzANBgkqhkiG9w0BAQsFADBN\\nMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E...SzSHfXp5lnu/3V08I72q1QNzOCgY1XeL4GKVcj4or6cT6tX6oJH7ePPmfrBfqI/O\\nOeH8gMJ+FuwtXYEPa4hBf38M5eU5xWG7\\n-----END CERTIFICATE-----\\n"), CustomKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), - Method: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLMethodHTTP), + Method: cloudflare.F(custom_hostnames.DCVMethodHTTP), Settings: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettings{ Ciphers: cloudflare.F([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"}), EarlyHints: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettingsEarlyHintsOn), @@ -160,7 +161,7 @@ func TestCustomHostnameEditWithOptionalParams(t *testing.T) { MinTLSVersion: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettingsMinTLSVersion1_2), TLS1_3: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettingsTLS1_3On), }), - Type: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLTypeDv), + Type: cloudflare.F(custom_hostnames.DomainValidationTypeDv), Wildcard: cloudflare.F(false), }), }, diff --git a/custom_hostnames/fallbackorigin.go b/custom_hostnames/fallbackorigin.go index 3287a414c22..d63acaa3359 100644 --- a/custom_hostnames/fallbackorigin.go +++ b/custom_hostnames/fallbackorigin.go @@ -35,7 +35,7 @@ func NewFallbackOriginService(opts ...option.RequestOption) (r *FallbackOriginSe } // Update Fallback Origin for Custom Hostnames -func (r *FallbackOriginService) Update(ctx context.Context, params FallbackOriginUpdateParams, opts ...option.RequestOption) (res *FallbackOriginUpdateResponse, err error) { +func (r *FallbackOriginService) Update(ctx context.Context, params FallbackOriginUpdateParams, opts ...option.RequestOption) (res *FallbackOriginUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env FallbackOriginUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", params.ZoneID) @@ -48,10 +48,10 @@ func (r *FallbackOriginService) Update(ctx context.Context, params FallbackOrigi } // Delete Fallback Origin for Custom Hostnames -func (r *FallbackOriginService) Delete(ctx context.Context, body FallbackOriginDeleteParams, opts ...option.RequestOption) (res *FallbackOriginDeleteResponse, err error) { +func (r *FallbackOriginService) Delete(ctx context.Context, params FallbackOriginDeleteParams, opts ...option.RequestOption) (res *FallbackOriginDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env FallbackOriginDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", body.ZoneID) + path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -61,7 +61,7 @@ func (r *FallbackOriginService) Delete(ctx context.Context, body FallbackOriginD } // Get Fallback Origin for Custom Hostnames -func (r *FallbackOriginService) Get(ctx context.Context, query FallbackOriginGetParams, opts ...option.RequestOption) (res *FallbackOriginGetResponse, err error) { +func (r *FallbackOriginService) Get(ctx context.Context, query FallbackOriginGetParams, opts ...option.RequestOption) (res *FallbackOriginGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env FallbackOriginGetResponseEnvelope path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", query.ZoneID) @@ -75,13 +75,13 @@ func (r *FallbackOriginService) Get(ctx context.Context, query FallbackOriginGet // Union satisfied by [custom_hostnames.FallbackOriginUpdateResponseUnknown] or // [shared.UnionString]. -type FallbackOriginUpdateResponse interface { - ImplementsCustomHostnamesFallbackOriginUpdateResponse() +type FallbackOriginUpdateResponseUnion interface { + ImplementsCustomHostnamesFallbackOriginUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*FallbackOriginUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*FallbackOriginUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -92,13 +92,13 @@ func init() { // Union satisfied by [custom_hostnames.FallbackOriginDeleteResponseUnknown] or // [shared.UnionString]. -type FallbackOriginDeleteResponse interface { - ImplementsCustomHostnamesFallbackOriginDeleteResponse() +type FallbackOriginDeleteResponseUnion interface { + ImplementsCustomHostnamesFallbackOriginDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*FallbackOriginDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*FallbackOriginDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -109,13 +109,13 @@ func init() { // Union satisfied by [custom_hostnames.FallbackOriginGetResponseUnknown] or // [shared.UnionString]. -type FallbackOriginGetResponse interface { - ImplementsCustomHostnamesFallbackOriginGetResponse() +type FallbackOriginGetResponseUnion interface { + ImplementsCustomHostnamesFallbackOriginGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*FallbackOriginGetResponse)(nil)).Elem(), + reflect.TypeOf((*FallbackOriginGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -136,9 +136,9 @@ func (r FallbackOriginUpdateParams) MarshalJSON() (data []byte, err error) { } type FallbackOriginUpdateResponseEnvelope struct { - Errors []FallbackOriginUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FallbackOriginUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FallbackOriginUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FallbackOriginUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success FallbackOriginUpdateResponseEnvelopeSuccess `json:"success,required"` JSON fallbackOriginUpdateResponseEnvelopeJSON `json:"-"` @@ -163,52 +163,6 @@ func (r fallbackOriginUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FallbackOriginUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON fallbackOriginUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// fallbackOriginUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FallbackOriginUpdateResponseEnvelopeErrors] -type fallbackOriginUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FallbackOriginUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r fallbackOriginUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FallbackOriginUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON fallbackOriginUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// fallbackOriginUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FallbackOriginUpdateResponseEnvelopeMessages] -type fallbackOriginUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FallbackOriginUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r fallbackOriginUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FallbackOriginUpdateResponseEnvelopeSuccess bool @@ -227,12 +181,17 @@ func (r FallbackOriginUpdateResponseEnvelopeSuccess) IsKnown() bool { type FallbackOriginDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r FallbackOriginDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type FallbackOriginDeleteResponseEnvelope struct { - Errors []FallbackOriginDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FallbackOriginDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FallbackOriginDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FallbackOriginDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success FallbackOriginDeleteResponseEnvelopeSuccess `json:"success,required"` JSON fallbackOriginDeleteResponseEnvelopeJSON `json:"-"` @@ -257,52 +216,6 @@ func (r fallbackOriginDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FallbackOriginDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON fallbackOriginDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// fallbackOriginDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FallbackOriginDeleteResponseEnvelopeErrors] -type fallbackOriginDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FallbackOriginDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r fallbackOriginDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FallbackOriginDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON fallbackOriginDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// fallbackOriginDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FallbackOriginDeleteResponseEnvelopeMessages] -type fallbackOriginDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FallbackOriginDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r fallbackOriginDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FallbackOriginDeleteResponseEnvelopeSuccess bool @@ -324,9 +237,9 @@ type FallbackOriginGetParams struct { } type FallbackOriginGetResponseEnvelope struct { - Errors []FallbackOriginGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FallbackOriginGetResponseEnvelopeMessages `json:"messages,required"` - Result FallbackOriginGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FallbackOriginGetResponseUnion `json:"result,required"` // Whether the API call was successful Success FallbackOriginGetResponseEnvelopeSuccess `json:"success,required"` JSON fallbackOriginGetResponseEnvelopeJSON `json:"-"` @@ -351,52 +264,6 @@ func (r fallbackOriginGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FallbackOriginGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON fallbackOriginGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// fallbackOriginGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FallbackOriginGetResponseEnvelopeErrors] -type fallbackOriginGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FallbackOriginGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r fallbackOriginGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FallbackOriginGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON fallbackOriginGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// fallbackOriginGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FallbackOriginGetResponseEnvelopeMessages] -type fallbackOriginGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FallbackOriginGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r fallbackOriginGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FallbackOriginGetResponseEnvelopeSuccess bool diff --git a/custom_hostnames/fallbackorigin_test.go b/custom_hostnames/fallbackorigin_test.go index 1e2de9182a9..988da10cf65 100644 --- a/custom_hostnames/fallbackorigin_test.go +++ b/custom_hostnames/fallbackorigin_test.go @@ -57,6 +57,7 @@ func TestFallbackOriginDelete(t *testing.T) { ) _, err := client.CustomHostnames.FallbackOrigin.Delete(context.TODO(), custom_hostnames.FallbackOriginDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/custom_nameservers/aliases.go b/custom_nameservers/aliases.go index a7c773e0f4e..204a2ba1824 100644 --- a/custom_nameservers/aliases.go +++ b/custom_nameservers/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/custom_nameservers/customnameserver.go b/custom_nameservers/customnameserver.go index 48af5ebb5f6..67dfa7ba459 100644 --- a/custom_nameservers/customnameserver.go +++ b/custom_nameservers/customnameserver.go @@ -48,10 +48,10 @@ func (r *CustomNameserverService) New(ctx context.Context, params CustomNameserv } // Delete Account Custom Nameserver -func (r *CustomNameserverService) Delete(ctx context.Context, customNSID string, body CustomNameserverDeleteParams, opts ...option.RequestOption) (res *CustomNameserverDeleteResponse, err error) { +func (r *CustomNameserverService) Delete(ctx context.Context, customNSID string, params CustomNameserverDeleteParams, opts ...option.RequestOption) (res *CustomNameserverDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CustomNameserverDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/custom_ns/%s", body.AccountID, customNSID) + path := fmt.Sprintf("accounts/%s/custom_ns/%s", params.AccountID, customNSID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -87,10 +87,10 @@ func (r *CustomNameserverService) Get(ctx context.Context, query CustomNameserve } // Verify Account Custom Nameserver Glue Records -func (r *CustomNameserverService) Verify(ctx context.Context, body CustomNameserverVerifyParams, opts ...option.RequestOption) (res *[]CustomNameserver, err error) { +func (r *CustomNameserverService) Verify(ctx context.Context, params CustomNameserverVerifyParams, opts ...option.RequestOption) (res *[]CustomNameserver, err error) { opts = append(r.Options[:], opts...) var env CustomNameserverVerifyResponseEnvelope - path := fmt.Sprintf("accounts/%s/custom_ns/verify", body.AccountID) + path := fmt.Sprintf("accounts/%s/custom_ns/verify", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -195,13 +195,13 @@ func (r CustomNameserverStatus) IsKnown() bool { // Union satisfied by [custom_nameservers.CustomNameserverDeleteResponseUnknown], // [custom_nameservers.CustomNameserverDeleteResponseArray] or // [shared.UnionString]. -type CustomNameserverDeleteResponse interface { - ImplementsCustomNameserversCustomNameserverDeleteResponse() +type CustomNameserverDeleteResponseUnion interface { + ImplementsCustomNameserversCustomNameserverDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CustomNameserverDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*CustomNameserverDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -216,7 +216,7 @@ func init() { type CustomNameserverDeleteResponseArray []interface{} -func (r CustomNameserverDeleteResponseArray) ImplementsCustomNameserversCustomNameserverDeleteResponse() { +func (r CustomNameserverDeleteResponseArray) ImplementsCustomNameserversCustomNameserverDeleteResponseUnion() { } type CustomNameserverNewParams struct { @@ -233,8 +233,8 @@ func (r CustomNameserverNewParams) MarshalJSON() (data []byte, err error) { } type CustomNameserverNewResponseEnvelope struct { - Errors []CustomNameserverNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A single account custom nameserver. Result CustomNameserver `json:"result,required"` // Whether the API call was successful @@ -261,52 +261,6 @@ func (r customNameserverNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomNameserverNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomNameserverNewResponseEnvelopeErrors] -type customNameserverNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomNameserverNewResponseEnvelopeMessages] -type customNameserverNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomNameserverNewResponseEnvelopeSuccess bool @@ -325,12 +279,17 @@ func (r CustomNameserverNewResponseEnvelopeSuccess) IsKnown() bool { type CustomNameserverDeleteParams struct { // Account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CustomNameserverDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CustomNameserverDeleteResponseEnvelope struct { - Errors []CustomNameserverDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CustomNameserverDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomNameserverDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success CustomNameserverDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo CustomNameserverDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -357,52 +316,6 @@ func (r customNameserverDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomNameserverDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomNameserverDeleteResponseEnvelopeErrors] -type customNameserverDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CustomNameserverDeleteResponseEnvelopeMessages] -type customNameserverDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomNameserverDeleteResponseEnvelopeSuccess bool @@ -455,9 +368,9 @@ type CustomNameserverAvailabiltyParams struct { } type CustomNameserverAvailabiltyResponseEnvelope struct { - Errors []CustomNameserverAvailabiltyResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverAvailabiltyResponseEnvelopeMessages `json:"messages,required"` - Result []string `json:"result,required,nullable" format:"hostname"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []string `json:"result,required,nullable" format:"hostname"` // Whether the API call was successful Success CustomNameserverAvailabiltyResponseEnvelopeSuccess `json:"success,required"` ResultInfo CustomNameserverAvailabiltyResponseEnvelopeResultInfo `json:"result_info"` @@ -484,52 +397,6 @@ func (r customNameserverAvailabiltyResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomNameserverAvailabiltyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverAvailabiltyResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverAvailabiltyResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CustomNameserverAvailabiltyResponseEnvelopeErrors] -type customNameserverAvailabiltyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverAvailabiltyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverAvailabiltyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverAvailabiltyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverAvailabiltyResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverAvailabiltyResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CustomNameserverAvailabiltyResponseEnvelopeMessages] -type customNameserverAvailabiltyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverAvailabiltyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverAvailabiltyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomNameserverAvailabiltyResponseEnvelopeSuccess bool @@ -582,9 +449,9 @@ type CustomNameserverGetParams struct { } type CustomNameserverGetResponseEnvelope struct { - Errors []CustomNameserverGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverGetResponseEnvelopeMessages `json:"messages,required"` - Result []CustomNameserver `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []CustomNameserver `json:"result,required,nullable"` // Whether the API call was successful Success CustomNameserverGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo CustomNameserverGetResponseEnvelopeResultInfo `json:"result_info"` @@ -611,52 +478,6 @@ func (r customNameserverGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomNameserverGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomNameserverGetResponseEnvelopeErrors] -type customNameserverGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomNameserverGetResponseEnvelopeMessages] -type customNameserverGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomNameserverGetResponseEnvelopeSuccess bool @@ -706,12 +527,17 @@ func (r customNameserverGetResponseEnvelopeResultInfoJSON) RawJSON() string { type CustomNameserverVerifyParams struct { // Account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CustomNameserverVerifyParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CustomNameserverVerifyResponseEnvelope struct { - Errors []CustomNameserverVerifyResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverVerifyResponseEnvelopeMessages `json:"messages,required"` - Result []CustomNameserver `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []CustomNameserver `json:"result,required,nullable"` // Whether the API call was successful Success CustomNameserverVerifyResponseEnvelopeSuccess `json:"success,required"` ResultInfo CustomNameserverVerifyResponseEnvelopeResultInfo `json:"result_info"` @@ -738,52 +564,6 @@ func (r customNameserverVerifyResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomNameserverVerifyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverVerifyResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverVerifyResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomNameserverVerifyResponseEnvelopeErrors] -type customNameserverVerifyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverVerifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverVerifyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverVerifyResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverVerifyResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CustomNameserverVerifyResponseEnvelopeMessages] -type customNameserverVerifyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverVerifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomNameserverVerifyResponseEnvelopeSuccess bool diff --git a/custom_nameservers/customnameserver_test.go b/custom_nameservers/customnameserver_test.go index a4e93a017b4..7d9df3e08e4 100644 --- a/custom_nameservers/customnameserver_test.go +++ b/custom_nameservers/customnameserver_test.go @@ -61,6 +61,7 @@ func TestCustomNameserverDelete(t *testing.T) { "ns1.example.com", custom_nameservers.CustomNameserverDeleteParams{ AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -140,6 +141,7 @@ func TestCustomNameserverVerify(t *testing.T) { ) _, err := client.CustomNameservers.Verify(context.TODO(), custom_nameservers.CustomNameserverVerifyParams{ AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/d1/aliases.go b/d1/aliases.go index 9977bb75962..d40b4c6ed39 100644 --- a/d1/aliases.go +++ b/d1/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/d1/d1.go b/d1/d1.go index 276eb33647c..93e165ca50f 100644 --- a/d1/d1.go +++ b/d1/d1.go @@ -3,6 +3,7 @@ package d1 import ( + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -24,3 +25,35 @@ func NewD1Service(opts ...option.RequestOption) (r *D1Service) { r.Database = NewDatabaseService(opts...) return } + +type D1 struct { + // Specifies the timestamp the resource was created as an ISO8601 string. + CreatedAt string `json:"created_at"` + // The D1 database's size, in bytes. + FileSize float64 `json:"file_size"` + Name string `json:"name"` + NumTables float64 `json:"num_tables"` + UUID string `json:"uuid"` + Version string `json:"version"` + JSON d1JSON `json:"-"` +} + +// d1JSON contains the JSON metadata for the struct [D1] +type d1JSON struct { + CreatedAt apijson.Field + FileSize apijson.Field + Name apijson.Field + NumTables apijson.Field + UUID apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *D1) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r d1JSON) RawJSON() string { + return r.raw +} diff --git a/d1/database.go b/d1/database.go index 94944aa3e3e..a37699d1b82 100644 --- a/d1/database.go +++ b/d1/database.go @@ -37,7 +37,7 @@ func NewDatabaseService(opts ...option.RequestOption) (r *DatabaseService) { } // Returns the created D1 database. -func (r *DatabaseService) New(ctx context.Context, params DatabaseNewParams, opts ...option.RequestOption) (res *D1CreateDatabase, err error) { +func (r *DatabaseService) New(ctx context.Context, params DatabaseNewParams, opts ...option.RequestOption) (res *DatabaseNewResponse, err error) { opts = append(r.Options[:], opts...) var env DatabaseNewResponseEnvelope path := fmt.Sprintf("accounts/%s/d1/database", params.AccountID) @@ -50,7 +50,7 @@ func (r *DatabaseService) New(ctx context.Context, params DatabaseNewParams, opt } // Returns a list of D1 databases. -func (r *DatabaseService) List(ctx context.Context, params DatabaseListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[D1CreateDatabase], err error) { +func (r *DatabaseService) List(ctx context.Context, params DatabaseListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DatabaseListResponse], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -68,12 +68,12 @@ func (r *DatabaseService) List(ctx context.Context, params DatabaseListParams, o } // Returns a list of D1 databases. -func (r *DatabaseService) ListAutoPaging(ctx context.Context, params DatabaseListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[D1CreateDatabase] { +func (r *DatabaseService) ListAutoPaging(ctx context.Context, params DatabaseListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DatabaseListResponse] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } // Deletes the specified D1 database. -func (r *DatabaseService) Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *DatabaseDeleteResponse, err error) { +func (r *DatabaseService) Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *DatabaseDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DatabaseDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/d1/database/%s", accountIdentifier, databaseIdentifier) @@ -86,7 +86,7 @@ func (r *DatabaseService) Delete(ctx context.Context, accountIdentifier string, } // Returns the specified D1 database. -func (r *DatabaseService) Get(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *D1DatabaseDetails, err error) { +func (r *DatabaseService) Get(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *D1, err error) { opts = append(r.Options[:], opts...) var env DatabaseGetResponseEnvelope path := fmt.Sprintf("accounts/%s/d1/database/%s", accountIdentifier, databaseIdentifier) @@ -99,7 +99,7 @@ func (r *DatabaseService) Get(ctx context.Context, accountIdentifier string, dat } // Returns the query result. -func (r *DatabaseService) Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body DatabaseQueryParams, opts ...option.RequestOption) (res *[]D1QueryResult, err error) { +func (r *DatabaseService) Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body DatabaseQueryParams, opts ...option.RequestOption) (res *[]QueryResult, err error) { opts = append(r.Options[:], opts...) var env DatabaseQueryResponseEnvelope path := fmt.Sprintf("accounts/%s/d1/database/%s/query", accountIdentifier, databaseIdentifier) @@ -111,132 +111,126 @@ func (r *DatabaseService) Query(ctx context.Context, accountIdentifier string, d return } -type D1CreateDatabase struct { - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedAt string `json:"created_at"` - Name string `json:"name"` - UUID string `json:"uuid"` - Version string `json:"version"` - JSON d1CreateDatabaseJSON `json:"-"` +type QueryResult struct { + Meta QueryResultMeta `json:"meta"` + Results []interface{} `json:"results"` + Success bool `json:"success"` + JSON queryResultJSON `json:"-"` } -// d1CreateDatabaseJSON contains the JSON metadata for the struct -// [D1CreateDatabase] -type d1CreateDatabaseJSON struct { - CreatedAt apijson.Field - Name apijson.Field - UUID apijson.Field - Version apijson.Field +// queryResultJSON contains the JSON metadata for the struct [QueryResult] +type queryResultJSON struct { + Meta apijson.Field + Results apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *D1CreateDatabase) UnmarshalJSON(data []byte) (err error) { +func (r *QueryResult) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r d1CreateDatabaseJSON) RawJSON() string { +func (r queryResultJSON) RawJSON() string { return r.raw } -type D1DatabaseDetails struct { - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedAt string `json:"created_at"` - // The D1 database's size, in bytes. - FileSize float64 `json:"file_size"` - Name string `json:"name"` - NumTables float64 `json:"num_tables"` - UUID string `json:"uuid"` - Version string `json:"version"` - JSON d1DatabaseDetailsJSON `json:"-"` -} - -// d1DatabaseDetailsJSON contains the JSON metadata for the struct -// [D1DatabaseDetails] -type d1DatabaseDetailsJSON struct { - CreatedAt apijson.Field - FileSize apijson.Field - Name apijson.Field - NumTables apijson.Field - UUID apijson.Field - Version apijson.Field +type QueryResultMeta struct { + ChangedDB bool `json:"changed_db"` + Changes float64 `json:"changes"` + Duration float64 `json:"duration"` + LastRowID float64 `json:"last_row_id"` + RowsRead float64 `json:"rows_read"` + RowsWritten float64 `json:"rows_written"` + SizeAfter float64 `json:"size_after"` + JSON queryResultMetaJSON `json:"-"` +} + +// queryResultMetaJSON contains the JSON metadata for the struct [QueryResultMeta] +type queryResultMetaJSON struct { + ChangedDB apijson.Field + Changes apijson.Field + Duration apijson.Field + LastRowID apijson.Field + RowsRead apijson.Field + RowsWritten apijson.Field + SizeAfter apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *D1DatabaseDetails) UnmarshalJSON(data []byte) (err error) { +func (r *QueryResultMeta) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r d1DatabaseDetailsJSON) RawJSON() string { +func (r queryResultMetaJSON) RawJSON() string { return r.raw } -type D1QueryResult struct { - Meta D1QueryResultMeta `json:"meta"` - Results []interface{} `json:"results"` - Success bool `json:"success"` - JSON d1QueryResultJSON `json:"-"` +type DatabaseNewResponse struct { + // Specifies the timestamp the resource was created as an ISO8601 string. + CreatedAt string `json:"created_at"` + Name string `json:"name"` + UUID string `json:"uuid"` + Version string `json:"version"` + JSON databaseNewResponseJSON `json:"-"` } -// d1QueryResultJSON contains the JSON metadata for the struct [D1QueryResult] -type d1QueryResultJSON struct { - Meta apijson.Field - Results apijson.Field - Success apijson.Field +// databaseNewResponseJSON contains the JSON metadata for the struct +// [DatabaseNewResponse] +type databaseNewResponseJSON struct { + CreatedAt apijson.Field + Name apijson.Field + UUID apijson.Field + Version apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *D1QueryResult) UnmarshalJSON(data []byte) (err error) { +func (r *DatabaseNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r d1QueryResultJSON) RawJSON() string { +func (r databaseNewResponseJSON) RawJSON() string { return r.raw } -type D1QueryResultMeta struct { - ChangedDB bool `json:"changed_db"` - Changes float64 `json:"changes"` - Duration float64 `json:"duration"` - LastRowID float64 `json:"last_row_id"` - RowsRead float64 `json:"rows_read"` - RowsWritten float64 `json:"rows_written"` - SizeAfter float64 `json:"size_after"` - JSON d1QueryResultMetaJSON `json:"-"` +type DatabaseListResponse struct { + // Specifies the timestamp the resource was created as an ISO8601 string. + CreatedAt string `json:"created_at"` + Name string `json:"name"` + UUID string `json:"uuid"` + Version string `json:"version"` + JSON databaseListResponseJSON `json:"-"` } -// d1QueryResultMetaJSON contains the JSON metadata for the struct -// [D1QueryResultMeta] -type d1QueryResultMetaJSON struct { - ChangedDB apijson.Field - Changes apijson.Field - Duration apijson.Field - LastRowID apijson.Field - RowsRead apijson.Field - RowsWritten apijson.Field - SizeAfter apijson.Field +// databaseListResponseJSON contains the JSON metadata for the struct +// [DatabaseListResponse] +type databaseListResponseJSON struct { + CreatedAt apijson.Field + Name apijson.Field + UUID apijson.Field + Version apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *D1QueryResultMeta) UnmarshalJSON(data []byte) (err error) { +func (r *DatabaseListResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r d1QueryResultMetaJSON) RawJSON() string { +func (r databaseListResponseJSON) RawJSON() string { return r.raw } // Union satisfied by [d1.DatabaseDeleteResponseUnknown] or [shared.UnionString]. -type DatabaseDeleteResponse interface { - ImplementsD1DatabaseDeleteResponse() +type DatabaseDeleteResponseUnion interface { + ImplementsD1DatabaseDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DatabaseDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*DatabaseDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -256,9 +250,9 @@ func (r DatabaseNewParams) MarshalJSON() (data []byte, err error) { } type DatabaseNewResponseEnvelope struct { - Errors []DatabaseNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DatabaseNewResponseEnvelopeMessages `json:"messages,required"` - Result D1CreateDatabase `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DatabaseNewResponse `json:"result,required"` // Whether the API call was successful Success DatabaseNewResponseEnvelopeSuccess `json:"success,required"` JSON databaseNewResponseEnvelopeJSON `json:"-"` @@ -283,52 +277,6 @@ func (r databaseNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DatabaseNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// databaseNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DatabaseNewResponseEnvelopeErrors] -type databaseNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DatabaseNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// databaseNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DatabaseNewResponseEnvelopeMessages] -type databaseNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DatabaseNewResponseEnvelopeSuccess bool @@ -358,15 +306,15 @@ type DatabaseListParams struct { // URLQuery serializes [DatabaseListParams]'s query parameters as `url.Values`. func (r DatabaseListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DatabaseDeleteResponseEnvelope struct { - Errors []DatabaseDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DatabaseDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DatabaseDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DatabaseDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success DatabaseDeleteResponseEnvelopeSuccess `json:"success,required"` JSON databaseDeleteResponseEnvelopeJSON `json:"-"` @@ -391,52 +339,6 @@ func (r databaseDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DatabaseDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// databaseDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DatabaseDeleteResponseEnvelopeErrors] -type databaseDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DatabaseDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// databaseDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DatabaseDeleteResponseEnvelopeMessages] -type databaseDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DatabaseDeleteResponseEnvelopeSuccess bool @@ -453,9 +355,9 @@ func (r DatabaseDeleteResponseEnvelopeSuccess) IsKnown() bool { } type DatabaseGetResponseEnvelope struct { - Errors []DatabaseGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DatabaseGetResponseEnvelopeMessages `json:"messages,required"` - Result D1DatabaseDetails `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result D1 `json:"result,required"` // Whether the API call was successful Success DatabaseGetResponseEnvelopeSuccess `json:"success,required"` JSON databaseGetResponseEnvelopeJSON `json:"-"` @@ -480,52 +382,6 @@ func (r databaseGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DatabaseGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// databaseGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DatabaseGetResponseEnvelopeErrors] -type databaseGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DatabaseGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// databaseGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DatabaseGetResponseEnvelopeMessages] -type databaseGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DatabaseGetResponseEnvelopeSuccess bool @@ -551,9 +407,9 @@ func (r DatabaseQueryParams) MarshalJSON() (data []byte, err error) { } type DatabaseQueryResponseEnvelope struct { - Errors []DatabaseQueryResponseEnvelopeErrors `json:"errors,required"` - Messages []DatabaseQueryResponseEnvelopeMessages `json:"messages,required"` - Result []D1QueryResult `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []QueryResult `json:"result,required"` // Whether the API call was successful Success DatabaseQueryResponseEnvelopeSuccess `json:"success,required"` JSON databaseQueryResponseEnvelopeJSON `json:"-"` @@ -578,52 +434,6 @@ func (r databaseQueryResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DatabaseQueryResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseQueryResponseEnvelopeErrorsJSON `json:"-"` -} - -// databaseQueryResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DatabaseQueryResponseEnvelopeErrors] -type databaseQueryResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseQueryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseQueryResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DatabaseQueryResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON databaseQueryResponseEnvelopeMessagesJSON `json:"-"` -} - -// databaseQueryResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DatabaseQueryResponseEnvelopeMessages] -type databaseQueryResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatabaseQueryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r databaseQueryResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DatabaseQueryResponseEnvelopeSuccess bool diff --git a/dcv_delegation/aliases.go b/dcv_delegation/aliases.go index d0fdbd58451..adad4bfa5f5 100644 --- a/dcv_delegation/aliases.go +++ b/dcv_delegation/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/dcv_delegation/uuid.go b/dcv_delegation/uuid.go index e2c6663cd1c..6e51a39cc9a 100644 --- a/dcv_delegation/uuid.go +++ b/dcv_delegation/uuid.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -72,9 +73,9 @@ type UUIDGetParams struct { } type UUIDGetResponseEnvelope struct { - Errors []UUIDGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UUIDGetResponseEnvelopeMessages `json:"messages,required"` - Result DCVDelegationUUID `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DCVDelegationUUID `json:"result,required"` // Whether the API call was successful Success UUIDGetResponseEnvelopeSuccess `json:"success,required"` JSON uuidGetResponseEnvelopeJSON `json:"-"` @@ -99,52 +100,6 @@ func (r uuidGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UUIDGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uuidGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// uuidGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UUIDGetResponseEnvelopeErrors] -type uuidGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UUIDGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uuidGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UUIDGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uuidGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// uuidGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [UUIDGetResponseEnvelopeMessages] -type uuidGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UUIDGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uuidGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UUIDGetResponseEnvelopeSuccess bool diff --git a/diagnostics/aliases.go b/diagnostics/aliases.go index d1fe6d66be7..3913b5b5551 100644 --- a/diagnostics/aliases.go +++ b/diagnostics/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/diagnostics/traceroute.go b/diagnostics/traceroute.go index 16c042602d0..44e880a10ad 100644 --- a/diagnostics/traceroute.go +++ b/diagnostics/traceroute.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,7 +32,7 @@ func NewTracerouteService(opts ...option.RequestOption) (r *TracerouteService) { } // Run traceroutes from Cloudflare colos. -func (r *TracerouteService) New(ctx context.Context, params TracerouteNewParams, opts ...option.RequestOption) (res *[]MagicTransitTargetResult, err error) { +func (r *TracerouteService) New(ctx context.Context, params TracerouteNewParams, opts ...option.RequestOption) (res *[]Traceroute, err error) { opts = append(r.Options[:], opts...) var env TracerouteNewResponseEnvelope path := fmt.Sprintf("accounts/%s/diagnostics/traceroute", params.AccountID) @@ -43,45 +44,43 @@ func (r *TracerouteService) New(ctx context.Context, params TracerouteNewParams, return } -type MagicTransitTargetResult struct { - Colos []MagicTransitTargetResultColo `json:"colos"` +type Traceroute struct { + Colos []TracerouteColo `json:"colos"` // The target hostname, IPv6, or IPv6 address. - Target string `json:"target"` - JSON magicTransitTargetResultJSON `json:"-"` + Target string `json:"target"` + JSON tracerouteJSON `json:"-"` } -// magicTransitTargetResultJSON contains the JSON metadata for the struct -// [MagicTransitTargetResult] -type magicTransitTargetResultJSON struct { +// tracerouteJSON contains the JSON metadata for the struct [Traceroute] +type tracerouteJSON struct { Colos apijson.Field Target apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *MagicTransitTargetResult) UnmarshalJSON(data []byte) (err error) { +func (r *Traceroute) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicTransitTargetResultJSON) RawJSON() string { +func (r tracerouteJSON) RawJSON() string { return r.raw } -type MagicTransitTargetResultColo struct { - Colo MagicTransitTargetResultColosColo `json:"colo"` +type TracerouteColo struct { + Colo TracerouteColosColo `json:"colo"` // Errors resulting from collecting traceroute from colo to target. - Error MagicTransitTargetResultColosError `json:"error"` - Hops []MagicTransitTargetResultColosHop `json:"hops"` + Error TracerouteColosError `json:"error"` + Hops []TracerouteColosHop `json:"hops"` // Aggregated statistics from all hops about the target. TargetSummary interface{} `json:"target_summary"` // Total time of traceroute in ms. - TracerouteTimeMs int64 `json:"traceroute_time_ms"` - JSON magicTransitTargetResultColoJSON `json:"-"` + TracerouteTimeMs int64 `json:"traceroute_time_ms"` + JSON tracerouteColoJSON `json:"-"` } -// magicTransitTargetResultColoJSON contains the JSON metadata for the struct -// [MagicTransitTargetResultColo] -type magicTransitTargetResultColoJSON struct { +// tracerouteColoJSON contains the JSON metadata for the struct [TracerouteColo] +type tracerouteColoJSON struct { Colo apijson.Field Error apijson.Field Hops apijson.Field @@ -91,73 +90,73 @@ type magicTransitTargetResultColoJSON struct { ExtraFields map[string]apijson.Field } -func (r *MagicTransitTargetResultColo) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteColo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicTransitTargetResultColoJSON) RawJSON() string { +func (r tracerouteColoJSON) RawJSON() string { return r.raw } -type MagicTransitTargetResultColosColo struct { +type TracerouteColosColo struct { // Source colo city. City string `json:"city"` // Source colo name. - Name string `json:"name"` - JSON magicTransitTargetResultColosColoJSON `json:"-"` + Name string `json:"name"` + JSON tracerouteColosColoJSON `json:"-"` } -// magicTransitTargetResultColosColoJSON contains the JSON metadata for the struct -// [MagicTransitTargetResultColosColo] -type magicTransitTargetResultColosColoJSON struct { +// tracerouteColosColoJSON contains the JSON metadata for the struct +// [TracerouteColosColo] +type tracerouteColosColoJSON struct { City apijson.Field Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *MagicTransitTargetResultColosColo) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteColosColo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicTransitTargetResultColosColoJSON) RawJSON() string { +func (r tracerouteColosColoJSON) RawJSON() string { return r.raw } // Errors resulting from collecting traceroute from colo to target. -type MagicTransitTargetResultColosError string +type TracerouteColosError string const ( - MagicTransitTargetResultColosErrorEmpty MagicTransitTargetResultColosError = "" - MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode1 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 1" - MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode2 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 2" - MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode3 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 3" - MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode4 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 4" + TracerouteColosErrorEmpty TracerouteColosError = "" + TracerouteColosErrorCouldNotGatherTracerouteDataCode1 TracerouteColosError = "Could not gather traceroute data: Code 1" + TracerouteColosErrorCouldNotGatherTracerouteDataCode2 TracerouteColosError = "Could not gather traceroute data: Code 2" + TracerouteColosErrorCouldNotGatherTracerouteDataCode3 TracerouteColosError = "Could not gather traceroute data: Code 3" + TracerouteColosErrorCouldNotGatherTracerouteDataCode4 TracerouteColosError = "Could not gather traceroute data: Code 4" ) -func (r MagicTransitTargetResultColosError) IsKnown() bool { +func (r TracerouteColosError) IsKnown() bool { switch r { - case MagicTransitTargetResultColosErrorEmpty, MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode1, MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode2, MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode3, MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode4: + case TracerouteColosErrorEmpty, TracerouteColosErrorCouldNotGatherTracerouteDataCode1, TracerouteColosErrorCouldNotGatherTracerouteDataCode2, TracerouteColosErrorCouldNotGatherTracerouteDataCode3, TracerouteColosErrorCouldNotGatherTracerouteDataCode4: return true } return false } -type MagicTransitTargetResultColosHop struct { +type TracerouteColosHop struct { // An array of node objects. - Nodes []MagicTransitTargetResultColosHopsNode `json:"nodes"` + Nodes []TracerouteColosHopsNode `json:"nodes"` // Number of packets where no response was received. PacketsLost int64 `json:"packets_lost"` // Number of packets sent with specified TTL. PacketsSent int64 `json:"packets_sent"` // The time to live (TTL). - PacketsTTL int64 `json:"packets_ttl"` - JSON magicTransitTargetResultColosHopJSON `json:"-"` + PacketsTTL int64 `json:"packets_ttl"` + JSON tracerouteColosHopJSON `json:"-"` } -// magicTransitTargetResultColosHopJSON contains the JSON metadata for the struct -// [MagicTransitTargetResultColosHop] -type magicTransitTargetResultColosHopJSON struct { +// tracerouteColosHopJSON contains the JSON metadata for the struct +// [TracerouteColosHop] +type tracerouteColosHopJSON struct { Nodes apijson.Field PacketsLost apijson.Field PacketsSent apijson.Field @@ -166,15 +165,15 @@ type magicTransitTargetResultColosHopJSON struct { ExtraFields map[string]apijson.Field } -func (r *MagicTransitTargetResultColosHop) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteColosHop) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicTransitTargetResultColosHopJSON) RawJSON() string { +func (r tracerouteColosHopJSON) RawJSON() string { return r.raw } -type MagicTransitTargetResultColosHopsNode struct { +type TracerouteColosHopsNode struct { // AS number associated with the node object. ASN string `json:"asn"` // IP address of the node. @@ -194,13 +193,13 @@ type MagicTransitTargetResultColosHopsNode struct { // Number of packets with a response from this node. PacketCount int64 `json:"packet_count"` // Standard deviation of the RTTs in ms. - StdDevRTTMs float64 `json:"std_dev_rtt_ms"` - JSON magicTransitTargetResultColosHopsNodeJSON `json:"-"` + StdDevRTTMs float64 `json:"std_dev_rtt_ms"` + JSON tracerouteColosHopsNodeJSON `json:"-"` } -// magicTransitTargetResultColosHopsNodeJSON contains the JSON metadata for the -// struct [MagicTransitTargetResultColosHopsNode] -type magicTransitTargetResultColosHopsNodeJSON struct { +// tracerouteColosHopsNodeJSON contains the JSON metadata for the struct +// [TracerouteColosHopsNode] +type tracerouteColosHopsNodeJSON struct { ASN apijson.Field IP apijson.Field Labels apijson.Field @@ -214,11 +213,11 @@ type magicTransitTargetResultColosHopsNodeJSON struct { ExtraFields map[string]apijson.Field } -func (r *MagicTransitTargetResultColosHopsNode) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteColosHopsNode) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicTransitTargetResultColosHopsNodeJSON) RawJSON() string { +func (r tracerouteColosHopsNodeJSON) RawJSON() string { return r.raw } @@ -260,7 +259,7 @@ type TracerouteNewParamsOptionsPacketType string const ( TracerouteNewParamsOptionsPacketTypeIcmp TracerouteNewParamsOptionsPacketType = "icmp" - TracerouteNewParamsOptionsPacketTypeTcp TracerouteNewParamsOptionsPacketType = "tcp" + TracerouteNewParamsOptionsPacketTypeTCP TracerouteNewParamsOptionsPacketType = "tcp" TracerouteNewParamsOptionsPacketTypeUdp TracerouteNewParamsOptionsPacketType = "udp" TracerouteNewParamsOptionsPacketTypeGRE TracerouteNewParamsOptionsPacketType = "gre" TracerouteNewParamsOptionsPacketTypeGREIcmp TracerouteNewParamsOptionsPacketType = "gre+icmp" @@ -268,16 +267,16 @@ const ( func (r TracerouteNewParamsOptionsPacketType) IsKnown() bool { switch r { - case TracerouteNewParamsOptionsPacketTypeIcmp, TracerouteNewParamsOptionsPacketTypeTcp, TracerouteNewParamsOptionsPacketTypeUdp, TracerouteNewParamsOptionsPacketTypeGRE, TracerouteNewParamsOptionsPacketTypeGREIcmp: + case TracerouteNewParamsOptionsPacketTypeIcmp, TracerouteNewParamsOptionsPacketTypeTCP, TracerouteNewParamsOptionsPacketTypeUdp, TracerouteNewParamsOptionsPacketTypeGRE, TracerouteNewParamsOptionsPacketTypeGREIcmp: return true } return false } type TracerouteNewResponseEnvelope struct { - Errors []TracerouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TracerouteNewResponseEnvelopeMessages `json:"messages,required"` - Result []MagicTransitTargetResult `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Traceroute `json:"result,required,nullable"` // Whether the API call was successful Success TracerouteNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo TracerouteNewResponseEnvelopeResultInfo `json:"result_info"` @@ -304,52 +303,6 @@ func (r tracerouteNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TracerouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tracerouteNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// tracerouteNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TracerouteNewResponseEnvelopeErrors] -type tracerouteNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TracerouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tracerouteNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TracerouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tracerouteNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// tracerouteNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TracerouteNewResponseEnvelopeMessages] -type tracerouteNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TracerouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tracerouteNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TracerouteNewResponseEnvelopeSuccess bool diff --git a/dns/aliases.go b/dns/aliases.go index 9c106466985..61d93c581e4 100644 --- a/dns/aliases.go +++ b/dns/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/dns/analyticsreport.go b/dns/analyticsreport.go index c13b5f32a90..88f842719c3 100644 --- a/dns/analyticsreport.go +++ b/dns/analyticsreport.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -41,7 +42,7 @@ func NewAnalyticsReportService(opts ...option.RequestOption) (r *AnalyticsReport // See // [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) // for detailed information about the available query parameters. -func (r *AnalyticsReportService) Get(ctx context.Context, params AnalyticsReportGetParams, opts ...option.RequestOption) (res *DNSAnalyticsReport, err error) { +func (r *AnalyticsReportService) Get(ctx context.Context, params AnalyticsReportGetParams, opts ...option.RequestOption) (res *Report, err error) { opts = append(r.Options[:], opts...) var env AnalyticsReportGetResponseEnvelope path := fmt.Sprintf("zones/%s/dns_analytics/report", params.ZoneID) @@ -53,9 +54,9 @@ func (r *AnalyticsReportService) Get(ctx context.Context, params AnalyticsReport return } -type DNSAnalyticsReport struct { +type Report struct { // Array with one row per combination of dimension values. - Data []DNSAnalyticsReportData `json:"data,required"` + Data []ReportData `json:"data,required"` // Number of seconds between current time and last processed event, in another // words how many seconds of data could be missing. DataLag float64 `json:"data_lag,required"` @@ -64,19 +65,18 @@ type DNSAnalyticsReport struct { Max interface{} `json:"max,required"` // Minimum results for each metric (object mapping metric names to values). // Currently always an empty object. - Min interface{} `json:"min,required"` - Query DNSAnalyticsReportQuery `json:"query,required"` + Min interface{} `json:"min,required"` + Query ReportQuery `json:"query,required"` // Total number of rows in the result. Rows float64 `json:"rows,required"` // Total results for metrics across all data (object mapping metric names to // values). - Totals interface{} `json:"totals,required"` - JSON dnsAnalyticsReportJSON `json:"-"` + Totals interface{} `json:"totals,required"` + JSON reportJSON `json:"-"` } -// dnsAnalyticsReportJSON contains the JSON metadata for the struct -// [DNSAnalyticsReport] -type dnsAnalyticsReportJSON struct { +// reportJSON contains the JSON metadata for the struct [Report] +type reportJSON struct { Data apijson.Field DataLag apijson.Field Max apijson.Field @@ -88,41 +88,40 @@ type dnsAnalyticsReportJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSAnalyticsReport) UnmarshalJSON(data []byte) (err error) { +func (r *Report) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsAnalyticsReportJSON) RawJSON() string { +func (r reportJSON) RawJSON() string { return r.raw } -type DNSAnalyticsReportData struct { +type ReportData struct { // Array of dimension values, representing the combination of dimension values // corresponding to this row. Dimensions []string `json:"dimensions,required"` // Array with one item per requested metric. Each item is a single value. - Metrics []float64 `json:"metrics,required"` - JSON dnsAnalyticsReportDataJSON `json:"-"` + Metrics []float64 `json:"metrics,required"` + JSON reportDataJSON `json:"-"` } -// dnsAnalyticsReportDataJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportData] -type dnsAnalyticsReportDataJSON struct { +// reportDataJSON contains the JSON metadata for the struct [ReportData] +type reportDataJSON struct { Dimensions apijson.Field Metrics apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DNSAnalyticsReportData) UnmarshalJSON(data []byte) (err error) { +func (r *ReportData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsAnalyticsReportDataJSON) RawJSON() string { +func (r reportDataJSON) RawJSON() string { return r.raw } -type DNSAnalyticsReportQuery struct { +type ReportQuery struct { // Array of dimension names. Dimensions []string `json:"dimensions,required"` // Limit number of returned metrics. @@ -137,13 +136,12 @@ type DNSAnalyticsReportQuery struct { Filters string `json:"filters"` // Array of dimensions to sort by, where each dimension may be prefixed by - // (descending) or + (ascending). - Sort []string `json:"sort"` - JSON dnsAnalyticsReportQueryJSON `json:"-"` + Sort []string `json:"sort"` + JSON reportQueryJSON `json:"-"` } -// dnsAnalyticsReportQueryJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportQuery] -type dnsAnalyticsReportQueryJSON struct { +// reportQueryJSON contains the JSON metadata for the struct [ReportQuery] +type reportQueryJSON struct { Dimensions apijson.Field Limit apijson.Field Metrics apijson.Field @@ -155,11 +153,11 @@ type dnsAnalyticsReportQueryJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSAnalyticsReportQuery) UnmarshalJSON(data []byte) (err error) { +func (r *ReportQuery) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsAnalyticsReportQueryJSON) RawJSON() string { +func (r reportQueryJSON) RawJSON() string { return r.raw } @@ -187,15 +185,15 @@ type AnalyticsReportGetParams struct { // `url.Values`. func (r AnalyticsReportGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type AnalyticsReportGetResponseEnvelope struct { - Errors []AnalyticsReportGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyticsReportGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSAnalyticsReport `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Report `json:"result,required"` // Whether the API call was successful Success AnalyticsReportGetResponseEnvelopeSuccess `json:"success,required"` JSON analyticsReportGetResponseEnvelopeJSON `json:"-"` @@ -220,52 +218,6 @@ func (r analyticsReportGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyticsReportGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsReportGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyticsReportGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AnalyticsReportGetResponseEnvelopeErrors] -type analyticsReportGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsReportGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsReportGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyticsReportGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsReportGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyticsReportGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AnalyticsReportGetResponseEnvelopeMessages] -type analyticsReportGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsReportGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsReportGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyticsReportGetResponseEnvelopeSuccess bool diff --git a/dns/analyticsreportbytime.go b/dns/analyticsreportbytime.go index 62564215137..159f2ee7023 100644 --- a/dns/analyticsreportbytime.go +++ b/dns/analyticsreportbytime.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -39,7 +40,7 @@ func NewAnalyticsReportBytimeService(opts ...option.RequestOption) (r *Analytics // See // [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) // for detailed information about the available query parameters. -func (r *AnalyticsReportBytimeService) Get(ctx context.Context, params AnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *DNSAnalyticsReportByTime, err error) { +func (r *AnalyticsReportBytimeService) Get(ctx context.Context, params AnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *ByTime, err error) { opts = append(r.Options[:], opts...) var env AnalyticsReportBytimeGetResponseEnvelope path := fmt.Sprintf("zones/%s/dns_analytics/report/bytime", params.ZoneID) @@ -51,9 +52,9 @@ func (r *AnalyticsReportBytimeService) Get(ctx context.Context, params Analytics return } -type DNSAnalyticsReportByTime struct { +type ByTime struct { // Array with one row per combination of dimension values. - Data []DNSAnalyticsReportByTimeData `json:"data,required"` + Data []ByTimeData `json:"data,required"` // Number of seconds between current time and last processed event, in another // words how many seconds of data could be missing. DataLag float64 `json:"data_lag,required"` @@ -62,8 +63,8 @@ type DNSAnalyticsReportByTime struct { Max interface{} `json:"max,required"` // Minimum results for each metric (object mapping metric names to values). // Currently always an empty object. - Min interface{} `json:"min,required"` - Query DNSAnalyticsReportByTimeQuery `json:"query,required"` + Min interface{} `json:"min,required"` + Query DNSAnalyticsQuery `json:"query,required"` // Total number of rows in the result. Rows float64 `json:"rows,required"` // Array of time intervals in the response data. Each interval is represented as an @@ -71,13 +72,12 @@ type DNSAnalyticsReportByTime struct { TimeIntervals [][]time.Time `json:"time_intervals,required" format:"date-time"` // Total results for metrics across all data (object mapping metric names to // values). - Totals interface{} `json:"totals,required"` - JSON dnsAnalyticsReportByTimeJSON `json:"-"` + Totals interface{} `json:"totals,required"` + JSON byTimeJSON `json:"-"` } -// dnsAnalyticsReportByTimeJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportByTime] -type dnsAnalyticsReportByTimeJSON struct { +// byTimeJSON contains the JSON metadata for the struct [ByTime] +type byTimeJSON struct { Data apijson.Field DataLag apijson.Field Max apijson.Field @@ -90,109 +90,40 @@ type dnsAnalyticsReportByTimeJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSAnalyticsReportByTime) UnmarshalJSON(data []byte) (err error) { +func (r *ByTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsAnalyticsReportByTimeJSON) RawJSON() string { +func (r byTimeJSON) RawJSON() string { return r.raw } -type DNSAnalyticsReportByTimeData struct { +type ByTimeData struct { // Array of dimension values, representing the combination of dimension values // corresponding to this row. Dimensions []string `json:"dimensions,required"` // Array with one item per requested metric. Each item is an array of values, // broken down by time interval. - Metrics [][]interface{} `json:"metrics,required"` - JSON dnsAnalyticsReportByTimeDataJSON `json:"-"` + Metrics []DNSAnalyticsNominalMetric `json:"metrics,required"` + JSON byTimeDataJSON `json:"-"` } -// dnsAnalyticsReportByTimeDataJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportByTimeData] -type dnsAnalyticsReportByTimeDataJSON struct { +// byTimeDataJSON contains the JSON metadata for the struct [ByTimeData] +type byTimeDataJSON struct { Dimensions apijson.Field Metrics apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DNSAnalyticsReportByTimeData) UnmarshalJSON(data []byte) (err error) { +func (r *ByTimeData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsAnalyticsReportByTimeDataJSON) RawJSON() string { +func (r byTimeDataJSON) RawJSON() string { return r.raw } -type DNSAnalyticsReportByTimeQuery struct { - // Array of dimension names. - Dimensions []string `json:"dimensions,required"` - // Limit number of returned metrics. - Limit int64 `json:"limit,required"` - // Array of metric names. - Metrics []string `json:"metrics,required"` - // Start date and time of requesting data period in ISO 8601 format. - Since time.Time `json:"since,required" format:"date-time"` - // Unit of time to group data by. - TimeDelta DNSAnalyticsReportByTimeQueryTimeDelta `json:"time_delta,required"` - // End date and time of requesting data period in ISO 8601 format. - Until time.Time `json:"until,required" format:"date-time"` - // Segmentation filter in 'attribute operator value' format. - Filters string `json:"filters"` - // Array of dimensions to sort by, where each dimension may be prefixed by - - // (descending) or + (ascending). - Sort []string `json:"sort"` - JSON dnsAnalyticsReportByTimeQueryJSON `json:"-"` -} - -// dnsAnalyticsReportByTimeQueryJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportByTimeQuery] -type dnsAnalyticsReportByTimeQueryJSON struct { - Dimensions apijson.Field - Limit apijson.Field - Metrics apijson.Field - Since apijson.Field - TimeDelta apijson.Field - Until apijson.Field - Filters apijson.Field - Sort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportByTimeQuery) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportByTimeQueryJSON) RawJSON() string { - return r.raw -} - -// Unit of time to group data by. -type DNSAnalyticsReportByTimeQueryTimeDelta string - -const ( - DNSAnalyticsReportByTimeQueryTimeDeltaAll DNSAnalyticsReportByTimeQueryTimeDelta = "all" - DNSAnalyticsReportByTimeQueryTimeDeltaAuto DNSAnalyticsReportByTimeQueryTimeDelta = "auto" - DNSAnalyticsReportByTimeQueryTimeDeltaYear DNSAnalyticsReportByTimeQueryTimeDelta = "year" - DNSAnalyticsReportByTimeQueryTimeDeltaQuarter DNSAnalyticsReportByTimeQueryTimeDelta = "quarter" - DNSAnalyticsReportByTimeQueryTimeDeltaMonth DNSAnalyticsReportByTimeQueryTimeDelta = "month" - DNSAnalyticsReportByTimeQueryTimeDeltaWeek DNSAnalyticsReportByTimeQueryTimeDelta = "week" - DNSAnalyticsReportByTimeQueryTimeDeltaDay DNSAnalyticsReportByTimeQueryTimeDelta = "day" - DNSAnalyticsReportByTimeQueryTimeDeltaHour DNSAnalyticsReportByTimeQueryTimeDelta = "hour" - DNSAnalyticsReportByTimeQueryTimeDeltaDekaminute DNSAnalyticsReportByTimeQueryTimeDelta = "dekaminute" - DNSAnalyticsReportByTimeQueryTimeDeltaMinute DNSAnalyticsReportByTimeQueryTimeDelta = "minute" -) - -func (r DNSAnalyticsReportByTimeQueryTimeDelta) IsKnown() bool { - switch r { - case DNSAnalyticsReportByTimeQueryTimeDeltaAll, DNSAnalyticsReportByTimeQueryTimeDeltaAuto, DNSAnalyticsReportByTimeQueryTimeDeltaYear, DNSAnalyticsReportByTimeQueryTimeDeltaQuarter, DNSAnalyticsReportByTimeQueryTimeDeltaMonth, DNSAnalyticsReportByTimeQueryTimeDeltaWeek, DNSAnalyticsReportByTimeQueryTimeDeltaDay, DNSAnalyticsReportByTimeQueryTimeDeltaHour, DNSAnalyticsReportByTimeQueryTimeDeltaDekaminute, DNSAnalyticsReportByTimeQueryTimeDeltaMinute: - return true - } - return false -} - type AnalyticsReportBytimeGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -219,7 +150,7 @@ type AnalyticsReportBytimeGetParams struct { // `url.Values`. func (r AnalyticsReportBytimeGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -249,9 +180,9 @@ func (r AnalyticsReportBytimeGetParamsTimeDelta) IsKnown() bool { } type AnalyticsReportBytimeGetResponseEnvelope struct { - Errors []AnalyticsReportBytimeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyticsReportBytimeGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSAnalyticsReportByTime `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ByTime `json:"result,required"` // Whether the API call was successful Success AnalyticsReportBytimeGetResponseEnvelopeSuccess `json:"success,required"` JSON analyticsReportBytimeGetResponseEnvelopeJSON `json:"-"` @@ -276,52 +207,6 @@ func (r analyticsReportBytimeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyticsReportBytimeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsReportBytimeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyticsReportBytimeGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AnalyticsReportBytimeGetResponseEnvelopeErrors] -type analyticsReportBytimeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsReportBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsReportBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyticsReportBytimeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsReportBytimeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyticsReportBytimeGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AnalyticsReportBytimeGetResponseEnvelopeMessages] -type analyticsReportBytimeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsReportBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsReportBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyticsReportBytimeGetResponseEnvelopeSuccess bool diff --git a/dns/dns.go b/dns/dns.go index 6b01f10d43e..1237b3e020a 100644 --- a/dns/dns.go +++ b/dns/dns.go @@ -3,6 +3,9 @@ package dns import ( + "time" + + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -28,3 +31,73 @@ func NewDNSService(opts ...option.RequestOption) (r *DNSService) { r.Firewall = NewFirewallService(opts...) return } + +type DNSAnalyticsNominalMetric []interface{} + +type DNSAnalyticsQuery struct { + // Array of dimension names. + Dimensions []string `json:"dimensions,required"` + // Limit number of returned metrics. + Limit int64 `json:"limit,required"` + // Array of metric names. + Metrics []string `json:"metrics,required"` + // Start date and time of requesting data period in ISO 8601 format. + Since time.Time `json:"since,required" format:"date-time"` + // Unit of time to group data by. + TimeDelta DNSAnalyticsQueryTimeDelta `json:"time_delta,required"` + // End date and time of requesting data period in ISO 8601 format. + Until time.Time `json:"until,required" format:"date-time"` + // Segmentation filter in 'attribute operator value' format. + Filters string `json:"filters"` + // Array of dimensions to sort by, where each dimension may be prefixed by - + // (descending) or + (ascending). + Sort []string `json:"sort"` + JSON dnsAnalyticsQueryJSON `json:"-"` +} + +// dnsAnalyticsQueryJSON contains the JSON metadata for the struct +// [DNSAnalyticsQuery] +type dnsAnalyticsQueryJSON struct { + Dimensions apijson.Field + Limit apijson.Field + Metrics apijson.Field + Since apijson.Field + TimeDelta apijson.Field + Until apijson.Field + Filters apijson.Field + Sort apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSAnalyticsQuery) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsAnalyticsQueryJSON) RawJSON() string { + return r.raw +} + +// Unit of time to group data by. +type DNSAnalyticsQueryTimeDelta string + +const ( + DNSAnalyticsQueryTimeDeltaAll DNSAnalyticsQueryTimeDelta = "all" + DNSAnalyticsQueryTimeDeltaAuto DNSAnalyticsQueryTimeDelta = "auto" + DNSAnalyticsQueryTimeDeltaYear DNSAnalyticsQueryTimeDelta = "year" + DNSAnalyticsQueryTimeDeltaQuarter DNSAnalyticsQueryTimeDelta = "quarter" + DNSAnalyticsQueryTimeDeltaMonth DNSAnalyticsQueryTimeDelta = "month" + DNSAnalyticsQueryTimeDeltaWeek DNSAnalyticsQueryTimeDelta = "week" + DNSAnalyticsQueryTimeDeltaDay DNSAnalyticsQueryTimeDelta = "day" + DNSAnalyticsQueryTimeDeltaHour DNSAnalyticsQueryTimeDelta = "hour" + DNSAnalyticsQueryTimeDeltaDekaminute DNSAnalyticsQueryTimeDelta = "dekaminute" + DNSAnalyticsQueryTimeDeltaMinute DNSAnalyticsQueryTimeDelta = "minute" +) + +func (r DNSAnalyticsQueryTimeDelta) IsKnown() bool { + switch r { + case DNSAnalyticsQueryTimeDeltaAll, DNSAnalyticsQueryTimeDeltaAuto, DNSAnalyticsQueryTimeDeltaYear, DNSAnalyticsQueryTimeDeltaQuarter, DNSAnalyticsQueryTimeDeltaMonth, DNSAnalyticsQueryTimeDeltaWeek, DNSAnalyticsQueryTimeDeltaDay, DNSAnalyticsQueryTimeDeltaHour, DNSAnalyticsQueryTimeDeltaDekaminute, DNSAnalyticsQueryTimeDeltaMinute: + return true + } + return false +} diff --git a/dns/firewall.go b/dns/firewall.go index 2b690150e20..cab5e9339c6 100644 --- a/dns/firewall.go +++ b/dns/firewall.go @@ -40,7 +40,7 @@ func NewFirewallService(opts ...option.RequestOption) (r *FirewallService) { } // Create a configured DNS Firewall Cluster. -func (r *FirewallService) New(ctx context.Context, params FirewallNewParams, opts ...option.RequestOption) (res *DNSFirewall, err error) { +func (r *FirewallService) New(ctx context.Context, params FirewallNewParams, opts ...option.RequestOption) (res *Firewall, err error) { opts = append(r.Options[:], opts...) var env FirewallNewResponseEnvelope path := fmt.Sprintf("accounts/%s/dns_firewall", params.AccountID) @@ -53,7 +53,7 @@ func (r *FirewallService) New(ctx context.Context, params FirewallNewParams, opt } // List configured DNS Firewall clusters for an account. -func (r *FirewallService) List(ctx context.Context, params FirewallListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DNSFirewall], err error) { +func (r *FirewallService) List(ctx context.Context, params FirewallListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Firewall], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -71,15 +71,15 @@ func (r *FirewallService) List(ctx context.Context, params FirewallListParams, o } // List configured DNS Firewall clusters for an account. -func (r *FirewallService) ListAutoPaging(ctx context.Context, params FirewallListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DNSFirewall] { +func (r *FirewallService) ListAutoPaging(ctx context.Context, params FirewallListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Firewall] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } // Delete a configured DNS Firewall Cluster. -func (r *FirewallService) Delete(ctx context.Context, dnsFirewallID string, body FirewallDeleteParams, opts ...option.RequestOption) (res *FirewallDeleteResponse, err error) { +func (r *FirewallService) Delete(ctx context.Context, dnsFirewallID string, params FirewallDeleteParams, opts ...option.RequestOption) (res *FirewallDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env FirewallDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/dns_firewall/%s", body.AccountID, dnsFirewallID) + path := fmt.Sprintf("accounts/%s/dns_firewall/%s", params.AccountID, dnsFirewallID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -89,7 +89,7 @@ func (r *FirewallService) Delete(ctx context.Context, dnsFirewallID string, body } // Modify a DNS Firewall Cluster configuration. -func (r *FirewallService) Edit(ctx context.Context, dnsFirewallID string, params FirewallEditParams, opts ...option.RequestOption) (res *DNSFirewall, err error) { +func (r *FirewallService) Edit(ctx context.Context, dnsFirewallID string, params FirewallEditParams, opts ...option.RequestOption) (res *Firewall, err error) { opts = append(r.Options[:], opts...) var env FirewallEditResponseEnvelope path := fmt.Sprintf("accounts/%s/dns_firewall/%s", params.AccountID, dnsFirewallID) @@ -102,7 +102,7 @@ func (r *FirewallService) Edit(ctx context.Context, dnsFirewallID string, params } // Show a single configured DNS Firewall cluster for an account. -func (r *FirewallService) Get(ctx context.Context, dnsFirewallID string, query FirewallGetParams, opts ...option.RequestOption) (res *DNSFirewall, err error) { +func (r *FirewallService) Get(ctx context.Context, dnsFirewallID string, query FirewallGetParams, opts ...option.RequestOption) (res *Firewall, err error) { opts = append(r.Options[:], opts...) var env FirewallGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dns_firewall/%s", query.AccountID, dnsFirewallID) @@ -114,12 +114,52 @@ func (r *FirewallService) Get(ctx context.Context, dnsFirewallID string, query F return } -type DNSFirewall struct { +// Attack mitigation settings. +type AttackMitigation struct { + // When enabled, random-prefix attacks are automatically mitigated and the upstream + // DNS servers protected. + Enabled bool `json:"enabled"` + // Only mitigate attacks when upstream servers seem unhealthy. + OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` + JSON attackMitigationJSON `json:"-"` +} + +// attackMitigationJSON contains the JSON metadata for the struct +// [AttackMitigation] +type attackMitigationJSON struct { + Enabled apijson.Field + OnlyWhenUpstreamUnhealthy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackMitigation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackMitigationJSON) RawJSON() string { + return r.raw +} + +// Attack mitigation settings. +type AttackMitigationParam struct { + // When enabled, random-prefix attacks are automatically mitigated and the upstream + // DNS servers protected. + Enabled param.Field[bool] `json:"enabled"` + // Only mitigate attacks when upstream servers seem unhealthy. + OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` +} + +func (r AttackMitigationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Firewall struct { // Identifier ID string `json:"id,required"` // Deprecate the response to ANY requests. - DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` - DNSFirewallIPs []DNSFirewallDNSFirewallIP `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. @@ -129,10 +169,10 @@ type DNSFirewall struct { // Last modification of DNS Firewall cluster. ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` // DNS Firewall Cluster Name. - Name string `json:"name,required"` - UpstreamIPs []DNSFirewallUpstreamIP `json:"upstream_ips,required" format:"ipv4"` + Name string `json:"name,required"` + UpstreamIPs []UpstreamIPsUnion `json:"upstream_ips,required" format:"ipv4"` // Attack mitigation settings. - AttackMitigation DNSFirewallAttackMitigation `json:"attack_mitigation,nullable"` + AttackMitigation AttackMitigation `json:"attack_mitigation,nullable"` // Negative DNS Cache TTL. NegativeCacheTTL float64 `json:"negative_cache_ttl,nullable"` // Ratelimit in queries per second per datacenter (applies to DNS queries sent to @@ -140,12 +180,12 @@ type DNSFirewall struct { Ratelimit float64 `json:"ratelimit,nullable"` // Number of retries for fetching DNS responses from upstream nameservers (not // counting the initial attempt). - Retries float64 `json:"retries"` - JSON dnsFirewallJSON `json:"-"` + Retries float64 `json:"retries"` + JSON firewallJSON `json:"-"` } -// dnsFirewallJSON contains the JSON metadata for the struct [DNSFirewall] -type dnsFirewallJSON struct { +// firewallJSON contains the JSON metadata for the struct [Firewall] +type firewallJSON struct { ID apijson.Field DeprecateAnyRequests apijson.Field DNSFirewallIPs apijson.Field @@ -163,24 +203,53 @@ type dnsFirewallJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSFirewall) UnmarshalJSON(data []byte) (err error) { +func (r *Firewall) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsFirewallJSON) RawJSON() string { +func (r firewallJSON) RawJSON() string { return r.raw } +type FirewallParam struct { + // Deprecate the response to ANY requests. + 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. + MaximumCacheTTL param.Field[float64] `json:"maximum_cache_ttl,required"` + // Minimum DNS Cache TTL. + MinimumCacheTTL param.Field[float64] `json:"minimum_cache_ttl,required"` + // DNS Firewall Cluster Name. + Name param.Field[string] `json:"name,required"` + UpstreamIPs param.Field[[]UpstreamIPsUnionParam] `json:"upstream_ips,required" format:"ipv4"` + // Attack mitigation settings. + AttackMitigation param.Field[AttackMitigationParam] `json:"attack_mitigation"` + // Negative DNS Cache TTL. + NegativeCacheTTL param.Field[float64] `json:"negative_cache_ttl"` + // Ratelimit in queries per second per datacenter (applies to DNS queries sent to + // the upstream nameservers configured on the cluster). + Ratelimit param.Field[float64] `json:"ratelimit"` + // Number of retries for fetching DNS responses from upstream nameservers (not + // counting the initial attempt). + Retries param.Field[float64] `json:"retries"` +} + +func (r FirewallParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Cloudflare-assigned DNS IPv4 Address. // // Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallDNSFirewallIP interface { - ImplementsDNSDNSFirewallDNSFirewallIP() +type FirewallIPsUnion interface { + ImplementsDNSFirewallIPsUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallDNSFirewallIP)(nil)).Elem(), + reflect.TypeOf((*FirewallIPsUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -193,16 +262,23 @@ func init() { ) } +// Cloudflare-assigned DNS IPv4 Address. +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type FirewallIPsUnionParam interface { + ImplementsDNSFirewallIPsUnionParam() +} + // Upstream DNS Server IPv4 Address. // // Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallUpstreamIP interface { - ImplementsDNSDNSFirewallUpstreamIP() +type UpstreamIPsUnion interface { + ImplementsDNSUpstreamIPsUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallUpstreamIP)(nil)).Elem(), + reflect.TypeOf((*UpstreamIPsUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -215,31 +291,11 @@ func init() { ) } -// Attack mitigation settings. -type DNSFirewallAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled bool `json:"enabled"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` - JSON dnsFirewallAttackMitigationJSON `json:"-"` -} - -// dnsFirewallAttackMitigationJSON contains the JSON metadata for the struct -// [DNSFirewallAttackMitigation] -type dnsFirewallAttackMitigationJSON struct { - Enabled apijson.Field - OnlyWhenUpstreamUnhealthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAttackMitigation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAttackMitigationJSON) RawJSON() string { - return r.raw +// Upstream DNS Server IPv4 Address. +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type UpstreamIPsUnionParam interface { + ImplementsDNSUpstreamIPsUnionParam() } type FirewallDeleteResponse struct { @@ -268,10 +324,10 @@ type FirewallNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` // DNS Firewall Cluster Name. - Name param.Field[string] `json:"name,required"` - UpstreamIPs param.Field[[]FirewallNewParamsUpstreamIP] `json:"upstream_ips,required" format:"ipv4"` + Name param.Field[string] `json:"name,required"` + UpstreamIPs param.Field[[]UpstreamIPsUnionParam] `json:"upstream_ips,required" format:"ipv4"` // Attack mitigation settings. - AttackMitigation param.Field[FirewallNewParamsAttackMitigation] `json:"attack_mitigation"` + AttackMitigation param.Field[AttackMitigationParam] `json:"attack_mitigation"` // Deprecate the response to ANY requests. DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests"` // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. @@ -294,30 +350,10 @@ func (r FirewallNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Upstream DNS Server IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type FirewallNewParamsUpstreamIP interface { - ImplementsDNSFirewallNewParamsUpstreamIP() -} - -// Attack mitigation settings. -type FirewallNewParamsAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled param.Field[bool] `json:"enabled"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` -} - -func (r FirewallNewParamsAttackMitigation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type FirewallNewResponseEnvelope struct { - Errors []FirewallNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallNewResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewall `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Firewall `json:"result,required"` // Whether the API call was successful Success FirewallNewResponseEnvelopeSuccess `json:"success,required"` JSON firewallNewResponseEnvelopeJSON `json:"-"` @@ -342,52 +378,6 @@ func (r firewallNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FirewallNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FirewallNewResponseEnvelopeErrors] -type firewallNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallNewResponseEnvelopeMessages] -type firewallNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FirewallNewResponseEnvelopeSuccess bool @@ -415,7 +405,7 @@ type FirewallListParams struct { // URLQuery serializes [FirewallListParams]'s query parameters as `url.Values`. func (r FirewallListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -423,12 +413,17 @@ func (r FirewallListParams) URLQuery() (v url.Values) { type FirewallDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r FirewallDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type FirewallDeleteResponseEnvelope struct { - Errors []FirewallDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FirewallDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FirewallDeleteResponse `json:"result,required"` // Whether the API call was successful Success FirewallDeleteResponseEnvelopeSuccess `json:"success,required"` JSON firewallDeleteResponseEnvelopeJSON `json:"-"` @@ -453,52 +448,6 @@ func (r firewallDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FirewallDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallDeleteResponseEnvelopeErrors] -type firewallDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallDeleteResponseEnvelopeMessages] -type firewallDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FirewallDeleteResponseEnvelopeSuccess bool @@ -517,65 +466,17 @@ func (r FirewallDeleteResponseEnvelopeSuccess) IsKnown() bool { 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[[]FirewallEditParamsDNSFirewallIP] `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. - MaximumCacheTTL param.Field[float64] `json:"maximum_cache_ttl,required"` - // Minimum DNS Cache TTL. - MinimumCacheTTL param.Field[float64] `json:"minimum_cache_ttl,required"` - // DNS Firewall Cluster Name. - Name param.Field[string] `json:"name,required"` - UpstreamIPs param.Field[[]FirewallEditParamsUpstreamIP] `json:"upstream_ips,required" format:"ipv4"` - // Attack mitigation settings. - AttackMitigation param.Field[FirewallEditParamsAttackMitigation] `json:"attack_mitigation"` - // Negative DNS Cache TTL. - NegativeCacheTTL param.Field[float64] `json:"negative_cache_ttl"` - // Ratelimit in queries per second per datacenter (applies to DNS queries sent to - // the upstream nameservers configured on the cluster). - Ratelimit param.Field[float64] `json:"ratelimit"` - // Number of retries for fetching DNS responses from upstream nameservers (not - // counting the initial attempt). - Retries param.Field[float64] `json:"retries"` + Firewall FirewallParam `json:"firewall,required"` } func (r FirewallEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Cloudflare-assigned DNS IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type FirewallEditParamsDNSFirewallIP interface { - ImplementsDNSFirewallEditParamsDNSFirewallIP() -} - -// Upstream DNS Server IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type FirewallEditParamsUpstreamIP interface { - ImplementsDNSFirewallEditParamsUpstreamIP() -} - -// Attack mitigation settings. -type FirewallEditParamsAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled param.Field[bool] `json:"enabled"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` -} - -func (r FirewallEditParamsAttackMitigation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Firewall) } type FirewallEditResponseEnvelope struct { - Errors []FirewallEditResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallEditResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewall `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Firewall `json:"result,required"` // Whether the API call was successful Success FirewallEditResponseEnvelopeSuccess `json:"success,required"` JSON firewallEditResponseEnvelopeJSON `json:"-"` @@ -600,52 +501,6 @@ func (r firewallEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FirewallEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FirewallEditResponseEnvelopeErrors] -type firewallEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallEditResponseEnvelopeMessages] -type firewallEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FirewallEditResponseEnvelopeSuccess bool @@ -667,9 +522,9 @@ type FirewallGetParams struct { } type FirewallGetResponseEnvelope struct { - Errors []FirewallGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewall `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Firewall `json:"result,required"` // Whether the API call was successful Success FirewallGetResponseEnvelopeSuccess `json:"success,required"` JSON firewallGetResponseEnvelopeJSON `json:"-"` @@ -694,52 +549,6 @@ func (r firewallGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FirewallGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FirewallGetResponseEnvelopeErrors] -type firewallGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallGetResponseEnvelopeMessages] -type firewallGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FirewallGetResponseEnvelopeSuccess bool diff --git a/dns/firewall_test.go b/dns/firewall_test.go index abf79d0ff28..624ae1b64ec 100644 --- a/dns/firewall_test.go +++ b/dns/firewall_test.go @@ -32,8 +32,8 @@ func TestFirewallNewWithOptionalParams(t *testing.T) { _, err := client.DNS.Firewall.New(context.TODO(), dns.FirewallNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("My Awesome DNS Firewall cluster"), - UpstreamIPs: cloudflare.F([]dns.FirewallNewParamsUpstreamIP{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), - AttackMitigation: cloudflare.F(dns.FirewallNewParamsAttackMitigation{ + UpstreamIPs: cloudflare.F([]dns.UpstreamIPsUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), + AttackMitigation: cloudflare.F(dns.AttackMitigationParam{ Enabled: cloudflare.F(true), OnlyWhenUpstreamUnhealthy: cloudflare.F(false), }), @@ -101,6 +101,7 @@ func TestFirewallDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", dns.FirewallDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -130,21 +131,23 @@ func TestFirewallEditWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", dns.FirewallEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DeprecateAnyRequests: cloudflare.F(true), - DNSFirewallIPs: cloudflare.F([]dns.FirewallEditParamsDNSFirewallIP{shared.UnionString("203.0.113.1"), shared.UnionString("203.0.113.254"), shared.UnionString("2001:DB8:AB::CF"), shared.UnionString("2001:DB8:CD::CF")}), - EcsFallback: cloudflare.F(false), - MaximumCacheTTL: cloudflare.F(900.000000), - MinimumCacheTTL: cloudflare.F(60.000000), - Name: cloudflare.F("My Awesome DNS Firewall cluster"), - UpstreamIPs: cloudflare.F([]dns.FirewallEditParamsUpstreamIP{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), - AttackMitigation: cloudflare.F(dns.FirewallEditParamsAttackMitigation{ - Enabled: cloudflare.F(true), - OnlyWhenUpstreamUnhealthy: cloudflare.F(false), - }), - NegativeCacheTTL: cloudflare.F(900.000000), - Ratelimit: cloudflare.F(600.000000), - Retries: cloudflare.F(2.000000), + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Firewall: dns.FirewallParam{ + AttackMitigation: cloudflare.F(dns.AttackMitigationParam{ + Enabled: cloudflare.F(true), + OnlyWhenUpstreamUnhealthy: cloudflare.F(false), + }), + DeprecateAnyRequests: cloudflare.F(true), + 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), + Name: cloudflare.F("My Awesome DNS Firewall cluster"), + NegativeCacheTTL: cloudflare.F(900.000000), + Ratelimit: cloudflare.F(600.000000), + Retries: cloudflare.F(2.000000), + UpstreamIPs: cloudflare.F([]dns.UpstreamIPsUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), + }, }, ) if err != nil { diff --git a/dns/firewallanalyticsreport.go b/dns/firewallanalyticsreport.go index 0d132b44e9f..c2d4824aeea 100644 --- a/dns/firewallanalyticsreport.go +++ b/dns/firewallanalyticsreport.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -41,7 +42,7 @@ func NewFirewallAnalyticsReportService(opts ...option.RequestOption) (r *Firewal // See // [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) // for detailed information about the available query parameters. -func (r *FirewallAnalyticsReportService) Get(ctx context.Context, dnsFirewallID string, params FirewallAnalyticsReportGetParams, opts ...option.RequestOption) (res *DNSAnalyticsReport, err error) { +func (r *FirewallAnalyticsReportService) Get(ctx context.Context, dnsFirewallID string, params FirewallAnalyticsReportGetParams, opts ...option.RequestOption) (res *Report, err error) { opts = append(r.Options[:], opts...) var env FirewallAnalyticsReportGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dns_firewall/%s/dns_analytics/report", params.AccountID, dnsFirewallID) @@ -77,15 +78,15 @@ type FirewallAnalyticsReportGetParams struct { // `url.Values`. func (r FirewallAnalyticsReportGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type FirewallAnalyticsReportGetResponseEnvelope struct { - Errors []FirewallAnalyticsReportGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAnalyticsReportGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSAnalyticsReport `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Report `json:"result,required"` // Whether the API call was successful Success FirewallAnalyticsReportGetResponseEnvelopeSuccess `json:"success,required"` JSON firewallAnalyticsReportGetResponseEnvelopeJSON `json:"-"` @@ -110,52 +111,6 @@ func (r firewallAnalyticsReportGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FirewallAnalyticsReportGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAnalyticsReportGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAnalyticsReportGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallAnalyticsReportGetResponseEnvelopeErrors] -type firewallAnalyticsReportGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAnalyticsReportGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAnalyticsReportGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAnalyticsReportGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAnalyticsReportGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAnalyticsReportGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [FirewallAnalyticsReportGetResponseEnvelopeMessages] -type firewallAnalyticsReportGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAnalyticsReportGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAnalyticsReportGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FirewallAnalyticsReportGetResponseEnvelopeSuccess bool diff --git a/dns/firewallanalyticsreportbytime.go b/dns/firewallanalyticsreportbytime.go index b8effdbd308..692c195e846 100644 --- a/dns/firewallanalyticsreportbytime.go +++ b/dns/firewallanalyticsreportbytime.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -39,7 +40,7 @@ func NewFirewallAnalyticsReportBytimeService(opts ...option.RequestOption) (r *F // See // [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) // for detailed information about the available query parameters. -func (r *FirewallAnalyticsReportBytimeService) Get(ctx context.Context, dnsFirewallID string, params FirewallAnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *DNSAnalyticsReportByTime, err error) { +func (r *FirewallAnalyticsReportBytimeService) Get(ctx context.Context, dnsFirewallID string, params FirewallAnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *ByTime, err error) { opts = append(r.Options[:], opts...) var env FirewallAnalyticsReportBytimeGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dns_firewall/%s/dns_analytics/report/bytime", params.AccountID, dnsFirewallID) @@ -77,7 +78,7 @@ type FirewallAnalyticsReportBytimeGetParams struct { // as `url.Values`. func (r FirewallAnalyticsReportBytimeGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -107,9 +108,9 @@ func (r FirewallAnalyticsReportBytimeGetParamsTimeDelta) IsKnown() bool { } type FirewallAnalyticsReportBytimeGetResponseEnvelope struct { - Errors []FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSAnalyticsReportByTime `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ByTime `json:"result,required"` // Whether the API call was successful Success FirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess `json:"success,required"` JSON firewallAnalyticsReportBytimeGetResponseEnvelopeJSON `json:"-"` @@ -134,53 +135,6 @@ func (r firewallAnalyticsReportBytimeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors] -type firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages] -type firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess bool diff --git a/dns/record.go b/dns/record.go index eeed51da61c..d8cd58ba01b 100644 --- a/dns/record.go +++ b/dns/record.go @@ -45,10 +45,10 @@ func NewRecordService(opts ...option.RequestOption) (r *RecordService) { // - NS records cannot exist on the same name as any other record type. // - Domain names are always represented in Punycode, even if Unicode characters // were used when creating the record. -func (r *RecordService) New(ctx context.Context, params RecordNewParams, opts ...option.RequestOption) (res *DNSRecord, err error) { +func (r *RecordService) New(ctx context.Context, params RecordNewParams, opts ...option.RequestOption) (res *Record, err error) { opts = append(r.Options[:], opts...) var env RecordNewResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records", params.getZoneID()) + path := fmt.Sprintf("zones/%s/dns_records", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return @@ -63,10 +63,10 @@ func (r *RecordService) New(ctx context.Context, params RecordNewParams, opts .. // - NS records cannot exist on the same name as any other record type. // - Domain names are always represented in Punycode, even if Unicode characters // were used when creating the record. -func (r *RecordService) Update(ctx context.Context, dnsRecordID string, params RecordUpdateParams, opts ...option.RequestOption) (res *DNSRecord, err error) { +func (r *RecordService) Update(ctx context.Context, dnsRecordID string, params RecordUpdateParams, opts ...option.RequestOption) (res *Record, err error) { opts = append(r.Options[:], opts...) var env RecordUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/%s", params.getZoneID(), dnsRecordID) + path := fmt.Sprintf("zones/%s/dns_records/%s", params.ZoneID, dnsRecordID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return @@ -76,7 +76,7 @@ func (r *RecordService) Update(ctx context.Context, dnsRecordID string, params R } // List, search, sort, and filter a zones' DNS records. -func (r *RecordService) List(ctx context.Context, params RecordListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DNSRecord], err error) { +func (r *RecordService) List(ctx context.Context, params RecordListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Record], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -94,15 +94,15 @@ func (r *RecordService) List(ctx context.Context, params RecordListParams, opts } // List, search, sort, and filter a zones' DNS records. -func (r *RecordService) ListAutoPaging(ctx context.Context, params RecordListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DNSRecord] { +func (r *RecordService) ListAutoPaging(ctx context.Context, params RecordListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Record] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } // Delete DNS Record -func (r *RecordService) Delete(ctx context.Context, dnsRecordID string, body RecordDeleteParams, opts ...option.RequestOption) (res *RecordDeleteResponse, err error) { +func (r *RecordService) Delete(ctx context.Context, dnsRecordID string, params RecordDeleteParams, opts ...option.RequestOption) (res *RecordDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env RecordDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/%s", body.ZoneID, dnsRecordID) + path := fmt.Sprintf("zones/%s/dns_records/%s", params.ZoneID, dnsRecordID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -117,10 +117,10 @@ func (r *RecordService) Delete(ctx context.Context, dnsRecordID string, body Rec // - NS records cannot exist on the same name as any other record type. // - Domain names are always represented in Punycode, even if Unicode characters // were used when creating the record. -func (r *RecordService) Edit(ctx context.Context, dnsRecordID string, params RecordEditParams, opts ...option.RequestOption) (res *DNSRecord, err error) { +func (r *RecordService) Edit(ctx context.Context, dnsRecordID string, params RecordEditParams, opts ...option.RequestOption) (res *Record, err error) { opts = append(r.Options[:], opts...) var env RecordEditResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/%s", params.getZoneID(), dnsRecordID) + path := fmt.Sprintf("zones/%s/dns_records/%s", params.ZoneID, dnsRecordID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) if err != nil { return @@ -145,7 +145,7 @@ func (r *RecordService) Export(ctx context.Context, query RecordExportParams, op } // DNS Record Details -func (r *RecordService) Get(ctx context.Context, dnsRecordID string, query RecordGetParams, opts ...option.RequestOption) (res *DNSRecord, err error) { +func (r *RecordService) Get(ctx context.Context, dnsRecordID string, query RecordGetParams, opts ...option.RequestOption) (res *Record, err error) { opts = append(r.Options[:], opts...) var env RecordGetResponseEnvelope path := fmt.Sprintf("zones/%s/dns_records/%s", query.ZoneID, dnsRecordID) @@ -179,10 +179,10 @@ func (r *RecordService) Import(ctx context.Context, params RecordImportParams, o // Scan for common DNS records on your domain and automatically add them to your // zone. Useful if you haven't updated your nameservers yet. -func (r *RecordService) Scan(ctx context.Context, body RecordScanParams, opts ...option.RequestOption) (res *RecordScanResponse, err error) { +func (r *RecordService) Scan(ctx context.Context, params RecordScanParams, opts ...option.RequestOption) (res *RecordScanResponse, err error) { opts = append(r.Options[:], opts...) var env RecordScanResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/scan", body.ZoneID) + path := fmt.Sprintf("zones/%s/dns_records/scan", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -191,131 +191,13 @@ func (r *RecordService) Scan(ctx context.Context, body RecordScanParams, opts .. return } -// Union satisfied by [dns.DNSRecordA], [dns.DNSRecordAAAA], [dns.DNSRecordCAA], -// [dns.DNSRecordCERT], [dns.DNSRecordCNAME], [dns.DNSRecordDNSKEY], -// [dns.DNSRecordDS], [dns.DNSRecordHTTPS], [dns.DNSRecordLOC], [dns.DNSRecordMX], -// [dns.DNSRecordNAPTR], [dns.DNSRecordNS], [dns.DNSRecordPTR], -// [dns.DNSRecordSMIMEA], [dns.DNSRecordSRV], [dns.DNSRecordSSHFP], -// [dns.DNSRecordSVCB], [dns.DNSRecordTLSA], [dns.DNSRecordTXT] or -// [dns.DNSRecordURI]. -type DNSRecord interface { - implementsDNSDNSRecord() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecord)(nil)).Elem(), - "type", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordA{}), - DiscriminatorValue: "A", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordAAAA{}), - DiscriminatorValue: "AAAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordCAA{}), - DiscriminatorValue: "CAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordCERT{}), - DiscriminatorValue: "CERT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordCNAME{}), - DiscriminatorValue: "CNAME", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordDNSKEY{}), - DiscriminatorValue: "DNSKEY", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordDS{}), - DiscriminatorValue: "DS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordHTTPS{}), - DiscriminatorValue: "HTTPS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordLOC{}), - DiscriminatorValue: "LOC", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordMX{}), - DiscriminatorValue: "MX", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNAPTR{}), - DiscriminatorValue: "NAPTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNS{}), - DiscriminatorValue: "NS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordPTR{}), - DiscriminatorValue: "PTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordSMIMEA{}), - DiscriminatorValue: "SMIMEA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordSRV{}), - DiscriminatorValue: "SRV", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordSSHFP{}), - DiscriminatorValue: "SSHFP", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordSVCB{}), - DiscriminatorValue: "SVCB", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordTLSA{}), - DiscriminatorValue: "TLSA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordTXT{}), - DiscriminatorValue: "TXT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordURI{}), - DiscriminatorValue: "URI", - }, - ) -} - -type DNSRecordA struct { +type ARecord struct { // A valid IPv4 address. Content string `json:"content,required" format:"ipv4"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordAType `json:"type,required"` + Type ARecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -327,7 +209,7 @@ type DNSRecordA struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordAMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Whether the record can be proxied by Cloudflare or not. @@ -336,20 +218,20 @@ type DNSRecordA struct { // Cloudflare. Proxied bool `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `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. - TTL DNSRecordATTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordAJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON aRecordJSON `json:"-"` } -// dnsRecordAJSON contains the JSON metadata for the struct [DNSRecordA] -type dnsRecordAJSON struct { +// aRecordJSON contains the JSON metadata for the struct [ARecord] +type aRecordJSON struct { Content apijson.Field Name apijson.Field Type apijson.Field @@ -369,102 +251,65 @@ type dnsRecordAJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordA) UnmarshalJSON(data []byte) (err error) { +func (r *ARecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordAJSON) RawJSON() string { +func (r aRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordA) implementsDNSDNSRecord() {} +func (r ARecord) implementsDNSRecord() {} // Record type. -type DNSRecordAType string +type ARecordType string const ( - DNSRecordATypeA DNSRecordAType = "A" + ARecordTypeA ARecordType = "A" ) -func (r DNSRecordAType) IsKnown() bool { +func (r ARecordType) IsKnown() bool { switch r { - case DNSRecordATypeA: + case ARecordTypeA: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordAMetaJSON `json:"-"` -} - -// dnsRecordAMetaJSON contains the JSON metadata for the struct [DNSRecordAMeta] -type dnsRecordAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordAMetaJSON) RawJSON() string { - return r.raw -} - -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordATTLNumber]. -type DNSRecordATTL interface { - ImplementsDNSDNSRecordAttl() +type ARecordParam struct { + // A valid IPv4 address. + Content param.Field[string] `json:"content,required" format:"ipv4"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[ARecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordATTLNumber(0)), - }, - ) +func (r ARecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordATTLNumber float64 - -const ( - DNSRecordATTLNumber1 DNSRecordATTLNumber = 1 -) - -func (r DNSRecordATTLNumber) IsKnown() bool { - switch r { - case DNSRecordATTLNumber1: - return true - } - return false -} +func (r ARecordParam) implementsDNSRecordUnionParam() {} -type DNSRecordAAAA struct { +type AAAARecord struct { // A valid IPv6 address. Content string `json:"content,required" format:"ipv6"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordAAAAType `json:"type,required"` + Type AAAARecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -476,7 +321,7 @@ type DNSRecordAAAA struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordAAAAMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Whether the record can be proxied by Cloudflare or not. @@ -485,20 +330,20 @@ type DNSRecordAAAA struct { // Cloudflare. Proxied bool `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `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. - TTL DNSRecordAAAATTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordAAAAJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON aaaaRecordJSON `json:"-"` } -// dnsRecordAAAAJSON contains the JSON metadata for the struct [DNSRecordAAAA] -type dnsRecordAAAAJSON struct { +// aaaaRecordJSON contains the JSON metadata for the struct [AAAARecord] +type aaaaRecordJSON struct { Content apijson.Field Name apijson.Field Type apijson.Field @@ -518,103 +363,65 @@ type dnsRecordAAAAJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordAAAA) UnmarshalJSON(data []byte) (err error) { +func (r *AAAARecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordAAAAJSON) RawJSON() string { +func (r aaaaRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordAAAA) implementsDNSDNSRecord() {} +func (r AAAARecord) implementsDNSRecord() {} // Record type. -type DNSRecordAAAAType string +type AAAARecordType string const ( - DNSRecordAAAATypeAAAA DNSRecordAAAAType = "AAAA" + AAAARecordTypeAAAA AAAARecordType = "AAAA" ) -func (r DNSRecordAAAAType) IsKnown() bool { +func (r AAAARecordType) IsKnown() bool { switch r { - case DNSRecordAAAATypeAAAA: + case AAAARecordTypeAAAA: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordAAAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordAAAAMetaJSON `json:"-"` -} - -// dnsRecordAAAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordAAAAMeta] -type dnsRecordAAAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordAAAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordAAAAMetaJSON) RawJSON() string { - return r.raw -} - -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordAAAATTLNumber]. -type DNSRecordAAAATTL interface { - ImplementsDNSDNSRecordAaaattl() +type AAAARecordParam struct { + // A valid IPv6 address. + Content param.Field[string] `json:"content,required" format:"ipv6"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[AAAARecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordAAAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordAAAATTLNumber(0)), - }, - ) +func (r AAAARecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordAAAATTLNumber float64 - -const ( - DNSRecordAAAATTLNumber1 DNSRecordAAAATTLNumber = 1 -) - -func (r DNSRecordAAAATTLNumber) IsKnown() bool { - switch r { - case DNSRecordAAAATTLNumber1: - return true - } - return false -} +func (r AAAARecordParam) implementsDNSRecordUnionParam() {} -type DNSRecordCAA struct { +type CAARecord struct { // Components of a CAA record. - Data DNSRecordCAAData `json:"data,required"` + Data CAARecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordCAAType `json:"type,required"` + Type CAARecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -628,26 +435,26 @@ type DNSRecordCAA struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordCAAMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordCAATTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordCAAJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON caaRecordJSON `json:"-"` } -// dnsRecordCAAJSON contains the JSON metadata for the struct [DNSRecordCAA] -type dnsRecordCAAJSON struct { +// caaRecordJSON contains the JSON metadata for the struct [CAARecord] +type caaRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -667,30 +474,29 @@ type dnsRecordCAAJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordCAA) UnmarshalJSON(data []byte) (err error) { +func (r *CAARecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordCAAJSON) RawJSON() string { +func (r caaRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordCAA) implementsDNSDNSRecord() {} +func (r CAARecord) implementsDNSRecord() {} // Components of a CAA record. -type DNSRecordCAAData struct { +type CAARecordData struct { // Flags for the CAA record. Flags float64 `json:"flags"` // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). Tag string `json:"tag"` // Value of the record. This field's semantics depend on the chosen tag. - Value string `json:"value"` - JSON dnsRecordCAADataJSON `json:"-"` + Value string `json:"value"` + JSON caaRecordDataJSON `json:"-"` } -// dnsRecordCAADataJSON contains the JSON metadata for the struct -// [DNSRecordCAAData] -type dnsRecordCAADataJSON struct { +// caaRecordDataJSON contains the JSON metadata for the struct [CAARecordData] +type caaRecordDataJSON struct { Flags apijson.Field Tag apijson.Field Value apijson.Field @@ -698,101 +504,74 @@ type dnsRecordCAADataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordCAAData) UnmarshalJSON(data []byte) (err error) { +func (r *CAARecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordCAADataJSON) RawJSON() string { +func (r caaRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordCAAType string +type CAARecordType string const ( - DNSRecordCAATypeCAA DNSRecordCAAType = "CAA" + CAARecordTypeCAA CAARecordType = "CAA" ) -func (r DNSRecordCAAType) IsKnown() bool { +func (r CAARecordType) IsKnown() bool { switch r { - case DNSRecordCAATypeCAA: + case CAARecordTypeCAA: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordCAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordCAAMetaJSON `json:"-"` +type CAARecordParam struct { + // Components of a CAA record. + Data param.Field[CAARecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[CAARecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -// dnsRecordCAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordCAAMeta] -type dnsRecordCAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r CAARecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *DNSRecordCAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +func (r CAARecordParam) implementsDNSRecordUnionParam() {} -func (r dnsRecordCAAMetaJSON) RawJSON() string { - return r.raw +// Components of a CAA record. +type CAARecordDataParam struct { + // Flags for the CAA record. + Flags param.Field[float64] `json:"flags"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag param.Field[string] `json:"tag"` + // Value of the record. This field's semantics depend on the chosen tag. + Value param.Field[string] `json:"value"` } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordCAATTLNumber]. -type DNSRecordCAATTL interface { - ImplementsDNSDNSRecordCaattl() +func (r CAARecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordCAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordCAATTLNumber(0)), - }, - ) -} - -type DNSRecordCAATTLNumber float64 - -const ( - DNSRecordCAATTLNumber1 DNSRecordCAATTLNumber = 1 -) - -func (r DNSRecordCAATTLNumber) IsKnown() bool { - switch r { - case DNSRecordCAATTLNumber1: - return true - } - return false -} - -type DNSRecordCERT struct { +type CERTRecord struct { // Components of a CERT record. - Data DNSRecordCERTData `json:"data,required"` + Data CERTRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordCERTType `json:"type,required"` + Type CERTRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -806,26 +585,26 @@ type DNSRecordCERT struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordCERTMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordCERTTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordCERTJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON certRecordJSON `json:"-"` } -// dnsRecordCERTJSON contains the JSON metadata for the struct [DNSRecordCERT] -type dnsRecordCERTJSON struct { +// certRecordJSON contains the JSON metadata for the struct [CERTRecord] +type certRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -845,18 +624,18 @@ type dnsRecordCERTJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordCERT) UnmarshalJSON(data []byte) (err error) { +func (r *CERTRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordCERTJSON) RawJSON() string { +func (r certRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordCERT) implementsDNSDNSRecord() {} +func (r CERTRecord) implementsDNSRecord() {} // Components of a CERT record. -type DNSRecordCERTData struct { +type CERTRecordData struct { // Algorithm. Algorithm float64 `json:"algorithm"` // Certificate. @@ -864,13 +643,12 @@ type DNSRecordCERTData struct { // Key Tag. KeyTag float64 `json:"key_tag"` // Type. - Type float64 `json:"type"` - JSON dnsRecordCERTDataJSON `json:"-"` + Type float64 `json:"type"` + JSON certRecordDataJSON `json:"-"` } -// dnsRecordCERTDataJSON contains the JSON metadata for the struct -// [DNSRecordCERTData] -type dnsRecordCERTDataJSON struct { +// certRecordDataJSON contains the JSON metadata for the struct [CERTRecordData] +type certRecordDataJSON struct { Algorithm apijson.Field Certificate apijson.Field KeyTag apijson.Field @@ -879,101 +657,76 @@ type dnsRecordCERTDataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordCERTData) UnmarshalJSON(data []byte) (err error) { +func (r *CERTRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordCERTDataJSON) RawJSON() string { +func (r certRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordCERTType string +type CERTRecordType string const ( - DNSRecordCERTTypeCERT DNSRecordCERTType = "CERT" + CERTRecordTypeCERT CERTRecordType = "CERT" ) -func (r DNSRecordCERTType) IsKnown() bool { +func (r CERTRecordType) IsKnown() bool { switch r { - case DNSRecordCERTTypeCERT: + case CERTRecordTypeCERT: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordCERTMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordCERTMetaJSON `json:"-"` -} - -// dnsRecordCERTMetaJSON contains the JSON metadata for the struct -// [DNSRecordCERTMeta] -type dnsRecordCERTMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordCERTMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type CERTRecordParam struct { + // Components of a CERT record. + Data param.Field[CERTRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[CERTRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r dnsRecordCERTMetaJSON) RawJSON() string { - return r.raw +func (r CERTRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordCERTTTLNumber]. -type DNSRecordCERTTTL interface { - ImplementsDNSDNSRecordCertttl() -} +func (r CERTRecordParam) implementsDNSRecordUnionParam() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordCERTTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordCERTTTLNumber(0)), - }, - ) +// Components of a CERT record. +type CERTRecordDataParam struct { + // Algorithm. + Algorithm param.Field[float64] `json:"algorithm"` + // Certificate. + Certificate param.Field[string] `json:"certificate"` + // Key Tag. + KeyTag param.Field[float64] `json:"key_tag"` + // Type. + Type param.Field[float64] `json:"type"` } -type DNSRecordCERTTTLNumber float64 - -const ( - DNSRecordCERTTTLNumber1 DNSRecordCERTTTLNumber = 1 -) - -func (r DNSRecordCERTTTLNumber) IsKnown() bool { - switch r { - case DNSRecordCERTTTLNumber1: - return true - } - return false +func (r CERTRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordCNAME struct { +type CNAMERecord struct { // A valid hostname. Must not match the record's name. Content interface{} `json:"content,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordCNAMEType `json:"type,required"` + Type CNAMERecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -985,7 +738,7 @@ type DNSRecordCNAME struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordCNAMEMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Whether the record can be proxied by Cloudflare or not. @@ -994,20 +747,20 @@ type DNSRecordCNAME struct { // Cloudflare. Proxied bool `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `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. - TTL DNSRecordCNAMETTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordCNAMEJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON cnameRecordJSON `json:"-"` } -// dnsRecordCNAMEJSON contains the JSON metadata for the struct [DNSRecordCNAME] -type dnsRecordCNAMEJSON struct { +// cnameRecordJSON contains the JSON metadata for the struct [CNAMERecord] +type cnameRecordJSON struct { Content apijson.Field Name apijson.Field Type apijson.Field @@ -1027,103 +780,65 @@ type dnsRecordCNAMEJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordCNAME) UnmarshalJSON(data []byte) (err error) { +func (r *CNAMERecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordCNAMEJSON) RawJSON() string { +func (r cnameRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordCNAME) implementsDNSDNSRecord() {} +func (r CNAMERecord) implementsDNSRecord() {} // Record type. -type DNSRecordCNAMEType string +type CNAMERecordType string const ( - DNSRecordCNAMETypeCNAME DNSRecordCNAMEType = "CNAME" + CNAMERecordTypeCNAME CNAMERecordType = "CNAME" ) -func (r DNSRecordCNAMEType) IsKnown() bool { +func (r CNAMERecordType) IsKnown() bool { switch r { - case DNSRecordCNAMETypeCNAME: + case CNAMERecordTypeCNAME: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordCNAMEMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordCNAMEMetaJSON `json:"-"` -} - -// dnsRecordCNAMEMetaJSON contains the JSON metadata for the struct -// [DNSRecordCNAMEMeta] -type dnsRecordCNAMEMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordCNAMEMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordCNAMEMetaJSON) RawJSON() string { - return r.raw -} - -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordCNAMETTLNumber]. -type DNSRecordCNAMETTL interface { - ImplementsDNSDNSRecordCnamettl() +type CNAMERecordParam struct { + // A valid hostname. Must not match the record's name. + Content param.Field[interface{}] `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[CNAMERecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordCNAMETTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordCNAMETTLNumber(0)), - }, - ) +func (r CNAMERecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordCNAMETTLNumber float64 - -const ( - DNSRecordCNAMETTLNumber1 DNSRecordCNAMETTLNumber = 1 -) - -func (r DNSRecordCNAMETTLNumber) IsKnown() bool { - switch r { - case DNSRecordCNAMETTLNumber1: - return true - } - return false -} +func (r CNAMERecordParam) implementsDNSRecordUnionParam() {} -type DNSRecordDNSKEY struct { +type DNSKEYRecord struct { // Components of a DNSKEY record. - Data DNSRecordDNSKEYData `json:"data,required"` + Data DNSKEYRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordDNSKEYType `json:"type,required"` + Type DNSKEYRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -1137,26 +852,26 @@ type DNSRecordDNSKEY struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordDNSKEYMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordDNSKEYTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordDNSKEYJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON dnskeyRecordJSON `json:"-"` } -// dnsRecordDNSKEYJSON contains the JSON metadata for the struct [DNSRecordDNSKEY] -type dnsRecordDNSKEYJSON struct { +// dnskeyRecordJSON contains the JSON metadata for the struct [DNSKEYRecord] +type dnskeyRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -1176,18 +891,18 @@ type dnsRecordDNSKEYJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordDNSKEY) UnmarshalJSON(data []byte) (err error) { +func (r *DNSKEYRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordDNSKEYJSON) RawJSON() string { +func (r dnskeyRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordDNSKEY) implementsDNSDNSRecord() {} +func (r DNSKEYRecord) implementsDNSRecord() {} // Components of a DNSKEY record. -type DNSRecordDNSKEYData struct { +type DNSKEYRecordData struct { // Algorithm. Algorithm float64 `json:"algorithm"` // Flags. @@ -1195,13 +910,13 @@ type DNSRecordDNSKEYData struct { // Protocol. Protocol float64 `json:"protocol"` // Public Key. - PublicKey string `json:"public_key"` - JSON dnsRecordDNSKEYDataJSON `json:"-"` + PublicKey string `json:"public_key"` + JSON dnskeyRecordDataJSON `json:"-"` } -// dnsRecordDNSKEYDataJSON contains the JSON metadata for the struct -// [DNSRecordDNSKEYData] -type dnsRecordDNSKEYDataJSON struct { +// dnskeyRecordDataJSON contains the JSON metadata for the struct +// [DNSKEYRecordData] +type dnskeyRecordDataJSON struct { Algorithm apijson.Field Flags apijson.Field Protocol apijson.Field @@ -1210,101 +925,76 @@ type dnsRecordDNSKEYDataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordDNSKEYData) UnmarshalJSON(data []byte) (err error) { +func (r *DNSKEYRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordDNSKEYDataJSON) RawJSON() string { +func (r dnskeyRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordDNSKEYType string +type DNSKEYRecordType string const ( - DNSRecordDNSKEYTypeDNSKEY DNSRecordDNSKEYType = "DNSKEY" + DNSKEYRecordTypeDNSKEY DNSKEYRecordType = "DNSKEY" ) -func (r DNSRecordDNSKEYType) IsKnown() bool { +func (r DNSKEYRecordType) IsKnown() bool { switch r { - case DNSRecordDNSKEYTypeDNSKEY: + case DNSKEYRecordTypeDNSKEY: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordDNSKEYMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordDNSKEYMetaJSON `json:"-"` -} - -// dnsRecordDNSKEYMetaJSON contains the JSON metadata for the struct -// [DNSRecordDNSKEYMeta] -type dnsRecordDNSKEYMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type DNSKEYRecordParam struct { + // Components of a DNSKEY record. + Data param.Field[DNSKEYRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[DNSKEYRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r dnsRecordDNSKEYMetaJSON) RawJSON() string { - return r.raw +func (r DNSKEYRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordDNSKEYTTLNumber]. -type DNSRecordDNSKEYTTL interface { - ImplementsDNSDNSRecordDnskeyttl() -} +func (r DNSKEYRecordParam) implementsDNSRecordUnionParam() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordDNSKEYTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordDNSKEYTTLNumber(0)), - }, - ) +// Components of a DNSKEY record. +type DNSKEYRecordDataParam struct { + // Algorithm. + Algorithm param.Field[float64] `json:"algorithm"` + // Flags. + Flags param.Field[float64] `json:"flags"` + // Protocol. + Protocol param.Field[float64] `json:"protocol"` + // Public Key. + PublicKey param.Field[string] `json:"public_key"` } -type DNSRecordDNSKEYTTLNumber float64 - -const ( - DNSRecordDNSKEYTTLNumber1 DNSRecordDNSKEYTTLNumber = 1 -) - -func (r DNSRecordDNSKEYTTLNumber) IsKnown() bool { - switch r { - case DNSRecordDNSKEYTTLNumber1: - return true - } - return false +func (r DNSKEYRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordDS struct { +type DSRecord struct { // Components of a DS record. - Data DNSRecordDSData `json:"data,required"` + Data DSRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordDSType `json:"type,required"` + Type DSRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -1318,26 +1008,26 @@ type DNSRecordDS struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordDSMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordDSTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordDSJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON dsRecordJSON `json:"-"` } -// dnsRecordDSJSON contains the JSON metadata for the struct [DNSRecordDS] -type dnsRecordDSJSON struct { +// dsRecordJSON contains the JSON metadata for the struct [DSRecord] +type dsRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -1357,18 +1047,18 @@ type dnsRecordDSJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordDS) UnmarshalJSON(data []byte) (err error) { +func (r *DSRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordDSJSON) RawJSON() string { +func (r dsRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordDS) implementsDNSDNSRecord() {} +func (r DSRecord) implementsDNSRecord() {} // Components of a DS record. -type DNSRecordDSData struct { +type DSRecordData struct { // Algorithm. Algorithm float64 `json:"algorithm"` // Digest. @@ -1376,12 +1066,12 @@ type DNSRecordDSData struct { // Digest Type. DigestType float64 `json:"digest_type"` // Key Tag. - KeyTag float64 `json:"key_tag"` - JSON dnsRecordDSDataJSON `json:"-"` + KeyTag float64 `json:"key_tag"` + JSON dsRecordDataJSON `json:"-"` } -// dnsRecordDSDataJSON contains the JSON metadata for the struct [DNSRecordDSData] -type dnsRecordDSDataJSON struct { +// dsRecordDataJSON contains the JSON metadata for the struct [DSRecordData] +type dsRecordDataJSON struct { Algorithm apijson.Field Digest apijson.Field DigestType apijson.Field @@ -1390,100 +1080,76 @@ type dnsRecordDSDataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordDSData) UnmarshalJSON(data []byte) (err error) { +func (r *DSRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordDSDataJSON) RawJSON() string { +func (r dsRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordDSType string +type DSRecordType string const ( - DNSRecordDSTypeDS DNSRecordDSType = "DS" + DSRecordTypeDS DSRecordType = "DS" ) -func (r DNSRecordDSType) IsKnown() bool { +func (r DSRecordType) IsKnown() bool { switch r { - case DNSRecordDSTypeDS: + case DSRecordTypeDS: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordDSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordDSMetaJSON `json:"-"` -} - -// dnsRecordDSMetaJSON contains the JSON metadata for the struct [DNSRecordDSMeta] -type dnsRecordDSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field +type DSRecordParam struct { + // Components of a DS record. + Data param.Field[DSRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[DSRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r *DNSRecordDSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r DSRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r dnsRecordDSMetaJSON) RawJSON() string { - return r.raw -} +func (r DSRecordParam) implementsDNSRecordUnionParam() {} -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordDSTTLNumber]. -type DNSRecordDSTTL interface { - ImplementsDNSDNSRecordDsttl() +// Components of a DS record. +type DSRecordDataParam struct { + // Algorithm. + Algorithm param.Field[float64] `json:"algorithm"` + // Digest. + Digest param.Field[string] `json:"digest"` + // Digest Type. + DigestType param.Field[float64] `json:"digest_type"` + // Key Tag. + KeyTag param.Field[float64] `json:"key_tag"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordDSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordDSTTLNumber(0)), - }, - ) +func (r DSRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordDSTTLNumber float64 - -const ( - DNSRecordDSTTLNumber1 DNSRecordDSTTLNumber = 1 -) - -func (r DNSRecordDSTTLNumber) IsKnown() bool { - switch r { - case DNSRecordDSTTLNumber1: - return true - } - return false -} - -type DNSRecordHTTPS struct { +type HTTPSRecord struct { // Components of a HTTPS record. - Data DNSRecordHTTPSData `json:"data,required"` + Data HTTPSRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordHTTPSType `json:"type,required"` + Type HTTPSRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -1497,26 +1163,26 @@ type DNSRecordHTTPS struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordHTTPSMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordHTTPSTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordHTTPSJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON httpsRecordJSON `json:"-"` } -// dnsRecordHTTPSJSON contains the JSON metadata for the struct [DNSRecordHTTPS] -type dnsRecordHTTPSJSON struct { +// httpsRecordJSON contains the JSON metadata for the struct [HTTPSRecord] +type httpsRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -1536,30 +1202,29 @@ type dnsRecordHTTPSJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordHTTPS) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPSRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordHTTPSJSON) RawJSON() string { +func (r httpsRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordHTTPS) implementsDNSDNSRecord() {} +func (r HTTPSRecord) implementsDNSRecord() {} // Components of a HTTPS record. -type DNSRecordHTTPSData struct { +type HTTPSRecordData struct { // priority. Priority float64 `json:"priority"` // target. Target string `json:"target"` // value. - Value string `json:"value"` - JSON dnsRecordHTTPSDataJSON `json:"-"` + Value string `json:"value"` + JSON httpsRecordDataJSON `json:"-"` } -// dnsRecordHTTPSDataJSON contains the JSON metadata for the struct -// [DNSRecordHTTPSData] -type dnsRecordHTTPSDataJSON struct { +// httpsRecordDataJSON contains the JSON metadata for the struct [HTTPSRecordData] +type httpsRecordDataJSON struct { Priority apijson.Field Target apijson.Field Value apijson.Field @@ -1567,101 +1232,74 @@ type dnsRecordHTTPSDataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordHTTPSData) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPSRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordHTTPSDataJSON) RawJSON() string { +func (r httpsRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordHTTPSType string +type HTTPSRecordType string const ( - DNSRecordHTTPSTypeHTTPS DNSRecordHTTPSType = "HTTPS" + HTTPSRecordTypeHTTPS HTTPSRecordType = "HTTPS" ) -func (r DNSRecordHTTPSType) IsKnown() bool { +func (r HTTPSRecordType) IsKnown() bool { switch r { - case DNSRecordHTTPSTypeHTTPS: + case HTTPSRecordTypeHTTPS: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordHTTPSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordHTTPSMetaJSON `json:"-"` -} - -// dnsRecordHTTPSMetaJSON contains the JSON metadata for the struct -// [DNSRecordHTTPSMeta] -type dnsRecordHTTPSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordHTTPSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type HTTPSRecordParam struct { + // Components of a HTTPS record. + Data param.Field[HTTPSRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[HTTPSRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r dnsRecordHTTPSMetaJSON) RawJSON() string { - return r.raw +func (r HTTPSRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordHTTPSTTLNumber]. -type DNSRecordHTTPSTTL interface { - ImplementsDNSDNSRecordHttpsttl() -} +func (r HTTPSRecordParam) implementsDNSRecordUnionParam() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordHTTPSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordHTTPSTTLNumber(0)), - }, - ) +// Components of a HTTPS record. +type HTTPSRecordDataParam struct { + // priority. + Priority param.Field[float64] `json:"priority"` + // target. + Target param.Field[string] `json:"target"` + // value. + Value param.Field[string] `json:"value"` } -type DNSRecordHTTPSTTLNumber float64 - -const ( - DNSRecordHTTPSTTLNumber1 DNSRecordHTTPSTTLNumber = 1 -) - -func (r DNSRecordHTTPSTTLNumber) IsKnown() bool { - switch r { - case DNSRecordHTTPSTTLNumber1: - return true - } - return false +func (r HTTPSRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordLOC struct { +type LOCRecord struct { // Components of a LOC record. - Data DNSRecordLOCData `json:"data,required"` + Data LOCRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordLOCType `json:"type,required"` + Type LOCRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -1675,26 +1313,26 @@ type DNSRecordLOC struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordLOCMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordLOCTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordLOCJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON locRecordJSON `json:"-"` } -// dnsRecordLOCJSON contains the JSON metadata for the struct [DNSRecordLOC] -type dnsRecordLOCJSON struct { +// locRecordJSON contains the JSON metadata for the struct [LOCRecord] +type locRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -1714,24 +1352,24 @@ type dnsRecordLOCJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordLOC) UnmarshalJSON(data []byte) (err error) { +func (r *LOCRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordLOCJSON) RawJSON() string { +func (r locRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordLOC) implementsDNSDNSRecord() {} +func (r LOCRecord) implementsDNSRecord() {} // Components of a LOC record. -type DNSRecordLOCData struct { +type LOCRecordData struct { // Altitude of location in meters. Altitude float64 `json:"altitude"` // Degrees of latitude. LatDegrees float64 `json:"lat_degrees"` // Latitude direction. - LatDirection DNSRecordLOCDataLatDirection `json:"lat_direction"` + LatDirection LOCRecordDataLatDirection `json:"lat_direction"` // Minutes of latitude. LatMinutes float64 `json:"lat_minutes"` // Seconds of latitude. @@ -1739,7 +1377,7 @@ type DNSRecordLOCData struct { // Degrees of longitude. LongDegrees float64 `json:"long_degrees"` // Longitude direction. - LongDirection DNSRecordLOCDataLongDirection `json:"long_direction"` + LongDirection LOCRecordDataLongDirection `json:"long_direction"` // Minutes of longitude. LongMinutes float64 `json:"long_minutes"` // Seconds of longitude. @@ -1749,13 +1387,12 @@ type DNSRecordLOCData struct { // Vertical precision of location. PrecisionVert float64 `json:"precision_vert"` // Size of location in meters. - Size float64 `json:"size"` - JSON dnsRecordLOCDataJSON `json:"-"` + Size float64 `json:"size"` + JSON locRecordDataJSON `json:"-"` } -// dnsRecordLOCDataJSON contains the JSON metadata for the struct -// [DNSRecordLOCData] -type dnsRecordLOCDataJSON struct { +// locRecordDataJSON contains the JSON metadata for the struct [LOCRecordData] +type locRecordDataJSON struct { Altitude apijson.Field LatDegrees apijson.Field LatDirection apijson.Field @@ -1772,127 +1409,118 @@ type dnsRecordLOCDataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordLOCData) UnmarshalJSON(data []byte) (err error) { +func (r *LOCRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordLOCDataJSON) RawJSON() string { +func (r locRecordDataJSON) RawJSON() string { return r.raw } // Latitude direction. -type DNSRecordLOCDataLatDirection string +type LOCRecordDataLatDirection string const ( - DNSRecordLOCDataLatDirectionN DNSRecordLOCDataLatDirection = "N" - DNSRecordLOCDataLatDirectionS DNSRecordLOCDataLatDirection = "S" + LOCRecordDataLatDirectionN LOCRecordDataLatDirection = "N" + LOCRecordDataLatDirectionS LOCRecordDataLatDirection = "S" ) -func (r DNSRecordLOCDataLatDirection) IsKnown() bool { +func (r LOCRecordDataLatDirection) IsKnown() bool { switch r { - case DNSRecordLOCDataLatDirectionN, DNSRecordLOCDataLatDirectionS: + case LOCRecordDataLatDirectionN, LOCRecordDataLatDirectionS: return true } return false } // Longitude direction. -type DNSRecordLOCDataLongDirection string +type LOCRecordDataLongDirection string const ( - DNSRecordLOCDataLongDirectionE DNSRecordLOCDataLongDirection = "E" - DNSRecordLOCDataLongDirectionW DNSRecordLOCDataLongDirection = "W" + LOCRecordDataLongDirectionE LOCRecordDataLongDirection = "E" + LOCRecordDataLongDirectionW LOCRecordDataLongDirection = "W" ) -func (r DNSRecordLOCDataLongDirection) IsKnown() bool { +func (r LOCRecordDataLongDirection) IsKnown() bool { switch r { - case DNSRecordLOCDataLongDirectionE, DNSRecordLOCDataLongDirectionW: + case LOCRecordDataLongDirectionE, LOCRecordDataLongDirectionW: return true } return false } // Record type. -type DNSRecordLOCType string +type LOCRecordType string const ( - DNSRecordLOCTypeLOC DNSRecordLOCType = "LOC" + LOCRecordTypeLOC LOCRecordType = "LOC" ) -func (r DNSRecordLOCType) IsKnown() bool { +func (r LOCRecordType) IsKnown() bool { switch r { - case DNSRecordLOCTypeLOC: + case LOCRecordTypeLOC: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordLOCMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordLOCMetaJSON `json:"-"` -} - -// dnsRecordLOCMetaJSON contains the JSON metadata for the struct -// [DNSRecordLOCMeta] -type dnsRecordLOCMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordLOCMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type LOCRecordParam struct { + // Components of a LOC record. + Data param.Field[LOCRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[LOCRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r dnsRecordLOCMetaJSON) RawJSON() string { - return r.raw +func (r LOCRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordLOCTTLNumber]. -type DNSRecordLOCTTL interface { - ImplementsDNSDNSRecordLocttl() -} +func (r LOCRecordParam) implementsDNSRecordUnionParam() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordLOCTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordLOCTTLNumber(0)), - }, - ) +// Components of a LOC record. +type LOCRecordDataParam struct { + // Altitude of location in meters. + Altitude param.Field[float64] `json:"altitude"` + // Degrees of latitude. + LatDegrees param.Field[float64] `json:"lat_degrees"` + // Latitude direction. + LatDirection param.Field[LOCRecordDataLatDirection] `json:"lat_direction"` + // Minutes of latitude. + LatMinutes param.Field[float64] `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds param.Field[float64] `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees param.Field[float64] `json:"long_degrees"` + // Longitude direction. + LongDirection param.Field[LOCRecordDataLongDirection] `json:"long_direction"` + // Minutes of longitude. + LongMinutes param.Field[float64] `json:"long_minutes"` + // Seconds of longitude. + LongSeconds param.Field[float64] `json:"long_seconds"` + // Horizontal precision of location. + PrecisionHorz param.Field[float64] `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert param.Field[float64] `json:"precision_vert"` + // Size of location in meters. + Size param.Field[float64] `json:"size"` } -type DNSRecordLOCTTLNumber float64 - -const ( - DNSRecordLOCTTLNumber1 DNSRecordLOCTTLNumber = 1 -) - -func (r DNSRecordLOCTTLNumber) IsKnown() bool { - switch r { - case DNSRecordLOCTTLNumber1: - return true - } - return false +func (r LOCRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordMX struct { +type MXRecord struct { // A valid mail server hostname. Content string `json:"content,required" format:"hostname"` // DNS record name (or @ for the zone apex) in Punycode. @@ -1901,7 +1529,7 @@ type DNSRecordMX struct { // lower priorities are preferred. Priority float64 `json:"priority,required"` // Record type. - Type DNSRecordMXType `json:"type,required"` + Type MXRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -1913,26 +1541,26 @@ type DNSRecordMX struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordMXMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordMXTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordMXJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON mxRecordJSON `json:"-"` } -// dnsRecordMXJSON contains the JSON metadata for the struct [DNSRecordMX] -type dnsRecordMXJSON struct { +// mxRecordJSON contains the JSON metadata for the struct [MXRecord] +type mxRecordJSON struct { Content apijson.Field Name apijson.Field Priority apijson.Field @@ -1952,102 +1580,65 @@ type dnsRecordMXJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordMX) UnmarshalJSON(data []byte) (err error) { +func (r *MXRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordMXJSON) RawJSON() string { +func (r mxRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordMX) implementsDNSDNSRecord() {} +func (r MXRecord) implementsDNSRecord() {} // Record type. -type DNSRecordMXType string +type MXRecordType string const ( - DNSRecordMXTypeMX DNSRecordMXType = "MX" + MXRecordTypeMX MXRecordType = "MX" ) -func (r DNSRecordMXType) IsKnown() bool { +func (r MXRecordType) IsKnown() bool { switch r { - case DNSRecordMXTypeMX: + case MXRecordTypeMX: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordMXMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordMXMetaJSON `json:"-"` -} - -// dnsRecordMXMetaJSON contains the JSON metadata for the struct [DNSRecordMXMeta] -type dnsRecordMXMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordMXMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordMXMetaJSON) RawJSON() string { - return r.raw -} - -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordMXTTLNumber]. -type DNSRecordMXTTL interface { - ImplementsDNSDNSRecordMxttl() +type MXRecordParam struct { + // A valid mail server hostname. + Content param.Field[string] `json:"content,required" format:"hostname"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority param.Field[float64] `json:"priority,required"` + // Record type. + Type param.Field[MXRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordMXTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordMXTTLNumber(0)), - }, - ) +func (r MXRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordMXTTLNumber float64 - -const ( - DNSRecordMXTTLNumber1 DNSRecordMXTTLNumber = 1 -) - -func (r DNSRecordMXTTLNumber) IsKnown() bool { - switch r { - case DNSRecordMXTTLNumber1: - return true - } - return false -} +func (r MXRecordParam) implementsDNSRecordUnionParam() {} -type DNSRecordNAPTR struct { +type NAPTRRecord struct { // Components of a NAPTR record. - Data DNSRecordNAPTRData `json:"data,required"` + Data NAPTRRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordNAPTRType `json:"type,required"` + Type NAPTRRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -2061,26 +1652,26 @@ type DNSRecordNAPTR struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordNAPTRMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordNAPTRTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNAPTRJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON naptrRecordJSON `json:"-"` } -// dnsRecordNAPTRJSON contains the JSON metadata for the struct [DNSRecordNAPTR] -type dnsRecordNAPTRJSON struct { +// naptrRecordJSON contains the JSON metadata for the struct [NAPTRRecord] +type naptrRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -2100,18 +1691,18 @@ type dnsRecordNAPTRJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordNAPTR) UnmarshalJSON(data []byte) (err error) { +func (r *NAPTRRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordNAPTRJSON) RawJSON() string { +func (r naptrRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordNAPTR) implementsDNSDNSRecord() {} +func (r NAPTRRecord) implementsDNSRecord() {} // Components of a NAPTR record. -type DNSRecordNAPTRData struct { +type NAPTRRecordData struct { // Flags. Flags string `json:"flags"` // Order. @@ -2123,13 +1714,12 @@ type DNSRecordNAPTRData struct { // Replacement. Replacement string `json:"replacement"` // Service. - Service string `json:"service"` - JSON dnsRecordNAPTRDataJSON `json:"-"` + Service string `json:"service"` + JSON naptrRecordDataJSON `json:"-"` } -// dnsRecordNAPTRDataJSON contains the JSON metadata for the struct -// [DNSRecordNAPTRData] -type dnsRecordNAPTRDataJSON struct { +// naptrRecordDataJSON contains the JSON metadata for the struct [NAPTRRecordData] +type naptrRecordDataJSON struct { Flags apijson.Field Order apijson.Field Preference apijson.Field @@ -2140,101 +1730,80 @@ type dnsRecordNAPTRDataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordNAPTRData) UnmarshalJSON(data []byte) (err error) { +func (r *NAPTRRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordNAPTRDataJSON) RawJSON() string { +func (r naptrRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordNAPTRType string +type NAPTRRecordType string const ( - DNSRecordNAPTRTypeNAPTR DNSRecordNAPTRType = "NAPTR" + NAPTRRecordTypeNAPTR NAPTRRecordType = "NAPTR" ) -func (r DNSRecordNAPTRType) IsKnown() bool { +func (r NAPTRRecordType) IsKnown() bool { switch r { - case DNSRecordNAPTRTypeNAPTR: + case NAPTRRecordTypeNAPTR: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordNAPTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNAPTRMetaJSON `json:"-"` -} - -// dnsRecordNAPTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordNAPTRMeta] -type dnsRecordNAPTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field +type NAPTRRecordParam struct { + // Components of a NAPTR record. + Data param.Field[NAPTRRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[NAPTRRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r *DNSRecordNAPTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r NAPTRRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r dnsRecordNAPTRMetaJSON) RawJSON() string { - return r.raw -} +func (r NAPTRRecordParam) implementsDNSRecordUnionParam() {} -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordNAPTRTTLNumber]. -type DNSRecordNAPTRTTL interface { - ImplementsDNSDNSRecordNaptrttl() +// Components of a NAPTR record. +type NAPTRRecordDataParam struct { + // Flags. + Flags param.Field[string] `json:"flags"` + // Order. + Order param.Field[float64] `json:"order"` + // Preference. + Preference param.Field[float64] `json:"preference"` + // Regex. + Regex param.Field[string] `json:"regex"` + // Replacement. + Replacement param.Field[string] `json:"replacement"` + // Service. + Service param.Field[string] `json:"service"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNAPTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNAPTRTTLNumber(0)), - }, - ) +func (r NAPTRRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordNAPTRTTLNumber float64 - -const ( - DNSRecordNAPTRTTLNumber1 DNSRecordNAPTRTTLNumber = 1 -) - -func (r DNSRecordNAPTRTTLNumber) IsKnown() bool { - switch r { - case DNSRecordNAPTRTTLNumber1: - return true - } - return false -} - -type DNSRecordNS struct { +type NSRecord struct { // A valid name server host name. Content string `json:"content,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordNSType `json:"type,required"` + Type NSRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -2246,26 +1815,26 @@ type DNSRecordNS struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordNSMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordNSTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNSJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON nsRecordJSON `json:"-"` } -// dnsRecordNSJSON contains the JSON metadata for the struct [DNSRecordNS] -type dnsRecordNSJSON struct { +// nsRecordJSON contains the JSON metadata for the struct [NSRecord] +type nsRecordJSON struct { Content apijson.Field Name apijson.Field Type apijson.Field @@ -2284,102 +1853,62 @@ type dnsRecordNSJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordNS) UnmarshalJSON(data []byte) (err error) { +func (r *NSRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordNSJSON) RawJSON() string { +func (r nsRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordNS) implementsDNSDNSRecord() {} +func (r NSRecord) implementsDNSRecord() {} // Record type. -type DNSRecordNSType string +type NSRecordType string const ( - DNSRecordNSTypeNS DNSRecordNSType = "NS" + NSRecordTypeNS NSRecordType = "NS" ) -func (r DNSRecordNSType) IsKnown() bool { +func (r NSRecordType) IsKnown() bool { switch r { - case DNSRecordNSTypeNS: + case NSRecordTypeNS: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordNSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNSMetaJSON `json:"-"` -} - -// dnsRecordNSMetaJSON contains the JSON metadata for the struct [DNSRecordNSMeta] -type dnsRecordNSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNSMetaJSON) RawJSON() string { - return r.raw -} - -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordNSTTLNumber]. -type DNSRecordNSTTL interface { - ImplementsDNSDNSRecordNsttl() +type NSRecordParam struct { + // A valid name server host name. + Content param.Field[string] `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[NSRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNSTTLNumber(0)), - }, - ) +func (r NSRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordNSTTLNumber float64 - -const ( - DNSRecordNSTTLNumber1 DNSRecordNSTTLNumber = 1 -) - -func (r DNSRecordNSTTLNumber) IsKnown() bool { - switch r { - case DNSRecordNSTTLNumber1: - return true - } - return false -} +func (r NSRecordParam) implementsDNSRecordUnionParam() {} -type DNSRecordPTR struct { +type PTRRecord struct { // Domain name pointing to the address. Content string `json:"content,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordPTRType `json:"type,required"` + Type PTRRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -2391,26 +1920,26 @@ type DNSRecordPTR struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordPTRMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordPTRTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordPTRJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON ptrRecordJSON `json:"-"` } -// dnsRecordPTRJSON contains the JSON metadata for the struct [DNSRecordPTR] -type dnsRecordPTRJSON struct { +// ptrRecordJSON contains the JSON metadata for the struct [PTRRecord] +type ptrRecordJSON struct { Content apijson.Field Name apijson.Field Type apijson.Field @@ -2429,143 +1958,106 @@ type dnsRecordPTRJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordPTR) UnmarshalJSON(data []byte) (err error) { +func (r *PTRRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordPTRJSON) RawJSON() string { +func (r ptrRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordPTR) implementsDNSDNSRecord() {} +func (r PTRRecord) implementsDNSRecord() {} // Record type. -type DNSRecordPTRType string +type PTRRecordType string const ( - DNSRecordPTRTypePTR DNSRecordPTRType = "PTR" + PTRRecordTypePTR PTRRecordType = "PTR" ) -func (r DNSRecordPTRType) IsKnown() bool { +func (r PTRRecordType) IsKnown() bool { switch r { - case DNSRecordPTRTypePTR: + case PTRRecordTypePTR: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordPTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordPTRMetaJSON `json:"-"` -} - -// dnsRecordPTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordPTRMeta] -type dnsRecordPTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordPTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordPTRMetaJSON) RawJSON() string { - return r.raw -} - -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordPTRTTLNumber]. -type DNSRecordPTRTTL interface { - ImplementsDNSDNSRecordPtrttl() +type PTRRecordParam struct { + // Domain name pointing to the address. + Content param.Field[string] `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[PTRRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordPTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordPTRTTLNumber(0)), - }, - ) +func (r PTRRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordPTRTTLNumber float64 - -const ( - DNSRecordPTRTTLNumber1 DNSRecordPTRTTLNumber = 1 -) - -func (r DNSRecordPTRTTLNumber) IsKnown() bool { - switch r { - case DNSRecordPTRTTLNumber1: - return true - } - return false -} +func (r PTRRecordParam) implementsDNSRecordUnionParam() {} -type DNSRecordSMIMEA struct { - // Components of a SMIMEA record. - Data DNSRecordSMIMEAData `json:"data,required"` +type Record struct { + Content interface{} `json:"content,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` // Record type. - Type DNSRecordSMIMEAType `json:"type,required"` - // Identifier - ID string `json:"id"` + Type RecordType `json:"type,required"` // Comments or notes about the DNS record. This field has no effect on DNS // responses. Comment string `json:"comment"` - // Formatted SMIMEA content. See 'data' to set SMIMEA properties. - Content string `json:"content"` // When the record was created. CreatedOn time.Time `json:"created_on" format:"date-time"` + // Identifier + ID string `json:"id"` // Whether this record can be modified/deleted (true means it's managed by // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordSMIMEAMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `json:"tags"` + Proxiable bool `json:"proxiable"` + Tags interface{} `json:"tags,required"` // 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. - TTL DNSRecordSMIMEATTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordSMIMEAJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + Data interface{} `json:"data,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + JSON recordJSON `json:"-"` + union RecordUnion } -// dnsRecordSMIMEAJSON contains the JSON metadata for the struct [DNSRecordSMIMEA] -type dnsRecordSMIMEAJSON struct { - Data apijson.Field +// recordJSON contains the JSON metadata for the struct [Record] +type recordJSON struct { + Content apijson.Field Name apijson.Field + Proxied apijson.Field Type apijson.Field - ID apijson.Field Comment apijson.Field - Content apijson.Field CreatedOn apijson.Field + ID apijson.Field Locked apijson.Field Meta apijson.Field ModifiedOn apijson.Field @@ -2574,148 +2066,303 @@ type dnsRecordSMIMEAJSON struct { TTL apijson.Field ZoneID apijson.Field ZoneName apijson.Field + Data apijson.Field + Priority apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DNSRecordSMIMEA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordSMIMEAJSON) RawJSON() string { +func (r recordJSON) RawJSON() string { return r.raw } -func (r DNSRecordSMIMEA) implementsDNSDNSRecord() {} - -// Components of a SMIMEA record. -type DNSRecordSMIMEAData struct { - // Certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordSMIMEADataJSON `json:"-"` +func (r *Record) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -// dnsRecordSMIMEADataJSON contains the JSON metadata for the struct -// [DNSRecordSMIMEAData] -type dnsRecordSMIMEADataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r Record) AsUnion() RecordUnion { + return r.union } -func (r *DNSRecordSMIMEAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [dns.ARecord], [dns.AAAARecord], [dns.CAARecord], +// [dns.CERTRecord], [dns.CNAMERecord], [dns.DNSKEYRecord], [dns.DSRecord], +// [dns.HTTPSRecord], [dns.LOCRecord], [dns.MXRecord], [dns.NAPTRRecord], +// [dns.NSRecord], [dns.PTRRecord], [dns.SMIMEARecord], [dns.SRVRecord], +// [dns.SSHFPRecord], [dns.SVCBRecord], [dns.TLSARecord], [dns.TXTRecord] or +// [dns.URIRecord]. +type RecordUnion interface { + implementsDNSRecord() } -func (r dnsRecordSMIMEADataJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUnion)(nil)).Elem(), + "type", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ARecord{}), + DiscriminatorValue: "A", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AAAARecord{}), + DiscriminatorValue: "AAAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CAARecord{}), + DiscriminatorValue: "CAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CERTRecord{}), + DiscriminatorValue: "CERT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CNAMERecord{}), + DiscriminatorValue: "CNAME", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DNSKEYRecord{}), + DiscriminatorValue: "DNSKEY", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DSRecord{}), + DiscriminatorValue: "DS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(HTTPSRecord{}), + DiscriminatorValue: "HTTPS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LOCRecord{}), + DiscriminatorValue: "LOC", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(MXRecord{}), + DiscriminatorValue: "MX", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NAPTRRecord{}), + DiscriminatorValue: "NAPTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NSRecord{}), + DiscriminatorValue: "NS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PTRRecord{}), + DiscriminatorValue: "PTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SMIMEARecord{}), + DiscriminatorValue: "SMIMEA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SRVRecord{}), + DiscriminatorValue: "SRV", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SSHFPRecord{}), + DiscriminatorValue: "SSHFP", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SVCBRecord{}), + DiscriminatorValue: "SVCB", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TLSARecord{}), + DiscriminatorValue: "TLSA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TXTRecord{}), + DiscriminatorValue: "TXT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(URIRecord{}), + DiscriminatorValue: "URI", + }, + ) } // Record type. -type DNSRecordSMIMEAType string +type RecordType string const ( - DNSRecordSMIMEATypeSMIMEA DNSRecordSMIMEAType = "SMIMEA" + RecordTypeA RecordType = "A" + RecordTypeAAAA RecordType = "AAAA" + RecordTypeCAA RecordType = "CAA" + RecordTypeCERT RecordType = "CERT" + RecordTypeCNAME RecordType = "CNAME" + RecordTypeDNSKEY RecordType = "DNSKEY" + RecordTypeDS RecordType = "DS" + RecordTypeHTTPS RecordType = "HTTPS" + RecordTypeLOC RecordType = "LOC" + RecordTypeMX RecordType = "MX" + RecordTypeNAPTR RecordType = "NAPTR" + RecordTypeNS RecordType = "NS" + RecordTypePTR RecordType = "PTR" + RecordTypeSMIMEA RecordType = "SMIMEA" + RecordTypeSRV RecordType = "SRV" + RecordTypeSSHFP RecordType = "SSHFP" + RecordTypeSVCB RecordType = "SVCB" + RecordTypeTLSA RecordType = "TLSA" + RecordTypeTXT RecordType = "TXT" + RecordTypeURI RecordType = "URI" ) -func (r DNSRecordSMIMEAType) IsKnown() bool { +func (r RecordType) IsKnown() bool { switch r { - case DNSRecordSMIMEATypeSMIMEA: + case RecordTypeA, RecordTypeAAAA, RecordTypeCAA, RecordTypeCERT, RecordTypeCNAME, RecordTypeDNSKEY, RecordTypeDS, RecordTypeHTTPS, RecordTypeLOC, RecordTypeMX, RecordTypeNAPTR, RecordTypeNS, RecordTypePTR, RecordTypeSMIMEA, RecordTypeSRV, RecordTypeSSHFP, RecordTypeSVCB, RecordTypeTLSA, RecordTypeTXT, RecordTypeURI: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordSMIMEAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. +type RecordParam struct { + Content param.Field[interface{}] `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `json:"proxied"` + // Record type. + Type param.Field[RecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + Tags param.Field[interface{}] `json:"tags,required"` + // 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` + Data param.Field[interface{}] `json:"data,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority param.Field[float64] `json:"priority"` +} + +func (r RecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RecordParam) implementsDNSRecordUnionParam() {} + +// Satisfied by [dns.ARecordParam], [dns.AAAARecordParam], [dns.CAARecordParam], +// [dns.CERTRecordParam], [dns.CNAMERecordParam], [dns.DNSKEYRecordParam], +// [dns.DSRecordParam], [dns.HTTPSRecordParam], [dns.LOCRecordParam], +// [dns.MXRecordParam], [dns.NAPTRRecordParam], [dns.NSRecordParam], +// [dns.PTRRecordParam], [dns.SMIMEARecordParam], [dns.SRVRecordParam], +// [dns.SSHFPRecordParam], [dns.SVCBRecordParam], [dns.TLSARecordParam], +// [dns.TXTRecordParam], [dns.URIRecordParam], [RecordParam]. +type RecordUnionParam interface { + implementsDNSRecordUnionParam() +} + +// Extra Cloudflare-specific information about the record. +type RecordMetadata struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. AutoAdded bool `json:"auto_added"` // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordSMIMEAMetaJSON `json:"-"` + Source string `json:"source"` + JSON recordMetadataJSON `json:"-"` } -// dnsRecordSMIMEAMetaJSON contains the JSON metadata for the struct -// [DNSRecordSMIMEAMeta] -type dnsRecordSMIMEAMetaJSON struct { +// recordMetadataJSON contains the JSON metadata for the struct [RecordMetadata] +type recordMetadataJSON struct { AutoAdded apijson.Field Source apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DNSRecordSMIMEAMeta) UnmarshalJSON(data []byte) (err error) { +func (r *RecordMetadata) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordSMIMEAMetaJSON) RawJSON() string { +func (r recordMetadataJSON) RawJSON() string { return r.raw } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordSMIMEATTLNumber]. -type DNSRecordSMIMEATTL interface { - ImplementsDNSDNSRecordSmimeattl() +// Extra Cloudflare-specific information about the record. +type RecordMetadataParam struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded param.Field[bool] `json:"auto_added"` + // Where the record originated from. + Source param.Field[string] `json:"source"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordSMIMEATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordSMIMEATTLNumber(0)), - }, - ) +func (r RecordMetadataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordSMIMEATTLNumber float64 +type RecordProcessTiming struct { + // When the file parsing ended. + EndTime time.Time `json:"end_time" format:"date-time"` + // Processing time of the file in seconds. + ProcessTime float64 `json:"process_time"` + // When the file parsing started. + StartTime time.Time `json:"start_time" format:"date-time"` + JSON recordProcessTimingJSON `json:"-"` +} -const ( - DNSRecordSMIMEATTLNumber1 DNSRecordSMIMEATTLNumber = 1 -) +// recordProcessTimingJSON contains the JSON metadata for the struct +// [RecordProcessTiming] +type recordProcessTimingJSON struct { + EndTime apijson.Field + ProcessTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -func (r DNSRecordSMIMEATTLNumber) IsKnown() bool { - switch r { - case DNSRecordSMIMEATTLNumber1: - return true - } - return false +func (r *RecordProcessTiming) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -type DNSRecordSRV struct { - // Components of a SRV record. - Data DNSRecordSRVData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. +func (r recordProcessTimingJSON) RawJSON() string { + return r.raw +} + +type RecordTags = string + +type RecordTagsParam = string + +type SMIMEARecord struct { + // Components of a SMIMEA record. + Data SMIMEARecordData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordSRVType `json:"type,required"` + Type SMIMEARecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS // responses. Comment string `json:"comment"` - // Priority, weight, port, and SRV target. See 'data' for setting the individual - // component values. + // Formatted SMIMEA content. See 'data' to set SMIMEA properties. Content string `json:"content"` // When the record was created. CreatedOn time.Time `json:"created_on" format:"date-time"` @@ -2723,26 +2370,26 @@ type DNSRecordSRV struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordSRVMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordSRVTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordSRVJSON `json:"-"` + JSON smimeaRecordJSON `json:"-"` } -// dnsRecordSRVJSON contains the JSON metadata for the struct [DNSRecordSRV] -type dnsRecordSRVJSON struct { +// smimeaRecordJSON contains the JSON metadata for the struct [SMIMEARecord] +type smimeaRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -2762,157 +2409,119 @@ type dnsRecordSRVJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordSRV) UnmarshalJSON(data []byte) (err error) { +func (r *SMIMEARecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordSRVJSON) RawJSON() string { +func (r smimeaRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordSRV) implementsDNSDNSRecord() {} +func (r SMIMEARecord) implementsDNSRecord() {} -// Components of a SRV record. -type DNSRecordSRVData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name string `json:"name" format:"hostname"` - // The port of the service. - Port float64 `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto string `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service string `json:"service"` - // A valid hostname. - Target string `json:"target" format:"hostname"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordSRVDataJSON `json:"-"` +// Components of a SMIMEA record. +type SMIMEARecordData struct { + // Certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON smimeaRecordDataJSON `json:"-"` } -// dnsRecordSRVDataJSON contains the JSON metadata for the struct -// [DNSRecordSRVData] -type dnsRecordSRVDataJSON struct { - Name apijson.Field - Port apijson.Field - Priority apijson.Field - Proto apijson.Field - Service apijson.Field - Target apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field +// smimeaRecordDataJSON contains the JSON metadata for the struct +// [SMIMEARecordData] +type smimeaRecordDataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *DNSRecordSRVData) UnmarshalJSON(data []byte) (err error) { +func (r *SMIMEARecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordSRVDataJSON) RawJSON() string { +func (r smimeaRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordSRVType string +type SMIMEARecordType string const ( - DNSRecordSRVTypeSRV DNSRecordSRVType = "SRV" + SMIMEARecordTypeSMIMEA SMIMEARecordType = "SMIMEA" ) -func (r DNSRecordSRVType) IsKnown() bool { +func (r SMIMEARecordType) IsKnown() bool { switch r { - case DNSRecordSRVTypeSRV: + case SMIMEARecordTypeSMIMEA: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordSRVMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordSRVMetaJSON `json:"-"` -} - -// dnsRecordSRVMetaJSON contains the JSON metadata for the struct -// [DNSRecordSRVMeta] -type dnsRecordSRVMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordSRVMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type SMIMEARecordParam struct { + // Components of a SMIMEA record. + Data param.Field[SMIMEARecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[SMIMEARecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r dnsRecordSRVMetaJSON) RawJSON() string { - return r.raw +func (r SMIMEARecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordSRVTTLNumber]. -type DNSRecordSRVTTL interface { - ImplementsDNSDNSRecordSrvttl() -} +func (r SMIMEARecordParam) implementsDNSRecordUnionParam() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordSRVTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordSRVTTLNumber(0)), - }, - ) +// Components of a SMIMEA record. +type SMIMEARecordDataParam struct { + // Certificate. + Certificate param.Field[string] `json:"certificate"` + // Matching Type. + MatchingType param.Field[float64] `json:"matching_type"` + // Selector. + Selector param.Field[float64] `json:"selector"` + // Usage. + Usage param.Field[float64] `json:"usage"` } -type DNSRecordSRVTTLNumber float64 - -const ( - DNSRecordSRVTTLNumber1 DNSRecordSRVTTLNumber = 1 -) - -func (r DNSRecordSRVTTLNumber) IsKnown() bool { - switch r { - case DNSRecordSRVTTLNumber1: - return true - } - return false +func (r SMIMEARecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordSSHFP struct { - // Components of a SSHFP record. - Data DNSRecordSSHFPData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. +type SRVRecord struct { + // Components of a SRV record. + Data SRVRecordData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first + // label is normally a service and the second a protocol name, each starting with + // an underscore. Name string `json:"name,required"` // Record type. - Type DNSRecordSSHFPType `json:"type,required"` + Type SRVRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS // responses. Comment string `json:"comment"` - // Formatted SSHFP content. See 'data' to set SSHFP properties. + // Priority, weight, port, and SRV target. See 'data' for setting the individual + // component values. Content string `json:"content"` // When the record was created. CreatedOn time.Time `json:"created_on" format:"date-time"` @@ -2920,26 +2529,26 @@ type DNSRecordSSHFP struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordSSHFPMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordSSHFPTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordSSHFPJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON srvRecordJSON `json:"-"` } -// dnsRecordSSHFPJSON contains the JSON metadata for the struct [DNSRecordSSHFP] -type dnsRecordSSHFPJSON struct { +// srvRecordJSON contains the JSON metadata for the struct [SRVRecord] +type srvRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -2959,132 +2568,290 @@ type dnsRecordSSHFPJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordSSHFP) UnmarshalJSON(data []byte) (err error) { +func (r *SRVRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordSSHFPJSON) RawJSON() string { +func (r srvRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordSSHFP) implementsDNSDNSRecord() {} +func (r SRVRecord) implementsDNSRecord() {} -// Components of a SSHFP record. -type DNSRecordSSHFPData struct { - // algorithm. - Algorithm float64 `json:"algorithm"` - // fingerprint. - Fingerprint string `json:"fingerprint"` - // type. - Type float64 `json:"type"` - JSON dnsRecordSSHFPDataJSON `json:"-"` +// Components of a SRV record. +type SRVRecordData struct { + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name string `json:"name" format:"hostname"` + // The port of the service. + Port float64 `json:"port"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto string `json:"proto"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service string `json:"service"` + // A valid hostname. + Target string `json:"target" format:"hostname"` + // The record weight. + Weight float64 `json:"weight"` + JSON srvRecordDataJSON `json:"-"` } -// dnsRecordSSHFPDataJSON contains the JSON metadata for the struct -// [DNSRecordSSHFPData] -type dnsRecordSSHFPDataJSON struct { - Algorithm apijson.Field - Fingerprint apijson.Field - Type apijson.Field +// srvRecordDataJSON contains the JSON metadata for the struct [SRVRecordData] +type srvRecordDataJSON struct { + Name apijson.Field + Port apijson.Field + Priority apijson.Field + Proto apijson.Field + Service apijson.Field + Target apijson.Field + Weight apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DNSRecordSSHFPData) UnmarshalJSON(data []byte) (err error) { +func (r *SRVRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordSSHFPDataJSON) RawJSON() string { +func (r srvRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordSSHFPType string +type SRVRecordType string const ( - DNSRecordSSHFPTypeSSHFP DNSRecordSSHFPType = "SSHFP" + SRVRecordTypeSRV SRVRecordType = "SRV" ) -func (r DNSRecordSSHFPType) IsKnown() bool { +func (r SRVRecordType) IsKnown() bool { switch r { - case DNSRecordSSHFPTypeSSHFP: + case SRVRecordTypeSRV: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordSSHFPMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordSSHFPMetaJSON `json:"-"` +type SRVRecordParam struct { + // Components of a SRV record. + Data param.Field[SRVRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first + // label is normally a service and the second a protocol name, each starting with + // an underscore. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[SRVRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -// dnsRecordSSHFPMetaJSON contains the JSON metadata for the struct -// [DNSRecordSSHFPMeta] -type dnsRecordSSHFPMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r SRVRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *DNSRecordSSHFPMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +func (r SRVRecordParam) implementsDNSRecordUnionParam() {} -func (r dnsRecordSSHFPMetaJSON) RawJSON() string { +// Components of a SRV record. +type SRVRecordDataParam struct { + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name param.Field[string] `json:"name" format:"hostname"` + // The port of the service. + Port param.Field[float64] `json:"port"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority param.Field[float64] `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto param.Field[string] `json:"proto"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service param.Field[string] `json:"service"` + // A valid hostname. + Target param.Field[string] `json:"target" format:"hostname"` + // The record weight. + Weight param.Field[float64] `json:"weight"` +} + +func (r SRVRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SSHFPRecord struct { + // Components of a SSHFP record. + Data SSHFPRecordData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type SSHFPRecordType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SSHFP content. See 'data' to set SSHFP properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordMetadata `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // 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 []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. + TTL TTLUnion `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON sshfpRecordJSON `json:"-"` +} + +// sshfpRecordJSON contains the JSON metadata for the struct [SSHFPRecord] +type sshfpRecordJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SSHFPRecord) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sshfpRecordJSON) RawJSON() string { return r.raw } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordSSHFPTTLNumber]. -type DNSRecordSSHFPTTL interface { - ImplementsDNSDNSRecordSshfpttl() +func (r SSHFPRecord) implementsDNSRecord() {} + +// Components of a SSHFP record. +type SSHFPRecordData struct { + // algorithm. + Algorithm float64 `json:"algorithm"` + // fingerprint. + Fingerprint string `json:"fingerprint"` + // type. + Type float64 `json:"type"` + JSON sshfpRecordDataJSON `json:"-"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordSSHFPTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordSSHFPTTLNumber(0)), - }, - ) +// sshfpRecordDataJSON contains the JSON metadata for the struct [SSHFPRecordData] +type sshfpRecordDataJSON struct { + Algorithm apijson.Field + Fingerprint apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SSHFPRecordData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sshfpRecordDataJSON) RawJSON() string { + return r.raw } -type DNSRecordSSHFPTTLNumber float64 +// Record type. +type SSHFPRecordType string const ( - DNSRecordSSHFPTTLNumber1 DNSRecordSSHFPTTLNumber = 1 + SSHFPRecordTypeSSHFP SSHFPRecordType = "SSHFP" ) -func (r DNSRecordSSHFPTTLNumber) IsKnown() bool { +func (r SSHFPRecordType) IsKnown() bool { switch r { - case DNSRecordSSHFPTTLNumber1: + case SSHFPRecordTypeSSHFP: return true } return false } -type DNSRecordSVCB struct { +type SSHFPRecordParam struct { + // Components of a SSHFP record. + Data param.Field[SSHFPRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[SSHFPRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` +} + +func (r SSHFPRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SSHFPRecordParam) implementsDNSRecordUnionParam() {} + +// Components of a SSHFP record. +type SSHFPRecordDataParam struct { + // algorithm. + Algorithm param.Field[float64] `json:"algorithm"` + // fingerprint. + Fingerprint param.Field[string] `json:"fingerprint"` + // type. + Type param.Field[float64] `json:"type"` +} + +func (r SSHFPRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SVCBRecord struct { // Components of a SVCB record. - Data DNSRecordSVCBData `json:"data,required"` + Data SVCBRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordSVCBType `json:"type,required"` + Type SVCBRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -3098,26 +2865,26 @@ type DNSRecordSVCB struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordSVCBMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordSVCBTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordSVCBJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON svcbRecordJSON `json:"-"` } -// dnsRecordSVCBJSON contains the JSON metadata for the struct [DNSRecordSVCB] -type dnsRecordSVCBJSON struct { +// svcbRecordJSON contains the JSON metadata for the struct [SVCBRecord] +type svcbRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -3137,30 +2904,29 @@ type dnsRecordSVCBJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordSVCB) UnmarshalJSON(data []byte) (err error) { +func (r *SVCBRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordSVCBJSON) RawJSON() string { +func (r svcbRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordSVCB) implementsDNSDNSRecord() {} +func (r SVCBRecord) implementsDNSRecord() {} // Components of a SVCB record. -type DNSRecordSVCBData struct { +type SVCBRecordData struct { // priority. Priority float64 `json:"priority"` // target. Target string `json:"target"` // value. - Value string `json:"value"` - JSON dnsRecordSVCBDataJSON `json:"-"` + Value string `json:"value"` + JSON svcbRecordDataJSON `json:"-"` } -// dnsRecordSVCBDataJSON contains the JSON metadata for the struct -// [DNSRecordSVCBData] -type dnsRecordSVCBDataJSON struct { +// svcbRecordDataJSON contains the JSON metadata for the struct [SVCBRecordData] +type svcbRecordDataJSON struct { Priority apijson.Field Target apijson.Field Value apijson.Field @@ -3168,101 +2934,74 @@ type dnsRecordSVCBDataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordSVCBData) UnmarshalJSON(data []byte) (err error) { +func (r *SVCBRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordSVCBDataJSON) RawJSON() string { +func (r svcbRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordSVCBType string +type SVCBRecordType string const ( - DNSRecordSVCBTypeSVCB DNSRecordSVCBType = "SVCB" + SVCBRecordTypeSVCB SVCBRecordType = "SVCB" ) -func (r DNSRecordSVCBType) IsKnown() bool { +func (r SVCBRecordType) IsKnown() bool { switch r { - case DNSRecordSVCBTypeSVCB: + case SVCBRecordTypeSVCB: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordSVCBMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordSVCBMetaJSON `json:"-"` -} - -// dnsRecordSVCBMetaJSON contains the JSON metadata for the struct -// [DNSRecordSVCBMeta] -type dnsRecordSVCBMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordSVCBMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type SVCBRecordParam struct { + // Components of a SVCB record. + Data param.Field[SVCBRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[SVCBRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r dnsRecordSVCBMetaJSON) RawJSON() string { - return r.raw +func (r SVCBRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordSVCBTTLNumber]. -type DNSRecordSVCBTTL interface { - ImplementsDNSDNSRecordSvcbttl() -} +func (r SVCBRecordParam) implementsDNSRecordUnionParam() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordSVCBTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordSVCBTTLNumber(0)), - }, - ) +// Components of a SVCB record. +type SVCBRecordDataParam struct { + // priority. + Priority param.Field[float64] `json:"priority"` + // target. + Target param.Field[string] `json:"target"` + // value. + Value param.Field[string] `json:"value"` } -type DNSRecordSVCBTTLNumber float64 - -const ( - DNSRecordSVCBTTLNumber1 DNSRecordSVCBTTLNumber = 1 -) - -func (r DNSRecordSVCBTTLNumber) IsKnown() bool { - switch r { - case DNSRecordSVCBTTLNumber1: - return true - } - return false +func (r SVCBRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordTLSA struct { +type TLSARecord struct { // Components of a TLSA record. - Data DNSRecordTLSAData `json:"data,required"` + Data TLSARecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordTLSAType `json:"type,required"` + Type TLSARecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -3276,26 +3015,26 @@ type DNSRecordTLSA struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordTLSAMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordTLSATTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordTLSAJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON tlsaRecordJSON `json:"-"` } -// dnsRecordTLSAJSON contains the JSON metadata for the struct [DNSRecordTLSA] -type dnsRecordTLSAJSON struct { +// tlsaRecordJSON contains the JSON metadata for the struct [TLSARecord] +type tlsaRecordJSON struct { Data apijson.Field Name apijson.Field Type apijson.Field @@ -3315,18 +3054,18 @@ type dnsRecordTLSAJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordTLSA) UnmarshalJSON(data []byte) (err error) { +func (r *TLSARecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordTLSAJSON) RawJSON() string { +func (r tlsaRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordTLSA) implementsDNSDNSRecord() {} +func (r TLSARecord) implementsDNSRecord() {} // Components of a TLSA record. -type DNSRecordTLSAData struct { +type TLSARecordData struct { // certificate. Certificate string `json:"certificate"` // Matching Type. @@ -3334,13 +3073,12 @@ type DNSRecordTLSAData struct { // Selector. Selector float64 `json:"selector"` // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordTLSADataJSON `json:"-"` + Usage float64 `json:"usage"` + JSON tlsaRecordDataJSON `json:"-"` } -// dnsRecordTLSADataJSON contains the JSON metadata for the struct -// [DNSRecordTLSAData] -type dnsRecordTLSADataJSON struct { +// tlsaRecordDataJSON contains the JSON metadata for the struct [TLSARecordData] +type tlsaRecordDataJSON struct { Certificate apijson.Field MatchingType apijson.Field Selector apijson.Field @@ -3349,68 +3087,81 @@ type dnsRecordTLSADataJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordTLSAData) UnmarshalJSON(data []byte) (err error) { +func (r *TLSARecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordTLSADataJSON) RawJSON() string { +func (r tlsaRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordTLSAType string +type TLSARecordType string const ( - DNSRecordTLSATypeTLSA DNSRecordTLSAType = "TLSA" + TLSARecordTypeTLSA TLSARecordType = "TLSA" ) -func (r DNSRecordTLSAType) IsKnown() bool { +func (r TLSARecordType) IsKnown() bool { switch r { - case DNSRecordTLSATypeTLSA: + case TLSARecordTypeTLSA: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordTLSAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordTLSAMetaJSON `json:"-"` +type TLSARecordParam struct { + // Components of a TLSA record. + Data param.Field[TLSARecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[TLSARecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -// dnsRecordTLSAMetaJSON contains the JSON metadata for the struct -// [DNSRecordTLSAMeta] -type dnsRecordTLSAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r TLSARecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *DNSRecordTLSAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r TLSARecordParam) implementsDNSRecordUnionParam() {} + +// Components of a TLSA record. +type TLSARecordDataParam struct { + // certificate. + Certificate param.Field[string] `json:"certificate"` + // Matching Type. + MatchingType param.Field[float64] `json:"matching_type"` + // Selector. + Selector param.Field[float64] `json:"selector"` + // Usage. + Usage param.Field[float64] `json:"usage"` } -func (r dnsRecordTLSAMetaJSON) RawJSON() string { - return r.raw +func (r TLSARecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // 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. // -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordTLSATTLNumber]. -type DNSRecordTLSATTL interface { - ImplementsDNSDNSRecordTlsattl() +// Union satisfied by [shared.UnionFloat] or [dns.TTLNumber]. +type TTLUnion interface { + ImplementsDNSTTLUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordTLSATTL)(nil)).Elem(), + reflect.TypeOf((*TTLUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.Number, @@ -3418,32 +3169,41 @@ func init() { }, apijson.UnionVariant{ TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordTLSATTLNumber(0)), + Type: reflect.TypeOf(TTLNumber(0)), }, ) } -type DNSRecordTLSATTLNumber float64 +type TTLNumber float64 const ( - DNSRecordTLSATTLNumber1 DNSRecordTLSATTLNumber = 1 + TTLNumber1 TTLNumber = 1 ) -func (r DNSRecordTLSATTLNumber) IsKnown() bool { +func (r TTLNumber) IsKnown() bool { switch r { - case DNSRecordTLSATTLNumber1: + case TTLNumber1: return true } return false } -type DNSRecordTXT struct { +// 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. +// +// Satisfied by [shared.UnionFloat], [dns.TTLNumber]. +type TTLUnionParam interface { + ImplementsDNSTTLUnionParam() +} + +type TXTRecord struct { // Text content for the record. Content string `json:"content,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Record type. - Type DNSRecordTXTType `json:"type,required"` + Type TXTRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -3455,26 +3215,26 @@ type DNSRecordTXT struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordTXTMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordTXTTTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordTXTJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON txtRecordJSON `json:"-"` } -// dnsRecordTXTJSON contains the JSON metadata for the struct [DNSRecordTXT] -type dnsRecordTXTJSON struct { +// txtRecordJSON contains the JSON metadata for the struct [TXTRecord] +type txtRecordJSON struct { Content apijson.Field Name apijson.Field Type apijson.Field @@ -3493,106 +3253,65 @@ type dnsRecordTXTJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordTXT) UnmarshalJSON(data []byte) (err error) { +func (r *TXTRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordTXTJSON) RawJSON() string { +func (r txtRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordTXT) implementsDNSDNSRecord() {} +func (r TXTRecord) implementsDNSRecord() {} // Record type. -type DNSRecordTXTType string +type TXTRecordType string const ( - DNSRecordTXTTypeTXT DNSRecordTXTType = "TXT" + TXTRecordTypeTXT TXTRecordType = "TXT" ) -func (r DNSRecordTXTType) IsKnown() bool { +func (r TXTRecordType) IsKnown() bool { switch r { - case DNSRecordTXTTypeTXT: + case TXTRecordTypeTXT: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordTXTMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordTXTMetaJSON `json:"-"` -} - -// dnsRecordTXTMetaJSON contains the JSON metadata for the struct -// [DNSRecordTXTMeta] -type dnsRecordTXTMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordTXTMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordTXTMetaJSON) RawJSON() string { - return r.raw -} - -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordTXTTTLNumber]. -type DNSRecordTXTTTL interface { - ImplementsDNSDNSRecordTxtttl() +type TXTRecordParam struct { + // Text content for the record. + Content param.Field[string] `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[TXTRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordTXTTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordTXTTTLNumber(0)), - }, - ) +func (r TXTRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSRecordTXTTTLNumber float64 - -const ( - DNSRecordTXTTTLNumber1 DNSRecordTXTTTLNumber = 1 -) - -func (r DNSRecordTXTTTLNumber) IsKnown() bool { - switch r { - case DNSRecordTXTTTLNumber1: - return true - } - return false -} +func (r TXTRecordParam) implementsDNSRecordUnionParam() {} -type DNSRecordURI struct { +type URIRecord struct { // Components of a URI record. - Data DNSRecordURIData `json:"data,required"` + Data URIRecordData `json:"data,required"` // DNS record name (or @ for the zone apex) in Punycode. Name string `json:"name,required"` // Required for MX, SRV and URI records; unused by other record types. Records with // lower priorities are preferred. Priority float64 `json:"priority,required"` // Record type. - Type DNSRecordURIType `json:"type,required"` + Type URIRecordType `json:"type,required"` // Identifier ID string `json:"id"` // Comments or notes about the DNS record. This field has no effect on DNS @@ -3606,26 +3325,26 @@ type DNSRecordURI struct { // Cloudflare). Locked bool `json:"locked"` // Extra Cloudflare-specific information about the record. - Meta DNSRecordURIMeta `json:"meta"` + Meta RecordMetadata `json:"meta"` // When the record was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // 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 []string `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. - TTL DNSRecordURITTL `json:"ttl"` + TTL TTLUnion `json:"ttl"` // Identifier ZoneID string `json:"zone_id"` // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordURIJSON `json:"-"` + ZoneName string `json:"zone_name" format:"hostname"` + JSON uriRecordJSON `json:"-"` } -// dnsRecordURIJSON contains the JSON metadata for the struct [DNSRecordURI] -type dnsRecordURIJSON struct { +// uriRecordJSON contains the JSON metadata for the struct [URIRecord] +type uriRecordJSON struct { Data apijson.Field Name apijson.Field Priority apijson.Field @@ -3646,120 +3365,93 @@ type dnsRecordURIJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSRecordURI) UnmarshalJSON(data []byte) (err error) { +func (r *URIRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordURIJSON) RawJSON() string { +func (r uriRecordJSON) RawJSON() string { return r.raw } -func (r DNSRecordURI) implementsDNSDNSRecord() {} +func (r URIRecord) implementsDNSRecord() {} // Components of a URI record. -type DNSRecordURIData struct { +type URIRecordData struct { // The record content. Content string `json:"content"` // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordURIDataJSON `json:"-"` + Weight float64 `json:"weight"` + JSON uriRecordDataJSON `json:"-"` } -// dnsRecordURIDataJSON contains the JSON metadata for the struct -// [DNSRecordURIData] -type dnsRecordURIDataJSON struct { +// uriRecordDataJSON contains the JSON metadata for the struct [URIRecordData] +type uriRecordDataJSON struct { Content apijson.Field Weight apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DNSRecordURIData) UnmarshalJSON(data []byte) (err error) { +func (r *URIRecordData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsRecordURIDataJSON) RawJSON() string { +func (r uriRecordDataJSON) RawJSON() string { return r.raw } // Record type. -type DNSRecordURIType string +type URIRecordType string const ( - DNSRecordURITypeURI DNSRecordURIType = "URI" + URIRecordTypeURI URIRecordType = "URI" ) -func (r DNSRecordURIType) IsKnown() bool { +func (r URIRecordType) IsKnown() bool { switch r { - case DNSRecordURITypeURI: + case URIRecordTypeURI: return true } return false } -// Extra Cloudflare-specific information about the record. -type DNSRecordURIMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordURIMetaJSON `json:"-"` -} - -// dnsRecordURIMetaJSON contains the JSON metadata for the struct -// [DNSRecordURIMeta] -type dnsRecordURIMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordURIMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type URIRecordParam struct { + // Components of a URI record. + Data param.Field[URIRecordDataParam] `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority param.Field[float64] `json:"priority,required"` + // Record type. + Type param.Field[URIRecordType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + 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. + TTL param.Field[TTLUnionParam] `json:"ttl"` } -func (r dnsRecordURIMetaJSON) RawJSON() string { - return r.raw +func (r URIRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// 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. -// -// Union satisfied by [shared.UnionFloat] or [dns.DNSRecordURITTLNumber]. -type DNSRecordURITTL interface { - ImplementsDNSDNSRecordUrittl() -} +func (r URIRecordParam) implementsDNSRecordUnionParam() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordURITTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordURITTLNumber(0)), - }, - ) +// Components of a URI record. +type URIRecordDataParam struct { + // The record content. + Content param.Field[string] `json:"content"` + // The record weight. + Weight param.Field[float64] `json:"weight"` } -type DNSRecordURITTLNumber float64 - -const ( - DNSRecordURITTLNumber1 DNSRecordURITTLNumber = 1 -) - -func (r DNSRecordURITTLNumber) IsKnown() bool { - switch r { - case DNSRecordURITTLNumber1: - return true - } - return false +func (r URIRecordDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } type RecordDeleteResponse struct { @@ -3834,5579 +3526,369 @@ func (r recordScanResponseJSON) RawJSON() string { return r.raw } -// This interface is a union satisfied by one of the following: -// [RecordNewParamsDNSRecordsARecord], [RecordNewParamsDNSRecordsAAAARecord], -// [RecordNewParamsDNSRecordsCAARecord], [RecordNewParamsDNSRecordsCERTRecord], -// [RecordNewParamsDNSRecordsCNAMERecord], [RecordNewParamsDNSRecordsDNSKEYRecord], -// [RecordNewParamsDNSRecordsDSRecord], [RecordNewParamsDNSRecordsHTTPSRecord], -// [RecordNewParamsDNSRecordsLOCRecord], [RecordNewParamsDNSRecordsMXRecord], -// [RecordNewParamsDNSRecordsNAPTRRecord], [RecordNewParamsDNSRecordsNSRecord], -// [RecordNewParamsDNSRecordsPTRRecord], [RecordNewParamsDNSRecordsSMIMEARecord], -// [RecordNewParamsDNSRecordsSRVRecord], [RecordNewParamsDNSRecordsSSHFPRecord], -// [RecordNewParamsDNSRecordsSVCBRecord], [RecordNewParamsDNSRecordsTLSARecord], -// [RecordNewParamsDNSRecordsTXTRecord], [RecordNewParamsDNSRecordsURIRecord]. -type RecordNewParams interface { - ImplementsRecordNewParams() - - getZoneID() param.Field[string] -} - -type RecordNewParamsDNSRecordsARecord struct { +type RecordNewParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` - // A valid IPv4 address. - Content param.Field[string] `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsARecordTTL] `json:"ttl"` + Record RecordUnionParam `json:"record,required"` } -func (r RecordNewParamsDNSRecordsARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r RecordNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Record) } -func (r RecordNewParamsDNSRecordsARecord) getZoneID() param.Field[string] { - return r.ZoneID +type RecordNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Record `json:"result,required"` + // Whether the API call was successful + Success RecordNewResponseEnvelopeSuccess `json:"success,required"` + JSON recordNewResponseEnvelopeJSON `json:"-"` } -func (RecordNewParamsDNSRecordsARecord) ImplementsRecordNewParams() { - +// recordNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordNewResponseEnvelope] +type recordNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Record type. -type RecordNewParamsDNSRecordsARecordType string - -const ( - RecordNewParamsDNSRecordsARecordTypeA RecordNewParamsDNSRecordsARecordType = "A" -) - -func (r RecordNewParamsDNSRecordsARecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsARecordTypeA: - return true - } - return false +func (r *RecordNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsARecordTTLNumber]. -type RecordNewParamsDNSRecordsARecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsARecordTTL() +func (r recordNewResponseEnvelopeJSON) RawJSON() string { + return r.raw } -type RecordNewParamsDNSRecordsARecordTTLNumber float64 +// Whether the API call was successful +type RecordNewResponseEnvelopeSuccess bool const ( - RecordNewParamsDNSRecordsARecordTTLNumber1 RecordNewParamsDNSRecordsARecordTTLNumber = 1 + RecordNewResponseEnvelopeSuccessTrue RecordNewResponseEnvelopeSuccess = true ) -func (r RecordNewParamsDNSRecordsARecordTTLNumber) IsKnown() bool { +func (r RecordNewResponseEnvelopeSuccess) IsKnown() bool { switch r { - case RecordNewParamsDNSRecordsARecordTTLNumber1: + case RecordNewResponseEnvelopeSuccessTrue: return true } return false } -type RecordNewParamsDNSRecordsAAAARecord struct { +type RecordUpdateParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` - // A valid IPv6 address. - Content param.Field[string] `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsAAAARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsAAAARecordTTL] `json:"ttl"` + Record RecordUnionParam `json:"record,required"` } -func (r RecordNewParamsDNSRecordsAAAARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r RecordUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Record) } -func (r RecordNewParamsDNSRecordsAAAARecord) getZoneID() param.Field[string] { - return r.ZoneID +type RecordUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Record `json:"result,required"` + // Whether the API call was successful + Success RecordUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON recordUpdateResponseEnvelopeJSON `json:"-"` } -func (RecordNewParamsDNSRecordsAAAARecord) ImplementsRecordNewParams() { - +// recordUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordUpdateResponseEnvelope] +type recordUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Record type. -type RecordNewParamsDNSRecordsAAAARecordType string - -const ( - RecordNewParamsDNSRecordsAAAARecordTypeAAAA RecordNewParamsDNSRecordsAAAARecordType = "AAAA" -) - -func (r RecordNewParamsDNSRecordsAAAARecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsAAAARecordTypeAAAA: - return true - } - return false +func (r *RecordUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsAAAARecordTTLNumber]. -type RecordNewParamsDNSRecordsAAAARecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsAAAARecordTTL() +func (r recordUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw } -type RecordNewParamsDNSRecordsAAAARecordTTLNumber float64 +// Whether the API call was successful +type RecordUpdateResponseEnvelopeSuccess bool const ( - RecordNewParamsDNSRecordsAAAARecordTTLNumber1 RecordNewParamsDNSRecordsAAAARecordTTLNumber = 1 + RecordUpdateResponseEnvelopeSuccessTrue RecordUpdateResponseEnvelopeSuccess = true ) -func (r RecordNewParamsDNSRecordsAAAARecordTTLNumber) IsKnown() bool { +func (r RecordUpdateResponseEnvelopeSuccess) IsKnown() bool { switch r { - case RecordNewParamsDNSRecordsAAAARecordTTLNumber1: + case RecordUpdateResponseEnvelopeSuccessTrue: return true } return false } -type RecordNewParamsDNSRecordsCAARecord struct { +type RecordListParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a CAA record. - Data param.Field[RecordNewParamsDNSRecordsCAARecordData] `json:"data,required"` + ZoneID param.Field[string] `path:"zone_id,required"` + Comment param.Field[RecordListParamsComment] `query:"comment"` + // DNS record content. + Content param.Field[string] `query:"content"` + // Direction to order DNS records in. + Direction param.Field[RecordListParamsDirection] `query:"direction"` + // Whether to match all search requirements or at least one (any). If set to `all`, + // acts like a logical AND between filters. If set to `any`, acts like a logical OR + // instead. Note that the interaction between tag filters is controlled by the + // `tag-match` parameter instead. + Match param.Field[RecordListParamsMatch] `query:"match"` // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` + Name param.Field[string] `query:"name"` + // Field to order DNS records by. + Order param.Field[RecordListParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of DNS records per page. + PerPage param.Field[float64] `query:"per_page"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `query:"proxied"` + // Allows searching in multiple properties of a DNS record simultaneously. This + // parameter is intended for human users, not automation. Its exact behavior is + // intentionally left unspecified and is subject to change in the future. This + // parameter works independently of the `match` setting. For automated searches, + // please use the other available parameters. + Search param.Field[string] `query:"search"` + Tag param.Field[RecordListParamsTag] `query:"tag"` + // Whether to match all tag search requirements or at least one (any). If set to + // `all`, acts like a logical AND between tag filters. If set to `any`, acts like a + // logical OR instead. Note that the regular `match` parameter is still used to + // combine the resulting condition with other filters that aren't related to tags. + TagMatch param.Field[RecordListParamsTagMatch] `query:"tag_match"` // Record type. - Type param.Field[RecordNewParamsDNSRecordsCAARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsCAARecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsCAARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsCAARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsCAARecord) ImplementsRecordNewParams() { - -} - -// Components of a CAA record. -type RecordNewParamsDNSRecordsCAARecordData struct { - // Flags for the CAA record. - Flags param.Field[float64] `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag param.Field[string] `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value param.Field[string] `json:"value"` -} - -func (r RecordNewParamsDNSRecordsCAARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsCAARecordType string - -const ( - RecordNewParamsDNSRecordsCAARecordTypeCAA RecordNewParamsDNSRecordsCAARecordType = "CAA" -) - -func (r RecordNewParamsDNSRecordsCAARecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsCAARecordTypeCAA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsCAARecordTTLNumber]. -type RecordNewParamsDNSRecordsCAARecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsCAARecordTTL() -} - -type RecordNewParamsDNSRecordsCAARecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsCAARecordTTLNumber1 RecordNewParamsDNSRecordsCAARecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsCAARecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsCAARecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsCERTRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a CERT record. - Data param.Field[RecordNewParamsDNSRecordsCERTRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsCERTRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsCERTRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsCERTRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsCERTRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsCERTRecord) ImplementsRecordNewParams() { - -} - -// Components of a CERT record. -type RecordNewParamsDNSRecordsCERTRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Certificate. - Certificate param.Field[string] `json:"certificate"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` - // Type. - Type param.Field[float64] `json:"type"` -} - -func (r RecordNewParamsDNSRecordsCERTRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsCERTRecordType string - -const ( - RecordNewParamsDNSRecordsCERTRecordTypeCERT RecordNewParamsDNSRecordsCERTRecordType = "CERT" -) - -func (r RecordNewParamsDNSRecordsCERTRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsCERTRecordTypeCERT: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsCERTRecordTTLNumber]. -type RecordNewParamsDNSRecordsCERTRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsCERTRecordTTL() -} - -type RecordNewParamsDNSRecordsCERTRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsCERTRecordTTLNumber1 RecordNewParamsDNSRecordsCERTRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsCERTRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsCERTRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsCNAMERecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid hostname. Must not match the record's name. - Content param.Field[interface{}] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsCNAMERecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsCNAMERecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsCNAMERecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsCNAMERecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsCNAMERecord) ImplementsRecordNewParams() { - -} - -// Record type. -type RecordNewParamsDNSRecordsCNAMERecordType string - -const ( - RecordNewParamsDNSRecordsCNAMERecordTypeCNAME RecordNewParamsDNSRecordsCNAMERecordType = "CNAME" -) - -func (r RecordNewParamsDNSRecordsCNAMERecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsCNAMERecordTypeCNAME: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsCNAMERecordTTLNumber]. -type RecordNewParamsDNSRecordsCNAMERecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsCNAMERecordTTL() -} - -type RecordNewParamsDNSRecordsCNAMERecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsCNAMERecordTTLNumber1 RecordNewParamsDNSRecordsCNAMERecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsCNAMERecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsCNAMERecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsDNSKEYRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a DNSKEY record. - Data param.Field[RecordNewParamsDNSRecordsDNSKEYRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsDNSKEYRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsDNSKEYRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsDNSKEYRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsDNSKEYRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsDNSKEYRecord) ImplementsRecordNewParams() { - -} - -// Components of a DNSKEY record. -type RecordNewParamsDNSRecordsDNSKEYRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Flags. - Flags param.Field[float64] `json:"flags"` - // Protocol. - Protocol param.Field[float64] `json:"protocol"` - // Public Key. - PublicKey param.Field[string] `json:"public_key"` -} - -func (r RecordNewParamsDNSRecordsDNSKEYRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsDNSKEYRecordType string - -const ( - RecordNewParamsDNSRecordsDNSKEYRecordTypeDNSKEY RecordNewParamsDNSRecordsDNSKEYRecordType = "DNSKEY" -) - -func (r RecordNewParamsDNSRecordsDNSKEYRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsDNSKEYRecordTypeDNSKEY: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsDNSKEYRecordTTLNumber]. -type RecordNewParamsDNSRecordsDNSKEYRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsDNSKEYRecordTTL() -} - -type RecordNewParamsDNSRecordsDNSKEYRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsDNSKEYRecordTTLNumber1 RecordNewParamsDNSRecordsDNSKEYRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsDNSKEYRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsDNSKEYRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsDSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a DS record. - Data param.Field[RecordNewParamsDNSRecordsDSRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsDSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsDSRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsDSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsDSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsDSRecord) ImplementsRecordNewParams() { - -} - -// Components of a DS record. -type RecordNewParamsDNSRecordsDSRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Digest. - Digest param.Field[string] `json:"digest"` - // Digest Type. - DigestType param.Field[float64] `json:"digest_type"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` -} - -func (r RecordNewParamsDNSRecordsDSRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsDSRecordType string - -const ( - RecordNewParamsDNSRecordsDSRecordTypeDS RecordNewParamsDNSRecordsDSRecordType = "DS" -) - -func (r RecordNewParamsDNSRecordsDSRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsDSRecordTypeDS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsDSRecordTTLNumber]. -type RecordNewParamsDNSRecordsDSRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsDSRecordTTL() -} - -type RecordNewParamsDNSRecordsDSRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsDSRecordTTLNumber1 RecordNewParamsDNSRecordsDSRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsDSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsDSRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsHTTPSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a HTTPS record. - Data param.Field[RecordNewParamsDNSRecordsHTTPSRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsHTTPSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsHTTPSRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsHTTPSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsHTTPSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsHTTPSRecord) ImplementsRecordNewParams() { - -} - -// Components of a HTTPS record. -type RecordNewParamsDNSRecordsHTTPSRecordData struct { - // priority. - Priority param.Field[float64] `json:"priority"` - // target. - Target param.Field[string] `json:"target"` - // value. - Value param.Field[string] `json:"value"` -} - -func (r RecordNewParamsDNSRecordsHTTPSRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsHTTPSRecordType string - -const ( - RecordNewParamsDNSRecordsHTTPSRecordTypeHTTPS RecordNewParamsDNSRecordsHTTPSRecordType = "HTTPS" -) - -func (r RecordNewParamsDNSRecordsHTTPSRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsHTTPSRecordTypeHTTPS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsHTTPSRecordTTLNumber]. -type RecordNewParamsDNSRecordsHTTPSRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsHTTPSRecordTTL() -} - -type RecordNewParamsDNSRecordsHTTPSRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsHTTPSRecordTTLNumber1 RecordNewParamsDNSRecordsHTTPSRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsHTTPSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsHTTPSRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsLOCRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a LOC record. - Data param.Field[RecordNewParamsDNSRecordsLOCRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsLOCRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsLOCRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsLOCRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsLOCRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsLOCRecord) ImplementsRecordNewParams() { - -} - -// Components of a LOC record. -type RecordNewParamsDNSRecordsLOCRecordData struct { - // Altitude of location in meters. - Altitude param.Field[float64] `json:"altitude"` - // Degrees of latitude. - LatDegrees param.Field[float64] `json:"lat_degrees"` - // Latitude direction. - LatDirection param.Field[RecordNewParamsDNSRecordsLOCRecordDataLatDirection] `json:"lat_direction"` - // Minutes of latitude. - LatMinutes param.Field[float64] `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds param.Field[float64] `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees param.Field[float64] `json:"long_degrees"` - // Longitude direction. - LongDirection param.Field[RecordNewParamsDNSRecordsLOCRecordDataLongDirection] `json:"long_direction"` - // Minutes of longitude. - LongMinutes param.Field[float64] `json:"long_minutes"` - // Seconds of longitude. - LongSeconds param.Field[float64] `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz param.Field[float64] `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert param.Field[float64] `json:"precision_vert"` - // Size of location in meters. - Size param.Field[float64] `json:"size"` -} - -func (r RecordNewParamsDNSRecordsLOCRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Latitude direction. -type RecordNewParamsDNSRecordsLOCRecordDataLatDirection string - -const ( - RecordNewParamsDNSRecordsLOCRecordDataLatDirectionN RecordNewParamsDNSRecordsLOCRecordDataLatDirection = "N" - RecordNewParamsDNSRecordsLOCRecordDataLatDirectionS RecordNewParamsDNSRecordsLOCRecordDataLatDirection = "S" -) - -func (r RecordNewParamsDNSRecordsLOCRecordDataLatDirection) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsLOCRecordDataLatDirectionN, RecordNewParamsDNSRecordsLOCRecordDataLatDirectionS: - return true - } - return false -} - -// Longitude direction. -type RecordNewParamsDNSRecordsLOCRecordDataLongDirection string - -const ( - RecordNewParamsDNSRecordsLOCRecordDataLongDirectionE RecordNewParamsDNSRecordsLOCRecordDataLongDirection = "E" - RecordNewParamsDNSRecordsLOCRecordDataLongDirectionW RecordNewParamsDNSRecordsLOCRecordDataLongDirection = "W" -) - -func (r RecordNewParamsDNSRecordsLOCRecordDataLongDirection) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsLOCRecordDataLongDirectionE, RecordNewParamsDNSRecordsLOCRecordDataLongDirectionW: - return true - } - return false -} - -// Record type. -type RecordNewParamsDNSRecordsLOCRecordType string - -const ( - RecordNewParamsDNSRecordsLOCRecordTypeLOC RecordNewParamsDNSRecordsLOCRecordType = "LOC" -) - -func (r RecordNewParamsDNSRecordsLOCRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsLOCRecordTypeLOC: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsLOCRecordTTLNumber]. -type RecordNewParamsDNSRecordsLOCRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsLOCRecordTTL() -} - -type RecordNewParamsDNSRecordsLOCRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsLOCRecordTTLNumber1 RecordNewParamsDNSRecordsLOCRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsLOCRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsLOCRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsMXRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid mail server hostname. - Content param.Field[string] `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsMXRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsMXRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsMXRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsMXRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsMXRecord) ImplementsRecordNewParams() { - -} - -// Record type. -type RecordNewParamsDNSRecordsMXRecordType string - -const ( - RecordNewParamsDNSRecordsMXRecordTypeMX RecordNewParamsDNSRecordsMXRecordType = "MX" -) - -func (r RecordNewParamsDNSRecordsMXRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsMXRecordTypeMX: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsMXRecordTTLNumber]. -type RecordNewParamsDNSRecordsMXRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsMXRecordTTL() -} - -type RecordNewParamsDNSRecordsMXRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsMXRecordTTLNumber1 RecordNewParamsDNSRecordsMXRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsMXRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsMXRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsNAPTRRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a NAPTR record. - Data param.Field[RecordNewParamsDNSRecordsNAPTRRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsNAPTRRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsNAPTRRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsNAPTRRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsNAPTRRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsNAPTRRecord) ImplementsRecordNewParams() { - -} - -// Components of a NAPTR record. -type RecordNewParamsDNSRecordsNAPTRRecordData struct { - // Flags. - Flags param.Field[string] `json:"flags"` - // Order. - Order param.Field[float64] `json:"order"` - // Preference. - Preference param.Field[float64] `json:"preference"` - // Regex. - Regex param.Field[string] `json:"regex"` - // Replacement. - Replacement param.Field[string] `json:"replacement"` - // Service. - Service param.Field[string] `json:"service"` -} - -func (r RecordNewParamsDNSRecordsNAPTRRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsNAPTRRecordType string - -const ( - RecordNewParamsDNSRecordsNAPTRRecordTypeNAPTR RecordNewParamsDNSRecordsNAPTRRecordType = "NAPTR" -) - -func (r RecordNewParamsDNSRecordsNAPTRRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsNAPTRRecordTypeNAPTR: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsNAPTRRecordTTLNumber]. -type RecordNewParamsDNSRecordsNAPTRRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsNAPTRRecordTTL() -} - -type RecordNewParamsDNSRecordsNAPTRRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsNAPTRRecordTTLNumber1 RecordNewParamsDNSRecordsNAPTRRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsNAPTRRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsNAPTRRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsNSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid name server host name. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsNSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsNSRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsNSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsNSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsNSRecord) ImplementsRecordNewParams() { - -} - -// Record type. -type RecordNewParamsDNSRecordsNSRecordType string - -const ( - RecordNewParamsDNSRecordsNSRecordTypeNS RecordNewParamsDNSRecordsNSRecordType = "NS" -) - -func (r RecordNewParamsDNSRecordsNSRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsNSRecordTypeNS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsNSRecordTTLNumber]. -type RecordNewParamsDNSRecordsNSRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsNSRecordTTL() -} - -type RecordNewParamsDNSRecordsNSRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsNSRecordTTLNumber1 RecordNewParamsDNSRecordsNSRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsNSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsNSRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsPTRRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Domain name pointing to the address. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsPTRRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsPTRRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsPTRRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsPTRRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsPTRRecord) ImplementsRecordNewParams() { - -} - -// Record type. -type RecordNewParamsDNSRecordsPTRRecordType string - -const ( - RecordNewParamsDNSRecordsPTRRecordTypePTR RecordNewParamsDNSRecordsPTRRecordType = "PTR" -) - -func (r RecordNewParamsDNSRecordsPTRRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsPTRRecordTypePTR: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsPTRRecordTTLNumber]. -type RecordNewParamsDNSRecordsPTRRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsPTRRecordTTL() -} - -type RecordNewParamsDNSRecordsPTRRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsPTRRecordTTLNumber1 RecordNewParamsDNSRecordsPTRRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsPTRRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsPTRRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsSMIMEARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SMIMEA record. - Data param.Field[RecordNewParamsDNSRecordsSMIMEARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsSMIMEARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsSMIMEARecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsSMIMEARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsSMIMEARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsSMIMEARecord) ImplementsRecordNewParams() { - -} - -// Components of a SMIMEA record. -type RecordNewParamsDNSRecordsSMIMEARecordData struct { - // Certificate. - Certificate param.Field[string] `json:"certificate"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // Usage. - Usage param.Field[float64] `json:"usage"` -} - -func (r RecordNewParamsDNSRecordsSMIMEARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsSMIMEARecordType string - -const ( - RecordNewParamsDNSRecordsSMIMEARecordTypeSMIMEA RecordNewParamsDNSRecordsSMIMEARecordType = "SMIMEA" -) - -func (r RecordNewParamsDNSRecordsSMIMEARecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSMIMEARecordTypeSMIMEA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsSMIMEARecordTTLNumber]. -type RecordNewParamsDNSRecordsSMIMEARecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsSMIMEARecordTTL() -} - -type RecordNewParamsDNSRecordsSMIMEARecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsSMIMEARecordTTLNumber1 RecordNewParamsDNSRecordsSMIMEARecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsSMIMEARecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSMIMEARecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsSRVRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SRV record. - Data param.Field[RecordNewParamsDNSRecordsSRVRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsSRVRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsSRVRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsSRVRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsSRVRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsSRVRecord) ImplementsRecordNewParams() { - -} - -// Components of a SRV record. -type RecordNewParamsDNSRecordsSRVRecordData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name param.Field[string] `json:"name" format:"hostname"` - // The port of the service. - Port param.Field[float64] `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto param.Field[string] `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service param.Field[string] `json:"service"` - // A valid hostname. - Target param.Field[string] `json:"target" format:"hostname"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r RecordNewParamsDNSRecordsSRVRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsSRVRecordType string - -const ( - RecordNewParamsDNSRecordsSRVRecordTypeSRV RecordNewParamsDNSRecordsSRVRecordType = "SRV" -) - -func (r RecordNewParamsDNSRecordsSRVRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSRVRecordTypeSRV: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsSRVRecordTTLNumber]. -type RecordNewParamsDNSRecordsSRVRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsSRVRecordTTL() -} - -type RecordNewParamsDNSRecordsSRVRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsSRVRecordTTLNumber1 RecordNewParamsDNSRecordsSRVRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsSRVRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSRVRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsSSHFPRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SSHFP record. - Data param.Field[RecordNewParamsDNSRecordsSSHFPRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsSSHFPRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsSSHFPRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsSSHFPRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsSSHFPRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsSSHFPRecord) ImplementsRecordNewParams() { - -} - -// Components of a SSHFP record. -type RecordNewParamsDNSRecordsSSHFPRecordData struct { - // algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // fingerprint. - Fingerprint param.Field[string] `json:"fingerprint"` - // type. - Type param.Field[float64] `json:"type"` -} - -func (r RecordNewParamsDNSRecordsSSHFPRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsSSHFPRecordType string - -const ( - RecordNewParamsDNSRecordsSSHFPRecordTypeSSHFP RecordNewParamsDNSRecordsSSHFPRecordType = "SSHFP" -) - -func (r RecordNewParamsDNSRecordsSSHFPRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSSHFPRecordTypeSSHFP: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsSSHFPRecordTTLNumber]. -type RecordNewParamsDNSRecordsSSHFPRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsSSHFPRecordTTL() -} - -type RecordNewParamsDNSRecordsSSHFPRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsSSHFPRecordTTLNumber1 RecordNewParamsDNSRecordsSSHFPRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsSSHFPRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSSHFPRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsSVCBRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SVCB record. - Data param.Field[RecordNewParamsDNSRecordsSVCBRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsSVCBRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsSVCBRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsSVCBRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsSVCBRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsSVCBRecord) ImplementsRecordNewParams() { - -} - -// Components of a SVCB record. -type RecordNewParamsDNSRecordsSVCBRecordData struct { - // priority. - Priority param.Field[float64] `json:"priority"` - // target. - Target param.Field[string] `json:"target"` - // value. - Value param.Field[string] `json:"value"` -} - -func (r RecordNewParamsDNSRecordsSVCBRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsSVCBRecordType string - -const ( - RecordNewParamsDNSRecordsSVCBRecordTypeSVCB RecordNewParamsDNSRecordsSVCBRecordType = "SVCB" -) - -func (r RecordNewParamsDNSRecordsSVCBRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSVCBRecordTypeSVCB: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsSVCBRecordTTLNumber]. -type RecordNewParamsDNSRecordsSVCBRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsSVCBRecordTTL() -} - -type RecordNewParamsDNSRecordsSVCBRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsSVCBRecordTTLNumber1 RecordNewParamsDNSRecordsSVCBRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsSVCBRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsSVCBRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsTLSARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a TLSA record. - Data param.Field[RecordNewParamsDNSRecordsTLSARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsTLSARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsTLSARecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsTLSARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsTLSARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsTLSARecord) ImplementsRecordNewParams() { - -} - -// Components of a TLSA record. -type RecordNewParamsDNSRecordsTLSARecordData struct { - // certificate. - Certificate param.Field[string] `json:"certificate"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // Usage. - Usage param.Field[float64] `json:"usage"` -} - -func (r RecordNewParamsDNSRecordsTLSARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsTLSARecordType string - -const ( - RecordNewParamsDNSRecordsTLSARecordTypeTLSA RecordNewParamsDNSRecordsTLSARecordType = "TLSA" -) - -func (r RecordNewParamsDNSRecordsTLSARecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsTLSARecordTypeTLSA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsTLSARecordTTLNumber]. -type RecordNewParamsDNSRecordsTLSARecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsTLSARecordTTL() -} - -type RecordNewParamsDNSRecordsTLSARecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsTLSARecordTTLNumber1 RecordNewParamsDNSRecordsTLSARecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsTLSARecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsTLSARecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsTXTRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Text content for the record. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsTXTRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsTXTRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsTXTRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsTXTRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsTXTRecord) ImplementsRecordNewParams() { - -} - -// Record type. -type RecordNewParamsDNSRecordsTXTRecordType string - -const ( - RecordNewParamsDNSRecordsTXTRecordTypeTXT RecordNewParamsDNSRecordsTXTRecordType = "TXT" -) - -func (r RecordNewParamsDNSRecordsTXTRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsTXTRecordTypeTXT: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsTXTRecordTTLNumber]. -type RecordNewParamsDNSRecordsTXTRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsTXTRecordTTL() -} - -type RecordNewParamsDNSRecordsTXTRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsTXTRecordTTLNumber1 RecordNewParamsDNSRecordsTXTRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsTXTRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsTXTRecordTTLNumber1: - return true - } - return false -} - -type RecordNewParamsDNSRecordsURIRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a URI record. - Data param.Field[RecordNewParamsDNSRecordsURIRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority,required"` - // Record type. - Type param.Field[RecordNewParamsDNSRecordsURIRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordNewParamsDNSRecordsURIRecordTTL] `json:"ttl"` -} - -func (r RecordNewParamsDNSRecordsURIRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordNewParamsDNSRecordsURIRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordNewParamsDNSRecordsURIRecord) ImplementsRecordNewParams() { - -} - -// Components of a URI record. -type RecordNewParamsDNSRecordsURIRecordData struct { - // The record content. - Content param.Field[string] `json:"content"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r RecordNewParamsDNSRecordsURIRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordNewParamsDNSRecordsURIRecordType string - -const ( - RecordNewParamsDNSRecordsURIRecordTypeURI RecordNewParamsDNSRecordsURIRecordType = "URI" -) - -func (r RecordNewParamsDNSRecordsURIRecordType) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsURIRecordTypeURI: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordNewParamsDNSRecordsURIRecordTTLNumber]. -type RecordNewParamsDNSRecordsURIRecordTTL interface { - ImplementsDNSRecordNewParamsDNSRecordsURIRecordTTL() -} - -type RecordNewParamsDNSRecordsURIRecordTTLNumber float64 - -const ( - RecordNewParamsDNSRecordsURIRecordTTLNumber1 RecordNewParamsDNSRecordsURIRecordTTLNumber = 1 -) - -func (r RecordNewParamsDNSRecordsURIRecordTTLNumber) IsKnown() bool { - switch r { - case RecordNewParamsDNSRecordsURIRecordTTLNumber1: - return true - } - return false -} - -type RecordNewResponseEnvelope struct { - Errors []RecordNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RecordNewResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecord `json:"result,required"` - // Whether the API call was successful - Success RecordNewResponseEnvelopeSuccess `json:"success,required"` - JSON recordNewResponseEnvelopeJSON `json:"-"` -} - -// recordNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RecordNewResponseEnvelope] -type recordNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RecordNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// recordNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RecordNewResponseEnvelopeErrors] -type recordNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RecordNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// recordNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RecordNewResponseEnvelopeMessages] -type recordNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RecordNewResponseEnvelopeSuccess bool - -const ( - RecordNewResponseEnvelopeSuccessTrue RecordNewResponseEnvelopeSuccess = true -) - -func (r RecordNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case RecordNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -// This interface is a union satisfied by one of the following: -// [RecordUpdateParamsDNSRecordsARecord], [RecordUpdateParamsDNSRecordsAAAARecord], -// [RecordUpdateParamsDNSRecordsCAARecord], -// [RecordUpdateParamsDNSRecordsCERTRecord], -// [RecordUpdateParamsDNSRecordsCNAMERecord], -// [RecordUpdateParamsDNSRecordsDNSKEYRecord], -// [RecordUpdateParamsDNSRecordsDSRecord], -// [RecordUpdateParamsDNSRecordsHTTPSRecord], -// [RecordUpdateParamsDNSRecordsLOCRecord], [RecordUpdateParamsDNSRecordsMXRecord], -// [RecordUpdateParamsDNSRecordsNAPTRRecord], -// [RecordUpdateParamsDNSRecordsNSRecord], [RecordUpdateParamsDNSRecordsPTRRecord], -// [RecordUpdateParamsDNSRecordsSMIMEARecord], -// [RecordUpdateParamsDNSRecordsSRVRecord], -// [RecordUpdateParamsDNSRecordsSSHFPRecord], -// [RecordUpdateParamsDNSRecordsSVCBRecord], -// [RecordUpdateParamsDNSRecordsTLSARecord], -// [RecordUpdateParamsDNSRecordsTXTRecord], -// [RecordUpdateParamsDNSRecordsURIRecord]. -type RecordUpdateParams interface { - ImplementsRecordUpdateParams() - - getZoneID() param.Field[string] -} - -type RecordUpdateParamsDNSRecordsARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid IPv4 address. - Content param.Field[string] `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsARecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsARecord) ImplementsRecordUpdateParams() { - -} - -// Record type. -type RecordUpdateParamsDNSRecordsARecordType string - -const ( - RecordUpdateParamsDNSRecordsARecordTypeA RecordUpdateParamsDNSRecordsARecordType = "A" -) - -func (r RecordUpdateParamsDNSRecordsARecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsARecordTypeA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsARecordTTLNumber]. -type RecordUpdateParamsDNSRecordsARecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsARecordTTL() -} - -type RecordUpdateParamsDNSRecordsARecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsARecordTTLNumber1 RecordUpdateParamsDNSRecordsARecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsARecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsARecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsAAAARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid IPv6 address. - Content param.Field[string] `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsAAAARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsAAAARecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsAAAARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsAAAARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsAAAARecord) ImplementsRecordUpdateParams() { - -} - -// Record type. -type RecordUpdateParamsDNSRecordsAAAARecordType string - -const ( - RecordUpdateParamsDNSRecordsAAAARecordTypeAAAA RecordUpdateParamsDNSRecordsAAAARecordType = "AAAA" -) - -func (r RecordUpdateParamsDNSRecordsAAAARecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsAAAARecordTypeAAAA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsAAAARecordTTLNumber]. -type RecordUpdateParamsDNSRecordsAAAARecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsAAAARecordTTL() -} - -type RecordUpdateParamsDNSRecordsAAAARecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsAAAARecordTTLNumber1 RecordUpdateParamsDNSRecordsAAAARecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsAAAARecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsAAAARecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsCAARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a CAA record. - Data param.Field[RecordUpdateParamsDNSRecordsCAARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsCAARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsCAARecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsCAARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsCAARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsCAARecord) ImplementsRecordUpdateParams() { - -} - -// Components of a CAA record. -type RecordUpdateParamsDNSRecordsCAARecordData struct { - // Flags for the CAA record. - Flags param.Field[float64] `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag param.Field[string] `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value param.Field[string] `json:"value"` -} - -func (r RecordUpdateParamsDNSRecordsCAARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsCAARecordType string - -const ( - RecordUpdateParamsDNSRecordsCAARecordTypeCAA RecordUpdateParamsDNSRecordsCAARecordType = "CAA" -) - -func (r RecordUpdateParamsDNSRecordsCAARecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsCAARecordTypeCAA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsCAARecordTTLNumber]. -type RecordUpdateParamsDNSRecordsCAARecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsCAARecordTTL() -} - -type RecordUpdateParamsDNSRecordsCAARecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsCAARecordTTLNumber1 RecordUpdateParamsDNSRecordsCAARecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsCAARecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsCAARecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsCERTRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a CERT record. - Data param.Field[RecordUpdateParamsDNSRecordsCERTRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsCERTRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsCERTRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsCERTRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsCERTRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsCERTRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a CERT record. -type RecordUpdateParamsDNSRecordsCERTRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Certificate. - Certificate param.Field[string] `json:"certificate"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` - // Type. - Type param.Field[float64] `json:"type"` -} - -func (r RecordUpdateParamsDNSRecordsCERTRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsCERTRecordType string - -const ( - RecordUpdateParamsDNSRecordsCERTRecordTypeCERT RecordUpdateParamsDNSRecordsCERTRecordType = "CERT" -) - -func (r RecordUpdateParamsDNSRecordsCERTRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsCERTRecordTypeCERT: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsCERTRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsCERTRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsCERTRecordTTL() -} - -type RecordUpdateParamsDNSRecordsCERTRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsCERTRecordTTLNumber1 RecordUpdateParamsDNSRecordsCERTRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsCERTRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsCERTRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsCNAMERecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid hostname. Must not match the record's name. - Content param.Field[interface{}] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsCNAMERecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsCNAMERecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsCNAMERecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsCNAMERecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsCNAMERecord) ImplementsRecordUpdateParams() { - -} - -// Record type. -type RecordUpdateParamsDNSRecordsCNAMERecordType string - -const ( - RecordUpdateParamsDNSRecordsCNAMERecordTypeCNAME RecordUpdateParamsDNSRecordsCNAMERecordType = "CNAME" -) - -func (r RecordUpdateParamsDNSRecordsCNAMERecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsCNAMERecordTypeCNAME: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsCNAMERecordTTLNumber]. -type RecordUpdateParamsDNSRecordsCNAMERecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsCNAMERecordTTL() -} - -type RecordUpdateParamsDNSRecordsCNAMERecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsCNAMERecordTTLNumber1 RecordUpdateParamsDNSRecordsCNAMERecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsCNAMERecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsCNAMERecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsDNSKEYRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a DNSKEY record. - Data param.Field[RecordUpdateParamsDNSRecordsDNSKEYRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsDNSKEYRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsDNSKEYRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsDNSKEYRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsDNSKEYRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsDNSKEYRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a DNSKEY record. -type RecordUpdateParamsDNSRecordsDNSKEYRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Flags. - Flags param.Field[float64] `json:"flags"` - // Protocol. - Protocol param.Field[float64] `json:"protocol"` - // Public Key. - PublicKey param.Field[string] `json:"public_key"` -} - -func (r RecordUpdateParamsDNSRecordsDNSKEYRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsDNSKEYRecordType string - -const ( - RecordUpdateParamsDNSRecordsDNSKEYRecordTypeDNSKEY RecordUpdateParamsDNSRecordsDNSKEYRecordType = "DNSKEY" -) - -func (r RecordUpdateParamsDNSRecordsDNSKEYRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsDNSKEYRecordTypeDNSKEY: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsDNSKEYRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsDNSKEYRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsDNSKEYRecordTTL() -} - -type RecordUpdateParamsDNSRecordsDNSKEYRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsDNSKEYRecordTTLNumber1 RecordUpdateParamsDNSRecordsDNSKEYRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsDNSKEYRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsDNSKEYRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsDSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a DS record. - Data param.Field[RecordUpdateParamsDNSRecordsDSRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsDSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsDSRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsDSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsDSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsDSRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a DS record. -type RecordUpdateParamsDNSRecordsDSRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Digest. - Digest param.Field[string] `json:"digest"` - // Digest Type. - DigestType param.Field[float64] `json:"digest_type"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` -} - -func (r RecordUpdateParamsDNSRecordsDSRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsDSRecordType string - -const ( - RecordUpdateParamsDNSRecordsDSRecordTypeDS RecordUpdateParamsDNSRecordsDSRecordType = "DS" -) - -func (r RecordUpdateParamsDNSRecordsDSRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsDSRecordTypeDS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsDSRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsDSRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsDSRecordTTL() -} - -type RecordUpdateParamsDNSRecordsDSRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsDSRecordTTLNumber1 RecordUpdateParamsDNSRecordsDSRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsDSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsDSRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsHTTPSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a HTTPS record. - Data param.Field[RecordUpdateParamsDNSRecordsHTTPSRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsHTTPSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsHTTPSRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsHTTPSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsHTTPSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsHTTPSRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a HTTPS record. -type RecordUpdateParamsDNSRecordsHTTPSRecordData struct { - // priority. - Priority param.Field[float64] `json:"priority"` - // target. - Target param.Field[string] `json:"target"` - // value. - Value param.Field[string] `json:"value"` -} - -func (r RecordUpdateParamsDNSRecordsHTTPSRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsHTTPSRecordType string - -const ( - RecordUpdateParamsDNSRecordsHTTPSRecordTypeHTTPS RecordUpdateParamsDNSRecordsHTTPSRecordType = "HTTPS" -) - -func (r RecordUpdateParamsDNSRecordsHTTPSRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsHTTPSRecordTypeHTTPS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsHTTPSRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsHTTPSRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsHTTPSRecordTTL() -} - -type RecordUpdateParamsDNSRecordsHTTPSRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsHTTPSRecordTTLNumber1 RecordUpdateParamsDNSRecordsHTTPSRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsHTTPSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsHTTPSRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsLOCRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a LOC record. - Data param.Field[RecordUpdateParamsDNSRecordsLOCRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsLOCRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsLOCRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsLOCRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsLOCRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsLOCRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a LOC record. -type RecordUpdateParamsDNSRecordsLOCRecordData struct { - // Altitude of location in meters. - Altitude param.Field[float64] `json:"altitude"` - // Degrees of latitude. - LatDegrees param.Field[float64] `json:"lat_degrees"` - // Latitude direction. - LatDirection param.Field[RecordUpdateParamsDNSRecordsLOCRecordDataLatDirection] `json:"lat_direction"` - // Minutes of latitude. - LatMinutes param.Field[float64] `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds param.Field[float64] `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees param.Field[float64] `json:"long_degrees"` - // Longitude direction. - LongDirection param.Field[RecordUpdateParamsDNSRecordsLOCRecordDataLongDirection] `json:"long_direction"` - // Minutes of longitude. - LongMinutes param.Field[float64] `json:"long_minutes"` - // Seconds of longitude. - LongSeconds param.Field[float64] `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz param.Field[float64] `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert param.Field[float64] `json:"precision_vert"` - // Size of location in meters. - Size param.Field[float64] `json:"size"` -} - -func (r RecordUpdateParamsDNSRecordsLOCRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Latitude direction. -type RecordUpdateParamsDNSRecordsLOCRecordDataLatDirection string - -const ( - RecordUpdateParamsDNSRecordsLOCRecordDataLatDirectionN RecordUpdateParamsDNSRecordsLOCRecordDataLatDirection = "N" - RecordUpdateParamsDNSRecordsLOCRecordDataLatDirectionS RecordUpdateParamsDNSRecordsLOCRecordDataLatDirection = "S" -) - -func (r RecordUpdateParamsDNSRecordsLOCRecordDataLatDirection) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsLOCRecordDataLatDirectionN, RecordUpdateParamsDNSRecordsLOCRecordDataLatDirectionS: - return true - } - return false -} - -// Longitude direction. -type RecordUpdateParamsDNSRecordsLOCRecordDataLongDirection string - -const ( - RecordUpdateParamsDNSRecordsLOCRecordDataLongDirectionE RecordUpdateParamsDNSRecordsLOCRecordDataLongDirection = "E" - RecordUpdateParamsDNSRecordsLOCRecordDataLongDirectionW RecordUpdateParamsDNSRecordsLOCRecordDataLongDirection = "W" -) - -func (r RecordUpdateParamsDNSRecordsLOCRecordDataLongDirection) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsLOCRecordDataLongDirectionE, RecordUpdateParamsDNSRecordsLOCRecordDataLongDirectionW: - return true - } - return false -} - -// Record type. -type RecordUpdateParamsDNSRecordsLOCRecordType string - -const ( - RecordUpdateParamsDNSRecordsLOCRecordTypeLOC RecordUpdateParamsDNSRecordsLOCRecordType = "LOC" -) - -func (r RecordUpdateParamsDNSRecordsLOCRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsLOCRecordTypeLOC: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsLOCRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsLOCRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsLOCRecordTTL() -} - -type RecordUpdateParamsDNSRecordsLOCRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsLOCRecordTTLNumber1 RecordUpdateParamsDNSRecordsLOCRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsLOCRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsLOCRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsMXRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid mail server hostname. - Content param.Field[string] `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsMXRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsMXRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsMXRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsMXRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsMXRecord) ImplementsRecordUpdateParams() { - -} - -// Record type. -type RecordUpdateParamsDNSRecordsMXRecordType string - -const ( - RecordUpdateParamsDNSRecordsMXRecordTypeMX RecordUpdateParamsDNSRecordsMXRecordType = "MX" -) - -func (r RecordUpdateParamsDNSRecordsMXRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsMXRecordTypeMX: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsMXRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsMXRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsMXRecordTTL() -} - -type RecordUpdateParamsDNSRecordsMXRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsMXRecordTTLNumber1 RecordUpdateParamsDNSRecordsMXRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsMXRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsMXRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsNAPTRRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a NAPTR record. - Data param.Field[RecordUpdateParamsDNSRecordsNAPTRRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsNAPTRRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsNAPTRRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsNAPTRRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsNAPTRRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsNAPTRRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a NAPTR record. -type RecordUpdateParamsDNSRecordsNAPTRRecordData struct { - // Flags. - Flags param.Field[string] `json:"flags"` - // Order. - Order param.Field[float64] `json:"order"` - // Preference. - Preference param.Field[float64] `json:"preference"` - // Regex. - Regex param.Field[string] `json:"regex"` - // Replacement. - Replacement param.Field[string] `json:"replacement"` - // Service. - Service param.Field[string] `json:"service"` -} - -func (r RecordUpdateParamsDNSRecordsNAPTRRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsNAPTRRecordType string - -const ( - RecordUpdateParamsDNSRecordsNAPTRRecordTypeNAPTR RecordUpdateParamsDNSRecordsNAPTRRecordType = "NAPTR" -) - -func (r RecordUpdateParamsDNSRecordsNAPTRRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsNAPTRRecordTypeNAPTR: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsNAPTRRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsNAPTRRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsNAPTRRecordTTL() -} - -type RecordUpdateParamsDNSRecordsNAPTRRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsNAPTRRecordTTLNumber1 RecordUpdateParamsDNSRecordsNAPTRRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsNAPTRRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsNAPTRRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsNSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid name server host name. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsNSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsNSRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsNSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsNSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsNSRecord) ImplementsRecordUpdateParams() { - -} - -// Record type. -type RecordUpdateParamsDNSRecordsNSRecordType string - -const ( - RecordUpdateParamsDNSRecordsNSRecordTypeNS RecordUpdateParamsDNSRecordsNSRecordType = "NS" -) - -func (r RecordUpdateParamsDNSRecordsNSRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsNSRecordTypeNS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsNSRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsNSRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsNSRecordTTL() -} - -type RecordUpdateParamsDNSRecordsNSRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsNSRecordTTLNumber1 RecordUpdateParamsDNSRecordsNSRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsNSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsNSRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsPTRRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Domain name pointing to the address. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsPTRRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsPTRRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsPTRRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsPTRRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsPTRRecord) ImplementsRecordUpdateParams() { - -} - -// Record type. -type RecordUpdateParamsDNSRecordsPTRRecordType string - -const ( - RecordUpdateParamsDNSRecordsPTRRecordTypePTR RecordUpdateParamsDNSRecordsPTRRecordType = "PTR" -) - -func (r RecordUpdateParamsDNSRecordsPTRRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsPTRRecordTypePTR: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsPTRRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsPTRRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsPTRRecordTTL() -} - -type RecordUpdateParamsDNSRecordsPTRRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsPTRRecordTTLNumber1 RecordUpdateParamsDNSRecordsPTRRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsPTRRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsPTRRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsSMIMEARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SMIMEA record. - Data param.Field[RecordUpdateParamsDNSRecordsSMIMEARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsSMIMEARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsSMIMEARecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsSMIMEARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsSMIMEARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsSMIMEARecord) ImplementsRecordUpdateParams() { - -} - -// Components of a SMIMEA record. -type RecordUpdateParamsDNSRecordsSMIMEARecordData struct { - // Certificate. - Certificate param.Field[string] `json:"certificate"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // Usage. - Usage param.Field[float64] `json:"usage"` -} - -func (r RecordUpdateParamsDNSRecordsSMIMEARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsSMIMEARecordType string - -const ( - RecordUpdateParamsDNSRecordsSMIMEARecordTypeSMIMEA RecordUpdateParamsDNSRecordsSMIMEARecordType = "SMIMEA" -) - -func (r RecordUpdateParamsDNSRecordsSMIMEARecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSMIMEARecordTypeSMIMEA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsSMIMEARecordTTLNumber]. -type RecordUpdateParamsDNSRecordsSMIMEARecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsSMIMEARecordTTL() -} - -type RecordUpdateParamsDNSRecordsSMIMEARecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsSMIMEARecordTTLNumber1 RecordUpdateParamsDNSRecordsSMIMEARecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsSMIMEARecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSMIMEARecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsSRVRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SRV record. - Data param.Field[RecordUpdateParamsDNSRecordsSRVRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsSRVRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsSRVRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsSRVRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsSRVRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsSRVRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a SRV record. -type RecordUpdateParamsDNSRecordsSRVRecordData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name param.Field[string] `json:"name" format:"hostname"` - // The port of the service. - Port param.Field[float64] `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto param.Field[string] `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service param.Field[string] `json:"service"` - // A valid hostname. - Target param.Field[string] `json:"target" format:"hostname"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r RecordUpdateParamsDNSRecordsSRVRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsSRVRecordType string - -const ( - RecordUpdateParamsDNSRecordsSRVRecordTypeSRV RecordUpdateParamsDNSRecordsSRVRecordType = "SRV" -) - -func (r RecordUpdateParamsDNSRecordsSRVRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSRVRecordTypeSRV: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsSRVRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsSRVRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsSRVRecordTTL() -} - -type RecordUpdateParamsDNSRecordsSRVRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsSRVRecordTTLNumber1 RecordUpdateParamsDNSRecordsSRVRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsSRVRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSRVRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsSSHFPRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SSHFP record. - Data param.Field[RecordUpdateParamsDNSRecordsSSHFPRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsSSHFPRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsSSHFPRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsSSHFPRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsSSHFPRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsSSHFPRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a SSHFP record. -type RecordUpdateParamsDNSRecordsSSHFPRecordData struct { - // algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // fingerprint. - Fingerprint param.Field[string] `json:"fingerprint"` - // type. - Type param.Field[float64] `json:"type"` -} - -func (r RecordUpdateParamsDNSRecordsSSHFPRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsSSHFPRecordType string - -const ( - RecordUpdateParamsDNSRecordsSSHFPRecordTypeSSHFP RecordUpdateParamsDNSRecordsSSHFPRecordType = "SSHFP" -) - -func (r RecordUpdateParamsDNSRecordsSSHFPRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSSHFPRecordTypeSSHFP: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsSSHFPRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsSSHFPRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsSSHFPRecordTTL() -} - -type RecordUpdateParamsDNSRecordsSSHFPRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsSSHFPRecordTTLNumber1 RecordUpdateParamsDNSRecordsSSHFPRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsSSHFPRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSSHFPRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsSVCBRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SVCB record. - Data param.Field[RecordUpdateParamsDNSRecordsSVCBRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsSVCBRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsSVCBRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsSVCBRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsSVCBRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsSVCBRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a SVCB record. -type RecordUpdateParamsDNSRecordsSVCBRecordData struct { - // priority. - Priority param.Field[float64] `json:"priority"` - // target. - Target param.Field[string] `json:"target"` - // value. - Value param.Field[string] `json:"value"` -} - -func (r RecordUpdateParamsDNSRecordsSVCBRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsSVCBRecordType string - -const ( - RecordUpdateParamsDNSRecordsSVCBRecordTypeSVCB RecordUpdateParamsDNSRecordsSVCBRecordType = "SVCB" -) - -func (r RecordUpdateParamsDNSRecordsSVCBRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSVCBRecordTypeSVCB: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsSVCBRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsSVCBRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsSVCBRecordTTL() -} - -type RecordUpdateParamsDNSRecordsSVCBRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsSVCBRecordTTLNumber1 RecordUpdateParamsDNSRecordsSVCBRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsSVCBRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsSVCBRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsTLSARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a TLSA record. - Data param.Field[RecordUpdateParamsDNSRecordsTLSARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsTLSARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsTLSARecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsTLSARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsTLSARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsTLSARecord) ImplementsRecordUpdateParams() { - -} - -// Components of a TLSA record. -type RecordUpdateParamsDNSRecordsTLSARecordData struct { - // certificate. - Certificate param.Field[string] `json:"certificate"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // Usage. - Usage param.Field[float64] `json:"usage"` -} - -func (r RecordUpdateParamsDNSRecordsTLSARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsTLSARecordType string - -const ( - RecordUpdateParamsDNSRecordsTLSARecordTypeTLSA RecordUpdateParamsDNSRecordsTLSARecordType = "TLSA" -) - -func (r RecordUpdateParamsDNSRecordsTLSARecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsTLSARecordTypeTLSA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsTLSARecordTTLNumber]. -type RecordUpdateParamsDNSRecordsTLSARecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsTLSARecordTTL() -} - -type RecordUpdateParamsDNSRecordsTLSARecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsTLSARecordTTLNumber1 RecordUpdateParamsDNSRecordsTLSARecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsTLSARecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsTLSARecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsTXTRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Text content for the record. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsTXTRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsTXTRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsTXTRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsTXTRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsTXTRecord) ImplementsRecordUpdateParams() { - -} - -// Record type. -type RecordUpdateParamsDNSRecordsTXTRecordType string - -const ( - RecordUpdateParamsDNSRecordsTXTRecordTypeTXT RecordUpdateParamsDNSRecordsTXTRecordType = "TXT" -) - -func (r RecordUpdateParamsDNSRecordsTXTRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsTXTRecordTypeTXT: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsTXTRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsTXTRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsTXTRecordTTL() -} - -type RecordUpdateParamsDNSRecordsTXTRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsTXTRecordTTLNumber1 RecordUpdateParamsDNSRecordsTXTRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsTXTRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsTXTRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateParamsDNSRecordsURIRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a URI record. - Data param.Field[RecordUpdateParamsDNSRecordsURIRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority,required"` - // Record type. - Type param.Field[RecordUpdateParamsDNSRecordsURIRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordUpdateParamsDNSRecordsURIRecordTTL] `json:"ttl"` -} - -func (r RecordUpdateParamsDNSRecordsURIRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordUpdateParamsDNSRecordsURIRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordUpdateParamsDNSRecordsURIRecord) ImplementsRecordUpdateParams() { - -} - -// Components of a URI record. -type RecordUpdateParamsDNSRecordsURIRecordData struct { - // The record content. - Content param.Field[string] `json:"content"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r RecordUpdateParamsDNSRecordsURIRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordUpdateParamsDNSRecordsURIRecordType string - -const ( - RecordUpdateParamsDNSRecordsURIRecordTypeURI RecordUpdateParamsDNSRecordsURIRecordType = "URI" -) - -func (r RecordUpdateParamsDNSRecordsURIRecordType) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsURIRecordTypeURI: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordUpdateParamsDNSRecordsURIRecordTTLNumber]. -type RecordUpdateParamsDNSRecordsURIRecordTTL interface { - ImplementsDNSRecordUpdateParamsDNSRecordsURIRecordTTL() -} - -type RecordUpdateParamsDNSRecordsURIRecordTTLNumber float64 - -const ( - RecordUpdateParamsDNSRecordsURIRecordTTLNumber1 RecordUpdateParamsDNSRecordsURIRecordTTLNumber = 1 -) - -func (r RecordUpdateParamsDNSRecordsURIRecordTTLNumber) IsKnown() bool { - switch r { - case RecordUpdateParamsDNSRecordsURIRecordTTLNumber1: - return true - } - return false -} - -type RecordUpdateResponseEnvelope struct { - Errors []RecordUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RecordUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecord `json:"result,required"` - // Whether the API call was successful - Success RecordUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON recordUpdateResponseEnvelopeJSON `json:"-"` -} - -// recordUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [RecordUpdateResponseEnvelope] -type recordUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RecordUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// recordUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RecordUpdateResponseEnvelopeErrors] -type recordUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RecordUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// recordUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RecordUpdateResponseEnvelopeMessages] -type recordUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RecordUpdateResponseEnvelopeSuccess bool - -const ( - RecordUpdateResponseEnvelopeSuccessTrue RecordUpdateResponseEnvelopeSuccess = true -) - -func (r RecordUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case RecordUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type RecordListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Comment param.Field[RecordListParamsComment] `query:"comment"` - // DNS record content. - Content param.Field[string] `query:"content"` - // Direction to order DNS records in. - Direction param.Field[RecordListParamsDirection] `query:"direction"` - // Whether to match all search requirements or at least one (any). If set to `all`, - // acts like a logical AND between filters. If set to `any`, acts like a logical OR - // instead. Note that the interaction between tag filters is controlled by the - // `tag-match` parameter instead. - Match param.Field[RecordListParamsMatch] `query:"match"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `query:"name"` - // Field to order DNS records by. - Order param.Field[RecordListParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of DNS records per page. - PerPage param.Field[float64] `query:"per_page"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `query:"proxied"` - // Allows searching in multiple properties of a DNS record simultaneously. This - // parameter is intended for human users, not automation. Its exact behavior is - // intentionally left unspecified and is subject to change in the future. This - // parameter works independently of the `match` setting. For automated searches, - // please use the other available parameters. - Search param.Field[string] `query:"search"` - Tag param.Field[RecordListParamsTag] `query:"tag"` - // Whether to match all tag search requirements or at least one (any). If set to - // `all`, acts like a logical AND between tag filters. If set to `any`, acts like a - // logical OR instead. Note that the regular `match` parameter is still used to - // combine the resulting condition with other filters that aren't related to tags. - TagMatch param.Field[RecordListParamsTagMatch] `query:"tag_match"` - // Record type. - Type param.Field[RecordListParamsType] `query:"type"` -} - -// URLQuery serializes [RecordListParams]'s query parameters as `url.Values`. -func (r RecordListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RecordListParamsComment struct { - // If this parameter is present, only records _without_ a comment are returned. - Absent param.Field[string] `query:"absent"` - // Substring of the DNS record comment. Comment filters are case-insensitive. - Contains param.Field[string] `query:"contains"` - // Suffix of the DNS record comment. Comment filters are case-insensitive. - Endswith param.Field[string] `query:"endswith"` - // Exact value of the DNS record comment. Comment filters are case-insensitive. - Exact param.Field[string] `query:"exact"` - // If this parameter is present, only records _with_ a comment are returned. - Present param.Field[string] `query:"present"` - // Prefix of the DNS record comment. Comment filters are case-insensitive. - Startswith param.Field[string] `query:"startswith"` -} - -// URLQuery serializes [RecordListParamsComment]'s query parameters as -// `url.Values`. -func (r RecordListParamsComment) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order DNS records in. -type RecordListParamsDirection string - -const ( - RecordListParamsDirectionAsc RecordListParamsDirection = "asc" - RecordListParamsDirectionDesc RecordListParamsDirection = "desc" -) - -func (r RecordListParamsDirection) IsKnown() bool { - switch r { - case RecordListParamsDirectionAsc, RecordListParamsDirectionDesc: - return true - } - return false -} - -// Whether to match all search requirements or at least one (any). If set to `all`, -// acts like a logical AND between filters. If set to `any`, acts like a logical OR -// instead. Note that the interaction between tag filters is controlled by the -// `tag-match` parameter instead. -type RecordListParamsMatch string - -const ( - RecordListParamsMatchAny RecordListParamsMatch = "any" - RecordListParamsMatchAll RecordListParamsMatch = "all" -) - -func (r RecordListParamsMatch) IsKnown() bool { - switch r { - case RecordListParamsMatchAny, RecordListParamsMatchAll: - return true - } - return false -} - -// Field to order DNS records by. -type RecordListParamsOrder string - -const ( - RecordListParamsOrderType RecordListParamsOrder = "type" - RecordListParamsOrderName RecordListParamsOrder = "name" - RecordListParamsOrderContent RecordListParamsOrder = "content" - RecordListParamsOrderTTL RecordListParamsOrder = "ttl" - RecordListParamsOrderProxied RecordListParamsOrder = "proxied" -) - -func (r RecordListParamsOrder) IsKnown() bool { - switch r { - case RecordListParamsOrderType, RecordListParamsOrderName, RecordListParamsOrderContent, RecordListParamsOrderTTL, RecordListParamsOrderProxied: - return true - } - return false -} - -type RecordListParamsTag struct { - // Name of a tag which must _not_ be present on the DNS record. Tag filters are - // case-insensitive. - Absent param.Field[string] `query:"absent"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value contains - // ``. Tag filters are case-insensitive. - Contains param.Field[string] `query:"contains"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value ends with - // ``. Tag filters are case-insensitive. - Endswith param.Field[string] `query:"endswith"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value is ``. Tag - // filters are case-insensitive. - Exact param.Field[string] `query:"exact"` - // Name of a tag which must be present on the DNS record. Tag filters are - // case-insensitive. - Present param.Field[string] `query:"present"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value starts with - // ``. Tag filters are case-insensitive. - Startswith param.Field[string] `query:"startswith"` -} - -// URLQuery serializes [RecordListParamsTag]'s query parameters as `url.Values`. -func (r RecordListParamsTag) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Whether to match all tag search requirements or at least one (any). If set to -// `all`, acts like a logical AND between tag filters. If set to `any`, acts like a -// logical OR instead. Note that the regular `match` parameter is still used to -// combine the resulting condition with other filters that aren't related to tags. -type RecordListParamsTagMatch string - -const ( - RecordListParamsTagMatchAny RecordListParamsTagMatch = "any" - RecordListParamsTagMatchAll RecordListParamsTagMatch = "all" -) - -func (r RecordListParamsTagMatch) IsKnown() bool { - switch r { - case RecordListParamsTagMatchAny, RecordListParamsTagMatchAll: - return true - } - return false -} - -// Record type. -type RecordListParamsType string - -const ( - RecordListParamsTypeA RecordListParamsType = "A" - RecordListParamsTypeAAAA RecordListParamsType = "AAAA" - RecordListParamsTypeCAA RecordListParamsType = "CAA" - RecordListParamsTypeCERT RecordListParamsType = "CERT" - RecordListParamsTypeCNAME RecordListParamsType = "CNAME" - RecordListParamsTypeDNSKEY RecordListParamsType = "DNSKEY" - RecordListParamsTypeDS RecordListParamsType = "DS" - RecordListParamsTypeHTTPS RecordListParamsType = "HTTPS" - RecordListParamsTypeLOC RecordListParamsType = "LOC" - RecordListParamsTypeMX RecordListParamsType = "MX" - RecordListParamsTypeNAPTR RecordListParamsType = "NAPTR" - RecordListParamsTypeNS RecordListParamsType = "NS" - RecordListParamsTypePTR RecordListParamsType = "PTR" - RecordListParamsTypeSMIMEA RecordListParamsType = "SMIMEA" - RecordListParamsTypeSRV RecordListParamsType = "SRV" - RecordListParamsTypeSSHFP RecordListParamsType = "SSHFP" - RecordListParamsTypeSVCB RecordListParamsType = "SVCB" - RecordListParamsTypeTLSA RecordListParamsType = "TLSA" - RecordListParamsTypeTXT RecordListParamsType = "TXT" - RecordListParamsTypeURI RecordListParamsType = "URI" -) - -func (r RecordListParamsType) IsKnown() bool { - switch r { - case RecordListParamsTypeA, RecordListParamsTypeAAAA, RecordListParamsTypeCAA, RecordListParamsTypeCERT, RecordListParamsTypeCNAME, RecordListParamsTypeDNSKEY, RecordListParamsTypeDS, RecordListParamsTypeHTTPS, RecordListParamsTypeLOC, RecordListParamsTypeMX, RecordListParamsTypeNAPTR, RecordListParamsTypeNS, RecordListParamsTypePTR, RecordListParamsTypeSMIMEA, RecordListParamsTypeSRV, RecordListParamsTypeSSHFP, RecordListParamsTypeSVCB, RecordListParamsTypeTLSA, RecordListParamsTypeTXT, RecordListParamsTypeURI: - return true - } - return false -} - -type RecordDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type RecordDeleteResponseEnvelope struct { - Result RecordDeleteResponse `json:"result"` - JSON recordDeleteResponseEnvelopeJSON `json:"-"` -} - -// recordDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [RecordDeleteResponseEnvelope] -type recordDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// This interface is a union satisfied by one of the following: -// [RecordEditParamsDNSRecordsARecord], [RecordEditParamsDNSRecordsAAAARecord], -// [RecordEditParamsDNSRecordsCAARecord], [RecordEditParamsDNSRecordsCERTRecord], -// [RecordEditParamsDNSRecordsCNAMERecord], -// [RecordEditParamsDNSRecordsDNSKEYRecord], [RecordEditParamsDNSRecordsDSRecord], -// [RecordEditParamsDNSRecordsHTTPSRecord], [RecordEditParamsDNSRecordsLOCRecord], -// [RecordEditParamsDNSRecordsMXRecord], [RecordEditParamsDNSRecordsNAPTRRecord], -// [RecordEditParamsDNSRecordsNSRecord], [RecordEditParamsDNSRecordsPTRRecord], -// [RecordEditParamsDNSRecordsSMIMEARecord], [RecordEditParamsDNSRecordsSRVRecord], -// [RecordEditParamsDNSRecordsSSHFPRecord], [RecordEditParamsDNSRecordsSVCBRecord], -// [RecordEditParamsDNSRecordsTLSARecord], [RecordEditParamsDNSRecordsTXTRecord], -// [RecordEditParamsDNSRecordsURIRecord]. -type RecordEditParams interface { - ImplementsRecordEditParams() - - getZoneID() param.Field[string] -} - -type RecordEditParamsDNSRecordsARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid IPv4 address. - Content param.Field[string] `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsARecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsARecord) ImplementsRecordEditParams() { - -} - -// Record type. -type RecordEditParamsDNSRecordsARecordType string - -const ( - RecordEditParamsDNSRecordsARecordTypeA RecordEditParamsDNSRecordsARecordType = "A" -) - -func (r RecordEditParamsDNSRecordsARecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsARecordTypeA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsARecordTTLNumber]. -type RecordEditParamsDNSRecordsARecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsARecordTTL() -} - -type RecordEditParamsDNSRecordsARecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsARecordTTLNumber1 RecordEditParamsDNSRecordsARecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsARecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsARecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsAAAARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid IPv6 address. - Content param.Field[string] `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsAAAARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsAAAARecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsAAAARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsAAAARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsAAAARecord) ImplementsRecordEditParams() { - -} - -// Record type. -type RecordEditParamsDNSRecordsAAAARecordType string - -const ( - RecordEditParamsDNSRecordsAAAARecordTypeAAAA RecordEditParamsDNSRecordsAAAARecordType = "AAAA" -) - -func (r RecordEditParamsDNSRecordsAAAARecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsAAAARecordTypeAAAA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsAAAARecordTTLNumber]. -type RecordEditParamsDNSRecordsAAAARecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsAAAARecordTTL() -} - -type RecordEditParamsDNSRecordsAAAARecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsAAAARecordTTLNumber1 RecordEditParamsDNSRecordsAAAARecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsAAAARecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsAAAARecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsCAARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a CAA record. - Data param.Field[RecordEditParamsDNSRecordsCAARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsCAARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsCAARecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsCAARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsCAARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsCAARecord) ImplementsRecordEditParams() { - -} - -// Components of a CAA record. -type RecordEditParamsDNSRecordsCAARecordData struct { - // Flags for the CAA record. - Flags param.Field[float64] `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag param.Field[string] `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value param.Field[string] `json:"value"` -} - -func (r RecordEditParamsDNSRecordsCAARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsCAARecordType string - -const ( - RecordEditParamsDNSRecordsCAARecordTypeCAA RecordEditParamsDNSRecordsCAARecordType = "CAA" -) - -func (r RecordEditParamsDNSRecordsCAARecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsCAARecordTypeCAA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsCAARecordTTLNumber]. -type RecordEditParamsDNSRecordsCAARecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsCAARecordTTL() -} - -type RecordEditParamsDNSRecordsCAARecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsCAARecordTTLNumber1 RecordEditParamsDNSRecordsCAARecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsCAARecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsCAARecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsCERTRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a CERT record. - Data param.Field[RecordEditParamsDNSRecordsCERTRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsCERTRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsCERTRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsCERTRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsCERTRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsCERTRecord) ImplementsRecordEditParams() { - -} - -// Components of a CERT record. -type RecordEditParamsDNSRecordsCERTRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Certificate. - Certificate param.Field[string] `json:"certificate"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` - // Type. - Type param.Field[float64] `json:"type"` -} - -func (r RecordEditParamsDNSRecordsCERTRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsCERTRecordType string - -const ( - RecordEditParamsDNSRecordsCERTRecordTypeCERT RecordEditParamsDNSRecordsCERTRecordType = "CERT" -) - -func (r RecordEditParamsDNSRecordsCERTRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsCERTRecordTypeCERT: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsCERTRecordTTLNumber]. -type RecordEditParamsDNSRecordsCERTRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsCERTRecordTTL() -} - -type RecordEditParamsDNSRecordsCERTRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsCERTRecordTTLNumber1 RecordEditParamsDNSRecordsCERTRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsCERTRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsCERTRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsCNAMERecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid hostname. Must not match the record's name. - Content param.Field[interface{}] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsCNAMERecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsCNAMERecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsCNAMERecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsCNAMERecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsCNAMERecord) ImplementsRecordEditParams() { - -} - -// Record type. -type RecordEditParamsDNSRecordsCNAMERecordType string - -const ( - RecordEditParamsDNSRecordsCNAMERecordTypeCNAME RecordEditParamsDNSRecordsCNAMERecordType = "CNAME" -) - -func (r RecordEditParamsDNSRecordsCNAMERecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsCNAMERecordTypeCNAME: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsCNAMERecordTTLNumber]. -type RecordEditParamsDNSRecordsCNAMERecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsCNAMERecordTTL() -} - -type RecordEditParamsDNSRecordsCNAMERecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsCNAMERecordTTLNumber1 RecordEditParamsDNSRecordsCNAMERecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsCNAMERecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsCNAMERecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsDNSKEYRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a DNSKEY record. - Data param.Field[RecordEditParamsDNSRecordsDNSKEYRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsDNSKEYRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsDNSKEYRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsDNSKEYRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsDNSKEYRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsDNSKEYRecord) ImplementsRecordEditParams() { - -} - -// Components of a DNSKEY record. -type RecordEditParamsDNSRecordsDNSKEYRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Flags. - Flags param.Field[float64] `json:"flags"` - // Protocol. - Protocol param.Field[float64] `json:"protocol"` - // Public Key. - PublicKey param.Field[string] `json:"public_key"` -} - -func (r RecordEditParamsDNSRecordsDNSKEYRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsDNSKEYRecordType string - -const ( - RecordEditParamsDNSRecordsDNSKEYRecordTypeDNSKEY RecordEditParamsDNSRecordsDNSKEYRecordType = "DNSKEY" -) - -func (r RecordEditParamsDNSRecordsDNSKEYRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsDNSKEYRecordTypeDNSKEY: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsDNSKEYRecordTTLNumber]. -type RecordEditParamsDNSRecordsDNSKEYRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsDNSKEYRecordTTL() -} - -type RecordEditParamsDNSRecordsDNSKEYRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsDNSKEYRecordTTLNumber1 RecordEditParamsDNSRecordsDNSKEYRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsDNSKEYRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsDNSKEYRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsDSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a DS record. - Data param.Field[RecordEditParamsDNSRecordsDSRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsDSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsDSRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsDSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsDSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsDSRecord) ImplementsRecordEditParams() { - -} - -// Components of a DS record. -type RecordEditParamsDNSRecordsDSRecordData struct { - // Algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Digest. - Digest param.Field[string] `json:"digest"` - // Digest Type. - DigestType param.Field[float64] `json:"digest_type"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` -} - -func (r RecordEditParamsDNSRecordsDSRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsDSRecordType string - -const ( - RecordEditParamsDNSRecordsDSRecordTypeDS RecordEditParamsDNSRecordsDSRecordType = "DS" -) - -func (r RecordEditParamsDNSRecordsDSRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsDSRecordTypeDS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsDSRecordTTLNumber]. -type RecordEditParamsDNSRecordsDSRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsDSRecordTTL() -} - -type RecordEditParamsDNSRecordsDSRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsDSRecordTTLNumber1 RecordEditParamsDNSRecordsDSRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsDSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsDSRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsHTTPSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a HTTPS record. - Data param.Field[RecordEditParamsDNSRecordsHTTPSRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsHTTPSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsHTTPSRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsHTTPSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsHTTPSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsHTTPSRecord) ImplementsRecordEditParams() { - -} - -// Components of a HTTPS record. -type RecordEditParamsDNSRecordsHTTPSRecordData struct { - // priority. - Priority param.Field[float64] `json:"priority"` - // target. - Target param.Field[string] `json:"target"` - // value. - Value param.Field[string] `json:"value"` -} - -func (r RecordEditParamsDNSRecordsHTTPSRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsHTTPSRecordType string - -const ( - RecordEditParamsDNSRecordsHTTPSRecordTypeHTTPS RecordEditParamsDNSRecordsHTTPSRecordType = "HTTPS" -) - -func (r RecordEditParamsDNSRecordsHTTPSRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsHTTPSRecordTypeHTTPS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsHTTPSRecordTTLNumber]. -type RecordEditParamsDNSRecordsHTTPSRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsHTTPSRecordTTL() -} - -type RecordEditParamsDNSRecordsHTTPSRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsHTTPSRecordTTLNumber1 RecordEditParamsDNSRecordsHTTPSRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsHTTPSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsHTTPSRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsLOCRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a LOC record. - Data param.Field[RecordEditParamsDNSRecordsLOCRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsLOCRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsLOCRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsLOCRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsLOCRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsLOCRecord) ImplementsRecordEditParams() { - -} - -// Components of a LOC record. -type RecordEditParamsDNSRecordsLOCRecordData struct { - // Altitude of location in meters. - Altitude param.Field[float64] `json:"altitude"` - // Degrees of latitude. - LatDegrees param.Field[float64] `json:"lat_degrees"` - // Latitude direction. - LatDirection param.Field[RecordEditParamsDNSRecordsLOCRecordDataLatDirection] `json:"lat_direction"` - // Minutes of latitude. - LatMinutes param.Field[float64] `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds param.Field[float64] `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees param.Field[float64] `json:"long_degrees"` - // Longitude direction. - LongDirection param.Field[RecordEditParamsDNSRecordsLOCRecordDataLongDirection] `json:"long_direction"` - // Minutes of longitude. - LongMinutes param.Field[float64] `json:"long_minutes"` - // Seconds of longitude. - LongSeconds param.Field[float64] `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz param.Field[float64] `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert param.Field[float64] `json:"precision_vert"` - // Size of location in meters. - Size param.Field[float64] `json:"size"` -} - -func (r RecordEditParamsDNSRecordsLOCRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Latitude direction. -type RecordEditParamsDNSRecordsLOCRecordDataLatDirection string - -const ( - RecordEditParamsDNSRecordsLOCRecordDataLatDirectionN RecordEditParamsDNSRecordsLOCRecordDataLatDirection = "N" - RecordEditParamsDNSRecordsLOCRecordDataLatDirectionS RecordEditParamsDNSRecordsLOCRecordDataLatDirection = "S" -) - -func (r RecordEditParamsDNSRecordsLOCRecordDataLatDirection) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsLOCRecordDataLatDirectionN, RecordEditParamsDNSRecordsLOCRecordDataLatDirectionS: - return true - } - return false -} - -// Longitude direction. -type RecordEditParamsDNSRecordsLOCRecordDataLongDirection string - -const ( - RecordEditParamsDNSRecordsLOCRecordDataLongDirectionE RecordEditParamsDNSRecordsLOCRecordDataLongDirection = "E" - RecordEditParamsDNSRecordsLOCRecordDataLongDirectionW RecordEditParamsDNSRecordsLOCRecordDataLongDirection = "W" -) - -func (r RecordEditParamsDNSRecordsLOCRecordDataLongDirection) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsLOCRecordDataLongDirectionE, RecordEditParamsDNSRecordsLOCRecordDataLongDirectionW: - return true - } - return false -} - -// Record type. -type RecordEditParamsDNSRecordsLOCRecordType string - -const ( - RecordEditParamsDNSRecordsLOCRecordTypeLOC RecordEditParamsDNSRecordsLOCRecordType = "LOC" -) - -func (r RecordEditParamsDNSRecordsLOCRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsLOCRecordTypeLOC: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsLOCRecordTTLNumber]. -type RecordEditParamsDNSRecordsLOCRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsLOCRecordTTL() -} - -type RecordEditParamsDNSRecordsLOCRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsLOCRecordTTLNumber1 RecordEditParamsDNSRecordsLOCRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsLOCRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsLOCRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsMXRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid mail server hostname. - Content param.Field[string] `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsMXRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsMXRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsMXRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsMXRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsMXRecord) ImplementsRecordEditParams() { - -} - -// Record type. -type RecordEditParamsDNSRecordsMXRecordType string - -const ( - RecordEditParamsDNSRecordsMXRecordTypeMX RecordEditParamsDNSRecordsMXRecordType = "MX" -) - -func (r RecordEditParamsDNSRecordsMXRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsMXRecordTypeMX: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsMXRecordTTLNumber]. -type RecordEditParamsDNSRecordsMXRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsMXRecordTTL() -} - -type RecordEditParamsDNSRecordsMXRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsMXRecordTTLNumber1 RecordEditParamsDNSRecordsMXRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsMXRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsMXRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsNAPTRRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a NAPTR record. - Data param.Field[RecordEditParamsDNSRecordsNAPTRRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsNAPTRRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsNAPTRRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsNAPTRRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsNAPTRRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsNAPTRRecord) ImplementsRecordEditParams() { - -} - -// Components of a NAPTR record. -type RecordEditParamsDNSRecordsNAPTRRecordData struct { - // Flags. - Flags param.Field[string] `json:"flags"` - // Order. - Order param.Field[float64] `json:"order"` - // Preference. - Preference param.Field[float64] `json:"preference"` - // Regex. - Regex param.Field[string] `json:"regex"` - // Replacement. - Replacement param.Field[string] `json:"replacement"` - // Service. - Service param.Field[string] `json:"service"` -} - -func (r RecordEditParamsDNSRecordsNAPTRRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsNAPTRRecordType string - -const ( - RecordEditParamsDNSRecordsNAPTRRecordTypeNAPTR RecordEditParamsDNSRecordsNAPTRRecordType = "NAPTR" -) - -func (r RecordEditParamsDNSRecordsNAPTRRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsNAPTRRecordTypeNAPTR: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsNAPTRRecordTTLNumber]. -type RecordEditParamsDNSRecordsNAPTRRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsNAPTRRecordTTL() -} - -type RecordEditParamsDNSRecordsNAPTRRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsNAPTRRecordTTLNumber1 RecordEditParamsDNSRecordsNAPTRRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsNAPTRRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsNAPTRRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsNSRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A valid name server host name. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsNSRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsNSRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsNSRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsNSRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsNSRecord) ImplementsRecordEditParams() { - -} - -// Record type. -type RecordEditParamsDNSRecordsNSRecordType string - -const ( - RecordEditParamsDNSRecordsNSRecordTypeNS RecordEditParamsDNSRecordsNSRecordType = "NS" -) - -func (r RecordEditParamsDNSRecordsNSRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsNSRecordTypeNS: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsNSRecordTTLNumber]. -type RecordEditParamsDNSRecordsNSRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsNSRecordTTL() -} - -type RecordEditParamsDNSRecordsNSRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsNSRecordTTLNumber1 RecordEditParamsDNSRecordsNSRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsNSRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsNSRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsPTRRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Domain name pointing to the address. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsPTRRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsPTRRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsPTRRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsPTRRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsPTRRecord) ImplementsRecordEditParams() { - -} - -// Record type. -type RecordEditParamsDNSRecordsPTRRecordType string - -const ( - RecordEditParamsDNSRecordsPTRRecordTypePTR RecordEditParamsDNSRecordsPTRRecordType = "PTR" -) - -func (r RecordEditParamsDNSRecordsPTRRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsPTRRecordTypePTR: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsPTRRecordTTLNumber]. -type RecordEditParamsDNSRecordsPTRRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsPTRRecordTTL() -} - -type RecordEditParamsDNSRecordsPTRRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsPTRRecordTTLNumber1 RecordEditParamsDNSRecordsPTRRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsPTRRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsPTRRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsSMIMEARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SMIMEA record. - Data param.Field[RecordEditParamsDNSRecordsSMIMEARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsSMIMEARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsSMIMEARecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsSMIMEARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsSMIMEARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsSMIMEARecord) ImplementsRecordEditParams() { - -} - -// Components of a SMIMEA record. -type RecordEditParamsDNSRecordsSMIMEARecordData struct { - // Certificate. - Certificate param.Field[string] `json:"certificate"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // Usage. - Usage param.Field[float64] `json:"usage"` -} - -func (r RecordEditParamsDNSRecordsSMIMEARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsSMIMEARecordType string - -const ( - RecordEditParamsDNSRecordsSMIMEARecordTypeSMIMEA RecordEditParamsDNSRecordsSMIMEARecordType = "SMIMEA" -) - -func (r RecordEditParamsDNSRecordsSMIMEARecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsSMIMEARecordTypeSMIMEA: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsSMIMEARecordTTLNumber]. -type RecordEditParamsDNSRecordsSMIMEARecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsSMIMEARecordTTL() -} - -type RecordEditParamsDNSRecordsSMIMEARecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsSMIMEARecordTTLNumber1 RecordEditParamsDNSRecordsSMIMEARecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsSMIMEARecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsSMIMEARecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsSRVRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SRV record. - Data param.Field[RecordEditParamsDNSRecordsSRVRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsSRVRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsSRVRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsSRVRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsSRVRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsSRVRecord) ImplementsRecordEditParams() { - -} - -// Components of a SRV record. -type RecordEditParamsDNSRecordsSRVRecordData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name param.Field[string] `json:"name" format:"hostname"` - // The port of the service. - Port param.Field[float64] `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto param.Field[string] `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service param.Field[string] `json:"service"` - // A valid hostname. - Target param.Field[string] `json:"target" format:"hostname"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r RecordEditParamsDNSRecordsSRVRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsSRVRecordType string - -const ( - RecordEditParamsDNSRecordsSRVRecordTypeSRV RecordEditParamsDNSRecordsSRVRecordType = "SRV" -) - -func (r RecordEditParamsDNSRecordsSRVRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsSRVRecordTypeSRV: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsSRVRecordTTLNumber]. -type RecordEditParamsDNSRecordsSRVRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsSRVRecordTTL() -} - -type RecordEditParamsDNSRecordsSRVRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsSRVRecordTTLNumber1 RecordEditParamsDNSRecordsSRVRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsSRVRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsSRVRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsSSHFPRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SSHFP record. - Data param.Field[RecordEditParamsDNSRecordsSSHFPRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsSSHFPRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsSSHFPRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsSSHFPRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsSSHFPRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsSSHFPRecord) ImplementsRecordEditParams() { - -} - -// Components of a SSHFP record. -type RecordEditParamsDNSRecordsSSHFPRecordData struct { - // algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // fingerprint. - Fingerprint param.Field[string] `json:"fingerprint"` - // type. - Type param.Field[float64] `json:"type"` -} - -func (r RecordEditParamsDNSRecordsSSHFPRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsSSHFPRecordType string - -const ( - RecordEditParamsDNSRecordsSSHFPRecordTypeSSHFP RecordEditParamsDNSRecordsSSHFPRecordType = "SSHFP" -) - -func (r RecordEditParamsDNSRecordsSSHFPRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsSSHFPRecordTypeSSHFP: - return true - } - return false -} - -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsSSHFPRecordTTLNumber]. -type RecordEditParamsDNSRecordsSSHFPRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsSSHFPRecordTTL() -} - -type RecordEditParamsDNSRecordsSSHFPRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsSSHFPRecordTTLNumber1 RecordEditParamsDNSRecordsSSHFPRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsSSHFPRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsSSHFPRecordTTLNumber1: - return true - } - return false -} - -type RecordEditParamsDNSRecordsSVCBRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a SVCB record. - Data param.Field[RecordEditParamsDNSRecordsSVCBRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsSVCBRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsSVCBRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsSVCBRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsSVCBRecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsSVCBRecord) ImplementsRecordEditParams() { - -} - -// Components of a SVCB record. -type RecordEditParamsDNSRecordsSVCBRecordData struct { - // priority. - Priority param.Field[float64] `json:"priority"` - // target. - Target param.Field[string] `json:"target"` - // value. - Value param.Field[string] `json:"value"` + Type param.Field[RecordListParamsType] `query:"type"` } -func (r RecordEditParamsDNSRecordsSVCBRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// URLQuery serializes [RecordListParams]'s query parameters as `url.Values`. +func (r RecordListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } -// Record type. -type RecordEditParamsDNSRecordsSVCBRecordType string - -const ( - RecordEditParamsDNSRecordsSVCBRecordTypeSVCB RecordEditParamsDNSRecordsSVCBRecordType = "SVCB" -) - -func (r RecordEditParamsDNSRecordsSVCBRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsSVCBRecordTypeSVCB: - return true - } - return false +type RecordListParamsComment struct { + // If this parameter is present, only records _without_ a comment are returned. + Absent param.Field[string] `query:"absent"` + // Substring of the DNS record comment. Comment filters are case-insensitive. + Contains param.Field[string] `query:"contains"` + // Suffix of the DNS record comment. Comment filters are case-insensitive. + Endswith param.Field[string] `query:"endswith"` + // Exact value of the DNS record comment. Comment filters are case-insensitive. + Exact param.Field[string] `query:"exact"` + // If this parameter is present, only records _with_ a comment are returned. + Present param.Field[string] `query:"present"` + // Prefix of the DNS record comment. Comment filters are case-insensitive. + Startswith param.Field[string] `query:"startswith"` } -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsSVCBRecordTTLNumber]. -type RecordEditParamsDNSRecordsSVCBRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsSVCBRecordTTL() +// URLQuery serializes [RecordListParamsComment]'s query parameters as +// `url.Values`. +func (r RecordListParamsComment) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } -type RecordEditParamsDNSRecordsSVCBRecordTTLNumber float64 +// Direction to order DNS records in. +type RecordListParamsDirection string const ( - RecordEditParamsDNSRecordsSVCBRecordTTLNumber1 RecordEditParamsDNSRecordsSVCBRecordTTLNumber = 1 + RecordListParamsDirectionAsc RecordListParamsDirection = "asc" + RecordListParamsDirectionDesc RecordListParamsDirection = "desc" ) -func (r RecordEditParamsDNSRecordsSVCBRecordTTLNumber) IsKnown() bool { +func (r RecordListParamsDirection) IsKnown() bool { switch r { - case RecordEditParamsDNSRecordsSVCBRecordTTLNumber1: + case RecordListParamsDirectionAsc, RecordListParamsDirectionDesc: return true } return false } -type RecordEditParamsDNSRecordsTLSARecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a TLSA record. - Data param.Field[RecordEditParamsDNSRecordsTLSARecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsTLSARecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsTLSARecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsTLSARecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsTLSARecord) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (RecordEditParamsDNSRecordsTLSARecord) ImplementsRecordEditParams() { - -} - -// Components of a TLSA record. -type RecordEditParamsDNSRecordsTLSARecordData struct { - // certificate. - Certificate param.Field[string] `json:"certificate"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // Usage. - Usage param.Field[float64] `json:"usage"` -} - -func (r RecordEditParamsDNSRecordsTLSARecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type RecordEditParamsDNSRecordsTLSARecordType string +// Whether to match all search requirements or at least one (any). If set to `all`, +// acts like a logical AND between filters. If set to `any`, acts like a logical OR +// instead. Note that the interaction between tag filters is controlled by the +// `tag-match` parameter instead. +type RecordListParamsMatch string const ( - RecordEditParamsDNSRecordsTLSARecordTypeTLSA RecordEditParamsDNSRecordsTLSARecordType = "TLSA" + RecordListParamsMatchAny RecordListParamsMatch = "any" + RecordListParamsMatchAll RecordListParamsMatch = "all" ) -func (r RecordEditParamsDNSRecordsTLSARecordType) IsKnown() bool { +func (r RecordListParamsMatch) IsKnown() bool { switch r { - case RecordEditParamsDNSRecordsTLSARecordTypeTLSA: + case RecordListParamsMatchAny, RecordListParamsMatchAll: return true } return false } -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsTLSARecordTTLNumber]. -type RecordEditParamsDNSRecordsTLSARecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsTLSARecordTTL() -} - -type RecordEditParamsDNSRecordsTLSARecordTTLNumber float64 +// Field to order DNS records by. +type RecordListParamsOrder string const ( - RecordEditParamsDNSRecordsTLSARecordTTLNumber1 RecordEditParamsDNSRecordsTLSARecordTTLNumber = 1 + RecordListParamsOrderType RecordListParamsOrder = "type" + RecordListParamsOrderName RecordListParamsOrder = "name" + RecordListParamsOrderContent RecordListParamsOrder = "content" + RecordListParamsOrderTTL RecordListParamsOrder = "ttl" + RecordListParamsOrderProxied RecordListParamsOrder = "proxied" ) -func (r RecordEditParamsDNSRecordsTLSARecordTTLNumber) IsKnown() bool { +func (r RecordListParamsOrder) IsKnown() bool { switch r { - case RecordEditParamsDNSRecordsTLSARecordTTLNumber1: + case RecordListParamsOrderType, RecordListParamsOrderName, RecordListParamsOrderContent, RecordListParamsOrderTTL, RecordListParamsOrderProxied: return true } return false } -type RecordEditParamsDNSRecordsTXTRecord struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Text content for the record. - Content param.Field[string] `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsTXTRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsTXTRecordTTL] `json:"ttl"` -} - -func (r RecordEditParamsDNSRecordsTXTRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsTXTRecord) getZoneID() param.Field[string] { - return r.ZoneID +type RecordListParamsTag struct { + // Name of a tag which must _not_ be present on the DNS record. Tag filters are + // case-insensitive. + Absent param.Field[string] `query:"absent"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value contains + // ``. Tag filters are case-insensitive. + Contains param.Field[string] `query:"contains"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value ends with + // ``. Tag filters are case-insensitive. + Endswith param.Field[string] `query:"endswith"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value is ``. Tag + // filters are case-insensitive. + Exact param.Field[string] `query:"exact"` + // Name of a tag which must be present on the DNS record. Tag filters are + // case-insensitive. + Present param.Field[string] `query:"present"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value starts with + // ``. Tag filters are case-insensitive. + Startswith param.Field[string] `query:"startswith"` } -func (RecordEditParamsDNSRecordsTXTRecord) ImplementsRecordEditParams() { - +// URLQuery serializes [RecordListParamsTag]'s query parameters as `url.Values`. +func (r RecordListParamsTag) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } -// Record type. -type RecordEditParamsDNSRecordsTXTRecordType string +// Whether to match all tag search requirements or at least one (any). If set to +// `all`, acts like a logical AND between tag filters. If set to `any`, acts like a +// logical OR instead. Note that the regular `match` parameter is still used to +// combine the resulting condition with other filters that aren't related to tags. +type RecordListParamsTagMatch string const ( - RecordEditParamsDNSRecordsTXTRecordTypeTXT RecordEditParamsDNSRecordsTXTRecordType = "TXT" + RecordListParamsTagMatchAny RecordListParamsTagMatch = "any" + RecordListParamsTagMatchAll RecordListParamsTagMatch = "all" ) -func (r RecordEditParamsDNSRecordsTXTRecordType) IsKnown() bool { +func (r RecordListParamsTagMatch) IsKnown() bool { switch r { - case RecordEditParamsDNSRecordsTXTRecordTypeTXT: + case RecordListParamsTagMatchAny, RecordListParamsTagMatchAll: return true } return false } -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsTXTRecordTTLNumber]. -type RecordEditParamsDNSRecordsTXTRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsTXTRecordTTL() -} - -type RecordEditParamsDNSRecordsTXTRecordTTLNumber float64 +// Record type. +type RecordListParamsType string const ( - RecordEditParamsDNSRecordsTXTRecordTTLNumber1 RecordEditParamsDNSRecordsTXTRecordTTLNumber = 1 + RecordListParamsTypeA RecordListParamsType = "A" + RecordListParamsTypeAAAA RecordListParamsType = "AAAA" + RecordListParamsTypeCAA RecordListParamsType = "CAA" + RecordListParamsTypeCERT RecordListParamsType = "CERT" + RecordListParamsTypeCNAME RecordListParamsType = "CNAME" + RecordListParamsTypeDNSKEY RecordListParamsType = "DNSKEY" + RecordListParamsTypeDS RecordListParamsType = "DS" + RecordListParamsTypeHTTPS RecordListParamsType = "HTTPS" + RecordListParamsTypeLOC RecordListParamsType = "LOC" + RecordListParamsTypeMX RecordListParamsType = "MX" + RecordListParamsTypeNAPTR RecordListParamsType = "NAPTR" + RecordListParamsTypeNS RecordListParamsType = "NS" + RecordListParamsTypePTR RecordListParamsType = "PTR" + RecordListParamsTypeSMIMEA RecordListParamsType = "SMIMEA" + RecordListParamsTypeSRV RecordListParamsType = "SRV" + RecordListParamsTypeSSHFP RecordListParamsType = "SSHFP" + RecordListParamsTypeSVCB RecordListParamsType = "SVCB" + RecordListParamsTypeTLSA RecordListParamsType = "TLSA" + RecordListParamsTypeTXT RecordListParamsType = "TXT" + RecordListParamsTypeURI RecordListParamsType = "URI" ) -func (r RecordEditParamsDNSRecordsTXTRecordTTLNumber) IsKnown() bool { +func (r RecordListParamsType) IsKnown() bool { switch r { - case RecordEditParamsDNSRecordsTXTRecordTTLNumber1: + case RecordListParamsTypeA, RecordListParamsTypeAAAA, RecordListParamsTypeCAA, RecordListParamsTypeCERT, RecordListParamsTypeCNAME, RecordListParamsTypeDNSKEY, RecordListParamsTypeDS, RecordListParamsTypeHTTPS, RecordListParamsTypeLOC, RecordListParamsTypeMX, RecordListParamsTypeNAPTR, RecordListParamsTypeNS, RecordListParamsTypePTR, RecordListParamsTypeSMIMEA, RecordListParamsTypeSRV, RecordListParamsTypeSSHFP, RecordListParamsTypeSVCB, RecordListParamsTypeTLSA, RecordListParamsTypeTXT, RecordListParamsTypeURI: return true } return false } -type RecordEditParamsDNSRecordsURIRecord struct { +type RecordDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` - // Components of a URI record. - Data param.Field[RecordEditParamsDNSRecordsURIRecordData] `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority,required"` - // Record type. - Type param.Field[RecordEditParamsDNSRecordsURIRecordType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `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. - TTL param.Field[RecordEditParamsDNSRecordsURIRecordTTL] `json:"ttl"` + Body interface{} `json:"body,required"` } -func (r RecordEditParamsDNSRecordsURIRecord) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RecordEditParamsDNSRecordsURIRecord) getZoneID() param.Field[string] { - return r.ZoneID +func (r RecordDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -func (RecordEditParamsDNSRecordsURIRecord) ImplementsRecordEditParams() { - +type RecordDeleteResponseEnvelope struct { + Result RecordDeleteResponse `json:"result"` + JSON recordDeleteResponseEnvelopeJSON `json:"-"` } -// Components of a URI record. -type RecordEditParamsDNSRecordsURIRecordData struct { - // The record content. - Content param.Field[string] `json:"content"` - // The record weight. - Weight param.Field[float64] `json:"weight"` +// recordDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordDeleteResponseEnvelope] +type recordDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r RecordEditParamsDNSRecordsURIRecordData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *RecordDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// Record type. -type RecordEditParamsDNSRecordsURIRecordType string - -const ( - RecordEditParamsDNSRecordsURIRecordTypeURI RecordEditParamsDNSRecordsURIRecordType = "URI" -) - -func (r RecordEditParamsDNSRecordsURIRecordType) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsURIRecordTypeURI: - return true - } - return false +func (r recordDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// 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. -// -// Satisfied by [shared.UnionFloat], -// [dns.RecordEditParamsDNSRecordsURIRecordTTLNumber]. -type RecordEditParamsDNSRecordsURIRecordTTL interface { - ImplementsDNSRecordEditParamsDNSRecordsURIRecordTTL() +type RecordEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Record RecordUnionParam `json:"record,required"` } -type RecordEditParamsDNSRecordsURIRecordTTLNumber float64 - -const ( - RecordEditParamsDNSRecordsURIRecordTTLNumber1 RecordEditParamsDNSRecordsURIRecordTTLNumber = 1 -) - -func (r RecordEditParamsDNSRecordsURIRecordTTLNumber) IsKnown() bool { - switch r { - case RecordEditParamsDNSRecordsURIRecordTTLNumber1: - return true - } - return false +func (r RecordEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Record) } type RecordEditResponseEnvelope struct { - Errors []RecordEditResponseEnvelopeErrors `json:"errors,required"` - Messages []RecordEditResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecord `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Record `json:"result,required"` // Whether the API call was successful Success RecordEditResponseEnvelopeSuccess `json:"success,required"` JSON recordEditResponseEnvelopeJSON `json:"-"` @@ -9431,52 +3913,6 @@ func (r recordEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RecordEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// recordEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RecordEditResponseEnvelopeErrors] -type recordEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RecordEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// recordEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RecordEditResponseEnvelopeMessages] -type recordEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RecordEditResponseEnvelopeSuccess bool @@ -9503,9 +3939,9 @@ type RecordGetParams struct { } type RecordGetResponseEnvelope struct { - Errors []RecordGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RecordGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecord `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Record `json:"result,required"` // Whether the API call was successful Success RecordGetResponseEnvelopeSuccess `json:"success,required"` JSON recordGetResponseEnvelopeJSON `json:"-"` @@ -9530,52 +3966,6 @@ func (r recordGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RecordGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// recordGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RecordGetResponseEnvelopeErrors] -type recordGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RecordGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// recordGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RecordGetResponseEnvelopeMessages] -type recordGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RecordGetResponseEnvelopeSuccess bool @@ -9611,12 +4001,12 @@ func (r RecordImportParams) MarshalJSON() (data []byte, err error) { } type RecordImportResponseEnvelope struct { - Errors []RecordImportResponseEnvelopeErrors `json:"errors,required"` - Messages []RecordImportResponseEnvelopeMessages `json:"messages,required"` - Result RecordImportResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RecordImportResponse `json:"result,required"` // Whether the API call was successful Success RecordImportResponseEnvelopeSuccess `json:"success,required"` - Timing RecordImportResponseEnvelopeTiming `json:"timing"` + Timing RecordProcessTiming `json:"timing"` JSON recordImportResponseEnvelopeJSON `json:"-"` } @@ -9640,52 +4030,6 @@ func (r recordImportResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RecordImportResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordImportResponseEnvelopeErrorsJSON `json:"-"` -} - -// recordImportResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RecordImportResponseEnvelopeErrors] -type recordImportResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordImportResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordImportResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RecordImportResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordImportResponseEnvelopeMessagesJSON `json:"-"` -} - -// recordImportResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RecordImportResponseEnvelopeMessages] -type recordImportResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordImportResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordImportResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RecordImportResponseEnvelopeSuccess bool @@ -9701,46 +4045,23 @@ func (r RecordImportResponseEnvelopeSuccess) IsKnown() bool { return false } -type RecordImportResponseEnvelopeTiming struct { - // When the file parsing ended. - EndTime time.Time `json:"end_time" format:"date-time"` - // Processing time of the file in seconds. - ProcessTime float64 `json:"process_time"` - // When the file parsing started. - StartTime time.Time `json:"start_time" format:"date-time"` - JSON recordImportResponseEnvelopeTimingJSON `json:"-"` -} - -// recordImportResponseEnvelopeTimingJSON contains the JSON metadata for the struct -// [RecordImportResponseEnvelopeTiming] -type recordImportResponseEnvelopeTimingJSON struct { - EndTime apijson.Field - ProcessTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordImportResponseEnvelopeTiming) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordImportResponseEnvelopeTimingJSON) RawJSON() string { - return r.raw -} - type RecordScanParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RecordScanParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type RecordScanResponseEnvelope struct { - Errors []RecordScanResponseEnvelopeErrors `json:"errors,required"` - Messages []RecordScanResponseEnvelopeMessages `json:"messages,required"` - Result RecordScanResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RecordScanResponse `json:"result,required"` // Whether the API call was successful Success RecordScanResponseEnvelopeSuccess `json:"success,required"` - Timing RecordScanResponseEnvelopeTiming `json:"timing"` + Timing RecordProcessTiming `json:"timing"` JSON recordScanResponseEnvelopeJSON `json:"-"` } @@ -9764,52 +4085,6 @@ func (r recordScanResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RecordScanResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordScanResponseEnvelopeErrorsJSON `json:"-"` -} - -// recordScanResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RecordScanResponseEnvelopeErrors] -type recordScanResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordScanResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordScanResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RecordScanResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recordScanResponseEnvelopeMessagesJSON `json:"-"` -} - -// recordScanResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RecordScanResponseEnvelopeMessages] -type recordScanResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordScanResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordScanResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RecordScanResponseEnvelopeSuccess bool @@ -9824,31 +4099,3 @@ func (r RecordScanResponseEnvelopeSuccess) IsKnown() bool { } return false } - -type RecordScanResponseEnvelopeTiming struct { - // When the file parsing ended. - EndTime time.Time `json:"end_time" format:"date-time"` - // Processing time of the file in seconds. - ProcessTime float64 `json:"process_time"` - // When the file parsing started. - StartTime time.Time `json:"start_time" format:"date-time"` - JSON recordScanResponseEnvelopeTimingJSON `json:"-"` -} - -// recordScanResponseEnvelopeTimingJSON contains the JSON metadata for the struct -// [RecordScanResponseEnvelopeTiming] -type recordScanResponseEnvelopeTimingJSON struct { - EndTime apijson.Field - ProcessTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecordScanResponseEnvelopeTiming) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recordScanResponseEnvelopeTimingJSON) RawJSON() string { - return r.raw -} diff --git a/dns/record_test.go b/dns/record_test.go index 4c59b3222f8..267e28141f4 100644 --- a/dns/record_test.go +++ b/dns/record_test.go @@ -29,15 +29,17 @@ func TestRecordNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.DNS.Records.New(context.TODO(), dns.RecordNewParamsDNSRecordsARecord{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Content: cloudflare.F("198.51.100.4"), - Name: cloudflare.F("example.com"), - Type: cloudflare.F(dns.RecordNewParamsDNSRecordsARecordTypeA), - Comment: cloudflare.F("Domain verification record"), - Proxied: cloudflare.F(false), - Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), - TTL: cloudflare.F[dns.RecordNewParamsDNSRecordsARecordTTL](shared.UnionFloat(3600.000000)), + _, err := client.DNS.Records.New(context.TODO(), dns.RecordNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Record: dns.ARecordParam{ + Content: cloudflare.F("198.51.100.4"), + Name: cloudflare.F("example.com"), + Proxied: cloudflare.F(false), + Type: cloudflare.F(dns.ARecordTypeA), + Comment: cloudflare.F("Domain verification record"), + 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 { var apierr *cloudflare.Error @@ -65,15 +67,17 @@ func TestRecordUpdateWithOptionalParams(t *testing.T) { _, err := client.DNS.Records.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - dns.RecordUpdateParamsDNSRecordsARecord{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Content: cloudflare.F("198.51.100.4"), - Name: cloudflare.F("example.com"), - Type: cloudflare.F(dns.RecordUpdateParamsDNSRecordsARecordTypeA), - Comment: cloudflare.F("Domain verification record"), - Proxied: cloudflare.F(false), - Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), - TTL: cloudflare.F[dns.RecordUpdateParamsDNSRecordsARecordTTL](shared.UnionFloat(3600.000000)), + dns.RecordUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Record: dns.ARecordParam{ + Content: cloudflare.F("198.51.100.4"), + Name: cloudflare.F("example.com"), + Proxied: cloudflare.F(false), + Type: cloudflare.F(dns.ARecordTypeA), + Comment: cloudflare.F("Domain verification record"), + 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 { @@ -157,6 +161,7 @@ func TestRecordDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", dns.RecordDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -185,15 +190,17 @@ func TestRecordEditWithOptionalParams(t *testing.T) { _, err := client.DNS.Records.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - dns.RecordEditParamsDNSRecordsARecord{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Content: cloudflare.F("198.51.100.4"), - Name: cloudflare.F("example.com"), - Type: cloudflare.F(dns.RecordEditParamsDNSRecordsARecordTypeA), - Comment: cloudflare.F("Domain verification record"), - Proxied: cloudflare.F(false), - Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), - TTL: cloudflare.F[dns.RecordEditParamsDNSRecordsARecordTTL](shared.UnionFloat(3600.000000)), + dns.RecordEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Record: dns.ARecordParam{ + Content: cloudflare.F("198.51.100.4"), + Name: cloudflare.F("example.com"), + Proxied: cloudflare.F(false), + Type: cloudflare.F(dns.ARecordTypeA), + Comment: cloudflare.F("Domain verification record"), + 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 { @@ -305,6 +312,7 @@ func TestRecordScan(t *testing.T) { ) _, err := client.DNS.Records.Scan(context.TODO(), dns.RecordScanParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/dnssec/aliases.go b/dnssec/aliases.go index a49dcff263b..0bdac82730a 100644 --- a/dnssec/aliases.go +++ b/dnssec/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/dnssec/dnssec.go b/dnssec/dnssec.go index d39593d1cc5..0cbbb31b673 100644 --- a/dnssec/dnssec.go +++ b/dnssec/dnssec.go @@ -35,10 +35,10 @@ func NewDNSSECService(opts ...option.RequestOption) (r *DNSSECService) { } // Delete DNSSEC. -func (r *DNSSECService) Delete(ctx context.Context, body DNSSECDeleteParams, opts ...option.RequestOption) (res *DNSSECDeleteResponse, err error) { +func (r *DNSSECService) Delete(ctx context.Context, params DNSSECDeleteParams, opts ...option.RequestOption) (res *DNSSECDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DNSSECDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/dnssec", body.ZoneID) + path := fmt.Sprintf("zones/%s/dnssec", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -163,13 +163,13 @@ func (r DNSSECStatus) IsKnown() bool { } // Union satisfied by [dnssec.DNSSECDeleteResponseUnknown] or [shared.UnionString]. -type DNSSECDeleteResponse interface { - ImplementsDNSSECDNSSECDeleteResponse() +type DNSSECDeleteResponseUnion interface { + ImplementsDNSSECDNSSECDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DNSSECDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*DNSSECDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -181,12 +181,17 @@ func init() { type DNSSECDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DNSSECDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DNSSECDeleteResponseEnvelope struct { - Errors []DNSSECDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSSECDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DNSSECDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DNSSECDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success DNSSECDeleteResponseEnvelopeSuccess `json:"success,required"` JSON dnssecDeleteResponseEnvelopeJSON `json:"-"` @@ -211,52 +216,6 @@ func (r dnssecDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DNSSECDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnssecDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnssecDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DNSSECDeleteResponseEnvelopeErrors] -type dnssecDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSECDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnssecDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSSECDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnssecDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnssecDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSSECDeleteResponseEnvelopeMessages] -type dnssecDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSECDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnssecDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DNSSECDeleteResponseEnvelopeSuccess bool @@ -317,9 +276,9 @@ func (r DNSSECEditParamsStatus) IsKnown() bool { } type DNSSECEditResponseEnvelope struct { - Errors []DNSSECEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSSECEditResponseEnvelopeMessages `json:"messages,required"` - Result DNSSEC `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DNSSEC `json:"result,required"` // Whether the API call was successful Success DNSSECEditResponseEnvelopeSuccess `json:"success,required"` JSON dnssecEditResponseEnvelopeJSON `json:"-"` @@ -344,52 +303,6 @@ func (r dnssecEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DNSSECEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnssecEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnssecEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DNSSECEditResponseEnvelopeErrors] -type dnssecEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSECEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnssecEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSSECEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnssecEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnssecEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DNSSECEditResponseEnvelopeMessages] -type dnssecEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSECEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnssecEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DNSSECEditResponseEnvelopeSuccess bool @@ -411,9 +324,9 @@ type DNSSECGetParams struct { } type DNSSECGetResponseEnvelope struct { - Errors []DNSSECGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSSECGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSSEC `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DNSSEC `json:"result,required"` // Whether the API call was successful Success DNSSECGetResponseEnvelopeSuccess `json:"success,required"` JSON dnssecGetResponseEnvelopeJSON `json:"-"` @@ -438,52 +351,6 @@ func (r dnssecGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DNSSECGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnssecGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnssecGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DNSSECGetResponseEnvelopeErrors] -type dnssecGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSECGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnssecGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSSECGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnssecGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnssecGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DNSSECGetResponseEnvelopeMessages] -type dnssecGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSECGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnssecGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DNSSECGetResponseEnvelopeSuccess bool diff --git a/dnssec/dnssec_test.go b/dnssec/dnssec_test.go index e8f58a54b66..2e87d475d14 100644 --- a/dnssec/dnssec_test.go +++ b/dnssec/dnssec_test.go @@ -30,6 +30,7 @@ func TestDNSSECDelete(t *testing.T) { ) _, err := client.DNSSEC.Delete(context.TODO(), dnssec.DNSSECDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/durable_objects/aliases.go b/durable_objects/aliases.go index 280b6157b68..019035d725f 100644 --- a/durable_objects/aliases.go +++ b/durable_objects/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/durable_objects/namespace.go b/durable_objects/namespace.go index b70369ec3c4..dca9761392f 100644 --- a/durable_objects/namespace.go +++ b/durable_objects/namespace.go @@ -34,7 +34,7 @@ func NewNamespaceService(opts ...option.RequestOption) (r *NamespaceService) { } // Returns the Durable Object namespaces owned by an account. -func (r *NamespaceService) List(ctx context.Context, query NamespaceListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DurableObjectNamespace], err error) { +func (r *NamespaceService) List(ctx context.Context, query NamespaceListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Namespace], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -52,21 +52,20 @@ func (r *NamespaceService) List(ctx context.Context, query NamespaceListParams, } // Returns the Durable Object namespaces owned by an account. -func (r *NamespaceService) ListAutoPaging(ctx context.Context, query NamespaceListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DurableObjectNamespace] { +func (r *NamespaceService) ListAutoPaging(ctx context.Context, query NamespaceListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Namespace] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } -type DurableObjectNamespace struct { - ID interface{} `json:"id"` - Class interface{} `json:"class"` - Name interface{} `json:"name"` - Script interface{} `json:"script"` - JSON durableObjectNamespaceJSON `json:"-"` +type Namespace struct { + ID interface{} `json:"id"` + Class interface{} `json:"class"` + Name interface{} `json:"name"` + Script interface{} `json:"script"` + JSON namespaceJSON `json:"-"` } -// durableObjectNamespaceJSON contains the JSON metadata for the struct -// [DurableObjectNamespace] -type durableObjectNamespaceJSON struct { +// namespaceJSON contains the JSON metadata for the struct [Namespace] +type namespaceJSON struct { ID apijson.Field Class apijson.Field Name apijson.Field @@ -75,11 +74,11 @@ type durableObjectNamespaceJSON struct { ExtraFields map[string]apijson.Field } -func (r *DurableObjectNamespace) UnmarshalJSON(data []byte) (err error) { +func (r *Namespace) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r durableObjectNamespaceJSON) RawJSON() string { +func (r namespaceJSON) RawJSON() string { return r.raw } diff --git a/durable_objects/namespaceobject.go b/durable_objects/namespaceobject.go index 91eeb023b50..b403524cad0 100644 --- a/durable_objects/namespaceobject.go +++ b/durable_objects/namespaceobject.go @@ -97,7 +97,7 @@ type NamespaceObjectListParams struct { // `url.Values`. func (r NamespaceObjectListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/email_routing/address.go b/email_routing/address.go index 598aa141acf..f1644572a7b 100644 --- a/email_routing/address.go +++ b/email_routing/address.go @@ -14,6 +14,7 @@ import ( "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" ) @@ -36,7 +37,7 @@ func NewAddressService(opts ...option.RequestOption) (r *AddressService) { // Create a destination address to forward your emails to. Destination addresses // need to be verified before they can be used. -func (r *AddressService) New(ctx context.Context, accountIdentifier string, body AddressNewParams, opts ...option.RequestOption) (res *AddressNewResponse, err error) { +func (r *AddressService) New(ctx context.Context, accountIdentifier string, body AddressNewParams, opts ...option.RequestOption) (res *Address, err error) { opts = append(r.Options[:], opts...) var env AddressNewResponseEnvelope path := fmt.Sprintf("accounts/%s/email/routing/addresses", accountIdentifier) @@ -49,7 +50,7 @@ func (r *AddressService) New(ctx context.Context, accountIdentifier string, body } // Lists existing destination addresses. -func (r *AddressService) List(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[AddressListResponse], err error) { +func (r *AddressService) List(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Address], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -67,12 +68,12 @@ func (r *AddressService) List(ctx context.Context, accountIdentifier string, que } // Lists existing destination addresses. -func (r *AddressService) ListAutoPaging(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[AddressListResponse] { +func (r *AddressService) ListAutoPaging(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Address] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) } // Deletes a specific destination address. -func (r *AddressService) Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *AddressDeleteResponse, err error) { +func (r *AddressService) Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *Address, err error) { opts = append(r.Options[:], opts...) var env AddressDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) @@ -85,7 +86,7 @@ func (r *AddressService) Delete(ctx context.Context, accountIdentifier string, d } // Gets information for a specific destination email already created. -func (r *AddressService) Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *AddressGetResponse, err error) { +func (r *AddressService) Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *Address, err error) { opts = append(r.Options[:], opts...) var env AddressGetResponseEnvelope path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) @@ -97,7 +98,7 @@ func (r *AddressService) Get(ctx context.Context, accountIdentifier string, dest return } -type AddressNewResponse struct { +type Address struct { // Destination address identifier. ID string `json:"id"` // The date and time the destination address has been created. @@ -111,13 +112,12 @@ type AddressNewResponse struct { Tag string `json:"tag"` // The date and time the destination address has been verified. Null means not // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON addressNewResponseJSON `json:"-"` + Verified time.Time `json:"verified" format:"date-time"` + JSON addressJSON `json:"-"` } -// addressNewResponseJSON contains the JSON metadata for the struct -// [AddressNewResponse] -type addressNewResponseJSON struct { +// addressJSON contains the JSON metadata for the struct [Address] +type addressJSON struct { ID apijson.Field Created apijson.Field Email apijson.Field @@ -128,128 +128,11 @@ type addressNewResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Address) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressNewResponseJSON) RawJSON() string { - return r.raw -} - -type AddressListResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON addressListResponseJSON `json:"-"` -} - -// addressListResponseJSON contains the JSON metadata for the struct -// [AddressListResponse] -type addressListResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressListResponseJSON) RawJSON() string { - return r.raw -} - -type AddressDeleteResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON addressDeleteResponseJSON `json:"-"` -} - -// addressDeleteResponseJSON contains the JSON metadata for the struct -// [AddressDeleteResponse] -type addressDeleteResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type AddressGetResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON addressGetResponseJSON `json:"-"` -} - -// addressGetResponseJSON contains the JSON metadata for the struct -// [AddressGetResponse] -type addressGetResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressGetResponseJSON) RawJSON() string { +func (r addressJSON) RawJSON() string { return r.raw } @@ -263,9 +146,9 @@ func (r AddressNewParams) MarshalJSON() (data []byte, err error) { } type AddressNewResponseEnvelope struct { - Errors []AddressNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Address `json:"result,required"` // Whether the API call was successful Success AddressNewResponseEnvelopeSuccess `json:"success,required"` JSON addressNewResponseEnvelopeJSON `json:"-"` @@ -290,52 +173,6 @@ func (r addressNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AddressNewResponseEnvelopeErrors] -type addressNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AddressNewResponseEnvelopeMessages] -type addressNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressNewResponseEnvelopeSuccess bool @@ -365,7 +202,7 @@ type AddressListParams struct { // URLQuery serializes [AddressListParams]'s query parameters as `url.Values`. func (r AddressListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -403,9 +240,9 @@ func (r AddressListParamsVerified) IsKnown() bool { } type AddressDeleteResponseEnvelope struct { - Errors []AddressDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Address `json:"result,required"` // Whether the API call was successful Success AddressDeleteResponseEnvelopeSuccess `json:"success,required"` JSON addressDeleteResponseEnvelopeJSON `json:"-"` @@ -430,52 +267,6 @@ func (r addressDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressDeleteResponseEnvelopeErrors] -type addressDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AddressDeleteResponseEnvelopeMessages] -type addressDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressDeleteResponseEnvelopeSuccess bool @@ -492,9 +283,9 @@ func (r AddressDeleteResponseEnvelopeSuccess) IsKnown() bool { } type AddressGetResponseEnvelope struct { - Errors []AddressGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Address `json:"result,required"` // Whether the API call was successful Success AddressGetResponseEnvelopeSuccess `json:"success,required"` JSON addressGetResponseEnvelopeJSON `json:"-"` @@ -519,52 +310,6 @@ func (r addressGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AddressGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AddressGetResponseEnvelopeErrors] -type addressGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AddressGetResponseEnvelopeMessages] -type addressGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AddressGetResponseEnvelopeSuccess bool diff --git a/email_routing/aliases.go b/email_routing/aliases.go index 02c8ca9d4b9..319771a4b20 100644 --- a/email_routing/aliases.go +++ b/email_routing/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/email_routing/dns.go b/email_routing/dns.go index 8e9bcdad841..3eb565abce2 100644 --- a/email_routing/dns.go +++ b/email_routing/dns.go @@ -33,7 +33,7 @@ func NewDNSService(opts ...option.RequestOption) (r *DNSService) { } // Show the DNS records needed to configure your Email Routing zone. -func (r *DNSService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]EmailDNSRecord, err error) { +func (r *DNSService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]DNSRecord, err error) { opts = append(r.Options[:], opts...) var env DNSGetResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/dns", zoneIdentifier) @@ -46,7 +46,7 @@ func (r *DNSService) Get(ctx context.Context, zoneIdentifier string, opts ...opt } // List of records needed to enable an Email Routing zone. -type EmailDNSRecord struct { +type DNSRecord struct { // DNS record content. Content string `json:"content"` // DNS record name (or @ for the zone apex). @@ -56,14 +56,14 @@ type EmailDNSRecord struct { Priority float64 `json:"priority"` // Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 // for 'automatic'. - TTL EmailDNSRecordTTL `json:"ttl"` + TTL DNSRecordTTLUnion `json:"ttl"` // DNS record type. - Type EmailDNSRecordType `json:"type"` - JSON emailDNSRecordJSON `json:"-"` + Type DNSRecordType `json:"type"` + JSON dnsRecordJSON `json:"-"` } -// emailDNSRecordJSON contains the JSON metadata for the struct [EmailDNSRecord] -type emailDNSRecordJSON struct { +// dnsRecordJSON contains the JSON metadata for the struct [DNSRecord] +type dnsRecordJSON struct { Content apijson.Field Name apijson.Field Priority apijson.Field @@ -73,26 +73,25 @@ type emailDNSRecordJSON struct { ExtraFields map[string]apijson.Field } -func (r *EmailDNSRecord) UnmarshalJSON(data []byte) (err error) { +func (r *DNSRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r emailDNSRecordJSON) RawJSON() string { +func (r dnsRecordJSON) RawJSON() string { return r.raw } // Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 // for 'automatic'. // -// Union satisfied by [shared.UnionFloat] or -// [email_routing.EmailDNSRecordTTLNumber]. -type EmailDNSRecordTTL interface { - ImplementsEmailRoutingEmailDNSRecordTTL() +// Union satisfied by [shared.UnionFloat] or [email_routing.DNSRecordTTLNumber]. +type DNSRecordTTLUnion interface { + ImplementsEmailRoutingDNSRecordTTLUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*EmailDNSRecordTTL)(nil)).Elem(), + reflect.TypeOf((*DNSRecordTTLUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.Number, @@ -100,61 +99,61 @@ func init() { }, apijson.UnionVariant{ TypeFilter: gjson.Number, - Type: reflect.TypeOf(EmailDNSRecordTTLNumber(0)), + Type: reflect.TypeOf(DNSRecordTTLNumber(0)), }, ) } -type EmailDNSRecordTTLNumber float64 +type DNSRecordTTLNumber float64 const ( - EmailDNSRecordTTLNumber1 EmailDNSRecordTTLNumber = 1 + DNSRecordTTLNumber1 DNSRecordTTLNumber = 1 ) -func (r EmailDNSRecordTTLNumber) IsKnown() bool { +func (r DNSRecordTTLNumber) IsKnown() bool { switch r { - case EmailDNSRecordTTLNumber1: + case DNSRecordTTLNumber1: return true } return false } // DNS record type. -type EmailDNSRecordType string +type DNSRecordType string const ( - EmailDNSRecordTypeA EmailDNSRecordType = "A" - EmailDNSRecordTypeAAAA EmailDNSRecordType = "AAAA" - EmailDNSRecordTypeCNAME EmailDNSRecordType = "CNAME" - EmailDNSRecordTypeHTTPS EmailDNSRecordType = "HTTPS" - EmailDNSRecordTypeTXT EmailDNSRecordType = "TXT" - EmailDNSRecordTypeSRV EmailDNSRecordType = "SRV" - EmailDNSRecordTypeLOC EmailDNSRecordType = "LOC" - EmailDNSRecordTypeMX EmailDNSRecordType = "MX" - EmailDNSRecordTypeNS EmailDNSRecordType = "NS" - EmailDNSRecordTypeCERT EmailDNSRecordType = "CERT" - EmailDNSRecordTypeDNSKEY EmailDNSRecordType = "DNSKEY" - EmailDNSRecordTypeDS EmailDNSRecordType = "DS" - EmailDNSRecordTypeNAPTR EmailDNSRecordType = "NAPTR" - EmailDNSRecordTypeSMIMEA EmailDNSRecordType = "SMIMEA" - EmailDNSRecordTypeSSHFP EmailDNSRecordType = "SSHFP" - EmailDNSRecordTypeSVCB EmailDNSRecordType = "SVCB" - EmailDNSRecordTypeTLSA EmailDNSRecordType = "TLSA" - EmailDNSRecordTypeURI EmailDNSRecordType = "URI" + DNSRecordTypeA DNSRecordType = "A" + DNSRecordTypeAAAA DNSRecordType = "AAAA" + DNSRecordTypeCNAME DNSRecordType = "CNAME" + DNSRecordTypeHTTPS DNSRecordType = "HTTPS" + DNSRecordTypeTXT DNSRecordType = "TXT" + DNSRecordTypeSRV DNSRecordType = "SRV" + DNSRecordTypeLOC DNSRecordType = "LOC" + DNSRecordTypeMX DNSRecordType = "MX" + DNSRecordTypeNS DNSRecordType = "NS" + DNSRecordTypeCERT DNSRecordType = "CERT" + DNSRecordTypeDNSKEY DNSRecordType = "DNSKEY" + DNSRecordTypeDS DNSRecordType = "DS" + DNSRecordTypeNAPTR DNSRecordType = "NAPTR" + DNSRecordTypeSMIMEA DNSRecordType = "SMIMEA" + DNSRecordTypeSSHFP DNSRecordType = "SSHFP" + DNSRecordTypeSVCB DNSRecordType = "SVCB" + DNSRecordTypeTLSA DNSRecordType = "TLSA" + DNSRecordTypeURI DNSRecordType = "URI" ) -func (r EmailDNSRecordType) IsKnown() bool { +func (r DNSRecordType) IsKnown() bool { switch r { - case EmailDNSRecordTypeA, EmailDNSRecordTypeAAAA, EmailDNSRecordTypeCNAME, EmailDNSRecordTypeHTTPS, EmailDNSRecordTypeTXT, EmailDNSRecordTypeSRV, EmailDNSRecordTypeLOC, EmailDNSRecordTypeMX, EmailDNSRecordTypeNS, EmailDNSRecordTypeCERT, EmailDNSRecordTypeDNSKEY, EmailDNSRecordTypeDS, EmailDNSRecordTypeNAPTR, EmailDNSRecordTypeSMIMEA, EmailDNSRecordTypeSSHFP, EmailDNSRecordTypeSVCB, EmailDNSRecordTypeTLSA, EmailDNSRecordTypeURI: + case DNSRecordTypeA, DNSRecordTypeAAAA, DNSRecordTypeCNAME, DNSRecordTypeHTTPS, DNSRecordTypeTXT, DNSRecordTypeSRV, DNSRecordTypeLOC, DNSRecordTypeMX, DNSRecordTypeNS, DNSRecordTypeCERT, DNSRecordTypeDNSKEY, DNSRecordTypeDS, DNSRecordTypeNAPTR, DNSRecordTypeSMIMEA, DNSRecordTypeSSHFP, DNSRecordTypeSVCB, DNSRecordTypeTLSA, DNSRecordTypeURI: return true } return false } type DNSGetResponseEnvelope struct { - Errors []DNSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSGetResponseEnvelopeMessages `json:"messages,required"` - Result []EmailDNSRecord `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []DNSRecord `json:"result,required,nullable"` // Whether the API call was successful Success DNSGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DNSGetResponseEnvelopeResultInfo `json:"result_info"` @@ -181,52 +180,6 @@ func (r dnsGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DNSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DNSGetResponseEnvelopeErrors] -type dnsGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DNSGetResponseEnvelopeMessages] -type dnsGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DNSGetResponseEnvelopeSuccess bool diff --git a/email_routing/emailrouting.go b/email_routing/emailrouting.go index 7723da52864..35bded23be9 100644 --- a/email_routing/emailrouting.go +++ b/email_routing/emailrouting.go @@ -10,6 +10,7 @@ import ( "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" ) @@ -39,7 +40,7 @@ func NewEmailRoutingService(opts ...option.RequestOption) (r *EmailRoutingServic // Disable your Email Routing zone. Also removes additional MX records previously // required for Email Routing to work. -func (r *EmailRoutingService) Disable(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingDisableResponse, err error) { +func (r *EmailRoutingService) Disable(ctx context.Context, zoneIdentifier string, body EmailRoutingDisableParams, opts ...option.RequestOption) (res *Settings, err error) { opts = append(r.Options[:], opts...) var env EmailRoutingDisableResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/disable", zoneIdentifier) @@ -52,7 +53,7 @@ func (r *EmailRoutingService) Disable(ctx context.Context, zoneIdentifier string } // Enable you Email Routing zone. Add and lock the necessary MX and SPF records. -func (r *EmailRoutingService) Enable(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingEnableResponse, err error) { +func (r *EmailRoutingService) Enable(ctx context.Context, zoneIdentifier string, body EmailRoutingEnableParams, opts ...option.RequestOption) (res *Settings, err error) { opts = append(r.Options[:], opts...) var env EmailRoutingEnableResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/enable", zoneIdentifier) @@ -65,7 +66,7 @@ func (r *EmailRoutingService) Enable(ctx context.Context, zoneIdentifier string, } // Get information about the settings for your Email Routing zone. -func (r *EmailRoutingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingGetResponse, err error) { +func (r *EmailRoutingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *Settings, err error) { opts = append(r.Options[:], opts...) var env EmailRoutingGetResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing", zoneIdentifier) @@ -77,30 +78,29 @@ func (r *EmailRoutingService) Get(ctx context.Context, zoneIdentifier string, op return } -type EmailRoutingDisableResponse struct { +type Settings struct { // Email Routing settings identifier. ID string `json:"id"` // The date and time the settings have been created. Created time.Time `json:"created" format:"date-time"` // State of the zone settings for Email Routing. - Enabled EmailRoutingDisableResponseEnabled `json:"enabled"` + Enabled SettingsEnabled `json:"enabled"` // The date and time the settings have been modified. Modified time.Time `json:"modified" format:"date-time"` // Domain of your zone. Name string `json:"name"` // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingDisableResponseSkipWizard `json:"skip_wizard"` + SkipWizard SettingsSkipWizard `json:"skip_wizard"` // Show the state of your account, and the type or configuration error. - Status EmailRoutingDisableResponseStatus `json:"status"` + Status SettingsStatus `json:"status"` // Email Routing settings tag. (Deprecated, replaced by Email Routing settings // identifier) - Tag string `json:"tag"` - JSON emailRoutingDisableResponseJSON `json:"-"` + Tag string `json:"tag"` + JSON settingsJSON `json:"-"` } -// emailRoutingDisableResponseJSON contains the JSON metadata for the struct -// [EmailRoutingDisableResponse] -type emailRoutingDisableResponseJSON struct { +// settingsJSON contains the JSON metadata for the struct [Settings] +type settingsJSON struct { ID apijson.Field Created apijson.Field Enabled apijson.Field @@ -113,259 +113,77 @@ type emailRoutingDisableResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *EmailRoutingDisableResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Settings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r emailRoutingDisableResponseJSON) RawJSON() string { +func (r settingsJSON) RawJSON() string { return r.raw } // State of the zone settings for Email Routing. -type EmailRoutingDisableResponseEnabled bool +type SettingsEnabled bool const ( - EmailRoutingDisableResponseEnabledTrue EmailRoutingDisableResponseEnabled = true - EmailRoutingDisableResponseEnabledFalse EmailRoutingDisableResponseEnabled = false + SettingsEnabledTrue SettingsEnabled = true + SettingsEnabledFalse SettingsEnabled = false ) -func (r EmailRoutingDisableResponseEnabled) IsKnown() bool { +func (r SettingsEnabled) IsKnown() bool { switch r { - case EmailRoutingDisableResponseEnabledTrue, EmailRoutingDisableResponseEnabledFalse: + case SettingsEnabledTrue, SettingsEnabledFalse: return true } return false } // Flag to check if the user skipped the configuration wizard. -type EmailRoutingDisableResponseSkipWizard bool +type SettingsSkipWizard bool const ( - EmailRoutingDisableResponseSkipWizardTrue EmailRoutingDisableResponseSkipWizard = true - EmailRoutingDisableResponseSkipWizardFalse EmailRoutingDisableResponseSkipWizard = false + SettingsSkipWizardTrue SettingsSkipWizard = true + SettingsSkipWizardFalse SettingsSkipWizard = false ) -func (r EmailRoutingDisableResponseSkipWizard) IsKnown() bool { +func (r SettingsSkipWizard) IsKnown() bool { switch r { - case EmailRoutingDisableResponseSkipWizardTrue, EmailRoutingDisableResponseSkipWizardFalse: + case SettingsSkipWizardTrue, SettingsSkipWizardFalse: return true } return false } // Show the state of your account, and the type or configuration error. -type EmailRoutingDisableResponseStatus string +type SettingsStatus string const ( - EmailRoutingDisableResponseStatusReady EmailRoutingDisableResponseStatus = "ready" - EmailRoutingDisableResponseStatusUnconfigured EmailRoutingDisableResponseStatus = "unconfigured" - EmailRoutingDisableResponseStatusMisconfigured EmailRoutingDisableResponseStatus = "misconfigured" - EmailRoutingDisableResponseStatusMisconfiguredLocked EmailRoutingDisableResponseStatus = "misconfigured/locked" - EmailRoutingDisableResponseStatusUnlocked EmailRoutingDisableResponseStatus = "unlocked" + SettingsStatusReady SettingsStatus = "ready" + SettingsStatusUnconfigured SettingsStatus = "unconfigured" + SettingsStatusMisconfigured SettingsStatus = "misconfigured" + SettingsStatusMisconfiguredLocked SettingsStatus = "misconfigured/locked" + SettingsStatusUnlocked SettingsStatus = "unlocked" ) -func (r EmailRoutingDisableResponseStatus) IsKnown() bool { +func (r SettingsStatus) IsKnown() bool { switch r { - case EmailRoutingDisableResponseStatusReady, EmailRoutingDisableResponseStatusUnconfigured, EmailRoutingDisableResponseStatusMisconfigured, EmailRoutingDisableResponseStatusMisconfiguredLocked, EmailRoutingDisableResponseStatusUnlocked: + case SettingsStatusReady, SettingsStatusUnconfigured, SettingsStatusMisconfigured, SettingsStatusMisconfiguredLocked, SettingsStatusUnlocked: return true } return false } -type EmailRoutingEnableResponse struct { - // Email Routing settings identifier. - ID string `json:"id"` - // The date and time the settings have been created. - Created time.Time `json:"created" format:"date-time"` - // State of the zone settings for Email Routing. - Enabled EmailRoutingEnableResponseEnabled `json:"enabled"` - // The date and time the settings have been modified. - Modified time.Time `json:"modified" format:"date-time"` - // Domain of your zone. - Name string `json:"name"` - // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingEnableResponseSkipWizard `json:"skip_wizard"` - // Show the state of your account, and the type or configuration error. - Status EmailRoutingEnableResponseStatus `json:"status"` - // Email Routing settings tag. (Deprecated, replaced by Email Routing settings - // identifier) - Tag string `json:"tag"` - JSON emailRoutingEnableResponseJSON `json:"-"` -} - -// emailRoutingEnableResponseJSON contains the JSON metadata for the struct -// [EmailRoutingEnableResponse] -type emailRoutingEnableResponseJSON struct { - ID apijson.Field - Created apijson.Field - Enabled apijson.Field - Modified apijson.Field - Name apijson.Field - SkipWizard apijson.Field - Status apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingEnableResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingEnableResponseJSON) RawJSON() string { - return r.raw -} - -// State of the zone settings for Email Routing. -type EmailRoutingEnableResponseEnabled bool - -const ( - EmailRoutingEnableResponseEnabledTrue EmailRoutingEnableResponseEnabled = true - EmailRoutingEnableResponseEnabledFalse EmailRoutingEnableResponseEnabled = false -) - -func (r EmailRoutingEnableResponseEnabled) IsKnown() bool { - switch r { - case EmailRoutingEnableResponseEnabledTrue, EmailRoutingEnableResponseEnabledFalse: - return true - } - return false -} - -// Flag to check if the user skipped the configuration wizard. -type EmailRoutingEnableResponseSkipWizard bool - -const ( - EmailRoutingEnableResponseSkipWizardTrue EmailRoutingEnableResponseSkipWizard = true - EmailRoutingEnableResponseSkipWizardFalse EmailRoutingEnableResponseSkipWizard = false -) - -func (r EmailRoutingEnableResponseSkipWizard) IsKnown() bool { - switch r { - case EmailRoutingEnableResponseSkipWizardTrue, EmailRoutingEnableResponseSkipWizardFalse: - return true - } - return false -} - -// Show the state of your account, and the type or configuration error. -type EmailRoutingEnableResponseStatus string - -const ( - EmailRoutingEnableResponseStatusReady EmailRoutingEnableResponseStatus = "ready" - EmailRoutingEnableResponseStatusUnconfigured EmailRoutingEnableResponseStatus = "unconfigured" - EmailRoutingEnableResponseStatusMisconfigured EmailRoutingEnableResponseStatus = "misconfigured" - EmailRoutingEnableResponseStatusMisconfiguredLocked EmailRoutingEnableResponseStatus = "misconfigured/locked" - EmailRoutingEnableResponseStatusUnlocked EmailRoutingEnableResponseStatus = "unlocked" -) - -func (r EmailRoutingEnableResponseStatus) IsKnown() bool { - switch r { - case EmailRoutingEnableResponseStatusReady, EmailRoutingEnableResponseStatusUnconfigured, EmailRoutingEnableResponseStatusMisconfigured, EmailRoutingEnableResponseStatusMisconfiguredLocked, EmailRoutingEnableResponseStatusUnlocked: - return true - } - return false -} - -type EmailRoutingGetResponse struct { - // Email Routing settings identifier. - ID string `json:"id"` - // The date and time the settings have been created. - Created time.Time `json:"created" format:"date-time"` - // State of the zone settings for Email Routing. - Enabled EmailRoutingGetResponseEnabled `json:"enabled"` - // The date and time the settings have been modified. - Modified time.Time `json:"modified" format:"date-time"` - // Domain of your zone. - Name string `json:"name"` - // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingGetResponseSkipWizard `json:"skip_wizard"` - // Show the state of your account, and the type or configuration error. - Status EmailRoutingGetResponseStatus `json:"status"` - // Email Routing settings tag. (Deprecated, replaced by Email Routing settings - // identifier) - Tag string `json:"tag"` - JSON emailRoutingGetResponseJSON `json:"-"` -} - -// emailRoutingGetResponseJSON contains the JSON metadata for the struct -// [EmailRoutingGetResponse] -type emailRoutingGetResponseJSON struct { - ID apijson.Field - Created apijson.Field - Enabled apijson.Field - Modified apijson.Field - Name apijson.Field - SkipWizard apijson.Field - Status apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingGetResponseJSON) RawJSON() string { - return r.raw -} - -// State of the zone settings for Email Routing. -type EmailRoutingGetResponseEnabled bool - -const ( - EmailRoutingGetResponseEnabledTrue EmailRoutingGetResponseEnabled = true - EmailRoutingGetResponseEnabledFalse EmailRoutingGetResponseEnabled = false -) - -func (r EmailRoutingGetResponseEnabled) IsKnown() bool { - switch r { - case EmailRoutingGetResponseEnabledTrue, EmailRoutingGetResponseEnabledFalse: - return true - } - return false -} - -// Flag to check if the user skipped the configuration wizard. -type EmailRoutingGetResponseSkipWizard bool - -const ( - EmailRoutingGetResponseSkipWizardTrue EmailRoutingGetResponseSkipWizard = true - EmailRoutingGetResponseSkipWizardFalse EmailRoutingGetResponseSkipWizard = false -) - -func (r EmailRoutingGetResponseSkipWizard) IsKnown() bool { - switch r { - case EmailRoutingGetResponseSkipWizardTrue, EmailRoutingGetResponseSkipWizardFalse: - return true - } - return false +type EmailRoutingDisableParams struct { + Body interface{} `json:"body,required"` } -// Show the state of your account, and the type or configuration error. -type EmailRoutingGetResponseStatus string - -const ( - EmailRoutingGetResponseStatusReady EmailRoutingGetResponseStatus = "ready" - EmailRoutingGetResponseStatusUnconfigured EmailRoutingGetResponseStatus = "unconfigured" - EmailRoutingGetResponseStatusMisconfigured EmailRoutingGetResponseStatus = "misconfigured" - EmailRoutingGetResponseStatusMisconfiguredLocked EmailRoutingGetResponseStatus = "misconfigured/locked" - EmailRoutingGetResponseStatusUnlocked EmailRoutingGetResponseStatus = "unlocked" -) - -func (r EmailRoutingGetResponseStatus) IsKnown() bool { - switch r { - case EmailRoutingGetResponseStatusReady, EmailRoutingGetResponseStatusUnconfigured, EmailRoutingGetResponseStatusMisconfigured, EmailRoutingGetResponseStatusMisconfiguredLocked, EmailRoutingGetResponseStatusUnlocked: - return true - } - return false +func (r EmailRoutingDisableParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type EmailRoutingDisableResponseEnvelope struct { - Errors []EmailRoutingDisableResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingDisableResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingDisableResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Settings `json:"result,required"` // Whether the API call was successful Success EmailRoutingDisableResponseEnvelopeSuccess `json:"success,required"` JSON emailRoutingDisableResponseEnvelopeJSON `json:"-"` @@ -390,52 +208,6 @@ func (r emailRoutingDisableResponseEnvelopeJSON) RawJSON() string { return r.raw } -type EmailRoutingDisableResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingDisableResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingDisableResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [EmailRoutingDisableResponseEnvelopeErrors] -type emailRoutingDisableResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingDisableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingDisableResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingDisableResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingDisableResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingDisableResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [EmailRoutingDisableResponseEnvelopeMessages] -type emailRoutingDisableResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingDisableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingDisableResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type EmailRoutingDisableResponseEnvelopeSuccess bool @@ -451,10 +223,18 @@ func (r EmailRoutingDisableResponseEnvelopeSuccess) IsKnown() bool { return false } +type EmailRoutingEnableParams struct { + Body interface{} `json:"body,required"` +} + +func (r EmailRoutingEnableParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type EmailRoutingEnableResponseEnvelope struct { - Errors []EmailRoutingEnableResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingEnableResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingEnableResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Settings `json:"result,required"` // Whether the API call was successful Success EmailRoutingEnableResponseEnvelopeSuccess `json:"success,required"` JSON emailRoutingEnableResponseEnvelopeJSON `json:"-"` @@ -479,52 +259,6 @@ func (r emailRoutingEnableResponseEnvelopeJSON) RawJSON() string { return r.raw } -type EmailRoutingEnableResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingEnableResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingEnableResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [EmailRoutingEnableResponseEnvelopeErrors] -type emailRoutingEnableResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingEnableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingEnableResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingEnableResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingEnableResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingEnableResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [EmailRoutingEnableResponseEnvelopeMessages] -type emailRoutingEnableResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingEnableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingEnableResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type EmailRoutingEnableResponseEnvelopeSuccess bool @@ -541,9 +275,9 @@ func (r EmailRoutingEnableResponseEnvelopeSuccess) IsKnown() bool { } type EmailRoutingGetResponseEnvelope struct { - Errors []EmailRoutingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingGetResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Settings `json:"result,required"` // Whether the API call was successful Success EmailRoutingGetResponseEnvelopeSuccess `json:"success,required"` JSON emailRoutingGetResponseEnvelopeJSON `json:"-"` @@ -568,52 +302,6 @@ func (r emailRoutingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type EmailRoutingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [EmailRoutingGetResponseEnvelopeErrors] -type emailRoutingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [EmailRoutingGetResponseEnvelopeMessages] -type emailRoutingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type EmailRoutingGetResponseEnvelopeSuccess bool diff --git a/email_routing/emailrouting_test.go b/email_routing/emailrouting_test.go index e1b4587dc54..6bcafdd26b9 100644 --- a/email_routing/emailrouting_test.go +++ b/email_routing/emailrouting_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go/v2" + "github.com/cloudflare/cloudflare-go/v2/email_routing" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -27,7 +28,13 @@ func TestEmailRoutingDisable(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.EmailRouting.Disable(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + _, err := client.EmailRouting.Disable( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + email_routing.EmailRoutingDisableParams{ + Body: map[string]interface{}{}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -51,7 +58,13 @@ func TestEmailRoutingEnable(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.EmailRouting.Enable(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + _, err := client.EmailRouting.Enable( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + email_routing.EmailRoutingEnableParams{ + Body: map[string]interface{}{}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/email_routing/rule.go b/email_routing/rule.go index 14361c48046..bd8ca9b70ae 100644 --- a/email_routing/rule.go +++ b/email_routing/rule.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -38,7 +39,7 @@ func NewRuleService(opts ...option.RequestOption) (r *RuleService) { // Rules consist of a set of criteria for matching emails (such as an email being // sent to a specific custom email address) plus a set of actions to take on the // email (like forwarding it to a specific destination address). -func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleNewParams, opts ...option.RequestOption) (res *RuleNewResponse, err error) { +func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleNewParams, opts ...option.RequestOption) (res *EmailRoutingRule, err error) { opts = append(r.Options[:], opts...) var env RuleNewResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules", zoneIdentifier) @@ -51,7 +52,7 @@ func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleN } // Update actions and matches, or enable/disable specific routing rules. -func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body RuleUpdateParams, opts ...option.RequestOption) (res *RuleUpdateResponse, err error) { +func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body RuleUpdateParams, opts ...option.RequestOption) (res *EmailRoutingRule, err error) { opts = append(r.Options[:], opts...) var env RuleUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) @@ -64,7 +65,7 @@ func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, ruleIde } // Lists existing routing rules. -func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[RuleListResponse], err error) { +func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[EmailRoutingRule], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -82,12 +83,12 @@ func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query Rul } // Lists existing routing rules. -func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[RuleListResponse] { +func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[EmailRoutingRule] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) } // Delete a specific routing rule. -func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *RuleDeleteResponse, err error) { +func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRule, err error) { opts = append(r.Options[:], opts...) var env RuleDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) @@ -100,7 +101,7 @@ func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIde } // Get information for a specific routing rule already created. -func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *RuleGetResponse, err error) { +func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRule, err error) { opts = append(r.Options[:], opts...) var env RuleGetResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) @@ -112,653 +113,79 @@ func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdenti return } -type RuleNewResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleNewResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleNewResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleNewResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleNewResponseJSON `json:"-"` -} - -// ruleNewResponseJSON contains the JSON metadata for the struct [RuleNewResponse] -type ruleNewResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type RuleNewResponseAction struct { - // Type of supported action. - Type RuleNewResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleNewResponseActionJSON `json:"-"` -} - -// ruleNewResponseActionJSON contains the JSON metadata for the struct -// [RuleNewResponseAction] -type ruleNewResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type RuleNewResponseActionsType string - -const ( - RuleNewResponseActionsTypeDrop RuleNewResponseActionsType = "drop" - RuleNewResponseActionsTypeForward RuleNewResponseActionsType = "forward" - RuleNewResponseActionsTypeWorker RuleNewResponseActionsType = "worker" -) - -func (r RuleNewResponseActionsType) IsKnown() bool { - switch r { - case RuleNewResponseActionsTypeDrop, RuleNewResponseActionsTypeForward, RuleNewResponseActionsTypeWorker: - return true - } - return false -} - -// Routing rule status. -type RuleNewResponseEnabled bool - -const ( - RuleNewResponseEnabledTrue RuleNewResponseEnabled = true - RuleNewResponseEnabledFalse RuleNewResponseEnabled = false -) - -func (r RuleNewResponseEnabled) IsKnown() bool { - switch r { - case RuleNewResponseEnabledTrue, RuleNewResponseEnabledFalse: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleNewResponseMatcher struct { - // Field for type matcher. - Field RuleNewResponseMatchersField `json:"field,required"` - // Type of matcher. - Type RuleNewResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON ruleNewResponseMatcherJSON `json:"-"` -} - -// ruleNewResponseMatcherJSON contains the JSON metadata for the struct -// [RuleNewResponseMatcher] -type ruleNewResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type RuleNewResponseMatchersField string - -const ( - RuleNewResponseMatchersFieldTo RuleNewResponseMatchersField = "to" -) - -func (r RuleNewResponseMatchersField) IsKnown() bool { - switch r { - case RuleNewResponseMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleNewResponseMatchersType string - -const ( - RuleNewResponseMatchersTypeLiteral RuleNewResponseMatchersType = "literal" -) - -func (r RuleNewResponseMatchersType) IsKnown() bool { - switch r { - case RuleNewResponseMatchersTypeLiteral: - return true - } - return false -} - -type RuleUpdateResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleUpdateResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleUpdateResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleUpdateResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleUpdateResponseJSON `json:"-"` -} - -// ruleUpdateResponseJSON contains the JSON metadata for the struct -// [RuleUpdateResponse] -type ruleUpdateResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type RuleUpdateResponseAction struct { - // Type of supported action. - Type RuleUpdateResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleUpdateResponseActionJSON `json:"-"` -} - -// ruleUpdateResponseActionJSON contains the JSON metadata for the struct -// [RuleUpdateResponseAction] -type ruleUpdateResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type RuleUpdateResponseActionsType string - -const ( - RuleUpdateResponseActionsTypeDrop RuleUpdateResponseActionsType = "drop" - RuleUpdateResponseActionsTypeForward RuleUpdateResponseActionsType = "forward" - RuleUpdateResponseActionsTypeWorker RuleUpdateResponseActionsType = "worker" -) - -func (r RuleUpdateResponseActionsType) IsKnown() bool { - switch r { - case RuleUpdateResponseActionsTypeDrop, RuleUpdateResponseActionsTypeForward, RuleUpdateResponseActionsTypeWorker: - return true - } - return false -} - -// Routing rule status. -type RuleUpdateResponseEnabled bool - -const ( - RuleUpdateResponseEnabledTrue RuleUpdateResponseEnabled = true - RuleUpdateResponseEnabledFalse RuleUpdateResponseEnabled = false -) - -func (r RuleUpdateResponseEnabled) IsKnown() bool { - switch r { - case RuleUpdateResponseEnabledTrue, RuleUpdateResponseEnabledFalse: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleUpdateResponseMatcher struct { - // Field for type matcher. - Field RuleUpdateResponseMatchersField `json:"field,required"` - // Type of matcher. - Type RuleUpdateResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON ruleUpdateResponseMatcherJSON `json:"-"` -} - -// ruleUpdateResponseMatcherJSON contains the JSON metadata for the struct -// [RuleUpdateResponseMatcher] -type ruleUpdateResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type RuleUpdateResponseMatchersField string - -const ( - RuleUpdateResponseMatchersFieldTo RuleUpdateResponseMatchersField = "to" -) - -func (r RuleUpdateResponseMatchersField) IsKnown() bool { - switch r { - case RuleUpdateResponseMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleUpdateResponseMatchersType string - -const ( - RuleUpdateResponseMatchersTypeLiteral RuleUpdateResponseMatchersType = "literal" -) - -func (r RuleUpdateResponseMatchersType) IsKnown() bool { - switch r { - case RuleUpdateResponseMatchersTypeLiteral: - return true - } - return false -} - -type RuleListResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleListResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleListResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleListResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleListResponseJSON `json:"-"` -} - -// ruleListResponseJSON contains the JSON metadata for the struct -// [RuleListResponse] -type ruleListResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type RuleListResponseAction struct { - // Type of supported action. - Type RuleListResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleListResponseActionJSON `json:"-"` -} - -// ruleListResponseActionJSON contains the JSON metadata for the struct -// [RuleListResponseAction] -type ruleListResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type RuleListResponseActionsType string - -const ( - RuleListResponseActionsTypeDrop RuleListResponseActionsType = "drop" - RuleListResponseActionsTypeForward RuleListResponseActionsType = "forward" - RuleListResponseActionsTypeWorker RuleListResponseActionsType = "worker" -) - -func (r RuleListResponseActionsType) IsKnown() bool { - switch r { - case RuleListResponseActionsTypeDrop, RuleListResponseActionsTypeForward, RuleListResponseActionsTypeWorker: - return true - } - return false -} - -// Routing rule status. -type RuleListResponseEnabled bool - -const ( - RuleListResponseEnabledTrue RuleListResponseEnabled = true - RuleListResponseEnabledFalse RuleListResponseEnabled = false -) - -func (r RuleListResponseEnabled) IsKnown() bool { - switch r { - case RuleListResponseEnabledTrue, RuleListResponseEnabledFalse: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleListResponseMatcher struct { - // Field for type matcher. - Field RuleListResponseMatchersField `json:"field,required"` - // Type of matcher. - Type RuleListResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON ruleListResponseMatcherJSON `json:"-"` -} - -// ruleListResponseMatcherJSON contains the JSON metadata for the struct -// [RuleListResponseMatcher] -type ruleListResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type RuleListResponseMatchersField string - -const ( - RuleListResponseMatchersFieldTo RuleListResponseMatchersField = "to" -) - -func (r RuleListResponseMatchersField) IsKnown() bool { - switch r { - case RuleListResponseMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleListResponseMatchersType string - -const ( - RuleListResponseMatchersTypeLiteral RuleListResponseMatchersType = "literal" -) - -func (r RuleListResponseMatchersType) IsKnown() bool { - switch r { - case RuleListResponseMatchersTypeLiteral: - return true - } - return false -} - -type RuleDeleteResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleDeleteResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleDeleteResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleDeleteResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleDeleteResponseJSON `json:"-"` -} - -// ruleDeleteResponseJSON contains the JSON metadata for the struct -// [RuleDeleteResponse] -type ruleDeleteResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type RuleDeleteResponseAction struct { - // Type of supported action. - Type RuleDeleteResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleDeleteResponseActionJSON `json:"-"` -} - -// ruleDeleteResponseActionJSON contains the JSON metadata for the struct -// [RuleDeleteResponseAction] -type ruleDeleteResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type RuleDeleteResponseActionsType string - -const ( - RuleDeleteResponseActionsTypeDrop RuleDeleteResponseActionsType = "drop" - RuleDeleteResponseActionsTypeForward RuleDeleteResponseActionsType = "forward" - RuleDeleteResponseActionsTypeWorker RuleDeleteResponseActionsType = "worker" -) - -func (r RuleDeleteResponseActionsType) IsKnown() bool { - switch r { - case RuleDeleteResponseActionsTypeDrop, RuleDeleteResponseActionsTypeForward, RuleDeleteResponseActionsTypeWorker: - return true - } - return false -} - -// Routing rule status. -type RuleDeleteResponseEnabled bool - -const ( - RuleDeleteResponseEnabledTrue RuleDeleteResponseEnabled = true - RuleDeleteResponseEnabledFalse RuleDeleteResponseEnabled = false -) - -func (r RuleDeleteResponseEnabled) IsKnown() bool { - switch r { - case RuleDeleteResponseEnabledTrue, RuleDeleteResponseEnabledFalse: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleDeleteResponseMatcher struct { - // Field for type matcher. - Field RuleDeleteResponseMatchersField `json:"field,required"` - // Type of matcher. - Type RuleDeleteResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON ruleDeleteResponseMatcherJSON `json:"-"` +// Actions pattern. +type Action struct { + // Type of supported action. + Type ActionType `json:"type,required"` + Value []string `json:"value,required"` + JSON actionJSON `json:"-"` } -// ruleDeleteResponseMatcherJSON contains the JSON metadata for the struct -// [RuleDeleteResponseMatcher] -type ruleDeleteResponseMatcherJSON struct { - Field apijson.Field +// actionJSON contains the JSON metadata for the struct [Action] +type actionJSON struct { Type apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleDeleteResponseMatcher) UnmarshalJSON(data []byte) (err error) { +func (r *Action) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleDeleteResponseMatcherJSON) RawJSON() string { +func (r actionJSON) RawJSON() string { return r.raw } -// Field for type matcher. -type RuleDeleteResponseMatchersField string +// Type of supported action. +type ActionType string const ( - RuleDeleteResponseMatchersFieldTo RuleDeleteResponseMatchersField = "to" + ActionTypeDrop ActionType = "drop" + ActionTypeForward ActionType = "forward" + ActionTypeWorker ActionType = "worker" ) -func (r RuleDeleteResponseMatchersField) IsKnown() bool { +func (r ActionType) IsKnown() bool { switch r { - case RuleDeleteResponseMatchersFieldTo: + case ActionTypeDrop, ActionTypeForward, ActionTypeWorker: return true } return false } -// Type of matcher. -type RuleDeleteResponseMatchersType string - -const ( - RuleDeleteResponseMatchersTypeLiteral RuleDeleteResponseMatchersType = "literal" -) +// Actions pattern. +type ActionParam struct { + // Type of supported action. + Type param.Field[ActionType] `json:"type,required"` + Value param.Field[[]string] `json:"value,required"` +} -func (r RuleDeleteResponseMatchersType) IsKnown() bool { - switch r { - case RuleDeleteResponseMatchersTypeLiteral: - return true - } - return false +func (r ActionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type RuleGetResponse struct { +type EmailRoutingRule struct { // Routing rule identifier. ID string `json:"id"` // List actions patterns. - Actions []RuleGetResponseAction `json:"actions"` + Actions []Action `json:"actions"` // Routing rule status. - Enabled RuleGetResponseEnabled `json:"enabled"` + Enabled EmailRoutingRuleEnabled `json:"enabled"` // Matching patterns to forward to your actions. - Matchers []RuleGetResponseMatcher `json:"matchers"` + Matchers []Matcher `json:"matchers"` // Routing rule name. Name string `json:"name"` // Priority of the routing rule. Priority float64 `json:"priority"` // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleGetResponseJSON `json:"-"` + Tag string `json:"tag"` + JSON emailRoutingRuleJSON `json:"-"` } -// ruleGetResponseJSON contains the JSON metadata for the struct [RuleGetResponse] -type ruleGetResponseJSON struct { +// emailRoutingRuleJSON contains the JSON metadata for the struct +// [EmailRoutingRule] +type emailRoutingRuleJSON struct { ID apijson.Field Actions apijson.Field Enabled apijson.Field @@ -770,86 +197,43 @@ type ruleGetResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RuleGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type RuleGetResponseAction struct { - // Type of supported action. - Type RuleGetResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleGetResponseActionJSON `json:"-"` -} - -// ruleGetResponseActionJSON contains the JSON metadata for the struct -// [RuleGetResponseAction] -type ruleGetResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseAction) UnmarshalJSON(data []byte) (err error) { +func (r *EmailRoutingRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleGetResponseActionJSON) RawJSON() string { +func (r emailRoutingRuleJSON) RawJSON() string { return r.raw } -// Type of supported action. -type RuleGetResponseActionsType string - -const ( - RuleGetResponseActionsTypeDrop RuleGetResponseActionsType = "drop" - RuleGetResponseActionsTypeForward RuleGetResponseActionsType = "forward" - RuleGetResponseActionsTypeWorker RuleGetResponseActionsType = "worker" -) - -func (r RuleGetResponseActionsType) IsKnown() bool { - switch r { - case RuleGetResponseActionsTypeDrop, RuleGetResponseActionsTypeForward, RuleGetResponseActionsTypeWorker: - return true - } - return false -} - // Routing rule status. -type RuleGetResponseEnabled bool +type EmailRoutingRuleEnabled bool const ( - RuleGetResponseEnabledTrue RuleGetResponseEnabled = true - RuleGetResponseEnabledFalse RuleGetResponseEnabled = false + EmailRoutingRuleEnabledTrue EmailRoutingRuleEnabled = true + EmailRoutingRuleEnabledFalse EmailRoutingRuleEnabled = false ) -func (r RuleGetResponseEnabled) IsKnown() bool { +func (r EmailRoutingRuleEnabled) IsKnown() bool { switch r { - case RuleGetResponseEnabledTrue, RuleGetResponseEnabledFalse: + case EmailRoutingRuleEnabledTrue, EmailRoutingRuleEnabledFalse: return true } return false } // Matching pattern to forward your actions. -type RuleGetResponseMatcher struct { +type Matcher struct { // Field for type matcher. - Field RuleGetResponseMatchersField `json:"field,required"` + Field MatcherField `json:"field,required"` // Type of matcher. - Type RuleGetResponseMatchersType `json:"type,required"` + Type MatcherType `json:"type,required"` // Value for matcher. - Value string `json:"value,required"` - JSON ruleGetResponseMatcherJSON `json:"-"` + Value string `json:"value,required"` + JSON matcherJSON `json:"-"` } -// ruleGetResponseMatcherJSON contains the JSON metadata for the struct -// [RuleGetResponseMatcher] -type ruleGetResponseMatcherJSON struct { +// matcherJSON contains the JSON metadata for the struct [Matcher] +type matcherJSON struct { Field apijson.Field Type apijson.Field Value apijson.Field @@ -857,49 +241,63 @@ type ruleGetResponseMatcherJSON struct { ExtraFields map[string]apijson.Field } -func (r *RuleGetResponseMatcher) UnmarshalJSON(data []byte) (err error) { +func (r *Matcher) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleGetResponseMatcherJSON) RawJSON() string { +func (r matcherJSON) RawJSON() string { return r.raw } // Field for type matcher. -type RuleGetResponseMatchersField string +type MatcherField string const ( - RuleGetResponseMatchersFieldTo RuleGetResponseMatchersField = "to" + MatcherFieldTo MatcherField = "to" ) -func (r RuleGetResponseMatchersField) IsKnown() bool { +func (r MatcherField) IsKnown() bool { switch r { - case RuleGetResponseMatchersFieldTo: + case MatcherFieldTo: return true } return false } // Type of matcher. -type RuleGetResponseMatchersType string +type MatcherType string const ( - RuleGetResponseMatchersTypeLiteral RuleGetResponseMatchersType = "literal" + MatcherTypeLiteral MatcherType = "literal" ) -func (r RuleGetResponseMatchersType) IsKnown() bool { +func (r MatcherType) IsKnown() bool { switch r { - case RuleGetResponseMatchersTypeLiteral: + case MatcherTypeLiteral: return true } return false } +// Matching pattern to forward your actions. +type MatcherParam struct { + // Field for type matcher. + Field param.Field[MatcherField] `json:"field,required"` + // Type of matcher. + Type param.Field[MatcherType] `json:"type,required"` + // Value for matcher. + Value param.Field[string] `json:"value,required"` +} + +func (r MatcherParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type RuleNewParams struct { // List actions patterns. - Actions param.Field[[]RuleNewParamsAction] `json:"actions,required"` + Actions param.Field[[]ActionParam] `json:"actions,required"` // Matching patterns to forward to your actions. - Matchers param.Field[[]RuleNewParamsMatcher] `json:"matchers,required"` + Matchers param.Field[[]MatcherParam] `json:"matchers,required"` // Routing rule status. Enabled param.Field[RuleNewParamsEnabled] `json:"enabled"` // Routing rule name. @@ -912,78 +310,6 @@ func (r RuleNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Actions pattern. -type RuleNewParamsAction struct { - // Type of supported action. - Type param.Field[RuleNewParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value,required"` -} - -func (r RuleNewParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of supported action. -type RuleNewParamsActionsType string - -const ( - RuleNewParamsActionsTypeDrop RuleNewParamsActionsType = "drop" - RuleNewParamsActionsTypeForward RuleNewParamsActionsType = "forward" - RuleNewParamsActionsTypeWorker RuleNewParamsActionsType = "worker" -) - -func (r RuleNewParamsActionsType) IsKnown() bool { - switch r { - case RuleNewParamsActionsTypeDrop, RuleNewParamsActionsTypeForward, RuleNewParamsActionsTypeWorker: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleNewParamsMatcher struct { - // Field for type matcher. - Field param.Field[RuleNewParamsMatchersField] `json:"field,required"` - // Type of matcher. - Type param.Field[RuleNewParamsMatchersType] `json:"type,required"` - // Value for matcher. - Value param.Field[string] `json:"value,required"` -} - -func (r RuleNewParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Field for type matcher. -type RuleNewParamsMatchersField string - -const ( - RuleNewParamsMatchersFieldTo RuleNewParamsMatchersField = "to" -) - -func (r RuleNewParamsMatchersField) IsKnown() bool { - switch r { - case RuleNewParamsMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleNewParamsMatchersType string - -const ( - RuleNewParamsMatchersTypeLiteral RuleNewParamsMatchersType = "literal" -) - -func (r RuleNewParamsMatchersType) IsKnown() bool { - switch r { - case RuleNewParamsMatchersTypeLiteral: - return true - } - return false -} - // Routing rule status. type RuleNewParamsEnabled bool @@ -1001,9 +327,9 @@ func (r RuleNewParamsEnabled) IsKnown() bool { } type RuleNewResponseEnvelope struct { - Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` - Result RuleNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result EmailRoutingRule `json:"result,required"` // Whether the API call was successful Success RuleNewResponseEnvelopeSuccess `json:"success,required"` JSON ruleNewResponseEnvelopeJSON `json:"-"` @@ -1028,52 +354,6 @@ func (r ruleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeErrors] -type ruleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeMessages] -type ruleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleNewResponseEnvelopeSuccess bool @@ -1091,9 +371,9 @@ func (r RuleNewResponseEnvelopeSuccess) IsKnown() bool { type RuleUpdateParams struct { // List actions patterns. - Actions param.Field[[]RuleUpdateParamsAction] `json:"actions,required"` + Actions param.Field[[]ActionParam] `json:"actions,required"` // Matching patterns to forward to your actions. - Matchers param.Field[[]RuleUpdateParamsMatcher] `json:"matchers,required"` + Matchers param.Field[[]MatcherParam] `json:"matchers,required"` // Routing rule status. Enabled param.Field[RuleUpdateParamsEnabled] `json:"enabled"` // Routing rule name. @@ -1106,78 +386,6 @@ func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Actions pattern. -type RuleUpdateParamsAction struct { - // Type of supported action. - Type param.Field[RuleUpdateParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value,required"` -} - -func (r RuleUpdateParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of supported action. -type RuleUpdateParamsActionsType string - -const ( - RuleUpdateParamsActionsTypeDrop RuleUpdateParamsActionsType = "drop" - RuleUpdateParamsActionsTypeForward RuleUpdateParamsActionsType = "forward" - RuleUpdateParamsActionsTypeWorker RuleUpdateParamsActionsType = "worker" -) - -func (r RuleUpdateParamsActionsType) IsKnown() bool { - switch r { - case RuleUpdateParamsActionsTypeDrop, RuleUpdateParamsActionsTypeForward, RuleUpdateParamsActionsTypeWorker: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleUpdateParamsMatcher struct { - // Field for type matcher. - Field param.Field[RuleUpdateParamsMatchersField] `json:"field,required"` - // Type of matcher. - Type param.Field[RuleUpdateParamsMatchersType] `json:"type,required"` - // Value for matcher. - Value param.Field[string] `json:"value,required"` -} - -func (r RuleUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Field for type matcher. -type RuleUpdateParamsMatchersField string - -const ( - RuleUpdateParamsMatchersFieldTo RuleUpdateParamsMatchersField = "to" -) - -func (r RuleUpdateParamsMatchersField) IsKnown() bool { - switch r { - case RuleUpdateParamsMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleUpdateParamsMatchersType string - -const ( - RuleUpdateParamsMatchersTypeLiteral RuleUpdateParamsMatchersType = "literal" -) - -func (r RuleUpdateParamsMatchersType) IsKnown() bool { - switch r { - case RuleUpdateParamsMatchersTypeLiteral: - return true - } - return false -} - // Routing rule status. type RuleUpdateParamsEnabled bool @@ -1195,9 +403,9 @@ func (r RuleUpdateParamsEnabled) IsKnown() bool { } type RuleUpdateResponseEnvelope struct { - Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result RuleUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result EmailRoutingRule `json:"result,required"` // Whether the API call was successful Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` JSON ruleUpdateResponseEnvelopeJSON `json:"-"` @@ -1222,52 +430,6 @@ func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeErrors] -type ruleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeMessages] -type ruleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleUpdateResponseEnvelopeSuccess bool @@ -1295,7 +457,7 @@ type RuleListParams struct { // URLQuery serializes [RuleListParams]'s query parameters as `url.Values`. func (r RuleListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1317,9 +479,9 @@ func (r RuleListParamsEnabled) IsKnown() bool { } type RuleDeleteResponseEnvelope struct { - Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result RuleDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result EmailRoutingRule `json:"result,required"` // Whether the API call was successful Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON ruleDeleteResponseEnvelopeJSON `json:"-"` @@ -1344,52 +506,6 @@ func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeErrors] -type ruleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeMessages] -type ruleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleDeleteResponseEnvelopeSuccess bool @@ -1406,9 +522,9 @@ func (r RuleDeleteResponseEnvelopeSuccess) IsKnown() bool { } type RuleGetResponseEnvelope struct { - Errors []RuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleGetResponseEnvelopeMessages `json:"messages,required"` - Result RuleGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result EmailRoutingRule `json:"result,required"` // Whether the API call was successful Success RuleGetResponseEnvelopeSuccess `json:"success,required"` JSON ruleGetResponseEnvelopeJSON `json:"-"` @@ -1433,52 +549,6 @@ func (r ruleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleGetResponseEnvelopeErrors] -type ruleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleGetResponseEnvelopeMessages] -type ruleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleGetResponseEnvelopeSuccess bool diff --git a/email_routing/rule_test.go b/email_routing/rule_test.go index e0c99186cdf..ec41c0dbb95 100644 --- a/email_routing/rule_test.go +++ b/email_routing/rule_test.go @@ -32,27 +32,27 @@ func TestRuleNewWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", email_routing.RuleNewParams{ - Actions: cloudflare.F([]email_routing.RuleNewParamsAction{{ - Type: cloudflare.F(email_routing.RuleNewParamsActionsTypeForward), + Actions: cloudflare.F([]email_routing.ActionParam{{ + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleNewParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleNewParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }}), - Matchers: cloudflare.F([]email_routing.RuleNewParamsMatcher{{ - Field: cloudflare.F(email_routing.RuleNewParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleNewParamsMatchersTypeLiteral), + Matchers: cloudflare.F([]email_routing.MatcherParam{{ + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleNewParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleNewParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleNewParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleNewParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }}), Enabled: cloudflare.F(email_routing.RuleNewParamsEnabledTrue), @@ -88,27 +88,27 @@ func TestRuleUpdateWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "a7e6fb77503c41d8a7f3113c6918f10c", email_routing.RuleUpdateParams{ - Actions: cloudflare.F([]email_routing.RuleUpdateParamsAction{{ - Type: cloudflare.F(email_routing.RuleUpdateParamsActionsTypeForward), + Actions: cloudflare.F([]email_routing.ActionParam{{ + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }}), - Matchers: cloudflare.F([]email_routing.RuleUpdateParamsMatcher{{ - Field: cloudflare.F(email_routing.RuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleUpdateParamsMatchersTypeLiteral), + Matchers: cloudflare.F([]email_routing.MatcherParam{{ + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleUpdateParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleUpdateParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }}), Enabled: cloudflare.F(email_routing.RuleUpdateParamsEnabledTrue), diff --git a/email_routing/rulecatchall.go b/email_routing/rulecatchall.go index c747dfa88bd..e05779bd788 100644 --- a/email_routing/rulecatchall.go +++ b/email_routing/rulecatchall.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewRuleCatchAllService(opts ...option.RequestOption) (r *RuleCatchAllServic // Enable or disable catch-all routing rule, or change action to forward to // specific destination address. -func (r *RuleCatchAllService) Update(ctx context.Context, zoneIdentifier string, body RuleCatchAllUpdateParams, opts ...option.RequestOption) (res *EmailCatchAllRule, err error) { +func (r *RuleCatchAllService) Update(ctx context.Context, zoneIdentifier string, body RuleCatchAllUpdateParams, opts ...option.RequestOption) (res *RuleCatchAllUpdateResponse, err error) { opts = append(r.Options[:], opts...) var env RuleCatchAllUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/catch_all", zoneIdentifier) @@ -46,7 +47,7 @@ func (r *RuleCatchAllService) Update(ctx context.Context, zoneIdentifier string, } // Get information on the default catch-all routing rule. -func (r *RuleCatchAllService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailCatchAllRule, err error) { +func (r *RuleCatchAllService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *RuleCatchAllGetResponse, err error) { opts = append(r.Options[:], opts...) var env RuleCatchAllGetResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/catch_all", zoneIdentifier) @@ -58,207 +59,226 @@ func (r *RuleCatchAllService) Get(ctx context.Context, zoneIdentifier string, op return } -type EmailCatchAllRule struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions for the catch-all routing rule. - Actions []EmailCatchAllRuleAction `json:"actions"` - // Routing rule status. - Enabled EmailCatchAllRuleEnabled `json:"enabled"` - // List of matchers for the catch-all routing rule. - Matchers []EmailCatchAllRuleMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailCatchAllRuleJSON `json:"-"` -} - -// emailCatchAllRuleJSON contains the JSON metadata for the struct -// [EmailCatchAllRule] -type emailCatchAllRuleJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailCatchAllRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailCatchAllRuleJSON) RawJSON() string { - return r.raw -} - // Action for the catch-all routing rule. -type EmailCatchAllRuleAction struct { +type CatchAllAction struct { // Type of action for catch-all rule. - Type EmailCatchAllRuleActionsType `json:"type,required"` - Value []string `json:"value"` - JSON emailCatchAllRuleActionJSON `json:"-"` + Type CatchAllActionType `json:"type,required"` + Value []string `json:"value"` + JSON catchAllActionJSON `json:"-"` } -// emailCatchAllRuleActionJSON contains the JSON metadata for the struct -// [EmailCatchAllRuleAction] -type emailCatchAllRuleActionJSON struct { +// catchAllActionJSON contains the JSON metadata for the struct [CatchAllAction] +type catchAllActionJSON struct { Type apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *EmailCatchAllRuleAction) UnmarshalJSON(data []byte) (err error) { +func (r *CatchAllAction) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r emailCatchAllRuleActionJSON) RawJSON() string { +func (r catchAllActionJSON) RawJSON() string { return r.raw } // Type of action for catch-all rule. -type EmailCatchAllRuleActionsType string +type CatchAllActionType string const ( - EmailCatchAllRuleActionsTypeDrop EmailCatchAllRuleActionsType = "drop" - EmailCatchAllRuleActionsTypeForward EmailCatchAllRuleActionsType = "forward" - EmailCatchAllRuleActionsTypeWorker EmailCatchAllRuleActionsType = "worker" + CatchAllActionTypeDrop CatchAllActionType = "drop" + CatchAllActionTypeForward CatchAllActionType = "forward" + CatchAllActionTypeWorker CatchAllActionType = "worker" ) -func (r EmailCatchAllRuleActionsType) IsKnown() bool { +func (r CatchAllActionType) IsKnown() bool { switch r { - case EmailCatchAllRuleActionsTypeDrop, EmailCatchAllRuleActionsTypeForward, EmailCatchAllRuleActionsTypeWorker: + case CatchAllActionTypeDrop, CatchAllActionTypeForward, CatchAllActionTypeWorker: return true } return false } -// Routing rule status. -type EmailCatchAllRuleEnabled bool - -const ( - EmailCatchAllRuleEnabledTrue EmailCatchAllRuleEnabled = true - EmailCatchAllRuleEnabledFalse EmailCatchAllRuleEnabled = false -) +// Action for the catch-all routing rule. +type CatchAllActionParam struct { + // Type of action for catch-all rule. + Type param.Field[CatchAllActionType] `json:"type,required"` + Value param.Field[[]string] `json:"value"` +} -func (r EmailCatchAllRuleEnabled) IsKnown() bool { - switch r { - case EmailCatchAllRuleEnabledTrue, EmailCatchAllRuleEnabledFalse: - return true - } - return false +func (r CatchAllActionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Matcher for catch-all routing rule. -type EmailCatchAllRuleMatcher struct { +type CatchAllMatcher struct { // Type of matcher. Default is 'all'. - Type EmailCatchAllRuleMatchersType `json:"type,required"` - JSON emailCatchAllRuleMatcherJSON `json:"-"` + Type CatchAllMatcherType `json:"type,required"` + JSON catchAllMatcherJSON `json:"-"` } -// emailCatchAllRuleMatcherJSON contains the JSON metadata for the struct -// [EmailCatchAllRuleMatcher] -type emailCatchAllRuleMatcherJSON struct { +// catchAllMatcherJSON contains the JSON metadata for the struct [CatchAllMatcher] +type catchAllMatcherJSON struct { Type apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *EmailCatchAllRuleMatcher) UnmarshalJSON(data []byte) (err error) { +func (r *CatchAllMatcher) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r emailCatchAllRuleMatcherJSON) RawJSON() string { +func (r catchAllMatcherJSON) RawJSON() string { return r.raw } // Type of matcher. Default is 'all'. -type EmailCatchAllRuleMatchersType string +type CatchAllMatcherType string const ( - EmailCatchAllRuleMatchersTypeAll EmailCatchAllRuleMatchersType = "all" + CatchAllMatcherTypeAll CatchAllMatcherType = "all" ) -func (r EmailCatchAllRuleMatchersType) IsKnown() bool { +func (r CatchAllMatcherType) IsKnown() bool { switch r { - case EmailCatchAllRuleMatchersTypeAll: + case CatchAllMatcherTypeAll: return true } return false } -type RuleCatchAllUpdateParams struct { +// Matcher for catch-all routing rule. +type CatchAllMatcherParam struct { + // Type of matcher. Default is 'all'. + Type param.Field[CatchAllMatcherType] `json:"type,required"` +} + +func (r CatchAllMatcherParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleCatchAllUpdateResponse struct { + // Routing rule identifier. + ID string `json:"id"` // List actions for the catch-all routing rule. - Actions param.Field[[]RuleCatchAllUpdateParamsAction] `json:"actions,required"` - // List of matchers for the catch-all routing rule. - Matchers param.Field[[]RuleCatchAllUpdateParamsMatcher] `json:"matchers,required"` + Actions []CatchAllAction `json:"actions"` // Routing rule status. - Enabled param.Field[RuleCatchAllUpdateParamsEnabled] `json:"enabled"` + Enabled RuleCatchAllUpdateResponseEnabled `json:"enabled"` + // List of matchers for the catch-all routing rule. + Matchers []CatchAllMatcher `json:"matchers"` // Routing rule name. - Name param.Field[string] `json:"name"` + Name string `json:"name"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON ruleCatchAllUpdateResponseJSON `json:"-"` } -func (r RuleCatchAllUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// ruleCatchAllUpdateResponseJSON contains the JSON metadata for the struct +// [RuleCatchAllUpdateResponse] +type ruleCatchAllUpdateResponseJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Action for the catch-all routing rule. -type RuleCatchAllUpdateParamsAction struct { - // Type of action for catch-all rule. - Type param.Field[RuleCatchAllUpdateParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value"` +func (r *RuleCatchAllUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r RuleCatchAllUpdateParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r ruleCatchAllUpdateResponseJSON) RawJSON() string { + return r.raw } -// Type of action for catch-all rule. -type RuleCatchAllUpdateParamsActionsType string +// Routing rule status. +type RuleCatchAllUpdateResponseEnabled bool const ( - RuleCatchAllUpdateParamsActionsTypeDrop RuleCatchAllUpdateParamsActionsType = "drop" - RuleCatchAllUpdateParamsActionsTypeForward RuleCatchAllUpdateParamsActionsType = "forward" - RuleCatchAllUpdateParamsActionsTypeWorker RuleCatchAllUpdateParamsActionsType = "worker" + RuleCatchAllUpdateResponseEnabledTrue RuleCatchAllUpdateResponseEnabled = true + RuleCatchAllUpdateResponseEnabledFalse RuleCatchAllUpdateResponseEnabled = false ) -func (r RuleCatchAllUpdateParamsActionsType) IsKnown() bool { +func (r RuleCatchAllUpdateResponseEnabled) IsKnown() bool { switch r { - case RuleCatchAllUpdateParamsActionsTypeDrop, RuleCatchAllUpdateParamsActionsTypeForward, RuleCatchAllUpdateParamsActionsTypeWorker: + case RuleCatchAllUpdateResponseEnabledTrue, RuleCatchAllUpdateResponseEnabledFalse: return true } return false } -// Matcher for catch-all routing rule. -type RuleCatchAllUpdateParamsMatcher struct { - // Type of matcher. Default is 'all'. - Type param.Field[RuleCatchAllUpdateParamsMatchersType] `json:"type,required"` +type RuleCatchAllGetResponse struct { + // Routing rule identifier. + ID string `json:"id"` + // List actions for the catch-all routing rule. + Actions []CatchAllAction `json:"actions"` + // Routing rule status. + Enabled RuleCatchAllGetResponseEnabled `json:"enabled"` + // List of matchers for the catch-all routing rule. + Matchers []CatchAllMatcher `json:"matchers"` + // Routing rule name. + Name string `json:"name"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON ruleCatchAllGetResponseJSON `json:"-"` } -func (r RuleCatchAllUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// ruleCatchAllGetResponseJSON contains the JSON metadata for the struct +// [RuleCatchAllGetResponse] +type ruleCatchAllGetResponseJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Type of matcher. Default is 'all'. -type RuleCatchAllUpdateParamsMatchersType string +func (r *RuleCatchAllGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleCatchAllGetResponseJSON) RawJSON() string { + return r.raw +} + +// Routing rule status. +type RuleCatchAllGetResponseEnabled bool const ( - RuleCatchAllUpdateParamsMatchersTypeAll RuleCatchAllUpdateParamsMatchersType = "all" + RuleCatchAllGetResponseEnabledTrue RuleCatchAllGetResponseEnabled = true + RuleCatchAllGetResponseEnabledFalse RuleCatchAllGetResponseEnabled = false ) -func (r RuleCatchAllUpdateParamsMatchersType) IsKnown() bool { +func (r RuleCatchAllGetResponseEnabled) IsKnown() bool { switch r { - case RuleCatchAllUpdateParamsMatchersTypeAll: + case RuleCatchAllGetResponseEnabledTrue, RuleCatchAllGetResponseEnabledFalse: return true } return false } +type RuleCatchAllUpdateParams struct { + // List actions for the catch-all routing rule. + Actions param.Field[[]CatchAllActionParam] `json:"actions,required"` + // List of matchers for the catch-all routing rule. + Matchers param.Field[[]CatchAllMatcherParam] `json:"matchers,required"` + // Routing rule status. + Enabled param.Field[RuleCatchAllUpdateParamsEnabled] `json:"enabled"` + // Routing rule name. + Name param.Field[string] `json:"name"` +} + +func (r RuleCatchAllUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Routing rule status. type RuleCatchAllUpdateParamsEnabled bool @@ -276,9 +296,9 @@ func (r RuleCatchAllUpdateParamsEnabled) IsKnown() bool { } type RuleCatchAllUpdateResponseEnvelope struct { - Errors []RuleCatchAllUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleCatchAllUpdateResponseEnvelopeMessages `json:"messages,required"` - Result EmailCatchAllRule `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RuleCatchAllUpdateResponse `json:"result,required"` // Whether the API call was successful Success RuleCatchAllUpdateResponseEnvelopeSuccess `json:"success,required"` JSON ruleCatchAllUpdateResponseEnvelopeJSON `json:"-"` @@ -303,52 +323,6 @@ func (r ruleCatchAllUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleCatchAllUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleCatchAllUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleCatchAllUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RuleCatchAllUpdateResponseEnvelopeErrors] -type ruleCatchAllUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleCatchAllUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleCatchAllUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleCatchAllUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleCatchAllUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleCatchAllUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RuleCatchAllUpdateResponseEnvelopeMessages] -type ruleCatchAllUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleCatchAllUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleCatchAllUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleCatchAllUpdateResponseEnvelopeSuccess bool @@ -365,9 +339,9 @@ func (r RuleCatchAllUpdateResponseEnvelopeSuccess) IsKnown() bool { } type RuleCatchAllGetResponseEnvelope struct { - Errors []RuleCatchAllGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleCatchAllGetResponseEnvelopeMessages `json:"messages,required"` - Result EmailCatchAllRule `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RuleCatchAllGetResponse `json:"result,required"` // Whether the API call was successful Success RuleCatchAllGetResponseEnvelopeSuccess `json:"success,required"` JSON ruleCatchAllGetResponseEnvelopeJSON `json:"-"` @@ -392,52 +366,6 @@ func (r ruleCatchAllGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleCatchAllGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleCatchAllGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleCatchAllGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RuleCatchAllGetResponseEnvelopeErrors] -type ruleCatchAllGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleCatchAllGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleCatchAllGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleCatchAllGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleCatchAllGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleCatchAllGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RuleCatchAllGetResponseEnvelopeMessages] -type ruleCatchAllGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleCatchAllGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleCatchAllGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleCatchAllGetResponseEnvelopeSuccess bool diff --git a/email_routing/rulecatchall_test.go b/email_routing/rulecatchall_test.go index 12a6fa61cd9..fc47c1c6205 100644 --- a/email_routing/rulecatchall_test.go +++ b/email_routing/rulecatchall_test.go @@ -32,22 +32,22 @@ func TestRuleCatchAllUpdateWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", email_routing.RuleCatchAllUpdateParams{ - Actions: cloudflare.F([]email_routing.RuleCatchAllUpdateParamsAction{{ - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsActionsTypeForward), + Actions: cloudflare.F([]email_routing.CatchAllActionParam{{ + Type: cloudflare.F(email_routing.CatchAllActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.CatchAllActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.CatchAllActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }}), - Matchers: cloudflare.F([]email_routing.RuleCatchAllUpdateParamsMatcher{{ - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsMatchersTypeAll), + Matchers: cloudflare.F([]email_routing.CatchAllMatcherParam{{ + Type: cloudflare.F(email_routing.CatchAllMatcherTypeAll), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsMatchersTypeAll), + Type: cloudflare.F(email_routing.CatchAllMatcherTypeAll), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsMatchersTypeAll), + Type: cloudflare.F(email_routing.CatchAllMatcherTypeAll), }}), Enabled: cloudflare.F(email_routing.RuleCatchAllUpdateParamsEnabledTrue), Name: cloudflare.F("Send to user@example.net rule."), diff --git a/filters/aliases.go b/filters/aliases.go index ffa58551041..31f5a60f7b6 100644 --- a/filters/aliases.go +++ b/filters/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/filters/filter.go b/filters/filter.go index 93f0aaa964a..8ed53f1a813 100644 --- a/filters/filter.go +++ b/filters/filter.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -85,7 +86,7 @@ func (r *FilterService) ListAutoPaging(ctx context.Context, zoneIdentifier strin } // Deletes an existing filter. -func (r *FilterService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallFilter, err error) { +func (r *FilterService) Delete(ctx context.Context, zoneIdentifier string, id string, body FilterDeleteParams, opts ...option.RequestOption) (res *FirewallFilter, err error) { opts = append(r.Options[:], opts...) var env FilterDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/filters/%s", zoneIdentifier, id) @@ -144,10 +145,10 @@ func (r firewallFilterJSON) RawJSON() string { return r.raw } -func (r FirewallFilter) implementsFirewallFirewallFilterRuleFilter() {} +func (r FirewallFilter) implementsFirewallFirewallRuleFilter() {} type FilterNewParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r FilterNewParams) MarshalJSON() (data []byte, err error) { @@ -155,9 +156,9 @@ func (r FilterNewParams) MarshalJSON() (data []byte, err error) { } type FilterNewResponseEnvelope struct { - Errors []FilterNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterNewResponseEnvelopeMessages `json:"messages,required"` - Result []FirewallFilter `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []FirewallFilter `json:"result,required,nullable"` // Whether the API call was successful Success FilterNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo FilterNewResponseEnvelopeResultInfo `json:"result_info"` @@ -184,52 +185,6 @@ func (r filterNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FilterNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelopeErrors] -type filterNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelopeMessages] -type filterNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FilterNewResponseEnvelopeSuccess bool @@ -277,7 +232,7 @@ func (r filterNewResponseEnvelopeResultInfoJSON) RawJSON() string { } type FilterUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r FilterUpdateParams) MarshalJSON() (data []byte, err error) { @@ -285,9 +240,9 @@ func (r FilterUpdateParams) MarshalJSON() (data []byte, err error) { } type FilterUpdateResponseEnvelope struct { - Errors []FilterUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FirewallFilter `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FirewallFilter `json:"result,required"` // Whether the API call was successful Success FilterUpdateResponseEnvelopeSuccess `json:"success,required"` JSON filterUpdateResponseEnvelopeJSON `json:"-"` @@ -312,52 +267,6 @@ func (r filterUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FilterUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterUpdateResponseEnvelopeErrors] -type filterUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FilterUpdateResponseEnvelopeMessages] -type filterUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FilterUpdateResponseEnvelopeSuccess bool @@ -374,6 +283,8 @@ func (r FilterUpdateResponseEnvelopeSuccess) IsKnown() bool { } type FilterListParams struct { + // The unique identifier of the filter. + ID param.Field[string] `query:"id"` // A case-insensitive string to find in the description. Description param.Field[string] `query:"description"` // A case-insensitive string to find in the expression. @@ -391,15 +302,23 @@ type FilterListParams struct { // URLQuery serializes [FilterListParams]'s query parameters as `url.Values`. func (r FilterListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } +type FilterDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r FilterDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type FilterDeleteResponseEnvelope struct { - Errors []FilterDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FirewallFilter `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FirewallFilter `json:"result,required"` // Whether the API call was successful Success FilterDeleteResponseEnvelopeSuccess `json:"success,required"` JSON filterDeleteResponseEnvelopeJSON `json:"-"` @@ -424,52 +343,6 @@ func (r filterDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FilterDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterDeleteResponseEnvelopeErrors] -type filterDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FilterDeleteResponseEnvelopeMessages] -type filterDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FilterDeleteResponseEnvelopeSuccess bool @@ -486,9 +359,9 @@ func (r FilterDeleteResponseEnvelopeSuccess) IsKnown() bool { } type FilterGetResponseEnvelope struct { - Errors []FilterGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallFilter `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FirewallFilter `json:"result,required"` // Whether the API call was successful Success FilterGetResponseEnvelopeSuccess `json:"success,required"` JSON filterGetResponseEnvelopeJSON `json:"-"` @@ -513,52 +386,6 @@ func (r filterGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type FilterGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterGetResponseEnvelopeErrors] -type filterGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [FilterGetResponseEnvelopeMessages] -type filterGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type FilterGetResponseEnvelopeSuccess bool diff --git a/filters/filter_test.go b/filters/filter_test.go index 9eb85a1d19c..f39799c8455 100644 --- a/filters/filter_test.go +++ b/filters/filter_test.go @@ -32,7 +32,7 @@ func TestFilterNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", filters.FilterNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -63,7 +63,7 @@ func TestFilterUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b61", filters.FilterUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -93,6 +93,7 @@ func TestFilterListWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", filters.FilterListParams{ + ID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b61"), Description: cloudflare.F("browsers"), Expression: cloudflare.F("php"), Page: cloudflare.F(1.000000), @@ -128,6 +129,9 @@ func TestFilterDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b61", + filters.FilterDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/firewall/accessrule.go b/firewall/accessrule.go index f893a351676..81b293daa86 100644 --- a/firewall/accessrule.go +++ b/firewall/accessrule.go @@ -41,7 +41,7 @@ func NewAccessRuleService(opts ...option.RequestOption) (r *AccessRuleService) { // // Note: To create an IP Access rule that applies to a single zone, refer to the // [IP Access rules for a zone](#ip-access-rules-for-a-zone) endpoints. -func (r *AccessRuleService) New(ctx context.Context, params AccessRuleNewParams, opts ...option.RequestOption) (res *AccessRuleNewResponse, err error) { +func (r *AccessRuleService) New(ctx context.Context, params AccessRuleNewParams, opts ...option.RequestOption) (res *AccessRuleNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessRuleNewResponseEnvelope var accountOrZone string @@ -101,17 +101,17 @@ func (r *AccessRuleService) ListAutoPaging(ctx context.Context, params AccessRul // Deletes an existing IP Access rule defined. // // Note: This operation will affect all zones in the account or zone. -func (r *AccessRuleService) Delete(ctx context.Context, identifier interface{}, body AccessRuleDeleteParams, opts ...option.RequestOption) (res *AccessRuleDeleteResponse, err error) { +func (r *AccessRuleService) Delete(ctx context.Context, identifier interface{}, params AccessRuleDeleteParams, opts ...option.RequestOption) (res *AccessRuleDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env AccessRuleDeleteResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if body.AccountID.Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = body.AccountID + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = body.ZoneID + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/firewall/access_rules/rules/%v", accountOrZone, accountOrZoneID, identifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) @@ -125,7 +125,7 @@ func (r *AccessRuleService) Delete(ctx context.Context, identifier interface{}, // Updates an IP Access rule defined. // // Note: This operation will affect all zones in the account or zone. -func (r *AccessRuleService) Edit(ctx context.Context, identifier interface{}, params AccessRuleEditParams, opts ...option.RequestOption) (res *AccessRuleEditResponse, err error) { +func (r *AccessRuleService) Edit(ctx context.Context, identifier interface{}, params AccessRuleEditParams, opts ...option.RequestOption) (res *AccessRuleEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessRuleEditResponseEnvelope var accountOrZone string @@ -147,7 +147,7 @@ func (r *AccessRuleService) Edit(ctx context.Context, identifier interface{}, pa } // Fetches the details of an IP Access rule defined. -func (r *AccessRuleService) Get(ctx context.Context, identifier interface{}, query AccessRuleGetParams, opts ...option.RequestOption) (res *AccessRuleGetResponse, err error) { +func (r *AccessRuleService) Get(ctx context.Context, identifier interface{}, query AccessRuleGetParams, opts ...option.RequestOption) (res *AccessRuleGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessRuleGetResponseEnvelope var accountOrZone string @@ -168,15 +168,179 @@ func (r *AccessRuleService) Get(ctx context.Context, identifier interface{}, que return } +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) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} + +func (r AccessRuleCIDRConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() { +} + +// The configuration target. You must set the target to `ip_range` when specifying +// an IP address range in the rule. +type AccessRuleCIDRConfigurationTarget string + +const ( + AccessRuleCIDRConfigurationTargetIPRange AccessRuleCIDRConfigurationTarget = "ip_range" +) + +func (r AccessRuleCIDRConfigurationTarget) IsKnown() bool { + switch r { + case AccessRuleCIDRConfigurationTargetIPRange: + return true + } + 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) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} + +func (r AccessRuleIPConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} + +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the rule. +type AccessRuleIPConfigurationTarget string + +const ( + AccessRuleIPConfigurationTargetIP AccessRuleIPConfigurationTarget = "ip" +) + +func (r AccessRuleIPConfigurationTarget) IsKnown() bool { + switch r { + case AccessRuleIPConfigurationTargetIP: + return true + } + 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) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} + +func (r ASNConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} + +// The configuration target. You must set the target to `asn` when specifying an +// Autonomous System Number (ASN) in the rule. +type ASNConfigurationTarget string + +const ( + ASNConfigurationTargetASN ASNConfigurationTarget = "asn" +) + +func (r ASNConfigurationTarget) IsKnown() bool { + switch r { + case ASNConfigurationTargetASN: + return true + } + 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) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} + +func (r CountryConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} + +// The configuration target. You must set the target to `country` when specifying a +// country code in the rule. +type CountryConfigurationTarget string + +const ( + CountryConfigurationTargetCountry CountryConfigurationTarget = "country" +) + +func (r CountryConfigurationTarget) IsKnown() bool { + switch r { + case CountryConfigurationTargetCountry: + return true + } + 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) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} + +func (r IPV6ConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} + +// The configuration target. You must set the target to `ip6` when specifying an +// IPv6 address in the rule. +type IPV6ConfigurationTarget string + +const ( + IPV6ConfigurationTargetIp6 IPV6ConfigurationTarget = "ip6" +) + +func (r IPV6ConfigurationTarget) IsKnown() bool { + switch r { + case IPV6ConfigurationTargetIp6: + return true + } + return false +} + // Union satisfied by [firewall.AccessRuleNewResponseUnknown] or // [shared.UnionString]. -type AccessRuleNewResponse interface { - ImplementsFirewallAccessRuleNewResponse() +type AccessRuleNewResponseUnion interface { + ImplementsFirewallAccessRuleNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessRuleNewResponse)(nil)).Elem(), + reflect.TypeOf((*AccessRuleNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -211,13 +375,13 @@ func (r accessRuleDeleteResponseJSON) RawJSON() string { // Union satisfied by [firewall.AccessRuleEditResponseUnknown] or // [shared.UnionString]. -type AccessRuleEditResponse interface { - ImplementsFirewallAccessRuleEditResponse() +type AccessRuleEditResponseUnion interface { + ImplementsFirewallAccessRuleEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessRuleEditResponse)(nil)).Elem(), + reflect.TypeOf((*AccessRuleEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -228,13 +392,13 @@ func init() { // Union satisfied by [firewall.AccessRuleGetResponseUnknown] or // [shared.UnionString]. -type AccessRuleGetResponse interface { - ImplementsFirewallAccessRuleGetResponse() +type AccessRuleGetResponseUnion interface { + ImplementsFirewallAccessRuleGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessRuleGetResponse)(nil)).Elem(), + reflect.TypeOf((*AccessRuleGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -245,7 +409,7 @@ func init() { type AccessRuleNewParams struct { // The rule configuration. - Configuration param.Field[AccessRuleNewParamsConfiguration] `json:"configuration,required"` + Configuration param.Field[AccessRuleNewParamsConfigurationUnion] `json:"configuration,required"` // The action to apply to a matched request. Mode param.Field[AccessRuleNewParamsMode] `json:"mode,required"` // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. @@ -261,170 +425,46 @@ func (r AccessRuleNewParams) MarshalJSON() (data []byte, err error) { } // The rule configuration. -// -// Satisfied by -// [firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration], -// [firewall.AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration], -// [firewall.AccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration], -// [firewall.AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration], -// [firewall.AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration]. -type AccessRuleNewParamsConfiguration interface { - implementsFirewallAccessRuleNewParamsConfiguration() -} - -type AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration struct { +type AccessRuleNewParamsConfiguration struct { // The configuration target. You must set the target to `ip` when specifying an IP // address in the rule. - Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` + Target param.Field[AccessRuleNewParamsConfigurationTarget] `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 AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { +func (r AccessRuleNewParamsConfiguration) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { +func (r AccessRuleNewParamsConfiguration) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} + +// The rule configuration. +// +// Satisfied by [firewall.AccessRuleIPConfigurationParam], +// [firewall.IPV6ConfigurationParam], [firewall.AccessRuleCIDRConfigurationParam], +// [firewall.ASNConfigurationParam], [firewall.CountryConfigurationParam], +// [AccessRuleNewParamsConfiguration]. +type AccessRuleNewParamsConfigurationUnion interface { + implementsFirewallAccessRuleNewParamsConfigurationUnion() } // The configuration target. You must set the target to `ip` when specifying an IP // address in the rule. -type AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget string +type AccessRuleNewParamsConfigurationTarget string const ( - AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" + AccessRuleNewParamsConfigurationTargetIP AccessRuleNewParamsConfigurationTarget = "ip" + AccessRuleNewParamsConfigurationTargetIp6 AccessRuleNewParamsConfigurationTarget = "ip6" + AccessRuleNewParamsConfigurationTargetIPRange AccessRuleNewParamsConfigurationTarget = "ip_range" + AccessRuleNewParamsConfigurationTargetASN AccessRuleNewParamsConfigurationTarget = "asn" + AccessRuleNewParamsConfigurationTargetCountry AccessRuleNewParamsConfigurationTarget = "country" ) -func (r AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget) IsKnown() bool { +func (r AccessRuleNewParamsConfigurationTarget) IsKnown() bool { switch r { - case AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP: - return true - } - return false -} - -type AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` - // The IPv6 address to match. - Value param.Field[string] `json:"value"` -} - -func (r AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -func (r AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6: - return true - } - return false -} - -type AccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget] `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 AccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type AccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget string - -const ( - AccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTargetIPRange AccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget = "ip_range" -) - -func (r AccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTargetIPRange: - return true - } - return false -} - -type AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` - // The AS number to match. - Value param.Field[string] `json:"value"` -} - -func (r AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget string - -const ( - AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -func (r AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN: - return true - } - return false -} - -type AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget] `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 AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -func (r AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry: + case AccessRuleNewParamsConfigurationTargetIP, AccessRuleNewParamsConfigurationTargetIp6, AccessRuleNewParamsConfigurationTargetIPRange, AccessRuleNewParamsConfigurationTargetASN, AccessRuleNewParamsConfigurationTargetCountry: return true } return false @@ -437,22 +477,22 @@ const ( AccessRuleNewParamsModeBlock AccessRuleNewParamsMode = "block" AccessRuleNewParamsModeChallenge AccessRuleNewParamsMode = "challenge" AccessRuleNewParamsModeWhitelist AccessRuleNewParamsMode = "whitelist" - AccessRuleNewParamsModeJsChallenge AccessRuleNewParamsMode = "js_challenge" + AccessRuleNewParamsModeJSChallenge AccessRuleNewParamsMode = "js_challenge" AccessRuleNewParamsModeManagedChallenge AccessRuleNewParamsMode = "managed_challenge" ) func (r AccessRuleNewParamsMode) IsKnown() bool { switch r { - case AccessRuleNewParamsModeBlock, AccessRuleNewParamsModeChallenge, AccessRuleNewParamsModeWhitelist, AccessRuleNewParamsModeJsChallenge, AccessRuleNewParamsModeManagedChallenge: + case AccessRuleNewParamsModeBlock, AccessRuleNewParamsModeChallenge, AccessRuleNewParamsModeWhitelist, AccessRuleNewParamsModeJSChallenge, AccessRuleNewParamsModeManagedChallenge: return true } return false } type AccessRuleNewResponseEnvelope struct { - Errors []AccessRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result AccessRuleNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessRuleNewResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessRuleNewResponseEnvelopeSuccess `json:"success,required"` JSON accessRuleNewResponseEnvelopeJSON `json:"-"` @@ -477,52 +517,6 @@ func (r accessRuleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessRuleNewResponseEnvelopeErrors] -type accessRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessRuleNewResponseEnvelopeMessages] -type accessRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessRuleNewResponseEnvelopeSuccess bool @@ -558,7 +552,7 @@ type AccessRuleListParams struct { // URLQuery serializes [AccessRuleListParams]'s query parameters as `url.Values`. func (r AccessRuleListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -587,7 +581,7 @@ type AccessRuleListParamsEgsPagination struct { // `url.Values`. func (r AccessRuleListParamsEgsPagination) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -604,7 +598,7 @@ type AccessRuleListParamsEgsPaginationJson struct { // as `url.Values`. func (r AccessRuleListParamsEgsPaginationJson) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -632,7 +626,7 @@ type AccessRuleListParamsFilters struct { // `url.Values`. func (r AccessRuleListParamsFilters) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -679,13 +673,13 @@ const ( AccessRuleListParamsFiltersModeBlock AccessRuleListParamsFiltersMode = "block" AccessRuleListParamsFiltersModeChallenge AccessRuleListParamsFiltersMode = "challenge" AccessRuleListParamsFiltersModeWhitelist AccessRuleListParamsFiltersMode = "whitelist" - AccessRuleListParamsFiltersModeJsChallenge AccessRuleListParamsFiltersMode = "js_challenge" + AccessRuleListParamsFiltersModeJSChallenge AccessRuleListParamsFiltersMode = "js_challenge" AccessRuleListParamsFiltersModeManagedChallenge AccessRuleListParamsFiltersMode = "managed_challenge" ) func (r AccessRuleListParamsFiltersMode) IsKnown() bool { switch r { - case AccessRuleListParamsFiltersModeBlock, AccessRuleListParamsFiltersModeChallenge, AccessRuleListParamsFiltersModeWhitelist, AccessRuleListParamsFiltersModeJsChallenge, AccessRuleListParamsFiltersModeManagedChallenge: + case AccessRuleListParamsFiltersModeBlock, AccessRuleListParamsFiltersModeChallenge, AccessRuleListParamsFiltersModeWhitelist, AccessRuleListParamsFiltersModeJSChallenge, AccessRuleListParamsFiltersModeManagedChallenge: return true } return false @@ -709,16 +703,21 @@ func (r AccessRuleListParamsOrder) IsKnown() bool { } type AccessRuleDeleteParams struct { + Body interface{} `json:"body,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. ZoneID param.Field[string] `path:"zone_id"` } +func (r AccessRuleDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type AccessRuleDeleteResponseEnvelope struct { - Errors []AccessRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessRuleDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessRuleDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success AccessRuleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessRuleDeleteResponseEnvelopeJSON `json:"-"` @@ -743,52 +742,6 @@ func (r accessRuleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessRuleDeleteResponseEnvelopeErrors] -type accessRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessRuleDeleteResponseEnvelopeMessages] -type accessRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessRuleDeleteResponseEnvelopeSuccess bool @@ -806,7 +759,7 @@ func (r AccessRuleDeleteResponseEnvelopeSuccess) IsKnown() bool { type AccessRuleEditParams struct { // The rule configuration. - Configuration param.Field[AccessRuleEditParamsConfiguration] `json:"configuration,required"` + Configuration param.Field[AccessRuleEditParamsConfigurationUnion] `json:"configuration,required"` // The action to apply to a matched request. Mode param.Field[AccessRuleEditParamsMode] `json:"mode,required"` // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. @@ -822,170 +775,47 @@ func (r AccessRuleEditParams) MarshalJSON() (data []byte, err error) { } // The rule configuration. -// -// Satisfied by -// [firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration], -// [firewall.AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration], -// [firewall.AccessRuleEditParamsConfigurationLegacyJhsCIDRConfiguration], -// [firewall.AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration], -// [firewall.AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration]. -type AccessRuleEditParamsConfiguration interface { - implementsFirewallAccessRuleEditParamsConfiguration() -} - -type AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration struct { +type AccessRuleEditParamsConfiguration struct { // The configuration target. You must set the target to `ip` when specifying an IP // address in the rule. - Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` + Target param.Field[AccessRuleEditParamsConfigurationTarget] `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 AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget string - -const ( - AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTargetIP AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -func (r AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTargetIP: - return true - } - return false -} - -type AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` - // The IPv6 address to match. - Value param.Field[string] `json:"value"` -} - -func (r AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -func (r AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6: - return true - } - return false -} - -type AccessRuleEditParamsConfigurationLegacyJhsCIDRConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsCIDRConfigurationTarget] `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 AccessRuleEditParamsConfigurationLegacyJhsCIDRConfiguration) MarshalJSON() (data []byte, err error) { +func (r AccessRuleEditParamsConfiguration) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessRuleEditParamsConfigurationLegacyJhsCIDRConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type AccessRuleEditParamsConfigurationLegacyJhsCIDRConfigurationTarget string - -const ( - AccessRuleEditParamsConfigurationLegacyJhsCIDRConfigurationTargetIPRange AccessRuleEditParamsConfigurationLegacyJhsCIDRConfigurationTarget = "ip_range" -) - -func (r AccessRuleEditParamsConfigurationLegacyJhsCIDRConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleEditParamsConfigurationLegacyJhsCIDRConfigurationTargetIPRange: - return true - } - return false -} - -type AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` - // The AS number to match. - Value param.Field[string] `json:"value"` -} - -func (r AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r AccessRuleEditParamsConfiguration) implementsFirewallAccessRuleEditParamsConfigurationUnion() { } -func (r AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget string - -const ( - AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTargetASN AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -func (r AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget) IsKnown() bool { - switch r { - case AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTargetASN: - return true - } - return false -} - -type AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget] `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 AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { +// The rule configuration. +// +// Satisfied by [firewall.AccessRuleIPConfigurationParam], +// [firewall.IPV6ConfigurationParam], [firewall.AccessRuleCIDRConfigurationParam], +// [firewall.ASNConfigurationParam], [firewall.CountryConfigurationParam], +// [AccessRuleEditParamsConfiguration]. +type AccessRuleEditParamsConfigurationUnion interface { + implementsFirewallAccessRuleEditParamsConfigurationUnion() } -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget string +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the rule. +type AccessRuleEditParamsConfigurationTarget string const ( - AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTargetCountry AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" + AccessRuleEditParamsConfigurationTargetIP AccessRuleEditParamsConfigurationTarget = "ip" + AccessRuleEditParamsConfigurationTargetIp6 AccessRuleEditParamsConfigurationTarget = "ip6" + AccessRuleEditParamsConfigurationTargetIPRange AccessRuleEditParamsConfigurationTarget = "ip_range" + AccessRuleEditParamsConfigurationTargetASN AccessRuleEditParamsConfigurationTarget = "asn" + AccessRuleEditParamsConfigurationTargetCountry AccessRuleEditParamsConfigurationTarget = "country" ) -func (r AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget) IsKnown() bool { +func (r AccessRuleEditParamsConfigurationTarget) IsKnown() bool { switch r { - case AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTargetCountry: + case AccessRuleEditParamsConfigurationTargetIP, AccessRuleEditParamsConfigurationTargetIp6, AccessRuleEditParamsConfigurationTargetIPRange, AccessRuleEditParamsConfigurationTargetASN, AccessRuleEditParamsConfigurationTargetCountry: return true } return false @@ -998,22 +828,22 @@ const ( AccessRuleEditParamsModeBlock AccessRuleEditParamsMode = "block" AccessRuleEditParamsModeChallenge AccessRuleEditParamsMode = "challenge" AccessRuleEditParamsModeWhitelist AccessRuleEditParamsMode = "whitelist" - AccessRuleEditParamsModeJsChallenge AccessRuleEditParamsMode = "js_challenge" + AccessRuleEditParamsModeJSChallenge AccessRuleEditParamsMode = "js_challenge" AccessRuleEditParamsModeManagedChallenge AccessRuleEditParamsMode = "managed_challenge" ) func (r AccessRuleEditParamsMode) IsKnown() bool { switch r { - case AccessRuleEditParamsModeBlock, AccessRuleEditParamsModeChallenge, AccessRuleEditParamsModeWhitelist, AccessRuleEditParamsModeJsChallenge, AccessRuleEditParamsModeManagedChallenge: + case AccessRuleEditParamsModeBlock, AccessRuleEditParamsModeChallenge, AccessRuleEditParamsModeWhitelist, AccessRuleEditParamsModeJSChallenge, AccessRuleEditParamsModeManagedChallenge: return true } return false } type AccessRuleEditResponseEnvelope struct { - Errors []AccessRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessRuleEditResponseEnvelopeMessages `json:"messages,required"` - Result AccessRuleEditResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessRuleEditResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessRuleEditResponseEnvelopeSuccess `json:"success,required"` JSON accessRuleEditResponseEnvelopeJSON `json:"-"` @@ -1038,52 +868,6 @@ func (r accessRuleEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessRuleEditResponseEnvelopeErrors] -type accessRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessRuleEditResponseEnvelopeMessages] -type accessRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessRuleEditResponseEnvelopeSuccess bool @@ -1107,9 +891,9 @@ type AccessRuleGetParams struct { } type AccessRuleGetResponseEnvelope struct { - Errors []AccessRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result AccessRuleGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessRuleGetResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessRuleGetResponseEnvelopeSuccess `json:"success,required"` JSON accessRuleGetResponseEnvelopeJSON `json:"-"` @@ -1134,52 +918,6 @@ func (r accessRuleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessRuleGetResponseEnvelopeErrors] -type accessRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessRuleGetResponseEnvelopeMessages] -type accessRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessRuleGetResponseEnvelopeSuccess bool diff --git a/firewall/accessrule_test.go b/firewall/accessrule_test.go index 2dba5d481de..102a172c4c0 100644 --- a/firewall/accessrule_test.go +++ b/firewall/accessrule_test.go @@ -29,10 +29,10 @@ func TestAccessRuleNewWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.Firewall.AccessRules.New(context.TODO(), firewall.AccessRuleNewParams{ - Configuration: cloudflare.F[firewall.AccessRuleNewParamsConfiguration](firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration(firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration{ - Target: cloudflare.F(firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP), + Configuration: cloudflare.F[firewall.AccessRuleNewParamsConfigurationUnion](firewall.AccessRuleIPConfigurationParam{ + Target: cloudflare.F(firewall.AccessRuleIPConfigurationTargetIP), Value: cloudflare.F("198.51.100.4"), - })), + }), Mode: cloudflare.F(firewall.AccessRuleNewParamsModeChallenge), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), @@ -109,6 +109,7 @@ func TestAccessRuleDeleteWithOptionalParams(t *testing.T) { context.TODO(), map[string]interface{}{}, firewall.AccessRuleDeleteParams{ + Body: map[string]interface{}{}, AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), }, @@ -140,10 +141,10 @@ func TestAccessRuleEditWithOptionalParams(t *testing.T) { context.TODO(), map[string]interface{}{}, firewall.AccessRuleEditParams{ - Configuration: cloudflare.F[firewall.AccessRuleEditParamsConfiguration](firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration(firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration{ - Target: cloudflare.F(firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTargetIP), + Configuration: cloudflare.F[firewall.AccessRuleEditParamsConfigurationUnion](firewall.AccessRuleIPConfigurationParam{ + Target: cloudflare.F(firewall.AccessRuleIPConfigurationTargetIP), Value: cloudflare.F("198.51.100.4"), - })), + }), Mode: cloudflare.F(firewall.AccessRuleEditParamsModeChallenge), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), diff --git a/firewall/aliases.go b/firewall/aliases.go index 4fbf831e080..16fe507379f 100644 --- a/firewall/aliases.go +++ b/firewall/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/firewall/lockdown.go b/firewall/lockdown.go index fbbe96ac182..4d509127efa 100644 --- a/firewall/lockdown.go +++ b/firewall/lockdown.go @@ -15,6 +15,7 @@ import ( "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" ) @@ -37,7 +38,7 @@ func NewLockdownService(opts ...option.RequestOption) (r *LockdownService) { } // Creates a new Zone Lockdown rule. -func (r *LockdownService) New(ctx context.Context, zoneIdentifier string, body LockdownNewParams, opts ...option.RequestOption) (res *FirewallZoneLockdown, err error) { +func (r *LockdownService) New(ctx context.Context, zoneIdentifier string, body LockdownNewParams, opts ...option.RequestOption) (res *Lockdown, err error) { opts = append(r.Options[:], opts...) var env LockdownNewResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/lockdowns", zoneIdentifier) @@ -50,7 +51,7 @@ func (r *LockdownService) New(ctx context.Context, zoneIdentifier string, body L } // Updates an existing Zone Lockdown rule. -func (r *LockdownService) Update(ctx context.Context, zoneIdentifier string, id string, body LockdownUpdateParams, opts ...option.RequestOption) (res *FirewallZoneLockdown, err error) { +func (r *LockdownService) Update(ctx context.Context, zoneIdentifier string, id string, body LockdownUpdateParams, opts ...option.RequestOption) (res *Lockdown, err error) { opts = append(r.Options[:], opts...) var env LockdownUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) @@ -64,7 +65,7 @@ func (r *LockdownService) Update(ctx context.Context, zoneIdentifier string, id // Fetches Zone Lockdown rules. You can filter the results using several optional // parameters. -func (r *LockdownService) List(ctx context.Context, zoneIdentifier string, query LockdownListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[FirewallZoneLockdown], err error) { +func (r *LockdownService) List(ctx context.Context, zoneIdentifier string, query LockdownListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Lockdown], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -83,12 +84,12 @@ func (r *LockdownService) List(ctx context.Context, zoneIdentifier string, query // Fetches Zone Lockdown rules. You can filter the results using several optional // parameters. -func (r *LockdownService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query LockdownListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[FirewallZoneLockdown] { +func (r *LockdownService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query LockdownListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Lockdown] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) } // Deletes an existing Zone Lockdown rule. -func (r *LockdownService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *LockdownDeleteResponse, err error) { +func (r *LockdownService) Delete(ctx context.Context, zoneIdentifier string, id string, body LockdownDeleteParams, opts ...option.RequestOption) (res *LockdownDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env LockdownDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) @@ -101,7 +102,7 @@ func (r *LockdownService) Delete(ctx context.Context, zoneIdentifier string, id } // Fetches the details of a Zone Lockdown rule. -func (r *LockdownService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallZoneLockdown, err error) { +func (r *LockdownService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *Lockdown, err error) { opts = append(r.Options[:], opts...) var env LockdownGetResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) @@ -113,13 +114,121 @@ func (r *LockdownService) Get(ctx context.Context, zoneIdentifier string, id str return } -type FirewallZoneLockdown struct { +// A list of IP addresses or CIDR ranges that will be allowed to access the URLs +// specified in the Zone Lockdown rule. You can include any number of `ip` or +// `ip_range` configurations. +type Configuration struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the Zone Lockdown rule. + Target ConfigurationTarget `json:"target"` + // The IP address to match. This address will be compared to the IP address of + // incoming requests. + Value string `json:"value"` + JSON configurationJSON `json:"-"` + union ConfigurationUnion +} + +// configurationJSON contains the JSON metadata for the struct [Configuration] +type configurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r configurationJSON) RawJSON() string { + return r.raw +} + +func (r *Configuration) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r Configuration) AsUnion() ConfigurationUnion { + return r.union +} + +// A list of IP addresses or CIDR ranges that will be allowed to access the URLs +// specified in the Zone Lockdown rule. You can include any number of `ip` or +// `ip_range` configurations. +// +// Union satisfied by [firewall.LockdownIPConfiguration] or +// [firewall.LockdownCIDRConfiguration]. +type ConfigurationUnion interface { + implementsFirewallConfiguration() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ConfigurationUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LockdownIPConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LockdownCIDRConfiguration{}), + }, + ) +} + +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the Zone Lockdown rule. +type ConfigurationTarget string + +const ( + ConfigurationTargetIP ConfigurationTarget = "ip" + ConfigurationTargetIPRange ConfigurationTarget = "ip_range" +) + +func (r ConfigurationTarget) IsKnown() bool { + switch r { + case ConfigurationTargetIP, ConfigurationTargetIPRange: + return true + } + return false +} + +// A list of IP addresses or CIDR ranges that will be allowed to access the URLs +// specified in the Zone Lockdown rule. You can include any number of `ip` or +// `ip_range` configurations. +type ConfigurationParam struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the Zone Lockdown rule. + Target param.Field[ConfigurationTarget] `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 ConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ConfigurationParam) implementsFirewallConfigurationUnionParam() {} + +// A list of IP addresses or CIDR ranges that will be allowed to access the URLs +// specified in the Zone Lockdown rule. You can include any number of `ip` or +// `ip_range` configurations. +// +// Satisfied by [firewall.LockdownIPConfigurationParam], +// [firewall.LockdownCIDRConfigurationParam], [ConfigurationParam]. +type ConfigurationUnionParam interface { + implementsFirewallConfigurationUnionParam() +} + +type Lockdown struct { // The unique identifier of the Zone Lockdown rule. ID string `json:"id,required"` // A list of IP addresses or CIDR ranges that will be allowed to access the URLs // specified in the Zone Lockdown rule. You can include any number of `ip` or // `ip_range` configurations. - Configurations FirewallZoneLockdownConfigurations `json:"configurations,required"` + Configurations Configuration `json:"configurations,required"` // The timestamp of when the rule was created. CreatedOn time.Time `json:"created_on,required" format:"date-time"` // An informative summary of the rule. @@ -131,13 +240,12 @@ type FirewallZoneLockdown 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 []string `json:"urls,required"` - JSON firewallZoneLockdownJSON `json:"-"` + URLs []LockdownURL `json:"urls,required"` + JSON lockdownJSON `json:"-"` } -// firewallZoneLockdownJSON contains the JSON metadata for the struct -// [FirewallZoneLockdown] -type firewallZoneLockdownJSON struct { +// lockdownJSON contains the JSON metadata for the struct [Lockdown] +type lockdownJSON struct { ID apijson.Field Configurations apijson.Field CreatedOn apijson.Field @@ -149,133 +257,105 @@ type firewallZoneLockdownJSON struct { ExtraFields map[string]apijson.Field } -func (r *FirewallZoneLockdown) UnmarshalJSON(data []byte) (err error) { +func (r *Lockdown) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r firewallZoneLockdownJSON) RawJSON() string { +func (r lockdownJSON) RawJSON() string { return r.raw } -// A list of IP addresses or CIDR ranges that will be allowed to access the URLs -// specified in the Zone Lockdown rule. You can include any number of `ip` or -// `ip_range` configurations. -// -// Union satisfied by -// [firewall.FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfiguration] or -// [firewall.FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfiguration]. -type FirewallZoneLockdownConfigurations interface { - implementsFirewallFirewallZoneLockdownConfigurations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallZoneLockdownConfigurations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfiguration{}), - }, - ) -} - -type FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the Zone Lockdown rule. - Target FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON firewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON `json:"-"` +type LockdownCIDRConfiguration struct { + // The configuration target. You must set the target to `ip_range` when specifying + // an IP address range in the Zone Lockdown rule. + Target LockdownCIDRConfigurationTarget `json:"target"` + // The IP address range to match. You can only use prefix lengths `/16` and `/24`. + Value string `json:"value"` + JSON lockdownCIDRConfigurationJSON `json:"-"` } -// firewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON contains -// the JSON metadata for the struct -// [FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfiguration] -type firewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON struct { +// lockdownCIDRConfigurationJSON contains the JSON metadata for the struct +// [LockdownCIDRConfiguration] +type lockdownCIDRConfigurationJSON struct { Target apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfiguration) UnmarshalJSON(data []byte) (err error) { +func (r *LockdownCIDRConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r firewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON) RawJSON() string { +func (r lockdownCIDRConfigurationJSON) RawJSON() string { return r.raw } -func (r FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfiguration) implementsFirewallFirewallZoneLockdownConfigurations() { -} +func (r LockdownCIDRConfiguration) implementsFirewallConfiguration() {} -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the Zone Lockdown rule. -type FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationTarget string +// The configuration target. You must set the target to `ip_range` when specifying +// an IP address range in the Zone Lockdown rule. +type LockdownCIDRConfigurationTarget string const ( - FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationTargetIP FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationTarget = "ip" + LockdownCIDRConfigurationTargetIPRange LockdownCIDRConfigurationTarget = "ip_range" ) -func (r FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationTarget) IsKnown() bool { +func (r LockdownCIDRConfigurationTarget) IsKnown() bool { switch r { - case FirewallZoneLockdownConfigurationsLegacyJhsSchemasIPConfigurationTargetIP: + case LockdownCIDRConfigurationTargetIPRange: return true } return false } -type FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the Zone Lockdown rule. - Target FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24`. - Value string `json:"value"` - JSON firewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationJSON `json:"-"` +type LockdownIPConfiguration struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the Zone Lockdown rule. + Target LockdownIPConfigurationTarget `json:"target"` + // The IP address to match. This address will be compared to the IP address of + // incoming requests. + Value string `json:"value"` + JSON lockdownIPConfigurationJSON `json:"-"` } -// firewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationJSON contains -// the JSON metadata for the struct -// [FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfiguration] -type firewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationJSON struct { +// lockdownIPConfigurationJSON contains the JSON metadata for the struct +// [LockdownIPConfiguration] +type lockdownIPConfigurationJSON struct { Target apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfiguration) UnmarshalJSON(data []byte) (err error) { +func (r *LockdownIPConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r firewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationJSON) RawJSON() string { +func (r lockdownIPConfigurationJSON) RawJSON() string { return r.raw } -func (r FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfiguration) implementsFirewallFirewallZoneLockdownConfigurations() { -} +func (r LockdownIPConfiguration) implementsFirewallConfiguration() {} -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the Zone Lockdown rule. -type FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationTarget string +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the Zone Lockdown rule. +type LockdownIPConfigurationTarget string const ( - FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationTargetIPRange FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationTarget = "ip_range" + LockdownIPConfigurationTargetIP LockdownIPConfigurationTarget = "ip" ) -func (r FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationTarget) IsKnown() bool { +func (r LockdownIPConfigurationTarget) IsKnown() bool { switch r { - case FirewallZoneLockdownConfigurationsLegacyJhsSchemasCIDRConfigurationTargetIPRange: + case LockdownIPConfigurationTargetIP: return true } return false } +type LockdownURL = string + type LockdownDeleteResponse struct { // The unique identifier of the Zone Lockdown rule. ID string `json:"id"` @@ -299,7 +379,7 @@ func (r lockdownDeleteResponseJSON) RawJSON() string { } type LockdownNewParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r LockdownNewParams) MarshalJSON() (data []byte, err error) { @@ -307,9 +387,9 @@ func (r LockdownNewParams) MarshalJSON() (data []byte, err error) { } type LockdownNewResponseEnvelope struct { - Errors []LockdownNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LockdownNewResponseEnvelopeMessages `json:"messages,required"` - Result FirewallZoneLockdown `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Lockdown `json:"result,required"` // Whether the API call was successful Success LockdownNewResponseEnvelopeSuccess `json:"success,required"` JSON lockdownNewResponseEnvelopeJSON `json:"-"` @@ -334,52 +414,6 @@ func (r lockdownNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LockdownNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON lockdownNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// lockdownNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [LockdownNewResponseEnvelopeErrors] -type lockdownNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LockdownNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r lockdownNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LockdownNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON lockdownNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// lockdownNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LockdownNewResponseEnvelopeMessages] -type lockdownNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LockdownNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r lockdownNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LockdownNewResponseEnvelopeSuccess bool @@ -396,7 +430,7 @@ func (r LockdownNewResponseEnvelopeSuccess) IsKnown() bool { } type LockdownUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r LockdownUpdateParams) MarshalJSON() (data []byte, err error) { @@ -404,9 +438,9 @@ func (r LockdownUpdateParams) MarshalJSON() (data []byte, err error) { } type LockdownUpdateResponseEnvelope struct { - Errors []LockdownUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LockdownUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FirewallZoneLockdown `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Lockdown `json:"result,required"` // Whether the API call was successful Success LockdownUpdateResponseEnvelopeSuccess `json:"success,required"` JSON lockdownUpdateResponseEnvelopeJSON `json:"-"` @@ -431,52 +465,6 @@ func (r lockdownUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LockdownUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON lockdownUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// lockdownUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LockdownUpdateResponseEnvelopeErrors] -type lockdownUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LockdownUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r lockdownUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LockdownUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON lockdownUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// lockdownUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LockdownUpdateResponseEnvelopeMessages] -type lockdownUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LockdownUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r lockdownUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LockdownUpdateResponseEnvelopeSuccess bool @@ -493,6 +481,8 @@ func (r LockdownUpdateResponseEnvelopeSuccess) IsKnown() bool { } type LockdownListParams struct { + // The timestamp of when the rule was created. + CreatedOn param.Field[time.Time] `query:"created_on" format:"date-time"` // A string to search for in the description of existing rules. Description param.Field[string] `query:"description"` // A string to search for in the description of existing rules. @@ -503,6 +493,8 @@ type LockdownListParams struct { IPRangeSearch param.Field[string] `query:"ip_range_search"` // A single IP address to search for in existing rules. IPSearch param.Field[string] `query:"ip_search"` + // The timestamp of when the rule was last modified. + ModifiedOn param.Field[time.Time] `query:"modified_on" format:"date-time"` // 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 @@ -519,11 +511,19 @@ type LockdownListParams struct { // URLQuery serializes [LockdownListParams]'s query parameters as `url.Values`. func (r LockdownListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } +type LockdownDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r LockdownDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type LockdownDeleteResponseEnvelope struct { Result LockdownDeleteResponse `json:"result"` JSON lockdownDeleteResponseEnvelopeJSON `json:"-"` @@ -546,9 +546,9 @@ func (r lockdownDeleteResponseEnvelopeJSON) RawJSON() string { } type LockdownGetResponseEnvelope struct { - Errors []LockdownGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LockdownGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallZoneLockdown `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Lockdown `json:"result,required"` // Whether the API call was successful Success LockdownGetResponseEnvelopeSuccess `json:"success,required"` JSON lockdownGetResponseEnvelopeJSON `json:"-"` @@ -573,52 +573,6 @@ func (r lockdownGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LockdownGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON lockdownGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// lockdownGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [LockdownGetResponseEnvelopeErrors] -type lockdownGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LockdownGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r lockdownGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LockdownGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON lockdownGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// lockdownGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LockdownGetResponseEnvelopeMessages] -type lockdownGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LockdownGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r lockdownGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LockdownGetResponseEnvelopeSuccess bool diff --git a/firewall/lockdown_test.go b/firewall/lockdown_test.go index bb40b625503..37c38596048 100644 --- a/firewall/lockdown_test.go +++ b/firewall/lockdown_test.go @@ -7,6 +7,7 @@ import ( "errors" "os" "testing" + "time" "github.com/cloudflare/cloudflare-go/v2" "github.com/cloudflare/cloudflare-go/v2/firewall" @@ -32,7 +33,7 @@ func TestLockdownNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", firewall.LockdownNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -63,7 +64,7 @@ func TestLockdownUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", firewall.LockdownUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -93,11 +94,13 @@ func TestLockdownListWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", firewall.LockdownListParams{ + CreatedOn: cloudflare.F(time.Now()), Description: cloudflare.F("endpoints"), DescriptionSearch: cloudflare.F("endpoints"), IP: cloudflare.F("1.2.3.4"), IPRangeSearch: cloudflare.F("1.2.3.0/16"), IPSearch: cloudflare.F("1.2.3.4"), + ModifiedOn: cloudflare.F(time.Now()), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(1.000000), Priority: cloudflare.F(5.000000), @@ -131,6 +134,9 @@ func TestLockdownDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", + firewall.LockdownDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/firewall/rule.go b/firewall/rule.go index bbb20707e5e..5e9e1cd9eac 100644 --- a/firewall/rule.go +++ b/firewall/rule.go @@ -15,7 +15,9 @@ import ( "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/cloudflare/cloudflare-go/v2/rate_limits" "github.com/tidwall/gjson" ) @@ -37,7 +39,7 @@ func NewRuleService(opts ...option.RequestOption) (r *RuleService) { } // Create one or more firewall rules. -func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleNewParams, opts ...option.RequestOption) (res *[]FirewallFilterRule, err error) { +func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleNewParams, opts ...option.RequestOption) (res *[]FirewallRule, err error) { opts = append(r.Options[:], opts...) var env RuleNewResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/rules", zoneIdentifier) @@ -50,7 +52,7 @@ func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleN } // Updates an existing firewall rule. -func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, id string, body RuleUpdateParams, opts ...option.RequestOption) (res *FirewallFilterRule, err error) { +func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, id string, body RuleUpdateParams, opts ...option.RequestOption) (res *FirewallRule, err error) { opts = append(r.Options[:], opts...) var env RuleUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) @@ -64,7 +66,7 @@ func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, id stri // Fetches firewall rules in a zone. You can filter the results using several // optional parameters. -func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[FirewallFilterRule], err error) { +func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query RuleListParams, 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...) @@ -83,12 +85,12 @@ func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query Rul // Fetches firewall rules in a zone. You can filter the results using several // optional parameters. -func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[FirewallFilterRule] { +func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[FirewallRule] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) } // Deletes an existing firewall rule. -func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, id string, body RuleDeleteParams, opts ...option.RequestOption) (res *FirewallFilterRule, err error) { +func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, id string, body RuleDeleteParams, opts ...option.RequestOption) (res *FirewallRule, err error) { opts = append(r.Options[:], opts...) var env RuleDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) @@ -101,7 +103,7 @@ func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, id stri } // Updates the priority of an existing firewall rule. -func (r *RuleService) Edit(ctx context.Context, zoneIdentifier string, id string, body RuleEditParams, opts ...option.RequestOption) (res *[]FirewallFilterRule, err error) { +func (r *RuleService) Edit(ctx context.Context, zoneIdentifier string, id string, body RuleEditParams, opts ...option.RequestOption) (res *[]FirewallRule, err error) { opts = append(r.Options[:], opts...) var env RuleEditResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) @@ -114,11 +116,11 @@ func (r *RuleService) Edit(ctx context.Context, zoneIdentifier string, id string } // Fetches the details of a firewall rule. -func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, id string, query RuleGetParams, opts ...option.RequestOption) (res *FirewallFilterRule, err error) { +func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, params RuleGetParams, opts ...option.RequestOption) (res *FirewallRule, err error) { opts = append(r.Options[:], opts...) var env RuleGetResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, params.PathID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) if err != nil { return } @@ -126,30 +128,29 @@ func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, id string, return } -type FirewallFilterRule struct { +type FirewallRule struct { // The unique identifier of the firewall rule. ID string `json:"id"` // The action to apply to a matched request. The `log` action is only available on // an Enterprise plan. - Action FirewallFilterRuleAction `json:"action"` + Action rate_limits.Action `json:"action"` // An informative summary of the firewall rule. - Description string `json:"description"` - Filter FirewallFilterRuleFilter `json:"filter"` + Description string `json:"description"` + Filter FirewallRuleFilter `json:"filter"` // When true, indicates that the firewall rule is currently paused. Paused bool `json:"paused"` // 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 []FirewallFilterRuleProduct `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 firewallFilterRuleJSON `json:"-"` + Ref string `json:"ref"` + JSON firewallRuleJSON `json:"-"` } -// firewallFilterRuleJSON contains the JSON metadata for the struct -// [FirewallFilterRule] -type firewallFilterRuleJSON struct { +// firewallRuleJSON contains the JSON metadata for the struct [FirewallRule] +type firewallRuleJSON struct { ID apijson.Field Action apijson.Field Description apijson.Field @@ -162,45 +163,69 @@ type firewallFilterRuleJSON struct { ExtraFields map[string]apijson.Field } -func (r *FirewallFilterRule) UnmarshalJSON(data []byte) (err error) { +func (r *FirewallRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r firewallFilterRuleJSON) RawJSON() string { +func (r firewallRuleJSON) RawJSON() string { return r.raw } -// The action to apply to a matched request. The `log` action is only available on -// an Enterprise plan. -type FirewallFilterRuleAction string +type FirewallRuleFilter struct { + // An informative summary of the filter. + Description string `json:"description"` + // The filter expression. For more information, refer to + // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). + Expression string `json:"expression"` + // The unique identifier of the filter. + ID string `json:"id"` + // When true, indicates that the filter is currently paused. + Paused bool `json:"paused"` + // A short reference tag. Allows you to select related filters. + Ref string `json:"ref"` + // When true, indicates that the firewall rule was deleted. + Deleted bool `json:"deleted"` + JSON firewallRuleFilterJSON `json:"-"` + union FirewallRuleFilterUnion +} -const ( - FirewallFilterRuleActionBlock FirewallFilterRuleAction = "block" - FirewallFilterRuleActionChallenge FirewallFilterRuleAction = "challenge" - FirewallFilterRuleActionJsChallenge FirewallFilterRuleAction = "js_challenge" - FirewallFilterRuleActionManagedChallenge FirewallFilterRuleAction = "managed_challenge" - FirewallFilterRuleActionAllow FirewallFilterRuleAction = "allow" - FirewallFilterRuleActionLog FirewallFilterRuleAction = "log" - FirewallFilterRuleActionBypass FirewallFilterRuleAction = "bypass" -) +// firewallRuleFilterJSON contains the JSON metadata for the struct +// [FirewallRuleFilter] +type firewallRuleFilterJSON struct { + Description apijson.Field + Expression apijson.Field + ID apijson.Field + Paused apijson.Field + Ref apijson.Field + Deleted apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -func (r FirewallFilterRuleAction) IsKnown() bool { - switch r { - case FirewallFilterRuleActionBlock, FirewallFilterRuleActionChallenge, FirewallFilterRuleActionJsChallenge, FirewallFilterRuleActionManagedChallenge, FirewallFilterRuleActionAllow, FirewallFilterRuleActionLog, FirewallFilterRuleActionBypass: - return true +func (r firewallRuleFilterJSON) RawJSON() string { + return r.raw +} + +func (r *FirewallRuleFilter) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err } - return false + return apijson.Port(r.union, &r) +} + +func (r FirewallRuleFilter) AsUnion() FirewallRuleFilterUnion { + return r.union } -// Union satisfied by [filters.FirewallFilter] or -// [firewall.FirewallFilterRuleFilterLegacyJhsDeletedFilter]. -type FirewallFilterRuleFilter interface { - implementsFirewallFirewallFilterRuleFilter() +// Union satisfied by [filters.FirewallFilter] or [firewall.DeletedFilter]. +type FirewallRuleFilterUnion interface { + implementsFirewallFirewallRuleFilter() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*FirewallFilterRuleFilter)(nil)).Elem(), + reflect.TypeOf((*FirewallRuleFilterUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -208,62 +233,60 @@ func init() { }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallFilterRuleFilterLegacyJhsDeletedFilter{}), + Type: reflect.TypeOf(DeletedFilter{}), }, ) } -type FirewallFilterRuleFilterLegacyJhsDeletedFilter struct { +// A list of products to bypass for a request when using the `bypass` action. +type Products string + +const ( + ProductsZoneLockdown Products = "zoneLockdown" + ProductsUABlock Products = "uaBlock" + ProductsBic Products = "bic" + ProductsHot Products = "hot" + ProductsSecurityLevel Products = "securityLevel" + ProductsRateLimit Products = "rateLimit" + ProductsWAF Products = "waf" +) + +func (r Products) IsKnown() bool { + switch r { + case ProductsZoneLockdown, ProductsUABlock, ProductsBic, ProductsHot, ProductsSecurityLevel, ProductsRateLimit, ProductsWAF: + return true + } + return false +} + +type DeletedFilter struct { // The unique identifier of the filter. ID string `json:"id,required"` // When true, indicates that the firewall rule was deleted. - Deleted bool `json:"deleted,required"` - JSON firewallFilterRuleFilterLegacyJhsDeletedFilterJSON `json:"-"` + Deleted bool `json:"deleted,required"` + JSON deletedFilterJSON `json:"-"` } -// firewallFilterRuleFilterLegacyJhsDeletedFilterJSON contains the JSON metadata -// for the struct [FirewallFilterRuleFilterLegacyJhsDeletedFilter] -type firewallFilterRuleFilterLegacyJhsDeletedFilterJSON struct { +// deletedFilterJSON contains the JSON metadata for the struct [DeletedFilter] +type deletedFilterJSON struct { ID apijson.Field Deleted apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *FirewallFilterRuleFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { +func (r *DeletedFilter) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r firewallFilterRuleFilterLegacyJhsDeletedFilterJSON) RawJSON() string { +func (r deletedFilterJSON) RawJSON() string { return r.raw } -func (r FirewallFilterRuleFilterLegacyJhsDeletedFilter) implementsFirewallFirewallFilterRuleFilter() { -} - -// A list of products to bypass for a request when using the `bypass` action. -type FirewallFilterRuleProduct string - -const ( - FirewallFilterRuleProductZoneLockdown FirewallFilterRuleProduct = "zoneLockdown" - FirewallFilterRuleProductUABlock FirewallFilterRuleProduct = "uaBlock" - FirewallFilterRuleProductBic FirewallFilterRuleProduct = "bic" - FirewallFilterRuleProductHot FirewallFilterRuleProduct = "hot" - FirewallFilterRuleProductSecurityLevel FirewallFilterRuleProduct = "securityLevel" - FirewallFilterRuleProductRateLimit FirewallFilterRuleProduct = "rateLimit" - FirewallFilterRuleProductWAF FirewallFilterRuleProduct = "waf" -) - -func (r FirewallFilterRuleProduct) IsKnown() bool { - switch r { - case FirewallFilterRuleProductZoneLockdown, FirewallFilterRuleProductUABlock, FirewallFilterRuleProductBic, FirewallFilterRuleProductHot, FirewallFilterRuleProductSecurityLevel, FirewallFilterRuleProductRateLimit, FirewallFilterRuleProductWAF: - return true - } - return false -} +func (r DeletedFilter) implementsFirewallFirewallRuleFilter() {} type RuleNewParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r RuleNewParams) MarshalJSON() (data []byte, err error) { @@ -271,9 +294,9 @@ func (r RuleNewParams) MarshalJSON() (data []byte, err error) { } type RuleNewResponseEnvelope struct { - Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` - Result []FirewallFilterRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []FirewallRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo RuleNewResponseEnvelopeResultInfo `json:"result_info"` @@ -300,52 +323,6 @@ func (r ruleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeErrors] -type ruleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeMessages] -type ruleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleNewResponseEnvelopeSuccess bool @@ -393,7 +370,7 @@ func (r ruleNewResponseEnvelopeResultInfoJSON) RawJSON() string { } type RuleUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { @@ -401,9 +378,9 @@ func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { } type RuleUpdateResponseEnvelope struct { - Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FirewallFilterRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FirewallRule `json:"result,required"` // Whether the API call was successful Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` JSON ruleUpdateResponseEnvelopeJSON `json:"-"` @@ -428,52 +405,6 @@ func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeErrors] -type ruleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeMessages] -type ruleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleUpdateResponseEnvelopeSuccess bool @@ -490,6 +421,8 @@ func (r RuleUpdateResponseEnvelopeSuccess) IsKnown() bool { } type RuleListParams struct { + // The unique identifier of the firewall rule. + ID param.Field[string] `query:"id"` // The action to search for. Must be an exact match. Action param.Field[string] `query:"action"` // A case-insensitive string to find in the description. @@ -505,7 +438,7 @@ type RuleListParams struct { // URLQuery serializes [RuleListParams]'s query parameters as `url.Values`. func (r RuleListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -521,9 +454,9 @@ func (r RuleDeleteParams) MarshalJSON() (data []byte, err error) { } type RuleDeleteResponseEnvelope struct { - Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FirewallFilterRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FirewallRule `json:"result,required"` // Whether the API call was successful Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON ruleDeleteResponseEnvelopeJSON `json:"-"` @@ -548,52 +481,6 @@ func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeErrors] -type ruleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeMessages] -type ruleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleDeleteResponseEnvelopeSuccess bool @@ -610,7 +497,7 @@ func (r RuleDeleteResponseEnvelopeSuccess) IsKnown() bool { } type RuleEditParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r RuleEditParams) MarshalJSON() (data []byte, err error) { @@ -618,9 +505,9 @@ func (r RuleEditParams) MarshalJSON() (data []byte, err error) { } type RuleEditResponseEnvelope struct { - Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` - Result []FirewallFilterRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []FirewallRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleEditResponseEnvelopeSuccess `json:"success,required"` ResultInfo RuleEditResponseEnvelopeResultInfo `json:"result_info"` @@ -647,52 +534,6 @@ func (r ruleEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleEditResponseEnvelopeErrors] -type ruleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleEditResponseEnvelopeMessages] -type ruleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleEditResponseEnvelopeSuccess bool @@ -740,12 +581,24 @@ func (r ruleEditResponseEnvelopeResultInfoJSON) RawJSON() string { } type RuleGetParams struct { + // The unique identifier of the firewall rule. + PathID param.Field[string] `path:"id,required"` + // The unique identifier of the firewall rule. + QueryID param.Field[string] `query:"id"` +} + +// URLQuery serializes [RuleGetParams]'s query parameters as `url.Values`. +func (r RuleGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } type RuleGetResponseEnvelope struct { - Errors []RuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallFilterRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result FirewallRule `json:"result,required"` // Whether the API call was successful Success RuleGetResponseEnvelopeSuccess `json:"success,required"` JSON ruleGetResponseEnvelopeJSON `json:"-"` @@ -770,52 +623,6 @@ func (r ruleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleGetResponseEnvelopeErrors] -type ruleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleGetResponseEnvelopeMessages] -type ruleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleGetResponseEnvelopeSuccess bool diff --git a/firewall/rule_test.go b/firewall/rule_test.go index 48cd914552b..2d99b0534db 100644 --- a/firewall/rule_test.go +++ b/firewall/rule_test.go @@ -32,7 +32,7 @@ func TestRuleNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", firewall.RuleNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -63,7 +63,7 @@ func TestRuleUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b60", firewall.RuleUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -93,6 +93,7 @@ func TestRuleListWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", firewall.RuleListParams{ + ID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b60"), Action: cloudflare.F("block"), Description: cloudflare.F("mir"), Page: cloudflare.F(1.000000), @@ -159,7 +160,7 @@ func TestRuleEdit(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b60", firewall.RuleEditParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -171,7 +172,7 @@ func TestRuleEdit(t *testing.T) { } } -func TestRuleGet(t *testing.T) { +func TestRuleGetWithOptionalParams(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 { @@ -188,8 +189,10 @@ func TestRuleGet(t *testing.T) { _, err := client.Firewall.Rules.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b60", - firewall.RuleGetParams{}, + firewall.RuleGetParams{ + PathID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b60"), + QueryID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b60"), + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/firewall/uarule.go b/firewall/uarule.go index daaf9d78532..bbddbba5b13 100644 --- a/firewall/uarule.go +++ b/firewall/uarule.go @@ -37,7 +37,7 @@ func NewUARuleService(opts ...option.RequestOption) (r *UARuleService) { } // Creates a new User Agent Blocking rule in a zone. -func (r *UARuleService) New(ctx context.Context, zoneIdentifier string, body UARuleNewParams, opts ...option.RequestOption) (res *UARuleNewResponse, err error) { +func (r *UARuleService) New(ctx context.Context, zoneIdentifier string, body UARuleNewParams, opts ...option.RequestOption) (res *UARuleNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env UARuleNewResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/ua_rules", zoneIdentifier) @@ -50,7 +50,7 @@ func (r *UARuleService) New(ctx context.Context, zoneIdentifier string, body UAR } // Updates an existing User Agent Blocking rule. -func (r *UARuleService) Update(ctx context.Context, zoneIdentifier string, id string, body UARuleUpdateParams, opts ...option.RequestOption) (res *UARuleUpdateResponse, err error) { +func (r *UARuleService) Update(ctx context.Context, zoneIdentifier string, id string, body UARuleUpdateParams, opts ...option.RequestOption) (res *UARuleUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env UARuleUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) @@ -88,7 +88,7 @@ func (r *UARuleService) ListAutoPaging(ctx context.Context, zoneIdentifier strin } // Deletes an existing User Agent Blocking rule. -func (r *UARuleService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *UARuleDeleteResponse, err error) { +func (r *UARuleService) Delete(ctx context.Context, zoneIdentifier string, id string, body UARuleDeleteParams, opts ...option.RequestOption) (res *UARuleDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env UARuleDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) @@ -101,7 +101,7 @@ func (r *UARuleService) Delete(ctx context.Context, zoneIdentifier string, id st } // Fetches the details of a User Agent Blocking rule. -func (r *UARuleService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *UARuleGetResponse, err error) { +func (r *UARuleService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *UARuleGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env UARuleGetResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) @@ -114,13 +114,13 @@ func (r *UARuleService) Get(ctx context.Context, zoneIdentifier string, id strin } // Union satisfied by [firewall.UARuleNewResponseUnknown] or [shared.UnionString]. -type UARuleNewResponse interface { - ImplementsFirewallUARuleNewResponse() +type UARuleNewResponseUnion interface { + ImplementsFirewallUARuleNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*UARuleNewResponse)(nil)).Elem(), + reflect.TypeOf((*UARuleNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -131,13 +131,13 @@ func init() { // Union satisfied by [firewall.UARuleUpdateResponseUnknown] or // [shared.UnionString]. -type UARuleUpdateResponse interface { - ImplementsFirewallUARuleUpdateResponse() +type UARuleUpdateResponseUnion interface { + ImplementsFirewallUARuleUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*UARuleUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*UARuleUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -214,13 +214,13 @@ type UARuleListResponseMode string const ( UARuleListResponseModeBlock UARuleListResponseMode = "block" UARuleListResponseModeChallenge UARuleListResponseMode = "challenge" - UARuleListResponseModeJsChallenge UARuleListResponseMode = "js_challenge" + UARuleListResponseModeJSChallenge UARuleListResponseMode = "js_challenge" UARuleListResponseModeManagedChallenge UARuleListResponseMode = "managed_challenge" ) func (r UARuleListResponseMode) IsKnown() bool { switch r { - case UARuleListResponseModeBlock, UARuleListResponseModeChallenge, UARuleListResponseModeJsChallenge, UARuleListResponseModeManagedChallenge: + case UARuleListResponseModeBlock, UARuleListResponseModeChallenge, UARuleListResponseModeJSChallenge, UARuleListResponseModeManagedChallenge: return true } return false @@ -249,13 +249,13 @@ func (r uaRuleDeleteResponseJSON) RawJSON() string { } // Union satisfied by [firewall.UARuleGetResponseUnknown] or [shared.UnionString]. -type UARuleGetResponse interface { - ImplementsFirewallUARuleGetResponse() +type UARuleGetResponseUnion interface { + ImplementsFirewallUARuleGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*UARuleGetResponse)(nil)).Elem(), + reflect.TypeOf((*UARuleGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -265,7 +265,7 @@ func init() { } type UARuleNewParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r UARuleNewParams) MarshalJSON() (data []byte, err error) { @@ -273,9 +273,9 @@ func (r UARuleNewParams) MarshalJSON() (data []byte, err error) { } type UARuleNewResponseEnvelope struct { - Errors []UARuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []UARuleNewResponseEnvelopeMessages `json:"messages,required"` - Result UARuleNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UARuleNewResponseUnion `json:"result,required"` // Whether the API call was successful Success UARuleNewResponseEnvelopeSuccess `json:"success,required"` JSON uaRuleNewResponseEnvelopeJSON `json:"-"` @@ -300,52 +300,6 @@ func (r uaRuleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UARuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// uaRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UARuleNewResponseEnvelopeErrors] -type uaRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UARuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// uaRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [UARuleNewResponseEnvelopeMessages] -type uaRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UARuleNewResponseEnvelopeSuccess bool @@ -362,7 +316,7 @@ func (r UARuleNewResponseEnvelopeSuccess) IsKnown() bool { } type UARuleUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r UARuleUpdateParams) MarshalJSON() (data []byte, err error) { @@ -370,9 +324,9 @@ func (r UARuleUpdateParams) MarshalJSON() (data []byte, err error) { } type UARuleUpdateResponseEnvelope struct { - Errors []UARuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []UARuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result UARuleUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UARuleUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success UARuleUpdateResponseEnvelopeSuccess `json:"success,required"` JSON uaRuleUpdateResponseEnvelopeJSON `json:"-"` @@ -397,52 +351,6 @@ func (r uaRuleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UARuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// uaRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UARuleUpdateResponseEnvelopeErrors] -type uaRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UARuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// uaRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UARuleUpdateResponseEnvelopeMessages] -type uaRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UARuleUpdateResponseEnvelopeSuccess bool @@ -475,15 +383,23 @@ type UARuleListParams struct { // URLQuery serializes [UARuleListParams]'s query parameters as `url.Values`. func (r UARuleListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } +type UARuleDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r UARuleDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type UARuleDeleteResponseEnvelope struct { - Errors []UARuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []UARuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result UARuleDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UARuleDeleteResponse `json:"result,required"` // Whether the API call was successful Success UARuleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON uaRuleDeleteResponseEnvelopeJSON `json:"-"` @@ -508,52 +424,6 @@ func (r uaRuleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UARuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// uaRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UARuleDeleteResponseEnvelopeErrors] -type uaRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UARuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// uaRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UARuleDeleteResponseEnvelopeMessages] -type uaRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UARuleDeleteResponseEnvelopeSuccess bool @@ -570,9 +440,9 @@ func (r UARuleDeleteResponseEnvelopeSuccess) IsKnown() bool { } type UARuleGetResponseEnvelope struct { - Errors []UARuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UARuleGetResponseEnvelopeMessages `json:"messages,required"` - Result UARuleGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UARuleGetResponseUnion `json:"result,required"` // Whether the API call was successful Success UARuleGetResponseEnvelopeSuccess `json:"success,required"` JSON uaRuleGetResponseEnvelopeJSON `json:"-"` @@ -597,52 +467,6 @@ func (r uaRuleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UARuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// uaRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UARuleGetResponseEnvelopeErrors] -type uaRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UARuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON uaRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// uaRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [UARuleGetResponseEnvelopeMessages] -type uaRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UARuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r uaRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UARuleGetResponseEnvelopeSuccess bool diff --git a/firewall/uarule_test.go b/firewall/uarule_test.go index 16b059b119f..909e141d2fc 100644 --- a/firewall/uarule_test.go +++ b/firewall/uarule_test.go @@ -32,7 +32,7 @@ func TestUARuleNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", firewall.UARuleNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -63,7 +63,7 @@ func TestUARuleUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", firewall.UARuleUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -127,6 +127,9 @@ func TestUARuleDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", + firewall.UARuleDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/firewall/wafoverride.go b/firewall/wafoverride.go index 2b757e23a90..d3afc09ecd2 100644 --- a/firewall/wafoverride.go +++ b/firewall/wafoverride.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -38,7 +39,7 @@ func NewWAFOverrideService(opts ...option.RequestOption) (r *WAFOverrideService) // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFOverrideService) New(ctx context.Context, zoneIdentifier string, body WAFOverrideNewParams, opts ...option.RequestOption) (res *WAFOverride, err error) { +func (r *WAFOverrideService) New(ctx context.Context, zoneIdentifier string, body WAFOverrideNewParams, opts ...option.RequestOption) (res *Override, err error) { opts = append(r.Options[:], opts...) var env WAFOverrideNewResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/waf/overrides", zoneIdentifier) @@ -54,7 +55,7 @@ func (r *WAFOverrideService) New(ctx context.Context, zoneIdentifier string, bod // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFOverrideService) Update(ctx context.Context, zoneIdentifier string, id string, body WAFOverrideUpdateParams, opts ...option.RequestOption) (res *WAFOverride, err error) { +func (r *WAFOverrideService) Update(ctx context.Context, zoneIdentifier string, id string, body WAFOverrideUpdateParams, opts ...option.RequestOption) (res *Override, err error) { opts = append(r.Options[:], opts...) var env WAFOverrideUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) @@ -70,7 +71,7 @@ func (r *WAFOverrideService) Update(ctx context.Context, zoneIdentifier string, // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFOverrideService) List(ctx context.Context, zoneIdentifier string, query WAFOverrideListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[WAFOverride], err error) { +func (r *WAFOverrideService) List(ctx context.Context, zoneIdentifier string, query WAFOverrideListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Override], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -91,7 +92,7 @@ func (r *WAFOverrideService) List(ctx context.Context, zoneIdentifier string, qu // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFOverrideService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query WAFOverrideListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WAFOverride] { +func (r *WAFOverrideService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query WAFOverrideListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Override] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) } @@ -99,7 +100,7 @@ func (r *WAFOverrideService) ListAutoPaging(ctx context.Context, zoneIdentifier // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFOverrideService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *WAFOverrideDeleteResponse, err error) { +func (r *WAFOverrideService) Delete(ctx context.Context, zoneIdentifier string, id string, body WAFOverrideDeleteParams, opts ...option.RequestOption) (res *WAFOverrideDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env WAFOverrideDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) @@ -115,7 +116,7 @@ func (r *WAFOverrideService) Delete(ctx context.Context, zoneIdentifier string, // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFOverrideService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *WAFOverride, err error) { +func (r *WAFOverrideService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *Override, err error) { opts = append(r.Options[:], opts...) var env WAFOverrideGetResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) @@ -127,7 +128,7 @@ func (r *WAFOverrideService) Get(ctx context.Context, zoneIdentifier string, id return } -type WAFOverride struct { +type Override struct { // The unique identifier of the WAF override. ID string `json:"id"` // An informative summary of the current URI-based WAF override. @@ -146,22 +147,22 @@ type WAFOverride struct { Priority float64 `json:"priority"` // Specifies that, when a WAF rule matches, its configured action will be replaced // by the action configured in this object. - RewriteAction WAFOverrideRewriteAction `json:"rewrite_action"` + RewriteAction RewriteAction `json:"rewrite_action"` // An object that allows you to override the action of specific WAF rules. Each key // of this object must be the ID of a WAF rule, and each value must be a valid WAF // action. Unless you are disabling a rule, ensure that you also enable the rule // group that this WAF rule belongs to. When creating a new URI-based WAF override, // you must provide a `groups` object or a `rules` object. - Rules map[string]WAFOverrideRule `json:"rules"` + Rules WAFRule `json:"rules"` // The URLs to include in the current WAF override. You can use wildcards. Each // entered URL will be escaped before use, which means you can only use simple // wildcard patterns. - URLs []string `json:"urls"` - JSON wafOverrideJSON `json:"-"` + URLs []OverrideURL `json:"urls"` + JSON overrideJSON `json:"-"` } -// wafOverrideJSON contains the JSON metadata for the struct [WAFOverride] -type wafOverrideJSON struct { +// overrideJSON contains the JSON metadata for the struct [Override] +type overrideJSON struct { ID apijson.Field Description apijson.Field Groups apijson.Field @@ -174,30 +175,31 @@ type wafOverrideJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFOverride) UnmarshalJSON(data []byte) (err error) { +func (r *Override) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafOverrideJSON) RawJSON() string { +func (r overrideJSON) RawJSON() string { return r.raw } +type OverrideURL = string + // Specifies that, when a WAF rule matches, its configured action will be replaced // by the action configured in this object. -type WAFOverrideRewriteAction struct { +type RewriteAction struct { // The WAF rule action to apply. - Block WAFOverrideRewriteActionBlock `json:"block"` - Challenge string `json:"challenge"` - Default string `json:"default"` + Block RewriteActionBlock `json:"block"` + Challenge string `json:"challenge"` + Default string `json:"default"` // The WAF rule action to apply. - Disable WAFOverrideRewriteActionDisable `json:"disable"` - Simulate string `json:"simulate"` - JSON wafOverrideRewriteActionJSON `json:"-"` + Disable RewriteActionDisable `json:"disable"` + Simulate string `json:"simulate"` + JSON rewriteActionJSON `json:"-"` } -// wafOverrideRewriteActionJSON contains the JSON metadata for the struct -// [WAFOverrideRewriteAction] -type wafOverrideRewriteActionJSON struct { +// rewriteActionJSON contains the JSON metadata for the struct [RewriteAction] +type rewriteActionJSON struct { Block apijson.Field Challenge apijson.Field Default apijson.Field @@ -207,66 +209,68 @@ type wafOverrideRewriteActionJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFOverrideRewriteAction) UnmarshalJSON(data []byte) (err error) { +func (r *RewriteAction) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafOverrideRewriteActionJSON) RawJSON() string { +func (r rewriteActionJSON) RawJSON() string { return r.raw } // The WAF rule action to apply. -type WAFOverrideRewriteActionBlock string +type RewriteActionBlock string const ( - WAFOverrideRewriteActionBlockChallenge WAFOverrideRewriteActionBlock = "challenge" - WAFOverrideRewriteActionBlockBlock WAFOverrideRewriteActionBlock = "block" - WAFOverrideRewriteActionBlockSimulate WAFOverrideRewriteActionBlock = "simulate" - WAFOverrideRewriteActionBlockDisable WAFOverrideRewriteActionBlock = "disable" - WAFOverrideRewriteActionBlockDefault WAFOverrideRewriteActionBlock = "default" + RewriteActionBlockChallenge RewriteActionBlock = "challenge" + RewriteActionBlockBlock RewriteActionBlock = "block" + RewriteActionBlockSimulate RewriteActionBlock = "simulate" + RewriteActionBlockDisable RewriteActionBlock = "disable" + RewriteActionBlockDefault RewriteActionBlock = "default" ) -func (r WAFOverrideRewriteActionBlock) IsKnown() bool { +func (r RewriteActionBlock) IsKnown() bool { switch r { - case WAFOverrideRewriteActionBlockChallenge, WAFOverrideRewriteActionBlockBlock, WAFOverrideRewriteActionBlockSimulate, WAFOverrideRewriteActionBlockDisable, WAFOverrideRewriteActionBlockDefault: + case RewriteActionBlockChallenge, RewriteActionBlockBlock, RewriteActionBlockSimulate, RewriteActionBlockDisable, RewriteActionBlockDefault: return true } return false } // The WAF rule action to apply. -type WAFOverrideRewriteActionDisable string +type RewriteActionDisable string const ( - WAFOverrideRewriteActionDisableChallenge WAFOverrideRewriteActionDisable = "challenge" - WAFOverrideRewriteActionDisableBlock WAFOverrideRewriteActionDisable = "block" - WAFOverrideRewriteActionDisableSimulate WAFOverrideRewriteActionDisable = "simulate" - WAFOverrideRewriteActionDisableDisable WAFOverrideRewriteActionDisable = "disable" - WAFOverrideRewriteActionDisableDefault WAFOverrideRewriteActionDisable = "default" + RewriteActionDisableChallenge RewriteActionDisable = "challenge" + RewriteActionDisableBlock RewriteActionDisable = "block" + RewriteActionDisableSimulate RewriteActionDisable = "simulate" + RewriteActionDisableDisable RewriteActionDisable = "disable" + RewriteActionDisableDefault RewriteActionDisable = "default" ) -func (r WAFOverrideRewriteActionDisable) IsKnown() bool { +func (r RewriteActionDisable) IsKnown() bool { switch r { - case WAFOverrideRewriteActionDisableChallenge, WAFOverrideRewriteActionDisableBlock, WAFOverrideRewriteActionDisableSimulate, WAFOverrideRewriteActionDisableDisable, WAFOverrideRewriteActionDisableDefault: + case RewriteActionDisableChallenge, RewriteActionDisableBlock, RewriteActionDisableSimulate, RewriteActionDisableDisable, RewriteActionDisableDefault: return true } return false } +type WAFRule map[string]WAFRuleItem + // The WAF rule action to apply. -type WAFOverrideRule string +type WAFRuleItem string const ( - WAFOverrideRuleChallenge WAFOverrideRule = "challenge" - WAFOverrideRuleBlock WAFOverrideRule = "block" - WAFOverrideRuleSimulate WAFOverrideRule = "simulate" - WAFOverrideRuleDisable WAFOverrideRule = "disable" - WAFOverrideRuleDefault WAFOverrideRule = "default" + WAFRuleItemChallenge WAFRuleItem = "challenge" + WAFRuleItemBlock WAFRuleItem = "block" + WAFRuleItemSimulate WAFRuleItem = "simulate" + WAFRuleItemDisable WAFRuleItem = "disable" + WAFRuleItemDefault WAFRuleItem = "default" ) -func (r WAFOverrideRule) IsKnown() bool { +func (r WAFRuleItem) IsKnown() bool { switch r { - case WAFOverrideRuleChallenge, WAFOverrideRuleBlock, WAFOverrideRuleSimulate, WAFOverrideRuleDisable, WAFOverrideRuleDefault: + case WAFRuleItemChallenge, WAFRuleItemBlock, WAFRuleItemSimulate, WAFRuleItemDisable, WAFRuleItemDefault: return true } return false @@ -295,7 +299,7 @@ func (r wafOverrideDeleteResponseJSON) RawJSON() string { } type WAFOverrideNewParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r WAFOverrideNewParams) MarshalJSON() (data []byte, err error) { @@ -303,9 +307,9 @@ func (r WAFOverrideNewParams) MarshalJSON() (data []byte, err error) { } type WAFOverrideNewResponseEnvelope struct { - Errors []WAFOverrideNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WAFOverrideNewResponseEnvelopeMessages `json:"messages,required"` - Result WAFOverride `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Override `json:"result,required"` // Whether the API call was successful Success WAFOverrideNewResponseEnvelopeSuccess `json:"success,required"` JSON wafOverrideNewResponseEnvelopeJSON `json:"-"` @@ -330,52 +334,6 @@ func (r wafOverrideNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WAFOverrideNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafOverrideNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// wafOverrideNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WAFOverrideNewResponseEnvelopeErrors] -type wafOverrideNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFOverrideNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafOverrideNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WAFOverrideNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafOverrideNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// wafOverrideNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WAFOverrideNewResponseEnvelopeMessages] -type wafOverrideNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFOverrideNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafOverrideNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WAFOverrideNewResponseEnvelopeSuccess bool @@ -392,7 +350,7 @@ func (r WAFOverrideNewResponseEnvelopeSuccess) IsKnown() bool { } type WAFOverrideUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r WAFOverrideUpdateParams) MarshalJSON() (data []byte, err error) { @@ -400,9 +358,9 @@ func (r WAFOverrideUpdateParams) MarshalJSON() (data []byte, err error) { } type WAFOverrideUpdateResponseEnvelope struct { - Errors []WAFOverrideUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WAFOverrideUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WAFOverride `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Override `json:"result,required"` // Whether the API call was successful Success WAFOverrideUpdateResponseEnvelopeSuccess `json:"success,required"` JSON wafOverrideUpdateResponseEnvelopeJSON `json:"-"` @@ -427,52 +385,6 @@ func (r wafOverrideUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WAFOverrideUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafOverrideUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// wafOverrideUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WAFOverrideUpdateResponseEnvelopeErrors] -type wafOverrideUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFOverrideUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafOverrideUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WAFOverrideUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafOverrideUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// wafOverrideUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WAFOverrideUpdateResponseEnvelopeMessages] -type wafOverrideUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFOverrideUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafOverrideUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WAFOverrideUpdateResponseEnvelopeSuccess bool @@ -498,11 +410,19 @@ type WAFOverrideListParams struct { // URLQuery serializes [WAFOverrideListParams]'s query parameters as `url.Values`. func (r WAFOverrideListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } +type WAFOverrideDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r WAFOverrideDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type WAFOverrideDeleteResponseEnvelope struct { Result WAFOverrideDeleteResponse `json:"result"` JSON wafOverrideDeleteResponseEnvelopeJSON `json:"-"` @@ -525,9 +445,9 @@ func (r wafOverrideDeleteResponseEnvelopeJSON) RawJSON() string { } type WAFOverrideGetResponseEnvelope struct { - Errors []WAFOverrideGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WAFOverrideGetResponseEnvelopeMessages `json:"messages,required"` - Result WAFOverride `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Override `json:"result,required"` // Whether the API call was successful Success WAFOverrideGetResponseEnvelopeSuccess `json:"success,required"` JSON wafOverrideGetResponseEnvelopeJSON `json:"-"` @@ -552,52 +472,6 @@ func (r wafOverrideGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WAFOverrideGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafOverrideGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// wafOverrideGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WAFOverrideGetResponseEnvelopeErrors] -type wafOverrideGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFOverrideGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafOverrideGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WAFOverrideGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafOverrideGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// wafOverrideGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WAFOverrideGetResponseEnvelopeMessages] -type wafOverrideGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFOverrideGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafOverrideGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WAFOverrideGetResponseEnvelopeSuccess bool diff --git a/firewall/wafoverride_test.go b/firewall/wafoverride_test.go index dab0a3c7f57..1a187260cdf 100644 --- a/firewall/wafoverride_test.go +++ b/firewall/wafoverride_test.go @@ -32,7 +32,7 @@ func TestWAFOverrideNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", firewall.WAFOverrideNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -63,7 +63,7 @@ func TestWAFOverrideUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "de677e5818985db1285d0e80225f06e5", firewall.WAFOverrideUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -124,6 +124,9 @@ func TestWAFOverrideDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "de677e5818985db1285d0e80225f06e5", + firewall.WAFOverrideDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/firewall/wafpackage.go b/firewall/wafpackage.go index 1c8ff70a4fd..ae9b1a2842a 100644 --- a/firewall/wafpackage.go +++ b/firewall/wafpackage.go @@ -80,20 +80,59 @@ func (r *WAFPackageService) Get(ctx context.Context, zoneIdentifier string, iden return } +type WAFPackageListResponse struct { + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result interface{} `json:"result,required"` + // Whether the API call was successful + Success WAFPackageListResponseSuccess `json:"success"` + ResultInfo interface{} `json:"result_info,required"` + JSON wafPackageListResponseJSON `json:"-"` + union WAFPackageListResponseUnion +} + +// wafPackageListResponseJSON contains the JSON metadata for the struct +// [WAFPackageListResponse] +type wafPackageListResponseJSON 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 wafPackageListResponseJSON) RawJSON() string { + return r.raw +} + +func (r *WAFPackageListResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r WAFPackageListResponse) AsUnion() WAFPackageListResponseUnion { + return r.union +} + // Union satisfied by -// [firewall.WAFPackageListResponseLegacyJhsAPIResponseCollection] or +// [firewall.WAFPackageListResponseFirewallAPIResponseCollection] or // [firewall.WAFPackageListResponseObject]. -type WAFPackageListResponse interface { +type WAFPackageListResponseUnion interface { implementsFirewallWAFPackageListResponse() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageListResponse)(nil)).Elem(), + reflect.TypeOf((*WAFPackageListResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageListResponseLegacyJhsAPIResponseCollection{}), + Type: reflect.TypeOf(WAFPackageListResponseFirewallAPIResponseCollection{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -102,19 +141,19 @@ func init() { ) } -type WAFPackageListResponseLegacyJhsAPIResponseCollection struct { - Errors []WAFPackageListResponseLegacyJhsAPIResponseCollectionError `json:"errors,required"` - Messages []WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage `json:"messages,required"` - Result WAFPackageListResponseLegacyJhsAPIResponseCollectionResult `json:"result,required,nullable"` +type WAFPackageListResponseFirewallAPIResponseCollection struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WAFPackageListResponseFirewallAPIResponseCollectionResultUnion `json:"result,required,nullable"` // Whether the API call was successful - Success WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess `json:"success,required"` - ResultInfo WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo `json:"result_info"` - JSON wafPackageListResponseLegacyJhsAPIResponseCollectionJSON `json:"-"` + Success WAFPackageListResponseFirewallAPIResponseCollectionSuccess `json:"success,required"` + ResultInfo WAFPackageListResponseFirewallAPIResponseCollectionResultInfo `json:"result_info"` + JSON wafPackageListResponseFirewallAPIResponseCollectionJSON `json:"-"` } -// wafPackageListResponseLegacyJhsAPIResponseCollectionJSON contains the JSON -// metadata for the struct [WAFPackageListResponseLegacyJhsAPIResponseCollection] -type wafPackageListResponseLegacyJhsAPIResponseCollectionJSON struct { +// wafPackageListResponseFirewallAPIResponseCollectionJSON contains the JSON +// metadata for the struct [WAFPackageListResponseFirewallAPIResponseCollection] +type wafPackageListResponseFirewallAPIResponseCollectionJSON struct { Errors apijson.Field Messages apijson.Field Result apijson.Field @@ -124,80 +163,32 @@ type wafPackageListResponseLegacyJhsAPIResponseCollectionJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFPackageListResponseLegacyJhsAPIResponseCollection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageListResponseLegacyJhsAPIResponseCollectionJSON) RawJSON() string { - return r.raw -} - -func (r WAFPackageListResponseLegacyJhsAPIResponseCollection) implementsFirewallWAFPackageListResponse() { -} - -type WAFPackageListResponseLegacyJhsAPIResponseCollectionError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON `json:"-"` -} - -// wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON contains the JSON -// metadata for the struct -// [WAFPackageListResponseLegacyJhsAPIResponseCollectionError] -type wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageListResponseLegacyJhsAPIResponseCollectionError) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageListResponseFirewallAPIResponseCollection) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON) RawJSON() string { +func (r wafPackageListResponseFirewallAPIResponseCollectionJSON) RawJSON() string { return r.raw } -type WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON `json:"-"` -} - -// wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON contains the -// JSON metadata for the struct -// [WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage] -type wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON) RawJSON() string { - return r.raw +func (r WAFPackageListResponseFirewallAPIResponseCollection) implementsFirewallWAFPackageListResponse() { } // Union satisfied by -// [firewall.WAFPackageListResponseLegacyJhsAPIResponseCollectionResultUnknown], -// [firewall.WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray] or +// [firewall.WAFPackageListResponseFirewallAPIResponseCollectionResultUnknown], +// [firewall.WAFPackageListResponseFirewallAPIResponseCollectionResultArray] or // [shared.UnionString]. -type WAFPackageListResponseLegacyJhsAPIResponseCollectionResult interface { - ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() +type WAFPackageListResponseFirewallAPIResponseCollectionResultUnion interface { + ImplementsFirewallWAFPackageListResponseFirewallAPIResponseCollectionResultUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageListResponseLegacyJhsAPIResponseCollectionResult)(nil)).Elem(), + reflect.TypeOf((*WAFPackageListResponseFirewallAPIResponseCollectionResultUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray{}), + Type: reflect.TypeOf(WAFPackageListResponseFirewallAPIResponseCollectionResultArray{}), }, apijson.UnionVariant{ TypeFilter: gjson.String, @@ -206,27 +197,27 @@ func init() { ) } -type WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray []interface{} +type WAFPackageListResponseFirewallAPIResponseCollectionResultArray []interface{} -func (r WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray) ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() { +func (r WAFPackageListResponseFirewallAPIResponseCollectionResultArray) ImplementsFirewallWAFPackageListResponseFirewallAPIResponseCollectionResultUnion() { } // Whether the API call was successful -type WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess bool +type WAFPackageListResponseFirewallAPIResponseCollectionSuccess bool const ( - WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccessTrue WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess = true + WAFPackageListResponseFirewallAPIResponseCollectionSuccessTrue WAFPackageListResponseFirewallAPIResponseCollectionSuccess = true ) -func (r WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess) IsKnown() bool { +func (r WAFPackageListResponseFirewallAPIResponseCollectionSuccess) IsKnown() bool { switch r { - case WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccessTrue: + case WAFPackageListResponseFirewallAPIResponseCollectionSuccessTrue: return true } return false } -type WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo struct { +type WAFPackageListResponseFirewallAPIResponseCollectionResultInfo struct { // Total number of results for the requested service Count float64 `json:"count"` // Current page within paginated list of results @@ -234,14 +225,14 @@ type WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo struct { // 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 wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON `json:"-"` + TotalCount float64 `json:"total_count"` + JSON wafPackageListResponseFirewallAPIResponseCollectionResultInfoJSON `json:"-"` } -// wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON contains the +// wafPackageListResponseFirewallAPIResponseCollectionResultInfoJSON contains the // JSON metadata for the struct -// [WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo] -type wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON struct { +// [WAFPackageListResponseFirewallAPIResponseCollectionResultInfo] +type wafPackageListResponseFirewallAPIResponseCollectionResultInfoJSON struct { Count apijson.Field Page apijson.Field PerPage apijson.Field @@ -250,11 +241,11 @@ type wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageListResponseFirewallAPIResponseCollectionResultInfo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON) RawJSON() string { +func (r wafPackageListResponseFirewallAPIResponseCollectionResultInfoJSON) RawJSON() string { return r.raw } @@ -281,30 +272,91 @@ func (r wafPackageListResponseObjectJSON) RawJSON() string { func (r WAFPackageListResponseObject) implementsFirewallWAFPackageListResponse() {} +type WAFPackageListResponseObjectResult struct { + // A summary of the purpose/function of the WAF package. + Description string `json:"description,required"` + // The mode that defines how rules within the package are evaluated during the + // course of a request. When a package uses anomaly detection mode (`anomaly` + // value), each rule is given a score when triggered. If the total score of all + // triggered rules exceeds the sensitivity defined in the WAF package, the action + // configured in the package will be performed. Traditional detection mode + // (`traditional` value) will decide the action to take when it is triggered by the + // request. If multiple rules are triggered, the action providing the highest + // protection will be applied (for example, a 'block' action will win over a + // 'challenge' action). + DetectionMode WAFPackageListResponseObjectResultDetectionMode `json:"detection_mode,required"` + // Identifier + ID string `json:"id,required"` + // The name of the WAF package. + Name string `json:"name,required"` + // When set to `active`, indicates that the WAF package will be applied to the + // zone. + Status WAFPackageListResponseObjectResultStatus `json:"status"` + // Identifier + ZoneID string `json:"zone_id,required"` + // The default action performed by the rules in the WAF package. + ActionMode WAFPackageListResponseObjectResultActionMode `json:"action_mode"` + // The sensitivity of the WAF package. + Sensitivity WAFPackageListResponseObjectResultSensitivity `json:"sensitivity"` + JSON wafPackageListResponseObjectResultJSON `json:"-"` + union WAFPackageListResponseObjectResultUnion +} + +// wafPackageListResponseObjectResultJSON contains the JSON metadata for the struct +// [WAFPackageListResponseObjectResult] +type wafPackageListResponseObjectResultJSON struct { + Description apijson.Field + DetectionMode apijson.Field + ID apijson.Field + Name apijson.Field + Status apijson.Field + ZoneID apijson.Field + ActionMode apijson.Field + Sensitivity apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r wafPackageListResponseObjectResultJSON) RawJSON() string { + return r.raw +} + +func (r *WAFPackageListResponseObjectResult) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r WAFPackageListResponseObjectResult) AsUnion() WAFPackageListResponseObjectResultUnion { + return r.union +} + // Union satisfied by -// [firewall.WAFPackageListResponseObjectResultLegacyJhsPackageDefinition] or -// [firewall.WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage]. -type WAFPackageListResponseObjectResult interface { +// [firewall.WAFPackageListResponseObjectResultFirewallPackageDefinition] or +// [firewall.WAFPackageListResponseObjectResultFirewallAnomalyPackage]. +type WAFPackageListResponseObjectResultUnion interface { implementsFirewallWAFPackageListResponseObjectResult() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageListResponseObjectResult)(nil)).Elem(), + reflect.TypeOf((*WAFPackageListResponseObjectResultUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageListResponseObjectResultLegacyJhsPackageDefinition{}), + Type: reflect.TypeOf(WAFPackageListResponseObjectResultFirewallPackageDefinition{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage{}), + Type: reflect.TypeOf(WAFPackageListResponseObjectResultFirewallAnomalyPackage{}), }, ) } -type WAFPackageListResponseObjectResultLegacyJhsPackageDefinition struct { - // The unique identifier of a WAF package. +type WAFPackageListResponseObjectResultFirewallPackageDefinition struct { + // Identifier ID string `json:"id,required"` // A summary of the purpose/function of the WAF package. Description string `json:"description,required"` @@ -317,21 +369,21 @@ type WAFPackageListResponseObjectResultLegacyJhsPackageDefinition struct { // request. If multiple rules are triggered, the action providing the highest // protection will be applied (for example, a 'block' action will win over a // 'challenge' action). - DetectionMode WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode `json:"detection_mode,required"` + DetectionMode WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionMode `json:"detection_mode,required"` // The name of the WAF package. Name string `json:"name,required"` // Identifier ZoneID string `json:"zone_id,required"` // When set to `active`, indicates that the WAF package will be applied to the // zone. - Status WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus `json:"status"` - JSON wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON `json:"-"` + Status WAFPackageListResponseObjectResultFirewallPackageDefinitionStatus `json:"status"` + JSON wafPackageListResponseObjectResultFirewallPackageDefinitionJSON `json:"-"` } -// wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON contains the +// wafPackageListResponseObjectResultFirewallPackageDefinitionJSON contains the // JSON metadata for the struct -// [WAFPackageListResponseObjectResultLegacyJhsPackageDefinition] -type wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON struct { +// [WAFPackageListResponseObjectResultFirewallPackageDefinition] +type wafPackageListResponseObjectResultFirewallPackageDefinitionJSON struct { ID apijson.Field Description apijson.Field DetectionMode apijson.Field @@ -342,15 +394,15 @@ type wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFPackageListResponseObjectResultLegacyJhsPackageDefinition) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageListResponseObjectResultFirewallPackageDefinition) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON) RawJSON() string { +func (r wafPackageListResponseObjectResultFirewallPackageDefinitionJSON) RawJSON() string { return r.raw } -func (r WAFPackageListResponseObjectResultLegacyJhsPackageDefinition) implementsFirewallWAFPackageListResponseObjectResult() { +func (r WAFPackageListResponseObjectResultFirewallPackageDefinition) implementsFirewallWAFPackageListResponseObjectResult() { } // The mode that defines how rules within the package are evaluated during the @@ -362,16 +414,16 @@ func (r WAFPackageListResponseObjectResultLegacyJhsPackageDefinition) implements // request. If multiple rules are triggered, the action providing the highest // protection will be applied (for example, a 'block' action will win over a // 'challenge' action). -type WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode string +type WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionMode string const ( - WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeAnomaly WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode = "anomaly" - WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeTraditional WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode = "traditional" + WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionModeAnomaly WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionMode = "anomaly" + WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionModeTraditional WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionMode = "traditional" ) -func (r WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode) IsKnown() bool { +func (r WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionMode) IsKnown() bool { switch r { - case WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeAnomaly, WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeTraditional: + case WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionModeAnomaly, WAFPackageListResponseObjectResultFirewallPackageDefinitionDetectionModeTraditional: return true } return false @@ -379,47 +431,47 @@ func (r WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMod // When set to `active`, indicates that the WAF package will be applied to the // zone. -type WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus string +type WAFPackageListResponseObjectResultFirewallPackageDefinitionStatus string const ( - WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatusActive WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus = "active" + WAFPackageListResponseObjectResultFirewallPackageDefinitionStatusActive WAFPackageListResponseObjectResultFirewallPackageDefinitionStatus = "active" ) -func (r WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus) IsKnown() bool { +func (r WAFPackageListResponseObjectResultFirewallPackageDefinitionStatus) IsKnown() bool { switch r { - case WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatusActive: + case WAFPackageListResponseObjectResultFirewallPackageDefinitionStatusActive: return true } return false } -type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage struct { - // The unique identifier of a WAF package. +type WAFPackageListResponseObjectResultFirewallAnomalyPackage struct { + // Identifier ID string `json:"id,required"` // A summary of the purpose/function of the WAF package. Description string `json:"description,required"` // When a WAF package uses anomaly detection, each rule is given a score when // triggered. If the total score of all triggered rules exceeds the sensitivity // defined on the WAF package, the action defined on the package will be taken. - DetectionMode WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode `json:"detection_mode,required"` + DetectionMode WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionMode `json:"detection_mode,required"` // The name of the WAF package. Name string `json:"name,required"` // Identifier ZoneID string `json:"zone_id,required"` // The default action performed by the rules in the WAF package. - ActionMode WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode `json:"action_mode"` + ActionMode WAFPackageListResponseObjectResultFirewallAnomalyPackageActionMode `json:"action_mode"` // The sensitivity of the WAF package. - Sensitivity WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity `json:"sensitivity"` + Sensitivity WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivity `json:"sensitivity"` // When set to `active`, indicates that the WAF package will be applied to the // zone. - Status WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus `json:"status"` - JSON wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON `json:"-"` + Status WAFPackageListResponseObjectResultFirewallAnomalyPackageStatus `json:"status"` + JSON wafPackageListResponseObjectResultFirewallAnomalyPackageJSON `json:"-"` } -// wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON contains the JSON +// wafPackageListResponseObjectResultFirewallAnomalyPackageJSON contains the JSON // metadata for the struct -// [WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage] -type wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON struct { +// [WAFPackageListResponseObjectResultFirewallAnomalyPackage] +type wafPackageListResponseObjectResultFirewallAnomalyPackageJSON struct { ID apijson.Field Description apijson.Field DetectionMode apijson.Field @@ -432,65 +484,65 @@ type wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageListResponseObjectResultFirewallAnomalyPackage) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON) RawJSON() string { +func (r wafPackageListResponseObjectResultFirewallAnomalyPackageJSON) RawJSON() string { return r.raw } -func (r WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage) implementsFirewallWAFPackageListResponseObjectResult() { +func (r WAFPackageListResponseObjectResultFirewallAnomalyPackage) implementsFirewallWAFPackageListResponseObjectResult() { } // When a WAF package uses anomaly detection, each rule is given a score when // triggered. If the total score of all triggered rules exceeds the sensitivity // defined on the WAF package, the action defined on the package will be taken. -type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode string +type WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionMode string const ( - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeAnomaly WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode = "anomaly" - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeTraditional WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode = "traditional" + WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionModeAnomaly WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionMode = "anomaly" + WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionModeTraditional WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionMode = "traditional" ) -func (r WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode) IsKnown() bool { +func (r WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionMode) IsKnown() bool { switch r { - case WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeAnomaly, WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeTraditional: + case WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionModeAnomaly, WAFPackageListResponseObjectResultFirewallAnomalyPackageDetectionModeTraditional: return true } return false } // The default action performed by the rules in the WAF package. -type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode string +type WAFPackageListResponseObjectResultFirewallAnomalyPackageActionMode string const ( - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeSimulate WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "simulate" - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeBlock WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "block" - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeChallenge WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "challenge" + WAFPackageListResponseObjectResultFirewallAnomalyPackageActionModeSimulate WAFPackageListResponseObjectResultFirewallAnomalyPackageActionMode = "simulate" + WAFPackageListResponseObjectResultFirewallAnomalyPackageActionModeBlock WAFPackageListResponseObjectResultFirewallAnomalyPackageActionMode = "block" + WAFPackageListResponseObjectResultFirewallAnomalyPackageActionModeChallenge WAFPackageListResponseObjectResultFirewallAnomalyPackageActionMode = "challenge" ) -func (r WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode) IsKnown() bool { +func (r WAFPackageListResponseObjectResultFirewallAnomalyPackageActionMode) IsKnown() bool { switch r { - case WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeSimulate, WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeBlock, WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeChallenge: + case WAFPackageListResponseObjectResultFirewallAnomalyPackageActionModeSimulate, WAFPackageListResponseObjectResultFirewallAnomalyPackageActionModeBlock, WAFPackageListResponseObjectResultFirewallAnomalyPackageActionModeChallenge: return true } return false } // The sensitivity of the WAF package. -type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity string +type WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivity string const ( - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityHigh WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "high" - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityMedium WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "medium" - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityLow WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "low" - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityOff WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "off" + WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityHigh WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivity = "high" + WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityMedium WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivity = "medium" + WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityLow WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivity = "low" + WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityOff WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivity = "off" ) -func (r WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity) IsKnown() bool { +func (r WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivity) IsKnown() bool { switch r { - case WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityHigh, WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityMedium, WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityLow, WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityOff: + case WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityHigh, WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityMedium, WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityLow, WAFPackageListResponseObjectResultFirewallAnomalyPackageSensitivityOff: return true } return false @@ -498,53 +550,123 @@ func (r WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity) Is // When set to `active`, indicates that the WAF package will be applied to the // zone. -type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus string +type WAFPackageListResponseObjectResultFirewallAnomalyPackageStatus string const ( - WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatusActive WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus = "active" + WAFPackageListResponseObjectResultFirewallAnomalyPackageStatusActive WAFPackageListResponseObjectResultFirewallAnomalyPackageStatus = "active" ) -func (r WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus) IsKnown() bool { +func (r WAFPackageListResponseObjectResultFirewallAnomalyPackageStatus) IsKnown() bool { switch r { - case WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatusActive: + case WAFPackageListResponseObjectResultFirewallAnomalyPackageStatusActive: return true } return false } -// Union satisfied by [firewall.WAFPackageGetResponseLegacyJhsAPIResponseSingle] or -// [firewall.WAFPackageGetResponseObject]. -type WAFPackageGetResponse interface { - implementsFirewallWAFPackageGetResponse() +// The mode that defines how rules within the package are evaluated during the +// course of a request. When a package uses anomaly detection mode (`anomaly` +// value), each rule is given a score when triggered. If the total score of all +// triggered rules exceeds the sensitivity defined in the WAF package, the action +// configured in the package will be performed. Traditional detection mode +// (`traditional` value) will decide the action to take when it is triggered by the +// request. If multiple rules are triggered, the action providing the highest +// protection will be applied (for example, a 'block' action will win over a +// 'challenge' action). +type WAFPackageListResponseObjectResultDetectionMode string + +const ( + WAFPackageListResponseObjectResultDetectionModeAnomaly WAFPackageListResponseObjectResultDetectionMode = "anomaly" + WAFPackageListResponseObjectResultDetectionModeTraditional WAFPackageListResponseObjectResultDetectionMode = "traditional" +) + +func (r WAFPackageListResponseObjectResultDetectionMode) IsKnown() bool { + switch r { + case WAFPackageListResponseObjectResultDetectionModeAnomaly, WAFPackageListResponseObjectResultDetectionModeTraditional: + return true + } + return false } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageGetResponseLegacyJhsAPIResponseSingle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageGetResponseObject{}), - }, - ) +// When set to `active`, indicates that the WAF package will be applied to the +// zone. +type WAFPackageListResponseObjectResultStatus string + +const ( + WAFPackageListResponseObjectResultStatusActive WAFPackageListResponseObjectResultStatus = "active" +) + +func (r WAFPackageListResponseObjectResultStatus) IsKnown() bool { + switch r { + case WAFPackageListResponseObjectResultStatusActive: + return true + } + return false +} + +// The default action performed by the rules in the WAF package. +type WAFPackageListResponseObjectResultActionMode string + +const ( + WAFPackageListResponseObjectResultActionModeSimulate WAFPackageListResponseObjectResultActionMode = "simulate" + WAFPackageListResponseObjectResultActionModeBlock WAFPackageListResponseObjectResultActionMode = "block" + WAFPackageListResponseObjectResultActionModeChallenge WAFPackageListResponseObjectResultActionMode = "challenge" +) + +func (r WAFPackageListResponseObjectResultActionMode) IsKnown() bool { + switch r { + case WAFPackageListResponseObjectResultActionModeSimulate, WAFPackageListResponseObjectResultActionModeBlock, WAFPackageListResponseObjectResultActionModeChallenge: + return true + } + return false } -type WAFPackageGetResponseLegacyJhsAPIResponseSingle struct { - Errors []WAFPackageGetResponseLegacyJhsAPIResponseSingleError `json:"errors,required"` - Messages []WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage `json:"messages,required"` - Result WAFPackageGetResponseLegacyJhsAPIResponseSingleResult `json:"result,required,nullable"` +// The sensitivity of the WAF package. +type WAFPackageListResponseObjectResultSensitivity string + +const ( + WAFPackageListResponseObjectResultSensitivityHigh WAFPackageListResponseObjectResultSensitivity = "high" + WAFPackageListResponseObjectResultSensitivityMedium WAFPackageListResponseObjectResultSensitivity = "medium" + WAFPackageListResponseObjectResultSensitivityLow WAFPackageListResponseObjectResultSensitivity = "low" + WAFPackageListResponseObjectResultSensitivityOff WAFPackageListResponseObjectResultSensitivity = "off" +) + +func (r WAFPackageListResponseObjectResultSensitivity) IsKnown() bool { + switch r { + case WAFPackageListResponseObjectResultSensitivityHigh, WAFPackageListResponseObjectResultSensitivityMedium, WAFPackageListResponseObjectResultSensitivityLow, WAFPackageListResponseObjectResultSensitivityOff: + return true + } + return false +} + +// Whether the API call was successful +type WAFPackageListResponseSuccess bool + +const ( + WAFPackageListResponseSuccessTrue WAFPackageListResponseSuccess = true +) + +func (r WAFPackageListResponseSuccess) IsKnown() bool { + switch r { + case WAFPackageListResponseSuccessTrue: + return true + } + return false +} + +type WAFPackageGetResponse struct { + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result interface{} `json:"result,required"` // Whether the API call was successful - Success WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess `json:"success,required"` - JSON wafPackageGetResponseLegacyJhsAPIResponseSingleJSON `json:"-"` + Success WAFPackageGetResponseSuccess `json:"success"` + JSON wafPackageGetResponseJSON `json:"-"` + union WAFPackageGetResponseUnion } -// wafPackageGetResponseLegacyJhsAPIResponseSingleJSON contains the JSON metadata -// for the struct [WAFPackageGetResponseLegacyJhsAPIResponseSingle] -type wafPackageGetResponseLegacyJhsAPIResponseSingleJSON struct { +// wafPackageGetResponseJSON contains the JSON metadata for the struct +// [WAFPackageGetResponse] +type wafPackageGetResponseJSON struct { Errors apijson.Field Messages apijson.Field Result apijson.Field @@ -553,72 +675,83 @@ type wafPackageGetResponseLegacyJhsAPIResponseSingleJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFPackageGetResponseLegacyJhsAPIResponseSingle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageGetResponseLegacyJhsAPIResponseSingleJSON) RawJSON() string { +func (r wafPackageGetResponseJSON) RawJSON() string { return r.raw } -func (r WAFPackageGetResponseLegacyJhsAPIResponseSingle) implementsFirewallWAFPackageGetResponse() {} - -type WAFPackageGetResponseLegacyJhsAPIResponseSingleError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON `json:"-"` +func (r *WAFPackageGetResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -// wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON contains the JSON -// metadata for the struct [WAFPackageGetResponseLegacyJhsAPIResponseSingleError] -type wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r WAFPackageGetResponse) AsUnion() WAFPackageGetResponseUnion { + return r.union } -func (r *WAFPackageGetResponseLegacyJhsAPIResponseSingleError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [firewall.WAFPackageGetResponseFirewallAPIResponseSingle] or +// [firewall.WAFPackageGetResponseObject]. +type WAFPackageGetResponseUnion interface { + implementsFirewallWAFPackageGetResponse() } -func (r wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageGetResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageGetResponseFirewallAPIResponseSingle{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageGetResponseObject{}), + }, + ) } -type WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON `json:"-"` +type WAFPackageGetResponseFirewallAPIResponseSingle struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WAFPackageGetResponseFirewallAPIResponseSingleResultUnion `json:"result,required"` + // Whether the API call was successful + Success WAFPackageGetResponseFirewallAPIResponseSingleSuccess `json:"success,required"` + JSON wafPackageGetResponseFirewallAPIResponseSingleJSON `json:"-"` } -// wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON contains the JSON -// metadata for the struct [WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage] -type wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON struct { - Code apijson.Field - Message apijson.Field +// wafPackageGetResponseFirewallAPIResponseSingleJSON contains the JSON metadata +// for the struct [WAFPackageGetResponseFirewallAPIResponseSingle] +type wafPackageGetResponseFirewallAPIResponseSingleJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageGetResponseFirewallAPIResponseSingle) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON) RawJSON() string { +func (r wafPackageGetResponseFirewallAPIResponseSingleJSON) RawJSON() string { return r.raw } +func (r WAFPackageGetResponseFirewallAPIResponseSingle) implementsFirewallWAFPackageGetResponse() {} + // Union satisfied by -// [firewall.WAFPackageGetResponseLegacyJhsAPIResponseSingleResultUnknown] or +// [firewall.WAFPackageGetResponseFirewallAPIResponseSingleResultUnknown] or // [shared.UnionString]. -type WAFPackageGetResponseLegacyJhsAPIResponseSingleResult interface { - ImplementsFirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult() +type WAFPackageGetResponseFirewallAPIResponseSingleResultUnion interface { + ImplementsFirewallWAFPackageGetResponseFirewallAPIResponseSingleResultUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageGetResponseLegacyJhsAPIResponseSingleResult)(nil)).Elem(), + reflect.TypeOf((*WAFPackageGetResponseFirewallAPIResponseSingleResultUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -628,15 +761,15 @@ func init() { } // Whether the API call was successful -type WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess bool +type WAFPackageGetResponseFirewallAPIResponseSingleSuccess bool const ( - WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccessTrue WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess = true + WAFPackageGetResponseFirewallAPIResponseSingleSuccessTrue WAFPackageGetResponseFirewallAPIResponseSingleSuccess = true ) -func (r WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess) IsKnown() bool { +func (r WAFPackageGetResponseFirewallAPIResponseSingleSuccess) IsKnown() bool { switch r { - case WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccessTrue: + case WAFPackageGetResponseFirewallAPIResponseSingleSuccessTrue: return true } return false @@ -665,12 +798,29 @@ func (r wafPackageGetResponseObjectJSON) RawJSON() string { func (r WAFPackageGetResponseObject) implementsFirewallWAFPackageGetResponse() {} +// Whether the API call was successful +type WAFPackageGetResponseSuccess bool + +const ( + WAFPackageGetResponseSuccessTrue WAFPackageGetResponseSuccess = true +) + +func (r WAFPackageGetResponseSuccess) IsKnown() bool { + switch r { + case WAFPackageGetResponseSuccessTrue: + return true + } + return false +} + type WAFPackageListParams struct { // The direction used to sort returned packages. Direction param.Field[WAFPackageListParamsDirection] `query:"direction"` // 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[WAFPackageListParamsMatch] `query:"match"` + // The name of the WAF package. + Name param.Field[string] `query:"name"` // The field used to sort returned packages. Order param.Field[WAFPackageListParamsOrder] `query:"order"` // The page number of paginated results. @@ -682,7 +832,7 @@ type WAFPackageListParams struct { // URLQuery serializes [WAFPackageListParams]'s query parameters as `url.Values`. func (r WAFPackageListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/firewall/wafpackage_test.go b/firewall/wafpackage_test.go index 2a134c62959..6abf2e73bfa 100644 --- a/firewall/wafpackage_test.go +++ b/firewall/wafpackage_test.go @@ -34,6 +34,7 @@ func TestWAFPackageListWithOptionalParams(t *testing.T) { firewall.WAFPackageListParams{ Direction: cloudflare.F(firewall.WAFPackageListParamsDirectionDesc), Match: cloudflare.F(firewall.WAFPackageListParamsMatchAny), + Name: cloudflare.F("USER"), Order: cloudflare.F(firewall.WAFPackageListParamsOrderName), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), @@ -65,7 +66,7 @@ func TestWAFPackageGet(t *testing.T) { _, err := client.Firewall.WAF.Packages.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - "a25a9a7e9c00afc1fb2e0245519d725b", + "023e105f4ecef8ad9ca31a8372d0c353", ) if err != nil { var apierr *cloudflare.Error diff --git a/firewall/wafpackagegroup.go b/firewall/wafpackagegroup.go index 5dd21f64be8..13c542f25fd 100644 --- a/firewall/wafpackagegroup.go +++ b/firewall/wafpackagegroup.go @@ -41,7 +41,7 @@ func NewWAFPackageGroupService(opts ...option.RequestOption) (r *WAFPackageGroup // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFPackageGroupService) List(ctx context.Context, packageID string, params WAFPackageGroupListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[WAFManagedRulesGroup], err error) { +func (r *WAFPackageGroupService) List(ctx context.Context, packageID string, params WAFPackageGroupListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Group], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -62,7 +62,7 @@ func (r *WAFPackageGroupService) List(ctx context.Context, packageID string, par // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFPackageGroupService) ListAutoPaging(ctx context.Context, packageID string, params WAFPackageGroupListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WAFManagedRulesGroup] { +func (r *WAFPackageGroupService) ListAutoPaging(ctx context.Context, packageID string, params WAFPackageGroupListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Group] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, packageID, params, opts...)) } @@ -71,7 +71,7 @@ func (r *WAFPackageGroupService) ListAutoPaging(ctx context.Context, packageID s // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFPackageGroupService) Edit(ctx context.Context, packageID string, groupID string, params WAFPackageGroupEditParams, opts ...option.RequestOption) (res *WAFPackageGroupEditResponse, err error) { +func (r *WAFPackageGroupService) Edit(ctx context.Context, packageID string, groupID string, params WAFPackageGroupEditParams, opts ...option.RequestOption) (res *WAFPackageGroupEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WAFPackageGroupEditResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups/%s", params.ZoneID, packageID, groupID) @@ -87,7 +87,7 @@ func (r *WAFPackageGroupService) Edit(ctx context.Context, packageID string, gro // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFPackageGroupService) Get(ctx context.Context, packageID string, groupID string, query WAFPackageGroupGetParams, opts ...option.RequestOption) (res *WAFPackageGroupGetResponse, err error) { +func (r *WAFPackageGroupService) Get(ctx context.Context, packageID string, groupID string, query WAFPackageGroupGetParams, opts ...option.RequestOption) (res *WAFPackageGroupGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WAFPackageGroupGetResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups/%s", query.ZoneID, packageID, groupID) @@ -99,31 +99,30 @@ func (r *WAFPackageGroupService) Get(ctx context.Context, packageID string, grou return } -type WAFManagedRulesGroup struct { +type Group struct { // The unique identifier of the rule group. ID string `json:"id,required"` // An informative summary of what the rule group does. Description string `json:"description,required,nullable"` // The state of the rules contained in the rule group. When `on`, the rules in the // group are configurable/usable. - Mode WAFManagedRulesGroupMode `json:"mode,required"` + Mode GroupMode `json:"mode,required"` // The name of the rule group. Name string `json:"name,required"` // The number of rules in the current rule group. RulesCount float64 `json:"rules_count,required"` // The available states for the rule group. - AllowedModes []WAFManagedRulesGroupAllowedMode `json:"allowed_modes"` + AllowedModes []GroupAllowedMode `json:"allowed_modes"` // The number of rules within the group that have been modified from their default // configuration. ModifiedRulesCount float64 `json:"modified_rules_count"` // The unique identifier of a WAF package. - PackageID string `json:"package_id"` - JSON wafManagedRulesGroupJSON `json:"-"` + PackageID string `json:"package_id"` + JSON groupJSON `json:"-"` } -// wafManagedRulesGroupJSON contains the JSON metadata for the struct -// [WAFManagedRulesGroup] -type wafManagedRulesGroupJSON struct { +// groupJSON contains the JSON metadata for the struct [Group] +type groupJSON struct { ID apijson.Field Description apijson.Field Mode apijson.Field @@ -136,26 +135,26 @@ type wafManagedRulesGroupJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFManagedRulesGroup) UnmarshalJSON(data []byte) (err error) { +func (r *Group) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafManagedRulesGroupJSON) RawJSON() string { +func (r groupJSON) RawJSON() string { return r.raw } // The state of the rules contained in the rule group. When `on`, the rules in the // group are configurable/usable. -type WAFManagedRulesGroupMode string +type GroupMode string const ( - WAFManagedRulesGroupModeOn WAFManagedRulesGroupMode = "on" - WAFManagedRulesGroupModeOff WAFManagedRulesGroupMode = "off" + GroupModeOn GroupMode = "on" + GroupModeOff GroupMode = "off" ) -func (r WAFManagedRulesGroupMode) IsKnown() bool { +func (r GroupMode) IsKnown() bool { switch r { - case WAFManagedRulesGroupModeOn, WAFManagedRulesGroupModeOff: + case GroupModeOn, GroupModeOff: return true } return false @@ -163,35 +162,31 @@ func (r WAFManagedRulesGroupMode) IsKnown() bool { // The state of the rules contained in the rule group. When `on`, the rules in the // group are configurable/usable. -type WAFManagedRulesGroupAllowedMode string +type GroupAllowedMode string const ( - WAFManagedRulesGroupAllowedModeOn WAFManagedRulesGroupAllowedMode = "on" - WAFManagedRulesGroupAllowedModeOff WAFManagedRulesGroupAllowedMode = "off" + GroupAllowedModeOn GroupAllowedMode = "on" + GroupAllowedModeOff GroupAllowedMode = "off" ) -func (r WAFManagedRulesGroupAllowedMode) IsKnown() bool { +func (r GroupAllowedMode) IsKnown() bool { switch r { - case WAFManagedRulesGroupAllowedModeOn, WAFManagedRulesGroupAllowedModeOff: + case GroupAllowedModeOn, GroupAllowedModeOff: return true } return false } -// Union satisfied by [firewall.WAFPackageGroupEditResponseUnknown], -// [firewall.WAFPackageGroupEditResponseArray] or [shared.UnionString]. -type WAFPackageGroupEditResponse interface { - ImplementsFirewallWAFPackageGroupEditResponse() +// Union satisfied by [firewall.WAFPackageGroupEditResponseUnknown] or +// [shared.UnionString]. +type WAFPackageGroupEditResponseUnion interface { + ImplementsFirewallWAFPackageGroupEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageGroupEditResponse)(nil)).Elem(), + reflect.TypeOf((*WAFPackageGroupEditResponseUnion)(nil)).Elem(), "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageGroupEditResponseArray{}), - }, apijson.UnionVariant{ TypeFilter: gjson.String, Type: reflect.TypeOf(shared.UnionString("")), @@ -199,24 +194,16 @@ func init() { ) } -type WAFPackageGroupEditResponseArray []interface{} - -func (r WAFPackageGroupEditResponseArray) ImplementsFirewallWAFPackageGroupEditResponse() {} - -// Union satisfied by [firewall.WAFPackageGroupGetResponseUnknown], -// [firewall.WAFPackageGroupGetResponseArray] or [shared.UnionString]. -type WAFPackageGroupGetResponse interface { - ImplementsFirewallWAFPackageGroupGetResponse() +// Union satisfied by [firewall.WAFPackageGroupGetResponseUnknown] or +// [shared.UnionString]. +type WAFPackageGroupGetResponseUnion interface { + ImplementsFirewallWAFPackageGroupGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageGroupGetResponse)(nil)).Elem(), + reflect.TypeOf((*WAFPackageGroupGetResponseUnion)(nil)).Elem(), "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageGroupGetResponseArray{}), - }, apijson.UnionVariant{ TypeFilter: gjson.String, Type: reflect.TypeOf(shared.UnionString("")), @@ -224,10 +211,6 @@ func init() { ) } -type WAFPackageGroupGetResponseArray []interface{} - -func (r WAFPackageGroupGetResponseArray) ImplementsFirewallWAFPackageGroupGetResponse() {} - type WAFPackageGroupListParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -239,19 +222,23 @@ type WAFPackageGroupListParams struct { // The state of the rules contained in the rule group. When `on`, the rules in the // group are configurable/usable. Mode param.Field[WAFPackageGroupListParamsMode] `query:"mode"` + // The name of the rule group. + Name param.Field[string] `query:"name"` // The field used to sort returned rule groups. Order param.Field[WAFPackageGroupListParamsOrder] `query:"order"` // The page number of paginated results. Page param.Field[float64] `query:"page"` // The number of rule groups per page. PerPage param.Field[float64] `query:"per_page"` + // The number of rules in the current rule group. + RulesCount param.Field[float64] `query:"rules_count"` } // URLQuery serializes [WAFPackageGroupListParams]'s query parameters as // `url.Values`. func (r WAFPackageGroupListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -352,9 +339,9 @@ func (r WAFPackageGroupEditParamsMode) IsKnown() bool { } type WAFPackageGroupEditResponseEnvelope struct { - Errors []WAFPackageGroupEditResponseEnvelopeErrors `json:"errors,required"` - Messages []WAFPackageGroupEditResponseEnvelopeMessages `json:"messages,required"` - Result WAFPackageGroupEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WAFPackageGroupEditResponseUnion `json:"result,required"` // Whether the API call was successful Success WAFPackageGroupEditResponseEnvelopeSuccess `json:"success,required"` JSON wafPackageGroupEditResponseEnvelopeJSON `json:"-"` @@ -379,52 +366,6 @@ func (r wafPackageGroupEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WAFPackageGroupEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageGroupEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// wafPackageGroupEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WAFPackageGroupEditResponseEnvelopeErrors] -type wafPackageGroupEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageGroupEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageGroupEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WAFPackageGroupEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageGroupEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// wafPackageGroupEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WAFPackageGroupEditResponseEnvelopeMessages] -type wafPackageGroupEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageGroupEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageGroupEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WAFPackageGroupEditResponseEnvelopeSuccess bool @@ -446,9 +387,9 @@ type WAFPackageGroupGetParams struct { } type WAFPackageGroupGetResponseEnvelope struct { - Errors []WAFPackageGroupGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WAFPackageGroupGetResponseEnvelopeMessages `json:"messages,required"` - Result WAFPackageGroupGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WAFPackageGroupGetResponseUnion `json:"result,required"` // Whether the API call was successful Success WAFPackageGroupGetResponseEnvelopeSuccess `json:"success,required"` JSON wafPackageGroupGetResponseEnvelopeJSON `json:"-"` @@ -473,52 +414,6 @@ func (r wafPackageGroupGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WAFPackageGroupGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageGroupGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// wafPackageGroupGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WAFPackageGroupGetResponseEnvelopeErrors] -type wafPackageGroupGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageGroupGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageGroupGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WAFPackageGroupGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageGroupGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// wafPackageGroupGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WAFPackageGroupGetResponseEnvelopeMessages] -type wafPackageGroupGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageGroupGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageGroupGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WAFPackageGroupGetResponseEnvelopeSuccess bool diff --git a/firewall/wafpackagegroup_test.go b/firewall/wafpackagegroup_test.go index a8c2896081a..61a96ef341c 100644 --- a/firewall/wafpackagegroup_test.go +++ b/firewall/wafpackagegroup_test.go @@ -32,13 +32,15 @@ func TestWAFPackageGroupListWithOptionalParams(t *testing.T) { context.TODO(), "a25a9a7e9c00afc1fb2e0245519d725b", firewall.WAFPackageGroupListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(firewall.WAFPackageGroupListParamsDirectionDesc), - Match: cloudflare.F(firewall.WAFPackageGroupListParamsMatchAny), - Mode: cloudflare.F(firewall.WAFPackageGroupListParamsModeOn), - Order: cloudflare.F(firewall.WAFPackageGroupListParamsOrderMode), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Direction: cloudflare.F(firewall.WAFPackageGroupListParamsDirectionDesc), + Match: cloudflare.F(firewall.WAFPackageGroupListParamsMatchAny), + Mode: cloudflare.F(firewall.WAFPackageGroupListParamsModeOn), + Name: cloudflare.F("Project Honey Pot"), + Order: cloudflare.F(firewall.WAFPackageGroupListParamsOrderMode), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + RulesCount: cloudflare.F(10.000000), }, ) if err != nil { diff --git a/firewall/wafpackagerule.go b/firewall/wafpackagerule.go index b6c8c974a5e..50481126a48 100644 --- a/firewall/wafpackagerule.go +++ b/firewall/wafpackagerule.go @@ -41,7 +41,7 @@ func NewWAFPackageRuleService(opts ...option.RequestOption) (r *WAFPackageRuleSe // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFPackageRuleService) List(ctx context.Context, packageID string, params WAFPackageRuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[WAFManagedRulesRule], err error) { +func (r *WAFPackageRuleService) List(ctx context.Context, packageID string, params WAFPackageRuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[WAFPackageRuleListResponse], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -62,7 +62,7 @@ func (r *WAFPackageRuleService) List(ctx context.Context, packageID string, para // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFPackageRuleService) ListAutoPaging(ctx context.Context, packageID string, params WAFPackageRuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WAFManagedRulesRule] { +func (r *WAFPackageRuleService) ListAutoPaging(ctx context.Context, packageID string, params WAFPackageRuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WAFPackageRuleListResponse] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, packageID, params, opts...)) } @@ -86,7 +86,7 @@ func (r *WAFPackageRuleService) Edit(ctx context.Context, packageID string, rule // // **Note:** Applies only to the // [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *WAFPackageRuleService) Get(ctx context.Context, packageID string, ruleID string, query WAFPackageRuleGetParams, opts ...option.RequestOption) (res *WAFPackageRuleGetResponse, err error) { +func (r *WAFPackageRuleService) Get(ctx context.Context, packageID string, ruleID string, query WAFPackageRuleGetParams, opts ...option.RequestOption) (res *WAFPackageRuleGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WAFPackageRuleGetResponseEnvelope path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/rules/%s", query.ZoneID, packageID, ruleID) @@ -98,33 +98,131 @@ func (r *WAFPackageRuleService) Get(ctx context.Context, packageID string, ruleI return } +// When set to `on`, the current WAF rule will be used when evaluating the request. +// Applies to anomaly detection WAF rules. +type AllowedModesAnomaly string + +const ( + AllowedModesAnomalyOn AllowedModesAnomaly = "on" + AllowedModesAnomalyOff AllowedModesAnomaly = "off" +) + +func (r AllowedModesAnomaly) IsKnown() bool { + switch r { + case AllowedModesAnomalyOn, AllowedModesAnomalyOff: + return true + } + return false +} + +// The rule group to which the current WAF rule belongs. +type WAFRuleGroup struct { + // The unique identifier of the rule group. + ID string `json:"id"` + // The name of the rule group. + Name string `json:"name"` + JSON wafRuleGroupJSON `json:"-"` +} + +// wafRuleGroupJSON contains the JSON metadata for the struct [WAFRuleGroup] +type wafRuleGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafRuleGroupJSON) RawJSON() string { + return r.raw +} + +// When triggered, anomaly detection WAF rules contribute to an overall threat +// score that will determine if a request is considered malicious. You can +// configure the total scoring threshold through the 'sensitivity' property of the +// WAF package. +type WAFPackageRuleListResponse struct { + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFRuleGroup `json:"group,required"` + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + AllowedModes interface{} `json:"allowed_modes"` + // When set to `on`, the current WAF rule will be used when evaluating the request. + // Applies to anomaly detection WAF rules. + Mode AllowedModesAnomaly `json:"mode,required"` + DefaultMode interface{} `json:"default_mode,required"` + JSON wafPackageRuleListResponseJSON `json:"-"` + union WAFPackageRuleListResponseUnion +} + +// wafPackageRuleListResponseJSON contains the JSON metadata for the struct +// [WAFPackageRuleListResponse] +type wafPackageRuleListResponseJSON struct { + Description apijson.Field + Group apijson.Field + ID apijson.Field + PackageID apijson.Field + Priority apijson.Field + AllowedModes apijson.Field + Mode apijson.Field + DefaultMode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r wafPackageRuleListResponseJSON) RawJSON() string { + return r.raw +} + +func (r *WAFPackageRuleListResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r WAFPackageRuleListResponse) AsUnion() WAFPackageRuleListResponseUnion { + return r.union +} + // When triggered, anomaly detection WAF rules contribute to an overall threat // score that will determine if a request is considered malicious. You can // configure the total scoring threshold through the 'sensitivity' property of the // WAF package. // -// Union satisfied by [firewall.WAFManagedRulesRuleWAFManagedRulesAnomalyRule], -// [firewall.WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule] or -// [firewall.WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule]. -type WAFManagedRulesRule interface { - implementsFirewallWAFManagedRulesRule() +// Union satisfied by +// [firewall.WAFPackageRuleListResponseWAFManagedRulesAnomalyRule], +// [firewall.WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule] or +// [firewall.WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule]. +type WAFPackageRuleListResponseUnion interface { + implementsFirewallWAFPackageRuleListResponse() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFManagedRulesRule)(nil)).Elem(), + reflect.TypeOf((*WAFPackageRuleListResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFManagedRulesRuleWAFManagedRulesAnomalyRule{}), + Type: reflect.TypeOf(WAFPackageRuleListResponseWAFManagedRulesAnomalyRule{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule{}), + Type: reflect.TypeOf(WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule{}), + Type: reflect.TypeOf(WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule{}), }, ) } @@ -133,29 +231,29 @@ func init() { // score that will determine if a request is considered malicious. You can // configure the total scoring threshold through the 'sensitivity' property of the // WAF package. -type WAFManagedRulesRuleWAFManagedRulesAnomalyRule struct { +type WAFPackageRuleListResponseWAFManagedRulesAnomalyRule struct { // The unique identifier of the WAF rule. ID string `json:"id,required"` // Defines the available modes for the current WAF rule. Applies to anomaly // detection WAF rules. - AllowedModes []WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode `json:"allowed_modes,required"` + AllowedModes []AllowedModesAnomaly `json:"allowed_modes,required"` // The public description of the WAF rule. Description string `json:"description,required"` // The rule group to which the current WAF rule belongs. - Group WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup `json:"group,required"` + Group WAFRuleGroup `json:"group,required"` // When set to `on`, the current WAF rule will be used when evaluating the request. // Applies to anomaly detection WAF rules. - Mode WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode `json:"mode,required"` + Mode AllowedModesAnomaly `json:"mode,required"` // The unique identifier of a WAF package. PackageID string `json:"package_id,required"` // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON `json:"-"` + Priority string `json:"priority,required"` + JSON wafPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON `json:"-"` } -// wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON contains the JSON metadata for -// the struct [WAFManagedRulesRuleWAFManagedRulesAnomalyRule] -type wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON struct { +// wafPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON contains the JSON +// metadata for the struct [WAFPackageRuleListResponseWAFManagedRulesAnomalyRule] +type wafPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON struct { ID apijson.Field AllowedModes apijson.Field Description apijson.Field @@ -167,104 +265,46 @@ type wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFManagedRulesRuleWAFManagedRulesAnomalyRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON) RawJSON() string { - return r.raw -} - -func (r WAFManagedRulesRuleWAFManagedRulesAnomalyRule) implementsFirewallWAFManagedRulesRule() {} - -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode string - -const ( - WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedModeOn WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode = "on" - WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedModeOff WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode = "off" -) - -func (r WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode) IsKnown() bool { - switch r { - case WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedModeOn, WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedModeOff: - return true - } - return false -} - -// The rule group to which the current WAF rule belongs. -type WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON `json:"-"` -} - -// wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON contains the JSON -// metadata for the struct [WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup] -type wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageRuleListResponseWAFManagedRulesAnomalyRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON) RawJSON() string { +func (r wafPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON) RawJSON() string { return r.raw } -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode string - -const ( - WAFManagedRulesRuleWAFManagedRulesAnomalyRuleModeOn WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode = "on" - WAFManagedRulesRuleWAFManagedRulesAnomalyRuleModeOff WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode = "off" -) - -func (r WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode) IsKnown() bool { - switch r { - case WAFManagedRulesRuleWAFManagedRulesAnomalyRuleModeOn, WAFManagedRulesRuleWAFManagedRulesAnomalyRuleModeOff: - return true - } - return false +func (r WAFPackageRuleListResponseWAFManagedRulesAnomalyRule) implementsFirewallWAFPackageRuleListResponse() { } // When triggered, traditional WAF rules cause the firewall to immediately act upon // the request based on the configuration of the rule. A 'deny' rule will // immediately respond to the request based on the configured rule action/mode (for // example, 'block') and no other rules will be processed. -type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule struct { +type WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule struct { // The unique identifier of the WAF rule. ID string `json:"id,required"` // The list of possible actions of the WAF rule when it is triggered. - AllowedModes []WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode `json:"allowed_modes,required"` + AllowedModes []WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode `json:"allowed_modes,required"` // The default action/mode of a rule. - DefaultMode WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode `json:"default_mode,required"` + DefaultMode WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode `json:"default_mode,required"` // The public description of the WAF rule. Description string `json:"description,required"` // The rule group to which the current WAF rule belongs. - Group WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup `json:"group,required"` + Group WAFRuleGroup `json:"group,required"` // The action that the current WAF rule will perform when triggered. Applies to // traditional (deny) WAF rules. - Mode WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode `json:"mode,required"` + Mode WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode `json:"mode,required"` // The unique identifier of a WAF package. PackageID string `json:"package_id,required"` // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON `json:"-"` + Priority string `json:"priority,required"` + JSON wafPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON `json:"-"` } -// wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON contains the JSON -// metadata for the struct [WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule] -type wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON struct { +// wafPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON contains the +// JSON metadata for the struct +// [WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule] +type wafPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON struct { ID apijson.Field AllowedModes apijson.Field DefaultMode apijson.Field @@ -277,97 +317,70 @@ type wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON) RawJSON() string { +func (r wafPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON) RawJSON() string { return r.raw } -func (r WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule) implementsFirewallWAFManagedRulesRule() { +func (r WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule) implementsFirewallWAFPackageRuleListResponse() { } // The action that the current WAF rule will perform when triggered. Applies to // traditional (deny) WAF rules. -type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode string +type WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode string const ( - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeDefault WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "default" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeDisable WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "disable" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "simulate" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeBlock WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "block" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "challenge" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDefault WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "default" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDisable WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "disable" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "simulate" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeBlock WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "block" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "challenge" ) -func (r WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode) IsKnown() bool { +func (r WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode) IsKnown() bool { switch r { - case WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeDefault, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeDisable, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeBlock, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge: + case WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDefault, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDisable, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeBlock, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge: return true } return false } // The default action/mode of a rule. -type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode string +type WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode string const ( - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeDisable WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "disable" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "simulate" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeBlock WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "block" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "challenge" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeDisable WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "disable" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "simulate" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeBlock WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "block" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "challenge" ) -func (r WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode) IsKnown() bool { +func (r WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode) IsKnown() bool { switch r { - case WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeDisable, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeBlock, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge: + case WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeDisable, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeBlock, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge: return true } return false } -// The rule group to which the current WAF rule belongs. -type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON `json:"-"` -} - -// wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON contains the JSON -// metadata for the struct -// [WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup] -type wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON) RawJSON() string { - return r.raw -} - // The action that the current WAF rule will perform when triggered. Applies to // traditional (deny) WAF rules. -type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode string +type WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode string const ( - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeDefault WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "default" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeDisable WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "disable" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeSimulate WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "simulate" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeBlock WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "block" - WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeChallenge WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "challenge" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeDefault WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "default" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeDisable WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "disable" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeSimulate WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "simulate" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeBlock WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "block" + WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeChallenge WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "challenge" ) -func (r WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode) IsKnown() bool { +func (r WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode) IsKnown() bool { switch r { - case WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeDefault, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeDisable, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeSimulate, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeBlock, WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeChallenge: + case WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeDefault, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeDisable, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeSimulate, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeBlock, WAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeChallenge: return true } return false @@ -376,30 +389,33 @@ func (r WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode) IsKnown() boo // When triggered, traditional WAF rules cause the firewall to immediately act on // the request based on the rule configuration. An 'allow' rule will immediately // allow the request and no other rules will be processed. -type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule struct { +type WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule struct { // The unique identifier of the WAF rule. ID string `json:"id,required"` // Defines the available modes for the current WAF rule. - AllowedModes []WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode `json:"allowed_modes,required"` + AllowedModes []WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode `json:"allowed_modes,required"` + DefaultMode interface{} `json:"default_mode,required"` // The public description of the WAF rule. Description string `json:"description,required"` // The rule group to which the current WAF rule belongs. - Group WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup `json:"group,required"` + Group WAFRuleGroup `json:"group,required"` // When set to `on`, the current rule will be used when evaluating the request. // Applies to traditional (allow) WAF rules. - Mode WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode `json:"mode,required"` + Mode WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode `json:"mode,required"` // The unique identifier of a WAF package. PackageID string `json:"package_id,required"` // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON `json:"-"` + Priority string `json:"priority,required"` + JSON wafPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON `json:"-"` } -// wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON contains the JSON -// metadata for the struct [WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule] -type wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON struct { +// wafPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON contains the +// JSON metadata for the struct +// [WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule] +type wafPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON struct { ID apijson.Field AllowedModes apijson.Field + DefaultMode apijson.Field Description apijson.Field Group apijson.Field Mode apijson.Field @@ -409,78 +425,106 @@ type wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON struct { ExtraFields map[string]apijson.Field } -func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule) UnmarshalJSON(data []byte) (err error) { +func (r *WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON) RawJSON() string { +func (r wafPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON) RawJSON() string { return r.raw } -func (r WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule) implementsFirewallWAFManagedRulesRule() { +func (r WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule) implementsFirewallWAFPackageRuleListResponse() { } // When set to `on`, the current rule will be used when evaluating the request. // Applies to traditional (allow) WAF rules. -type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode string +type WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode string const ( - WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedModeOn WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode = "on" - WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedModeOff WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode = "off" + WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOn WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "on" + WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOff WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "off" ) -func (r WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode) IsKnown() bool { +func (r WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode) IsKnown() bool { switch r { - case WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedModeOn, WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedModeOff: + case WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOn, WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOff: return true } return false } -// The rule group to which the current WAF rule belongs. -type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON `json:"-"` -} - -// wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON contains the -// JSON metadata for the struct -// [WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup] -type wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON) RawJSON() string { - return r.raw -} - // When set to `on`, the current rule will be used when evaluating the request. // Applies to traditional (allow) WAF rules. -type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode string +type WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode string const ( - WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleModeOn WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode = "on" - WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleModeOff WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode = "off" + WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleModeOn WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode = "on" + WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleModeOff WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode = "off" ) -func (r WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode) IsKnown() bool { +func (r WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode) IsKnown() bool { switch r { - case WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleModeOn, WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleModeOff: + case WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleModeOn, WAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleModeOff: return true } return false } +// When triggered, anomaly detection WAF rules contribute to an overall threat +// score that will determine if a request is considered malicious. You can +// configure the total scoring threshold through the 'sensitivity' property of the +// WAF package. +type WAFPackageRuleEditResponse struct { + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFRuleGroup `json:"group,required"` + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + AllowedModes interface{} `json:"allowed_modes"` + // When set to `on`, the current WAF rule will be used when evaluating the request. + // Applies to anomaly detection WAF rules. + Mode AllowedModesAnomaly `json:"mode,required"` + DefaultMode interface{} `json:"default_mode,required"` + JSON wafPackageRuleEditResponseJSON `json:"-"` + union WAFPackageRuleEditResponseUnion +} + +// wafPackageRuleEditResponseJSON contains the JSON metadata for the struct +// [WAFPackageRuleEditResponse] +type wafPackageRuleEditResponseJSON struct { + Description apijson.Field + Group apijson.Field + ID apijson.Field + PackageID apijson.Field + Priority apijson.Field + AllowedModes apijson.Field + Mode apijson.Field + DefaultMode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r wafPackageRuleEditResponseJSON) RawJSON() string { + return r.raw +} + +func (r *WAFPackageRuleEditResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r WAFPackageRuleEditResponse) AsUnion() WAFPackageRuleEditResponseUnion { + return r.union +} + // When triggered, anomaly detection WAF rules contribute to an overall threat // score that will determine if a request is considered malicious. You can // configure the total scoring threshold through the 'sensitivity' property of the @@ -490,13 +534,13 @@ func (r WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode) IsKnown() bo // [firewall.WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule], // [firewall.WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule] or // [firewall.WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule]. -type WAFPackageRuleEditResponse interface { +type WAFPackageRuleEditResponseUnion interface { implementsFirewallWAFPackageRuleEditResponse() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageRuleEditResponse)(nil)).Elem(), + reflect.TypeOf((*WAFPackageRuleEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -522,14 +566,14 @@ type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule struct { ID string `json:"id,required"` // Defines the available modes for the current WAF rule. Applies to anomaly // detection WAF rules. - AllowedModes []WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode `json:"allowed_modes,required"` + AllowedModes []AllowedModesAnomaly `json:"allowed_modes,required"` // The public description of the WAF rule. Description string `json:"description,required"` // The rule group to which the current WAF rule belongs. - Group WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup `json:"group,required"` + Group WAFRuleGroup `json:"group,required"` // When set to `on`, the current WAF rule will be used when evaluating the request. // Applies to anomaly detection WAF rules. - Mode WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode `json:"mode,required"` + Mode AllowedModesAnomaly `json:"mode,required"` // The unique identifier of a WAF package. PackageID string `json:"package_id,required"` // The order in which the individual WAF rule is executed within its rule group. @@ -562,67 +606,6 @@ func (r wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON) RawJSON() stri func (r WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule) implementsFirewallWAFPackageRuleEditResponse() { } -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode string - -const ( - WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOn WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode = "on" - WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOff WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode = "off" -) - -func (r WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode) IsKnown() bool { - switch r { - case WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOn, WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOff: - return true - } - return false -} - -// The rule group to which the current WAF rule belongs. -type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON `json:"-"` -} - -// wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON contains the JSON -// metadata for the struct -// [WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup] -type wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON) RawJSON() string { - return r.raw -} - -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode string - -const ( - WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOn WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode = "on" - WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOff WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode = "off" -) - -func (r WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode) IsKnown() bool { - switch r { - case WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOn, WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOff: - return true - } - return false -} - // When triggered, traditional WAF rules cause the firewall to immediately act upon // the request based on the configuration of the rule. A 'deny' rule will // immediately respond to the request based on the configured rule action/mode (for @@ -637,7 +620,7 @@ type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule struct { // The public description of the WAF rule. Description string `json:"description,required"` // The rule group to which the current WAF rule belongs. - Group WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup `json:"group,required"` + Group WAFRuleGroup `json:"group,required"` // The action that the current WAF rule will perform when triggered. Applies to // traditional (deny) WAF rules. Mode WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode `json:"mode,required"` @@ -713,33 +696,6 @@ func (r WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode) return false } -// The rule group to which the current WAF rule belongs. -type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON `json:"-"` -} - -// wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON contains -// the JSON metadata for the struct -// [WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup] -type wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON) RawJSON() string { - return r.raw -} - // The action that the current WAF rule will perform when triggered. Applies to // traditional (deny) WAF rules. type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode string @@ -768,10 +724,11 @@ type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule struct { ID string `json:"id,required"` // Defines the available modes for the current WAF rule. AllowedModes []WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode `json:"allowed_modes,required"` + DefaultMode interface{} `json:"default_mode,required"` // The public description of the WAF rule. Description string `json:"description,required"` // The rule group to which the current WAF rule belongs. - Group WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup `json:"group,required"` + Group WAFRuleGroup `json:"group,required"` // When set to `on`, the current rule will be used when evaluating the request. // Applies to traditional (allow) WAF rules. Mode WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode `json:"mode,required"` @@ -788,6 +745,7 @@ type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule struct { type wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON struct { ID apijson.Field AllowedModes apijson.Field + DefaultMode apijson.Field Description apijson.Field Group apijson.Field Mode apijson.Field @@ -825,33 +783,6 @@ func (r WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode return false } -// The rule group to which the current WAF rule belongs. -type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON `json:"-"` -} - -// wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON contains -// the JSON metadata for the struct -// [WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup] -type wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON) RawJSON() string { - return r.raw -} - // When set to `on`, the current rule will be used when evaluating the request. // Applies to traditional (allow) WAF rules. type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode string @@ -869,20 +800,16 @@ func (r WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode) IsKno return false } -// Union satisfied by [firewall.WAFPackageRuleGetResponseUnknown], -// [firewall.WAFPackageRuleGetResponseArray] or [shared.UnionString]. -type WAFPackageRuleGetResponse interface { - ImplementsFirewallWAFPackageRuleGetResponse() +// Union satisfied by [firewall.WAFPackageRuleGetResponseUnknown] or +// [shared.UnionString]. +type WAFPackageRuleGetResponseUnion interface { + ImplementsFirewallWAFPackageRuleGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WAFPackageRuleGetResponse)(nil)).Elem(), + reflect.TypeOf((*WAFPackageRuleGetResponseUnion)(nil)).Elem(), "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WAFPackageRuleGetResponseArray{}), - }, apijson.UnionVariant{ TypeFilter: gjson.String, Type: reflect.TypeOf(shared.UnionString("")), @@ -890,15 +817,15 @@ func init() { ) } -type WAFPackageRuleGetResponseArray []interface{} - -func (r WAFPackageRuleGetResponseArray) ImplementsFirewallWAFPackageRuleGetResponse() {} - type WAFPackageRuleListParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + // The public description of the WAF rule. + Description param.Field[string] `query:"description"` // The direction used to sort returned rules. Direction param.Field[WAFPackageRuleListParamsDirection] `query:"direction"` + // The unique identifier of the rule group. + GroupID param.Field[string] `query:"group_id"` // 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[WAFPackageRuleListParamsMatch] `query:"match"` @@ -910,13 +837,15 @@ type WAFPackageRuleListParams struct { Page param.Field[float64] `query:"page"` // The number of rules per page. PerPage param.Field[float64] `query:"per_page"` + // The order in which the individual WAF rule is executed within its rule group. + Priority param.Field[string] `query:"priority"` } // URLQuery serializes [WAFPackageRuleListParams]'s query parameters as // `url.Values`. func (r WAFPackageRuleListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1024,8 +953,8 @@ func (r WAFPackageRuleEditParamsMode) IsKnown() bool { } type WAFPackageRuleEditResponseEnvelope struct { - Errors []WAFPackageRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []WAFPackageRuleEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // When triggered, anomaly detection WAF rules contribute to an overall threat // score that will determine if a request is considered malicious. You can // configure the total scoring threshold through the 'sensitivity' property of the @@ -1055,52 +984,6 @@ func (r wafPackageRuleEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WAFPackageRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// wafPackageRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WAFPackageRuleEditResponseEnvelopeErrors] -type wafPackageRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WAFPackageRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// wafPackageRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WAFPackageRuleEditResponseEnvelopeMessages] -type wafPackageRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WAFPackageRuleEditResponseEnvelopeSuccess bool @@ -1122,9 +1005,9 @@ type WAFPackageRuleGetParams struct { } type WAFPackageRuleGetResponseEnvelope struct { - Errors []WAFPackageRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WAFPackageRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result WAFPackageRuleGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WAFPackageRuleGetResponseUnion `json:"result,required"` // Whether the API call was successful Success WAFPackageRuleGetResponseEnvelopeSuccess `json:"success,required"` JSON wafPackageRuleGetResponseEnvelopeJSON `json:"-"` @@ -1149,52 +1032,6 @@ func (r wafPackageRuleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WAFPackageRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// wafPackageRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WAFPackageRuleGetResponseEnvelopeErrors] -type wafPackageRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WAFPackageRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON wafPackageRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// wafPackageRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WAFPackageRuleGetResponseEnvelopeMessages] -type wafPackageRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WAFPackageRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r wafPackageRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WAFPackageRuleGetResponseEnvelopeSuccess bool diff --git a/firewall/wafpackagerule_test.go b/firewall/wafpackagerule_test.go index 35223a5b2b7..1cdf79b6960 100644 --- a/firewall/wafpackagerule_test.go +++ b/firewall/wafpackagerule_test.go @@ -32,13 +32,16 @@ func TestWAFPackageRuleListWithOptionalParams(t *testing.T) { context.TODO(), "a25a9a7e9c00afc1fb2e0245519d725b", firewall.WAFPackageRuleListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(firewall.WAFPackageRuleListParamsDirectionDesc), - Match: cloudflare.F(firewall.WAFPackageRuleListParamsMatchAny), - Mode: cloudflare.F(firewall.WAFPackageRuleListParamsModeChl), - Order: cloudflare.F(firewall.WAFPackageRuleListParamsOrderPriority), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Description: cloudflare.F("SQL injection prevention for SELECT statements"), + Direction: cloudflare.F(firewall.WAFPackageRuleListParamsDirectionDesc), + GroupID: cloudflare.F("de677e5818985db1285d0e80225f06e5"), + Match: cloudflare.F(firewall.WAFPackageRuleListParamsMatchAny), + Mode: cloudflare.F(firewall.WAFPackageRuleListParamsModeChl), + Order: cloudflare.F(firewall.WAFPackageRuleListParamsOrderPriority), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + Priority: cloudflare.F("string"), }, ) if err != nil { diff --git a/healthchecks/aliases.go b/healthchecks/aliases.go index 389e438abc1..cf9bc24b819 100644 --- a/healthchecks/aliases.go +++ b/healthchecks/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/healthchecks/healthcheck.go b/healthchecks/healthcheck.go index a9572eed7a6..867246819cf 100644 --- a/healthchecks/healthcheck.go +++ b/healthchecks/healthcheck.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -85,10 +86,10 @@ func (r *HealthcheckService) ListAutoPaging(ctx context.Context, query Healthche } // Delete a health check. -func (r *HealthcheckService) Delete(ctx context.Context, healthcheckID string, body HealthcheckDeleteParams, opts ...option.RequestOption) (res *HealthcheckDeleteResponse, err error) { +func (r *HealthcheckService) Delete(ctx context.Context, healthcheckID string, params HealthcheckDeleteParams, opts ...option.RequestOption) (res *HealthcheckDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env HealthcheckDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/%s", body.ZoneID, healthcheckID) + path := fmt.Sprintf("zones/%s/healthchecks/%s", params.ZoneID, healthcheckID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -123,6 +124,38 @@ func (r *HealthcheckService) Get(ctx context.Context, healthcheckID string, quer return } +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, +// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS +// and ENTERPRISE customers only). +type CheckRegion string + +const ( + CheckRegionWnam CheckRegion = "WNAM" + CheckRegionEnam CheckRegion = "ENAM" + CheckRegionWeu CheckRegion = "WEU" + CheckRegionEeu CheckRegion = "EEU" + CheckRegionNsam CheckRegion = "NSAM" + CheckRegionSsam CheckRegion = "SSAM" + CheckRegionOc CheckRegion = "OC" + CheckRegionMe CheckRegion = "ME" + CheckRegionNaf CheckRegion = "NAF" + CheckRegionSaf CheckRegion = "SAF" + CheckRegionIn CheckRegion = "IN" + CheckRegionSeas CheckRegion = "SEAS" + CheckRegionNeas CheckRegion = "NEAS" + CheckRegionAllRegions CheckRegion = "ALL_REGIONS" +) + +func (r CheckRegion) IsKnown() bool { + switch r { + case CheckRegionWnam, CheckRegionEnam, CheckRegionWeu, CheckRegionEeu, CheckRegionNsam, CheckRegionSsam, CheckRegionOc, CheckRegionMe, CheckRegionNaf, CheckRegionSaf, CheckRegionIn, CheckRegionSeas, CheckRegionNeas, CheckRegionAllRegions: + return true + } + return false +} + type Healthcheck struct { // Identifier ID string `json:"id"` @@ -130,7 +163,7 @@ type Healthcheck struct { Address string `json:"address"` // A list of regions from which to run health checks. Null means Cloudflare will // pick a default region. - CheckRegions []HealthcheckCheckRegion `json:"check_regions,nullable"` + CheckRegions []CheckRegion `json:"check_regions,nullable"` // The number of consecutive fails required from a health check before changing the // health to unhealthy. ConsecutiveFails int64 `json:"consecutive_fails"` @@ -143,7 +176,7 @@ type Healthcheck struct { // The current failure reason if status is unhealthy. FailureReason string `json:"failure_reason"` // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckHTTPConfig `json:"http_config,nullable"` + HTTPConfig HTTPConfiguration `json:"http_config,nullable"` // The interval between each health check. Shorter intervals may give quicker // notifications if the origin status changes, but will increase load on the origin // as we check from multiple locations. @@ -160,7 +193,7 @@ type Healthcheck struct { // If suspended, no health checks are sent to the origin. Suspended bool `json:"suspended"` // Parameters specific to TCP health check. - TcpConfig HealthcheckTcpConfig `json:"tcp_config,nullable"` + TCPConfig TCPConfiguration `json:"tcp_config,nullable"` // 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 @@ -186,7 +219,7 @@ type healthcheckJSON struct { Retries apijson.Field Status apijson.Field Suspended apijson.Field - TcpConfig apijson.Field + TCPConfig apijson.Field Timeout apijson.Field Type apijson.Field raw string @@ -201,40 +234,26 @@ func (r healthcheckJSON) RawJSON() string { return r.raw } -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckCheckRegion string +// The current status of the origin server according to the health check. +type HealthcheckStatus string const ( - HealthcheckCheckRegionWnam HealthcheckCheckRegion = "WNAM" - HealthcheckCheckRegionEnam HealthcheckCheckRegion = "ENAM" - HealthcheckCheckRegionWeu HealthcheckCheckRegion = "WEU" - HealthcheckCheckRegionEeu HealthcheckCheckRegion = "EEU" - HealthcheckCheckRegionNsam HealthcheckCheckRegion = "NSAM" - HealthcheckCheckRegionSsam HealthcheckCheckRegion = "SSAM" - HealthcheckCheckRegionOc HealthcheckCheckRegion = "OC" - HealthcheckCheckRegionMe HealthcheckCheckRegion = "ME" - HealthcheckCheckRegionNaf HealthcheckCheckRegion = "NAF" - HealthcheckCheckRegionSaf HealthcheckCheckRegion = "SAF" - HealthcheckCheckRegionIn HealthcheckCheckRegion = "IN" - HealthcheckCheckRegionSeas HealthcheckCheckRegion = "SEAS" - HealthcheckCheckRegionNeas HealthcheckCheckRegion = "NEAS" - HealthcheckCheckRegionAllRegions HealthcheckCheckRegion = "ALL_REGIONS" + HealthcheckStatusUnknown HealthcheckStatus = "unknown" + HealthcheckStatusHealthy HealthcheckStatus = "healthy" + HealthcheckStatusUnhealthy HealthcheckStatus = "unhealthy" + HealthcheckStatusSuspended HealthcheckStatus = "suspended" ) -func (r HealthcheckCheckRegion) IsKnown() bool { +func (r HealthcheckStatus) IsKnown() bool { switch r { - case HealthcheckCheckRegionWnam, HealthcheckCheckRegionEnam, HealthcheckCheckRegionWeu, HealthcheckCheckRegionEeu, HealthcheckCheckRegionNsam, HealthcheckCheckRegionSsam, HealthcheckCheckRegionOc, HealthcheckCheckRegionMe, HealthcheckCheckRegionNaf, HealthcheckCheckRegionSaf, HealthcheckCheckRegionIn, HealthcheckCheckRegionSeas, HealthcheckCheckRegionNeas, HealthcheckCheckRegionAllRegions: + case HealthcheckStatusUnknown, HealthcheckStatusHealthy, HealthcheckStatusUnhealthy, HealthcheckStatusSuspended: return true } return false } // Parameters specific to an HTTP or HTTPS health check. -type HealthcheckHTTPConfig struct { +type HTTPConfiguration struct { // Do not validate the certificate when the health check uses HTTPS. AllowInsecure bool `json:"allow_insecure"` // A case-insensitive sub-string to look for in the response body. If this string @@ -249,18 +268,18 @@ type HealthcheckHTTPConfig struct { // a Host header by default. The User-Agent header cannot be overridden. Header interface{} `json:"header,nullable"` // The HTTP method to use for the health check. - Method HealthcheckHTTPConfigMethod `json:"method"` + Method HTTPConfigurationMethod `json:"method"` // The endpoint path to health check against. Path string `json:"path"` // Port number to connect to for the health check. Defaults to 80 if type is HTTP // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckHTTPConfigJSON `json:"-"` + Port int64 `json:"port"` + JSON httpConfigurationJSON `json:"-"` } -// healthcheckHTTPConfigJSON contains the JSON metadata for the struct -// [HealthcheckHTTPConfig] -type healthcheckHTTPConfigJSON struct { +// httpConfigurationJSON contains the JSON metadata for the struct +// [HTTPConfiguration] +type httpConfigurationJSON struct { AllowInsecure apijson.Field ExpectedBody apijson.Field ExpectedCodes apijson.Field @@ -273,114 +292,59 @@ type healthcheckHTTPConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *HealthcheckHTTPConfig) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r healthcheckHTTPConfigJSON) RawJSON() string { +func (r httpConfigurationJSON) RawJSON() string { return r.raw } // The HTTP method to use for the health check. -type HealthcheckHTTPConfigMethod string - -const ( - HealthcheckHTTPConfigMethodGet HealthcheckHTTPConfigMethod = "GET" - HealthcheckHTTPConfigMethodHead HealthcheckHTTPConfigMethod = "HEAD" -) - -func (r HealthcheckHTTPConfigMethod) IsKnown() bool { - switch r { - case HealthcheckHTTPConfigMethodGet, HealthcheckHTTPConfigMethodHead: - return true - } - return false -} - -// The current status of the origin server according to the health check. -type HealthcheckStatus string - -const ( - HealthcheckStatusUnknown HealthcheckStatus = "unknown" - HealthcheckStatusHealthy HealthcheckStatus = "healthy" - HealthcheckStatusUnhealthy HealthcheckStatus = "unhealthy" - HealthcheckStatusSuspended HealthcheckStatus = "suspended" -) - -func (r HealthcheckStatus) IsKnown() bool { - switch r { - case HealthcheckStatusUnknown, HealthcheckStatusHealthy, HealthcheckStatusUnhealthy, HealthcheckStatusSuspended: - return true - } - return false -} - -// Parameters specific to TCP health check. -type HealthcheckTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckTcpConfigJSON `json:"-"` -} - -// healthcheckTcpConfigJSON contains the JSON metadata for the struct -// [HealthcheckTcpConfig] -type healthcheckTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckTcpConfigMethod string +type HTTPConfigurationMethod string const ( - HealthcheckTcpConfigMethodConnectionEstablished HealthcheckTcpConfigMethod = "connection_established" + HTTPConfigurationMethodGet HTTPConfigurationMethod = "GET" + HTTPConfigurationMethodHead HTTPConfigurationMethod = "HEAD" ) -func (r HealthcheckTcpConfigMethod) IsKnown() bool { +func (r HTTPConfigurationMethod) IsKnown() bool { switch r { - case HealthcheckTcpConfigMethodConnectionEstablished: + case HTTPConfigurationMethodGet, HTTPConfigurationMethodHead: return true } return false } -type HealthcheckDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON healthcheckDeleteResponseJSON `json:"-"` -} - -// healthcheckDeleteResponseJSON contains the JSON metadata for the struct -// [HealthcheckDeleteResponse] -type healthcheckDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Parameters specific to an HTTP or HTTPS health check. +type HTTPConfigurationParam struct { + // Do not validate the certificate when the health check uses HTTPS. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // 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. + ExpectedBody param.Field[string] `json:"expected_body"` + // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all + // codes starting with 2) of the health check. + ExpectedCodes param.Field[[]string] `json:"expected_codes"` + // Follow redirects if the origin returns a 3xx status code. + 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. + Header param.Field[interface{}] `json:"header"` + // The HTTP method to use for the health check. + Method param.Field[HTTPConfigurationMethod] `json:"method"` + // The endpoint path to health check against. + Path param.Field[string] `json:"path"` + // Port number to connect to for the health check. Defaults to 80 if type is HTTP + // or 443 if type is HTTPS. + Port param.Field[int64] `json:"port"` } -func (r healthcheckDeleteResponseJSON) RawJSON() string { - return r.raw +func (r HTTPConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type HealthcheckNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` +type QueryHealthcheckParam struct { // The hostname or IP address of the origin server to run health checks on. Address param.Field[string] `json:"address,required"` // A short name to identify the health check. Only alphanumeric characters, hyphens @@ -388,7 +352,7 @@ type HealthcheckNewParams struct { Name param.Field[string] `json:"name,required"` // A list of regions from which to run health checks. Null means Cloudflare will // pick a default region. - CheckRegions param.Field[[]HealthcheckNewParamsCheckRegion] `json:"check_regions"` + CheckRegions param.Field[[]CheckRegion] `json:"check_regions"` // The number of consecutive fails required from a health check before changing the // health to unhealthy. ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` @@ -398,7 +362,7 @@ type HealthcheckNewParams struct { // A human-readable description of the health check. Description param.Field[string] `json:"description"` // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[HealthcheckNewParamsHTTPConfig] `json:"http_config"` + HTTPConfig param.Field[HTTPConfigurationParam] `json:"http_config"` // The interval between each health check. Shorter intervals may give quicker // notifications if the origin status changes, but will increase load on the origin // as we check from multiple locations. @@ -409,7 +373,7 @@ type HealthcheckNewParams struct { // If suspended, no health checks are sent to the origin. Suspended param.Field[bool] `json:"suspended"` // Parameters specific to TCP health check. - TcpConfig param.Field[HealthcheckNewParamsTcpConfig] `json:"tcp_config"` + TCPConfig param.Field[TCPConfigurationParam] `json:"tcp_config"` // 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 @@ -417,117 +381,99 @@ type HealthcheckNewParams struct { Type param.Field[string] `json:"type"` } -func (r HealthcheckNewParams) MarshalJSON() (data []byte, err error) { +func (r QueryHealthcheckParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckNewParamsCheckRegion string - -const ( - HealthcheckNewParamsCheckRegionWnam HealthcheckNewParamsCheckRegion = "WNAM" - HealthcheckNewParamsCheckRegionEnam HealthcheckNewParamsCheckRegion = "ENAM" - HealthcheckNewParamsCheckRegionWeu HealthcheckNewParamsCheckRegion = "WEU" - HealthcheckNewParamsCheckRegionEeu HealthcheckNewParamsCheckRegion = "EEU" - HealthcheckNewParamsCheckRegionNsam HealthcheckNewParamsCheckRegion = "NSAM" - HealthcheckNewParamsCheckRegionSsam HealthcheckNewParamsCheckRegion = "SSAM" - HealthcheckNewParamsCheckRegionOc HealthcheckNewParamsCheckRegion = "OC" - HealthcheckNewParamsCheckRegionMe HealthcheckNewParamsCheckRegion = "ME" - HealthcheckNewParamsCheckRegionNaf HealthcheckNewParamsCheckRegion = "NAF" - HealthcheckNewParamsCheckRegionSaf HealthcheckNewParamsCheckRegion = "SAF" - HealthcheckNewParamsCheckRegionIn HealthcheckNewParamsCheckRegion = "IN" - HealthcheckNewParamsCheckRegionSeas HealthcheckNewParamsCheckRegion = "SEAS" - HealthcheckNewParamsCheckRegionNeas HealthcheckNewParamsCheckRegion = "NEAS" - HealthcheckNewParamsCheckRegionAllRegions HealthcheckNewParamsCheckRegion = "ALL_REGIONS" -) +// Parameters specific to TCP health check. +type TCPConfiguration struct { + // The TCP connection method to use for the health check. + Method TCPConfigurationMethod `json:"method"` + // Port number to connect to for the health check. Defaults to 80. + Port int64 `json:"port"` + JSON tcpConfigurationJSON `json:"-"` +} -func (r HealthcheckNewParamsCheckRegion) IsKnown() bool { - switch r { - case HealthcheckNewParamsCheckRegionWnam, HealthcheckNewParamsCheckRegionEnam, HealthcheckNewParamsCheckRegionWeu, HealthcheckNewParamsCheckRegionEeu, HealthcheckNewParamsCheckRegionNsam, HealthcheckNewParamsCheckRegionSsam, HealthcheckNewParamsCheckRegionOc, HealthcheckNewParamsCheckRegionMe, HealthcheckNewParamsCheckRegionNaf, HealthcheckNewParamsCheckRegionSaf, HealthcheckNewParamsCheckRegionIn, HealthcheckNewParamsCheckRegionSeas, HealthcheckNewParamsCheckRegionNeas, HealthcheckNewParamsCheckRegionAllRegions: - return true - } - return false +// tcpConfigurationJSON contains the JSON metadata for the struct +// [TCPConfiguration] +type tcpConfigurationJSON struct { + Method apijson.Field + Port apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckNewParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // 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. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - 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. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[HealthcheckNewParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` +func (r *TCPConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r HealthcheckNewParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r tcpConfigurationJSON) RawJSON() string { + return r.raw } -// The HTTP method to use for the health check. -type HealthcheckNewParamsHTTPConfigMethod string +// The TCP connection method to use for the health check. +type TCPConfigurationMethod string const ( - HealthcheckNewParamsHTTPConfigMethodGet HealthcheckNewParamsHTTPConfigMethod = "GET" - HealthcheckNewParamsHTTPConfigMethodHead HealthcheckNewParamsHTTPConfigMethod = "HEAD" + TCPConfigurationMethodConnectionEstablished TCPConfigurationMethod = "connection_established" ) -func (r HealthcheckNewParamsHTTPConfigMethod) IsKnown() bool { +func (r TCPConfigurationMethod) IsKnown() bool { switch r { - case HealthcheckNewParamsHTTPConfigMethodGet, HealthcheckNewParamsHTTPConfigMethodHead: + case TCPConfigurationMethodConnectionEstablished: return true } return false } // Parameters specific to TCP health check. -type HealthcheckNewParamsTcpConfig struct { +type TCPConfigurationParam struct { // The TCP connection method to use for the health check. - Method param.Field[HealthcheckNewParamsTcpConfigMethod] `json:"method"` + Method param.Field[TCPConfigurationMethod] `json:"method"` // Port number to connect to for the health check. Defaults to 80. Port param.Field[int64] `json:"port"` } -func (r HealthcheckNewParamsTcpConfig) MarshalJSON() (data []byte, err error) { +func (r TCPConfigurationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The TCP connection method to use for the health check. -type HealthcheckNewParamsTcpConfigMethod string +type HealthcheckDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON healthcheckDeleteResponseJSON `json:"-"` +} -const ( - HealthcheckNewParamsTcpConfigMethodConnectionEstablished HealthcheckNewParamsTcpConfigMethod = "connection_established" -) +// healthcheckDeleteResponseJSON contains the JSON metadata for the struct +// [HealthcheckDeleteResponse] +type healthcheckDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -func (r HealthcheckNewParamsTcpConfigMethod) IsKnown() bool { - switch r { - case HealthcheckNewParamsTcpConfigMethodConnectionEstablished: - return true - } - return false +func (r *HealthcheckDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type HealthcheckNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + QueryHealthcheck QueryHealthcheckParam `json:"query_healthcheck,required"` +} + +func (r HealthcheckNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.QueryHealthcheck) } type HealthcheckNewResponseEnvelope struct { - Errors []HealthcheckNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckNewResponseEnvelopeMessages `json:"messages,required"` - Result Healthcheck `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Healthcheck `json:"result,required"` // Whether the API call was successful Success HealthcheckNewResponseEnvelopeSuccess `json:"success,required"` JSON healthcheckNewResponseEnvelopeJSON `json:"-"` @@ -552,316 +498,93 @@ func (r healthcheckNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HealthcheckNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckNewResponseEnvelopeErrorsJSON `json:"-"` -} +// Whether the API call was successful +type HealthcheckNewResponseEnvelopeSuccess bool -// healthcheckNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckNewResponseEnvelopeErrors] -type healthcheckNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +const ( + HealthcheckNewResponseEnvelopeSuccessTrue HealthcheckNewResponseEnvelopeSuccess = true +) + +func (r HealthcheckNewResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case HealthcheckNewResponseEnvelopeSuccessTrue: + return true + } + return false } -func (r *HealthcheckNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type HealthcheckUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + QueryHealthcheck QueryHealthcheckParam `json:"query_healthcheck,required"` } -func (r healthcheckNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw +func (r HealthcheckUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.QueryHealthcheck) } -type HealthcheckNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckNewResponseEnvelopeMessagesJSON `json:"-"` +type HealthcheckUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Healthcheck `json:"result,required"` + // Whether the API call was successful + Success HealthcheckUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON healthcheckUpdateResponseEnvelopeJSON `json:"-"` } -// healthcheckNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckNewResponseEnvelopeMessages] -type healthcheckNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field +// healthcheckUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [HealthcheckUpdateResponseEnvelope] +type healthcheckUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *HealthcheckNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *HealthcheckUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r healthcheckNewResponseEnvelopeMessagesJSON) RawJSON() string { +func (r healthcheckUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } // Whether the API call was successful -type HealthcheckNewResponseEnvelopeSuccess bool +type HealthcheckUpdateResponseEnvelopeSuccess bool const ( - HealthcheckNewResponseEnvelopeSuccessTrue HealthcheckNewResponseEnvelopeSuccess = true + HealthcheckUpdateResponseEnvelopeSuccessTrue HealthcheckUpdateResponseEnvelopeSuccess = true ) -func (r HealthcheckNewResponseEnvelopeSuccess) IsKnown() bool { +func (r HealthcheckUpdateResponseEnvelopeSuccess) IsKnown() bool { switch r { - case HealthcheckNewResponseEnvelopeSuccessTrue: + case HealthcheckUpdateResponseEnvelopeSuccessTrue: return true } return false } -type HealthcheckUpdateParams struct { +type HealthcheckListParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` - // The hostname or IP address of the origin server to run health checks on. - Address param.Field[string] `json:"address,required"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions param.Field[[]HealthcheckUpdateParamsCheckRegion] `json:"check_regions"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` - // A human-readable description of the health check. - Description param.Field[string] `json:"description"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[HealthcheckUpdateParamsHTTPConfig] `json:"http_config"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // 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"` - // If suspended, no health checks are sent to the origin. - Suspended param.Field[bool] `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig param.Field[HealthcheckUpdateParamsTcpConfig] `json:"tcp_config"` - // 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' and 'TCP'. - Type param.Field[string] `json:"type"` -} - -func (r HealthcheckUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckUpdateParamsCheckRegion string - -const ( - HealthcheckUpdateParamsCheckRegionWnam HealthcheckUpdateParamsCheckRegion = "WNAM" - HealthcheckUpdateParamsCheckRegionEnam HealthcheckUpdateParamsCheckRegion = "ENAM" - HealthcheckUpdateParamsCheckRegionWeu HealthcheckUpdateParamsCheckRegion = "WEU" - HealthcheckUpdateParamsCheckRegionEeu HealthcheckUpdateParamsCheckRegion = "EEU" - HealthcheckUpdateParamsCheckRegionNsam HealthcheckUpdateParamsCheckRegion = "NSAM" - HealthcheckUpdateParamsCheckRegionSsam HealthcheckUpdateParamsCheckRegion = "SSAM" - HealthcheckUpdateParamsCheckRegionOc HealthcheckUpdateParamsCheckRegion = "OC" - HealthcheckUpdateParamsCheckRegionMe HealthcheckUpdateParamsCheckRegion = "ME" - HealthcheckUpdateParamsCheckRegionNaf HealthcheckUpdateParamsCheckRegion = "NAF" - HealthcheckUpdateParamsCheckRegionSaf HealthcheckUpdateParamsCheckRegion = "SAF" - HealthcheckUpdateParamsCheckRegionIn HealthcheckUpdateParamsCheckRegion = "IN" - HealthcheckUpdateParamsCheckRegionSeas HealthcheckUpdateParamsCheckRegion = "SEAS" - HealthcheckUpdateParamsCheckRegionNeas HealthcheckUpdateParamsCheckRegion = "NEAS" - HealthcheckUpdateParamsCheckRegionAllRegions HealthcheckUpdateParamsCheckRegion = "ALL_REGIONS" -) - -func (r HealthcheckUpdateParamsCheckRegion) IsKnown() bool { - switch r { - case HealthcheckUpdateParamsCheckRegionWnam, HealthcheckUpdateParamsCheckRegionEnam, HealthcheckUpdateParamsCheckRegionWeu, HealthcheckUpdateParamsCheckRegionEeu, HealthcheckUpdateParamsCheckRegionNsam, HealthcheckUpdateParamsCheckRegionSsam, HealthcheckUpdateParamsCheckRegionOc, HealthcheckUpdateParamsCheckRegionMe, HealthcheckUpdateParamsCheckRegionNaf, HealthcheckUpdateParamsCheckRegionSaf, HealthcheckUpdateParamsCheckRegionIn, HealthcheckUpdateParamsCheckRegionSeas, HealthcheckUpdateParamsCheckRegionNeas, HealthcheckUpdateParamsCheckRegionAllRegions: - return true - } - return false -} - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckUpdateParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // 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. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - 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. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[HealthcheckUpdateParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckUpdateParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The HTTP method to use for the health check. -type HealthcheckUpdateParamsHTTPConfigMethod string - -const ( - HealthcheckUpdateParamsHTTPConfigMethodGet HealthcheckUpdateParamsHTTPConfigMethod = "GET" - HealthcheckUpdateParamsHTTPConfigMethodHead HealthcheckUpdateParamsHTTPConfigMethod = "HEAD" -) - -func (r HealthcheckUpdateParamsHTTPConfigMethod) IsKnown() bool { - switch r { - case HealthcheckUpdateParamsHTTPConfigMethodGet, HealthcheckUpdateParamsHTTPConfigMethodHead: - return true - } - return false -} - -// Parameters specific to TCP health check. -type HealthcheckUpdateParamsTcpConfig struct { - // The TCP connection method to use for the health check. - Method param.Field[HealthcheckUpdateParamsTcpConfigMethod] `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port param.Field[int64] `json:"port"` } -func (r HealthcheckUpdateParamsTcpConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TCP connection method to use for the health check. -type HealthcheckUpdateParamsTcpConfigMethod string - -const ( - HealthcheckUpdateParamsTcpConfigMethodConnectionEstablished HealthcheckUpdateParamsTcpConfigMethod = "connection_established" -) - -func (r HealthcheckUpdateParamsTcpConfigMethod) IsKnown() bool { - switch r { - case HealthcheckUpdateParamsTcpConfigMethodConnectionEstablished: - return true - } - return false -} - -type HealthcheckUpdateResponseEnvelope struct { - Errors []HealthcheckUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckUpdateResponseEnvelopeMessages `json:"messages,required"` - Result Healthcheck `json:"result,required"` - // Whether the API call was successful - Success HealthcheckUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckUpdateResponseEnvelopeJSON `json:"-"` -} - -// healthcheckUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [HealthcheckUpdateResponseEnvelope] -type healthcheckUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckUpdateResponseEnvelopeErrors] -type healthcheckUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckUpdateResponseEnvelopeMessages] -type healthcheckUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckUpdateResponseEnvelopeSuccess bool - -const ( - HealthcheckUpdateResponseEnvelopeSuccessTrue HealthcheckUpdateResponseEnvelopeSuccess = true -) - -func (r HealthcheckUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case HealthcheckUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type HealthcheckListParams struct { +type HealthcheckDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` } -type HealthcheckDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` +func (r HealthcheckDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type HealthcheckDeleteResponseEnvelope struct { - Errors []HealthcheckDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HealthcheckDeleteResponse `json:"result,required"` // Whether the API call was successful Success HealthcheckDeleteResponseEnvelopeSuccess `json:"success,required"` JSON healthcheckDeleteResponseEnvelopeJSON `json:"-"` @@ -886,52 +609,6 @@ func (r healthcheckDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HealthcheckDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckDeleteResponseEnvelopeErrors] -type healthcheckDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckDeleteResponseEnvelopeMessages] -type healthcheckDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HealthcheckDeleteResponseEnvelopeSuccess bool @@ -949,154 +626,18 @@ func (r HealthcheckDeleteResponseEnvelopeSuccess) IsKnown() bool { type HealthcheckEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The hostname or IP address of the origin server to run health checks on. - Address param.Field[string] `json:"address,required"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions param.Field[[]HealthcheckEditParamsCheckRegion] `json:"check_regions"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` - // A human-readable description of the health check. - Description param.Field[string] `json:"description"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[HealthcheckEditParamsHTTPConfig] `json:"http_config"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // 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"` - // If suspended, no health checks are sent to the origin. - Suspended param.Field[bool] `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig param.Field[HealthcheckEditParamsTcpConfig] `json:"tcp_config"` - // 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' and 'TCP'. - Type param.Field[string] `json:"type"` + ZoneID param.Field[string] `path:"zone_id,required"` + QueryHealthcheck QueryHealthcheckParam `json:"query_healthcheck,required"` } func (r HealthcheckEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckEditParamsCheckRegion string - -const ( - HealthcheckEditParamsCheckRegionWnam HealthcheckEditParamsCheckRegion = "WNAM" - HealthcheckEditParamsCheckRegionEnam HealthcheckEditParamsCheckRegion = "ENAM" - HealthcheckEditParamsCheckRegionWeu HealthcheckEditParamsCheckRegion = "WEU" - HealthcheckEditParamsCheckRegionEeu HealthcheckEditParamsCheckRegion = "EEU" - HealthcheckEditParamsCheckRegionNsam HealthcheckEditParamsCheckRegion = "NSAM" - HealthcheckEditParamsCheckRegionSsam HealthcheckEditParamsCheckRegion = "SSAM" - HealthcheckEditParamsCheckRegionOc HealthcheckEditParamsCheckRegion = "OC" - HealthcheckEditParamsCheckRegionMe HealthcheckEditParamsCheckRegion = "ME" - HealthcheckEditParamsCheckRegionNaf HealthcheckEditParamsCheckRegion = "NAF" - HealthcheckEditParamsCheckRegionSaf HealthcheckEditParamsCheckRegion = "SAF" - HealthcheckEditParamsCheckRegionIn HealthcheckEditParamsCheckRegion = "IN" - HealthcheckEditParamsCheckRegionSeas HealthcheckEditParamsCheckRegion = "SEAS" - HealthcheckEditParamsCheckRegionNeas HealthcheckEditParamsCheckRegion = "NEAS" - HealthcheckEditParamsCheckRegionAllRegions HealthcheckEditParamsCheckRegion = "ALL_REGIONS" -) - -func (r HealthcheckEditParamsCheckRegion) IsKnown() bool { - switch r { - case HealthcheckEditParamsCheckRegionWnam, HealthcheckEditParamsCheckRegionEnam, HealthcheckEditParamsCheckRegionWeu, HealthcheckEditParamsCheckRegionEeu, HealthcheckEditParamsCheckRegionNsam, HealthcheckEditParamsCheckRegionSsam, HealthcheckEditParamsCheckRegionOc, HealthcheckEditParamsCheckRegionMe, HealthcheckEditParamsCheckRegionNaf, HealthcheckEditParamsCheckRegionSaf, HealthcheckEditParamsCheckRegionIn, HealthcheckEditParamsCheckRegionSeas, HealthcheckEditParamsCheckRegionNeas, HealthcheckEditParamsCheckRegionAllRegions: - return true - } - return false -} - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckEditParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // 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. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - 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. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[HealthcheckEditParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckEditParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The HTTP method to use for the health check. -type HealthcheckEditParamsHTTPConfigMethod string - -const ( - HealthcheckEditParamsHTTPConfigMethodGet HealthcheckEditParamsHTTPConfigMethod = "GET" - HealthcheckEditParamsHTTPConfigMethodHead HealthcheckEditParamsHTTPConfigMethod = "HEAD" -) - -func (r HealthcheckEditParamsHTTPConfigMethod) IsKnown() bool { - switch r { - case HealthcheckEditParamsHTTPConfigMethodGet, HealthcheckEditParamsHTTPConfigMethodHead: - return true - } - return false -} - -// Parameters specific to TCP health check. -type HealthcheckEditParamsTcpConfig struct { - // The TCP connection method to use for the health check. - Method param.Field[HealthcheckEditParamsTcpConfigMethod] `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckEditParamsTcpConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TCP connection method to use for the health check. -type HealthcheckEditParamsTcpConfigMethod string - -const ( - HealthcheckEditParamsTcpConfigMethodConnectionEstablished HealthcheckEditParamsTcpConfigMethod = "connection_established" -) - -func (r HealthcheckEditParamsTcpConfigMethod) IsKnown() bool { - switch r { - case HealthcheckEditParamsTcpConfigMethodConnectionEstablished: - return true - } - return false + return apijson.MarshalRoot(r.QueryHealthcheck) } type HealthcheckEditResponseEnvelope struct { - Errors []HealthcheckEditResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckEditResponseEnvelopeMessages `json:"messages,required"` - Result Healthcheck `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Healthcheck `json:"result,required"` // Whether the API call was successful Success HealthcheckEditResponseEnvelopeSuccess `json:"success,required"` JSON healthcheckEditResponseEnvelopeJSON `json:"-"` @@ -1121,52 +662,6 @@ func (r healthcheckEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HealthcheckEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckEditResponseEnvelopeErrors] -type healthcheckEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckEditResponseEnvelopeMessages] -type healthcheckEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HealthcheckEditResponseEnvelopeSuccess bool @@ -1188,9 +683,9 @@ type HealthcheckGetParams struct { } type HealthcheckGetResponseEnvelope struct { - Errors []HealthcheckGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckGetResponseEnvelopeMessages `json:"messages,required"` - Result Healthcheck `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Healthcheck `json:"result,required"` // Whether the API call was successful Success HealthcheckGetResponseEnvelopeSuccess `json:"success,required"` JSON healthcheckGetResponseEnvelopeJSON `json:"-"` @@ -1215,52 +710,6 @@ func (r healthcheckGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HealthcheckGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckGetResponseEnvelopeErrors] -type healthcheckGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckGetResponseEnvelopeMessages] -type healthcheckGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HealthcheckGetResponseEnvelopeSuccess bool diff --git a/healthchecks/healthcheck_test.go b/healthchecks/healthcheck_test.go index e66309e546e..c74edc22035 100644 --- a/healthchecks/healthcheck_test.go +++ b/healthchecks/healthcheck_test.go @@ -29,39 +29,41 @@ func TestHealthcheckNewWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.Healthchecks.New(context.TODO(), healthchecks.HealthcheckNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Address: cloudflare.F("www.example.com"), - Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]healthchecks.HealthcheckNewParamsCheckRegion{healthchecks.HealthcheckNewParamsCheckRegionWeu, healthchecks.HealthcheckNewParamsCheckRegionEnam}), - ConsecutiveFails: cloudflare.F(int64(0)), - ConsecutiveSuccesses: cloudflare.F(int64(0)), - Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(healthchecks.HealthcheckNewParamsHTTPConfig{ - AllowInsecure: cloudflare.F(true), - ExpectedBody: cloudflare.F("success"), - ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), - 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", - }, + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + QueryHealthcheck: healthchecks.QueryHealthcheckParam{ + Address: cloudflare.F("www.example.com"), + CheckRegions: cloudflare.F([]healthchecks.CheckRegion{healthchecks.CheckRegionWeu, healthchecks.CheckRegionEnam}), + ConsecutiveFails: cloudflare.F(int64(0)), + ConsecutiveSuccesses: cloudflare.F(int64(0)), + Description: cloudflare.F("Health check for www.example.com"), + HTTPConfig: cloudflare.F(healthchecks.HTTPConfigurationParam{ + AllowInsecure: cloudflare.F(true), + ExpectedBody: cloudflare.F("success"), + ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), + 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", + }, + }), + Method: cloudflare.F(healthchecks.HTTPConfigurationMethodGet), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), }), - Method: cloudflare.F(healthchecks.HealthcheckNewParamsHTTPConfigMethodGet), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - }), - Interval: cloudflare.F(int64(0)), - Retries: cloudflare.F(int64(0)), - Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(healthchecks.HealthcheckNewParamsTcpConfig{ - Method: cloudflare.F(healthchecks.HealthcheckNewParamsTcpConfigMethodConnectionEstablished), - Port: cloudflare.F(int64(0)), - }), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F("HTTPS"), + Interval: cloudflare.F(int64(0)), + Name: cloudflare.F("server-1"), + Retries: cloudflare.F(int64(0)), + Suspended: cloudflare.F(true), + TCPConfig: cloudflare.F(healthchecks.TCPConfigurationParam{ + Method: cloudflare.F(healthchecks.TCPConfigurationMethodConnectionEstablished), + Port: cloudflare.F(int64(0)), + }), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F("HTTPS"), + }, }) if err != nil { var apierr *cloudflare.Error @@ -90,39 +92,41 @@ func TestHealthcheckUpdateWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", healthchecks.HealthcheckUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Address: cloudflare.F("www.example.com"), - Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]healthchecks.HealthcheckUpdateParamsCheckRegion{healthchecks.HealthcheckUpdateParamsCheckRegionWeu, healthchecks.HealthcheckUpdateParamsCheckRegionEnam}), - ConsecutiveFails: cloudflare.F(int64(0)), - ConsecutiveSuccesses: cloudflare.F(int64(0)), - Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(healthchecks.HealthcheckUpdateParamsHTTPConfig{ - AllowInsecure: cloudflare.F(true), - ExpectedBody: cloudflare.F("success"), - ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), - 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", - }, + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + QueryHealthcheck: healthchecks.QueryHealthcheckParam{ + Address: cloudflare.F("www.example.com"), + CheckRegions: cloudflare.F([]healthchecks.CheckRegion{healthchecks.CheckRegionWeu, healthchecks.CheckRegionEnam}), + ConsecutiveFails: cloudflare.F(int64(0)), + ConsecutiveSuccesses: cloudflare.F(int64(0)), + Description: cloudflare.F("Health check for www.example.com"), + HTTPConfig: cloudflare.F(healthchecks.HTTPConfigurationParam{ + AllowInsecure: cloudflare.F(true), + ExpectedBody: cloudflare.F("success"), + ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), + 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", + }, + }), + Method: cloudflare.F(healthchecks.HTTPConfigurationMethodGet), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), }), - Method: cloudflare.F(healthchecks.HealthcheckUpdateParamsHTTPConfigMethodGet), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - }), - Interval: cloudflare.F(int64(0)), - Retries: cloudflare.F(int64(0)), - Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(healthchecks.HealthcheckUpdateParamsTcpConfig{ - Method: cloudflare.F(healthchecks.HealthcheckUpdateParamsTcpConfigMethodConnectionEstablished), - Port: cloudflare.F(int64(0)), - }), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F("HTTPS"), + Interval: cloudflare.F(int64(0)), + Name: cloudflare.F("server-1"), + Retries: cloudflare.F(int64(0)), + Suspended: cloudflare.F(true), + TCPConfig: cloudflare.F(healthchecks.TCPConfigurationParam{ + Method: cloudflare.F(healthchecks.TCPConfigurationMethodConnectionEstablished), + Port: cloudflare.F(int64(0)), + }), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F("HTTPS"), + }, }, ) if err != nil { @@ -179,6 +183,7 @@ func TestHealthcheckDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", healthchecks.HealthcheckDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -208,39 +213,41 @@ func TestHealthcheckEditWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", healthchecks.HealthcheckEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Address: cloudflare.F("www.example.com"), - Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]healthchecks.HealthcheckEditParamsCheckRegion{healthchecks.HealthcheckEditParamsCheckRegionWeu, healthchecks.HealthcheckEditParamsCheckRegionEnam}), - ConsecutiveFails: cloudflare.F(int64(0)), - ConsecutiveSuccesses: cloudflare.F(int64(0)), - Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(healthchecks.HealthcheckEditParamsHTTPConfig{ - AllowInsecure: cloudflare.F(true), - ExpectedBody: cloudflare.F("success"), - ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), - 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", - }, + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + QueryHealthcheck: healthchecks.QueryHealthcheckParam{ + Address: cloudflare.F("www.example.com"), + CheckRegions: cloudflare.F([]healthchecks.CheckRegion{healthchecks.CheckRegionWeu, healthchecks.CheckRegionEnam}), + ConsecutiveFails: cloudflare.F(int64(0)), + ConsecutiveSuccesses: cloudflare.F(int64(0)), + Description: cloudflare.F("Health check for www.example.com"), + HTTPConfig: cloudflare.F(healthchecks.HTTPConfigurationParam{ + AllowInsecure: cloudflare.F(true), + ExpectedBody: cloudflare.F("success"), + ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), + 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", + }, + }), + Method: cloudflare.F(healthchecks.HTTPConfigurationMethodGet), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), }), - Method: cloudflare.F(healthchecks.HealthcheckEditParamsHTTPConfigMethodGet), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - }), - Interval: cloudflare.F(int64(0)), - Retries: cloudflare.F(int64(0)), - Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(healthchecks.HealthcheckEditParamsTcpConfig{ - Method: cloudflare.F(healthchecks.HealthcheckEditParamsTcpConfigMethodConnectionEstablished), - Port: cloudflare.F(int64(0)), - }), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F("HTTPS"), + Interval: cloudflare.F(int64(0)), + Name: cloudflare.F("server-1"), + Retries: cloudflare.F(int64(0)), + Suspended: cloudflare.F(true), + TCPConfig: cloudflare.F(healthchecks.TCPConfigurationParam{ + Method: cloudflare.F(healthchecks.TCPConfigurationMethodConnectionEstablished), + Port: cloudflare.F(int64(0)), + }), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F("HTTPS"), + }, }, ) if err != nil { diff --git a/healthchecks/preview.go b/healthchecks/preview.go index 65e46ebb8fe..2101e5169b2 100644 --- a/healthchecks/preview.go +++ b/healthchecks/preview.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -44,10 +45,10 @@ func (r *PreviewService) New(ctx context.Context, params PreviewNewParams, opts } // Delete a health check. -func (r *PreviewService) Delete(ctx context.Context, healthcheckID string, body PreviewDeleteParams, opts ...option.RequestOption) (res *PreviewDeleteResponse, err error) { +func (r *PreviewService) Delete(ctx context.Context, healthcheckID string, params PreviewDeleteParams, opts ...option.RequestOption) (res *PreviewDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env PreviewDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/preview/%s", body.ZoneID, healthcheckID) + path := fmt.Sprintf("zones/%s/healthchecks/preview/%s", params.ZoneID, healthcheckID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -93,154 +94,18 @@ func (r previewDeleteResponseJSON) RawJSON() string { type PreviewNewParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The hostname or IP address of the origin server to run health checks on. - Address param.Field[string] `json:"address,required"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions param.Field[[]PreviewNewParamsCheckRegion] `json:"check_regions"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` - // A human-readable description of the health check. - Description param.Field[string] `json:"description"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[PreviewNewParamsHTTPConfig] `json:"http_config"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // 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"` - // If suspended, no health checks are sent to the origin. - Suspended param.Field[bool] `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig param.Field[PreviewNewParamsTcpConfig] `json:"tcp_config"` - // 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' and 'TCP'. - Type param.Field[string] `json:"type"` + ZoneID param.Field[string] `path:"zone_id,required"` + QueryHealthcheck QueryHealthcheckParam `json:"query_healthcheck,required"` } func (r PreviewNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type PreviewNewParamsCheckRegion string - -const ( - PreviewNewParamsCheckRegionWnam PreviewNewParamsCheckRegion = "WNAM" - PreviewNewParamsCheckRegionEnam PreviewNewParamsCheckRegion = "ENAM" - PreviewNewParamsCheckRegionWeu PreviewNewParamsCheckRegion = "WEU" - PreviewNewParamsCheckRegionEeu PreviewNewParamsCheckRegion = "EEU" - PreviewNewParamsCheckRegionNsam PreviewNewParamsCheckRegion = "NSAM" - PreviewNewParamsCheckRegionSsam PreviewNewParamsCheckRegion = "SSAM" - PreviewNewParamsCheckRegionOc PreviewNewParamsCheckRegion = "OC" - PreviewNewParamsCheckRegionMe PreviewNewParamsCheckRegion = "ME" - PreviewNewParamsCheckRegionNaf PreviewNewParamsCheckRegion = "NAF" - PreviewNewParamsCheckRegionSaf PreviewNewParamsCheckRegion = "SAF" - PreviewNewParamsCheckRegionIn PreviewNewParamsCheckRegion = "IN" - PreviewNewParamsCheckRegionSeas PreviewNewParamsCheckRegion = "SEAS" - PreviewNewParamsCheckRegionNeas PreviewNewParamsCheckRegion = "NEAS" - PreviewNewParamsCheckRegionAllRegions PreviewNewParamsCheckRegion = "ALL_REGIONS" -) - -func (r PreviewNewParamsCheckRegion) IsKnown() bool { - switch r { - case PreviewNewParamsCheckRegionWnam, PreviewNewParamsCheckRegionEnam, PreviewNewParamsCheckRegionWeu, PreviewNewParamsCheckRegionEeu, PreviewNewParamsCheckRegionNsam, PreviewNewParamsCheckRegionSsam, PreviewNewParamsCheckRegionOc, PreviewNewParamsCheckRegionMe, PreviewNewParamsCheckRegionNaf, PreviewNewParamsCheckRegionSaf, PreviewNewParamsCheckRegionIn, PreviewNewParamsCheckRegionSeas, PreviewNewParamsCheckRegionNeas, PreviewNewParamsCheckRegionAllRegions: - return true - } - return false -} - -// Parameters specific to an HTTP or HTTPS health check. -type PreviewNewParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // 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. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - 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. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[PreviewNewParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` -} - -func (r PreviewNewParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The HTTP method to use for the health check. -type PreviewNewParamsHTTPConfigMethod string - -const ( - PreviewNewParamsHTTPConfigMethodGet PreviewNewParamsHTTPConfigMethod = "GET" - PreviewNewParamsHTTPConfigMethodHead PreviewNewParamsHTTPConfigMethod = "HEAD" -) - -func (r PreviewNewParamsHTTPConfigMethod) IsKnown() bool { - switch r { - case PreviewNewParamsHTTPConfigMethodGet, PreviewNewParamsHTTPConfigMethodHead: - return true - } - return false -} - -// Parameters specific to TCP health check. -type PreviewNewParamsTcpConfig struct { - // The TCP connection method to use for the health check. - Method param.Field[PreviewNewParamsTcpConfigMethod] `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port param.Field[int64] `json:"port"` -} - -func (r PreviewNewParamsTcpConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TCP connection method to use for the health check. -type PreviewNewParamsTcpConfigMethod string - -const ( - PreviewNewParamsTcpConfigMethodConnectionEstablished PreviewNewParamsTcpConfigMethod = "connection_established" -) - -func (r PreviewNewParamsTcpConfigMethod) IsKnown() bool { - switch r { - case PreviewNewParamsTcpConfigMethodConnectionEstablished: - return true - } - return false + return apijson.MarshalRoot(r.QueryHealthcheck) } type PreviewNewResponseEnvelope struct { - Errors []PreviewNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PreviewNewResponseEnvelopeMessages `json:"messages,required"` - Result Healthcheck `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Healthcheck `json:"result,required"` // Whether the API call was successful Success PreviewNewResponseEnvelopeSuccess `json:"success,required"` JSON previewNewResponseEnvelopeJSON `json:"-"` @@ -265,52 +130,6 @@ func (r previewNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PreviewNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// previewNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PreviewNewResponseEnvelopeErrors] -type previewNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PreviewNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// previewNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PreviewNewResponseEnvelopeMessages] -type previewNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PreviewNewResponseEnvelopeSuccess bool @@ -329,12 +148,17 @@ func (r PreviewNewResponseEnvelopeSuccess) IsKnown() bool { type PreviewDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r PreviewDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type PreviewDeleteResponseEnvelope struct { - Errors []PreviewDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PreviewDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PreviewDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PreviewDeleteResponse `json:"result,required"` // Whether the API call was successful Success PreviewDeleteResponseEnvelopeSuccess `json:"success,required"` JSON previewDeleteResponseEnvelopeJSON `json:"-"` @@ -359,52 +183,6 @@ func (r previewDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PreviewDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// previewDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PreviewDeleteResponseEnvelopeErrors] -type previewDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PreviewDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// previewDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PreviewDeleteResponseEnvelopeMessages] -type previewDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PreviewDeleteResponseEnvelopeSuccess bool @@ -426,9 +204,9 @@ type PreviewGetParams struct { } type PreviewGetResponseEnvelope struct { - Errors []PreviewGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PreviewGetResponseEnvelopeMessages `json:"messages,required"` - Result Healthcheck `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Healthcheck `json:"result,required"` // Whether the API call was successful Success PreviewGetResponseEnvelopeSuccess `json:"success,required"` JSON previewGetResponseEnvelopeJSON `json:"-"` @@ -453,52 +231,6 @@ func (r previewGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PreviewGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// previewGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PreviewGetResponseEnvelopeErrors] -type previewGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PreviewGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// previewGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PreviewGetResponseEnvelopeMessages] -type previewGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PreviewGetResponseEnvelopeSuccess bool diff --git a/healthchecks/preview_test.go b/healthchecks/preview_test.go index 89806a91173..47267ef08f0 100644 --- a/healthchecks/preview_test.go +++ b/healthchecks/preview_test.go @@ -29,39 +29,41 @@ func TestPreviewNewWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.Healthchecks.Previews.New(context.TODO(), healthchecks.PreviewNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Address: cloudflare.F("www.example.com"), - Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]healthchecks.PreviewNewParamsCheckRegion{healthchecks.PreviewNewParamsCheckRegionWeu, healthchecks.PreviewNewParamsCheckRegionEnam}), - ConsecutiveFails: cloudflare.F(int64(0)), - ConsecutiveSuccesses: cloudflare.F(int64(0)), - Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(healthchecks.PreviewNewParamsHTTPConfig{ - AllowInsecure: cloudflare.F(true), - ExpectedBody: cloudflare.F("success"), - ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), - 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", - }, + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + QueryHealthcheck: healthchecks.QueryHealthcheckParam{ + Address: cloudflare.F("www.example.com"), + CheckRegions: cloudflare.F([]healthchecks.CheckRegion{healthchecks.CheckRegionWeu, healthchecks.CheckRegionEnam}), + ConsecutiveFails: cloudflare.F(int64(0)), + ConsecutiveSuccesses: cloudflare.F(int64(0)), + Description: cloudflare.F("Health check for www.example.com"), + HTTPConfig: cloudflare.F(healthchecks.HTTPConfigurationParam{ + AllowInsecure: cloudflare.F(true), + ExpectedBody: cloudflare.F("success"), + ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), + 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", + }, + }), + Method: cloudflare.F(healthchecks.HTTPConfigurationMethodGet), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), }), - Method: cloudflare.F(healthchecks.PreviewNewParamsHTTPConfigMethodGet), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - }), - Interval: cloudflare.F(int64(0)), - Retries: cloudflare.F(int64(0)), - Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(healthchecks.PreviewNewParamsTcpConfig{ - Method: cloudflare.F(healthchecks.PreviewNewParamsTcpConfigMethodConnectionEstablished), - Port: cloudflare.F(int64(0)), - }), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F("HTTPS"), + Interval: cloudflare.F(int64(0)), + Name: cloudflare.F("server-1"), + Retries: cloudflare.F(int64(0)), + Suspended: cloudflare.F(true), + TCPConfig: cloudflare.F(healthchecks.TCPConfigurationParam{ + Method: cloudflare.F(healthchecks.TCPConfigurationMethodConnectionEstablished), + Port: cloudflare.F(int64(0)), + }), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F("HTTPS"), + }, }) if err != nil { var apierr *cloudflare.Error @@ -91,6 +93,7 @@ func TestPreviewDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", healthchecks.PreviewDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/hostnames/aliases.go b/hostnames/aliases.go index 575165253aa..c4615166466 100644 --- a/hostnames/aliases.go +++ b/hostnames/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/hostnames/settingtls.go b/hostnames/settingtls.go index 221e8312da4..207abfb50a9 100644 --- a/hostnames/settingtls.go +++ b/hostnames/settingtls.go @@ -35,7 +35,7 @@ func NewSettingTLSService(opts ...option.RequestOption) (r *SettingTLSService) { } // Update the tls setting value for the hostname. -func (r *SettingTLSService) Update(ctx context.Context, settingID SettingTLSUpdateParamsSettingID, hostname string, params SettingTLSUpdateParams, opts ...option.RequestOption) (res *HostnameStting, err error) { +func (r *SettingTLSService) Update(ctx context.Context, settingID SettingTLSUpdateParamsSettingID, hostname string, params SettingTLSUpdateParams, opts ...option.RequestOption) (res *Setting, err error) { opts = append(r.Options[:], opts...) var env SettingTLSUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/hostnames/settings/%v/%s", params.ZoneID, settingID, hostname) @@ -48,7 +48,7 @@ func (r *SettingTLSService) Update(ctx context.Context, settingID SettingTLSUpda } // Delete the tls setting value for the hostname. -func (r *SettingTLSService) Delete(ctx context.Context, settingID SettingTLSDeleteParamsSettingID, hostname string, body SettingTLSDeleteParams, opts ...option.RequestOption) (res *HostnameSettingDelete, err error) { +func (r *SettingTLSService) Delete(ctx context.Context, settingID SettingTLSDeleteParamsSettingID, hostname string, body SettingTLSDeleteParams, opts ...option.RequestOption) (res *SettingTLSDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env SettingTLSDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/hostnames/settings/%v/%s", body.ZoneID, settingID, hostname) @@ -73,39 +73,7 @@ func (r *SettingTLSService) Get(ctx context.Context, settingID SettingTLSGetPara return } -type HostnameSettingDelete struct { - // This is the time the tls setting was originally created for this hostname. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The hostname for which the tls settings are set. - Hostname string `json:"hostname"` - Status string `json:"status"` - // This is the time the tls setting was updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - Value string `json:"value"` - JSON hostnameSettingDeleteJSON `json:"-"` -} - -// hostnameSettingDeleteJSON contains the JSON metadata for the struct -// [HostnameSettingDelete] -type hostnameSettingDeleteJSON struct { - CreatedAt apijson.Field - Hostname apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingDelete) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingDeleteJSON) RawJSON() string { - return r.raw -} - -type HostnameStting struct { +type Setting struct { // This is the time the tls setting was originally created for this hostname. CreatedAt time.Time `json:"created_at" format:"date-time"` // The hostname for which the tls settings are set. @@ -115,12 +83,12 @@ type HostnameStting struct { // This is the time the tls setting was updated. UpdatedAt time.Time `json:"updated_at" format:"date-time"` // The tls setting value. - Value HostnameSttingValue `json:"value"` - JSON hostnameSttingJSON `json:"-"` + Value SettingValueUnion `json:"value"` + JSON settingJSON `json:"-"` } -// hostnameSttingJSON contains the JSON metadata for the struct [HostnameStting] -type hostnameSttingJSON struct { +// settingJSON contains the JSON metadata for the struct [Setting] +type settingJSON struct { CreatedAt apijson.Field Hostname apijson.Field Status apijson.Field @@ -130,25 +98,25 @@ type hostnameSttingJSON struct { ExtraFields map[string]apijson.Field } -func (r *HostnameStting) UnmarshalJSON(data []byte) (err error) { +func (r *Setting) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r hostnameSttingJSON) RawJSON() string { +func (r settingJSON) RawJSON() string { return r.raw } // The tls setting value. // // Union satisfied by [shared.UnionFloat], [shared.UnionString] or -// [hostnames.HostnameSttingValueArray]. -type HostnameSttingValue interface { - ImplementsHostnamesHostnameSttingValue() +// [hostnames.SettingValueArray]. +type SettingValueUnion interface { + ImplementsHostnamesSettingValueUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*HostnameSttingValue)(nil)).Elem(), + reflect.TypeOf((*SettingValueUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.Number, @@ -160,14 +128,58 @@ func init() { }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(HostnameSttingValueArray{}), + Type: reflect.TypeOf(SettingValueArray{}), }, ) } -type HostnameSttingValueArray []string +type SettingValueArray []string + +func (r SettingValueArray) ImplementsHostnamesSettingValueUnion() {} + +// The tls setting value. +// +// Satisfied by [shared.UnionFloat], [shared.UnionString], +// [hostnames.SettingValueArrayParam]. +type SettingValueUnionParam interface { + ImplementsHostnamesSettingValueUnionParam() +} + +type SettingValueArrayParam []string + +func (r SettingValueArrayParam) ImplementsHostnamesSettingValueUnionParam() {} + +type SettingTLSDeleteResponse struct { + // This is the time the tls setting was originally created for this hostname. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The hostname for which the tls settings are set. + Hostname string `json:"hostname"` + Status string `json:"status"` + // This is the time the tls setting was updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + Value string `json:"value"` + JSON settingTLSDeleteResponseJSON `json:"-"` +} + +// settingTLSDeleteResponseJSON contains the JSON metadata for the struct +// [SettingTLSDeleteResponse] +type settingTLSDeleteResponseJSON struct { + CreatedAt apijson.Field + Hostname apijson.Field + Status apijson.Field + UpdatedAt apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} -func (r HostnameSttingValueArray) ImplementsHostnamesHostnameSttingValue() {} +func (r settingTLSDeleteResponseJSON) RawJSON() string { + return r.raw +} type SettingTLSGetResponse struct { // This is the time the tls setting was originally created for this hostname. @@ -179,8 +191,8 @@ type SettingTLSGetResponse struct { // This is the time the tls setting was updated. UpdatedAt time.Time `json:"updated_at" format:"date-time"` // The tls setting value. - Value SettingTLSGetResponseValue `json:"value"` - JSON settingTLSGetResponseJSON `json:"-"` + Value SettingValueUnion `json:"value"` + JSON settingTLSGetResponseJSON `json:"-"` } // settingTLSGetResponseJSON contains the JSON metadata for the struct @@ -203,42 +215,11 @@ func (r settingTLSGetResponseJSON) RawJSON() string { return r.raw } -// The tls setting value. -// -// Union satisfied by [shared.UnionFloat], [shared.UnionString] or -// [hostnames.SettingTLSGetResponseValueArray]. -type SettingTLSGetResponseValue interface { - ImplementsHostnamesSettingTLSGetResponseValue() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SettingTLSGetResponseValue)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingTLSGetResponseValueArray{}), - }, - ) -} - -type SettingTLSGetResponseValueArray []string - -func (r SettingTLSGetResponseValueArray) ImplementsHostnamesSettingTLSGetResponseValue() {} - type SettingTLSUpdateParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // The tls setting value. - Value param.Field[SettingTLSUpdateParamsValue] `json:"value,required"` + Value param.Field[SettingValueUnionParam] `json:"value,required"` } func (r SettingTLSUpdateParams) MarshalJSON() (data []byte, err error) { @@ -262,22 +243,10 @@ func (r SettingTLSUpdateParamsSettingID) IsKnown() bool { return false } -// The tls setting value. -// -// Satisfied by [shared.UnionFloat], [shared.UnionString], -// [hostnames.SettingTLSUpdateParamsValueArray]. -type SettingTLSUpdateParamsValue interface { - ImplementsHostnamesSettingTLSUpdateParamsValue() -} - -type SettingTLSUpdateParamsValueArray []string - -func (r SettingTLSUpdateParamsValueArray) ImplementsHostnamesSettingTLSUpdateParamsValue() {} - type SettingTLSUpdateResponseEnvelope struct { - Errors []SettingTLSUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTLSUpdateResponseEnvelopeMessages `json:"messages,required"` - Result HostnameStting `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Setting `json:"result,required"` // Whether the API call was successful Success SettingTLSUpdateResponseEnvelopeSuccess `json:"success,required"` JSON settingTLSUpdateResponseEnvelopeJSON `json:"-"` @@ -302,52 +271,6 @@ func (r settingTLSUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingTLSUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTLSUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingTLSUpdateResponseEnvelopeErrors] -type settingTLSUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTLSUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTLSUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingTLSUpdateResponseEnvelopeMessages] -type settingTLSUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingTLSUpdateResponseEnvelopeSuccess bool @@ -386,9 +309,9 @@ func (r SettingTLSDeleteParamsSettingID) IsKnown() bool { } type SettingTLSDeleteResponseEnvelope struct { - Errors []SettingTLSDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTLSDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HostnameSettingDelete `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SettingTLSDeleteResponse `json:"result,required"` // Whether the API call was successful Success SettingTLSDeleteResponseEnvelopeSuccess `json:"success,required"` JSON settingTLSDeleteResponseEnvelopeJSON `json:"-"` @@ -413,52 +336,6 @@ func (r settingTLSDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingTLSDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTLSDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingTLSDeleteResponseEnvelopeErrors] -type settingTLSDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTLSDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTLSDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingTLSDeleteResponseEnvelopeMessages] -type settingTLSDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingTLSDeleteResponseEnvelopeSuccess bool @@ -497,9 +374,9 @@ func (r SettingTLSGetParamsSettingID) IsKnown() bool { } type SettingTLSGetResponseEnvelope struct { - Errors []SettingTLSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTLSGetResponseEnvelopeMessages `json:"messages,required"` - Result []SettingTLSGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SettingTLSGetResponse `json:"result,required,nullable"` // Whether the API call was successful Success SettingTLSGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo SettingTLSGetResponseEnvelopeResultInfo `json:"result_info"` @@ -526,52 +403,6 @@ func (r settingTLSGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingTLSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTLSGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingTLSGetResponseEnvelopeErrors] -type settingTLSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTLSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTLSGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingTLSGetResponseEnvelopeMessages] -type settingTLSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingTLSGetResponseEnvelopeSuccess bool diff --git a/hostnames/settingtls_test.go b/hostnames/settingtls_test.go index b201efb1e47..dfb2056f914 100644 --- a/hostnames/settingtls_test.go +++ b/hostnames/settingtls_test.go @@ -34,7 +34,7 @@ func TestSettingTLSUpdate(t *testing.T) { "app.example.com", hostnames.SettingTLSUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F[hostnames.SettingTLSUpdateParamsValue](hostnames.SettingTLSUpdateParamsValueArray([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"})), + Value: cloudflare.F[hostnames.SettingValueUnionParam](hostnames.SettingValueArrayParam([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"})), }, ) if err != nil { diff --git a/hyperdrive/aliases.go b/hyperdrive/aliases.go index cacde97be64..163b6fbd5b2 100644 --- a/hyperdrive/aliases.go +++ b/hyperdrive/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/hyperdrive/config.go b/hyperdrive/config.go index 32e43420147..47b9116f50a 100644 --- a/hyperdrive/config.go +++ b/hyperdrive/config.go @@ -35,7 +35,7 @@ func NewConfigService(opts ...option.RequestOption) (r *ConfigService) { } // Creates and returns a new Hyperdrive configuration. -func (r *ConfigService) New(ctx context.Context, params ConfigNewParams, opts ...option.RequestOption) (res *ConfigNewResponse, err error) { +func (r *ConfigService) New(ctx context.Context, params ConfigNewParams, opts ...option.RequestOption) (res *Hyperdrive, err error) { opts = append(r.Options[:], opts...) var env ConfigNewResponseEnvelope path := fmt.Sprintf("accounts/%s/hyperdrive/configs", params.AccountID) @@ -48,7 +48,7 @@ func (r *ConfigService) New(ctx context.Context, params ConfigNewParams, opts .. } // Updates and returns the specified Hyperdrive configuration. -func (r *ConfigService) Update(ctx context.Context, hyperdriveID string, params ConfigUpdateParams, opts ...option.RequestOption) (res *ConfigUpdateResponse, err error) { +func (r *ConfigService) Update(ctx context.Context, hyperdriveID string, params ConfigUpdateParams, opts ...option.RequestOption) (res *Hyperdrive, err error) { opts = append(r.Options[:], opts...) var env ConfigUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", params.AccountID, hyperdriveID) @@ -61,7 +61,7 @@ func (r *ConfigService) Update(ctx context.Context, hyperdriveID string, params } // Returns a list of Hyperdrives -func (r *ConfigService) List(ctx context.Context, query ConfigListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ConfigListResponse], err error) { +func (r *ConfigService) List(ctx context.Context, query ConfigListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Hyperdrive], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -79,12 +79,12 @@ func (r *ConfigService) List(ctx context.Context, query ConfigListParams, opts . } // Returns a list of Hyperdrives -func (r *ConfigService) ListAutoPaging(ctx context.Context, query ConfigListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ConfigListResponse] { +func (r *ConfigService) ListAutoPaging(ctx context.Context, query ConfigListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Hyperdrive] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes the specified Hyperdrive. -func (r *ConfigService) Delete(ctx context.Context, hyperdriveID string, body ConfigDeleteParams, opts ...option.RequestOption) (res *ConfigDeleteResponse, err error) { +func (r *ConfigService) Delete(ctx context.Context, hyperdriveID string, body ConfigDeleteParams, opts ...option.RequestOption) (res *ConfigDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ConfigDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", body.AccountID, hyperdriveID) @@ -98,7 +98,7 @@ func (r *ConfigService) Delete(ctx context.Context, hyperdriveID string, body Co // Patches and returns the specified Hyperdrive configuration. Updates to the // origin and caching settings are applied with an all-or-nothing approach. -func (r *ConfigService) Edit(ctx context.Context, hyperdriveID string, params ConfigEditParams, opts ...option.RequestOption) (res *ConfigEditResponse, err error) { +func (r *ConfigService) Edit(ctx context.Context, hyperdriveID string, params ConfigEditParams, opts ...option.RequestOption) (res *Hyperdrive, err error) { opts = append(r.Options[:], opts...) var env ConfigEditResponseEnvelope path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", params.AccountID, hyperdriveID) @@ -111,7 +111,7 @@ func (r *ConfigService) Edit(ctx context.Context, hyperdriveID string, params Co } // Returns the specified Hyperdrive configuration. -func (r *ConfigService) Get(ctx context.Context, hyperdriveID string, query ConfigGetParams, opts ...option.RequestOption) (res *ConfigGetResponse, err error) { +func (r *ConfigService) Get(ctx context.Context, hyperdriveID string, query ConfigGetParams, opts ...option.RequestOption) (res *Hyperdrive, err error) { opts = append(r.Options[:], opts...) var env ConfigGetResponseEnvelope path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", query.AccountID, hyperdriveID) @@ -123,81 +123,15 @@ func (r *ConfigService) Get(ctx context.Context, hyperdriveID string, query Conf return } -type ConfigNewResponse struct { - // Identifier - ID string `json:"id"` - JSON configNewResponseJSON `json:"-"` -} - -// configNewResponseJSON contains the JSON metadata for the struct -// [ConfigNewResponse] -type configNewResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configNewResponseJSON) RawJSON() string { - return r.raw -} - -type ConfigUpdateResponse struct { - // Identifier - ID string `json:"id"` - JSON configUpdateResponseJSON `json:"-"` -} - -// configUpdateResponseJSON contains the JSON metadata for the struct -// [ConfigUpdateResponse] -type configUpdateResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ConfigListResponse struct { - // Identifier - ID string `json:"id"` - JSON configListResponseJSON `json:"-"` -} - -// configListResponseJSON contains the JSON metadata for the struct -// [ConfigListResponse] -type configListResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configListResponseJSON) RawJSON() string { - return r.raw -} - // Union satisfied by [hyperdrive.ConfigDeleteResponseUnknown] or // [shared.UnionString]. -type ConfigDeleteResponse interface { - ImplementsHyperdriveConfigDeleteResponse() +type ConfigDeleteResponseUnion interface { + ImplementsHyperdriveConfigDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ConfigDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*ConfigDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -206,74 +140,20 @@ func init() { ) } -type ConfigEditResponse struct { - // Identifier - ID string `json:"id"` - JSON configEditResponseJSON `json:"-"` -} - -// configEditResponseJSON contains the JSON metadata for the struct -// [ConfigEditResponse] -type configEditResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configEditResponseJSON) RawJSON() string { - return r.raw -} - -type ConfigGetResponse struct { - // Identifier - ID string `json:"id"` - JSON configGetResponseJSON `json:"-"` -} - -// configGetResponseJSON contains the JSON metadata for the struct -// [ConfigGetResponse] -type configGetResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configGetResponseJSON) RawJSON() string { - return r.raw -} - type ConfigNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Origin param.Field[ConfigNewParamsOrigin] `json:"origin,required"` + AccountID param.Field[string] `path:"account_id,required"` + Hyperdrive HyperdriveParam `json:"hyperdrive,required"` } func (r ConfigNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ConfigNewParamsOrigin struct { - // The password required to access your origin database. This value is write-only - // and never returned by the API. - Password param.Field[string] `json:"password,required"` -} - -func (r ConfigNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Hyperdrive) } type ConfigNewResponseEnvelope struct { - Errors []ConfigNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigNewResponseEnvelopeMessages `json:"messages,required"` - Result ConfigNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Hyperdrive `json:"result,required,nullable"` // Whether the API call was successful Success ConfigNewResponseEnvelopeSuccess `json:"success,required"` JSON configNewResponseEnvelopeJSON `json:"-"` @@ -298,52 +178,6 @@ func (r configNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// configNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigNewResponseEnvelopeErrors] -type configNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// configNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ConfigNewResponseEnvelopeMessages] -type configNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigNewResponseEnvelopeSuccess bool @@ -361,28 +195,18 @@ func (r ConfigNewResponseEnvelopeSuccess) IsKnown() bool { type ConfigUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Origin param.Field[ConfigUpdateParamsOrigin] `json:"origin,required"` + AccountID param.Field[string] `path:"account_id,required"` + Hyperdrive HyperdriveParam `json:"hyperdrive,required"` } func (r ConfigUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ConfigUpdateParamsOrigin struct { - // The password required to access your origin database. This value is write-only - // and never returned by the API. - Password param.Field[string] `json:"password,required"` -} - -func (r ConfigUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Hyperdrive) } type ConfigUpdateResponseEnvelope struct { - Errors []ConfigUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ConfigUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Hyperdrive `json:"result,required,nullable"` // Whether the API call was successful Success ConfigUpdateResponseEnvelopeSuccess `json:"success,required"` JSON configUpdateResponseEnvelopeJSON `json:"-"` @@ -407,52 +231,6 @@ func (r configUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// configUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigUpdateResponseEnvelopeErrors] -type configUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// configUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConfigUpdateResponseEnvelopeMessages] -type configUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigUpdateResponseEnvelopeSuccess bool @@ -479,9 +257,9 @@ type ConfigDeleteParams struct { } type ConfigDeleteResponseEnvelope struct { - Errors []ConfigDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ConfigDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ConfigDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success ConfigDeleteResponseEnvelopeSuccess `json:"success,required"` JSON configDeleteResponseEnvelopeJSON `json:"-"` @@ -506,52 +284,6 @@ func (r configDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// configDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigDeleteResponseEnvelopeErrors] -type configDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// configDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConfigDeleteResponseEnvelopeMessages] -type configDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigDeleteResponseEnvelopeSuccess bool @@ -569,28 +301,18 @@ func (r ConfigDeleteResponseEnvelopeSuccess) IsKnown() bool { type ConfigEditParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Origin param.Field[ConfigEditParamsOrigin] `json:"origin"` + AccountID param.Field[string] `path:"account_id,required"` + Hyperdrive HyperdriveParam `json:"hyperdrive,required"` } func (r ConfigEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ConfigEditParamsOrigin struct { - // The password required to access your origin database. This value is write-only - // and never returned by the API. - Password param.Field[string] `json:"password,required"` -} - -func (r ConfigEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Hyperdrive) } type ConfigEditResponseEnvelope struct { - Errors []ConfigEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigEditResponseEnvelopeMessages `json:"messages,required"` - Result ConfigEditResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Hyperdrive `json:"result,required,nullable"` // Whether the API call was successful Success ConfigEditResponseEnvelopeSuccess `json:"success,required"` JSON configEditResponseEnvelopeJSON `json:"-"` @@ -615,52 +337,6 @@ func (r configEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// configEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigEditResponseEnvelopeErrors] -type configEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// configEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ConfigEditResponseEnvelopeMessages] -type configEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigEditResponseEnvelopeSuccess bool @@ -682,9 +358,9 @@ type ConfigGetParams struct { } type ConfigGetResponseEnvelope struct { - Errors []ConfigGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigGetResponseEnvelopeMessages `json:"messages,required"` - Result ConfigGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Hyperdrive `json:"result,required,nullable"` // Whether the API call was successful Success ConfigGetResponseEnvelopeSuccess `json:"success,required"` JSON configGetResponseEnvelopeJSON `json:"-"` @@ -709,52 +385,6 @@ func (r configGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// configGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigGetResponseEnvelopeErrors] -type configGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// configGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ConfigGetResponseEnvelopeMessages] -type configGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigGetResponseEnvelopeSuccess bool diff --git a/hyperdrive/config_test.go b/hyperdrive/config_test.go index c3e32802740..91cc316d45f 100644 --- a/hyperdrive/config_test.go +++ b/hyperdrive/config_test.go @@ -30,9 +30,12 @@ func TestConfigNew(t *testing.T) { ) _, err := client.Hyperdrive.Configs.New(context.TODO(), hyperdrive.ConfigNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Origin: cloudflare.F(hyperdrive.ConfigNewParamsOrigin{ - Password: cloudflare.F("password1234!"), - }), + Hyperdrive: hyperdrive.HyperdriveParam{ + Origin: cloudflare.F(hyperdrive.ConfigurationParam{ + Password: cloudflare.F("password1234!"), + }), + Name: cloudflare.F[any](map[string]interface{}{}), + }, }) if err != nil { var apierr *cloudflare.Error @@ -62,9 +65,12 @@ func TestConfigUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", hyperdrive.ConfigUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Origin: cloudflare.F(hyperdrive.ConfigUpdateParamsOrigin{ - Password: cloudflare.F("password1234!"), - }), + Hyperdrive: hyperdrive.HyperdriveParam{ + Origin: cloudflare.F(hyperdrive.ConfigurationParam{ + Password: cloudflare.F("password1234!"), + }), + Name: cloudflare.F[any](map[string]interface{}{}), + }, }, ) if err != nil { @@ -151,9 +157,11 @@ func TestConfigEditWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", hyperdrive.ConfigEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Origin: cloudflare.F(hyperdrive.ConfigEditParamsOrigin{ - Password: cloudflare.F("password1234!"), - }), + Hyperdrive: hyperdrive.HyperdriveParam{ + Origin: cloudflare.F(hyperdrive.ConfigurationParam{ + Password: cloudflare.F("password1234!"), + }), + }, }, ) if err != nil { diff --git a/hyperdrive/hyperdrive.go b/hyperdrive/hyperdrive.go index a02c0b9e17d..d0b0fff4fbb 100644 --- a/hyperdrive/hyperdrive.go +++ b/hyperdrive/hyperdrive.go @@ -3,6 +3,8 @@ package hyperdrive import ( + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -24,3 +26,149 @@ func NewHyperdriveService(opts ...option.RequestOption) (r *HyperdriveService) { r.Configs = NewConfigService(opts...) return } + +type Configuration struct { + // The name of your origin database. + Database string `json:"database,required"` + // The host (hostname or IP) of your origin database. + Host string `json:"host,required"` + // The port (default: 5432 for Postgres) of your origin database. + Port int64 `json:"port,required"` + // Specifies the URL scheme used to connect to your origin database. + Scheme ConfigurationScheme `json:"scheme,required"` + // The user of your origin database. + User string `json:"user,required"` + JSON configurationJSON `json:"-"` +} + +// configurationJSON contains the JSON metadata for the struct [Configuration] +type configurationJSON struct { + Database apijson.Field + Host apijson.Field + Port apijson.Field + Scheme apijson.Field + User apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Configuration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configurationJSON) RawJSON() string { + return r.raw +} + +// Specifies the URL scheme used to connect to your origin database. +type ConfigurationScheme string + +const ( + ConfigurationSchemePostgres ConfigurationScheme = "postgres" + ConfigurationSchemePostgresql ConfigurationScheme = "postgresql" + ConfigurationSchemeMysql ConfigurationScheme = "mysql" +) + +func (r ConfigurationScheme) IsKnown() bool { + switch r { + case ConfigurationSchemePostgres, ConfigurationSchemePostgresql, ConfigurationSchemeMysql: + return true + } + return false +} + +type ConfigurationParam struct { + // The name of your origin database. + Database param.Field[string] `json:"database,required"` + // The host (hostname or IP) of your origin database. + Host param.Field[string] `json:"host,required"` + // The port (default: 5432 for Postgres) of your origin database. + Port param.Field[int64] `json:"port,required"` + // Specifies the URL scheme used to connect to your origin database. + Scheme param.Field[ConfigurationScheme] `json:"scheme,required"` + // The user of your origin database. + User param.Field[string] `json:"user,required"` +} + +func (r ConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Hyperdrive struct { + Caching HyperdriveCaching `json:"caching"` + Name string `json:"name"` + Origin Configuration `json:"origin"` + JSON hyperdriveJSON `json:"-"` +} + +// hyperdriveJSON contains the JSON metadata for the struct [Hyperdrive] +type hyperdriveJSON struct { + Caching apijson.Field + Name apijson.Field + Origin apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Hyperdrive) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hyperdriveJSON) RawJSON() string { + return r.raw +} + +type HyperdriveCaching struct { + // When set to true, disables the caching of SQL responses. (Default: false) + Disabled bool `json:"disabled"` + // When present, specifies max duration for which items should persist in the + // cache. (Default: 60) + MaxAge int64 `json:"max_age"` + // When present, indicates the number of seconds cache may serve the response after + // it becomes stale. (Default: 15) + StaleWhileRevalidate int64 `json:"stale_while_revalidate"` + JSON hyperdriveCachingJSON `json:"-"` +} + +// hyperdriveCachingJSON contains the JSON metadata for the struct +// [HyperdriveCaching] +type hyperdriveCachingJSON struct { + Disabled apijson.Field + MaxAge apijson.Field + StaleWhileRevalidate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HyperdriveCaching) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hyperdriveCachingJSON) RawJSON() string { + return r.raw +} + +type HyperdriveParam struct { + Caching param.Field[HyperdriveCachingParam] `json:"caching"` + Name param.Field[string] `json:"name"` + Origin param.Field[ConfigurationParam] `json:"origin"` +} + +func (r HyperdriveParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HyperdriveCachingParam struct { + // When set to true, disables the caching of SQL responses. (Default: false) + Disabled param.Field[bool] `json:"disabled"` + // When present, specifies max duration for which items should persist in the + // cache. (Default: 60) + MaxAge param.Field[int64] `json:"max_age"` + // When present, indicates the number of seconds cache may serve the response after + // it becomes stale. (Default: 15) + StaleWhileRevalidate param.Field[int64] `json:"stale_while_revalidate"` +} + +func (r HyperdriveCachingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} diff --git a/images/aliases.go b/images/aliases.go index 2bcee307525..20a6da359f6 100644 --- a/images/aliases.go +++ b/images/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/images/v1.go b/images/v1.go index 2ec51b21153..5508db86710 100644 --- a/images/v1.go +++ b/images/v1.go @@ -51,7 +51,7 @@ func NewV1Service(opts ...option.RequestOption) (r *V1Service) { func (r *V1Service) New(ctx context.Context, params V1NewParams, opts ...option.RequestOption) (res *Image, err error) { opts = append(r.Options[:], opts...) var env V1NewResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1", params.getAccountID()) + path := fmt.Sprintf("accounts/%s/images/v1", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return @@ -87,10 +87,10 @@ func (r *V1Service) ListAutoPaging(ctx context.Context, params V1ListParams, opt // Delete an image on Cloudflare Images. On success, all copies of the image are // deleted and purged from cache. -func (r *V1Service) Delete(ctx context.Context, imageID string, body V1DeleteParams, opts ...option.RequestOption) (res *V1DeleteResponse, err error) { +func (r *V1Service) Delete(ctx context.Context, imageID string, params V1DeleteParams, opts ...option.RequestOption) (res *V1DeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env V1DeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/%s", body.AccountID, imageID) + path := fmt.Sprintf("accounts/%s/images/v1/%s", params.AccountID, imageID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -140,8 +140,8 @@ type Image struct { // When the media item was uploaded. Uploaded time.Time `json:"uploaded" format:"date-time"` // Object specifying available variants for an image. - Variants []ImageVariant `json:"variants" format:"uri"` - JSON imageJSON `json:"-"` + Variants []ImageVariantsUnion `json:"variants" format:"uri"` + JSON imageJSON `json:"-"` } // imageJSON contains the JSON metadata for the struct [Image] @@ -168,13 +168,13 @@ func (r imageJSON) RawJSON() string { // // Union satisfied by [shared.UnionString], [shared.UnionString] or // [shared.UnionString]. -type ImageVariant interface { - ImplementsImagesImageVariant() +type ImageVariantsUnion interface { + ImplementsImagesImageVariantsUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ImageVariant)(nil)).Elem(), + reflect.TypeOf((*ImageVariantsUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -192,9 +192,9 @@ func init() { } type V1ListResponse struct { - Errors []V1ListResponseError `json:"errors,required"` - Messages []V1ListResponseMessage `json:"messages,required"` - Result V1ListResponseResult `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V1ListResponseResult `json:"result,required"` // Whether the API call was successful Success V1ListResponseSuccess `json:"success,required"` JSON v1ListResponseJSON `json:"-"` @@ -218,52 +218,6 @@ func (r v1ListResponseJSON) RawJSON() string { return r.raw } -type V1ListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1ListResponseErrorJSON `json:"-"` -} - -// v1ListResponseErrorJSON contains the JSON metadata for the struct -// [V1ListResponseError] -type v1ListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1ListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1ListResponseErrorJSON) RawJSON() string { - return r.raw -} - -type V1ListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1ListResponseMessageJSON `json:"-"` -} - -// v1ListResponseMessageJSON contains the JSON metadata for the struct -// [V1ListResponseMessage] -type v1ListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1ListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1ListResponseMessageJSON) RawJSON() string { - return r.raw -} - type V1ListResponseResult struct { Images []Image `json:"images"` JSON v1ListResponseResultJSON `json:"-"` @@ -301,13 +255,13 @@ func (r V1ListResponseSuccess) IsKnown() bool { } // Union satisfied by [images.V1DeleteResponseUnknown] or [shared.UnionString]. -type V1DeleteResponse interface { - ImplementsImagesV1DeleteResponse() +type V1DeleteResponseUnion interface { + ImplementsImagesV1DeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*V1DeleteResponse)(nil)).Elem(), + reflect.TypeOf((*V1DeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -316,56 +270,29 @@ func init() { ) } -// This interface is a union satisfied by one of the following: -// [V1NewParamsImagesImageUploadViaFile], [V1NewParamsImagesImageUploadViaURL]. -type V1NewParams interface { - ImplementsV1NewParams() - - getAccountID() param.Field[string] -} - -type V1NewParamsImagesImageUploadViaFile struct { +type V1NewParams struct { // Account identifier tag. AccountID param.Field[string] `path:"account_id,required"` - // An image binary data. - File param.Field[interface{}] `json:"file,required"` -} - -func (r V1NewParamsImagesImageUploadViaFile) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r V1NewParamsImagesImageUploadViaFile) getAccountID() param.Field[string] { - return r.AccountID -} - -func (V1NewParamsImagesImageUploadViaFile) ImplementsV1NewParams() { - -} - -type V1NewParamsImagesImageUploadViaURL struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // A URL to fetch an image from origin. - URL param.Field[string] `json:"url,required"` + // An image binary data. Only needed when type is uploading a file. + File param.Field[interface{}] `json:"file"` + // User modifiable key-value store. Can use used for keeping references to another + // system of record for managing images. + Metadata param.Field[interface{}] `json:"metadata"` + // Indicates whether the image requires a signature token for the access. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` + // A URL to fetch an image from origin. Only needed when type is uploading from a + // URL. + URL param.Field[string] `json:"url"` } -func (r V1NewParamsImagesImageUploadViaURL) MarshalJSON() (data []byte, err error) { +func (r V1NewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r V1NewParamsImagesImageUploadViaURL) getAccountID() param.Field[string] { - return r.AccountID -} - -func (V1NewParamsImagesImageUploadViaURL) ImplementsV1NewParams() { - -} - type V1NewResponseEnvelope struct { - Errors []V1NewResponseEnvelopeErrors `json:"errors,required"` - Messages []V1NewResponseEnvelopeMessages `json:"messages,required"` - Result Image `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Image `json:"result,required"` // Whether the API call was successful Success V1NewResponseEnvelopeSuccess `json:"success,required"` JSON v1NewResponseEnvelopeJSON `json:"-"` @@ -390,52 +317,6 @@ func (r v1NewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1NewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1NewResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1NewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1NewResponseEnvelopeErrors] -type v1NewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1NewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1NewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1NewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1NewResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1NewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [V1NewResponseEnvelopeMessages] -type v1NewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1NewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1NewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1NewResponseEnvelopeSuccess bool @@ -463,7 +344,7 @@ type V1ListParams struct { // URLQuery serializes [V1ListParams]'s query parameters as `url.Values`. func (r V1ListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -471,12 +352,17 @@ func (r V1ListParams) URLQuery() (v url.Values) { type V1DeleteParams struct { // Account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r V1DeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type V1DeleteResponseEnvelope struct { - Errors []V1DeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []V1DeleteResponseEnvelopeMessages `json:"messages,required"` - Result V1DeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V1DeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success V1DeleteResponseEnvelopeSuccess `json:"success,required"` JSON v1DeleteResponseEnvelopeJSON `json:"-"` @@ -501,52 +387,6 @@ func (r v1DeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1DeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1DeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1DeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1DeleteResponseEnvelopeErrors] -type v1DeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1DeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1DeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1DeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1DeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1DeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [V1DeleteResponseEnvelopeMessages] -type v1DeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1DeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1DeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1DeleteResponseEnvelopeSuccess bool @@ -579,9 +419,9 @@ func (r V1EditParams) MarshalJSON() (data []byte, err error) { } type V1EditResponseEnvelope struct { - Errors []V1EditResponseEnvelopeErrors `json:"errors,required"` - Messages []V1EditResponseEnvelopeMessages `json:"messages,required"` - Result Image `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Image `json:"result,required"` // Whether the API call was successful Success V1EditResponseEnvelopeSuccess `json:"success,required"` JSON v1EditResponseEnvelopeJSON `json:"-"` @@ -606,52 +446,6 @@ func (r v1EditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1EditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1EditResponseEnvelopeErrors] -type v1EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1EditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [V1EditResponseEnvelopeMessages] -type v1EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1EditResponseEnvelopeSuccess bool @@ -673,9 +467,9 @@ type V1GetParams struct { } type V1GetResponseEnvelope struct { - Errors []V1GetResponseEnvelopeErrors `json:"errors,required"` - Messages []V1GetResponseEnvelopeMessages `json:"messages,required"` - Result Image `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Image `json:"result,required"` // Whether the API call was successful Success V1GetResponseEnvelopeSuccess `json:"success,required"` JSON v1GetResponseEnvelopeJSON `json:"-"` @@ -700,52 +494,6 @@ func (r v1GetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1GetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1GetResponseEnvelopeErrors] -type v1GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1GetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [V1GetResponseEnvelopeMessages] -type v1GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1GetResponseEnvelopeSuccess bool diff --git a/images/v1_test.go b/images/v1_test.go index f457523c26f..3971ac966bf 100644 --- a/images/v1_test.go +++ b/images/v1_test.go @@ -14,7 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/option" ) -func TestV1New(t *testing.T) { +func TestV1NewWithOptionalParams(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 { @@ -28,9 +28,12 @@ func TestV1New(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Images.V1.New(context.TODO(), images.V1NewParamsImagesImageUploadViaFile{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - File: cloudflare.F[any](map[string]interface{}{}), + _, err := client.Images.V1.New(context.TODO(), images.V1NewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + File: cloudflare.F[any](map[string]interface{}{}), + Metadata: cloudflare.F[any](map[string]interface{}{}), + RequireSignedURLs: cloudflare.F(true), + URL: cloudflare.F("https://example.com/path/to/logo.png"), }) if err != nil { var apierr *cloudflare.Error @@ -88,6 +91,7 @@ func TestV1Delete(t *testing.T) { "string", images.V1DeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/images/v1key.go b/images/v1key.go index c65a531c3d8..14095d0705d 100644 --- a/images/v1key.go +++ b/images/v1key.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,7 +32,7 @@ func NewV1KeyService(opts ...option.RequestOption) (r *V1KeyService) { } // Create a new signing key with specified name. Returns all keys available. -func (r *V1KeyService) Update(ctx context.Context, signingKeyName string, body V1KeyUpdateParams, opts ...option.RequestOption) (res *ImagesImageKeys, err error) { +func (r *V1KeyService) Update(ctx context.Context, signingKeyName string, body V1KeyUpdateParams, opts ...option.RequestOption) (res *Key, err error) { opts = append(r.Options[:], opts...) var env V1KeyUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/keys/%s", body.AccountID, signingKeyName) @@ -44,7 +45,7 @@ func (r *V1KeyService) Update(ctx context.Context, signingKeyName string, body V } // Lists your signing keys. These can be found on your Cloudflare Images dashboard. -func (r *V1KeyService) List(ctx context.Context, query V1KeyListParams, opts ...option.RequestOption) (res *ImagesImageKeys, err error) { +func (r *V1KeyService) List(ctx context.Context, query V1KeyListParams, opts ...option.RequestOption) (res *Key, err error) { opts = append(r.Options[:], opts...) var env V1KeyListResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/keys", query.AccountID) @@ -58,7 +59,7 @@ func (r *V1KeyService) List(ctx context.Context, query V1KeyListParams, opts ... // Delete signing key with specified name. Returns all keys available. When last // key is removed, a new default signing key will be generated. -func (r *V1KeyService) Delete(ctx context.Context, signingKeyName string, body V1KeyDeleteParams, opts ...option.RequestOption) (res *ImagesImageKeys, err error) { +func (r *V1KeyService) Delete(ctx context.Context, signingKeyName string, body V1KeyDeleteParams, opts ...option.RequestOption) (res *Key, err error) { opts = append(r.Options[:], opts...) var env V1KeyDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/keys/%s", body.AccountID, signingKeyName) @@ -70,48 +71,47 @@ func (r *V1KeyService) Delete(ctx context.Context, signingKeyName string, body V return } -type ImagesImageKeys struct { - Keys []ImagesImageKeysKey `json:"keys"` - JSON imagesImageKeysJSON `json:"-"` +type Key struct { + Keys []KeyKey `json:"keys"` + JSON keyJSON `json:"-"` } -// imagesImageKeysJSON contains the JSON metadata for the struct [ImagesImageKeys] -type imagesImageKeysJSON struct { +// keyJSON contains the JSON metadata for the struct [Key] +type keyJSON struct { Keys apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ImagesImageKeys) UnmarshalJSON(data []byte) (err error) { +func (r *Key) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r imagesImageKeysJSON) RawJSON() string { +func (r keyJSON) RawJSON() string { return r.raw } -type ImagesImageKeysKey struct { +type KeyKey struct { // Key name. Name string `json:"name"` // Key value. - Value string `json:"value"` - JSON imagesImageKeysKeyJSON `json:"-"` + Value string `json:"value"` + JSON keyKeyJSON `json:"-"` } -// imagesImageKeysKeyJSON contains the JSON metadata for the struct -// [ImagesImageKeysKey] -type imagesImageKeysKeyJSON struct { +// keyKeyJSON contains the JSON metadata for the struct [KeyKey] +type keyKeyJSON struct { Name apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ImagesImageKeysKey) UnmarshalJSON(data []byte) (err error) { +func (r *KeyKey) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r imagesImageKeysKeyJSON) RawJSON() string { +func (r keyKeyJSON) RawJSON() string { return r.raw } @@ -121,9 +121,9 @@ type V1KeyUpdateParams struct { } type V1KeyUpdateResponseEnvelope struct { - Errors []V1KeyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []V1KeyUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ImagesImageKeys `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Key `json:"result,required"` // Whether the API call was successful Success V1KeyUpdateResponseEnvelopeSuccess `json:"success,required"` JSON v1KeyUpdateResponseEnvelopeJSON `json:"-"` @@ -148,52 +148,6 @@ func (r v1KeyUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1KeyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1KeyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1KeyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1KeyUpdateResponseEnvelopeErrors] -type v1KeyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1KeyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1KeyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1KeyUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1KeyUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1KeyUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V1KeyUpdateResponseEnvelopeMessages] -type v1KeyUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1KeyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1KeyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1KeyUpdateResponseEnvelopeSuccess bool @@ -215,9 +169,9 @@ type V1KeyListParams struct { } type V1KeyListResponseEnvelope struct { - Errors []V1KeyListResponseEnvelopeErrors `json:"errors,required"` - Messages []V1KeyListResponseEnvelopeMessages `json:"messages,required"` - Result ImagesImageKeys `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Key `json:"result,required"` // Whether the API call was successful Success V1KeyListResponseEnvelopeSuccess `json:"success,required"` JSON v1KeyListResponseEnvelopeJSON `json:"-"` @@ -242,52 +196,6 @@ func (r v1KeyListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1KeyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1KeyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1KeyListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1KeyListResponseEnvelopeErrors] -type v1KeyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1KeyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1KeyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1KeyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1KeyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1KeyListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [V1KeyListResponseEnvelopeMessages] -type v1KeyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1KeyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1KeyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1KeyListResponseEnvelopeSuccess bool @@ -309,9 +217,9 @@ type V1KeyDeleteParams struct { } type V1KeyDeleteResponseEnvelope struct { - Errors []V1KeyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []V1KeyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ImagesImageKeys `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Key `json:"result,required"` // Whether the API call was successful Success V1KeyDeleteResponseEnvelopeSuccess `json:"success,required"` JSON v1KeyDeleteResponseEnvelopeJSON `json:"-"` @@ -336,52 +244,6 @@ func (r v1KeyDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1KeyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1KeyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1KeyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1KeyDeleteResponseEnvelopeErrors] -type v1KeyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1KeyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1KeyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1KeyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1KeyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1KeyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V1KeyDeleteResponseEnvelopeMessages] -type v1KeyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1KeyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1KeyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1KeyDeleteResponseEnvelopeSuccess bool diff --git a/images/v1key_test.go b/images/v1key_test.go index beb81dbced1..670ae3783c8 100644 --- a/images/v1key_test.go +++ b/images/v1key_test.go @@ -30,7 +30,7 @@ func TestV1KeyUpdate(t *testing.T) { ) _, err := client.Images.V1.Keys.Update( context.TODO(), - "string", + "someKey", images.V1KeyUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, @@ -86,7 +86,7 @@ func TestV1KeyDelete(t *testing.T) { ) _, err := client.Images.V1.Keys.Delete( context.TODO(), - "string", + "someKey", images.V1KeyDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, diff --git a/images/v1stat.go b/images/v1stat.go index 17d3dea7062..eb1dcc00949 100644 --- a/images/v1stat.go +++ b/images/v1stat.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,7 +32,7 @@ func NewV1StatService(opts ...option.RequestOption) (r *V1StatService) { } // Fetch usage statistics details for Cloudflare Images. -func (r *V1StatService) Get(ctx context.Context, query V1StatGetParams, opts ...option.RequestOption) (res *ImagesImagesStats, err error) { +func (r *V1StatService) Get(ctx context.Context, query V1StatGetParams, opts ...option.RequestOption) (res *Stat, err error) { opts = append(r.Options[:], opts...) var env V1StatGetResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/stats", query.AccountID) @@ -43,49 +44,47 @@ func (r *V1StatService) Get(ctx context.Context, query V1StatGetParams, opts ... return } -type ImagesImagesStats struct { - Count ImagesImagesStatsCount `json:"count"` - JSON imagesImagesStatsJSON `json:"-"` +type Stat struct { + Count StatCount `json:"count"` + JSON statJSON `json:"-"` } -// imagesImagesStatsJSON contains the JSON metadata for the struct -// [ImagesImagesStats] -type imagesImagesStatsJSON struct { +// statJSON contains the JSON metadata for the struct [Stat] +type statJSON struct { Count apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ImagesImagesStats) UnmarshalJSON(data []byte) (err error) { +func (r *Stat) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r imagesImagesStatsJSON) RawJSON() string { +func (r statJSON) RawJSON() string { return r.raw } -type ImagesImagesStatsCount struct { +type StatCount struct { // Cloudflare Images allowed usage. Allowed float64 `json:"allowed"` // Cloudflare Images current usage. - Current float64 `json:"current"` - JSON imagesImagesStatsCountJSON `json:"-"` + Current float64 `json:"current"` + JSON statCountJSON `json:"-"` } -// imagesImagesStatsCountJSON contains the JSON metadata for the struct -// [ImagesImagesStatsCount] -type imagesImagesStatsCountJSON struct { +// statCountJSON contains the JSON metadata for the struct [StatCount] +type statCountJSON struct { Allowed apijson.Field Current apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ImagesImagesStatsCount) UnmarshalJSON(data []byte) (err error) { +func (r *StatCount) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r imagesImagesStatsCountJSON) RawJSON() string { +func (r statCountJSON) RawJSON() string { return r.raw } @@ -95,9 +94,9 @@ type V1StatGetParams struct { } type V1StatGetResponseEnvelope struct { - Errors []V1StatGetResponseEnvelopeErrors `json:"errors,required"` - Messages []V1StatGetResponseEnvelopeMessages `json:"messages,required"` - Result ImagesImagesStats `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Stat `json:"result,required"` // Whether the API call was successful Success V1StatGetResponseEnvelopeSuccess `json:"success,required"` JSON v1StatGetResponseEnvelopeJSON `json:"-"` @@ -122,52 +121,6 @@ func (r v1StatGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1StatGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1StatGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1StatGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1StatGetResponseEnvelopeErrors] -type v1StatGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1StatGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1StatGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1StatGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1StatGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1StatGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [V1StatGetResponseEnvelopeMessages] -type v1StatGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1StatGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1StatGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1StatGetResponseEnvelopeSuccess bool diff --git a/images/v1variant.go b/images/v1variant.go index 305b198cbcb..1e1222b24a2 100644 --- a/images/v1variant.go +++ b/images/v1variant.go @@ -34,7 +34,7 @@ func NewV1VariantService(opts ...option.RequestOption) (r *V1VariantService) { } // Specify variants that allow you to resize images for different use cases. -func (r *V1VariantService) New(ctx context.Context, params V1VariantNewParams, opts ...option.RequestOption) (res *V1ImageVariant, err error) { +func (r *V1VariantService) New(ctx context.Context, params V1VariantNewParams, opts ...option.RequestOption) (res *V1VariantNewResponse, err error) { opts = append(r.Options[:], opts...) var env V1VariantNewResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/variants", params.AccountID) @@ -47,7 +47,7 @@ func (r *V1VariantService) New(ctx context.Context, params V1VariantNewParams, o } // Lists existing variants. -func (r *V1VariantService) List(ctx context.Context, query V1VariantListParams, opts ...option.RequestOption) (res *V1ImageVariants, err error) { +func (r *V1VariantService) List(ctx context.Context, query V1VariantListParams, opts ...option.RequestOption) (res *Variant, err error) { opts = append(r.Options[:], opts...) var env V1VariantListResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/variants", query.AccountID) @@ -60,10 +60,10 @@ func (r *V1VariantService) List(ctx context.Context, query V1VariantListParams, } // Deleting a variant purges the cache for all images associated with the variant. -func (r *V1VariantService) Delete(ctx context.Context, variantID string, body V1VariantDeleteParams, opts ...option.RequestOption) (res *V1VariantDeleteResponse, err error) { +func (r *V1VariantService) Delete(ctx context.Context, variantID string, params V1VariantDeleteParams, opts ...option.RequestOption) (res *V1VariantDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env V1VariantDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/variants/%s", body.AccountID, variantID) + path := fmt.Sprintf("accounts/%s/images/v1/variants/%s", params.AccountID, variantID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -73,7 +73,7 @@ func (r *V1VariantService) Delete(ctx context.Context, variantID string, body V1 } // Updating a variant purges the cache for all images associated with the variant. -func (r *V1VariantService) Edit(ctx context.Context, variantID string, params V1VariantEditParams, opts ...option.RequestOption) (res *V1ImageVariant, err error) { +func (r *V1VariantService) Edit(ctx context.Context, variantID string, params V1VariantEditParams, opts ...option.RequestOption) (res *V1VariantEditResponse, err error) { opts = append(r.Options[:], opts...) var env V1VariantEditResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/variants/%s", params.AccountID, variantID) @@ -86,7 +86,7 @@ func (r *V1VariantService) Edit(ctx context.Context, variantID string, params V1 } // Fetch details for a single variant. -func (r *V1VariantService) Get(ctx context.Context, variantID string, query V1VariantGetParams, opts ...option.RequestOption) (res *V1ImageVariant, err error) { +func (r *V1VariantService) Get(ctx context.Context, variantID string, query V1VariantGetParams, opts ...option.RequestOption) (res *V1VariantGetResponse, err error) { opts = append(r.Options[:], opts...) var env V1VariantGetResponseEnvelope path := fmt.Sprintf("accounts/%s/images/v1/variants/%s", query.AccountID, variantID) @@ -98,39 +98,59 @@ func (r *V1VariantService) Get(ctx context.Context, variantID string, query V1Va return } -type V1ImageVariant struct { - Variant V1ImageVariantVariant `json:"variant"` - JSON v1ImageVariantJSON `json:"-"` +type Variant struct { + Variants VariantVariants `json:"variants"` + JSON variantJSON `json:"-"` } -// v1ImageVariantJSON contains the JSON metadata for the struct [V1ImageVariant] -type v1ImageVariantJSON struct { - Variant apijson.Field +// variantJSON contains the JSON metadata for the struct [Variant] +type variantJSON struct { + Variants apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Variant) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantJSON) RawJSON() string { + return r.raw +} + +type VariantVariants struct { + Hero VariantVariantsHero `json:"hero"` + JSON variantVariantsJSON `json:"-"` +} + +// variantVariantsJSON contains the JSON metadata for the struct [VariantVariants] +type variantVariantsJSON struct { + Hero apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *V1ImageVariant) UnmarshalJSON(data []byte) (err error) { +func (r *VariantVariants) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r v1ImageVariantJSON) RawJSON() string { +func (r variantVariantsJSON) RawJSON() string { return r.raw } -type V1ImageVariantVariant struct { +type VariantVariantsHero struct { ID string `json:"id,required"` // Allows you to define image resizing sizes for different use cases. - Options V1ImageVariantVariantOptions `json:"options,required"` + Options VariantVariantsHeroOptions `json:"options,required"` // Indicates whether the variant can access an image without a signature, // regardless of image access control. - NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` - JSON v1ImageVariantVariantJSON `json:"-"` + NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` + JSON variantVariantsHeroJSON `json:"-"` } -// v1ImageVariantVariantJSON contains the JSON metadata for the struct -// [V1ImageVariantVariant] -type v1ImageVariantVariantJSON struct { +// variantVariantsHeroJSON contains the JSON metadata for the struct +// [VariantVariantsHero] +type variantVariantsHeroJSON struct { ID apijson.Field Options apijson.Field NeverRequireSignedURLs apijson.Field @@ -138,31 +158,31 @@ type v1ImageVariantVariantJSON struct { ExtraFields map[string]apijson.Field } -func (r *V1ImageVariantVariant) UnmarshalJSON(data []byte) (err error) { +func (r *VariantVariantsHero) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r v1ImageVariantVariantJSON) RawJSON() string { +func (r variantVariantsHeroJSON) RawJSON() string { return r.raw } // Allows you to define image resizing sizes for different use cases. -type V1ImageVariantVariantOptions struct { +type VariantVariantsHeroOptions struct { // The fit property describes how the width and height dimensions should be // interpreted. - Fit V1ImageVariantVariantOptionsFit `json:"fit,required"` + Fit VariantVariantsHeroOptionsFit `json:"fit,required"` // Maximum height in image pixels. Height float64 `json:"height,required"` // What EXIF data should be preserved in the output image. - Metadata V1ImageVariantVariantOptionsMetadata `json:"metadata,required"` + Metadata VariantVariantsHeroOptionsMetadata `json:"metadata,required"` // Maximum width in image pixels. - Width float64 `json:"width,required"` - JSON v1ImageVariantVariantOptionsJSON `json:"-"` + Width float64 `json:"width,required"` + JSON variantVariantsHeroOptionsJSON `json:"-"` } -// v1ImageVariantVariantOptionsJSON contains the JSON metadata for the struct -// [V1ImageVariantVariantOptions] -type v1ImageVariantVariantOptionsJSON struct { +// variantVariantsHeroOptionsJSON contains the JSON metadata for the struct +// [VariantVariantsHeroOptions] +type variantVariantsHeroOptionsJSON struct { Fit apijson.Field Height apijson.Field Metadata apijson.Field @@ -171,105 +191,85 @@ type v1ImageVariantVariantOptionsJSON struct { ExtraFields map[string]apijson.Field } -func (r *V1ImageVariantVariantOptions) UnmarshalJSON(data []byte) (err error) { +func (r *VariantVariantsHeroOptions) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r v1ImageVariantVariantOptionsJSON) RawJSON() string { +func (r variantVariantsHeroOptionsJSON) RawJSON() string { return r.raw } // The fit property describes how the width and height dimensions should be // interpreted. -type V1ImageVariantVariantOptionsFit string +type VariantVariantsHeroOptionsFit string const ( - V1ImageVariantVariantOptionsFitScaleDown V1ImageVariantVariantOptionsFit = "scale-down" - V1ImageVariantVariantOptionsFitContain V1ImageVariantVariantOptionsFit = "contain" - V1ImageVariantVariantOptionsFitCover V1ImageVariantVariantOptionsFit = "cover" - V1ImageVariantVariantOptionsFitCrop V1ImageVariantVariantOptionsFit = "crop" - V1ImageVariantVariantOptionsFitPad V1ImageVariantVariantOptionsFit = "pad" + VariantVariantsHeroOptionsFitScaleDown VariantVariantsHeroOptionsFit = "scale-down" + VariantVariantsHeroOptionsFitContain VariantVariantsHeroOptionsFit = "contain" + VariantVariantsHeroOptionsFitCover VariantVariantsHeroOptionsFit = "cover" + VariantVariantsHeroOptionsFitCrop VariantVariantsHeroOptionsFit = "crop" + VariantVariantsHeroOptionsFitPad VariantVariantsHeroOptionsFit = "pad" ) -func (r V1ImageVariantVariantOptionsFit) IsKnown() bool { +func (r VariantVariantsHeroOptionsFit) IsKnown() bool { switch r { - case V1ImageVariantVariantOptionsFitScaleDown, V1ImageVariantVariantOptionsFitContain, V1ImageVariantVariantOptionsFitCover, V1ImageVariantVariantOptionsFitCrop, V1ImageVariantVariantOptionsFitPad: + case VariantVariantsHeroOptionsFitScaleDown, VariantVariantsHeroOptionsFitContain, VariantVariantsHeroOptionsFitCover, VariantVariantsHeroOptionsFitCrop, VariantVariantsHeroOptionsFitPad: return true } return false } // What EXIF data should be preserved in the output image. -type V1ImageVariantVariantOptionsMetadata string +type VariantVariantsHeroOptionsMetadata string const ( - V1ImageVariantVariantOptionsMetadataKeep V1ImageVariantVariantOptionsMetadata = "keep" - V1ImageVariantVariantOptionsMetadataCopyright V1ImageVariantVariantOptionsMetadata = "copyright" - V1ImageVariantVariantOptionsMetadataNone V1ImageVariantVariantOptionsMetadata = "none" + VariantVariantsHeroOptionsMetadataKeep VariantVariantsHeroOptionsMetadata = "keep" + VariantVariantsHeroOptionsMetadataCopyright VariantVariantsHeroOptionsMetadata = "copyright" + VariantVariantsHeroOptionsMetadataNone VariantVariantsHeroOptionsMetadata = "none" ) -func (r V1ImageVariantVariantOptionsMetadata) IsKnown() bool { +func (r VariantVariantsHeroOptionsMetadata) IsKnown() bool { switch r { - case V1ImageVariantVariantOptionsMetadataKeep, V1ImageVariantVariantOptionsMetadataCopyright, V1ImageVariantVariantOptionsMetadataNone: + case VariantVariantsHeroOptionsMetadataKeep, VariantVariantsHeroOptionsMetadataCopyright, VariantVariantsHeroOptionsMetadataNone: return true } return false } -type V1ImageVariants struct { - Variants V1ImageVariantsVariants `json:"variants"` - JSON v1ImageVariantsJSON `json:"-"` +type V1VariantNewResponse struct { + Variant V1VariantNewResponseVariant `json:"variant"` + JSON v1VariantNewResponseJSON `json:"-"` } -// v1ImageVariantsJSON contains the JSON metadata for the struct [V1ImageVariants] -type v1ImageVariantsJSON struct { - Variants apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1ImageVariants) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1ImageVariantsJSON) RawJSON() string { - return r.raw -} - -type V1ImageVariantsVariants struct { - Hero V1ImageVariantsVariantsHero `json:"hero"` - JSON v1ImageVariantsVariantsJSON `json:"-"` -} - -// v1ImageVariantsVariantsJSON contains the JSON metadata for the struct -// [V1ImageVariantsVariants] -type v1ImageVariantsVariantsJSON struct { - Hero apijson.Field +// v1VariantNewResponseJSON contains the JSON metadata for the struct +// [V1VariantNewResponse] +type v1VariantNewResponseJSON struct { + Variant apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *V1ImageVariantsVariants) UnmarshalJSON(data []byte) (err error) { +func (r *V1VariantNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r v1ImageVariantsVariantsJSON) RawJSON() string { +func (r v1VariantNewResponseJSON) RawJSON() string { return r.raw } -type V1ImageVariantsVariantsHero struct { +type V1VariantNewResponseVariant struct { ID string `json:"id,required"` // Allows you to define image resizing sizes for different use cases. - Options V1ImageVariantsVariantsHeroOptions `json:"options,required"` + Options V1VariantNewResponseVariantOptions `json:"options,required"` // Indicates whether the variant can access an image without a signature, // regardless of image access control. NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` - JSON v1ImageVariantsVariantsHeroJSON `json:"-"` + JSON v1VariantNewResponseVariantJSON `json:"-"` } -// v1ImageVariantsVariantsHeroJSON contains the JSON metadata for the struct -// [V1ImageVariantsVariantsHero] -type v1ImageVariantsVariantsHeroJSON struct { +// v1VariantNewResponseVariantJSON contains the JSON metadata for the struct +// [V1VariantNewResponseVariant] +type v1VariantNewResponseVariantJSON struct { ID apijson.Field Options apijson.Field NeverRequireSignedURLs apijson.Field @@ -277,31 +277,31 @@ type v1ImageVariantsVariantsHeroJSON struct { ExtraFields map[string]apijson.Field } -func (r *V1ImageVariantsVariantsHero) UnmarshalJSON(data []byte) (err error) { +func (r *V1VariantNewResponseVariant) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r v1ImageVariantsVariantsHeroJSON) RawJSON() string { +func (r v1VariantNewResponseVariantJSON) RawJSON() string { return r.raw } // Allows you to define image resizing sizes for different use cases. -type V1ImageVariantsVariantsHeroOptions struct { +type V1VariantNewResponseVariantOptions struct { // The fit property describes how the width and height dimensions should be // interpreted. - Fit V1ImageVariantsVariantsHeroOptionsFit `json:"fit,required"` + Fit V1VariantNewResponseVariantOptionsFit `json:"fit,required"` // Maximum height in image pixels. Height float64 `json:"height,required"` // What EXIF data should be preserved in the output image. - Metadata V1ImageVariantsVariantsHeroOptionsMetadata `json:"metadata,required"` + Metadata V1VariantNewResponseVariantOptionsMetadata `json:"metadata,required"` // Maximum width in image pixels. Width float64 `json:"width,required"` - JSON v1ImageVariantsVariantsHeroOptionsJSON `json:"-"` + JSON v1VariantNewResponseVariantOptionsJSON `json:"-"` } -// v1ImageVariantsVariantsHeroOptionsJSON contains the JSON metadata for the struct -// [V1ImageVariantsVariantsHeroOptions] -type v1ImageVariantsVariantsHeroOptionsJSON struct { +// v1VariantNewResponseVariantOptionsJSON contains the JSON metadata for the struct +// [V1VariantNewResponseVariantOptions] +type v1VariantNewResponseVariantOptionsJSON struct { Fit apijson.Field Height apijson.Field Metadata apijson.Field @@ -310,46 +310,46 @@ type v1ImageVariantsVariantsHeroOptionsJSON struct { ExtraFields map[string]apijson.Field } -func (r *V1ImageVariantsVariantsHeroOptions) UnmarshalJSON(data []byte) (err error) { +func (r *V1VariantNewResponseVariantOptions) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r v1ImageVariantsVariantsHeroOptionsJSON) RawJSON() string { +func (r v1VariantNewResponseVariantOptionsJSON) RawJSON() string { return r.raw } // The fit property describes how the width and height dimensions should be // interpreted. -type V1ImageVariantsVariantsHeroOptionsFit string +type V1VariantNewResponseVariantOptionsFit string const ( - V1ImageVariantsVariantsHeroOptionsFitScaleDown V1ImageVariantsVariantsHeroOptionsFit = "scale-down" - V1ImageVariantsVariantsHeroOptionsFitContain V1ImageVariantsVariantsHeroOptionsFit = "contain" - V1ImageVariantsVariantsHeroOptionsFitCover V1ImageVariantsVariantsHeroOptionsFit = "cover" - V1ImageVariantsVariantsHeroOptionsFitCrop V1ImageVariantsVariantsHeroOptionsFit = "crop" - V1ImageVariantsVariantsHeroOptionsFitPad V1ImageVariantsVariantsHeroOptionsFit = "pad" + V1VariantNewResponseVariantOptionsFitScaleDown V1VariantNewResponseVariantOptionsFit = "scale-down" + V1VariantNewResponseVariantOptionsFitContain V1VariantNewResponseVariantOptionsFit = "contain" + V1VariantNewResponseVariantOptionsFitCover V1VariantNewResponseVariantOptionsFit = "cover" + V1VariantNewResponseVariantOptionsFitCrop V1VariantNewResponseVariantOptionsFit = "crop" + V1VariantNewResponseVariantOptionsFitPad V1VariantNewResponseVariantOptionsFit = "pad" ) -func (r V1ImageVariantsVariantsHeroOptionsFit) IsKnown() bool { +func (r V1VariantNewResponseVariantOptionsFit) IsKnown() bool { switch r { - case V1ImageVariantsVariantsHeroOptionsFitScaleDown, V1ImageVariantsVariantsHeroOptionsFitContain, V1ImageVariantsVariantsHeroOptionsFitCover, V1ImageVariantsVariantsHeroOptionsFitCrop, V1ImageVariantsVariantsHeroOptionsFitPad: + case V1VariantNewResponseVariantOptionsFitScaleDown, V1VariantNewResponseVariantOptionsFitContain, V1VariantNewResponseVariantOptionsFitCover, V1VariantNewResponseVariantOptionsFitCrop, V1VariantNewResponseVariantOptionsFitPad: return true } return false } // What EXIF data should be preserved in the output image. -type V1ImageVariantsVariantsHeroOptionsMetadata string +type V1VariantNewResponseVariantOptionsMetadata string const ( - V1ImageVariantsVariantsHeroOptionsMetadataKeep V1ImageVariantsVariantsHeroOptionsMetadata = "keep" - V1ImageVariantsVariantsHeroOptionsMetadataCopyright V1ImageVariantsVariantsHeroOptionsMetadata = "copyright" - V1ImageVariantsVariantsHeroOptionsMetadataNone V1ImageVariantsVariantsHeroOptionsMetadata = "none" + V1VariantNewResponseVariantOptionsMetadataKeep V1VariantNewResponseVariantOptionsMetadata = "keep" + V1VariantNewResponseVariantOptionsMetadataCopyright V1VariantNewResponseVariantOptionsMetadata = "copyright" + V1VariantNewResponseVariantOptionsMetadataNone V1VariantNewResponseVariantOptionsMetadata = "none" ) -func (r V1ImageVariantsVariantsHeroOptionsMetadata) IsKnown() bool { +func (r V1VariantNewResponseVariantOptionsMetadata) IsKnown() bool { switch r { - case V1ImageVariantsVariantsHeroOptionsMetadataKeep, V1ImageVariantsVariantsHeroOptionsMetadataCopyright, V1ImageVariantsVariantsHeroOptionsMetadataNone: + case V1VariantNewResponseVariantOptionsMetadataKeep, V1VariantNewResponseVariantOptionsMetadataCopyright, V1VariantNewResponseVariantOptionsMetadataNone: return true } return false @@ -357,13 +357,13 @@ func (r V1ImageVariantsVariantsHeroOptionsMetadata) IsKnown() bool { // Union satisfied by [images.V1VariantDeleteResponseUnknown] or // [shared.UnionString]. -type V1VariantDeleteResponse interface { - ImplementsImagesV1VariantDeleteResponse() +type V1VariantDeleteResponseUnion interface { + ImplementsImagesV1VariantDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*V1VariantDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*V1VariantDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -372,6 +372,244 @@ func init() { ) } +type V1VariantEditResponse struct { + Variant V1VariantEditResponseVariant `json:"variant"` + JSON v1VariantEditResponseJSON `json:"-"` +} + +// v1VariantEditResponseJSON contains the JSON metadata for the struct +// [V1VariantEditResponse] +type v1VariantEditResponseJSON struct { + Variant apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantEditResponseJSON) RawJSON() string { + return r.raw +} + +type V1VariantEditResponseVariant struct { + ID string `json:"id,required"` + // Allows you to define image resizing sizes for different use cases. + Options V1VariantEditResponseVariantOptions `json:"options,required"` + // Indicates whether the variant can access an image without a signature, + // regardless of image access control. + NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` + JSON v1VariantEditResponseVariantJSON `json:"-"` +} + +// v1VariantEditResponseVariantJSON contains the JSON metadata for the struct +// [V1VariantEditResponseVariant] +type v1VariantEditResponseVariantJSON struct { + ID apijson.Field + Options apijson.Field + NeverRequireSignedURLs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantEditResponseVariant) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantEditResponseVariantJSON) RawJSON() string { + return r.raw +} + +// Allows you to define image resizing sizes for different use cases. +type V1VariantEditResponseVariantOptions struct { + // The fit property describes how the width and height dimensions should be + // interpreted. + Fit V1VariantEditResponseVariantOptionsFit `json:"fit,required"` + // Maximum height in image pixels. + Height float64 `json:"height,required"` + // What EXIF data should be preserved in the output image. + Metadata V1VariantEditResponseVariantOptionsMetadata `json:"metadata,required"` + // Maximum width in image pixels. + Width float64 `json:"width,required"` + JSON v1VariantEditResponseVariantOptionsJSON `json:"-"` +} + +// v1VariantEditResponseVariantOptionsJSON contains the JSON metadata for the +// struct [V1VariantEditResponseVariantOptions] +type v1VariantEditResponseVariantOptionsJSON struct { + Fit apijson.Field + Height apijson.Field + Metadata apijson.Field + Width apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantEditResponseVariantOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantEditResponseVariantOptionsJSON) RawJSON() string { + return r.raw +} + +// The fit property describes how the width and height dimensions should be +// interpreted. +type V1VariantEditResponseVariantOptionsFit string + +const ( + V1VariantEditResponseVariantOptionsFitScaleDown V1VariantEditResponseVariantOptionsFit = "scale-down" + V1VariantEditResponseVariantOptionsFitContain V1VariantEditResponseVariantOptionsFit = "contain" + V1VariantEditResponseVariantOptionsFitCover V1VariantEditResponseVariantOptionsFit = "cover" + V1VariantEditResponseVariantOptionsFitCrop V1VariantEditResponseVariantOptionsFit = "crop" + V1VariantEditResponseVariantOptionsFitPad V1VariantEditResponseVariantOptionsFit = "pad" +) + +func (r V1VariantEditResponseVariantOptionsFit) IsKnown() bool { + switch r { + case V1VariantEditResponseVariantOptionsFitScaleDown, V1VariantEditResponseVariantOptionsFitContain, V1VariantEditResponseVariantOptionsFitCover, V1VariantEditResponseVariantOptionsFitCrop, V1VariantEditResponseVariantOptionsFitPad: + return true + } + return false +} + +// What EXIF data should be preserved in the output image. +type V1VariantEditResponseVariantOptionsMetadata string + +const ( + V1VariantEditResponseVariantOptionsMetadataKeep V1VariantEditResponseVariantOptionsMetadata = "keep" + V1VariantEditResponseVariantOptionsMetadataCopyright V1VariantEditResponseVariantOptionsMetadata = "copyright" + V1VariantEditResponseVariantOptionsMetadataNone V1VariantEditResponseVariantOptionsMetadata = "none" +) + +func (r V1VariantEditResponseVariantOptionsMetadata) IsKnown() bool { + switch r { + case V1VariantEditResponseVariantOptionsMetadataKeep, V1VariantEditResponseVariantOptionsMetadataCopyright, V1VariantEditResponseVariantOptionsMetadataNone: + return true + } + return false +} + +type V1VariantGetResponse struct { + Variant V1VariantGetResponseVariant `json:"variant"` + JSON v1VariantGetResponseJSON `json:"-"` +} + +// v1VariantGetResponseJSON contains the JSON metadata for the struct +// [V1VariantGetResponse] +type v1VariantGetResponseJSON struct { + Variant apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantGetResponseJSON) RawJSON() string { + return r.raw +} + +type V1VariantGetResponseVariant struct { + ID string `json:"id,required"` + // Allows you to define image resizing sizes for different use cases. + Options V1VariantGetResponseVariantOptions `json:"options,required"` + // Indicates whether the variant can access an image without a signature, + // regardless of image access control. + NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` + JSON v1VariantGetResponseVariantJSON `json:"-"` +} + +// v1VariantGetResponseVariantJSON contains the JSON metadata for the struct +// [V1VariantGetResponseVariant] +type v1VariantGetResponseVariantJSON struct { + ID apijson.Field + Options apijson.Field + NeverRequireSignedURLs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantGetResponseVariant) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantGetResponseVariantJSON) RawJSON() string { + return r.raw +} + +// Allows you to define image resizing sizes for different use cases. +type V1VariantGetResponseVariantOptions struct { + // The fit property describes how the width and height dimensions should be + // interpreted. + Fit V1VariantGetResponseVariantOptionsFit `json:"fit,required"` + // Maximum height in image pixels. + Height float64 `json:"height,required"` + // What EXIF data should be preserved in the output image. + Metadata V1VariantGetResponseVariantOptionsMetadata `json:"metadata,required"` + // Maximum width in image pixels. + Width float64 `json:"width,required"` + JSON v1VariantGetResponseVariantOptionsJSON `json:"-"` +} + +// v1VariantGetResponseVariantOptionsJSON contains the JSON metadata for the struct +// [V1VariantGetResponseVariantOptions] +type v1VariantGetResponseVariantOptionsJSON struct { + Fit apijson.Field + Height apijson.Field + Metadata apijson.Field + Width apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantGetResponseVariantOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantGetResponseVariantOptionsJSON) RawJSON() string { + return r.raw +} + +// The fit property describes how the width and height dimensions should be +// interpreted. +type V1VariantGetResponseVariantOptionsFit string + +const ( + V1VariantGetResponseVariantOptionsFitScaleDown V1VariantGetResponseVariantOptionsFit = "scale-down" + V1VariantGetResponseVariantOptionsFitContain V1VariantGetResponseVariantOptionsFit = "contain" + V1VariantGetResponseVariantOptionsFitCover V1VariantGetResponseVariantOptionsFit = "cover" + V1VariantGetResponseVariantOptionsFitCrop V1VariantGetResponseVariantOptionsFit = "crop" + V1VariantGetResponseVariantOptionsFitPad V1VariantGetResponseVariantOptionsFit = "pad" +) + +func (r V1VariantGetResponseVariantOptionsFit) IsKnown() bool { + switch r { + case V1VariantGetResponseVariantOptionsFitScaleDown, V1VariantGetResponseVariantOptionsFitContain, V1VariantGetResponseVariantOptionsFitCover, V1VariantGetResponseVariantOptionsFitCrop, V1VariantGetResponseVariantOptionsFitPad: + return true + } + return false +} + +// What EXIF data should be preserved in the output image. +type V1VariantGetResponseVariantOptionsMetadata string + +const ( + V1VariantGetResponseVariantOptionsMetadataKeep V1VariantGetResponseVariantOptionsMetadata = "keep" + V1VariantGetResponseVariantOptionsMetadataCopyright V1VariantGetResponseVariantOptionsMetadata = "copyright" + V1VariantGetResponseVariantOptionsMetadataNone V1VariantGetResponseVariantOptionsMetadata = "none" +) + +func (r V1VariantGetResponseVariantOptionsMetadata) IsKnown() bool { + switch r { + case V1VariantGetResponseVariantOptionsMetadataKeep, V1VariantGetResponseVariantOptionsMetadataCopyright, V1VariantGetResponseVariantOptionsMetadataNone: + return true + } + return false +} + type V1VariantNewParams struct { // Account identifier tag. AccountID param.Field[string] `path:"account_id,required"` @@ -442,9 +680,9 @@ func (r V1VariantNewParamsOptionsMetadata) IsKnown() bool { } type V1VariantNewResponseEnvelope struct { - Errors []V1VariantNewResponseEnvelopeErrors `json:"errors,required"` - Messages []V1VariantNewResponseEnvelopeMessages `json:"messages,required"` - Result V1ImageVariant `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V1VariantNewResponse `json:"result,required"` // Whether the API call was successful Success V1VariantNewResponseEnvelopeSuccess `json:"success,required"` JSON v1VariantNewResponseEnvelopeJSON `json:"-"` @@ -469,52 +707,6 @@ func (r v1VariantNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1VariantNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1VariantNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1VariantNewResponseEnvelopeErrors] -type v1VariantNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1VariantNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1VariantNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V1VariantNewResponseEnvelopeMessages] -type v1VariantNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1VariantNewResponseEnvelopeSuccess bool @@ -536,9 +728,9 @@ type V1VariantListParams struct { } type V1VariantListResponseEnvelope struct { - Errors []V1VariantListResponseEnvelopeErrors `json:"errors,required"` - Messages []V1VariantListResponseEnvelopeMessages `json:"messages,required"` - Result V1ImageVariants `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Variant `json:"result,required"` // Whether the API call was successful Success V1VariantListResponseEnvelopeSuccess `json:"success,required"` JSON v1VariantListResponseEnvelopeJSON `json:"-"` @@ -563,52 +755,6 @@ func (r v1VariantListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1VariantListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantListResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1VariantListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [V1VariantListResponseEnvelopeErrors] -type v1VariantListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1VariantListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantListResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1VariantListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V1VariantListResponseEnvelopeMessages] -type v1VariantListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1VariantListResponseEnvelopeSuccess bool @@ -627,12 +773,17 @@ func (r V1VariantListResponseEnvelopeSuccess) IsKnown() bool { type V1VariantDeleteParams struct { // Account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r V1VariantDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type V1VariantDeleteResponseEnvelope struct { - Errors []V1VariantDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []V1VariantDeleteResponseEnvelopeMessages `json:"messages,required"` - Result V1VariantDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V1VariantDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success V1VariantDeleteResponseEnvelopeSuccess `json:"success,required"` JSON v1VariantDeleteResponseEnvelopeJSON `json:"-"` @@ -657,52 +808,6 @@ func (r v1VariantDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1VariantDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1VariantDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [V1VariantDeleteResponseEnvelopeErrors] -type v1VariantDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1VariantDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1VariantDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V1VariantDeleteResponseEnvelopeMessages] -type v1VariantDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1VariantDeleteResponseEnvelopeSuccess bool @@ -787,9 +892,9 @@ func (r V1VariantEditParamsOptionsMetadata) IsKnown() bool { } type V1VariantEditResponseEnvelope struct { - Errors []V1VariantEditResponseEnvelopeErrors `json:"errors,required"` - Messages []V1VariantEditResponseEnvelopeMessages `json:"messages,required"` - Result V1ImageVariant `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V1VariantEditResponse `json:"result,required"` // Whether the API call was successful Success V1VariantEditResponseEnvelopeSuccess `json:"success,required"` JSON v1VariantEditResponseEnvelopeJSON `json:"-"` @@ -814,52 +919,6 @@ func (r v1VariantEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1VariantEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1VariantEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [V1VariantEditResponseEnvelopeErrors] -type v1VariantEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1VariantEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1VariantEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V1VariantEditResponseEnvelopeMessages] -type v1VariantEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1VariantEditResponseEnvelopeSuccess bool @@ -881,9 +940,9 @@ type V1VariantGetParams struct { } type V1VariantGetResponseEnvelope struct { - Errors []V1VariantGetResponseEnvelopeErrors `json:"errors,required"` - Messages []V1VariantGetResponseEnvelopeMessages `json:"messages,required"` - Result V1ImageVariant `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V1VariantGetResponse `json:"result,required"` // Whether the API call was successful Success V1VariantGetResponseEnvelopeSuccess `json:"success,required"` JSON v1VariantGetResponseEnvelopeJSON `json:"-"` @@ -908,52 +967,6 @@ func (r v1VariantGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V1VariantGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// v1VariantGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V1VariantGetResponseEnvelopeErrors] -type v1VariantGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V1VariantGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v1VariantGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// v1VariantGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V1VariantGetResponseEnvelopeMessages] -type v1VariantGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V1VariantGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v1VariantGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V1VariantGetResponseEnvelopeSuccess bool diff --git a/images/v1variant_test.go b/images/v1variant_test.go index e379a4a24a9..75b21ec3790 100644 --- a/images/v1variant_test.go +++ b/images/v1variant_test.go @@ -30,7 +30,7 @@ func TestV1VariantNewWithOptionalParams(t *testing.T) { ) _, err := client.Images.V1.Variants.New(context.TODO(), images.V1VariantNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ID: cloudflare.F("string"), + ID: cloudflare.F("hero"), Options: cloudflare.F(images.V1VariantNewParamsOptions{ Fit: cloudflare.F(images.V1VariantNewParamsOptionsFitScaleDown), Height: cloudflare.F(768.000000), @@ -90,9 +90,10 @@ func TestV1VariantDelete(t *testing.T) { ) _, err := client.Images.V1.Variants.Delete( context.TODO(), - "string", + "hero", images.V1VariantDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -120,7 +121,7 @@ func TestV1VariantEditWithOptionalParams(t *testing.T) { ) _, err := client.Images.V1.Variants.Edit( context.TODO(), - "string", + "hero", images.V1VariantEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Options: cloudflare.F(images.V1VariantEditParamsOptions{ @@ -157,7 +158,7 @@ func TestV1VariantGet(t *testing.T) { ) _, err := client.Images.V1.Variants.Get( context.TODO(), - "string", + "hero", images.V1VariantGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, diff --git a/images/v2.go b/images/v2.go index f217c8f76a8..335c89a0e2f 100644 --- a/images/v2.go +++ b/images/v2.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -87,7 +88,7 @@ type V2ListParams struct { // URLQuery serializes [V2ListParams]'s query parameters as `url.Values`. func (r V2ListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -109,9 +110,9 @@ func (r V2ListParamsSortOrder) IsKnown() bool { } type V2ListResponseEnvelope struct { - Errors []V2ListResponseEnvelopeErrors `json:"errors,required"` - Messages []V2ListResponseEnvelopeMessages `json:"messages,required"` - Result V2ListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V2ListResponse `json:"result,required"` // Whether the API call was successful Success V2ListResponseEnvelopeSuccess `json:"success,required"` JSON v2ListResponseEnvelopeJSON `json:"-"` @@ -136,52 +137,6 @@ func (r v2ListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V2ListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v2ListResponseEnvelopeErrorsJSON `json:"-"` -} - -// v2ListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [V2ListResponseEnvelopeErrors] -type v2ListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V2ListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v2ListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V2ListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v2ListResponseEnvelopeMessagesJSON `json:"-"` -} - -// v2ListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [V2ListResponseEnvelopeMessages] -type v2ListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V2ListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v2ListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V2ListResponseEnvelopeSuccess bool diff --git a/images/v2directupload.go b/images/v2directupload.go index 1cf8509e5f9..931e8497a55 100644 --- a/images/v2directupload.go +++ b/images/v2directupload.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -95,9 +96,9 @@ func (r V2DirectUploadNewParams) MarshalJSON() (data []byte, err error) { } type V2DirectUploadNewResponseEnvelope struct { - Errors []V2DirectUploadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []V2DirectUploadNewResponseEnvelopeMessages `json:"messages,required"` - Result V2DirectUploadNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result V2DirectUploadNewResponse `json:"result,required"` // Whether the API call was successful Success V2DirectUploadNewResponseEnvelopeSuccess `json:"success,required"` JSON v2DirectUploadNewResponseEnvelopeJSON `json:"-"` @@ -122,52 +123,6 @@ func (r v2DirectUploadNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type V2DirectUploadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v2DirectUploadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// v2DirectUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [V2DirectUploadNewResponseEnvelopeErrors] -type v2DirectUploadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V2DirectUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v2DirectUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type V2DirectUploadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON v2DirectUploadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// v2DirectUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [V2DirectUploadNewResponseEnvelopeMessages] -type v2DirectUploadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *V2DirectUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r v2DirectUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type V2DirectUploadNewResponseEnvelopeSuccess bool diff --git a/intel/aliases.go b/intel/aliases.go index 460771979c9..a66cb3acb0d 100644 --- a/intel/aliases.go +++ b/intel/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/intel/asn.go b/intel/asn.go index ecceed14c04..02a117330f2 100644 --- a/intel/asn.go +++ b/intel/asn.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewASNService(opts ...option.RequestOption) (r *ASNService) { } // Get ASN Overview -func (r *ASNService) Get(ctx context.Context, asn IntelASNParam, query ASNGetParams, opts ...option.RequestOption) (res *IntelASN, err error) { +func (r *ASNService) Get(ctx context.Context, asn ASNParam, query ASNGetParams, opts ...option.RequestOption) (res *ASN, err error) { opts = append(r.Options[:], opts...) var env ASNGetResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/asn/%v", query.AccountID, asn) @@ -45,9 +46,9 @@ func (r *ASNService) Get(ctx context.Context, asn IntelASNParam, query ASNGetPar return } -type IntelASN = int64 +type ASN = int64 -type IntelASNParam = int64 +type ASNParam = int64 type ASNGetParams struct { // Identifier @@ -55,9 +56,9 @@ type ASNGetParams struct { } type ASNGetResponseEnvelope struct { - Errors []ASNGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ASNGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelASN `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ASN `json:"result,required"` // Whether the API call was successful Success ASNGetResponseEnvelopeSuccess `json:"success,required"` JSON asnGetResponseEnvelopeJSON `json:"-"` @@ -82,52 +83,6 @@ func (r asnGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ASNGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON asnGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// asnGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ASNGetResponseEnvelopeErrors] -type asnGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ASNGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r asnGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ASNGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON asnGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// asnGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ASNGetResponseEnvelopeMessages] -type asnGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ASNGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r asnGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ASNGetResponseEnvelopeSuccess bool diff --git a/intel/asnsubnet.go b/intel/asnsubnet.go index 182fe00f1fd..d99695a68e8 100644 --- a/intel/asnsubnet.go +++ b/intel/asnsubnet.go @@ -31,7 +31,7 @@ func NewASNSubnetService(opts ...option.RequestOption) (r *ASNSubnetService) { } // Get ASN Subnets -func (r *ASNSubnetService) Get(ctx context.Context, asn IntelASNParam, query ASNSubnetGetParams, opts ...option.RequestOption) (res *ASNSubnetGetResponse, err error) { +func (r *ASNSubnetService) Get(ctx context.Context, asn ASNParam, query ASNSubnetGetParams, opts ...option.RequestOption) (res *ASNSubnetGetResponse, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("accounts/%s/intel/asn/%v/subnets", query.AccountID, asn) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) @@ -39,7 +39,7 @@ func (r *ASNSubnetService) Get(ctx context.Context, asn IntelASNParam, query ASN } type ASNSubnetGetResponse struct { - ASN IntelASN `json:"asn"` + ASN ASN `json:"asn"` // Total results returned based on your search parameters. Count float64 `json:"count"` IPCountTotal int64 `json:"ip_count_total"` diff --git a/intel/attacksurfacereportissue.go b/intel/attacksurfacereportissue.go index 3610e576d0c..98a16d2b4bd 100644 --- a/intel/attacksurfacereportissue.go +++ b/intel/attacksurfacereportissue.go @@ -75,7 +75,7 @@ func (r *AttackSurfaceReportIssueService) Class(ctx context.Context, params Atta } // Archive Security Center Insight -func (r *AttackSurfaceReportIssueService) Dismiss(ctx context.Context, issueID string, params AttackSurfaceReportIssueDismissParams, opts ...option.RequestOption) (res *AttackSurfaceReportIssueDismissResponse, err error) { +func (r *AttackSurfaceReportIssueService) Dismiss(ctx context.Context, issueID string, params AttackSurfaceReportIssueDismissParams, opts ...option.RequestOption) (res *AttackSurfaceReportIssueDismissResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AttackSurfaceReportIssueDismissResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/attack-surface-report/%s/dismiss", params.AccountID, issueID) @@ -113,10 +113,50 @@ func (r *AttackSurfaceReportIssueService) Type(ctx context.Context, params Attac return } +type IssueClassParam []string + +type IssueType string + +const ( + IssueTypeComplianceViolation IssueType = "compliance_violation" + IssueTypeEmailSecurity IssueType = "email_security" + IssueTypeExposedInfrastructure IssueType = "exposed_infrastructure" + IssueTypeInsecureConfiguration IssueType = "insecure_configuration" + IssueTypeWeakAuthentication IssueType = "weak_authentication" +) + +func (r IssueType) IsKnown() bool { + switch r { + case IssueTypeComplianceViolation, IssueTypeEmailSecurity, IssueTypeExposedInfrastructure, IssueTypeInsecureConfiguration, IssueTypeWeakAuthentication: + return true + } + return false +} + +type ProductParam []string + +type SeverityQueryParam string + +const ( + SeverityQueryParamLow SeverityQueryParam = "low" + SeverityQueryParamModerate SeverityQueryParam = "moderate" + SeverityQueryParamCritical SeverityQueryParam = "critical" +) + +func (r SeverityQueryParam) IsKnown() bool { + switch r { + case SeverityQueryParamLow, SeverityQueryParamModerate, SeverityQueryParamCritical: + return true + } + return false +} + +type SubjectParam []string + type AttackSurfaceReportIssueListResponse struct { - Errors []AttackSurfaceReportIssueListResponseError `json:"errors,required"` - Messages []AttackSurfaceReportIssueListResponseMessage `json:"messages,required"` - Result AttackSurfaceReportIssueListResponseResult `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AttackSurfaceReportIssueListResponseResult `json:"result,required"` // Whether the API call was successful Success AttackSurfaceReportIssueListResponseSuccess `json:"success,required"` JSON attackSurfaceReportIssueListResponseJSON `json:"-"` @@ -141,52 +181,6 @@ func (r attackSurfaceReportIssueListResponseJSON) RawJSON() string { return r.raw } -type AttackSurfaceReportIssueListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueListResponseErrorJSON `json:"-"` -} - -// attackSurfaceReportIssueListResponseErrorJSON contains the JSON metadata for the -// struct [AttackSurfaceReportIssueListResponseError] -type attackSurfaceReportIssueListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueListResponseErrorJSON) RawJSON() string { - return r.raw -} - -type AttackSurfaceReportIssueListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueListResponseMessageJSON `json:"-"` -} - -// attackSurfaceReportIssueListResponseMessageJSON contains the JSON metadata for -// the struct [AttackSurfaceReportIssueListResponseMessage] -type attackSurfaceReportIssueListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueListResponseMessageJSON) RawJSON() string { - return r.raw -} - type AttackSurfaceReportIssueListResponseResult struct { // Total number of results Count int64 `json:"count"` @@ -332,13 +326,13 @@ func (r attackSurfaceReportIssueClassResponseJSON) RawJSON() string { // Union satisfied by [intel.AttackSurfaceReportIssueDismissResponseUnknown] or // [shared.UnionString]. -type AttackSurfaceReportIssueDismissResponse interface { - ImplementsIntelAttackSurfaceReportIssueDismissResponse() +type AttackSurfaceReportIssueDismissResponseUnion interface { + ImplementsIntelAttackSurfaceReportIssueDismissResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AttackSurfaceReportIssueDismissResponse)(nil)).Elem(), + reflect.TypeOf((*AttackSurfaceReportIssueDismissResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -395,198 +389,62 @@ func (r attackSurfaceReportIssueTypeResponseJSON) RawJSON() string { type AttackSurfaceReportIssueListParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Dismissed param.Field[bool] `query:"dismissed"` - IssueClass param.Field[[]string] `query:"issue_class"` - IssueClassNeq param.Field[[]string] `query:"issue_class~neq"` - IssueType param.Field[[]AttackSurfaceReportIssueListParamsIssueType] `query:"issue_type"` - IssueTypeNeq param.Field[[]AttackSurfaceReportIssueListParamsIssueTypeNeq] `query:"issue_type~neq"` + AccountID param.Field[string] `path:"account_id,required"` + Dismissed param.Field[bool] `query:"dismissed"` + IssueClass param.Field[IssueClassParam] `query:"issue_class"` + IssueClassNeq param.Field[IssueClassParam] `query:"issue_class~neq"` + IssueType param.Field[[]IssueType] `query:"issue_type"` + IssueTypeNeq param.Field[[]IssueType] `query:"issue_type~neq"` // Current page within paginated list of results Page param.Field[int64] `query:"page"` // Number of results per page of results - PerPage param.Field[int64] `query:"per_page"` - Product param.Field[[]string] `query:"product"` - ProductNeq param.Field[[]string] `query:"product~neq"` - Severity param.Field[[]AttackSurfaceReportIssueListParamsSeverity] `query:"severity"` - SeverityNeq param.Field[[]AttackSurfaceReportIssueListParamsSeverityNeq] `query:"severity~neq"` - Subject param.Field[[]string] `query:"subject"` - SubjectNeq param.Field[[]string] `query:"subject~neq"` + PerPage param.Field[int64] `query:"per_page"` + Product param.Field[ProductParam] `query:"product"` + ProductNeq param.Field[ProductParam] `query:"product~neq"` + Severity param.Field[[]SeverityQueryParam] `query:"severity"` + SeverityNeq param.Field[[]SeverityQueryParam] `query:"severity~neq"` + Subject param.Field[SubjectParam] `query:"subject"` + SubjectNeq param.Field[SubjectParam] `query:"subject~neq"` } // URLQuery serializes [AttackSurfaceReportIssueListParams]'s query parameters as // `url.Values`. func (r AttackSurfaceReportIssueListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type AttackSurfaceReportIssueListParamsIssueType string - -const ( - AttackSurfaceReportIssueListParamsIssueTypeComplianceViolation AttackSurfaceReportIssueListParamsIssueType = "compliance_violation" - AttackSurfaceReportIssueListParamsIssueTypeEmailSecurity AttackSurfaceReportIssueListParamsIssueType = "email_security" - AttackSurfaceReportIssueListParamsIssueTypeExposedInfrastructure AttackSurfaceReportIssueListParamsIssueType = "exposed_infrastructure" - AttackSurfaceReportIssueListParamsIssueTypeInsecureConfiguration AttackSurfaceReportIssueListParamsIssueType = "insecure_configuration" - AttackSurfaceReportIssueListParamsIssueTypeWeakAuthentication AttackSurfaceReportIssueListParamsIssueType = "weak_authentication" -) - -func (r AttackSurfaceReportIssueListParamsIssueType) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueListParamsIssueTypeComplianceViolation, AttackSurfaceReportIssueListParamsIssueTypeEmailSecurity, AttackSurfaceReportIssueListParamsIssueTypeExposedInfrastructure, AttackSurfaceReportIssueListParamsIssueTypeInsecureConfiguration, AttackSurfaceReportIssueListParamsIssueTypeWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueListParamsIssueTypeNeq string - -const ( - AttackSurfaceReportIssueListParamsIssueTypeNeqComplianceViolation AttackSurfaceReportIssueListParamsIssueTypeNeq = "compliance_violation" - AttackSurfaceReportIssueListParamsIssueTypeNeqEmailSecurity AttackSurfaceReportIssueListParamsIssueTypeNeq = "email_security" - AttackSurfaceReportIssueListParamsIssueTypeNeqExposedInfrastructure AttackSurfaceReportIssueListParamsIssueTypeNeq = "exposed_infrastructure" - AttackSurfaceReportIssueListParamsIssueTypeNeqInsecureConfiguration AttackSurfaceReportIssueListParamsIssueTypeNeq = "insecure_configuration" - AttackSurfaceReportIssueListParamsIssueTypeNeqWeakAuthentication AttackSurfaceReportIssueListParamsIssueTypeNeq = "weak_authentication" -) - -func (r AttackSurfaceReportIssueListParamsIssueTypeNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueListParamsIssueTypeNeqComplianceViolation, AttackSurfaceReportIssueListParamsIssueTypeNeqEmailSecurity, AttackSurfaceReportIssueListParamsIssueTypeNeqExposedInfrastructure, AttackSurfaceReportIssueListParamsIssueTypeNeqInsecureConfiguration, AttackSurfaceReportIssueListParamsIssueTypeNeqWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueListParamsSeverity string - -const ( - AttackSurfaceReportIssueListParamsSeverityLow AttackSurfaceReportIssueListParamsSeverity = "low" - AttackSurfaceReportIssueListParamsSeverityModerate AttackSurfaceReportIssueListParamsSeverity = "moderate" - AttackSurfaceReportIssueListParamsSeverityCritical AttackSurfaceReportIssueListParamsSeverity = "critical" -) - -func (r AttackSurfaceReportIssueListParamsSeverity) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueListParamsSeverityLow, AttackSurfaceReportIssueListParamsSeverityModerate, AttackSurfaceReportIssueListParamsSeverityCritical: - return true - } - return false -} - -type AttackSurfaceReportIssueListParamsSeverityNeq string - -const ( - AttackSurfaceReportIssueListParamsSeverityNeqLow AttackSurfaceReportIssueListParamsSeverityNeq = "low" - AttackSurfaceReportIssueListParamsSeverityNeqModerate AttackSurfaceReportIssueListParamsSeverityNeq = "moderate" - AttackSurfaceReportIssueListParamsSeverityNeqCritical AttackSurfaceReportIssueListParamsSeverityNeq = "critical" -) - -func (r AttackSurfaceReportIssueListParamsSeverityNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueListParamsSeverityNeqLow, AttackSurfaceReportIssueListParamsSeverityNeqModerate, AttackSurfaceReportIssueListParamsSeverityNeqCritical: - return true - } - return false -} - type AttackSurfaceReportIssueClassParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Dismissed param.Field[bool] `query:"dismissed"` - IssueClass param.Field[[]string] `query:"issue_class"` - IssueClassNeq param.Field[[]string] `query:"issue_class~neq"` - IssueType param.Field[[]AttackSurfaceReportIssueClassParamsIssueType] `query:"issue_type"` - IssueTypeNeq param.Field[[]AttackSurfaceReportIssueClassParamsIssueTypeNeq] `query:"issue_type~neq"` - Product param.Field[[]string] `query:"product"` - ProductNeq param.Field[[]string] `query:"product~neq"` - Severity param.Field[[]AttackSurfaceReportIssueClassParamsSeverity] `query:"severity"` - SeverityNeq param.Field[[]AttackSurfaceReportIssueClassParamsSeverityNeq] `query:"severity~neq"` - Subject param.Field[[]string] `query:"subject"` - SubjectNeq param.Field[[]string] `query:"subject~neq"` + AccountID param.Field[string] `path:"account_id,required"` + Dismissed param.Field[bool] `query:"dismissed"` + IssueClass param.Field[IssueClassParam] `query:"issue_class"` + IssueClassNeq param.Field[IssueClassParam] `query:"issue_class~neq"` + IssueType param.Field[[]IssueType] `query:"issue_type"` + IssueTypeNeq param.Field[[]IssueType] `query:"issue_type~neq"` + Product param.Field[ProductParam] `query:"product"` + ProductNeq param.Field[ProductParam] `query:"product~neq"` + Severity param.Field[[]SeverityQueryParam] `query:"severity"` + SeverityNeq param.Field[[]SeverityQueryParam] `query:"severity~neq"` + Subject param.Field[SubjectParam] `query:"subject"` + SubjectNeq param.Field[SubjectParam] `query:"subject~neq"` } // URLQuery serializes [AttackSurfaceReportIssueClassParams]'s query parameters as // `url.Values`. func (r AttackSurfaceReportIssueClassParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type AttackSurfaceReportIssueClassParamsIssueType string - -const ( - AttackSurfaceReportIssueClassParamsIssueTypeComplianceViolation AttackSurfaceReportIssueClassParamsIssueType = "compliance_violation" - AttackSurfaceReportIssueClassParamsIssueTypeEmailSecurity AttackSurfaceReportIssueClassParamsIssueType = "email_security" - AttackSurfaceReportIssueClassParamsIssueTypeExposedInfrastructure AttackSurfaceReportIssueClassParamsIssueType = "exposed_infrastructure" - AttackSurfaceReportIssueClassParamsIssueTypeInsecureConfiguration AttackSurfaceReportIssueClassParamsIssueType = "insecure_configuration" - AttackSurfaceReportIssueClassParamsIssueTypeWeakAuthentication AttackSurfaceReportIssueClassParamsIssueType = "weak_authentication" -) - -func (r AttackSurfaceReportIssueClassParamsIssueType) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueClassParamsIssueTypeComplianceViolation, AttackSurfaceReportIssueClassParamsIssueTypeEmailSecurity, AttackSurfaceReportIssueClassParamsIssueTypeExposedInfrastructure, AttackSurfaceReportIssueClassParamsIssueTypeInsecureConfiguration, AttackSurfaceReportIssueClassParamsIssueTypeWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueClassParamsIssueTypeNeq string - -const ( - AttackSurfaceReportIssueClassParamsIssueTypeNeqComplianceViolation AttackSurfaceReportIssueClassParamsIssueTypeNeq = "compliance_violation" - AttackSurfaceReportIssueClassParamsIssueTypeNeqEmailSecurity AttackSurfaceReportIssueClassParamsIssueTypeNeq = "email_security" - AttackSurfaceReportIssueClassParamsIssueTypeNeqExposedInfrastructure AttackSurfaceReportIssueClassParamsIssueTypeNeq = "exposed_infrastructure" - AttackSurfaceReportIssueClassParamsIssueTypeNeqInsecureConfiguration AttackSurfaceReportIssueClassParamsIssueTypeNeq = "insecure_configuration" - AttackSurfaceReportIssueClassParamsIssueTypeNeqWeakAuthentication AttackSurfaceReportIssueClassParamsIssueTypeNeq = "weak_authentication" -) - -func (r AttackSurfaceReportIssueClassParamsIssueTypeNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueClassParamsIssueTypeNeqComplianceViolation, AttackSurfaceReportIssueClassParamsIssueTypeNeqEmailSecurity, AttackSurfaceReportIssueClassParamsIssueTypeNeqExposedInfrastructure, AttackSurfaceReportIssueClassParamsIssueTypeNeqInsecureConfiguration, AttackSurfaceReportIssueClassParamsIssueTypeNeqWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueClassParamsSeverity string - -const ( - AttackSurfaceReportIssueClassParamsSeverityLow AttackSurfaceReportIssueClassParamsSeverity = "low" - AttackSurfaceReportIssueClassParamsSeverityModerate AttackSurfaceReportIssueClassParamsSeverity = "moderate" - AttackSurfaceReportIssueClassParamsSeverityCritical AttackSurfaceReportIssueClassParamsSeverity = "critical" -) - -func (r AttackSurfaceReportIssueClassParamsSeverity) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueClassParamsSeverityLow, AttackSurfaceReportIssueClassParamsSeverityModerate, AttackSurfaceReportIssueClassParamsSeverityCritical: - return true - } - return false -} - -type AttackSurfaceReportIssueClassParamsSeverityNeq string - -const ( - AttackSurfaceReportIssueClassParamsSeverityNeqLow AttackSurfaceReportIssueClassParamsSeverityNeq = "low" - AttackSurfaceReportIssueClassParamsSeverityNeqModerate AttackSurfaceReportIssueClassParamsSeverityNeq = "moderate" - AttackSurfaceReportIssueClassParamsSeverityNeqCritical AttackSurfaceReportIssueClassParamsSeverityNeq = "critical" -) - -func (r AttackSurfaceReportIssueClassParamsSeverityNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueClassParamsSeverityNeqLow, AttackSurfaceReportIssueClassParamsSeverityNeqModerate, AttackSurfaceReportIssueClassParamsSeverityNeqCritical: - return true - } - return false -} - type AttackSurfaceReportIssueClassResponseEnvelope struct { - Errors []AttackSurfaceReportIssueClassResponseEnvelopeErrors `json:"errors,required"` - Messages []AttackSurfaceReportIssueClassResponseEnvelopeMessages `json:"messages,required"` - Result []AttackSurfaceReportIssueClassResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []AttackSurfaceReportIssueClassResponse `json:"result,required"` // Whether the API call was successful Success AttackSurfaceReportIssueClassResponseEnvelopeSuccess `json:"success,required"` JSON attackSurfaceReportIssueClassResponseEnvelopeJSON `json:"-"` @@ -611,52 +469,6 @@ func (r attackSurfaceReportIssueClassResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AttackSurfaceReportIssueClassResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueClassResponseEnvelopeErrorsJSON `json:"-"` -} - -// attackSurfaceReportIssueClassResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AttackSurfaceReportIssueClassResponseEnvelopeErrors] -type attackSurfaceReportIssueClassResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueClassResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueClassResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AttackSurfaceReportIssueClassResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueClassResponseEnvelopeMessagesJSON `json:"-"` -} - -// attackSurfaceReportIssueClassResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AttackSurfaceReportIssueClassResponseEnvelopeMessages] -type attackSurfaceReportIssueClassResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueClassResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueClassResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AttackSurfaceReportIssueClassResponseEnvelopeSuccess bool @@ -683,9 +495,9 @@ func (r AttackSurfaceReportIssueDismissParams) MarshalJSON() (data []byte, err e } type AttackSurfaceReportIssueDismissResponseEnvelope struct { - Errors []AttackSurfaceReportIssueDismissResponseEnvelopeErrors `json:"errors,required"` - Messages []AttackSurfaceReportIssueDismissResponseEnvelopeMessages `json:"messages,required"` - Result AttackSurfaceReportIssueDismissResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AttackSurfaceReportIssueDismissResponseUnion `json:"result,required"` // Whether the API call was successful Success AttackSurfaceReportIssueDismissResponseEnvelopeSuccess `json:"success,required"` JSON attackSurfaceReportIssueDismissResponseEnvelopeJSON `json:"-"` @@ -710,53 +522,6 @@ func (r attackSurfaceReportIssueDismissResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AttackSurfaceReportIssueDismissResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueDismissResponseEnvelopeErrorsJSON `json:"-"` -} - -// attackSurfaceReportIssueDismissResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AttackSurfaceReportIssueDismissResponseEnvelopeErrors] -type attackSurfaceReportIssueDismissResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueDismissResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueDismissResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AttackSurfaceReportIssueDismissResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueDismissResponseEnvelopeMessagesJSON `json:"-"` -} - -// attackSurfaceReportIssueDismissResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AttackSurfaceReportIssueDismissResponseEnvelopeMessages] -type attackSurfaceReportIssueDismissResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueDismissResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueDismissResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AttackSurfaceReportIssueDismissResponseEnvelopeSuccess bool @@ -774,101 +539,33 @@ func (r AttackSurfaceReportIssueDismissResponseEnvelopeSuccess) IsKnown() bool { type AttackSurfaceReportIssueSeverityParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Dismissed param.Field[bool] `query:"dismissed"` - IssueClass param.Field[[]string] `query:"issue_class"` - IssueClassNeq param.Field[[]string] `query:"issue_class~neq"` - IssueType param.Field[[]AttackSurfaceReportIssueSeverityParamsIssueType] `query:"issue_type"` - IssueTypeNeq param.Field[[]AttackSurfaceReportIssueSeverityParamsIssueTypeNeq] `query:"issue_type~neq"` - Product param.Field[[]string] `query:"product"` - ProductNeq param.Field[[]string] `query:"product~neq"` - Severity param.Field[[]AttackSurfaceReportIssueSeverityParamsSeverity] `query:"severity"` - SeverityNeq param.Field[[]AttackSurfaceReportIssueSeverityParamsSeverityNeq] `query:"severity~neq"` - Subject param.Field[[]string] `query:"subject"` - SubjectNeq param.Field[[]string] `query:"subject~neq"` + AccountID param.Field[string] `path:"account_id,required"` + Dismissed param.Field[bool] `query:"dismissed"` + IssueClass param.Field[IssueClassParam] `query:"issue_class"` + IssueClassNeq param.Field[IssueClassParam] `query:"issue_class~neq"` + IssueType param.Field[[]IssueType] `query:"issue_type"` + IssueTypeNeq param.Field[[]IssueType] `query:"issue_type~neq"` + Product param.Field[ProductParam] `query:"product"` + ProductNeq param.Field[ProductParam] `query:"product~neq"` + Severity param.Field[[]SeverityQueryParam] `query:"severity"` + SeverityNeq param.Field[[]SeverityQueryParam] `query:"severity~neq"` + Subject param.Field[SubjectParam] `query:"subject"` + SubjectNeq param.Field[SubjectParam] `query:"subject~neq"` } // URLQuery serializes [AttackSurfaceReportIssueSeverityParams]'s query parameters // as `url.Values`. func (r AttackSurfaceReportIssueSeverityParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type AttackSurfaceReportIssueSeverityParamsIssueType string - -const ( - AttackSurfaceReportIssueSeverityParamsIssueTypeComplianceViolation AttackSurfaceReportIssueSeverityParamsIssueType = "compliance_violation" - AttackSurfaceReportIssueSeverityParamsIssueTypeEmailSecurity AttackSurfaceReportIssueSeverityParamsIssueType = "email_security" - AttackSurfaceReportIssueSeverityParamsIssueTypeExposedInfrastructure AttackSurfaceReportIssueSeverityParamsIssueType = "exposed_infrastructure" - AttackSurfaceReportIssueSeverityParamsIssueTypeInsecureConfiguration AttackSurfaceReportIssueSeverityParamsIssueType = "insecure_configuration" - AttackSurfaceReportIssueSeverityParamsIssueTypeWeakAuthentication AttackSurfaceReportIssueSeverityParamsIssueType = "weak_authentication" -) - -func (r AttackSurfaceReportIssueSeverityParamsIssueType) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueSeverityParamsIssueTypeComplianceViolation, AttackSurfaceReportIssueSeverityParamsIssueTypeEmailSecurity, AttackSurfaceReportIssueSeverityParamsIssueTypeExposedInfrastructure, AttackSurfaceReportIssueSeverityParamsIssueTypeInsecureConfiguration, AttackSurfaceReportIssueSeverityParamsIssueTypeWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueSeverityParamsIssueTypeNeq string - -const ( - AttackSurfaceReportIssueSeverityParamsIssueTypeNeqComplianceViolation AttackSurfaceReportIssueSeverityParamsIssueTypeNeq = "compliance_violation" - AttackSurfaceReportIssueSeverityParamsIssueTypeNeqEmailSecurity AttackSurfaceReportIssueSeverityParamsIssueTypeNeq = "email_security" - AttackSurfaceReportIssueSeverityParamsIssueTypeNeqExposedInfrastructure AttackSurfaceReportIssueSeverityParamsIssueTypeNeq = "exposed_infrastructure" - AttackSurfaceReportIssueSeverityParamsIssueTypeNeqInsecureConfiguration AttackSurfaceReportIssueSeverityParamsIssueTypeNeq = "insecure_configuration" - AttackSurfaceReportIssueSeverityParamsIssueTypeNeqWeakAuthentication AttackSurfaceReportIssueSeverityParamsIssueTypeNeq = "weak_authentication" -) - -func (r AttackSurfaceReportIssueSeverityParamsIssueTypeNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueSeverityParamsIssueTypeNeqComplianceViolation, AttackSurfaceReportIssueSeverityParamsIssueTypeNeqEmailSecurity, AttackSurfaceReportIssueSeverityParamsIssueTypeNeqExposedInfrastructure, AttackSurfaceReportIssueSeverityParamsIssueTypeNeqInsecureConfiguration, AttackSurfaceReportIssueSeverityParamsIssueTypeNeqWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueSeverityParamsSeverity string - -const ( - AttackSurfaceReportIssueSeverityParamsSeverityLow AttackSurfaceReportIssueSeverityParamsSeverity = "low" - AttackSurfaceReportIssueSeverityParamsSeverityModerate AttackSurfaceReportIssueSeverityParamsSeverity = "moderate" - AttackSurfaceReportIssueSeverityParamsSeverityCritical AttackSurfaceReportIssueSeverityParamsSeverity = "critical" -) - -func (r AttackSurfaceReportIssueSeverityParamsSeverity) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueSeverityParamsSeverityLow, AttackSurfaceReportIssueSeverityParamsSeverityModerate, AttackSurfaceReportIssueSeverityParamsSeverityCritical: - return true - } - return false -} - -type AttackSurfaceReportIssueSeverityParamsSeverityNeq string - -const ( - AttackSurfaceReportIssueSeverityParamsSeverityNeqLow AttackSurfaceReportIssueSeverityParamsSeverityNeq = "low" - AttackSurfaceReportIssueSeverityParamsSeverityNeqModerate AttackSurfaceReportIssueSeverityParamsSeverityNeq = "moderate" - AttackSurfaceReportIssueSeverityParamsSeverityNeqCritical AttackSurfaceReportIssueSeverityParamsSeverityNeq = "critical" -) - -func (r AttackSurfaceReportIssueSeverityParamsSeverityNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueSeverityParamsSeverityNeqLow, AttackSurfaceReportIssueSeverityParamsSeverityNeqModerate, AttackSurfaceReportIssueSeverityParamsSeverityNeqCritical: - return true - } - return false -} - type AttackSurfaceReportIssueSeverityResponseEnvelope struct { - Errors []AttackSurfaceReportIssueSeverityResponseEnvelopeErrors `json:"errors,required"` - Messages []AttackSurfaceReportIssueSeverityResponseEnvelopeMessages `json:"messages,required"` - Result []AttackSurfaceReportIssueSeverityResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []AttackSurfaceReportIssueSeverityResponse `json:"result,required"` // Whether the API call was successful Success AttackSurfaceReportIssueSeverityResponseEnvelopeSuccess `json:"success,required"` JSON attackSurfaceReportIssueSeverityResponseEnvelopeJSON `json:"-"` @@ -893,53 +590,6 @@ func (r attackSurfaceReportIssueSeverityResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AttackSurfaceReportIssueSeverityResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueSeverityResponseEnvelopeErrorsJSON `json:"-"` -} - -// attackSurfaceReportIssueSeverityResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AttackSurfaceReportIssueSeverityResponseEnvelopeErrors] -type attackSurfaceReportIssueSeverityResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueSeverityResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueSeverityResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AttackSurfaceReportIssueSeverityResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueSeverityResponseEnvelopeMessagesJSON `json:"-"` -} - -// attackSurfaceReportIssueSeverityResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AttackSurfaceReportIssueSeverityResponseEnvelopeMessages] -type attackSurfaceReportIssueSeverityResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueSeverityResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueSeverityResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AttackSurfaceReportIssueSeverityResponseEnvelopeSuccess bool @@ -957,101 +607,33 @@ func (r AttackSurfaceReportIssueSeverityResponseEnvelopeSuccess) IsKnown() bool type AttackSurfaceReportIssueTypeParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Dismissed param.Field[bool] `query:"dismissed"` - IssueClass param.Field[[]string] `query:"issue_class"` - IssueClassNeq param.Field[[]string] `query:"issue_class~neq"` - IssueType param.Field[[]AttackSurfaceReportIssueTypeParamsIssueType] `query:"issue_type"` - IssueTypeNeq param.Field[[]AttackSurfaceReportIssueTypeParamsIssueTypeNeq] `query:"issue_type~neq"` - Product param.Field[[]string] `query:"product"` - ProductNeq param.Field[[]string] `query:"product~neq"` - Severity param.Field[[]AttackSurfaceReportIssueTypeParamsSeverity] `query:"severity"` - SeverityNeq param.Field[[]AttackSurfaceReportIssueTypeParamsSeverityNeq] `query:"severity~neq"` - Subject param.Field[[]string] `query:"subject"` - SubjectNeq param.Field[[]string] `query:"subject~neq"` + AccountID param.Field[string] `path:"account_id,required"` + Dismissed param.Field[bool] `query:"dismissed"` + IssueClass param.Field[IssueClassParam] `query:"issue_class"` + IssueClassNeq param.Field[IssueClassParam] `query:"issue_class~neq"` + IssueType param.Field[[]IssueType] `query:"issue_type"` + IssueTypeNeq param.Field[[]IssueType] `query:"issue_type~neq"` + Product param.Field[ProductParam] `query:"product"` + ProductNeq param.Field[ProductParam] `query:"product~neq"` + Severity param.Field[[]SeverityQueryParam] `query:"severity"` + SeverityNeq param.Field[[]SeverityQueryParam] `query:"severity~neq"` + Subject param.Field[SubjectParam] `query:"subject"` + SubjectNeq param.Field[SubjectParam] `query:"subject~neq"` } // URLQuery serializes [AttackSurfaceReportIssueTypeParams]'s query parameters as // `url.Values`. func (r AttackSurfaceReportIssueTypeParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type AttackSurfaceReportIssueTypeParamsIssueType string - -const ( - AttackSurfaceReportIssueTypeParamsIssueTypeComplianceViolation AttackSurfaceReportIssueTypeParamsIssueType = "compliance_violation" - AttackSurfaceReportIssueTypeParamsIssueTypeEmailSecurity AttackSurfaceReportIssueTypeParamsIssueType = "email_security" - AttackSurfaceReportIssueTypeParamsIssueTypeExposedInfrastructure AttackSurfaceReportIssueTypeParamsIssueType = "exposed_infrastructure" - AttackSurfaceReportIssueTypeParamsIssueTypeInsecureConfiguration AttackSurfaceReportIssueTypeParamsIssueType = "insecure_configuration" - AttackSurfaceReportIssueTypeParamsIssueTypeWeakAuthentication AttackSurfaceReportIssueTypeParamsIssueType = "weak_authentication" -) - -func (r AttackSurfaceReportIssueTypeParamsIssueType) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueTypeParamsIssueTypeComplianceViolation, AttackSurfaceReportIssueTypeParamsIssueTypeEmailSecurity, AttackSurfaceReportIssueTypeParamsIssueTypeExposedInfrastructure, AttackSurfaceReportIssueTypeParamsIssueTypeInsecureConfiguration, AttackSurfaceReportIssueTypeParamsIssueTypeWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueTypeParamsIssueTypeNeq string - -const ( - AttackSurfaceReportIssueTypeParamsIssueTypeNeqComplianceViolation AttackSurfaceReportIssueTypeParamsIssueTypeNeq = "compliance_violation" - AttackSurfaceReportIssueTypeParamsIssueTypeNeqEmailSecurity AttackSurfaceReportIssueTypeParamsIssueTypeNeq = "email_security" - AttackSurfaceReportIssueTypeParamsIssueTypeNeqExposedInfrastructure AttackSurfaceReportIssueTypeParamsIssueTypeNeq = "exposed_infrastructure" - AttackSurfaceReportIssueTypeParamsIssueTypeNeqInsecureConfiguration AttackSurfaceReportIssueTypeParamsIssueTypeNeq = "insecure_configuration" - AttackSurfaceReportIssueTypeParamsIssueTypeNeqWeakAuthentication AttackSurfaceReportIssueTypeParamsIssueTypeNeq = "weak_authentication" -) - -func (r AttackSurfaceReportIssueTypeParamsIssueTypeNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueTypeParamsIssueTypeNeqComplianceViolation, AttackSurfaceReportIssueTypeParamsIssueTypeNeqEmailSecurity, AttackSurfaceReportIssueTypeParamsIssueTypeNeqExposedInfrastructure, AttackSurfaceReportIssueTypeParamsIssueTypeNeqInsecureConfiguration, AttackSurfaceReportIssueTypeParamsIssueTypeNeqWeakAuthentication: - return true - } - return false -} - -type AttackSurfaceReportIssueTypeParamsSeverity string - -const ( - AttackSurfaceReportIssueTypeParamsSeverityLow AttackSurfaceReportIssueTypeParamsSeverity = "low" - AttackSurfaceReportIssueTypeParamsSeverityModerate AttackSurfaceReportIssueTypeParamsSeverity = "moderate" - AttackSurfaceReportIssueTypeParamsSeverityCritical AttackSurfaceReportIssueTypeParamsSeverity = "critical" -) - -func (r AttackSurfaceReportIssueTypeParamsSeverity) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueTypeParamsSeverityLow, AttackSurfaceReportIssueTypeParamsSeverityModerate, AttackSurfaceReportIssueTypeParamsSeverityCritical: - return true - } - return false -} - -type AttackSurfaceReportIssueTypeParamsSeverityNeq string - -const ( - AttackSurfaceReportIssueTypeParamsSeverityNeqLow AttackSurfaceReportIssueTypeParamsSeverityNeq = "low" - AttackSurfaceReportIssueTypeParamsSeverityNeqModerate AttackSurfaceReportIssueTypeParamsSeverityNeq = "moderate" - AttackSurfaceReportIssueTypeParamsSeverityNeqCritical AttackSurfaceReportIssueTypeParamsSeverityNeq = "critical" -) - -func (r AttackSurfaceReportIssueTypeParamsSeverityNeq) IsKnown() bool { - switch r { - case AttackSurfaceReportIssueTypeParamsSeverityNeqLow, AttackSurfaceReportIssueTypeParamsSeverityNeqModerate, AttackSurfaceReportIssueTypeParamsSeverityNeqCritical: - return true - } - return false -} - type AttackSurfaceReportIssueTypeResponseEnvelope struct { - Errors []AttackSurfaceReportIssueTypeResponseEnvelopeErrors `json:"errors,required"` - Messages []AttackSurfaceReportIssueTypeResponseEnvelopeMessages `json:"messages,required"` - Result []AttackSurfaceReportIssueTypeResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []AttackSurfaceReportIssueTypeResponse `json:"result,required"` // Whether the API call was successful Success AttackSurfaceReportIssueTypeResponseEnvelopeSuccess `json:"success,required"` JSON attackSurfaceReportIssueTypeResponseEnvelopeJSON `json:"-"` @@ -1076,52 +658,6 @@ func (r attackSurfaceReportIssueTypeResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AttackSurfaceReportIssueTypeResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueTypeResponseEnvelopeErrorsJSON `json:"-"` -} - -// attackSurfaceReportIssueTypeResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AttackSurfaceReportIssueTypeResponseEnvelopeErrors] -type attackSurfaceReportIssueTypeResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueTypeResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueTypeResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AttackSurfaceReportIssueTypeResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueTypeResponseEnvelopeMessagesJSON `json:"-"` -} - -// attackSurfaceReportIssueTypeResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AttackSurfaceReportIssueTypeResponseEnvelopeMessages] -type attackSurfaceReportIssueTypeResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueTypeResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueTypeResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AttackSurfaceReportIssueTypeResponseEnvelopeSuccess bool diff --git a/intel/attacksurfacereportissue_test.go b/intel/attacksurfacereportissue_test.go index 82d242bd4b1..0384573822e 100644 --- a/intel/attacksurfacereportissue_test.go +++ b/intel/attacksurfacereportissue_test.go @@ -33,14 +33,14 @@ func TestAttackSurfaceReportIssueListWithOptionalParams(t *testing.T) { Dismissed: cloudflare.F(false), IssueClass: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), IssueClassNeq: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), - IssueType: cloudflare.F([]intel.AttackSurfaceReportIssueListParamsIssueType{intel.AttackSurfaceReportIssueListParamsIssueTypeComplianceViolation, intel.AttackSurfaceReportIssueListParamsIssueTypeEmailSecurity}), - IssueTypeNeq: cloudflare.F([]intel.AttackSurfaceReportIssueListParamsIssueTypeNeq{intel.AttackSurfaceReportIssueListParamsIssueTypeNeqComplianceViolation, intel.AttackSurfaceReportIssueListParamsIssueTypeNeqEmailSecurity}), + IssueType: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), + IssueTypeNeq: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), Page: cloudflare.F(int64(1)), PerPage: cloudflare.F(int64(25)), Product: cloudflare.F([]string{"access", "dns"}), ProductNeq: cloudflare.F([]string{"access", "dns"}), - Severity: cloudflare.F([]intel.AttackSurfaceReportIssueListParamsSeverity{intel.AttackSurfaceReportIssueListParamsSeverityLow, intel.AttackSurfaceReportIssueListParamsSeverityModerate}), - SeverityNeq: cloudflare.F([]intel.AttackSurfaceReportIssueListParamsSeverityNeq{intel.AttackSurfaceReportIssueListParamsSeverityNeqLow, intel.AttackSurfaceReportIssueListParamsSeverityNeqModerate}), + Severity: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), + SeverityNeq: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), Subject: cloudflare.F([]string{"example.com", "example.com", "example.com"}), SubjectNeq: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }) @@ -72,12 +72,12 @@ func TestAttackSurfaceReportIssueClassWithOptionalParams(t *testing.T) { Dismissed: cloudflare.F(false), IssueClass: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), IssueClassNeq: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), - IssueType: cloudflare.F([]intel.AttackSurfaceReportIssueClassParamsIssueType{intel.AttackSurfaceReportIssueClassParamsIssueTypeComplianceViolation, intel.AttackSurfaceReportIssueClassParamsIssueTypeEmailSecurity}), - IssueTypeNeq: cloudflare.F([]intel.AttackSurfaceReportIssueClassParamsIssueTypeNeq{intel.AttackSurfaceReportIssueClassParamsIssueTypeNeqComplianceViolation, intel.AttackSurfaceReportIssueClassParamsIssueTypeNeqEmailSecurity}), + IssueType: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), + IssueTypeNeq: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), Product: cloudflare.F([]string{"access", "dns"}), ProductNeq: cloudflare.F([]string{"access", "dns"}), - Severity: cloudflare.F([]intel.AttackSurfaceReportIssueClassParamsSeverity{intel.AttackSurfaceReportIssueClassParamsSeverityLow, intel.AttackSurfaceReportIssueClassParamsSeverityModerate}), - SeverityNeq: cloudflare.F([]intel.AttackSurfaceReportIssueClassParamsSeverityNeq{intel.AttackSurfaceReportIssueClassParamsSeverityNeqLow, intel.AttackSurfaceReportIssueClassParamsSeverityNeqModerate}), + Severity: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), + SeverityNeq: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), Subject: cloudflare.F([]string{"example.com", "example.com", "example.com"}), SubjectNeq: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }) @@ -140,12 +140,12 @@ func TestAttackSurfaceReportIssueSeverityWithOptionalParams(t *testing.T) { Dismissed: cloudflare.F(false), IssueClass: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), IssueClassNeq: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), - IssueType: cloudflare.F([]intel.AttackSurfaceReportIssueSeverityParamsIssueType{intel.AttackSurfaceReportIssueSeverityParamsIssueTypeComplianceViolation, intel.AttackSurfaceReportIssueSeverityParamsIssueTypeEmailSecurity}), - IssueTypeNeq: cloudflare.F([]intel.AttackSurfaceReportIssueSeverityParamsIssueTypeNeq{intel.AttackSurfaceReportIssueSeverityParamsIssueTypeNeqComplianceViolation, intel.AttackSurfaceReportIssueSeverityParamsIssueTypeNeqEmailSecurity}), + IssueType: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), + IssueTypeNeq: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), Product: cloudflare.F([]string{"access", "dns"}), ProductNeq: cloudflare.F([]string{"access", "dns"}), - Severity: cloudflare.F([]intel.AttackSurfaceReportIssueSeverityParamsSeverity{intel.AttackSurfaceReportIssueSeverityParamsSeverityLow, intel.AttackSurfaceReportIssueSeverityParamsSeverityModerate}), - SeverityNeq: cloudflare.F([]intel.AttackSurfaceReportIssueSeverityParamsSeverityNeq{intel.AttackSurfaceReportIssueSeverityParamsSeverityNeqLow, intel.AttackSurfaceReportIssueSeverityParamsSeverityNeqModerate}), + Severity: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), + SeverityNeq: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), Subject: cloudflare.F([]string{"example.com", "example.com", "example.com"}), SubjectNeq: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }) @@ -177,12 +177,12 @@ func TestAttackSurfaceReportIssueTypeWithOptionalParams(t *testing.T) { Dismissed: cloudflare.F(false), IssueClass: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), IssueClassNeq: cloudflare.F([]string{"a_record_dangling", "always_use_https_not_enabled"}), - IssueType: cloudflare.F([]intel.AttackSurfaceReportIssueTypeParamsIssueType{intel.AttackSurfaceReportIssueTypeParamsIssueTypeComplianceViolation, intel.AttackSurfaceReportIssueTypeParamsIssueTypeEmailSecurity}), - IssueTypeNeq: cloudflare.F([]intel.AttackSurfaceReportIssueTypeParamsIssueTypeNeq{intel.AttackSurfaceReportIssueTypeParamsIssueTypeNeqComplianceViolation, intel.AttackSurfaceReportIssueTypeParamsIssueTypeNeqEmailSecurity}), + IssueType: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), + IssueTypeNeq: cloudflare.F([]intel.IssueType{intel.IssueTypeComplianceViolation, intel.IssueTypeEmailSecurity}), Product: cloudflare.F([]string{"access", "dns"}), ProductNeq: cloudflare.F([]string{"access", "dns"}), - Severity: cloudflare.F([]intel.AttackSurfaceReportIssueTypeParamsSeverity{intel.AttackSurfaceReportIssueTypeParamsSeverityLow, intel.AttackSurfaceReportIssueTypeParamsSeverityModerate}), - SeverityNeq: cloudflare.F([]intel.AttackSurfaceReportIssueTypeParamsSeverityNeq{intel.AttackSurfaceReportIssueTypeParamsSeverityNeqLow, intel.AttackSurfaceReportIssueTypeParamsSeverityNeqModerate}), + Severity: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), + SeverityNeq: cloudflare.F([]intel.SeverityQueryParam{intel.SeverityQueryParamLow, intel.SeverityQueryParamModerate}), Subject: cloudflare.F([]string{"example.com", "example.com", "example.com"}), SubjectNeq: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }) diff --git a/intel/attacksurfacereportissuetype.go b/intel/attacksurfacereportissuetype.go index eb05bc329f3..af9df35cd01 100644 --- a/intel/attacksurfacereportissuetype.go +++ b/intel/attacksurfacereportissuetype.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -50,9 +51,9 @@ type AttackSurfaceReportIssueTypeGetParams struct { } type AttackSurfaceReportIssueTypeGetResponseEnvelope struct { - Errors []AttackSurfaceReportIssueTypeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AttackSurfaceReportIssueTypeGetResponseEnvelopeMessages `json:"messages,required"` - Result []string `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []string `json:"result,required"` // Whether the API call was successful Success AttackSurfaceReportIssueTypeGetResponseEnvelopeSuccess `json:"success,required"` JSON attackSurfaceReportIssueTypeGetResponseEnvelopeJSON `json:"-"` @@ -77,53 +78,6 @@ func (r attackSurfaceReportIssueTypeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AttackSurfaceReportIssueTypeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueTypeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// attackSurfaceReportIssueTypeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AttackSurfaceReportIssueTypeGetResponseEnvelopeErrors] -type attackSurfaceReportIssueTypeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueTypeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueTypeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AttackSurfaceReportIssueTypeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON attackSurfaceReportIssueTypeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// attackSurfaceReportIssueTypeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AttackSurfaceReportIssueTypeGetResponseEnvelopeMessages] -type attackSurfaceReportIssueTypeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackSurfaceReportIssueTypeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackSurfaceReportIssueTypeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AttackSurfaceReportIssueTypeGetResponseEnvelopeSuccess bool diff --git a/intel/dns.go b/intel/dns.go index 061e10c2695..7f1cb07d88c 100644 --- a/intel/dns.go +++ b/intel/dns.go @@ -11,8 +11,10 @@ import ( "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" ) @@ -34,19 +36,29 @@ func NewDNSService(opts ...option.RequestOption) (r *DNSService) { } // Get Passive DNS by IP -func (r *DNSService) Get(ctx context.Context, params DNSGetParams, opts ...option.RequestOption) (res *IntelPassiveDNSByIP, err error) { - opts = append(r.Options[:], opts...) - var env DNSGetResponseEnvelope +func (r *DNSService) List(ctx context.Context, params DNSListParams, opts ...option.RequestOption) (res *pagination.V4PagePagination[DNSListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := fmt.Sprintf("accounts/%s/intel/dns", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) if err != nil { - return + return nil, err } - res = &env.Result - return + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Get Passive DNS by IP +func (r *DNSService) ListAutoPaging(ctx context.Context, params DNSListParams, opts ...option.RequestOption) *pagination.V4PagePaginationAutoPager[DNSListResponse] { + return pagination.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...)) } -type IntelPassiveDNSByIP struct { +type DNS struct { // Total results returned based on your search parameters. Count float64 `json:"count"` // Current page within paginated list of results. @@ -54,13 +66,12 @@ type IntelPassiveDNSByIP struct { // Number of results per page of results. PerPage float64 `json:"per_page"` // Reverse DNS look-ups observed during the time period. - ReverseRecords []IntelPassiveDNSByIPReverseRecord `json:"reverse_records"` - JSON intelPassiveDNSByIPJSON `json:"-"` + ReverseRecords []DNSReverseRecord `json:"reverse_records"` + JSON dnsJSON `json:"-"` } -// intelPassiveDNSByIPJSON contains the JSON metadata for the struct -// [IntelPassiveDNSByIP] -type intelPassiveDNSByIPJSON struct { +// dnsJSON contains the JSON metadata for the struct [DNS] +type dnsJSON struct { Count apijson.Field Page apijson.Field PerPage apijson.Field @@ -69,27 +80,27 @@ type intelPassiveDNSByIPJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelPassiveDNSByIP) UnmarshalJSON(data []byte) (err error) { +func (r *DNS) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPassiveDNSByIPJSON) RawJSON() string { +func (r dnsJSON) RawJSON() string { return r.raw } -type IntelPassiveDNSByIPReverseRecord struct { +type DNSReverseRecord struct { // First seen date of the DNS record during the time period. FirstSeen time.Time `json:"first_seen" format:"date"` // Hostname that the IP was observed resolving to. Hostname interface{} `json:"hostname"` // Last seen date of the DNS record during the time period. - LastSeen time.Time `json:"last_seen" format:"date"` - JSON intelPassiveDNSByIPReverseRecordJSON `json:"-"` + LastSeen time.Time `json:"last_seen" format:"date"` + JSON dnsReverseRecordJSON `json:"-"` } -// intelPassiveDNSByIPReverseRecordJSON contains the JSON metadata for the struct -// [IntelPassiveDNSByIPReverseRecord] -type intelPassiveDNSByIPReverseRecordJSON struct { +// dnsReverseRecordJSON contains the JSON metadata for the struct +// [DNSReverseRecord] +type dnsReverseRecordJSON struct { FirstSeen apijson.Field Hostname apijson.Field LastSeen apijson.Field @@ -97,61 +108,53 @@ type intelPassiveDNSByIPReverseRecordJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelPassiveDNSByIPReverseRecord) UnmarshalJSON(data []byte) (err error) { +func (r *DNSReverseRecord) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelPassiveDNSByIPReverseRecordJSON) RawJSON() string { +func (r dnsReverseRecordJSON) RawJSON() string { return r.raw } -type DNSGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - IPV4 param.Field[string] `query:"ipv4"` - // 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"` - StartEndParams param.Field[DNSGetParamsStartEndParams] `query:"start_end_params"` +type DNSParam struct { + // Total results returned based on your search parameters. + Count param.Field[float64] `json:"count"` + // Current page within paginated list of results. + Page param.Field[float64] `json:"page"` + // Number of results per page of results. + PerPage param.Field[float64] `json:"per_page"` + // Reverse DNS look-ups observed during the time period. + ReverseRecords param.Field[[]DNSReverseRecordParam] `json:"reverse_records"` } -// URLQuery serializes [DNSGetParams]'s query parameters as `url.Values`. -func (r DNSGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) +func (r DNSParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSGetParamsStartEndParams struct { - // Defaults to the current date. - End param.Field[time.Time] `query:"end" format:"date"` - // Defaults to 30 days before the end parameter value. - Start param.Field[time.Time] `query:"start" format:"date"` +type DNSReverseRecordParam struct { + // First seen date of the DNS record during the time period. + FirstSeen param.Field[time.Time] `json:"first_seen" format:"date"` + // Hostname that the IP was observed resolving to. + Hostname param.Field[interface{}] `json:"hostname"` + // Last seen date of the DNS record during the time period. + LastSeen param.Field[time.Time] `json:"last_seen" format:"date"` } -// URLQuery serializes [DNSGetParamsStartEndParams]'s query parameters as -// `url.Values`. -func (r DNSGetParamsStartEndParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) +func (r DNSReverseRecordParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DNSGetResponseEnvelope struct { - Errors []DNSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelPassiveDNSByIP `json:"result,required"` +type DNSListResponse struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DNS `json:"result,required"` // Whether the API call was successful - Success DNSGetResponseEnvelopeSuccess `json:"success,required"` - JSON dnsGetResponseEnvelopeJSON `json:"-"` + Success DNSListResponseSuccess `json:"success,required"` + JSON dnsListResponseJSON `json:"-"` } -// dnsGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSGetResponseEnvelope] -type dnsGetResponseEnvelopeJSON struct { +// dnsListResponseJSON contains the JSON metadata for the struct [DNSListResponse] +type dnsListResponseJSON struct { Errors apijson.Field Messages apijson.Field Result apijson.Field @@ -160,71 +163,60 @@ type dnsGetResponseEnvelopeJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *DNSListResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsGetResponseEnvelopeJSON) RawJSON() string { +func (r dnsListResponseJSON) RawJSON() string { return r.raw } -type DNSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DNSGetResponseEnvelopeErrors] -type dnsGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +// Whether the API call was successful +type DNSListResponseSuccess bool -func (r dnsGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} +const ( + DNSListResponseSuccessTrue DNSListResponseSuccess = true +) -type DNSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsGetResponseEnvelopeMessagesJSON `json:"-"` +func (r DNSListResponseSuccess) IsKnown() bool { + switch r { + case DNSListResponseSuccessTrue: + return true + } + return false } -// dnsGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DNSGetResponseEnvelopeMessages] -type dnsGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +type DNSListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + IPV4 param.Field[string] `query:"ipv4"` + // 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"` + StartEndParams param.Field[DNSListParamsStartEndParams] `query:"start_end_params"` } -func (r *DNSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// URLQuery serializes [DNSListParams]'s query parameters as `url.Values`. +func (r DNSListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } -func (r dnsGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw +type DNSListParamsStartEndParams struct { + // Defaults to the current date. + End param.Field[time.Time] `query:"end" format:"date"` + // Defaults to 30 days before the end parameter value. + Start param.Field[time.Time] `query:"start" format:"date"` } -// Whether the API call was successful -type DNSGetResponseEnvelopeSuccess bool - -const ( - DNSGetResponseEnvelopeSuccessTrue DNSGetResponseEnvelopeSuccess = true -) - -func (r DNSGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case DNSGetResponseEnvelopeSuccessTrue: - return true - } - return false +// URLQuery serializes [DNSListParamsStartEndParams]'s query parameters as +// `url.Values`. +func (r DNSListParamsStartEndParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } diff --git a/intel/dns_test.go b/intel/dns_test.go index 3a17f83c4d6..fb1700345f1 100644 --- a/intel/dns_test.go +++ b/intel/dns_test.go @@ -15,7 +15,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/option" ) -func TestDNSGetWithOptionalParams(t *testing.T) { +func TestDNSListWithOptionalParams(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 { @@ -29,12 +29,12 @@ func TestDNSGetWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Intel.DNS.Get(context.TODO(), intel.DNSGetParams{ + _, err := client.Intel.DNS.List(context.TODO(), intel.DNSListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), IPV4: cloudflare.F("string"), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(20.000000), - StartEndParams: cloudflare.F(intel.DNSGetParamsStartEndParams{ + StartEndParams: cloudflare.F(intel.DNSListParamsStartEndParams{ End: cloudflare.F(time.Now()), Start: cloudflare.F(time.Now()), }), diff --git a/intel/domain.go b/intel/domain.go index bd62eaa4d88..61baec62142 100644 --- a/intel/domain.go +++ b/intel/domain.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -35,7 +36,7 @@ func NewDomainService(opts ...option.RequestOption) (r *DomainService) { } // Get Domain Details -func (r *DomainService) Get(ctx context.Context, params DomainGetParams, opts ...option.RequestOption) (res *IntelDomain, err error) { +func (r *DomainService) Get(ctx context.Context, params DomainGetParams, opts ...option.RequestOption) (res *Domain, err error) { opts = append(r.Options[:], opts...) var env DomainGetResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/domain", params.AccountID) @@ -47,34 +48,34 @@ func (r *DomainService) Get(ctx context.Context, params DomainGetParams, opts .. return } -type IntelDomain struct { +type Domain struct { // Additional information related to the host name. - AdditionalInformation IntelDomainAdditionalInformation `json:"additional_information"` + AdditionalInformation DomainAdditionalInformation `json:"additional_information"` // Application that the hostname belongs to. - Application IntelDomainApplication `json:"application"` + Application DomainApplication `json:"application"` // Current content categories. - ContentCategories []interface{} `json:"content_categories"` - Domain string `json:"domain"` - InheritedContentCategories []IntelDomainInheritedContentCategory `json:"inherited_content_categories"` + ContentCategories []interface{} `json:"content_categories"` + Domain string `json:"domain"` + InheritedContentCategories []DomainInheritedContentCategory `json:"inherited_content_categories"` // Domain from which `inherited_content_categories` and `inherited_risk_types` are // inherited, if applicable. - InheritedFrom string `json:"inherited_from"` - InheritedRiskTypes []IntelDomainInheritedRiskType `json:"inherited_risk_types"` + InheritedFrom string `json:"inherited_from"` + InheritedRiskTypes []DomainInheritedRiskType `json:"inherited_risk_types"` // Global Cloudflare 100k ranking for the last 30 days, if available for the // hostname. The top ranked domain is 1, the lowest ranked domain is 100,000. PopularityRank int64 `json:"popularity_rank"` // Specifies a list of references to one or more IP addresses or domain names that // the domain name currently resolves to. - ResolvesToRefs []IntelDomainResolvesToRef `json:"resolves_to_refs"` + ResolvesToRefs []DomainResolvesToRef `json:"resolves_to_refs"` // Hostname risk score, which is a value between 0 (lowest risk) to 1 (highest // risk). - RiskScore float64 `json:"risk_score"` - RiskTypes []interface{} `json:"risk_types"` - JSON intelDomainJSON `json:"-"` + RiskScore float64 `json:"risk_score"` + RiskTypes []interface{} `json:"risk_types"` + JSON domainJSON `json:"-"` } -// intelDomainJSON contains the JSON metadata for the struct [IntelDomain] -type intelDomainJSON struct { +// domainJSON contains the JSON metadata for the struct [Domain] +type domainJSON struct { AdditionalInformation apijson.Field Application apijson.Field ContentCategories apijson.Field @@ -90,71 +91,71 @@ type intelDomainJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelDomain) UnmarshalJSON(data []byte) (err error) { +func (r *Domain) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainJSON) RawJSON() string { +func (r domainJSON) RawJSON() string { return r.raw } // Additional information related to the host name. -type IntelDomainAdditionalInformation struct { +type DomainAdditionalInformation struct { // Suspected DGA malware family. - SuspectedMalwareFamily string `json:"suspected_malware_family"` - JSON intelDomainAdditionalInformationJSON `json:"-"` + SuspectedMalwareFamily string `json:"suspected_malware_family"` + JSON domainAdditionalInformationJSON `json:"-"` } -// intelDomainAdditionalInformationJSON contains the JSON metadata for the struct -// [IntelDomainAdditionalInformation] -type intelDomainAdditionalInformationJSON struct { +// domainAdditionalInformationJSON contains the JSON metadata for the struct +// [DomainAdditionalInformation] +type domainAdditionalInformationJSON struct { SuspectedMalwareFamily apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelDomainAdditionalInformation) UnmarshalJSON(data []byte) (err error) { +func (r *DomainAdditionalInformation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainAdditionalInformationJSON) RawJSON() string { +func (r domainAdditionalInformationJSON) RawJSON() string { return r.raw } // Application that the hostname belongs to. -type IntelDomainApplication struct { - ID int64 `json:"id"` - Name string `json:"name"` - JSON intelDomainApplicationJSON `json:"-"` +type DomainApplication struct { + ID int64 `json:"id"` + Name string `json:"name"` + JSON domainApplicationJSON `json:"-"` } -// intelDomainApplicationJSON contains the JSON metadata for the struct -// [IntelDomainApplication] -type intelDomainApplicationJSON struct { +// domainApplicationJSON contains the JSON metadata for the struct +// [DomainApplication] +type domainApplicationJSON struct { ID apijson.Field Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelDomainApplication) UnmarshalJSON(data []byte) (err error) { +func (r *DomainApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainApplicationJSON) RawJSON() string { +func (r domainApplicationJSON) RawJSON() string { return r.raw } -type IntelDomainInheritedContentCategory struct { - ID int64 `json:"id"` - Name string `json:"name"` - SuperCategoryID int64 `json:"super_category_id"` - JSON intelDomainInheritedContentCategoryJSON `json:"-"` +type DomainInheritedContentCategory struct { + ID int64 `json:"id"` + Name string `json:"name"` + SuperCategoryID int64 `json:"super_category_id"` + JSON domainInheritedContentCategoryJSON `json:"-"` } -// intelDomainInheritedContentCategoryJSON contains the JSON metadata for the -// struct [IntelDomainInheritedContentCategory] -type intelDomainInheritedContentCategoryJSON struct { +// domainInheritedContentCategoryJSON contains the JSON metadata for the struct +// [DomainInheritedContentCategory] +type domainInheritedContentCategoryJSON struct { ID apijson.Field Name apijson.Field SuperCategoryID apijson.Field @@ -162,24 +163,24 @@ type intelDomainInheritedContentCategoryJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelDomainInheritedContentCategory) UnmarshalJSON(data []byte) (err error) { +func (r *DomainInheritedContentCategory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainInheritedContentCategoryJSON) RawJSON() string { +func (r domainInheritedContentCategoryJSON) RawJSON() string { return r.raw } -type IntelDomainInheritedRiskType struct { - ID int64 `json:"id"` - Name string `json:"name"` - SuperCategoryID int64 `json:"super_category_id"` - JSON intelDomainInheritedRiskTypeJSON `json:"-"` +type DomainInheritedRiskType struct { + ID int64 `json:"id"` + Name string `json:"name"` + SuperCategoryID int64 `json:"super_category_id"` + JSON domainInheritedRiskTypeJSON `json:"-"` } -// intelDomainInheritedRiskTypeJSON contains the JSON metadata for the struct -// [IntelDomainInheritedRiskType] -type intelDomainInheritedRiskTypeJSON struct { +// domainInheritedRiskTypeJSON contains the JSON metadata for the struct +// [DomainInheritedRiskType] +type domainInheritedRiskTypeJSON struct { ID apijson.Field Name apijson.Field SuperCategoryID apijson.Field @@ -187,37 +188,37 @@ type intelDomainInheritedRiskTypeJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelDomainInheritedRiskType) UnmarshalJSON(data []byte) (err error) { +func (r *DomainInheritedRiskType) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainInheritedRiskTypeJSON) RawJSON() string { +func (r domainInheritedRiskTypeJSON) RawJSON() string { return r.raw } -type IntelDomainResolvesToRef struct { +type DomainResolvesToRef struct { // STIX 2.1 identifier: // https://docs.oasis-open.org/cti/stix/v2.1/cs02/stix-v2.1-cs02.html#_64yvzeku5a5c ID string `json:"id"` // IP address or domain name. - Value string `json:"value"` - JSON intelDomainResolvesToRefJSON `json:"-"` + Value string `json:"value"` + JSON domainResolvesToRefJSON `json:"-"` } -// intelDomainResolvesToRefJSON contains the JSON metadata for the struct -// [IntelDomainResolvesToRef] -type intelDomainResolvesToRefJSON struct { +// domainResolvesToRefJSON contains the JSON metadata for the struct +// [DomainResolvesToRef] +type domainResolvesToRefJSON struct { ID apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelDomainResolvesToRef) UnmarshalJSON(data []byte) (err error) { +func (r *DomainResolvesToRef) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainResolvesToRefJSON) RawJSON() string { +func (r domainResolvesToRefJSON) RawJSON() string { return r.raw } @@ -230,15 +231,15 @@ type DomainGetParams struct { // URLQuery serializes [DomainGetParams]'s query parameters as `url.Values`. func (r DomainGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DomainGetResponseEnvelope struct { - Errors []DomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DomainGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelDomain `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Domain `json:"result,required"` // Whether the API call was successful Success DomainGetResponseEnvelopeSuccess `json:"success,required"` JSON domainGetResponseEnvelopeJSON `json:"-"` @@ -263,52 +264,6 @@ func (r domainGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// domainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DomainGetResponseEnvelopeErrors] -type domainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// domainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DomainGetResponseEnvelopeMessages] -type domainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DomainGetResponseEnvelopeSuccess bool diff --git a/intel/domainbulk.go b/intel/domainbulk.go index 806fabed347..ee3d9225a59 100644 --- a/intel/domainbulk.go +++ b/intel/domainbulk.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -200,15 +201,15 @@ type DomainBulkGetParams struct { // URLQuery serializes [DomainBulkGetParams]'s query parameters as `url.Values`. func (r DomainBulkGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DomainBulkGetResponseEnvelope struct { - Errors []DomainBulkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DomainBulkGetResponseEnvelopeMessages `json:"messages,required"` - Result []DomainBulkGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []DomainBulkGetResponse `json:"result,required,nullable"` // Whether the API call was successful Success DomainBulkGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DomainBulkGetResponseEnvelopeResultInfo `json:"result_info"` @@ -235,52 +236,6 @@ func (r domainBulkGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DomainBulkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainBulkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// domainBulkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DomainBulkGetResponseEnvelopeErrors] -type domainBulkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainBulkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainBulkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DomainBulkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainBulkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// domainBulkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DomainBulkGetResponseEnvelopeMessages] -type domainBulkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainBulkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainBulkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DomainBulkGetResponseEnvelopeSuccess bool diff --git a/intel/domainhistory.go b/intel/domainhistory.go index 597849240bd..552c9695c60 100644 --- a/intel/domainhistory.go +++ b/intel/domainhistory.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -35,7 +36,7 @@ func NewDomainHistoryService(opts ...option.RequestOption) (r *DomainHistoryServ } // Get Domain History -func (r *DomainHistoryService) Get(ctx context.Context, params DomainHistoryGetParams, opts ...option.RequestOption) (res *[]IntelDomainHistory, err error) { +func (r *DomainHistoryService) Get(ctx context.Context, params DomainHistoryGetParams, opts ...option.RequestOption) (res *[]DomainHistory, err error) { opts = append(r.Options[:], opts...) var env DomainHistoryGetResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/domain-history", params.AccountID) @@ -47,39 +48,38 @@ func (r *DomainHistoryService) Get(ctx context.Context, params DomainHistoryGetP return } -type IntelDomainHistory struct { - Categorizations []IntelDomainHistoryCategorization `json:"categorizations"` - Domain string `json:"domain"` - JSON intelDomainHistoryJSON `json:"-"` +type DomainHistory struct { + Categorizations []DomainHistoryCategorization `json:"categorizations"` + Domain string `json:"domain"` + JSON domainHistoryJSON `json:"-"` } -// intelDomainHistoryJSON contains the JSON metadata for the struct -// [IntelDomainHistory] -type intelDomainHistoryJSON struct { +// domainHistoryJSON contains the JSON metadata for the struct [DomainHistory] +type domainHistoryJSON struct { Categorizations apijson.Field Domain apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *IntelDomainHistory) UnmarshalJSON(data []byte) (err error) { +func (r *DomainHistory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainHistoryJSON) RawJSON() string { +func (r domainHistoryJSON) RawJSON() string { return r.raw } -type IntelDomainHistoryCategorization struct { - Categories []interface{} `json:"categories"` - End time.Time `json:"end" format:"date"` - Start time.Time `json:"start" format:"date"` - JSON intelDomainHistoryCategorizationJSON `json:"-"` +type DomainHistoryCategorization struct { + Categories []interface{} `json:"categories"` + End time.Time `json:"end" format:"date"` + Start time.Time `json:"start" format:"date"` + JSON domainHistoryCategorizationJSON `json:"-"` } -// intelDomainHistoryCategorizationJSON contains the JSON metadata for the struct -// [IntelDomainHistoryCategorization] -type intelDomainHistoryCategorizationJSON struct { +// domainHistoryCategorizationJSON contains the JSON metadata for the struct +// [DomainHistoryCategorization] +type domainHistoryCategorizationJSON struct { Categories apijson.Field End apijson.Field Start apijson.Field @@ -87,11 +87,11 @@ type intelDomainHistoryCategorizationJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelDomainHistoryCategorization) UnmarshalJSON(data []byte) (err error) { +func (r *DomainHistoryCategorization) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelDomainHistoryCategorizationJSON) RawJSON() string { +func (r domainHistoryCategorizationJSON) RawJSON() string { return r.raw } @@ -104,15 +104,15 @@ type DomainHistoryGetParams struct { // URLQuery serializes [DomainHistoryGetParams]'s query parameters as `url.Values`. func (r DomainHistoryGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DomainHistoryGetResponseEnvelope struct { - Errors []DomainHistoryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DomainHistoryGetResponseEnvelopeMessages `json:"messages,required"` - Result []IntelDomainHistory `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []DomainHistory `json:"result,required,nullable"` // Whether the API call was successful Success DomainHistoryGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DomainHistoryGetResponseEnvelopeResultInfo `json:"result_info"` @@ -139,52 +139,6 @@ func (r domainHistoryGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DomainHistoryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainHistoryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// domainHistoryGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DomainHistoryGetResponseEnvelopeErrors] -type domainHistoryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainHistoryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainHistoryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DomainHistoryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainHistoryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// domainHistoryGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DomainHistoryGetResponseEnvelopeMessages] -type domainHistoryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainHistoryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainHistoryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DomainHistoryGetResponseEnvelopeSuccess bool diff --git a/intel/indicatorfeed.go b/intel/indicatorfeed.go index 2d20b37a7ce..87296245c6c 100644 --- a/intel/indicatorfeed.go +++ b/intel/indicatorfeed.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -273,9 +274,9 @@ func (r IndicatorFeedNewParams) MarshalJSON() (data []byte, err error) { } type IndicatorFeedNewResponseEnvelope struct { - Errors []IndicatorFeedNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IndicatorFeedNewResponseEnvelopeMessages `json:"messages,required"` - Result IndicatorFeedNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndicatorFeedNewResponse `json:"result,required"` // Whether the API call was successful Success IndicatorFeedNewResponseEnvelopeSuccess `json:"success,required"` JSON indicatorFeedNewResponseEnvelopeJSON `json:"-"` @@ -300,52 +301,6 @@ func (r indicatorFeedNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndicatorFeedNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// indicatorFeedNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IndicatorFeedNewResponseEnvelopeErrors] -type indicatorFeedNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndicatorFeedNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// indicatorFeedNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndicatorFeedNewResponseEnvelopeMessages] -type indicatorFeedNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndicatorFeedNewResponseEnvelopeSuccess bool @@ -373,9 +328,9 @@ func (r IndicatorFeedUpdateParams) MarshalJSON() (data []byte, err error) { } type IndicatorFeedUpdateResponseEnvelope struct { - Errors []IndicatorFeedUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []IndicatorFeedUpdateResponseEnvelopeMessages `json:"messages,required"` - Result IndicatorFeedUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndicatorFeedUpdateResponse `json:"result,required"` // Whether the API call was successful Success IndicatorFeedUpdateResponseEnvelopeSuccess `json:"success,required"` JSON indicatorFeedUpdateResponseEnvelopeJSON `json:"-"` @@ -400,52 +355,6 @@ func (r indicatorFeedUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndicatorFeedUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// indicatorFeedUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IndicatorFeedUpdateResponseEnvelopeErrors] -type indicatorFeedUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndicatorFeedUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// indicatorFeedUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [IndicatorFeedUpdateResponseEnvelopeMessages] -type indicatorFeedUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndicatorFeedUpdateResponseEnvelopeSuccess bool @@ -477,9 +386,9 @@ type IndicatorFeedGetParams struct { } type IndicatorFeedGetResponseEnvelope struct { - Errors []IndicatorFeedGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IndicatorFeedGetResponseEnvelopeMessages `json:"messages,required"` - Result IndicatorFeedGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndicatorFeedGetResponse `json:"result,required"` // Whether the API call was successful Success IndicatorFeedGetResponseEnvelopeSuccess `json:"success,required"` JSON indicatorFeedGetResponseEnvelopeJSON `json:"-"` @@ -504,52 +413,6 @@ func (r indicatorFeedGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndicatorFeedGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// indicatorFeedGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IndicatorFeedGetResponseEnvelopeErrors] -type indicatorFeedGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndicatorFeedGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// indicatorFeedGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndicatorFeedGetResponseEnvelopeMessages] -type indicatorFeedGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndicatorFeedGetResponseEnvelopeSuccess bool diff --git a/intel/indicatorfeedpermission.go b/intel/indicatorfeedpermission.go index 49fd5819063..ae962e755b6 100644 --- a/intel/indicatorfeedpermission.go +++ b/intel/indicatorfeedpermission.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -156,9 +157,9 @@ func (r IndicatorFeedPermissionNewParams) MarshalJSON() (data []byte, err error) } type IndicatorFeedPermissionNewResponseEnvelope struct { - Errors []IndicatorFeedPermissionNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IndicatorFeedPermissionNewResponseEnvelopeMessages `json:"messages,required"` - Result IndicatorFeedPermissionNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndicatorFeedPermissionNewResponse `json:"result,required"` // Whether the API call was successful Success IndicatorFeedPermissionNewResponseEnvelopeSuccess `json:"success,required"` JSON indicatorFeedPermissionNewResponseEnvelopeJSON `json:"-"` @@ -183,52 +184,6 @@ func (r indicatorFeedPermissionNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndicatorFeedPermissionNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedPermissionNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// indicatorFeedPermissionNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [IndicatorFeedPermissionNewResponseEnvelopeErrors] -type indicatorFeedPermissionNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedPermissionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedPermissionNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndicatorFeedPermissionNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedPermissionNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// indicatorFeedPermissionNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [IndicatorFeedPermissionNewResponseEnvelopeMessages] -type indicatorFeedPermissionNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedPermissionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedPermissionNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndicatorFeedPermissionNewResponseEnvelopeSuccess bool @@ -250,9 +205,9 @@ type IndicatorFeedPermissionListParams struct { } type IndicatorFeedPermissionListResponseEnvelope struct { - Errors []IndicatorFeedPermissionListResponseEnvelopeErrors `json:"errors,required"` - Messages []IndicatorFeedPermissionListResponseEnvelopeMessages `json:"messages,required"` - Result []IndicatorFeedPermissionListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []IndicatorFeedPermissionListResponse `json:"result,required"` // Whether the API call was successful Success IndicatorFeedPermissionListResponseEnvelopeSuccess `json:"success,required"` JSON indicatorFeedPermissionListResponseEnvelopeJSON `json:"-"` @@ -277,52 +232,6 @@ func (r indicatorFeedPermissionListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndicatorFeedPermissionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedPermissionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// indicatorFeedPermissionListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [IndicatorFeedPermissionListResponseEnvelopeErrors] -type indicatorFeedPermissionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedPermissionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedPermissionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndicatorFeedPermissionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedPermissionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// indicatorFeedPermissionListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [IndicatorFeedPermissionListResponseEnvelopeMessages] -type indicatorFeedPermissionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedPermissionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedPermissionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndicatorFeedPermissionListResponseEnvelopeSuccess bool @@ -352,9 +261,9 @@ func (r IndicatorFeedPermissionDeleteParams) MarshalJSON() (data []byte, err err } type IndicatorFeedPermissionDeleteResponseEnvelope struct { - Errors []IndicatorFeedPermissionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []IndicatorFeedPermissionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result IndicatorFeedPermissionDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndicatorFeedPermissionDeleteResponse `json:"result,required"` // Whether the API call was successful Success IndicatorFeedPermissionDeleteResponseEnvelopeSuccess `json:"success,required"` JSON indicatorFeedPermissionDeleteResponseEnvelopeJSON `json:"-"` @@ -379,52 +288,6 @@ func (r indicatorFeedPermissionDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndicatorFeedPermissionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [IndicatorFeedPermissionDeleteResponseEnvelopeErrors] -type indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedPermissionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndicatorFeedPermissionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [IndicatorFeedPermissionDeleteResponseEnvelopeMessages] -type indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndicatorFeedPermissionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndicatorFeedPermissionDeleteResponseEnvelopeSuccess bool diff --git a/intel/ip.go b/intel/ip.go index fcc32138711..06f485310c3 100644 --- a/intel/ip.go +++ b/intel/ip.go @@ -36,7 +36,7 @@ func NewIPService(opts ...option.RequestOption) (r *IPService) { } // Get IP Overview -func (r *IPService) Get(ctx context.Context, params IPGetParams, opts ...option.RequestOption) (res *[]IntelSchemasIP, err error) { +func (r *IPService) Get(ctx context.Context, params IPGetParams, opts ...option.RequestOption) (res *[]IP, err error) { opts = append(r.Options[:], opts...) var env IPGetResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/ip", params.AccountID) @@ -48,17 +48,17 @@ func (r *IPService) Get(ctx context.Context, params IPGetParams, opts ...option. return } -type IntelSchemasIP struct { +type IP struct { // Specifies a reference to the autonomous systems (AS) that the IP address belongs // to. - BelongsToRef IntelSchemasIPBelongsToRef `json:"belongs_to_ref"` - IP IntelSchemasIPIP `json:"ip" format:"ipv4"` - RiskTypes []interface{} `json:"risk_types"` - JSON intelSchemasIPJSON `json:"-"` + BelongsToRef IPBelongsToRef `json:"belongs_to_ref"` + IP IPIPUnion `json:"ip" format:"ipv4"` + RiskTypes []interface{} `json:"risk_types"` + JSON ipJSON `json:"-"` } -// intelSchemasIPJSON contains the JSON metadata for the struct [IntelSchemasIP] -type intelSchemasIPJSON struct { +// ipJSON contains the JSON metadata for the struct [IP] +type ipJSON struct { BelongsToRef apijson.Field IP apijson.Field RiskTypes apijson.Field @@ -66,29 +66,28 @@ type intelSchemasIPJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelSchemasIP) UnmarshalJSON(data []byte) (err error) { +func (r *IP) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelSchemasIPJSON) RawJSON() string { +func (r ipJSON) RawJSON() string { return r.raw } // Specifies a reference to the autonomous systems (AS) that the IP address belongs // to. -type IntelSchemasIPBelongsToRef struct { +type IPBelongsToRef struct { ID string `json:"id"` Country string `json:"country"` Description string `json:"description"` // Infrastructure type of this ASN. - Type IntelSchemasIPBelongsToRefType `json:"type"` - Value string `json:"value"` - JSON intelSchemasIPBelongsToRefJSON `json:"-"` + Type IPBelongsToRefType `json:"type"` + Value string `json:"value"` + JSON ipBelongsToRefJSON `json:"-"` } -// intelSchemasIPBelongsToRefJSON contains the JSON metadata for the struct -// [IntelSchemasIPBelongsToRef] -type intelSchemasIPBelongsToRefJSON struct { +// ipBelongsToRefJSON contains the JSON metadata for the struct [IPBelongsToRef] +type ipBelongsToRefJSON struct { ID apijson.Field Country apijson.Field Description apijson.Field @@ -98,39 +97,39 @@ type intelSchemasIPBelongsToRefJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelSchemasIPBelongsToRef) UnmarshalJSON(data []byte) (err error) { +func (r *IPBelongsToRef) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelSchemasIPBelongsToRefJSON) RawJSON() string { +func (r ipBelongsToRefJSON) RawJSON() string { return r.raw } // Infrastructure type of this ASN. -type IntelSchemasIPBelongsToRefType string +type IPBelongsToRefType string const ( - IntelSchemasIPBelongsToRefTypeHostingProvider IntelSchemasIPBelongsToRefType = "hosting_provider" - IntelSchemasIPBelongsToRefTypeIsp IntelSchemasIPBelongsToRefType = "isp" - IntelSchemasIPBelongsToRefTypeOrganization IntelSchemasIPBelongsToRefType = "organization" + IPBelongsToRefTypeHostingProvider IPBelongsToRefType = "hosting_provider" + IPBelongsToRefTypeIsp IPBelongsToRefType = "isp" + IPBelongsToRefTypeOrganization IPBelongsToRefType = "organization" ) -func (r IntelSchemasIPBelongsToRefType) IsKnown() bool { +func (r IPBelongsToRefType) IsKnown() bool { switch r { - case IntelSchemasIPBelongsToRefTypeHostingProvider, IntelSchemasIPBelongsToRefTypeIsp, IntelSchemasIPBelongsToRefTypeOrganization: + case IPBelongsToRefTypeHostingProvider, IPBelongsToRefTypeIsp, IPBelongsToRefTypeOrganization: return true } return false } // Union satisfied by [shared.UnionString] or [shared.UnionString]. -type IntelSchemasIPIP interface { - ImplementsIntelIntelSchemasIpip() +type IPIPUnion interface { + ImplementsIntelIpipUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*IntelSchemasIPIP)(nil)).Elem(), + reflect.TypeOf((*IPIPUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -153,15 +152,15 @@ type IPGetParams struct { // URLQuery serializes [IPGetParams]'s query parameters as `url.Values`. func (r IPGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type IPGetResponseEnvelope struct { - Errors []IPGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IPGetResponseEnvelopeMessages `json:"messages,required"` - Result []IntelSchemasIP `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []IP `json:"result,required,nullable"` // Whether the API call was successful Success IPGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo IPGetResponseEnvelopeResultInfo `json:"result_info"` @@ -188,52 +187,6 @@ func (r ipGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IPGetResponseEnvelopeErrors] -type ipGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IPGetResponseEnvelopeMessages] -type ipGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPGetResponseEnvelopeSuccess bool diff --git a/intel/iplist.go b/intel/iplist.go index ac103b988e9..4f727dba9c5 100644 --- a/intel/iplist.go +++ b/intel/iplist.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,7 +32,7 @@ func NewIPListService(opts ...option.RequestOption) (r *IPListService) { } // Get IP Lists -func (r *IPListService) Get(ctx context.Context, query IPListGetParams, opts ...option.RequestOption) (res *[]IntelIPList, err error) { +func (r *IPListService) Get(ctx context.Context, query IPListGetParams, opts ...option.RequestOption) (res *[]IPList, err error) { opts = append(r.Options[:], opts...) var env IPListGetResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/ip-list", query.AccountID) @@ -43,15 +44,15 @@ func (r *IPListService) Get(ctx context.Context, query IPListGetParams, opts ... return } -type IntelIPList struct { - ID int64 `json:"id"` - Description string `json:"description"` - Name string `json:"name"` - JSON intelIPListJSON `json:"-"` +type IPList struct { + ID int64 `json:"id"` + Description string `json:"description"` + Name string `json:"name"` + JSON ipListJSON `json:"-"` } -// intelIPListJSON contains the JSON metadata for the struct [IntelIPList] -type intelIPListJSON struct { +// ipListJSON contains the JSON metadata for the struct [IPList] +type ipListJSON struct { ID apijson.Field Description apijson.Field Name apijson.Field @@ -59,11 +60,11 @@ type intelIPListJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelIPList) UnmarshalJSON(data []byte) (err error) { +func (r *IPList) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelIPListJSON) RawJSON() string { +func (r ipListJSON) RawJSON() string { return r.raw } @@ -73,9 +74,9 @@ type IPListGetParams struct { } type IPListGetResponseEnvelope struct { - Errors []IPListGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IPListGetResponseEnvelopeMessages `json:"messages,required"` - Result []IntelIPList `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []IPList `json:"result,required,nullable"` // Whether the API call was successful Success IPListGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo IPListGetResponseEnvelopeResultInfo `json:"result_info"` @@ -102,52 +103,6 @@ func (r ipListGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPListGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipListGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipListGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IPListGetResponseEnvelopeErrors] -type ipListGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipListGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPListGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipListGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipListGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IPListGetResponseEnvelopeMessages] -type ipListGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipListGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPListGetResponseEnvelopeSuccess bool diff --git a/intel/miscategorization.go b/intel/miscategorization.go index e822ea1d485..4a3b7217fe7 100644 --- a/intel/miscategorization.go +++ b/intel/miscategorization.go @@ -35,7 +35,7 @@ func NewMiscategorizationService(opts ...option.RequestOption) (r *Miscategoriza } // Create Miscategorization -func (r *MiscategorizationService) New(ctx context.Context, params MiscategorizationNewParams, opts ...option.RequestOption) (res *MiscategorizationNewResponse, err error) { +func (r *MiscategorizationService) New(ctx context.Context, params MiscategorizationNewParams, opts ...option.RequestOption) (res *MiscategorizationNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env MiscategorizationNewResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/miscategorization", params.AccountID) @@ -49,13 +49,13 @@ func (r *MiscategorizationService) New(ctx context.Context, params Miscategoriza // Union satisfied by [intel.MiscategorizationNewResponseUnknown] or // [shared.UnionString]. -type MiscategorizationNewResponse interface { - ImplementsIntelMiscategorizationNewResponse() +type MiscategorizationNewResponseUnion interface { + ImplementsIntelMiscategorizationNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*MiscategorizationNewResponse)(nil)).Elem(), + reflect.TypeOf((*MiscategorizationNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -106,9 +106,9 @@ func (r MiscategorizationNewParamsIndicatorType) IsKnown() bool { } type MiscategorizationNewResponseEnvelope struct { - Errors []MiscategorizationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MiscategorizationNewResponseEnvelopeMessages `json:"messages,required"` - Result MiscategorizationNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MiscategorizationNewResponseUnion `json:"result,required"` // Whether the API call was successful Success MiscategorizationNewResponseEnvelopeSuccess `json:"success,required"` JSON miscategorizationNewResponseEnvelopeJSON `json:"-"` @@ -133,52 +133,6 @@ func (r miscategorizationNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MiscategorizationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON miscategorizationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// miscategorizationNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MiscategorizationNewResponseEnvelopeErrors] -type miscategorizationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MiscategorizationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r miscategorizationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MiscategorizationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON miscategorizationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// miscategorizationNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MiscategorizationNewResponseEnvelopeMessages] -type miscategorizationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MiscategorizationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r miscategorizationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MiscategorizationNewResponseEnvelopeSuccess bool diff --git a/intel/sinkhole.go b/intel/sinkhole.go index 0094d97d4f4..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[IntelSinkholeItem], 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[IntelSinkholeItem] { +func (r *SinkholeService) ListAutoPaging(ctx context.Context, query SinkholeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Sinkhole] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } -type IntelSinkholeItem struct { +type Sinkhole struct { // The unique identifier for the sinkhole ID int64 `json:"id"` // The account tag that owns this sinkhole @@ -69,13 +69,12 @@ type IntelSinkholeItem 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 intelSinkholeItemJSON `json:"-"` + R2ID string `json:"r2_id"` + JSON sinkholeJSON `json:"-"` } -// intelSinkholeItemJSON contains the JSON metadata for the struct -// [IntelSinkholeItem] -type intelSinkholeItemJSON struct { +// sinkholeJSON contains the JSON metadata for the struct [Sinkhole] +type sinkholeJSON struct { ID apijson.Field AccountTag apijson.Field CreatedOn apijson.Field @@ -87,11 +86,11 @@ type intelSinkholeItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelSinkholeItem) UnmarshalJSON(data []byte) (err error) { +func (r *Sinkhole) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelSinkholeItemJSON) RawJSON() string { +func (r sinkholeJSON) RawJSON() string { return r.raw } diff --git a/intel/whois.go b/intel/whois.go index 68f9901f556..f30bca89a62 100644 --- a/intel/whois.go +++ b/intel/whois.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -34,7 +35,7 @@ func NewWhoisService(opts ...option.RequestOption) (r *WhoisService) { } // Get WHOIS Record -func (r *WhoisService) Get(ctx context.Context, params WhoisGetParams, opts ...option.RequestOption) (res *IntelWhois, err error) { +func (r *WhoisService) Get(ctx context.Context, params WhoisGetParams, opts ...option.RequestOption) (res *Whois, err error) { opts = append(r.Options[:], opts...) var env WhoisGetResponseEnvelope path := fmt.Sprintf("accounts/%s/intel/whois", params.AccountID) @@ -46,21 +47,21 @@ func (r *WhoisService) Get(ctx context.Context, params WhoisGetParams, opts ...o return } -type IntelWhois struct { - CreatedDate time.Time `json:"created_date" format:"date"` - Domain string `json:"domain"` - Nameservers []string `json:"nameservers"` - Registrant string `json:"registrant"` - RegistrantCountry string `json:"registrant_country"` - RegistrantEmail string `json:"registrant_email"` - RegistrantOrg string `json:"registrant_org"` - Registrar string `json:"registrar"` - UpdatedDate time.Time `json:"updated_date" format:"date"` - JSON intelWhoisJSON `json:"-"` +type Whois struct { + CreatedDate time.Time `json:"created_date" format:"date"` + Domain string `json:"domain"` + Nameservers []string `json:"nameservers"` + Registrant string `json:"registrant"` + RegistrantCountry string `json:"registrant_country"` + RegistrantEmail string `json:"registrant_email"` + RegistrantOrg string `json:"registrant_org"` + Registrar string `json:"registrar"` + UpdatedDate time.Time `json:"updated_date" format:"date"` + JSON whoisJSON `json:"-"` } -// intelWhoisJSON contains the JSON metadata for the struct [IntelWhois] -type intelWhoisJSON struct { +// whoisJSON contains the JSON metadata for the struct [Whois] +type whoisJSON struct { CreatedDate apijson.Field Domain apijson.Field Nameservers apijson.Field @@ -74,11 +75,11 @@ type intelWhoisJSON struct { ExtraFields map[string]apijson.Field } -func (r *IntelWhois) UnmarshalJSON(data []byte) (err error) { +func (r *Whois) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r intelWhoisJSON) RawJSON() string { +func (r whoisJSON) RawJSON() string { return r.raw } @@ -91,15 +92,15 @@ type WhoisGetParams struct { // URLQuery serializes [WhoisGetParams]'s query parameters as `url.Values`. func (r WhoisGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type WhoisGetResponseEnvelope struct { - Errors []WhoisGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WhoisGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelWhois `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Whois `json:"result,required"` // Whether the API call was successful Success WhoisGetResponseEnvelopeSuccess `json:"success,required"` JSON whoisGetResponseEnvelopeJSON `json:"-"` @@ -124,52 +125,6 @@ func (r whoisGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WhoisGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON whoisGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// whoisGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WhoisGetResponseEnvelopeErrors] -type whoisGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WhoisGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r whoisGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WhoisGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON whoisGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// whoisGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [WhoisGetResponseEnvelopeMessages] -type whoisGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WhoisGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r whoisGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WhoisGetResponseEnvelopeSuccess bool diff --git a/internal/apijson/decoder.go b/internal/apijson/decoder.go index 10839459289..2c1dd800c11 100644 --- a/internal/apijson/decoder.go +++ b/internal/apijson/decoder.go @@ -59,9 +59,9 @@ const ( // Some values had to fudged a bit, for example by converting a string to an // int, or an enum with extra values. loose exactness = iota - // There are some extra arguments + // There are some extra arguments, but other wise it matches the union. extras - // Exactly right + // Exactly right. exact ) diff --git a/internal/apijson/port.go b/internal/apijson/port.go new file mode 100644 index 00000000000..e3dc59f2cfa --- /dev/null +++ b/internal/apijson/port.go @@ -0,0 +1,94 @@ +package apijson + +import ( + "fmt" + "reflect" +) + +// Port copies over values from one struct to another struct. +func Port(from any, to any) error { + toVal := reflect.ValueOf(to) + fromVal := reflect.ValueOf(from) + + if toVal.Kind() != reflect.Ptr || toVal.IsNil() { + return fmt.Errorf("destination must be a non-nil pointer") + } + + for toVal.Kind() == reflect.Ptr { + toVal = toVal.Elem() + } + toType := toVal.Type() + + for fromVal.Kind() == reflect.Ptr { + fromVal = fromVal.Elem() + } + fromType := fromVal.Type() + + if toType.Kind() != reflect.Struct { + return fmt.Errorf("destination must be a non-nil pointer to a struct (%v %v)", toType, toType.Kind()) + } + + values := map[string]reflect.Value{} + fields := map[string]reflect.Value{} + + fromJSON := fromVal.FieldByName("JSON") + toJSON := toVal.FieldByName("JSON") + + // First, iterate through the from fields and load all the "normal" fields in the struct to the map of + // string to reflect.Value, as well as their raw .JSON.Foo counterpart. + for i := 0; i < fromType.NumField(); i++ { + field := fromType.Field(i) + ptag, ok := parseJSONStructTag(field) + if !ok { + continue + } + if ptag.name == "-" { + continue + } + values[ptag.name] = fromVal.Field(i) + if fromJSON.IsValid() { + fields[ptag.name] = fromJSON.FieldByName(field.Name) + } + } + + // Use the values from the previous step to populate the 'to' struct. + for i := 0; i < toType.NumField(); i++ { + field := toType.Field(i) + ptag, ok := parseJSONStructTag(field) + if !ok { + continue + } + if ptag.name == "-" { + continue + } + if value, ok := values[ptag.name]; ok { + delete(values, ptag.name) + if value.Kind() == reflect.String { + toVal.Field(i).SetString(value.String()) + } else { + toVal.Field(i).Set(value) + } + } + + if fromJSONField, ok := fields[ptag.name]; ok { + if toJSONField := toJSON.FieldByName(field.Name); toJSONField.IsValid() { + toJSONField.Set(fromJSONField) + } + } + } + + // Finally, copy over the .JSON.raw and .JSON.Extras + if toJSON.IsValid() { + if raw := toJSON.FieldByName("raw"); raw.IsValid() { + setUnexportedField(raw, fromJSON.Interface().(interface{ RawJSON() string }).RawJSON()) + } + + if toExtras := toJSON.FieldByName("Extras"); toExtras.IsValid() { + if fromExtras := fromJSON.FieldByName("Extras"); fromExtras.IsValid() { + setUnexportedField(toExtras, fromExtras.Interface()) + } + } + } + + return nil +} diff --git a/internal/apijson/port_test.go b/internal/apijson/port_test.go new file mode 100644 index 00000000000..f17c297172b --- /dev/null +++ b/internal/apijson/port_test.go @@ -0,0 +1,166 @@ +package apijson + +import ( + "reflect" + "testing" +) + +type Metadata struct { + CreatedAt string `json:"created_at"` +} + +// Card is the "combined" type of CardVisa and CardMastercard +type Card struct { + Processor CardProcessor `json:"processor"` + Data any `json:"data"` + IsFoo bool `json:"is_foo"` + IsBar bool `json:"is_bar"` + Metadata Metadata `json:"metadata"` + + JSON cardJSON +} + +type cardJSON struct { + Processor Field + Data Field + IsFoo Field + IsBar Field + Metadata Field + Extras map[string]Field + raw string +} + +func (r cardJSON) RawJSON() string { return r.raw } + +type CardProcessor string + +// CardVisa +type CardVisa struct { + Processor CardVisaProcessor `json:"processor"` + Data CardVisaData `json:"data"` + IsFoo bool `json:"is_foo"` + Metadata Metadata `json:"metadata"` + + JSON cardVisaJSON +} + +type cardVisaJSON struct { + Processor Field + Data Field + IsFoo Field + Metadata Field + Extras map[string]Field + raw string +} + +func (r cardVisaJSON) RawJSON() string { return r.raw } + +type CardVisaProcessor string + +type CardVisaData struct { + Foo string `json:"foo"` +} + +// CardMastercard +type CardMastercard struct { + Processor CardMastercardProcessor `json:"processor"` + Data CardMastercardData `json:"data"` + IsBar bool `json:"is_bar"` + Metadata Metadata `json:"metadata"` + + JSON cardMastercardJSON +} + +type cardMastercardJSON struct { + Processor Field + Data Field + IsBar Field + Metadata Field + Extras map[string]Field + raw string +} + +func (r cardMastercardJSON) RawJSON() string { return r.raw } + +type CardMastercardProcessor string + +type CardMastercardData struct { + Bar int64 `json:"bar"` +} + +var portTests = map[string]struct { + from any + to any +}{ + "visa to card": { + CardVisa{ + Processor: "visa", + IsFoo: true, + Data: CardVisaData{ + Foo: "foo", + }, + Metadata: Metadata{ + CreatedAt: "Mar 29 2024", + }, + JSON: cardVisaJSON{ + raw: `{"processor":"visa","is_foo":true,"data":{"foo":"foo"}}`, + Processor: Field{raw: `"visa"`, status: valid}, + IsFoo: Field{raw: `true`, status: valid}, + Data: Field{raw: `{"foo":"foo"}`, status: valid}, + Extras: map[string]Field{"extra": {raw: `"yo"`, status: valid}}, + }, + }, + Card{ + Processor: "visa", + IsFoo: true, + IsBar: false, + Data: CardVisaData{ + Foo: "foo", + }, + Metadata: Metadata{ + CreatedAt: "Mar 29 2024", + }, + JSON: cardJSON{ + raw: `{"processor":"visa","is_foo":true,"data":{"foo":"foo"}}`, + Processor: Field{raw: `"visa"`, status: valid}, + IsFoo: Field{raw: `true`, status: valid}, + Data: Field{raw: `{"foo":"foo"}`, status: valid}, + Extras: map[string]Field{"extra": {raw: `"yo"`, status: valid}}, + }, + }, + }, + "mastercard to card": { + CardMastercard{ + Processor: "visa", + IsBar: true, + Data: CardMastercardData{ + Bar: 13, + }, + }, + Card{ + Processor: "visa", + IsFoo: false, + IsBar: true, + Data: CardMastercardData{ + Bar: 13, + }, + }, + }, +} + +func TestPort(t *testing.T) { + for name, test := range portTests { + t.Run(name, func(t *testing.T) { + toVal := reflect.New(reflect.TypeOf(test.to)) + + err := Port(test.from, toVal.Interface()) + if err != nil { + t.Fatalf("port of %v failed with error %v", test.from, err) + } + + if !reflect.DeepEqual(toVal.Elem().Interface(), test.to) { + t.Fatalf("expected:\n%+#v\n\nto port to:\n%+#v\n\nbut got:\n%+#v", test.from, test.to, toVal.Elem().Interface()) + } + }) + } +} diff --git a/internal/shared/shared.go b/internal/shared/shared.go index 6b0610ba497..6e8789fd849 100644 --- a/internal/shared/shared.go +++ b/internal/shared/shared.go @@ -3,9 +3,317 @@ package shared import ( + "time" + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" ) +type AuditLog struct { + // A string that uniquely identifies the audit log. + ID string `json:"id"` + Action AuditLogAction `json:"action"` + Actor AuditLogActor `json:"actor"` + // The source of the event. + Interface string `json:"interface"` + // An object which can lend more context to the action being logged. This is a + // flexible value and varies between different actions. + Metadata interface{} `json:"metadata"` + // The new value of the resource that was modified. + NewValue string `json:"newValue"` + // The value of the resource before it was modified. + OldValue string `json:"oldValue"` + Owner AuditLogOwner `json:"owner"` + Resource AuditLogResource `json:"resource"` + // A UTC RFC3339 timestamp that specifies when the action being logged occured. + When time.Time `json:"when" format:"date-time"` + JSON auditLogJSON `json:"-"` +} + +// auditLogJSON contains the JSON metadata for the struct [AuditLog] +type auditLogJSON struct { + ID apijson.Field + Action apijson.Field + Actor apijson.Field + Interface apijson.Field + Metadata apijson.Field + NewValue apijson.Field + OldValue apijson.Field + Owner apijson.Field + Resource apijson.Field + When apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLog) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogJSON) RawJSON() string { + return r.raw +} + +type AuditLogAction struct { + // A boolean that indicates if the action attempted was successful. + Result bool `json:"result"` + // A short string that describes the action that was performed. + Type string `json:"type"` + JSON auditLogActionJSON `json:"-"` +} + +// auditLogActionJSON contains the JSON metadata for the struct [AuditLogAction] +type auditLogActionJSON struct { + Result apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogActionJSON) RawJSON() string { + return r.raw +} + +type AuditLogActor struct { + // The ID of the actor that performed the action. If a user performed the action, + // this will be their User ID. + ID string `json:"id"` + // The email of the user that performed the action. + Email string `json:"email" format:"email"` + // The IP address of the request that performed the action. + IP string `json:"ip"` + // The type of actor, whether a User, Cloudflare Admin, or an Automated System. + Type AuditLogActorType `json:"type"` + JSON auditLogActorJSON `json:"-"` +} + +// auditLogActorJSON contains the JSON metadata for the struct [AuditLogActor] +type auditLogActorJSON struct { + ID apijson.Field + Email apijson.Field + IP apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogActor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogActorJSON) RawJSON() string { + return r.raw +} + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +type AuditLogActorType string + +const ( + AuditLogActorTypeUser AuditLogActorType = "user" + AuditLogActorTypeAdmin AuditLogActorType = "admin" + AuditLogActorTypeCloudflare AuditLogActorType = "Cloudflare" +) + +func (r AuditLogActorType) IsKnown() bool { + switch r { + case AuditLogActorTypeUser, AuditLogActorTypeAdmin, AuditLogActorTypeCloudflare: + return true + } + return false +} + +type AuditLogOwner struct { + // Identifier + ID string `json:"id"` + JSON auditLogOwnerJSON `json:"-"` +} + +// auditLogOwnerJSON contains the JSON metadata for the struct [AuditLogOwner] +type auditLogOwnerJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogOwner) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogOwnerJSON) RawJSON() string { + return r.raw +} + +type AuditLogResource struct { + // An identifier for the resource that was affected by the action. + ID string `json:"id"` + // A short string that describes the resource that was affected by the action. + Type string `json:"type"` + JSON auditLogResourceJSON `json:"-"` +} + +// auditLogResourceJSON contains the JSON metadata for the struct +// [AuditLogResource] +type auditLogResourceJSON struct { + ID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogResource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogResourceJSON) RawJSON() string { + return r.raw +} + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +type CloudflareTunnel struct { + // UUID of the tunnel. + ID string `json:"id"` + // Cloudflare account ID + AccountTag string `json:"account_tag"` + // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. + Connections []CloudflareTunnelConnection `json:"connections"` + // Timestamp of when the tunnel established at least one connection to Cloudflare's + // edge. If `null`, the tunnel is inactive. + ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` + // Timestamp of when the tunnel became inactive (no connections to Cloudflare's + // edge). If `null`, the tunnel is active. + ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // Metadata associated with the tunnel. + Metadata interface{} `json:"metadata"` + // A user-friendly name for the tunnel. + Name string `json:"name"` + // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. + // If `false`, the tunnel must be configured locally on the origin machine. + RemoteConfig bool `json:"remote_config"` + // The status of the tunnel. Valid values are `inactive` (tunnel has never been + // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + // state), `healthy` (tunnel is active and able to serve traffic), or `down` + // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + Status string `json:"status"` + // The type of tunnel. + TunType CloudflareTunnelTunType `json:"tun_type"` + JSON cloudflareTunnelJSON `json:"-"` +} + +// cloudflareTunnelJSON contains the JSON metadata for the struct +// [CloudflareTunnel] +type cloudflareTunnelJSON struct { + ID apijson.Field + AccountTag apijson.Field + Connections apijson.Field + ConnsActiveAt apijson.Field + ConnsInactiveAt apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Metadata apijson.Field + Name apijson.Field + RemoteConfig apijson.Field + Status apijson.Field + TunType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudflareTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudflareTunnelJSON) RawJSON() string { + return r.raw +} + +func (r CloudflareTunnel) ImplementsWARPConnectorWARPConnectorNewResponse() {} + +func (r CloudflareTunnel) ImplementsWARPConnectorWARPConnectorListResponse() {} + +func (r CloudflareTunnel) ImplementsWARPConnectorWARPConnectorDeleteResponse() {} + +func (r CloudflareTunnel) ImplementsWARPConnectorWARPConnectorEditResponse() {} + +func (r CloudflareTunnel) ImplementsWARPConnectorWARPConnectorGetResponse() {} + +func (r CloudflareTunnel) ImplementsZeroTrustTunnelListResponse() {} + +func (r CloudflareTunnel) ImplementsZeroTrustTunnelEditResponse() {} + +type CloudflareTunnelConnection struct { + // UUID of the Cloudflare Tunnel connection. + ID string `json:"id"` + // UUID of the cloudflared instance. + ClientID interface{} `json:"client_id"` + // The cloudflared version used to establish this connection. + ClientVersion string `json:"client_version"` + // The Cloudflare data center used for this connection. + ColoName string `json:"colo_name"` + // Cloudflare continues to track connections for several minutes after they + // disconnect. This is an optimization to improve latency and reliability of + // reconnecting. If `true`, the connection has disconnected but is still being + // tracked. If `false`, the connection is actively serving traffic. + IsPendingReconnect bool `json:"is_pending_reconnect"` + // Timestamp of when the connection was established. + OpenedAt time.Time `json:"opened_at" format:"date-time"` + // The public IP address of the host running cloudflared. + OriginIP string `json:"origin_ip"` + // UUID of the Cloudflare Tunnel connection. + UUID string `json:"uuid"` + JSON cloudflareTunnelConnectionJSON `json:"-"` +} + +// cloudflareTunnelConnectionJSON contains the JSON metadata for the struct +// [CloudflareTunnelConnection] +type cloudflareTunnelConnectionJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientVersion apijson.Field + ColoName apijson.Field + IsPendingReconnect apijson.Field + OpenedAt apijson.Field + OriginIP apijson.Field + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudflareTunnelConnection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudflareTunnelConnectionJSON) RawJSON() string { + return r.raw +} + +// The type of tunnel. +type CloudflareTunnelTunType string + +const ( + CloudflareTunnelTunTypeCfdTunnel CloudflareTunnelTunType = "cfd_tunnel" + CloudflareTunnelTunTypeWARPConnector CloudflareTunnelTunType = "warp_connector" + CloudflareTunnelTunTypeIPSec CloudflareTunnelTunType = "ip_sec" + CloudflareTunnelTunTypeGRE CloudflareTunnelTunType = "gre" + CloudflareTunnelTunTypeCNI CloudflareTunnelTunType = "cni" +) + +func (r CloudflareTunnelTunType) IsKnown() bool { + switch r { + case CloudflareTunnelTunTypeCfdTunnel, CloudflareTunnelTunTypeWARPConnector, CloudflareTunnelTunTypeIPSec, CloudflareTunnelTunTypeGRE, CloudflareTunnelTunTypeCNI: + return true + } + return false +} + type ErrorData struct { Code int64 `json:"code"` Message string `json:"message"` @@ -27,3 +335,272 @@ func (r *ErrorData) UnmarshalJSON(data []byte) (err error) { func (r errorDataJSON) RawJSON() string { return r.raw } + +type Permission = string + +type PermissionGrant struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON permissionGrantJSON `json:"-"` +} + +// permissionGrantJSON contains the JSON metadata for the struct [PermissionGrant] +type permissionGrantJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PermissionGrant) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r permissionGrantJSON) RawJSON() string { + return r.raw +} + +type PermissionGrantParam struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r PermissionGrantParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ResponseInfo struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON responseInfoJSON `json:"-"` +} + +// responseInfoJSON contains the JSON metadata for the struct [ResponseInfo] +type responseInfoJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ResponseInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r responseInfoJSON) RawJSON() string { + return r.raw +} + +type Role struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role Name. + Name string `json:"name,required"` + // Access permissions for this User. + Permissions []Permission `json:"permissions,required"` + JSON roleJSON `json:"-"` +} + +// roleJSON contains the JSON metadata for the struct [Role] +type roleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Role) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleJSON) RawJSON() string { + return r.raw +} + +type User struct { + // Membership identifier tag. + ID string `json:"id,required"` + // Roles assigned to this member. + Roles []UserRole `json:"roles,required"` + Status interface{} `json:"status,required"` + User UserUser `json:"user,required"` + JSON userJSON `json:"-"` +} + +// userJSON contains the JSON metadata for the struct [User] +type userJSON struct { + ID apijson.Field + Roles apijson.Field + Status apijson.Field + User apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *User) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r userJSON) RawJSON() string { + return r.raw +} + +type UserRole struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role name. + Name string `json:"name,required"` + Permissions UserRolesPermissions `json:"permissions,required"` + JSON userRoleJSON `json:"-"` +} + +// userRoleJSON contains the JSON metadata for the struct [UserRole] +type userRoleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UserRole) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r userRoleJSON) RawJSON() string { + return r.raw +} + +type UserRolesPermissions 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 userRolesPermissionsJSON `json:"-"` +} + +// userRolesPermissionsJSON contains the JSON metadata for the struct +// [UserRolesPermissions] +type userRolesPermissionsJSON 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 *UserRolesPermissions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r userRolesPermissionsJSON) RawJSON() string { + return r.raw +} + +type UserUser struct { + // The contact email address of the user. + Email string `json:"email,required"` + // Identifier + ID string `json:"id"` + // User's first name + FirstName string `json:"first_name,nullable"` + // User's last name + LastName string `json:"last_name,nullable"` + // Indicates whether two-factor authentication is enabled for the user account. + // Does not apply to API authentication. + TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` + JSON userUserJSON `json:"-"` +} + +// userUserJSON contains the JSON metadata for the struct [UserUser] +type userUserJSON struct { + Email apijson.Field + ID apijson.Field + FirstName apijson.Field + LastName apijson.Field + TwoFactorAuthenticationEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UserUser) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r userUserJSON) RawJSON() string { + return r.raw +} + +type UserParam struct { + // Roles assigned to this member. + Roles param.Field[[]UserRoleParam] `json:"roles,required"` +} + +func (r UserParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type UserRoleParam struct { + // Role identifier tag. + ID param.Field[string] `json:"id,required"` +} + +func (r UserRoleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type UserRolesPermissionsParam 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 UserRolesPermissionsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type UserUserParam struct { + // The contact email address of the user. + Email param.Field[string] `json:"email,required"` + // User's first name + FirstName param.Field[string] `json:"first_name"` + // User's last name + LastName param.Field[string] `json:"last_name"` +} + +func (r UserUserParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} diff --git a/internal/shared/union.go b/internal/shared/union.go index b61264e442d..3ce4c02ece4 100644 --- a/internal/shared/union.go +++ b/internal/shared/union.go @@ -4,312 +4,200 @@ package shared type UnionString string -func (UnionString) ImplementsAccountsAccountUpdateResponse() {} -func (UnionString) ImplementsAccountsAccountGetResponse() {} -func (UnionString) ImplementsAccountsRoleGetResponse() {} -func (UnionString) ImplementsOriginCACertificatesOriginCACertificateNewResponse() {} -func (UnionString) ImplementsOriginCACertificatesOriginCACertificateGetResponse() {} -func (UnionString) ImplementsMembershipsMembershipUpdateResponse() {} -func (UnionString) ImplementsMembershipsMembershipGetResponse() {} -func (UnionString) ImplementsUserUserEditResponse() {} -func (UnionString) ImplementsUserUserGetResponse() {} -func (UnionString) ImplementsUserAuditLogListResponse() {} -func (UnionString) ImplementsUserBillingProfileGetResponse() {} -func (UnionString) ImplementsUserInviteEditResponse() {} -func (UnionString) ImplementsUserInviteGetResponse() {} -func (UnionString) ImplementsUserLoadBalancerPoolHealthResponse() {} -func (UnionString) ImplementsUserOrganizationGetResponse() {} -func (UnionString) ImplementsUserSubscriptionUpdateResponse() {} -func (UnionString) ImplementsUserSubscriptionEditResponse() {} -func (UnionString) ImplementsUserTokenUpdateResponse() {} -func (UnionString) ImplementsUserTokenGetResponse() {} -func (UnionString) ImplementsZonesCustomNameserverUpdateResponse() {} -func (UnionString) ImplementsZonesCustomNameserverGetResponse() {} -func (UnionString) ImplementsZonesWorkerScriptUpdateResponse() {} -func (UnionString) ImplementsZonesSubscriptionNewResponse() {} -func (UnionString) ImplementsZonesSubscriptionGetResponse() {} -func (UnionString) ImplementsLoadBalancersPoolHealthGetResponse() {} -func (UnionString) ImplementsLoadBalancersRegionListResponse() {} -func (UnionString) ImplementsLoadBalancersRegionGetResponse() {} -func (UnionString) ImplementsCacheCachePurgeParamsCachePurgeFilesFile() {} -func (UnionString) ImplementsCacheSmartTieredCacheDeleteResponse() {} -func (UnionString) ImplementsCacheSmartTieredCacheEditResponse() {} -func (UnionString) ImplementsCacheSmartTieredCacheGetResponse() {} -func (UnionString) ImplementsSSLAnalyzeNewResponse() {} -func (UnionString) ImplementsSSLCertificatePackGetResponse() {} -func (UnionString) ImplementsSubscriptionsSubscriptionNewResponse() {} -func (UnionString) ImplementsSubscriptionsSubscriptionUpdateResponse() {} -func (UnionString) ImplementsSubscriptionsSubscriptionGetResponse() {} -func (UnionString) ImplementsArgoSmartRoutingEditResponse() {} -func (UnionString) ImplementsArgoSmartRoutingGetResponse() {} -func (UnionString) ImplementsArgoTieredCachingEditResponse() {} -func (UnionString) ImplementsArgoTieredCachingGetResponse() {} -func (UnionString) ImplementsCustomCertificatesCustomCertificateNewResponse() {} -func (UnionString) ImplementsCustomCertificatesCustomCertificateEditResponse() {} -func (UnionString) ImplementsCustomCertificatesCustomCertificateGetResponse() {} -func (UnionString) ImplementsCustomHostnamesFallbackOriginUpdateResponse() {} -func (UnionString) ImplementsCustomHostnamesFallbackOriginDeleteResponse() {} -func (UnionString) ImplementsCustomHostnamesFallbackOriginGetResponse() {} -func (UnionString) ImplementsCustomNameserversCustomNameserverDeleteResponse() {} -func (UnionString) ImplementsDNSDNSFirewallDNSFirewallIP() {} -func (UnionString) ImplementsDNSDNSFirewallUpstreamIP() {} -func (UnionString) ImplementsDNSFirewallNewParamsUpstreamIP() {} -func (UnionString) ImplementsDNSFirewallEditParamsDNSFirewallIP() {} -func (UnionString) ImplementsDNSFirewallEditParamsUpstreamIP() {} -func (UnionString) ImplementsDNSSECDNSSECDeleteResponse() {} -func (UnionString) ImplementsFirewallAccessRuleNewResponse() {} -func (UnionString) ImplementsFirewallAccessRuleEditResponse() {} -func (UnionString) ImplementsFirewallAccessRuleGetResponse() {} -func (UnionString) ImplementsFirewallUARuleNewResponse() {} -func (UnionString) ImplementsFirewallUARuleUpdateResponse() {} -func (UnionString) ImplementsFirewallUARuleGetResponse() {} -func (UnionString) ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() {} -func (UnionString) ImplementsFirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult() {} -func (UnionString) ImplementsFirewallWAFPackageGroupEditResponse() {} -func (UnionString) ImplementsFirewallWAFPackageGroupGetResponse() {} -func (UnionString) ImplementsFirewallWAFPackageRuleGetResponse() {} -func (UnionString) ImplementsLogpushJobDeleteResponse() {} -func (UnionString) ImplementsLogsControlCmbConfigDeleteResponse() {} -func (UnionString) ImplementsLogsRayIDGetResponse() {} -func (UnionString) ImplementsLogsReceivedGetResponse() {} -func (UnionString) ImplementsLogsReceivedGetParamsEnd() {} -func (UnionString) ImplementsLogsReceivedGetParamsStart() {} -func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthNewResponse() {} -func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthDeleteResponse() {} -func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthGetResponse() {} -func (UnionString) ImplementsPagerulesPageruleNewResponse() {} -func (UnionString) ImplementsPagerulesPageruleUpdateResponse() {} -func (UnionString) ImplementsPagerulesPageruleEditResponse() {} -func (UnionString) ImplementsPagerulesPageruleGetResponse() {} -func (UnionString) ImplementsRateLimitsRateLimitNewResponse() {} -func (UnionString) ImplementsRateLimitsRateLimitEditResponse() {} -func (UnionString) ImplementsRateLimitsRateLimitGetResponse() {} -func (UnionString) ImplementsWorkersAIRunResponse() {} -func (UnionString) ImplementsWorkersAIRunParamsTextEmbeddingsText() {} -func (UnionString) ImplementsWorkersScriptTailDeleteResponse() {} -func (UnionString) ImplementsWorkersRouteNewResponse() {} -func (UnionString) ImplementsWorkersRouteDeleteResponse() {} -func (UnionString) ImplementsKVNamespaceUpdateResponse() {} -func (UnionString) ImplementsKVNamespaceDeleteResponse() {} -func (UnionString) ImplementsKVNamespaceBulkUpdateResponse() {} -func (UnionString) ImplementsKVNamespaceBulkDeleteResponse() {} -func (UnionString) ImplementsKVNamespaceValueUpdateResponse() {} -func (UnionString) ImplementsKVNamespaceValueDeleteResponse() {} -func (UnionString) ImplementsQueuesQueueDeleteResponse() {} -func (UnionString) ImplementsQueuesConsumerDeleteResponse() {} -func (UnionString) ImplementsSpectrumAnalyticsEventBytimeGetResponse() {} -func (UnionString) ImplementsSpectrumAnalyticsEventSummaryGetResponse() {} -func (UnionString) ImplementsSpectrumAppNewResponseOriginPort() {} -func (UnionString) ImplementsSpectrumAppUpdateResponseOriginPort() {} -func (UnionString) ImplementsSpectrumAppGetResponse() {} -func (UnionString) ImplementsSpectrumAppNewParamsOriginPort() {} -func (UnionString) ImplementsSpectrumAppUpdateParamsOriginPort() {} -func (UnionString) ImplementsAddressingAddressMapDeleteResponse() {} -func (UnionString) ImplementsAddressingAddressMapAccountUpdateResponse() {} -func (UnionString) ImplementsAddressingAddressMapAccountDeleteResponse() {} -func (UnionString) ImplementsAddressingAddressMapIPUpdateResponse() {} -func (UnionString) ImplementsAddressingAddressMapIPDeleteResponse() {} -func (UnionString) ImplementsAddressingAddressMapZoneUpdateResponse() {} -func (UnionString) ImplementsAddressingAddressMapZoneDeleteResponse() {} -func (UnionString) ImplementsAddressingPrefixDeleteResponse() {} -func (UnionString) ImplementsAddressingPrefixBGPBindingDeleteResponse() {} -func (UnionString) ImplementsAuditLogsAuditLogListResponse() {} -func (UnionString) ImplementsBillingProfileGetResponse() {} -func (UnionString) ImplementsImagesImageVariant() {} -func (UnionString) ImplementsImagesV1DeleteResponse() {} -func (UnionString) ImplementsImagesV1VariantDeleteResponse() {} -func (UnionString) ImplementsIntelIntelSchemasIpip() {} -func (UnionString) ImplementsIntelMiscategorizationNewResponse() {} -func (UnionString) ImplementsIntelAttackSurfaceReportIssueDismissResponse() {} -func (UnionString) ImplementsMagicTransitSiteACLNewResponseACLsLan1Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLNewResponseACLsLan2Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLUpdateResponseAcllan1Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLUpdateResponseAcllan2Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLListResponseACLsLan1Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLListResponseACLsLan2Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLDeleteResponseDeletedAcllan1Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLDeleteResponseDeletedAcllan2Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLGetResponseAcllan1Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLGetResponseAcllan2Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLNewParamsAcllan1Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLNewParamsAcllan2Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLUpdateParamsAcllan1Subnet() {} -func (UnionString) ImplementsMagicTransitSiteACLUpdateParamsAcllan2Subnet() {} -func (UnionString) ImplementsPagesProjectNewResponse() {} -func (UnionString) ImplementsPagesProjectEditResponse() {} -func (UnionString) ImplementsPagesProjectDeploymentHistoryLogGetResponse() {} -func (UnionString) ImplementsPagesProjectDomainNewResponse() {} -func (UnionString) ImplementsPagesProjectDomainEditResponse() {} -func (UnionString) ImplementsPagesProjectDomainGetResponse() {} -func (UnionString) ImplementsRegistrarDomainUpdateResponse() {} -func (UnionString) ImplementsRegistrarDomainGetResponse() {} -func (UnionString) ImplementsRulesListItemGetResponse() {} -func (UnionString) ImplementsStreamAudioTrackDeleteResponse() {} -func (UnionString) ImplementsStreamKeyDeleteResponse() {} -func (UnionString) ImplementsStreamWatermarkNewResponse() {} -func (UnionString) ImplementsStreamWatermarkDeleteResponse() {} -func (UnionString) ImplementsStreamWatermarkGetResponse() {} -func (UnionString) ImplementsStreamWebhookUpdateResponse() {} -func (UnionString) ImplementsStreamWebhookDeleteResponse() {} -func (UnionString) ImplementsStreamWebhookGetResponse() {} -func (UnionString) ImplementsStreamCaptionUpdateResponse() {} -func (UnionString) ImplementsStreamCaptionDeleteResponse() {} -func (UnionString) ImplementsStreamDownloadNewResponse() {} -func (UnionString) ImplementsStreamDownloadDeleteResponse() {} -func (UnionString) ImplementsStreamDownloadGetResponse() {} -func (UnionString) ImplementsAlertingAvailableAlertListResponse() {} -func (UnionString) ImplementsAlertingDestinationEligibleGetResponse() {} -func (UnionString) ImplementsAlertingDestinationPagerdutyDeleteResponse() {} -func (UnionString) ImplementsAlertingDestinationWebhookDeleteResponse() {} -func (UnionString) ImplementsAlertingAlertingPoliciesMechanismsID() {} -func (UnionString) ImplementsAlertingPolicyDeleteResponse() {} -func (UnionString) ImplementsAlertingPolicyNewParamsMechanismsID() {} -func (UnionString) ImplementsAlertingPolicyUpdateParamsMechanismsID() {} -func (UnionString) ImplementsD1DatabaseDeleteResponse() {} -func (UnionString) ImplementsWARPConnectorWARPConnectorTokenResponse() {} -func (UnionString) ImplementsZeroTrustDeviceGetResponse() {} -func (UnionString) ImplementsZeroTrustDevicePostureIntegrationDeleteResponse() {} -func (UnionString) ImplementsZeroTrustDeviceRevokeNewResponse() {} -func (UnionString) ImplementsZeroTrustDeviceUnrevokeNewResponse() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsSelfHostedApplicationAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsSaaSApplicationAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsBrowserSSHApplicationAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsBrowserVncApplicationAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsAppLauncherApplicationAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationAppID() { +func (UnionString) ImplementsAccountsAccountUpdateResponseUnion() {} +func (UnionString) ImplementsAccountsAccountGetResponseUnion() {} +func (UnionString) ImplementsAccountsRoleGetResponseUnion() {} +func (UnionString) ImplementsOriginCACertificatesOriginCACertificateNewResponseUnion() {} +func (UnionString) ImplementsOriginCACertificatesOriginCACertificateGetResponseUnion() {} +func (UnionString) ImplementsMembershipsMembershipUpdateResponseUnion() {} +func (UnionString) ImplementsMembershipsMembershipGetResponseUnion() {} +func (UnionString) ImplementsUserUserEditResponseUnion() {} +func (UnionString) ImplementsUserUserGetResponseUnion() {} +func (UnionString) ImplementsUserAuditLogListResponse() {} +func (UnionString) ImplementsUserBillingProfileGetResponseUnion() {} +func (UnionString) ImplementsUserInviteEditResponseUnion() {} +func (UnionString) ImplementsUserInviteGetResponseUnion() {} +func (UnionString) ImplementsUserOrganizationGetResponseUnion() {} +func (UnionString) ImplementsUserSubscriptionUpdateResponseUnion() {} +func (UnionString) ImplementsUserSubscriptionEditResponseUnion() {} +func (UnionString) ImplementsUserTokenUpdateResponseUnion() {} +func (UnionString) ImplementsUserTokenGetResponseUnion() {} +func (UnionString) ImplementsZonesCustomNameserverUpdateResponseUnion() {} +func (UnionString) ImplementsZonesCustomNameserverGetResponseUnion() {} +func (UnionString) ImplementsZonesSubscriptionNewResponseUnion() {} +func (UnionString) ImplementsZonesSubscriptionGetResponseUnion() {} +func (UnionString) ImplementsLoadBalancersPoolHealthGetResponseUnion() {} +func (UnionString) ImplementsLoadBalancersRegionListResponseUnion() {} +func (UnionString) ImplementsLoadBalancersRegionGetResponseUnion() {} +func (UnionString) ImplementsCacheCachePurgeParamsBodyCachePurgeFilesFileUnion() {} +func (UnionString) ImplementsCacheSmartTieredCacheDeleteResponseUnion() {} +func (UnionString) ImplementsCacheSmartTieredCacheEditResponseUnion() {} +func (UnionString) ImplementsCacheSmartTieredCacheGetResponseUnion() {} +func (UnionString) ImplementsSSLAnalyzeNewResponseUnion() {} +func (UnionString) ImplementsSSLCertificatePackGetResponseUnion() {} +func (UnionString) ImplementsSubscriptionsSubscriptionNewResponseUnion() {} +func (UnionString) ImplementsSubscriptionsSubscriptionUpdateResponseUnion() {} +func (UnionString) ImplementsSubscriptionsSubscriptionGetResponseUnion() {} +func (UnionString) ImplementsArgoSmartRoutingEditResponseUnion() {} +func (UnionString) ImplementsArgoSmartRoutingGetResponseUnion() {} +func (UnionString) ImplementsArgoTieredCachingEditResponseUnion() {} +func (UnionString) ImplementsArgoTieredCachingGetResponseUnion() {} +func (UnionString) ImplementsCustomCertificatesCustomCertificateNewResponseUnion() {} +func (UnionString) ImplementsCustomCertificatesCustomCertificateEditResponseUnion() {} +func (UnionString) ImplementsCustomCertificatesCustomCertificateGetResponseUnion() {} +func (UnionString) ImplementsCustomHostnamesFallbackOriginUpdateResponseUnion() {} +func (UnionString) ImplementsCustomHostnamesFallbackOriginDeleteResponseUnion() {} +func (UnionString) ImplementsCustomHostnamesFallbackOriginGetResponseUnion() {} +func (UnionString) ImplementsCustomNameserversCustomNameserverDeleteResponseUnion() {} +func (UnionString) ImplementsDNSFirewallIPsUnionParam() {} +func (UnionString) ImplementsDNSFirewallIPsUnion() {} +func (UnionString) ImplementsDNSUpstreamIPsUnionParam() {} +func (UnionString) ImplementsDNSUpstreamIPsUnion() {} +func (UnionString) ImplementsDNSSECDNSSECDeleteResponseUnion() {} +func (UnionString) ImplementsFirewallAccessRuleNewResponseUnion() {} +func (UnionString) ImplementsFirewallAccessRuleEditResponseUnion() {} +func (UnionString) ImplementsFirewallAccessRuleGetResponseUnion() {} +func (UnionString) ImplementsFirewallUARuleNewResponseUnion() {} +func (UnionString) ImplementsFirewallUARuleUpdateResponseUnion() {} +func (UnionString) ImplementsFirewallUARuleGetResponseUnion() {} +func (UnionString) ImplementsFirewallWAFPackageListResponseFirewallAPIResponseCollectionResultUnion() { } -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationAppID() { +func (UnionString) ImplementsFirewallWAFPackageGetResponseFirewallAPIResponseSingleResultUnion() {} +func (UnionString) ImplementsFirewallWAFPackageGroupEditResponseUnion() {} +func (UnionString) ImplementsFirewallWAFPackageGroupGetResponseUnion() {} +func (UnionString) ImplementsFirewallWAFPackageRuleGetResponseUnion() {} +func (UnionString) ImplementsLogpushJobDeleteResponseUnion() {} +func (UnionString) ImplementsLogsControlCmbConfigDeleteResponseUnion() {} +func (UnionString) ImplementsLogsRayIDGetResponseUnion() {} +func (UnionString) ImplementsLogsReceivedGetResponseUnion() {} +func (UnionString) ImplementsLogsReceivedGetParamsEndUnion() {} +func (UnionString) ImplementsLogsReceivedGetParamsStartUnion() {} +func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthNewResponseUnion() {} +func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthDeleteResponseUnion() {} +func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthGetResponseUnion() {} +func (UnionString) ImplementsPagerulesPageruleNewResponseUnion() {} +func (UnionString) ImplementsPagerulesPageruleUpdateResponseUnion() {} +func (UnionString) ImplementsPagerulesPageruleEditResponseUnion() {} +func (UnionString) ImplementsPagerulesPageruleGetResponseUnion() {} +func (UnionString) ImplementsRateLimitsRateLimitNewResponseUnion() {} +func (UnionString) ImplementsRateLimitsRateLimitEditResponseUnion() {} +func (UnionString) ImplementsRateLimitsRateLimitGetResponseUnion() {} +func (UnionString) ImplementsWorkersAIRunResponseUnion() {} +func (UnionString) ImplementsWorkersAIRunParamsBodyTextEmbeddingsTextUnion() {} +func (UnionString) ImplementsWorkersScriptTailDeleteResponseUnion() {} +func (UnionString) ImplementsKVNamespaceUpdateResponseUnion() {} +func (UnionString) ImplementsKVNamespaceDeleteResponseUnion() {} +func (UnionString) ImplementsKVNamespaceBulkUpdateResponseUnion() {} +func (UnionString) ImplementsKVNamespaceBulkDeleteResponseUnion() {} +func (UnionString) ImplementsKVNamespaceValueUpdateResponseUnion() {} +func (UnionString) ImplementsKVNamespaceValueDeleteResponseUnion() {} +func (UnionString) ImplementsQueuesQueueDeleteResponseUnion() {} +func (UnionString) ImplementsQueuesConsumerDeleteResponseUnion() {} +func (UnionString) ImplementsSpectrumOriginPortUnionParam() {} +func (UnionString) ImplementsSpectrumOriginPortUnion() {} +func (UnionString) ImplementsSpectrumAnalyticsEventBytimeGetResponseUnion() {} +func (UnionString) ImplementsSpectrumAnalyticsEventSummaryGetResponseUnion() {} +func (UnionString) ImplementsSpectrumAppGetResponseUnion() {} +func (UnionString) ImplementsAddressingAddressMapDeleteResponseUnion() {} +func (UnionString) ImplementsAddressingAddressMapAccountUpdateResponseUnion() {} +func (UnionString) ImplementsAddressingAddressMapAccountDeleteResponseUnion() {} +func (UnionString) ImplementsAddressingAddressMapIPUpdateResponseUnion() {} +func (UnionString) ImplementsAddressingAddressMapIPDeleteResponseUnion() {} +func (UnionString) ImplementsAddressingAddressMapZoneUpdateResponseUnion() {} +func (UnionString) ImplementsAddressingAddressMapZoneDeleteResponseUnion() {} +func (UnionString) ImplementsAddressingPrefixDeleteResponseUnion() {} +func (UnionString) ImplementsAddressingPrefixBGPBindingDeleteResponseUnion() {} +func (UnionString) ImplementsAuditLogsAuditLogListResponse() {} +func (UnionString) ImplementsBillingProfileGetResponseUnion() {} +func (UnionString) ImplementsImagesImageVariantsUnion() {} +func (UnionString) ImplementsImagesV1DeleteResponseUnion() {} +func (UnionString) ImplementsImagesV1VariantDeleteResponseUnion() {} +func (UnionString) ImplementsIntelIpipUnion() {} +func (UnionString) ImplementsIntelMiscategorizationNewResponseUnion() {} +func (UnionString) ImplementsIntelAttackSurfaceReportIssueDismissResponseUnion() {} +func (UnionString) ImplementsMagicTransitSubnetUnionParam() {} +func (UnionString) ImplementsMagicTransitSubnetUnion() {} +func (UnionString) ImplementsPagesProjectNewResponseUnion() {} +func (UnionString) ImplementsPagesProjectEditResponseUnion() {} +func (UnionString) ImplementsPagesProjectDeploymentHistoryLogGetResponseUnion() {} +func (UnionString) ImplementsPagesProjectDomainNewResponseUnion() {} +func (UnionString) ImplementsPagesProjectDomainEditResponseUnion() {} +func (UnionString) ImplementsPagesProjectDomainGetResponseUnion() {} +func (UnionString) ImplementsRegistrarDomainUpdateResponseUnion() {} +func (UnionString) ImplementsRegistrarDomainGetResponseUnion() {} +func (UnionString) ImplementsRulesListItemGetResponseUnion() {} +func (UnionString) ImplementsStreamAudioTrackDeleteResponseUnion() {} +func (UnionString) ImplementsStreamKeyDeleteResponseUnion() {} +func (UnionString) ImplementsStreamWatermarkNewResponseUnion() {} +func (UnionString) ImplementsStreamWatermarkDeleteResponseUnion() {} +func (UnionString) ImplementsStreamWatermarkGetResponseUnion() {} +func (UnionString) ImplementsStreamWebhookUpdateResponseUnion() {} +func (UnionString) ImplementsStreamWebhookDeleteResponseUnion() {} +func (UnionString) ImplementsStreamWebhookGetResponseUnion() {} +func (UnionString) ImplementsStreamCaptionUpdateResponseUnion() {} +func (UnionString) ImplementsStreamCaptionDeleteResponseUnion() {} +func (UnionString) ImplementsStreamDownloadNewResponseUnion() {} +func (UnionString) ImplementsStreamDownloadDeleteResponseUnion() {} +func (UnionString) ImplementsStreamDownloadGetResponseUnion() {} +func (UnionString) ImplementsAlertingAvailableAlertListResponseUnion() {} +func (UnionString) ImplementsAlertingDestinationEligibleGetResponseUnion() {} +func (UnionString) ImplementsAlertingDestinationPagerdutyDeleteResponseUnion() {} +func (UnionString) ImplementsAlertingDestinationWebhookDeleteResponseUnion() {} +func (UnionString) ImplementsAlertingMechanismIDUnionParam() {} +func (UnionString) ImplementsAlertingMechanismIDUnion() {} +func (UnionString) ImplementsAlertingPolicyDeleteResponseUnion() {} +func (UnionString) ImplementsD1DatabaseDeleteResponseUnion() {} +func (UnionString) ImplementsWARPConnectorWARPConnectorTokenResponseUnion() {} +func (UnionString) ImplementsZeroTrustDeviceGetResponseUnion() {} +func (UnionString) ImplementsZeroTrustDevicePostureIntegrationDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustDeviceRevokeNewResponseUnion() {} +func (UnionString) ImplementsZeroTrustDeviceUnrevokeNewResponseUnion() {} +func (UnionString) ImplementsZeroTrustAppIDUnionParam() {} +func (UnionString) ImplementsZeroTrustAccessApplicationCANewResponseUnion() {} +func (UnionString) ImplementsZeroTrustAccessApplicationCAGetResponseUnion() {} +func (UnionString) ImplementsZeroTrustAccessKeyUpdateResponseUnion() {} +func (UnionString) ImplementsZeroTrustAccessKeyGetResponseUnion() {} +func (UnionString) ImplementsZeroTrustAccessKeyRotateResponseUnion() {} +func (UnionString) ImplementsZeroTrustTunnelConfigurationUpdateResponseUnion() {} +func (UnionString) ImplementsZeroTrustTunnelConfigurationGetResponseUnion() {} +func (UnionString) ImplementsZeroTrustTunnelConnectionDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustTunnelTokenGetResponseUnion() {} +func (UnionString) ImplementsZeroTrustTunnelManagementNewResponseUnion() {} +func (UnionString) ImplementsZeroTrustDLPProfileCustomDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustGatewayListDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustGatewayLocationDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustGatewayProxyEndpointDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustGatewayRuleDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkNewResponseUnion() {} +func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponseUnion() {} +func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkEditResponseUnion() {} +func (UnionString) ImplementsHyperdriveConfigDeleteResponseUnion() {} +func (UnionString) ImplementsVectorizeIndexDeleteResponseUnion() {} +func (UnionString) ImplementsRadarRankingTimeseriesGroupsResponseSerie0Union() {} +func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionUpdateResponseUnion() { } -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsBookmarkApplicationAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationDeleteParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationGetParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationRevokeTokensParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationCANewResponse() {} -func (UnionString) ImplementsZeroTrustAccessApplicationCAGetResponse() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUserPolicyCheckListParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessKeyUpdateResponse() {} -func (UnionString) ImplementsZeroTrustAccessKeyGetResponse() {} -func (UnionString) ImplementsZeroTrustAccessKeyRotateResponse() {} -func (UnionString) ImplementsZeroTrustTunnelConfigurationUpdateResponse() {} -func (UnionString) ImplementsZeroTrustTunnelConfigurationGetResponse() {} -func (UnionString) ImplementsZeroTrustTunnelConnectionDeleteResponse() {} -func (UnionString) ImplementsZeroTrustTunnelTokenGetResponse() {} -func (UnionString) ImplementsZeroTrustTunnelManagementNewResponse() {} -func (UnionString) ImplementsZeroTrustDLPProfileCustomDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayListDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayLocationDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayProxyEndpointDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayRuleDeleteResponse() {} -func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkNewResponse() {} -func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() {} -func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkEditResponse() {} -func (UnionString) ImplementsHyperdriveConfigDeleteResponse() {} -func (UnionString) ImplementsVectorizeIndexDeleteResponse() {} -func (UnionString) ImplementsRadarRankingTimeseriesGroupsResponseSerie0() {} -func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionUpdateResponse() {} -func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionGetResponse() {} -func (UnionString) ImplementsHostnamesHostnameSttingValue() {} -func (UnionString) ImplementsHostnamesSettingTLSGetResponseValue() {} -func (UnionString) ImplementsHostnamesSettingTLSUpdateParamsValue() {} -func (UnionString) ImplementsSnippetsSnippetDeleteResponse() {} -func (UnionString) ImplementsCloudforceOneRequestDeleteResponse() {} -func (UnionString) ImplementsCloudforceOneRequestMessageDeleteResponse() {} -func (UnionString) ImplementsCloudforceOneRequestPriorityDeleteResponse() {} +func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionGetResponseUnion() { +} +func (UnionString) ImplementsHostnamesSettingValueUnionParam() {} +func (UnionString) ImplementsHostnamesSettingValueUnion() {} +func (UnionString) ImplementsSnippetsSnippetDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestMessageDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() {} type UnionInt int64 -func (UnionInt) ImplementsLogsReceivedGetParamsEnd() {} -func (UnionInt) ImplementsLogsReceivedGetParamsStart() {} -func (UnionInt) ImplementsSpectrumAppNewResponseOriginPort() {} -func (UnionInt) ImplementsSpectrumAppUpdateResponseOriginPort() {} -func (UnionInt) ImplementsSpectrumAppNewParamsOriginPort() {} -func (UnionInt) ImplementsSpectrumAppUpdateParamsOriginPort() {} -func (UnionInt) ImplementsRulesListItemGetResponse() {} +func (UnionInt) ImplementsLogsReceivedGetParamsEndUnion() {} +func (UnionInt) ImplementsLogsReceivedGetParamsStartUnion() {} +func (UnionInt) ImplementsSpectrumOriginPortUnionParam() {} +func (UnionInt) ImplementsSpectrumOriginPortUnion() {} +func (UnionInt) ImplementsRulesListItemGetResponseUnion() {} type UnionFloat float64 -func (UnionFloat) ImplementsDNSDNSRecordAttl() {} -func (UnionFloat) ImplementsDNSDNSRecordAaaattl() {} -func (UnionFloat) ImplementsDNSDNSRecordCaattl() {} -func (UnionFloat) ImplementsDNSDNSRecordCertttl() {} -func (UnionFloat) ImplementsDNSDNSRecordCnamettl() {} -func (UnionFloat) ImplementsDNSDNSRecordDnskeyttl() {} -func (UnionFloat) ImplementsDNSDNSRecordDsttl() {} -func (UnionFloat) ImplementsDNSDNSRecordHttpsttl() {} -func (UnionFloat) ImplementsDNSDNSRecordLocttl() {} -func (UnionFloat) ImplementsDNSDNSRecordMxttl() {} -func (UnionFloat) ImplementsDNSDNSRecordNaptrttl() {} -func (UnionFloat) ImplementsDNSDNSRecordNsttl() {} -func (UnionFloat) ImplementsDNSDNSRecordPtrttl() {} -func (UnionFloat) ImplementsDNSDNSRecordSmimeattl() {} -func (UnionFloat) ImplementsDNSDNSRecordSrvttl() {} -func (UnionFloat) ImplementsDNSDNSRecordSshfpttl() {} -func (UnionFloat) ImplementsDNSDNSRecordSvcbttl() {} -func (UnionFloat) ImplementsDNSDNSRecordTlsattl() {} -func (UnionFloat) ImplementsDNSDNSRecordTxtttl() {} -func (UnionFloat) ImplementsDNSDNSRecordUrittl() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsAAAARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsCAARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsCERTRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsCNAMERecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsDNSKEYRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsDSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsHTTPSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsLOCRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsMXRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsNAPTRRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsNSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsPTRRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsSMIMEARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsSRVRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsSSHFPRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsSVCBRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsTLSARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsTXTRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordNewParamsDNSRecordsURIRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsAAAARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsCAARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsCERTRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsCNAMERecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsDNSKEYRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsDSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsHTTPSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsLOCRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsMXRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsNAPTRRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsNSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsPTRRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsSMIMEARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsSRVRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsSSHFPRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsSVCBRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsTLSARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsTXTRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsDNSRecordsURIRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsAAAARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsCAARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsCERTRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsCNAMERecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsDNSKEYRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsDSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsHTTPSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsLOCRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsMXRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsNAPTRRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsNSRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsPTRRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsSMIMEARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsSRVRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsSSHFPRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsSVCBRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsTLSARecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsTXTRecordTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsDNSRecordsURIRecordTTL() {} -func (UnionFloat) ImplementsEmailRoutingEmailDNSRecordTTL() {} -func (UnionFloat) ImplementsRadarRankingTimeseriesGroupsResponseSerie0() {} -func (UnionFloat) ImplementsHostnamesHostnameSttingValue() {} -func (UnionFloat) ImplementsHostnamesSettingTLSGetResponseValue() {} -func (UnionFloat) ImplementsHostnamesSettingTLSUpdateParamsValue() {} +func (UnionFloat) ImplementsDNSTTLUnionParam() {} +func (UnionFloat) ImplementsDNSTTLUnion() {} +func (UnionFloat) ImplementsEmailRoutingDNSRecordTTLUnion() {} +func (UnionFloat) ImplementsRadarRankingTimeseriesGroupsResponseSerie0Union() {} +func (UnionFloat) ImplementsHostnamesSettingValueUnionParam() {} +func (UnionFloat) ImplementsHostnamesSettingValueUnion() {} diff --git a/internal/version.go b/internal/version.go index 4fb415b2e08..fef66226b8c 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "2.0.0-beta.17" // x-release-please-version +const PackageVersion = "2.0.0" // x-release-please-version diff --git a/ips/aliases.go b/ips/aliases.go index 089b118c8ef..e9a9d6a2f7b 100644 --- a/ips/aliases.go +++ b/ips/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/ips/ip.go b/ips/ip.go index f6cb93a93df..8c7f3331430 100644 --- a/ips/ip.go +++ b/ips/ip.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -110,14 +111,50 @@ func (r JDCloudIPsJSON) RawJSON() string { func (r JDCloudIPs) implementsIPsIPListResponse() {} +type IPListResponse struct { + // A digest of the IP data. Useful for determining if the data has changed. + Etag string `json:"etag"` + IPV4CIDRs interface{} `json:"ipv4_cidrs,required"` + IPV6CIDRs interface{} `json:"ipv6_cidrs,required"` + JDCloudCIDRs interface{} `json:"jdcloud_cidrs,required"` + JSON ipListResponseJSON `json:"-"` + union IPListResponseUnion +} + +// ipListResponseJSON contains the JSON metadata for the struct [IPListResponse] +type ipListResponseJSON struct { + Etag apijson.Field + IPV4CIDRs apijson.Field + IPV6CIDRs apijson.Field + JDCloudCIDRs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r ipListResponseJSON) RawJSON() string { + return r.raw +} + +func (r *IPListResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r IPListResponse) AsUnion() IPListResponseUnion { + return r.union +} + // Union satisfied by [ips.IPs] or [ips.JDCloudIPs]. -type IPListResponse interface { +type IPListResponseUnion interface { implementsIPsIPListResponse() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*IPListResponse)(nil)).Elem(), + reflect.TypeOf((*IPListResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -138,15 +175,15 @@ type IPListParams struct { // URLQuery serializes [IPListParams]'s query parameters as `url.Values`. func (r IPListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type IPListResponseEnvelope struct { - Errors []IPListResponseEnvelopeErrors `json:"errors,required"` - Messages []IPListResponseEnvelopeMessages `json:"messages,required"` - Result IPListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IPListResponse `json:"result,required"` // Whether the API call was successful Success IPListResponseEnvelopeSuccess `json:"success,required"` JSON ipListResponseEnvelopeJSON `json:"-"` @@ -171,52 +208,6 @@ func (r ipListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipListResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IPListResponseEnvelopeErrors] -type ipListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipListResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IPListResponseEnvelopeMessages] -type ipListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPListResponseEnvelopeSuccess bool diff --git a/keyless_certificates/aliases.go b/keyless_certificates/aliases.go index 0834fb511c2..51b7a5f7426 100644 --- a/keyless_certificates/aliases.go +++ b/keyless_certificates/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/keyless_certificates/keylesscertificate.go b/keyless_certificates/keylesscertificate.go index 96b98138c7b..903d0dc2425 100644 --- a/keyless_certificates/keylesscertificate.go +++ b/keyless_certificates/keylesscertificate.go @@ -8,10 +8,12 @@ import ( "net/http" "time" + "github.com/cloudflare/cloudflare-go/v2/custom_hostnames" "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" ) @@ -34,7 +36,7 @@ func NewKeylessCertificateService(opts ...option.RequestOption) (r *KeylessCerti } // Create Keyless SSL Configuration -func (r *KeylessCertificateService) New(ctx context.Context, params KeylessCertificateNewParams, opts ...option.RequestOption) (res *KeylessCertificateHostname, err error) { +func (r *KeylessCertificateService) New(ctx context.Context, params KeylessCertificateNewParams, opts ...option.RequestOption) (res *KeylessCertificate, err error) { opts = append(r.Options[:], opts...) var env KeylessCertificateNewResponseEnvelope path := fmt.Sprintf("zones/%s/keyless_certificates", params.ZoneID) @@ -47,7 +49,7 @@ func (r *KeylessCertificateService) New(ctx context.Context, params KeylessCerti } // List all Keyless SSL configurations for a given zone. -func (r *KeylessCertificateService) List(ctx context.Context, query KeylessCertificateListParams, opts ...option.RequestOption) (res *pagination.SinglePage[KeylessCertificateHostname], err error) { +func (r *KeylessCertificateService) List(ctx context.Context, query KeylessCertificateListParams, opts ...option.RequestOption) (res *pagination.SinglePage[KeylessCertificate], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -65,15 +67,15 @@ func (r *KeylessCertificateService) List(ctx context.Context, query KeylessCerti } // List all Keyless SSL configurations for a given zone. -func (r *KeylessCertificateService) ListAutoPaging(ctx context.Context, query KeylessCertificateListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[KeylessCertificateHostname] { +func (r *KeylessCertificateService) ListAutoPaging(ctx context.Context, query KeylessCertificateListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[KeylessCertificate] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete Keyless SSL Configuration -func (r *KeylessCertificateService) Delete(ctx context.Context, keylessCertificateID string, body KeylessCertificateDeleteParams, opts ...option.RequestOption) (res *KeylessCertificateDeleteResponse, err error) { +func (r *KeylessCertificateService) Delete(ctx context.Context, keylessCertificateID string, params KeylessCertificateDeleteParams, opts ...option.RequestOption) (res *KeylessCertificateDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env KeylessCertificateDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/keyless_certificates/%s", body.ZoneID, keylessCertificateID) + path := fmt.Sprintf("zones/%s/keyless_certificates/%s", params.ZoneID, keylessCertificateID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -84,7 +86,7 @@ func (r *KeylessCertificateService) Delete(ctx context.Context, keylessCertifica // This will update attributes of a Keyless SSL. Consists of one or more of the // following: host,name,port. -func (r *KeylessCertificateService) Edit(ctx context.Context, keylessCertificateID string, params KeylessCertificateEditParams, opts ...option.RequestOption) (res *KeylessCertificateHostname, err error) { +func (r *KeylessCertificateService) Edit(ctx context.Context, keylessCertificateID string, params KeylessCertificateEditParams, opts ...option.RequestOption) (res *KeylessCertificate, err error) { opts = append(r.Options[:], opts...) var env KeylessCertificateEditResponseEnvelope path := fmt.Sprintf("zones/%s/keyless_certificates/%s", params.ZoneID, keylessCertificateID) @@ -97,7 +99,7 @@ func (r *KeylessCertificateService) Edit(ctx context.Context, keylessCertificate } // Get details for one Keyless SSL configuration. -func (r *KeylessCertificateService) Get(ctx context.Context, keylessCertificateID string, query KeylessCertificateGetParams, opts ...option.RequestOption) (res *KeylessCertificateHostname, err error) { +func (r *KeylessCertificateService) Get(ctx context.Context, keylessCertificateID string, query KeylessCertificateGetParams, opts ...option.RequestOption) (res *KeylessCertificate, err error) { opts = append(r.Options[:], opts...) var env KeylessCertificateGetResponseEnvelope path := fmt.Sprintf("zones/%s/keyless_certificates/%s", query.ZoneID, keylessCertificateID) @@ -109,7 +111,7 @@ func (r *KeylessCertificateService) Get(ctx context.Context, keylessCertificateI return } -type KeylessCertificateHostname struct { +type KeylessCertificate struct { // Keyless certificate identifier tag. ID string `json:"id,required"` // When the Keyless SSL was created. @@ -129,15 +131,15 @@ type KeylessCertificateHostname struct { // Keyless SSL server. Port float64 `json:"port,required"` // Status of the Keyless SSL. - Status KeylessCertificateHostnameStatus `json:"status,required"` + Status KeylessCertificateStatus `json:"status,required"` // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel KeylessCertificateHostnameTunnel `json:"tunnel"` - JSON keylessCertificateHostnameJSON `json:"-"` + Tunnel Tunnel `json:"tunnel"` + JSON keylessCertificateJSON `json:"-"` } -// keylessCertificateHostnameJSON contains the JSON metadata for the struct -// [KeylessCertificateHostname] -type keylessCertificateHostnameJSON struct { +// keylessCertificateJSON contains the JSON metadata for the struct +// [KeylessCertificate] +type keylessCertificateJSON struct { ID apijson.Field CreatedOn apijson.Field Enabled apijson.Field @@ -152,56 +154,67 @@ type keylessCertificateHostnameJSON struct { ExtraFields map[string]apijson.Field } -func (r *KeylessCertificateHostname) UnmarshalJSON(data []byte) (err error) { +func (r *KeylessCertificate) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r keylessCertificateHostnameJSON) RawJSON() string { +func (r keylessCertificateJSON) RawJSON() string { return r.raw } // Status of the Keyless SSL. -type KeylessCertificateHostnameStatus string +type KeylessCertificateStatus string const ( - KeylessCertificateHostnameStatusActive KeylessCertificateHostnameStatus = "active" - KeylessCertificateHostnameStatusDeleted KeylessCertificateHostnameStatus = "deleted" + KeylessCertificateStatusActive KeylessCertificateStatus = "active" + KeylessCertificateStatusDeleted KeylessCertificateStatus = "deleted" ) -func (r KeylessCertificateHostnameStatus) IsKnown() bool { +func (r KeylessCertificateStatus) IsKnown() bool { switch r { - case KeylessCertificateHostnameStatusActive, KeylessCertificateHostnameStatusDeleted: + case KeylessCertificateStatusActive, KeylessCertificateStatusDeleted: return true } return false } // Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateHostnameTunnel struct { +type Tunnel struct { // Private IP of the Key Server Host PrivateIP string `json:"private_ip,required"` // Cloudflare Tunnel Virtual Network ID - VnetID string `json:"vnet_id,required"` - JSON keylessCertificateHostnameTunnelJSON `json:"-"` + VnetID string `json:"vnet_id,required"` + JSON tunnelJSON `json:"-"` } -// keylessCertificateHostnameTunnelJSON contains the JSON metadata for the struct -// [KeylessCertificateHostnameTunnel] -type keylessCertificateHostnameTunnelJSON struct { +// tunnelJSON contains the JSON metadata for the struct [Tunnel] +type tunnelJSON struct { PrivateIP apijson.Field VnetID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *KeylessCertificateHostnameTunnel) UnmarshalJSON(data []byte) (err error) { +func (r *Tunnel) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r keylessCertificateHostnameTunnelJSON) RawJSON() string { +func (r tunnelJSON) RawJSON() string { return r.raw } +// Configuration for using Keyless SSL through a Cloudflare Tunnel +type TunnelParam struct { + // Private IP of the Key Server Host + PrivateIP param.Field[string] `json:"private_ip,required"` + // Cloudflare Tunnel Virtual Network ID + VnetID param.Field[string] `json:"vnet_id,required"` +} + +func (r TunnelParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type KeylessCertificateDeleteResponse struct { // Identifier ID string `json:"id"` @@ -238,53 +251,21 @@ type KeylessCertificateNewParams struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod param.Field[KeylessCertificateNewParamsBundleMethod] `json:"bundle_method"` + BundleMethod param.Field[custom_hostnames.BundleMethod] `json:"bundle_method"` // The keyless SSL name. Name param.Field[string] `json:"name"` // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel param.Field[KeylessCertificateNewParamsTunnel] `json:"tunnel"` + Tunnel param.Field[TunnelParam] `json:"tunnel"` } func (r KeylessCertificateNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type KeylessCertificateNewParamsBundleMethod string - -const ( - KeylessCertificateNewParamsBundleMethodUbiquitous KeylessCertificateNewParamsBundleMethod = "ubiquitous" - KeylessCertificateNewParamsBundleMethodOptimal KeylessCertificateNewParamsBundleMethod = "optimal" - KeylessCertificateNewParamsBundleMethodForce KeylessCertificateNewParamsBundleMethod = "force" -) - -func (r KeylessCertificateNewParamsBundleMethod) IsKnown() bool { - switch r { - case KeylessCertificateNewParamsBundleMethodUbiquitous, KeylessCertificateNewParamsBundleMethodOptimal, KeylessCertificateNewParamsBundleMethodForce: - return true - } - return false -} - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateNewParamsTunnel struct { - // Private IP of the Key Server Host - PrivateIP param.Field[string] `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID param.Field[string] `json:"vnet_id,required"` -} - -func (r KeylessCertificateNewParamsTunnel) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type KeylessCertificateNewResponseEnvelope struct { - Errors []KeylessCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateHostname `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result KeylessCertificate `json:"result,required"` // Whether the API call was successful Success KeylessCertificateNewResponseEnvelopeSuccess `json:"success,required"` JSON keylessCertificateNewResponseEnvelopeJSON `json:"-"` @@ -309,52 +290,6 @@ func (r keylessCertificateNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type KeylessCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KeylessCertificateNewResponseEnvelopeErrors] -type keylessCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [KeylessCertificateNewResponseEnvelopeMessages] -type keylessCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type KeylessCertificateNewResponseEnvelopeSuccess bool @@ -378,12 +313,17 @@ type KeylessCertificateListParams struct { type KeylessCertificateDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r KeylessCertificateDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type KeylessCertificateDeleteResponseEnvelope struct { - Errors []KeylessCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result KeylessCertificateDeleteResponse `json:"result,required"` // Whether the API call was successful Success KeylessCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON keylessCertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -408,52 +348,6 @@ func (r keylessCertificateDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type KeylessCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [KeylessCertificateDeleteResponseEnvelopeErrors] -type keylessCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KeylessCertificateDeleteResponseEnvelopeMessages] -type keylessCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type KeylessCertificateDeleteResponseEnvelopeSuccess bool @@ -482,29 +376,17 @@ type KeylessCertificateEditParams struct { // Keyless SSL server. Port param.Field[float64] `json:"port"` // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel param.Field[KeylessCertificateEditParamsTunnel] `json:"tunnel"` + Tunnel param.Field[TunnelParam] `json:"tunnel"` } func (r KeylessCertificateEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateEditParamsTunnel struct { - // Private IP of the Key Server Host - PrivateIP param.Field[string] `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID param.Field[string] `json:"vnet_id,required"` -} - -func (r KeylessCertificateEditParamsTunnel) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type KeylessCertificateEditResponseEnvelope struct { - Errors []KeylessCertificateEditResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateEditResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateHostname `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result KeylessCertificate `json:"result,required"` // Whether the API call was successful Success KeylessCertificateEditResponseEnvelopeSuccess `json:"success,required"` JSON keylessCertificateEditResponseEnvelopeJSON `json:"-"` @@ -529,52 +411,6 @@ func (r keylessCertificateEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type KeylessCertificateEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KeylessCertificateEditResponseEnvelopeErrors] -type keylessCertificateEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KeylessCertificateEditResponseEnvelopeMessages] -type keylessCertificateEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type KeylessCertificateEditResponseEnvelopeSuccess bool @@ -596,9 +432,9 @@ type KeylessCertificateGetParams struct { } type KeylessCertificateGetResponseEnvelope struct { - Errors []KeylessCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateHostname `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result KeylessCertificate `json:"result,required"` // Whether the API call was successful Success KeylessCertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON keylessCertificateGetResponseEnvelopeJSON `json:"-"` @@ -623,52 +459,6 @@ func (r keylessCertificateGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type KeylessCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KeylessCertificateGetResponseEnvelopeErrors] -type keylessCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [KeylessCertificateGetResponseEnvelopeMessages] -type keylessCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type KeylessCertificateGetResponseEnvelopeSuccess bool diff --git a/keyless_certificates/keylesscertificate_test.go b/keyless_certificates/keylesscertificate_test.go index 15ac5fd0597..bef4462bd5f 100644 --- a/keyless_certificates/keylesscertificate_test.go +++ b/keyless_certificates/keylesscertificate_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go/v2" + "github.com/cloudflare/cloudflare-go/v2/custom_hostnames" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" "github.com/cloudflare/cloudflare-go/v2/keyless_certificates" "github.com/cloudflare/cloudflare-go/v2/option" @@ -33,9 +34,9 @@ func TestKeylessCertificateNewWithOptionalParams(t *testing.T) { Certificate: cloudflare.F("-----BEGIN CERTIFICATE----- MIIDtTCCAp2gAwIBAgIJAM15n7fdxhRtMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV BAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQwHhcNMTQwMzExMTkyMTU5WhcNMTQwNDEwMTkyMTU5WjBF MQswCQYDVQQGEwJVUzETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB CgKCAQEAvq3sKsHpeduJHimOK+fvQdKsI8z8A05MZyyLp2/R/GE8FjNv+hkVY1WQ LIyTNNQH7CJecE1nbTfo8Y56S7x/rhxC6/DJ8MIulapFPnorq46KU6yRxiM0MQ3N nTJHlHA2ozZta6YBBfVfhHWl1F0IfNbXCLKvGwWWMbCx43OfW6KTkbRnE6gFWKuO fSO5h2u5TaWVuSIzBvYs7Vza6m+gtYAvKAJV2nSZ+eSEFPDo29corOy8+huEOUL8 5FAw4BFPsr1TlrlGPFitduQUHGrSL7skk1ESGza0to3bOtrodKei2s9bk5MXm7lZ qI+WZJX4Zu9+mzZhc9pCVi8r/qlXuQIDAQABo4GnMIGkMB0GA1UdDgQWBBRvavf+ sWM4IwKiH9X9w1vl6nUVRDB1BgNVHSMEbjBsgBRvavf+sWM4IwKiH9X9w1vl6nUV RKFJpEcwRTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV BAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAM15n7fdxhRtMAwGA1UdEwQF MAMBAf8wDQYJKoZIhvcNAQEFBQADggEBABY2ZzBaW0dMsAAT7tPJzrVWVzQx6KU4 UEBLudIlWPlkAwTnINCWR/8eNjCCmGA4heUdHmazdpPa8RzwOmc0NT1NQqzSyktt vTqb4iHD7+8f9MqJ9/FssCfTtqr/Qst/hGH4Wmdf1EJ/6FqYAAb5iRlPgshFZxU8 uXtA8hWn6fK6eISD9HBdcAFToUvKNZ1BIDPvh9f95Ine8ar6yGd56TUNrHR8eHBs ESxz5ddVR/oWRysNJ+aGAyYqHS8S/ttmC7r4XCAHqXptkHPCGRqkAhsterYhd4I8 /cBzejUobNCjjHFbtkAL/SjxZOLW+pNkZwfeYdM8iPkD54Uua1v2tdw= -----END CERTIFICATE-----"), Host: cloudflare.F("example.com"), Port: cloudflare.F(24008.000000), - BundleMethod: cloudflare.F(keyless_certificates.KeylessCertificateNewParamsBundleMethodUbiquitous), + BundleMethod: cloudflare.F(custom_hostnames.BundleMethodUbiquitous), Name: cloudflare.F("example.com Keyless SSL"), - Tunnel: cloudflare.F(keyless_certificates.KeylessCertificateNewParamsTunnel{ + Tunnel: cloudflare.F(keyless_certificates.TunnelParam{ PrivateIP: cloudflare.F("10.0.0.1"), VnetID: cloudflare.F("7365377a-85a4-4390-9480-531ef7dc7a3c"), }), @@ -94,6 +95,7 @@ func TestKeylessCertificateDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", keyless_certificates.KeylessCertificateDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -128,7 +130,7 @@ func TestKeylessCertificateEditWithOptionalParams(t *testing.T) { Host: cloudflare.F("example.com"), Name: cloudflare.F("example.com Keyless SSL"), Port: cloudflare.F(24008.000000), - Tunnel: cloudflare.F(keyless_certificates.KeylessCertificateEditParamsTunnel{ + Tunnel: cloudflare.F(keyless_certificates.TunnelParam{ PrivateIP: cloudflare.F("10.0.0.1"), VnetID: cloudflare.F("7365377a-85a4-4390-9480-531ef7dc7a3c"), }), diff --git a/kv/aliases.go b/kv/aliases.go index 05c573f379e..a3d531463a0 100644 --- a/kv/aliases.go +++ b/kv/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/kv/namespace.go b/kv/namespace.go index 65db08ac666..c91a623e4b9 100644 --- a/kv/namespace.go +++ b/kv/namespace.go @@ -47,7 +47,7 @@ func NewNamespaceService(opts ...option.RequestOption) (r *NamespaceService) { // Creates a namespace under the given title. A `400` is returned if the account // already owns a namespace with this title. A namespace must be explicitly deleted // to be replaced. -func (r *NamespaceService) New(ctx context.Context, params NamespaceNewParams, opts ...option.RequestOption) (res *WorkersKVNamespace, err error) { +func (r *NamespaceService) New(ctx context.Context, params NamespaceNewParams, opts ...option.RequestOption) (res *Namespace, err error) { opts = append(r.Options[:], opts...) var env NamespaceNewResponseEnvelope path := fmt.Sprintf("accounts/%s/storage/kv/namespaces", params.AccountID) @@ -60,7 +60,7 @@ func (r *NamespaceService) New(ctx context.Context, params NamespaceNewParams, o } // Modifies a namespace's title. -func (r *NamespaceService) Update(ctx context.Context, namespaceID string, params NamespaceUpdateParams, opts ...option.RequestOption) (res *NamespaceUpdateResponse, err error) { +func (r *NamespaceService) Update(ctx context.Context, namespaceID string, params NamespaceUpdateParams, opts ...option.RequestOption) (res *NamespaceUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NamespaceUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s", params.AccountID, namespaceID) @@ -73,7 +73,7 @@ func (r *NamespaceService) Update(ctx context.Context, namespaceID string, param } // Returns the namespaces owned by an account. -func (r *NamespaceService) List(ctx context.Context, params NamespaceListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[WorkersKVNamespace], err error) { +func (r *NamespaceService) List(ctx context.Context, params NamespaceListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Namespace], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -91,15 +91,15 @@ func (r *NamespaceService) List(ctx context.Context, params NamespaceListParams, } // Returns the namespaces owned by an account. -func (r *NamespaceService) ListAutoPaging(ctx context.Context, params NamespaceListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WorkersKVNamespace] { +func (r *NamespaceService) ListAutoPaging(ctx context.Context, params NamespaceListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Namespace] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } // Deletes the namespace corresponding to the given ID. -func (r *NamespaceService) Delete(ctx context.Context, namespaceID string, body NamespaceDeleteParams, opts ...option.RequestOption) (res *NamespaceDeleteResponse, err error) { +func (r *NamespaceService) Delete(ctx context.Context, namespaceID string, params NamespaceDeleteParams, opts ...option.RequestOption) (res *NamespaceDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NamespaceDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s", body.AccountID, namespaceID) + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s", params.AccountID, namespaceID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -108,20 +108,19 @@ func (r *NamespaceService) Delete(ctx context.Context, namespaceID string, body return } -type WorkersKVNamespace struct { +type Namespace struct { // Namespace identifier tag. ID string `json:"id,required"` // A human-readable string name for a Namespace. Title string `json:"title,required"` // True if keys written on the URL will be URL-decoded before storing. For example, // if set to "true", a key written on the URL as "%3F" will be stored as "?". - SupportsURLEncoding bool `json:"supports_url_encoding"` - JSON workersKVNamespaceJSON `json:"-"` + SupportsURLEncoding bool `json:"supports_url_encoding"` + JSON namespaceJSON `json:"-"` } -// workersKVNamespaceJSON contains the JSON metadata for the struct -// [WorkersKVNamespace] -type workersKVNamespaceJSON struct { +// namespaceJSON contains the JSON metadata for the struct [Namespace] +type namespaceJSON struct { ID apijson.Field Title apijson.Field SupportsURLEncoding apijson.Field @@ -129,22 +128,22 @@ type workersKVNamespaceJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersKVNamespace) UnmarshalJSON(data []byte) (err error) { +func (r *Namespace) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVNamespaceJSON) RawJSON() string { +func (r namespaceJSON) RawJSON() string { return r.raw } // Union satisfied by [kv.NamespaceUpdateResponseUnknown] or [shared.UnionString]. -type NamespaceUpdateResponse interface { - ImplementsKVNamespaceUpdateResponse() +type NamespaceUpdateResponseUnion interface { + ImplementsKVNamespaceUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NamespaceUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*NamespaceUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -154,13 +153,13 @@ func init() { } // Union satisfied by [kv.NamespaceDeleteResponseUnknown] or [shared.UnionString]. -type NamespaceDeleteResponse interface { - ImplementsKVNamespaceDeleteResponse() +type NamespaceDeleteResponseUnion interface { + ImplementsKVNamespaceDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NamespaceDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*NamespaceDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -181,9 +180,9 @@ func (r NamespaceNewParams) MarshalJSON() (data []byte, err error) { } type NamespaceNewResponseEnvelope struct { - Errors []NamespaceNewResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceNewResponseEnvelopeMessages `json:"messages,required"` - Result WorkersKVNamespace `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Namespace `json:"result,required"` // Whether the API call was successful Success NamespaceNewResponseEnvelopeSuccess `json:"success,required"` JSON namespaceNewResponseEnvelopeJSON `json:"-"` @@ -208,52 +207,6 @@ func (r namespaceNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [NamespaceNewResponseEnvelopeErrors] -type namespaceNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [NamespaceNewResponseEnvelopeMessages] -type namespaceNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceNewResponseEnvelopeSuccess bool @@ -281,9 +234,9 @@ func (r NamespaceUpdateParams) MarshalJSON() (data []byte, err error) { } type NamespaceUpdateResponseEnvelope struct { - Errors []NamespaceUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceUpdateResponseEnvelopeMessages `json:"messages,required"` - Result NamespaceUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NamespaceUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success NamespaceUpdateResponseEnvelopeSuccess `json:"success,required"` JSON namespaceUpdateResponseEnvelopeJSON `json:"-"` @@ -308,52 +261,6 @@ func (r namespaceUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NamespaceUpdateResponseEnvelopeErrors] -type namespaceUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [NamespaceUpdateResponseEnvelopeMessages] -type namespaceUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceUpdateResponseEnvelopeSuccess bool @@ -385,7 +292,7 @@ type NamespaceListParams struct { // URLQuery serializes [NamespaceListParams]'s query parameters as `url.Values`. func (r NamespaceListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -425,12 +332,17 @@ func (r NamespaceListParamsOrder) IsKnown() bool { type NamespaceDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r NamespaceDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type NamespaceDeleteResponseEnvelope struct { - Errors []NamespaceDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceDeleteResponseEnvelopeMessages `json:"messages,required"` - Result NamespaceDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NamespaceDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success NamespaceDeleteResponseEnvelopeSuccess `json:"success,required"` JSON namespaceDeleteResponseEnvelopeJSON `json:"-"` @@ -455,52 +367,6 @@ func (r namespaceDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NamespaceDeleteResponseEnvelopeErrors] -type namespaceDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [NamespaceDeleteResponseEnvelopeMessages] -type namespaceDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceDeleteResponseEnvelopeSuccess bool diff --git a/kv/namespace_test.go b/kv/namespace_test.go index 635b9e316c2..3d4bbb4e88f 100644 --- a/kv/namespace_test.go +++ b/kv/namespace_test.go @@ -121,6 +121,7 @@ func TestNamespaceDelete(t *testing.T) { "0f2ac74b498b48028cb68387c421e279", kv.NamespaceDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/kv/namespacebulk.go b/kv/namespacebulk.go index ddb22fa11c2..6d492909e2a 100644 --- a/kv/namespacebulk.go +++ b/kv/namespacebulk.go @@ -40,7 +40,7 @@ func NewNamespaceBulkService(opts ...option.RequestOption) (r *NamespaceBulkServ // `expiration_ttl` is specified, the key-value pair will never expire. If both are // set, `expiration_ttl` is used and `expiration` is ignored. The entire request // size must be 100 megabytes or less. -func (r *NamespaceBulkService) Update(ctx context.Context, namespaceID string, params NamespaceBulkUpdateParams, opts ...option.RequestOption) (res *NamespaceBulkUpdateResponse, err error) { +func (r *NamespaceBulkService) Update(ctx context.Context, namespaceID string, params NamespaceBulkUpdateParams, opts ...option.RequestOption) (res *NamespaceBulkUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NamespaceBulkUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/bulk", params.AccountID, namespaceID) @@ -54,7 +54,7 @@ func (r *NamespaceBulkService) Update(ctx context.Context, namespaceID string, p // Remove multiple KV pairs from the namespace. Body should be an array of up to // 10,000 keys to be removed. -func (r *NamespaceBulkService) Delete(ctx context.Context, namespaceID string, params NamespaceBulkDeleteParams, opts ...option.RequestOption) (res *NamespaceBulkDeleteResponse, err error) { +func (r *NamespaceBulkService) Delete(ctx context.Context, namespaceID string, params NamespaceBulkDeleteParams, opts ...option.RequestOption) (res *NamespaceBulkDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NamespaceBulkDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/bulk", params.AccountID, namespaceID) @@ -68,13 +68,13 @@ func (r *NamespaceBulkService) Delete(ctx context.Context, namespaceID string, p // Union satisfied by [kv.NamespaceBulkUpdateResponseUnknown] or // [shared.UnionString]. -type NamespaceBulkUpdateResponse interface { - ImplementsKVNamespaceBulkUpdateResponse() +type NamespaceBulkUpdateResponseUnion interface { + ImplementsKVNamespaceBulkUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NamespaceBulkUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*NamespaceBulkUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -85,13 +85,13 @@ func init() { // Union satisfied by [kv.NamespaceBulkDeleteResponseUnknown] or // [shared.UnionString]. -type NamespaceBulkDeleteResponse interface { - ImplementsKVNamespaceBulkDeleteResponse() +type NamespaceBulkDeleteResponseUnion interface { + ImplementsKVNamespaceBulkDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NamespaceBulkDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*NamespaceBulkDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -102,8 +102,8 @@ func init() { type NamespaceBulkUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]NamespaceBulkUpdateParamsBody] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body []NamespaceBulkUpdateParamsBody `json:"body,required"` } func (r NamespaceBulkUpdateParams) MarshalJSON() (data []byte, err error) { @@ -135,9 +135,9 @@ func (r NamespaceBulkUpdateParamsBody) MarshalJSON() (data []byte, err error) { } type NamespaceBulkUpdateResponseEnvelope struct { - Errors []NamespaceBulkUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceBulkUpdateResponseEnvelopeMessages `json:"messages,required"` - Result NamespaceBulkUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NamespaceBulkUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success NamespaceBulkUpdateResponseEnvelopeSuccess `json:"success,required"` JSON namespaceBulkUpdateResponseEnvelopeJSON `json:"-"` @@ -162,52 +162,6 @@ func (r namespaceBulkUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceBulkUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceBulkUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceBulkUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NamespaceBulkUpdateResponseEnvelopeErrors] -type namespaceBulkUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceBulkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceBulkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceBulkUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceBulkUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceBulkUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [NamespaceBulkUpdateResponseEnvelopeMessages] -type namespaceBulkUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceBulkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceBulkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceBulkUpdateResponseEnvelopeSuccess bool @@ -225,8 +179,8 @@ func (r NamespaceBulkUpdateResponseEnvelopeSuccess) IsKnown() bool { type NamespaceBulkDeleteParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]string] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body []string `json:"body,required"` } func (r NamespaceBulkDeleteParams) MarshalJSON() (data []byte, err error) { @@ -234,9 +188,9 @@ func (r NamespaceBulkDeleteParams) MarshalJSON() (data []byte, err error) { } type NamespaceBulkDeleteResponseEnvelope struct { - Errors []NamespaceBulkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceBulkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result NamespaceBulkDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NamespaceBulkDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success NamespaceBulkDeleteResponseEnvelopeSuccess `json:"success,required"` JSON namespaceBulkDeleteResponseEnvelopeJSON `json:"-"` @@ -261,52 +215,6 @@ func (r namespaceBulkDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceBulkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceBulkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceBulkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NamespaceBulkDeleteResponseEnvelopeErrors] -type namespaceBulkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceBulkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceBulkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceBulkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceBulkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceBulkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [NamespaceBulkDeleteResponseEnvelopeMessages] -type namespaceBulkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceBulkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceBulkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceBulkDeleteResponseEnvelopeSuccess bool diff --git a/kv/namespacebulk_test.go b/kv/namespacebulk_test.go index dafa63c7c3d..b8ab731e9f1 100644 --- a/kv/namespacebulk_test.go +++ b/kv/namespacebulk_test.go @@ -33,7 +33,7 @@ func TestNamespaceBulkUpdate(t *testing.T) { "0f2ac74b498b48028cb68387c421e279", kv.NamespaceBulkUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]kv.NamespaceBulkUpdateParamsBody{{ + Body: []kv.NamespaceBulkUpdateParamsBody{{ Base64: cloudflare.F(true), Expiration: cloudflare.F(1578435000.000000), ExpirationTTL: cloudflare.F(300.000000), @@ -60,7 +60,7 @@ func TestNamespaceBulkUpdate(t *testing.T) { "someMetadataKey": "someMetadataValue", }), Value: cloudflare.F("Some string"), - }}), + }}, }, ) if err != nil { @@ -91,7 +91,7 @@ func TestNamespaceBulkDelete(t *testing.T) { "0f2ac74b498b48028cb68387c421e279", kv.NamespaceBulkDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]string{"My-Key", "My-Key", "My-Key"}), + Body: []string{"My-Key", "My-Key", "My-Key"}, }, ) if err != nil { diff --git a/kv/namespacekey.go b/kv/namespacekey.go index ba6e6a56790..a5f794ebbe6 100644 --- a/kv/namespacekey.go +++ b/kv/namespacekey.go @@ -35,7 +35,7 @@ func NewNamespaceKeyService(opts ...option.RequestOption) (r *NamespaceKeyServic } // Lists a namespace's keys. -func (r *NamespaceKeyService) List(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) (res *pagination.CursorLimitPagination[WorkersKVKey], err error) { +func (r *NamespaceKeyService) List(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) (res *pagination.CursorLimitPagination[Key], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -53,13 +53,13 @@ func (r *NamespaceKeyService) List(ctx context.Context, namespaceID string, para } // Lists a namespace's keys. -func (r *NamespaceKeyService) ListAutoPaging(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) *pagination.CursorLimitPaginationAutoPager[WorkersKVKey] { +func (r *NamespaceKeyService) ListAutoPaging(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) *pagination.CursorLimitPaginationAutoPager[Key] { return pagination.NewCursorLimitPaginationAutoPager(r.List(ctx, namespaceID, params, opts...)) } // A name for a value. A value stored under a given key may be retrieved via the // same key. -type WorkersKVKey struct { +type Key struct { // A key's name. The name may be at most 512 bytes. All printable, non-whitespace // characters are valid. Use percent-encoding to define key names as part of a URL. Name string `json:"name,required"` @@ -67,12 +67,12 @@ type WorkersKVKey struct { // will expire. This property is omitted for keys that will not expire. Expiration float64 `json:"expiration"` // Arbitrary JSON that is associated with a key. - Metadata interface{} `json:"metadata"` - JSON workersKVKeyJSON `json:"-"` + Metadata interface{} `json:"metadata"` + JSON keyJSON `json:"-"` } -// workersKVKeyJSON contains the JSON metadata for the struct [WorkersKVKey] -type workersKVKeyJSON struct { +// keyJSON contains the JSON metadata for the struct [Key] +type keyJSON struct { Name apijson.Field Expiration apijson.Field Metadata apijson.Field @@ -80,11 +80,11 @@ type workersKVKeyJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersKVKey) UnmarshalJSON(data []byte) (err error) { +func (r *Key) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVKeyJSON) RawJSON() string { +func (r keyJSON) RawJSON() string { return r.raw } @@ -107,7 +107,7 @@ type NamespaceKeyListParams struct { // URLQuery serializes [NamespaceKeyListParams]'s query parameters as `url.Values`. func (r NamespaceKeyListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/kv/namespacemetadata.go b/kv/namespacemetadata.go index 4fdcc87cbe2..fc4e631f59f 100644 --- a/kv/namespacemetadata.go +++ b/kv/namespacemetadata.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -54,8 +55,8 @@ type NamespaceMetadataGetParams struct { } type NamespaceMetadataGetResponseEnvelope struct { - Errors []NamespaceMetadataGetResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceMetadataGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Arbitrary JSON that is associated with a key. Result NamespaceMetadataGetResponse `json:"result,required"` // Whether the API call was successful @@ -82,52 +83,6 @@ func (r namespaceMetadataGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceMetadataGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceMetadataGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceMetadataGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [NamespaceMetadataGetResponseEnvelopeErrors] -type namespaceMetadataGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceMetadataGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceMetadataGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceMetadataGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceMetadataGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceMetadataGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [NamespaceMetadataGetResponseEnvelopeMessages] -type namespaceMetadataGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceMetadataGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceMetadataGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceMetadataGetResponseEnvelopeSuccess bool diff --git a/kv/namespacevalue.go b/kv/namespacevalue.go index dbd53c07c47..c5b061402af 100644 --- a/kv/namespacevalue.go +++ b/kv/namespacevalue.go @@ -40,7 +40,7 @@ func NewNamespaceValueService(opts ...option.RequestOption) (r *NamespaceValueSe // Existing values, expirations, and metadata will be overwritten. If neither // `expiration` nor `expiration_ttl` is specified, the key-value pair will never // expire. If both are set, `expiration_ttl` is used and `expiration` is ignored. -func (r *NamespaceValueService) Update(ctx context.Context, namespaceID string, keyName string, params NamespaceValueUpdateParams, opts ...option.RequestOption) (res *NamespaceValueUpdateResponse, err error) { +func (r *NamespaceValueService) Update(ctx context.Context, namespaceID string, keyName string, params NamespaceValueUpdateParams, opts ...option.RequestOption) (res *NamespaceValueUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NamespaceValueUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", params.AccountID, namespaceID, keyName) @@ -54,10 +54,10 @@ func (r *NamespaceValueService) Update(ctx context.Context, namespaceID string, // Remove a KV pair from the namespace. Use URL-encoding to use special characters // (for example, `:`, `!`, `%`) in the key name. -func (r *NamespaceValueService) Delete(ctx context.Context, namespaceID string, keyName string, body NamespaceValueDeleteParams, opts ...option.RequestOption) (res *NamespaceValueDeleteResponse, err error) { +func (r *NamespaceValueService) Delete(ctx context.Context, namespaceID string, keyName string, params NamespaceValueDeleteParams, opts ...option.RequestOption) (res *NamespaceValueDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NamespaceValueDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", body.AccountID, namespaceID, keyName) + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", params.AccountID, namespaceID, keyName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -80,13 +80,13 @@ func (r *NamespaceValueService) Get(ctx context.Context, namespaceID string, key // Union satisfied by [kv.NamespaceValueUpdateResponseUnknown] or // [shared.UnionString]. -type NamespaceValueUpdateResponse interface { - ImplementsKVNamespaceValueUpdateResponse() +type NamespaceValueUpdateResponseUnion interface { + ImplementsKVNamespaceValueUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NamespaceValueUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*NamespaceValueUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -97,13 +97,13 @@ func init() { // Union satisfied by [kv.NamespaceValueDeleteResponseUnknown] or // [shared.UnionString]. -type NamespaceValueDeleteResponse interface { - ImplementsKVNamespaceValueDeleteResponse() +type NamespaceValueDeleteResponseUnion interface { + ImplementsKVNamespaceValueDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NamespaceValueDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*NamespaceValueDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -126,9 +126,9 @@ func (r NamespaceValueUpdateParams) MarshalJSON() (data []byte, err error) { } type NamespaceValueUpdateResponseEnvelope struct { - Errors []NamespaceValueUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceValueUpdateResponseEnvelopeMessages `json:"messages,required"` - Result NamespaceValueUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NamespaceValueUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success NamespaceValueUpdateResponseEnvelopeSuccess `json:"success,required"` JSON namespaceValueUpdateResponseEnvelopeJSON `json:"-"` @@ -153,52 +153,6 @@ func (r namespaceValueUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceValueUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceValueUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceValueUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [NamespaceValueUpdateResponseEnvelopeErrors] -type namespaceValueUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceValueUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceValueUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceValueUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceValueUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceValueUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [NamespaceValueUpdateResponseEnvelopeMessages] -type namespaceValueUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceValueUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceValueUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceValueUpdateResponseEnvelopeSuccess bool @@ -217,12 +171,17 @@ func (r NamespaceValueUpdateResponseEnvelopeSuccess) IsKnown() bool { type NamespaceValueDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r NamespaceValueDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type NamespaceValueDeleteResponseEnvelope struct { - Errors []NamespaceValueDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []NamespaceValueDeleteResponseEnvelopeMessages `json:"messages,required"` - Result NamespaceValueDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NamespaceValueDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success NamespaceValueDeleteResponseEnvelopeSuccess `json:"success,required"` JSON namespaceValueDeleteResponseEnvelopeJSON `json:"-"` @@ -247,52 +206,6 @@ func (r namespaceValueDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NamespaceValueDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceValueDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// namespaceValueDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [NamespaceValueDeleteResponseEnvelopeErrors] -type namespaceValueDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceValueDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceValueDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NamespaceValueDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON namespaceValueDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// namespaceValueDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [NamespaceValueDeleteResponseEnvelopeMessages] -type namespaceValueDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceValueDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceValueDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NamespaceValueDeleteResponseEnvelopeSuccess bool diff --git a/kv/namespacevalue_test.go b/kv/namespacevalue_test.go index 6cc0ab66977..175a684b6fd 100644 --- a/kv/namespacevalue_test.go +++ b/kv/namespacevalue_test.go @@ -67,6 +67,7 @@ func TestNamespaceValueDelete(t *testing.T) { "My-Key", kv.NamespaceValueDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/load_balancers/aliases.go b/load_balancers/aliases.go index 025c10c597d..ed4503bf1f9 100644 --- a/load_balancers/aliases.go +++ b/load_balancers/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/load_balancers/loadbalancer.go b/load_balancers/loadbalancer.go index 26d59298c7c..1447f7662cd 100644 --- a/load_balancers/loadbalancer.go +++ b/load_balancers/loadbalancer.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -93,10 +94,10 @@ func (r *LoadBalancerService) ListAutoPaging(ctx context.Context, query LoadBala } // Delete a configured load balancer. -func (r *LoadBalancerService) Delete(ctx context.Context, loadBalancerID string, body LoadBalancerDeleteParams, opts ...option.RequestOption) (res *LoadBalancerDeleteResponse, err error) { +func (r *LoadBalancerService) Delete(ctx context.Context, loadBalancerID string, params LoadBalancerDeleteParams, opts ...option.RequestOption) (res *LoadBalancerDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env LoadBalancerDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/load_balancers/%s", body.ZoneID, loadBalancerID) + path := fmt.Sprintf("zones/%s/load_balancers/%s", params.ZoneID, loadBalancerID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -131,6 +132,175 @@ func (r *LoadBalancerService) Get(ctx context.Context, loadBalancerID string, qu return } +// 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 +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type AdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools bool `json:"failover_across_pools"` + JSON adaptiveRoutingJSON `json:"-"` +} + +// adaptiveRoutingJSON contains the JSON metadata for the struct [AdaptiveRouting] +type adaptiveRoutingJSON struct { + FailoverAcrossPools apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AdaptiveRouting) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r adaptiveRoutingJSON) RawJSON() string { + return r.raw +} + +// 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 +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type AdaptiveRoutingParam struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` +} + +func (r AdaptiveRoutingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type CheckRegion string + +const ( + CheckRegionWnam CheckRegion = "WNAM" + CheckRegionEnam CheckRegion = "ENAM" + CheckRegionWeu CheckRegion = "WEU" + CheckRegionEeu CheckRegion = "EEU" + CheckRegionNsam CheckRegion = "NSAM" + CheckRegionSsam CheckRegion = "SSAM" + CheckRegionOc CheckRegion = "OC" + CheckRegionMe CheckRegion = "ME" + CheckRegionNaf CheckRegion = "NAF" + CheckRegionSaf CheckRegion = "SAF" + CheckRegionSas CheckRegion = "SAS" + CheckRegionSeas CheckRegion = "SEAS" + CheckRegionNeas CheckRegion = "NEAS" + CheckRegionAllRegions CheckRegion = "ALL_REGIONS" +) + +func (r CheckRegion) IsKnown() bool { + switch r { + case CheckRegionWnam, CheckRegionEnam, CheckRegionWeu, CheckRegionEeu, CheckRegionNsam, CheckRegionSsam, CheckRegionOc, CheckRegionMe, CheckRegionNaf, CheckRegionSaf, CheckRegionSas, CheckRegionSeas, CheckRegionNeas, CheckRegionAllRegions: + return true + } + return false +} + +type DefaultPools = string + +type DefaultPoolsParam = string + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type FilterOptions struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable bool `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy bool `json:"healthy,nullable"` + JSON filterOptionsJSON `json:"-"` +} + +// filterOptionsJSON contains the JSON metadata for the struct [FilterOptions] +type filterOptionsJSON struct { + Disable apijson.Field + Healthy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterOptionsJSON) RawJSON() string { + return r.raw +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type FilterOptionsParam struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r FilterOptionsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type Header struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host []Host `json:"Host"` + JSON headerJSON `json:"-"` +} + +// headerJSON contains the JSON metadata for the struct [Header] +type headerJSON struct { + Host apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Header) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r headerJSON) RawJSON() string { + return r.raw +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type HeaderParam struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]HostParam] `json:"Host"` +} + +func (r HeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Host = string + +type HostParam = string + type LoadBalancer struct { ID string `json:"id"` // Controls features that modify the routing of requests to pools and origins in @@ -139,7 +309,7 @@ type LoadBalancer struct { // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 // response codes. If there is another healthy origin in the same pool, the request // is retried once against this alternate origin. - AdaptiveRouting LoadBalancerAdaptiveRouting `json:"adaptive_routing"` + AdaptiveRouting AdaptiveRouting `json:"adaptive_routing"` // A mapping of country codes to a list of pool IDs (ordered by their failover // priority) for the given country. Any country not explicitly defined will fall // back to using the corresponding region_pool mapping if it exists else to @@ -148,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 []string `json:"default_pools"` + DefaultPools []DefaultPools `json:"default_pools"` // Object description. Description string `json:"description"` // Whether to enable (the default) this load balancer. @@ -157,8 +327,8 @@ type LoadBalancer struct { FallbackPool interface{} `json:"fallback_pool"` // Controls location-based steering for non-proxied requests. See `steering_policy` // to learn how steering is affected. - LocationStrategy LoadBalancerLocationStrategy `json:"location_strategy"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` + LocationStrategy LocationStrategy `json:"location_strategy"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` // The DNS hostname to associate with your Load Balancer. If this hostname already // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take // precedence and the DNS record will not be used. @@ -178,14 +348,14 @@ type LoadBalancer struct { // pool's outstanding requests. // - `steering_policy="least_connections"`: Use pool weights to scale each pool's // open connections. - RandomSteering LoadBalancerRandomSteering `json:"random_steering"` + RandomSteering RandomSteering `json:"random_steering"` // A mapping of region codes to a list of pool IDs (ordered by their failover // priority) for the given region. Any regions not explicitly defined will fall // back to using default_pools. RegionPools interface{} `json:"region_pools"` // BETA Field Not General Access: A list of rules for this load balancer to // execute. - Rules []LoadBalancerRule `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: // @@ -211,7 +381,7 @@ type LoadBalancer struct { // configuration. SessionAffinity LoadBalancerSessionAffinity `json:"session_affinity"` // Configures attributes for session affinity. - SessionAffinityAttributes LoadBalancerSessionAffinityAttributes `json:"session_affinity_attributes"` + SessionAffinityAttributes SessionAffinityAttributes `json:"session_affinity_attributes"` // Time, in seconds, until a client's session expires after being created. Once the // expiry time has been reached, subsequent requests may get sent to a different // origin server. The accepted ranges per `session_affinity` policy are: @@ -287,49 +457,194 @@ func (r loadBalancerJSON) RawJSON() string { return r.raw } -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools bool `json:"failover_across_pools"` - JSON loadBalancerAdaptiveRoutingJSON `json:"-"` +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerSessionAffinity string + +const ( + LoadBalancerSessionAffinityNone LoadBalancerSessionAffinity = "none" + LoadBalancerSessionAffinityCookie LoadBalancerSessionAffinity = "cookie" + LoadBalancerSessionAffinityIPCookie LoadBalancerSessionAffinity = "ip_cookie" + LoadBalancerSessionAffinityHeader LoadBalancerSessionAffinity = "header" + LoadBalancerSessionAffinityEmpty LoadBalancerSessionAffinity = "\"\"" +) + +func (r LoadBalancerSessionAffinity) IsKnown() bool { + switch r { + case LoadBalancerSessionAffinityNone, LoadBalancerSessionAffinityCookie, LoadBalancerSessionAffinityIPCookie, LoadBalancerSessionAffinityHeader, LoadBalancerSessionAffinityEmpty: + return true + } + return false } -// loadBalancerAdaptiveRoutingJSON contains the JSON metadata for the struct -// [LoadBalancerAdaptiveRouting] -type loadBalancerAdaptiveRoutingJSON struct { - FailoverAcrossPools apijson.Field - raw string - ExtraFields map[string]apijson.Field +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// 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 LoadBalancerSteeringPolicy string + +const ( + LoadBalancerSteeringPolicyOff LoadBalancerSteeringPolicy = "off" + LoadBalancerSteeringPolicyGeo LoadBalancerSteeringPolicy = "geo" + LoadBalancerSteeringPolicyRandom LoadBalancerSteeringPolicy = "random" + LoadBalancerSteeringPolicyDynamicLatency LoadBalancerSteeringPolicy = "dynamic_latency" + LoadBalancerSteeringPolicyProximity LoadBalancerSteeringPolicy = "proximity" + LoadBalancerSteeringPolicyLeastOutstandingRequests LoadBalancerSteeringPolicy = "least_outstanding_requests" + LoadBalancerSteeringPolicyLeastConnections LoadBalancerSteeringPolicy = "least_connections" + LoadBalancerSteeringPolicyEmpty LoadBalancerSteeringPolicy = "\"\"" +) + +func (r LoadBalancerSteeringPolicy) IsKnown() bool { + switch r { + case LoadBalancerSteeringPolicyOff, LoadBalancerSteeringPolicyGeo, LoadBalancerSteeringPolicyRandom, LoadBalancerSteeringPolicyDynamicLatency, LoadBalancerSteeringPolicyProximity, LoadBalancerSteeringPolicyLeastOutstandingRequests, LoadBalancerSteeringPolicyLeastConnections, LoadBalancerSteeringPolicyEmpty: + return true + } + return false } -func (r *LoadBalancerAdaptiveRouting) UnmarshalJSON(data []byte) (err error) { +// Configures load shedding policies and percentages for the pool. +type LoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent float64 `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy LoadSheddingDefaultPolicy `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent float64 `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy LoadSheddingSessionPolicy `json:"session_policy"` + JSON loadSheddingJSON `json:"-"` +} + +// loadSheddingJSON contains the JSON metadata for the struct [LoadShedding] +type loadSheddingJSON struct { + DefaultPercent apijson.Field + DefaultPolicy apijson.Field + SessionPercent apijson.Field + SessionPolicy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadShedding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerAdaptiveRoutingJSON) RawJSON() string { +func (r loadSheddingJSON) RawJSON() string { return r.raw } +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type LoadSheddingDefaultPolicy string + +const ( + LoadSheddingDefaultPolicyRandom LoadSheddingDefaultPolicy = "random" + LoadSheddingDefaultPolicyHash LoadSheddingDefaultPolicy = "hash" +) + +func (r LoadSheddingDefaultPolicy) IsKnown() bool { + switch r { + case LoadSheddingDefaultPolicyRandom, LoadSheddingDefaultPolicyHash: + return true + } + return false +} + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type LoadSheddingSessionPolicy string + +const ( + LoadSheddingSessionPolicyHash LoadSheddingSessionPolicy = "hash" +) + +func (r LoadSheddingSessionPolicy) IsKnown() bool { + switch r { + case LoadSheddingSessionPolicyHash: + return true + } + return false +} + +// Configures load shedding policies and percentages for the pool. +type LoadSheddingParam struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[LoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[LoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r LoadSheddingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Controls location-based steering for non-proxied requests. See `steering_policy` // to learn how steering is affected. -type LoadBalancerLocationStrategy struct { +type LocationStrategy struct { // Determines the authoritative location when ECS is not preferred, does not exist // in the request, or its GeoIP lookup is unsuccessful. // // - `"pop"`: Use the Cloudflare PoP location. // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is // unsuccessful, use the Cloudflare PoP location. - Mode LoadBalancerLocationStrategyMode `json:"mode"` + Mode LocationStrategyMode `json:"mode"` // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the // authoritative location. // @@ -337,24 +652,24 @@ type LoadBalancerLocationStrategy struct { // - `"never"`: Never prefer ECS. // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs LoadBalancerLocationStrategyPreferEcs `json:"prefer_ecs"` - JSON loadBalancerLocationStrategyJSON `json:"-"` + PreferEcs LocationStrategyPreferEcs `json:"prefer_ecs"` + JSON locationStrategyJSON `json:"-"` } -// loadBalancerLocationStrategyJSON contains the JSON metadata for the struct -// [LoadBalancerLocationStrategy] -type loadBalancerLocationStrategyJSON struct { +// locationStrategyJSON contains the JSON metadata for the struct +// [LocationStrategy] +type locationStrategyJSON struct { Mode apijson.Field PreferEcs apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *LoadBalancerLocationStrategy) UnmarshalJSON(data []byte) (err error) { +func (r *LocationStrategy) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerLocationStrategyJSON) RawJSON() string { +func (r locationStrategyJSON) RawJSON() string { return r.raw } @@ -364,16 +679,16 @@ func (r loadBalancerLocationStrategyJSON) RawJSON() string { // - `"pop"`: Use the Cloudflare PoP location. // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is // unsuccessful, use the Cloudflare PoP location. -type LoadBalancerLocationStrategyMode string +type LocationStrategyMode string const ( - LoadBalancerLocationStrategyModePop LoadBalancerLocationStrategyMode = "pop" - LoadBalancerLocationStrategyModeResolverIP LoadBalancerLocationStrategyMode = "resolver_ip" + LocationStrategyModePop LocationStrategyMode = "pop" + LocationStrategyModeResolverIP LocationStrategyMode = "resolver_ip" ) -func (r LoadBalancerLocationStrategyMode) IsKnown() bool { +func (r LocationStrategyMode) IsKnown() bool { switch r { - case LoadBalancerLocationStrategyModePop, LoadBalancerLocationStrategyModeResolverIP: + case LocationStrategyModePop, LocationStrategyModeResolverIP: return true } return false @@ -386,78 +701,341 @@ func (r LoadBalancerLocationStrategyMode) IsKnown() bool { // - `"never"`: Never prefer ECS. // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerLocationStrategyPreferEcs string +type LocationStrategyPreferEcs string const ( - LoadBalancerLocationStrategyPreferEcsAlways LoadBalancerLocationStrategyPreferEcs = "always" - LoadBalancerLocationStrategyPreferEcsNever LoadBalancerLocationStrategyPreferEcs = "never" - LoadBalancerLocationStrategyPreferEcsProximity LoadBalancerLocationStrategyPreferEcs = "proximity" - LoadBalancerLocationStrategyPreferEcsGeo LoadBalancerLocationStrategyPreferEcs = "geo" + LocationStrategyPreferEcsAlways LocationStrategyPreferEcs = "always" + LocationStrategyPreferEcsNever LocationStrategyPreferEcs = "never" + LocationStrategyPreferEcsProximity LocationStrategyPreferEcs = "proximity" + LocationStrategyPreferEcsGeo LocationStrategyPreferEcs = "geo" ) -func (r LoadBalancerLocationStrategyPreferEcs) IsKnown() bool { +func (r LocationStrategyPreferEcs) IsKnown() bool { switch r { - case LoadBalancerLocationStrategyPreferEcsAlways, LoadBalancerLocationStrategyPreferEcsNever, LoadBalancerLocationStrategyPreferEcsProximity, LoadBalancerLocationStrategyPreferEcsGeo: + case LocationStrategyPreferEcsAlways, LocationStrategyPreferEcsNever, LocationStrategyPreferEcsProximity, LocationStrategyPreferEcsGeo: return true } return false } -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight float64 `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights interface{} `json:"pool_weights"` - JSON loadBalancerRandomSteeringJSON `json:"-"` +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LocationStrategyParam struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode param.Field[LocationStrategyMode] `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs param.Field[LocationStrategyPreferEcs] `json:"prefer_ecs"` } -// loadBalancerRandomSteeringJSON contains the JSON metadata for the struct -// [LoadBalancerRandomSteering] -type loadBalancerRandomSteeringJSON struct { - DefaultWeight apijson.Field - PoolWeights apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r LocationStrategyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type NotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin FilterOptions `json:"origin,nullable"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool FilterOptions `json:"pool,nullable"` + JSON notificationFilterJSON `json:"-"` +} + +// notificationFilterJSON contains the JSON metadata for the struct +// [NotificationFilter] +type notificationFilterJSON struct { + Origin apijson.Field + Pool apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *LoadBalancerRandomSteering) UnmarshalJSON(data []byte) (err error) { +func (r *NotificationFilter) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerRandomSteeringJSON) RawJSON() string { +func (r notificationFilterJSON) RawJSON() string { return r.raw } -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerRule 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 - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition string `json:"condition"` +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type NotificationFilterParam struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[FilterOptionsParam] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[FilterOptionsParam] `json:"pool"` +} + +func (r NotificationFilterParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Origin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address string `json:"address"` + // This field shows up only if the origin is disabled. This field is set with the + // time the origin was disabled. + DisabledAt time.Time `json:"disabled_at" format:"date-time"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled bool `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header Header `json:"header"` + // A human-identifiable name for the origin. + Name string `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID string `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight float64 `json:"weight"` + JSON originJSON `json:"-"` +} + +// originJSON contains the JSON metadata for the struct [Origin] +type originJSON struct { + Address apijson.Field + DisabledAt apijson.Field + Enabled apijson.Field + Header apijson.Field + Name apijson.Field + VirtualNetworkID apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Origin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r originJSON) RawJSON() string { + return r.raw +} + +type OriginParam struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[HeaderParam] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r OriginParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type OriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy OriginSteeringPolicy `json:"policy"` + JSON originSteeringJSON `json:"-"` +} + +// originSteeringJSON contains the JSON metadata for the struct [OriginSteering] +type originSteeringJSON struct { + Policy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OriginSteering) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r originSteeringJSON) RawJSON() string { + return r.raw +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type OriginSteeringPolicy string + +const ( + OriginSteeringPolicyRandom OriginSteeringPolicy = "random" + OriginSteeringPolicyHash OriginSteeringPolicy = "hash" + OriginSteeringPolicyLeastOutstandingRequests OriginSteeringPolicy = "least_outstanding_requests" + OriginSteeringPolicyLeastConnections OriginSteeringPolicy = "least_connections" +) + +func (r OriginSteeringPolicy) IsKnown() bool { + switch r { + case OriginSteeringPolicyRandom, OriginSteeringPolicyHash, OriginSteeringPolicyLeastOutstandingRequests, OriginSteeringPolicyLeastConnections: + return true + } + return false +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type OriginSteeringParam struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[OriginSteeringPolicy] `json:"policy"` +} + +func (r OriginSteeringParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type RandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight float64 `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights interface{} `json:"pool_weights"` + JSON randomSteeringJSON `json:"-"` +} + +// randomSteeringJSON contains the JSON metadata for the struct [RandomSteering] +type randomSteeringJSON struct { + DefaultWeight apijson.Field + PoolWeights apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RandomSteering) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r randomSteeringJSON) RawJSON() string { + return r.raw +} + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type RandomSteeringParam struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight param.Field[float64] `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights param.Field[interface{}] `json:"pool_weights"` +} + +func (r RandomSteeringParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A rule object containing conditions and overrides for this load balancer to +// evaluate. +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 + // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. + Condition string `json:"condition"` // Disable this specific rule. It will no longer be evaluated by this load // balancer. Disabled bool `json:"disabled"` // 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 LoadBalancerRulesFixedResponse `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 LoadBalancerRulesOverrides `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 @@ -465,13 +1043,12 @@ type LoadBalancerRule 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 loadBalancerRuleJSON `json:"-"` + Terminates bool `json:"terminates"` + JSON rulesJSON `json:"-"` } -// loadBalancerRuleJSON contains the JSON metadata for the struct -// [LoadBalancerRule] -type loadBalancerRuleJSON struct { +// rulesJSON contains the JSON metadata for the struct [Rules] +type rulesJSON struct { Condition apijson.Field Disabled apijson.Field FixedResponse apijson.Field @@ -483,18 +1060,18 @@ type loadBalancerRuleJSON struct { ExtraFields map[string]apijson.Field } -func (r *LoadBalancerRule) UnmarshalJSON(data []byte) (err error) { +func (r *Rules) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerRuleJSON) 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 LoadBalancerRulesFixedResponse 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. @@ -502,13 +1079,13 @@ type LoadBalancerRulesFixedResponse 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 loadBalancerRulesFixedResponseJSON `json:"-"` + StatusCode int64 `json:"status_code"` + JSON rulesFixedResponseJSON `json:"-"` } -// loadBalancerRulesFixedResponseJSON contains the JSON metadata for the struct -// [LoadBalancerRulesFixedResponse] -type loadBalancerRulesFixedResponseJSON struct { +// rulesFixedResponseJSON contains the JSON metadata for the struct +// [RulesFixedResponse] +type rulesFixedResponseJSON struct { ContentType apijson.Field Location apijson.Field MessageBody apijson.Field @@ -517,24 +1094,24 @@ type loadBalancerRulesFixedResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *LoadBalancerRulesFixedResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RulesFixedResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerRulesFixedResponseJSON) 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 LoadBalancerRulesOverrides 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 // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 // response codes. If there is another healthy origin in the same pool, the request // is retried once against this alternate origin. - AdaptiveRouting LoadBalancerRulesOverridesAdaptiveRouting `json:"adaptive_routing"` + AdaptiveRouting AdaptiveRouting `json:"adaptive_routing"` // A mapping of country codes to a list of pool IDs (ordered by their failover // priority) for the given country. Any country not explicitly defined will fall // back to using the corresponding region_pool mapping if it exists else to @@ -542,12 +1119,12 @@ type LoadBalancerRulesOverrides 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 []string `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` // to learn how steering is affected. - LocationStrategy LoadBalancerRulesOverridesLocationStrategy `json:"location_strategy"` + LocationStrategy LocationStrategy `json:"location_strategy"` // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not // explicitly defined will fall back to using the corresponding country_pool, then @@ -561,7 +1138,7 @@ type LoadBalancerRulesOverrides struct { // pool's outstanding requests. // - `steering_policy="least_connections"`: Use pool weights to scale each pool's // open connections. - RandomSteering LoadBalancerRulesOverridesRandomSteering `json:"random_steering"` + RandomSteering RandomSteering `json:"random_steering"` // A mapping of region codes to a list of pool IDs (ordered by their failover // priority) for the given region. Any regions not explicitly defined will fall // back to using default_pools. @@ -589,9 +1166,9 @@ type LoadBalancerRulesOverrides struct { // server is unhealthy, then a new origin server is calculated and used. See // `headers` in `session_affinity_attributes` for additional required // configuration. - SessionAffinity LoadBalancerRulesOverridesSessionAffinity `json:"session_affinity"` + SessionAffinity RulesOverridesSessionAffinity `json:"session_affinity"` // Configures attributes for session affinity. - SessionAffinityAttributes LoadBalancerRulesOverridesSessionAffinityAttributes `json:"session_affinity_attributes"` + SessionAffinityAttributes SessionAffinityAttributes `json:"session_affinity_attributes"` // Time, in seconds, until a client's session expires after being created. Once the // expiry time has been reached, subsequent requests may get sent to a different // origin server. The accepted ranges per `session_affinity` policy are: @@ -625,16 +1202,15 @@ type LoadBalancerRulesOverrides 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 LoadBalancerRulesOverridesSteeringPolicy `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 loadBalancerRulesOverridesJSON `json:"-"` + TTL float64 `json:"ttl"` + JSON rulesOverridesJSON `json:"-"` } -// loadBalancerRulesOverridesJSON contains the JSON metadata for the struct -// [LoadBalancerRulesOverrides] -type loadBalancerRulesOverridesJSON struct { +// rulesOverridesJSON contains the JSON metadata for the struct [RulesOverrides] +type rulesOverridesJSON struct { AdaptiveRouting apijson.Field CountryPools apijson.Field DefaultPools apijson.Field @@ -652,162 +1228,11 @@ type loadBalancerRulesOverridesJSON struct { ExtraFields map[string]apijson.Field } -func (r *LoadBalancerRulesOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesJSON) RawJSON() string { - return r.raw -} - -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools bool `json:"failover_across_pools"` - JSON loadBalancerRulesOverridesAdaptiveRoutingJSON `json:"-"` -} - -// loadBalancerRulesOverridesAdaptiveRoutingJSON contains the JSON metadata for the -// struct [LoadBalancerRulesOverridesAdaptiveRouting] -type loadBalancerRulesOverridesAdaptiveRoutingJSON struct { - FailoverAcrossPools apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesAdaptiveRouting) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesAdaptiveRoutingJSON) RawJSON() string { - return r.raw -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode LoadBalancerRulesOverridesLocationStrategyMode `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs LoadBalancerRulesOverridesLocationStrategyPreferEcs `json:"prefer_ecs"` - JSON loadBalancerRulesOverridesLocationStrategyJSON `json:"-"` -} - -// loadBalancerRulesOverridesLocationStrategyJSON contains the JSON metadata for -// the struct [LoadBalancerRulesOverridesLocationStrategy] -type loadBalancerRulesOverridesLocationStrategyJSON struct { - Mode apijson.Field - PreferEcs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesLocationStrategy) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesLocationStrategyJSON) RawJSON() string { - return r.raw -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerRulesOverridesLocationStrategyModePop LoadBalancerRulesOverridesLocationStrategyMode = "pop" - LoadBalancerRulesOverridesLocationStrategyModeResolverIP LoadBalancerRulesOverridesLocationStrategyMode = "resolver_ip" -) - -func (r LoadBalancerRulesOverridesLocationStrategyMode) IsKnown() bool { - switch r { - case LoadBalancerRulesOverridesLocationStrategyModePop, LoadBalancerRulesOverridesLocationStrategyModeResolverIP: - return true - } - return false -} - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerRulesOverridesLocationStrategyPreferEcsNever LoadBalancerRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerRulesOverridesLocationStrategyPreferEcs = "geo" -) - -func (r LoadBalancerRulesOverridesLocationStrategyPreferEcs) IsKnown() bool { - switch r { - case LoadBalancerRulesOverridesLocationStrategyPreferEcsAlways, LoadBalancerRulesOverridesLocationStrategyPreferEcsNever, LoadBalancerRulesOverridesLocationStrategyPreferEcsProximity, LoadBalancerRulesOverridesLocationStrategyPreferEcsGeo: - return true - } - return false -} - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight float64 `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights interface{} `json:"pool_weights"` - JSON loadBalancerRulesOverridesRandomSteeringJSON `json:"-"` -} - -// loadBalancerRulesOverridesRandomSteeringJSON contains the JSON metadata for the -// struct [LoadBalancerRulesOverridesRandomSteering] -type loadBalancerRulesOverridesRandomSteeringJSON struct { - DefaultWeight apijson.Field - PoolWeights apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesRandomSteering) UnmarshalJSON(data []byte) (err error) { +func (r *RulesOverrides) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerRulesOverridesRandomSteeringJSON) RawJSON() string { +func (r rulesOverridesJSON) RawJSON() string { return r.raw } @@ -834,156 +1259,19 @@ func (r loadBalancerRulesOverridesRandomSteeringJSON) 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 LoadBalancerRulesOverridesSessionAffinity string +type RulesOverridesSessionAffinity string const ( - LoadBalancerRulesOverridesSessionAffinityNone LoadBalancerRulesOverridesSessionAffinity = "none" - LoadBalancerRulesOverridesSessionAffinityCookie LoadBalancerRulesOverridesSessionAffinity = "cookie" - LoadBalancerRulesOverridesSessionAffinityIPCookie LoadBalancerRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerRulesOverridesSessionAffinityHeader LoadBalancerRulesOverridesSessionAffinity = "header" - LoadBalancerRulesOverridesSessionAffinityEmpty LoadBalancerRulesOverridesSessionAffinity = "\"\"" + RulesOverridesSessionAffinityNone RulesOverridesSessionAffinity = "none" + RulesOverridesSessionAffinityCookie RulesOverridesSessionAffinity = "cookie" + RulesOverridesSessionAffinityIPCookie RulesOverridesSessionAffinity = "ip_cookie" + RulesOverridesSessionAffinityHeader RulesOverridesSessionAffinity = "header" + RulesOverridesSessionAffinityEmpty RulesOverridesSessionAffinity = "\"\"" ) -func (r LoadBalancerRulesOverridesSessionAffinity) IsKnown() bool { +func (r RulesOverridesSessionAffinity) IsKnown() bool { switch r { - case LoadBalancerRulesOverridesSessionAffinityNone, LoadBalancerRulesOverridesSessionAffinityCookie, LoadBalancerRulesOverridesSessionAffinityIPCookie, LoadBalancerRulesOverridesSessionAffinityHeader, LoadBalancerRulesOverridesSessionAffinityEmpty: - return true - } - return false -} - -// Configures attributes for session affinity. -type LoadBalancerRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration float64 `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers []string `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders bool `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite LoadBalancerRulesOverridesSessionAffinityAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure LoadBalancerRulesOverridesSessionAffinityAttributesSecure `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover `json:"zero_downtime_failover"` - JSON loadBalancerRulesOverridesSessionAffinityAttributesJSON `json:"-"` -} - -// loadBalancerRulesOverridesSessionAffinityAttributesJSON contains the JSON -// metadata for the struct [LoadBalancerRulesOverridesSessionAffinityAttributes] -type loadBalancerRulesOverridesSessionAffinityAttributesJSON struct { - DrainDuration apijson.Field - Headers apijson.Field - RequireAllHeaders apijson.Field - Samesite apijson.Field - Secure apijson.Field - ZeroDowntimeFailover apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesSessionAffinityAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesSessionAffinityAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -func (r LoadBalancerRulesOverridesSessionAffinityAttributesSamesite) IsKnown() bool { - switch r { - case LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteAuto, LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteLax, LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteNone, LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -func (r LoadBalancerRulesOverridesSessionAffinityAttributesSecure) IsKnown() bool { - switch r { - case LoadBalancerRulesOverridesSessionAffinityAttributesSecureAuto, LoadBalancerRulesOverridesSessionAffinityAttributesSecureAlways, LoadBalancerRulesOverridesSessionAffinityAttributesSecureNever: - return true - } - return false -} - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -func (r LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { - switch r { - case LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky: + case RulesOverridesSessionAffinityNone, RulesOverridesSessionAffinityCookie, RulesOverridesSessionAffinityIPCookie, RulesOverridesSessionAffinityHeader, RulesOverridesSessionAffinityEmpty: return true } return false @@ -1011,70 +1299,191 @@ func (r LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover) // 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 LoadBalancerRulesOverridesSteeringPolicy string +type RulesOverridesSteeringPolicy string const ( - LoadBalancerRulesOverridesSteeringPolicyOff LoadBalancerRulesOverridesSteeringPolicy = "off" - LoadBalancerRulesOverridesSteeringPolicyGeo LoadBalancerRulesOverridesSteeringPolicy = "geo" - LoadBalancerRulesOverridesSteeringPolicyRandom LoadBalancerRulesOverridesSteeringPolicy = "random" - LoadBalancerRulesOverridesSteeringPolicyDynamicLatency LoadBalancerRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerRulesOverridesSteeringPolicyProximity LoadBalancerRulesOverridesSteeringPolicy = "proximity" - LoadBalancerRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerRulesOverridesSteeringPolicyLeastConnections LoadBalancerRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerRulesOverridesSteeringPolicyEmpty LoadBalancerRulesOverridesSteeringPolicy = "\"\"" + 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 LoadBalancerRulesOverridesSteeringPolicy) IsKnown() bool { +func (r RulesOverridesSteeringPolicy) IsKnown() bool { switch r { - case LoadBalancerRulesOverridesSteeringPolicyOff, LoadBalancerRulesOverridesSteeringPolicyGeo, LoadBalancerRulesOverridesSteeringPolicyRandom, LoadBalancerRulesOverridesSteeringPolicyDynamicLatency, LoadBalancerRulesOverridesSteeringPolicyProximity, LoadBalancerRulesOverridesSteeringPolicyLeastOutstandingRequests, LoadBalancerRulesOverridesSteeringPolicyLeastConnections, LoadBalancerRulesOverridesSteeringPolicyEmpty: + case RulesOverridesSteeringPolicyOff, RulesOverridesSteeringPolicyGeo, RulesOverridesSteeringPolicyRandom, RulesOverridesSteeringPolicyDynamicLatency, RulesOverridesSteeringPolicyProximity, RulesOverridesSteeringPolicyLeastOutstandingRequests, RulesOverridesSteeringPolicyLeastConnections, RulesOverridesSteeringPolicyEmpty: return true } return false } -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerSessionAffinity string +// A rule object containing conditions and overrides for this load balancer to +// evaluate. +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 + // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. + Condition param.Field[string] `json:"condition"` + // Disable this specific rule. It will no longer be evaluated by this load + // balancer. + Disabled param.Field[bool] `json:"disabled"` + // 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[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[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 + // a priority. + Priority param.Field[int64] `json:"priority"` + // If this rule's condition is true, this causes rule evaluation to stop after + // processing this rule. + Terminates param.Field[bool] `json:"terminates"` +} -const ( - LoadBalancerSessionAffinityNone LoadBalancerSessionAffinity = "none" - LoadBalancerSessionAffinityCookie LoadBalancerSessionAffinity = "cookie" - LoadBalancerSessionAffinityIPCookie LoadBalancerSessionAffinity = "ip_cookie" - LoadBalancerSessionAffinityHeader LoadBalancerSessionAffinity = "header" - LoadBalancerSessionAffinityEmpty LoadBalancerSessionAffinity = "\"\"" -) +func (r RulesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} -func (r LoadBalancerSessionAffinity) IsKnown() bool { - switch r { - case LoadBalancerSessionAffinityNone, LoadBalancerSessionAffinityCookie, LoadBalancerSessionAffinityIPCookie, LoadBalancerSessionAffinityHeader, LoadBalancerSessionAffinityEmpty: - return true - } - return false +// 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 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. + Location param.Field[string] `json:"location"` + // Text to include as the http body. + MessageBody param.Field[string] `json:"message_body"` + // The http status code to respond with. + StatusCode param.Field[int64] `json:"status_code"` +} + +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 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 + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting param.Field[AdaptiveRoutingParam] `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + 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[[]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` + // to learn how steering is affected. + LocationStrategy param.Field[LocationStrategyParam] `json:"location_strategy"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools param.Field[interface{}] `json:"pop_pools"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering param.Field[RandomSteeringParam] `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools param.Field[interface{}] `json:"region_pools"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // 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[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 + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // 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[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 RulesOverridesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Configures attributes for session affinity. -type LoadBalancerSessionAffinityAttributes struct { +type SessionAffinityAttributes struct { // Configures the drain duration in seconds. This field is only used when session // affinity is enabled on the load balancer. DrainDuration float64 `json:"drain_duration"` @@ -1101,12 +1510,12 @@ type LoadBalancerSessionAffinityAttributes struct { // Configures the SameSite attribute on session affinity cookie. Value "Auto" will // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: // when using value "None", the secure attribute can not be set to "Never". - Samesite LoadBalancerSessionAffinityAttributesSamesite `json:"samesite"` + Samesite SessionAffinityAttributesSamesite `json:"samesite"` // Configures the Secure attribute on session affinity cookie. Value "Always" // indicates the Secure attribute will be set in the Set-Cookie header, "Never" // indicates the Secure attribute will not be set, and "Auto" will set the Secure // attribute depending if Always Use HTTPS is enabled. - Secure LoadBalancerSessionAffinityAttributesSecure `json:"secure"` + Secure SessionAffinityAttributesSecure `json:"secure"` // Configures the zero-downtime failover between origins within a pool when session // affinity is enabled. This feature is currently incompatible with Argo, Tiered // Cache, and Bandwidth Alliance. The supported values are: @@ -1118,13 +1527,13 @@ type LoadBalancerSessionAffinityAttributes struct { // - `"sticky"`: The session affinity cookie is updated and subsequent requests are // sent to the new origin. Note: Zero-downtime failover with sticky sessions is // currently not supported for session affinity by header. - ZeroDowntimeFailover LoadBalancerSessionAffinityAttributesZeroDowntimeFailover `json:"zero_downtime_failover"` - JSON loadBalancerSessionAffinityAttributesJSON `json:"-"` + ZeroDowntimeFailover SessionAffinityAttributesZeroDowntimeFailover `json:"zero_downtime_failover"` + JSON sessionAffinityAttributesJSON `json:"-"` } -// loadBalancerSessionAffinityAttributesJSON contains the JSON metadata for the -// struct [LoadBalancerSessionAffinityAttributes] -type loadBalancerSessionAffinityAttributesJSON struct { +// sessionAffinityAttributesJSON contains the JSON metadata for the struct +// [SessionAffinityAttributes] +type sessionAffinityAttributesJSON struct { DrainDuration apijson.Field Headers apijson.Field RequireAllHeaders apijson.Field @@ -1135,29 +1544,29 @@ type loadBalancerSessionAffinityAttributesJSON struct { ExtraFields map[string]apijson.Field } -func (r *LoadBalancerSessionAffinityAttributes) UnmarshalJSON(data []byte) (err error) { +func (r *SessionAffinityAttributes) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerSessionAffinityAttributesJSON) RawJSON() string { +func (r sessionAffinityAttributesJSON) RawJSON() string { return r.raw } // Configures the SameSite attribute on session affinity cookie. Value "Auto" will // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: // when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerSessionAffinityAttributesSamesite string +type SessionAffinityAttributesSamesite string const ( - LoadBalancerSessionAffinityAttributesSamesiteAuto LoadBalancerSessionAffinityAttributesSamesite = "Auto" - LoadBalancerSessionAffinityAttributesSamesiteLax LoadBalancerSessionAffinityAttributesSamesite = "Lax" - LoadBalancerSessionAffinityAttributesSamesiteNone LoadBalancerSessionAffinityAttributesSamesite = "None" - LoadBalancerSessionAffinityAttributesSamesiteStrict LoadBalancerSessionAffinityAttributesSamesite = "Strict" + SessionAffinityAttributesSamesiteAuto SessionAffinityAttributesSamesite = "Auto" + SessionAffinityAttributesSamesiteLax SessionAffinityAttributesSamesite = "Lax" + SessionAffinityAttributesSamesiteNone SessionAffinityAttributesSamesite = "None" + SessionAffinityAttributesSamesiteStrict SessionAffinityAttributesSamesite = "Strict" ) -func (r LoadBalancerSessionAffinityAttributesSamesite) IsKnown() bool { +func (r SessionAffinityAttributesSamesite) IsKnown() bool { switch r { - case LoadBalancerSessionAffinityAttributesSamesiteAuto, LoadBalancerSessionAffinityAttributesSamesiteLax, LoadBalancerSessionAffinityAttributesSamesiteNone, LoadBalancerSessionAffinityAttributesSamesiteStrict: + case SessionAffinityAttributesSamesiteAuto, SessionAffinityAttributesSamesiteLax, SessionAffinityAttributesSamesiteNone, SessionAffinityAttributesSamesiteStrict: return true } return false @@ -1167,17 +1576,17 @@ func (r LoadBalancerSessionAffinityAttributesSamesite) IsKnown() bool { // indicates the Secure attribute will be set in the Set-Cookie header, "Never" // indicates the Secure attribute will not be set, and "Auto" will set the Secure // attribute depending if Always Use HTTPS is enabled. -type LoadBalancerSessionAffinityAttributesSecure string +type SessionAffinityAttributesSecure string const ( - LoadBalancerSessionAffinityAttributesSecureAuto LoadBalancerSessionAffinityAttributesSecure = "Auto" - LoadBalancerSessionAffinityAttributesSecureAlways LoadBalancerSessionAffinityAttributesSecure = "Always" - LoadBalancerSessionAffinityAttributesSecureNever LoadBalancerSessionAffinityAttributesSecure = "Never" + SessionAffinityAttributesSecureAuto SessionAffinityAttributesSecure = "Auto" + SessionAffinityAttributesSecureAlways SessionAffinityAttributesSecure = "Always" + SessionAffinityAttributesSecureNever SessionAffinityAttributesSecure = "Never" ) -func (r LoadBalancerSessionAffinityAttributesSecure) IsKnown() bool { +func (r SessionAffinityAttributesSecure) IsKnown() bool { switch r { - case LoadBalancerSessionAffinityAttributesSecureAuto, LoadBalancerSessionAffinityAttributesSecureAlways, LoadBalancerSessionAffinityAttributesSecureNever: + case SessionAffinityAttributesSecureAuto, SessionAffinityAttributesSecureAlways, SessionAffinityAttributesSecureNever: return true } return false @@ -1194,63 +1603,72 @@ func (r LoadBalancerSessionAffinityAttributesSecure) IsKnown() bool { // - `"sticky"`: The session affinity cookie is updated and subsequent requests are // sent to the new origin. Note: Zero-downtime failover with sticky sessions is // currently not supported for session affinity by header. -type LoadBalancerSessionAffinityAttributesZeroDowntimeFailover string +type SessionAffinityAttributesZeroDowntimeFailover string const ( - LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "sticky" + SessionAffinityAttributesZeroDowntimeFailoverNone SessionAffinityAttributesZeroDowntimeFailover = "none" + SessionAffinityAttributesZeroDowntimeFailoverTemporary SessionAffinityAttributesZeroDowntimeFailover = "temporary" + SessionAffinityAttributesZeroDowntimeFailoverSticky SessionAffinityAttributesZeroDowntimeFailover = "sticky" ) -func (r LoadBalancerSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { +func (r SessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { switch r { - case LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverSticky: + case SessionAffinityAttributesZeroDowntimeFailoverNone, SessionAffinityAttributesZeroDowntimeFailoverTemporary, SessionAffinityAttributesZeroDowntimeFailoverSticky: return true } return false } -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// 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 LoadBalancerSteeringPolicy string - -const ( - LoadBalancerSteeringPolicyOff LoadBalancerSteeringPolicy = "off" - LoadBalancerSteeringPolicyGeo LoadBalancerSteeringPolicy = "geo" - LoadBalancerSteeringPolicyRandom LoadBalancerSteeringPolicy = "random" - LoadBalancerSteeringPolicyDynamicLatency LoadBalancerSteeringPolicy = "dynamic_latency" - LoadBalancerSteeringPolicyProximity LoadBalancerSteeringPolicy = "proximity" - LoadBalancerSteeringPolicyLeastOutstandingRequests LoadBalancerSteeringPolicy = "least_outstanding_requests" - LoadBalancerSteeringPolicyLeastConnections LoadBalancerSteeringPolicy = "least_connections" - LoadBalancerSteeringPolicyEmpty LoadBalancerSteeringPolicy = "\"\"" -) +// Configures attributes for session affinity. +type SessionAffinityAttributesParam struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration param.Field[float64] `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers param.Field[[]string] `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders param.Field[bool] `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite param.Field[SessionAffinityAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure param.Field[SessionAffinityAttributesSecure] `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover param.Field[SessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +} -func (r LoadBalancerSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerSteeringPolicyOff, LoadBalancerSteeringPolicyGeo, LoadBalancerSteeringPolicyRandom, LoadBalancerSteeringPolicyDynamicLatency, LoadBalancerSteeringPolicyProximity, LoadBalancerSteeringPolicyLeastOutstandingRequests, LoadBalancerSteeringPolicyLeastConnections, LoadBalancerSteeringPolicyEmpty: - return true - } - return false +func (r SessionAffinityAttributesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } type LoadBalancerDeleteResponse struct { @@ -1278,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[[]string] `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 @@ -1291,7 +1709,7 @@ type LoadBalancerNewParams struct { // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 // response codes. If there is another healthy origin in the same pool, the request // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerNewParamsAdaptiveRouting] `json:"adaptive_routing"` + AdaptiveRouting param.Field[AdaptiveRoutingParam] `json:"adaptive_routing"` // A mapping of country codes to a list of pool IDs (ordered by their failover // priority) for the given country. Any country not explicitly defined will fall // back to using the corresponding region_pool mapping if it exists else to @@ -1301,7 +1719,7 @@ type LoadBalancerNewParams struct { Description param.Field[string] `json:"description"` // Controls location-based steering for non-proxied requests. See `steering_policy` // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerNewParamsLocationStrategy] `json:"location_strategy"` + LocationStrategy param.Field[LocationStrategyParam] `json:"location_strategy"` // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not // explicitly defined will fall back to using the corresponding country_pool, then @@ -1317,14 +1735,14 @@ type LoadBalancerNewParams struct { // pool's outstanding requests. // - `steering_policy="least_connections"`: Use pool weights to scale each pool's // open connections. - RandomSteering param.Field[LoadBalancerNewParamsRandomSteering] `json:"random_steering"` + RandomSteering param.Field[RandomSteeringParam] `json:"random_steering"` // A mapping of region codes to a list of pool IDs (ordered by their failover // priority) for the given region. Any regions not explicitly defined will fall // back to using default_pools. 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[[]LoadBalancerNewParamsRule] `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: // @@ -1350,7 +1768,7 @@ type LoadBalancerNewParams struct { // configuration. SessionAffinity param.Field[LoadBalancerNewParamsSessionAffinity] `json:"session_affinity"` // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerNewParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` + SessionAffinityAttributes param.Field[SessionAffinityAttributesParam] `json:"session_affinity_attributes"` // Time, in seconds, until a client's session expires after being created. Once the // expiry time has been reached, subsequent requests may get sent to a different // origin server. The accepted ranges per `session_affinity` policy are: @@ -1394,196 +1812,170 @@ func (r LoadBalancerNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerNewParamsAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerNewParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerNewParamsLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerNewParamsLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerNewParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerNewParamsLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: // -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerNewParamsLocationStrategyMode string +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerNewParamsSessionAffinity string const ( - LoadBalancerNewParamsLocationStrategyModePop LoadBalancerNewParamsLocationStrategyMode = "pop" - LoadBalancerNewParamsLocationStrategyModeResolverIP LoadBalancerNewParamsLocationStrategyMode = "resolver_ip" + LoadBalancerNewParamsSessionAffinityNone LoadBalancerNewParamsSessionAffinity = "none" + LoadBalancerNewParamsSessionAffinityCookie LoadBalancerNewParamsSessionAffinity = "cookie" + LoadBalancerNewParamsSessionAffinityIPCookie LoadBalancerNewParamsSessionAffinity = "ip_cookie" + LoadBalancerNewParamsSessionAffinityHeader LoadBalancerNewParamsSessionAffinity = "header" + LoadBalancerNewParamsSessionAffinityEmpty LoadBalancerNewParamsSessionAffinity = "\"\"" ) -func (r LoadBalancerNewParamsLocationStrategyMode) IsKnown() bool { +func (r LoadBalancerNewParamsSessionAffinity) IsKnown() bool { switch r { - case LoadBalancerNewParamsLocationStrategyModePop, LoadBalancerNewParamsLocationStrategyModeResolverIP: + case LoadBalancerNewParamsSessionAffinityNone, LoadBalancerNewParamsSessionAffinityCookie, LoadBalancerNewParamsSessionAffinityIPCookie, LoadBalancerNewParamsSessionAffinityHeader, LoadBalancerNewParamsSessionAffinityEmpty: return true } return false } -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. +// Steering Policy for this load balancer. // -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerNewParamsLocationStrategyPreferEcs string +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// 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 LoadBalancerNewParamsSteeringPolicy string const ( - LoadBalancerNewParamsLocationStrategyPreferEcsAlways LoadBalancerNewParamsLocationStrategyPreferEcs = "always" - LoadBalancerNewParamsLocationStrategyPreferEcsNever LoadBalancerNewParamsLocationStrategyPreferEcs = "never" - LoadBalancerNewParamsLocationStrategyPreferEcsProximity LoadBalancerNewParamsLocationStrategyPreferEcs = "proximity" - LoadBalancerNewParamsLocationStrategyPreferEcsGeo LoadBalancerNewParamsLocationStrategyPreferEcs = "geo" + LoadBalancerNewParamsSteeringPolicyOff LoadBalancerNewParamsSteeringPolicy = "off" + LoadBalancerNewParamsSteeringPolicyGeo LoadBalancerNewParamsSteeringPolicy = "geo" + LoadBalancerNewParamsSteeringPolicyRandom LoadBalancerNewParamsSteeringPolicy = "random" + LoadBalancerNewParamsSteeringPolicyDynamicLatency LoadBalancerNewParamsSteeringPolicy = "dynamic_latency" + LoadBalancerNewParamsSteeringPolicyProximity LoadBalancerNewParamsSteeringPolicy = "proximity" + LoadBalancerNewParamsSteeringPolicyLeastOutstandingRequests LoadBalancerNewParamsSteeringPolicy = "least_outstanding_requests" + LoadBalancerNewParamsSteeringPolicyLeastConnections LoadBalancerNewParamsSteeringPolicy = "least_connections" + LoadBalancerNewParamsSteeringPolicyEmpty LoadBalancerNewParamsSteeringPolicy = "\"\"" ) -func (r LoadBalancerNewParamsLocationStrategyPreferEcs) IsKnown() bool { +func (r LoadBalancerNewParamsSteeringPolicy) IsKnown() bool { switch r { - case LoadBalancerNewParamsLocationStrategyPreferEcsAlways, LoadBalancerNewParamsLocationStrategyPreferEcsNever, LoadBalancerNewParamsLocationStrategyPreferEcsProximity, LoadBalancerNewParamsLocationStrategyPreferEcsGeo: + case LoadBalancerNewParamsSteeringPolicyOff, LoadBalancerNewParamsSteeringPolicyGeo, LoadBalancerNewParamsSteeringPolicyRandom, LoadBalancerNewParamsSteeringPolicyDynamicLatency, LoadBalancerNewParamsSteeringPolicyProximity, LoadBalancerNewParamsSteeringPolicyLeastOutstandingRequests, LoadBalancerNewParamsSteeringPolicyLeastConnections, LoadBalancerNewParamsSteeringPolicyEmpty: return true } return false } -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerNewParamsRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` +type LoadBalancerNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LoadBalancer `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerNewResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerNewResponseEnvelopeJSON `json:"-"` } -func (r LoadBalancerNewParamsRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// loadBalancerNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerNewResponseEnvelope] +type loadBalancerNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerNewParamsRule 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 - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition param.Field[string] `json:"condition"` - // Disable this specific rule. It will no longer be evaluated by this load - // balancer. - Disabled param.Field[bool] `json:"disabled"` - // 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[LoadBalancerNewParamsRulesFixedResponse] `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[LoadBalancerNewParamsRulesOverrides] `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 - // a priority. - Priority param.Field[int64] `json:"priority"` - // If this rule's condition is true, this causes rule evaluation to stop after - // processing this rule. - Terminates param.Field[bool] `json:"terminates"` +func (r *LoadBalancerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r LoadBalancerNewParamsRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r loadBalancerNewResponseEnvelopeJSON) 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 LoadBalancerNewParamsRulesFixedResponse 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. - Location param.Field[string] `json:"location"` - // Text to include as the http body. - MessageBody param.Field[string] `json:"message_body"` - // The http status code to respond with. - StatusCode param.Field[int64] `json:"status_code"` -} +// Whether the API call was successful +type LoadBalancerNewResponseEnvelopeSuccess bool -func (r LoadBalancerNewParamsRulesFixedResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +const ( + LoadBalancerNewResponseEnvelopeSuccessTrue LoadBalancerNewResponseEnvelopeSuccess = true +) + +func (r LoadBalancerNewResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case LoadBalancerNewResponseEnvelopeSuccessTrue: + return true + } + return false } -// A collection of overrides to apply to the load balancer when this rule's -// condition is true. All fields are optional. -type LoadBalancerNewParamsRulesOverrides struct { +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[[]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 + // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take + // precedence and the DNS record will not be used. + Name param.Field[string] `json:"name,required"` // 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 // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 // response codes. If there is another healthy origin in the same pool, the request // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerNewParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` + AdaptiveRouting param.Field[AdaptiveRoutingParam] `json:"adaptive_routing"` // A mapping of country codes to a list of pool IDs (ordered by their failover // priority) for the given country. Any country not explicitly defined will fall // back to using the corresponding region_pool mapping if it exists else to // default_pools. 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[[]string] `json:"default_pools"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool param.Field[interface{}] `json:"fallback_pool"` + // Object description. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) this load balancer. + Enabled param.Field[bool] `json:"enabled"` // Controls location-based steering for non-proxied requests. See `steering_policy` // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategy] `json:"location_strategy"` + LocationStrategy param.Field[LocationStrategyParam] `json:"location_strategy"` // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not // explicitly defined will fall back to using the corresponding country_pool, then // region_pool mapping if it exists else to default_pools. PopPools param.Field[interface{}] `json:"pop_pools"` + // Whether the hostname should be gray clouded (false) or orange clouded (true). + Proxied param.Field[bool] `json:"proxied"` // Configures pool weights. // // - `steering_policy="random"`: A random pool is selected with probability @@ -1592,11 +1984,14 @@ type LoadBalancerNewParamsRulesOverrides struct { // pool's outstanding requests. // - `steering_policy="least_connections"`: Use pool weights to scale each pool's // open connections. - RandomSteering param.Field[LoadBalancerNewParamsRulesOverridesRandomSteering] `json:"random_steering"` + RandomSteering param.Field[RandomSteeringParam] `json:"random_steering"` // A mapping of region codes to a list of pool IDs (ordered by their failover // priority) for the given region. Any regions not explicitly defined will fall // back to using default_pools. 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[[]RulesParam] `json:"rules"` // Specifies the type of session affinity the load balancer should use unless // specified as `"none"` or "" (default). The supported types are: // @@ -1620,9 +2015,9 @@ type LoadBalancerNewParamsRulesOverrides 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[LoadBalancerNewParamsRulesOverridesSessionAffinity] `json:"session_affinity"` + SessionAffinity param.Field[LoadBalancerUpdateParamsSessionAffinity] `json:"session_affinity"` // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` + SessionAffinityAttributes param.Field[SessionAffinityAttributesParam] `json:"session_affinity_attributes"` // Time, in seconds, until a client's session expires after being created. Once the // expiry time has been reached, subsequent requests may get sent to a different // origin server. The accepted ranges per `session_affinity` policy are: @@ -1656,123 +2051,13 @@ type LoadBalancerNewParamsRulesOverrides 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[LoadBalancerNewParamsRulesOverridesSteeringPolicy] `json:"steering_policy"` + SteeringPolicy param.Field[LoadBalancerUpdateParamsSteeringPolicy] `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 LoadBalancerNewParamsRulesOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerNewParamsRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerNewParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerNewParamsRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerNewParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerNewParamsRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerNewParamsRulesOverridesLocationStrategyModePop LoadBalancerNewParamsRulesOverridesLocationStrategyMode = "pop" - LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerNewParamsRulesOverridesLocationStrategyMode = "resolver_ip" -) - -func (r LoadBalancerNewParamsRulesOverridesLocationStrategyMode) IsKnown() bool { - switch r { - case LoadBalancerNewParamsRulesOverridesLocationStrategyModePop, LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP: - return true - } - return false -} - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "geo" -) - -func (r LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs) IsKnown() bool { - switch r { - case LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways, LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsNever, LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsProximity, LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsGeo: - return true - } - return false -} - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerNewParamsRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerNewParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { +func (r LoadBalancerUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } @@ -1799,138 +2084,19 @@ func (r LoadBalancerNewParamsRulesOverridesRandomSteering) MarshalJSON() (data [ // server is unhealthy, then a new origin server is calculated and used. See // `headers` in `session_affinity_attributes` for additional required // configuration. -type LoadBalancerNewParamsRulesOverridesSessionAffinity string - -const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityNone LoadBalancerNewParamsRulesOverridesSessionAffinity = "none" - LoadBalancerNewParamsRulesOverridesSessionAffinityCookie LoadBalancerNewParamsRulesOverridesSessionAffinity = "cookie" - LoadBalancerNewParamsRulesOverridesSessionAffinityIPCookie LoadBalancerNewParamsRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerNewParamsRulesOverridesSessionAffinityHeader LoadBalancerNewParamsRulesOverridesSessionAffinity = "header" - LoadBalancerNewParamsRulesOverridesSessionAffinityEmpty LoadBalancerNewParamsRulesOverridesSessionAffinity = "\"\"" -) - -func (r LoadBalancerNewParamsRulesOverridesSessionAffinity) IsKnown() bool { - switch r { - case LoadBalancerNewParamsRulesOverridesSessionAffinityNone, LoadBalancerNewParamsRulesOverridesSessionAffinityCookie, LoadBalancerNewParamsRulesOverridesSessionAffinityIPCookie, LoadBalancerNewParamsRulesOverridesSessionAffinityHeader, LoadBalancerNewParamsRulesOverridesSessionAffinityEmpty: - return true - } - return false -} - -// Configures attributes for session affinity. -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -func (r LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite) IsKnown() bool { - switch r { - case LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto, LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteLax, LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteNone, LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -func (r LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure) IsKnown() bool { - switch r { - case LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto, LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAlways, LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureNever: - return true - } - return false -} - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string +type LoadBalancerUpdateParamsSessionAffinity string const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" + LoadBalancerUpdateParamsSessionAffinityNone LoadBalancerUpdateParamsSessionAffinity = "none" + LoadBalancerUpdateParamsSessionAffinityCookie LoadBalancerUpdateParamsSessionAffinity = "cookie" + LoadBalancerUpdateParamsSessionAffinityIPCookie LoadBalancerUpdateParamsSessionAffinity = "ip_cookie" + LoadBalancerUpdateParamsSessionAffinityHeader LoadBalancerUpdateParamsSessionAffinity = "header" + LoadBalancerUpdateParamsSessionAffinityEmpty LoadBalancerUpdateParamsSessionAffinity = "\"\"" ) -func (r LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { +func (r LoadBalancerUpdateParamsSessionAffinity) IsKnown() bool { switch r { - case LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky: + case LoadBalancerUpdateParamsSessionAffinityNone, LoadBalancerUpdateParamsSessionAffinityCookie, LoadBalancerUpdateParamsSessionAffinityIPCookie, LoadBalancerUpdateParamsSessionAffinityHeader, LoadBalancerUpdateParamsSessionAffinityEmpty: return true } return false @@ -1958,242 +2124,95 @@ func (r LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntime // 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 LoadBalancerNewParamsRulesOverridesSteeringPolicy string +type LoadBalancerUpdateParamsSteeringPolicy string const ( - LoadBalancerNewParamsRulesOverridesSteeringPolicyOff LoadBalancerNewParamsRulesOverridesSteeringPolicy = "off" - LoadBalancerNewParamsRulesOverridesSteeringPolicyGeo LoadBalancerNewParamsRulesOverridesSteeringPolicy = "geo" - LoadBalancerNewParamsRulesOverridesSteeringPolicyRandom LoadBalancerNewParamsRulesOverridesSteeringPolicy = "random" - LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerNewParamsRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerNewParamsRulesOverridesSteeringPolicyProximity LoadBalancerNewParamsRulesOverridesSteeringPolicy = "proximity" - LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerNewParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerNewParamsRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerNewParamsRulesOverridesSteeringPolicyEmpty LoadBalancerNewParamsRulesOverridesSteeringPolicy = "\"\"" + LoadBalancerUpdateParamsSteeringPolicyOff LoadBalancerUpdateParamsSteeringPolicy = "off" + LoadBalancerUpdateParamsSteeringPolicyGeo LoadBalancerUpdateParamsSteeringPolicy = "geo" + LoadBalancerUpdateParamsSteeringPolicyRandom LoadBalancerUpdateParamsSteeringPolicy = "random" + LoadBalancerUpdateParamsSteeringPolicyDynamicLatency LoadBalancerUpdateParamsSteeringPolicy = "dynamic_latency" + LoadBalancerUpdateParamsSteeringPolicyProximity LoadBalancerUpdateParamsSteeringPolicy = "proximity" + LoadBalancerUpdateParamsSteeringPolicyLeastOutstandingRequests LoadBalancerUpdateParamsSteeringPolicy = "least_outstanding_requests" + LoadBalancerUpdateParamsSteeringPolicyLeastConnections LoadBalancerUpdateParamsSteeringPolicy = "least_connections" + LoadBalancerUpdateParamsSteeringPolicyEmpty LoadBalancerUpdateParamsSteeringPolicy = "\"\"" ) -func (r LoadBalancerNewParamsRulesOverridesSteeringPolicy) IsKnown() bool { +func (r LoadBalancerUpdateParamsSteeringPolicy) IsKnown() bool { switch r { - case LoadBalancerNewParamsRulesOverridesSteeringPolicyOff, LoadBalancerNewParamsRulesOverridesSteeringPolicyGeo, LoadBalancerNewParamsRulesOverridesSteeringPolicyRandom, LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency, LoadBalancerNewParamsRulesOverridesSteeringPolicyProximity, LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastOutstandingRequests, LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastConnections, LoadBalancerNewParamsRulesOverridesSteeringPolicyEmpty: + case LoadBalancerUpdateParamsSteeringPolicyOff, LoadBalancerUpdateParamsSteeringPolicyGeo, LoadBalancerUpdateParamsSteeringPolicyRandom, LoadBalancerUpdateParamsSteeringPolicyDynamicLatency, LoadBalancerUpdateParamsSteeringPolicyProximity, LoadBalancerUpdateParamsSteeringPolicyLeastOutstandingRequests, LoadBalancerUpdateParamsSteeringPolicyLeastConnections, LoadBalancerUpdateParamsSteeringPolicyEmpty: return true } return false } -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerNewParamsSessionAffinity string - -const ( - LoadBalancerNewParamsSessionAffinityNone LoadBalancerNewParamsSessionAffinity = "none" - LoadBalancerNewParamsSessionAffinityCookie LoadBalancerNewParamsSessionAffinity = "cookie" - LoadBalancerNewParamsSessionAffinityIPCookie LoadBalancerNewParamsSessionAffinity = "ip_cookie" - LoadBalancerNewParamsSessionAffinityHeader LoadBalancerNewParamsSessionAffinity = "header" - LoadBalancerNewParamsSessionAffinityEmpty LoadBalancerNewParamsSessionAffinity = "\"\"" -) - -func (r LoadBalancerNewParamsSessionAffinity) IsKnown() bool { - switch r { - case LoadBalancerNewParamsSessionAffinityNone, LoadBalancerNewParamsSessionAffinityCookie, LoadBalancerNewParamsSessionAffinityIPCookie, LoadBalancerNewParamsSessionAffinityHeader, LoadBalancerNewParamsSessionAffinityEmpty: - return true - } - return false +type LoadBalancerUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LoadBalancer `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerUpdateResponseEnvelopeJSON `json:"-"` } -// Configures attributes for session affinity. -type LoadBalancerNewParamsSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerNewParamsSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerNewParamsSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +// loadBalancerUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerUpdateResponseEnvelope] +type loadBalancerUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r LoadBalancerNewParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *LoadBalancerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerNewParamsSessionAffinityAttributesSamesite string - -const ( - LoadBalancerNewParamsSessionAffinityAttributesSamesiteAuto LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Auto" - LoadBalancerNewParamsSessionAffinityAttributesSamesiteLax LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Lax" - LoadBalancerNewParamsSessionAffinityAttributesSamesiteNone LoadBalancerNewParamsSessionAffinityAttributesSamesite = "None" - LoadBalancerNewParamsSessionAffinityAttributesSamesiteStrict LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Strict" -) - -func (r LoadBalancerNewParamsSessionAffinityAttributesSamesite) IsKnown() bool { - switch r { - case LoadBalancerNewParamsSessionAffinityAttributesSamesiteAuto, LoadBalancerNewParamsSessionAffinityAttributesSamesiteLax, LoadBalancerNewParamsSessionAffinityAttributesSamesiteNone, LoadBalancerNewParamsSessionAffinityAttributesSamesiteStrict: - return true - } - return false +func (r loadBalancerUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerNewParamsSessionAffinityAttributesSecure string +// Whether the API call was successful +type LoadBalancerUpdateResponseEnvelopeSuccess bool const ( - LoadBalancerNewParamsSessionAffinityAttributesSecureAuto LoadBalancerNewParamsSessionAffinityAttributesSecure = "Auto" - LoadBalancerNewParamsSessionAffinityAttributesSecureAlways LoadBalancerNewParamsSessionAffinityAttributesSecure = "Always" - LoadBalancerNewParamsSessionAffinityAttributesSecureNever LoadBalancerNewParamsSessionAffinityAttributesSecure = "Never" + LoadBalancerUpdateResponseEnvelopeSuccessTrue LoadBalancerUpdateResponseEnvelopeSuccess = true ) -func (r LoadBalancerNewParamsSessionAffinityAttributesSecure) IsKnown() bool { +func (r LoadBalancerUpdateResponseEnvelopeSuccess) IsKnown() bool { switch r { - case LoadBalancerNewParamsSessionAffinityAttributesSecureAuto, LoadBalancerNewParamsSessionAffinityAttributesSecureAlways, LoadBalancerNewParamsSessionAffinityAttributesSecureNever: + case LoadBalancerUpdateResponseEnvelopeSuccessTrue: return true } return false } -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -func (r LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { - switch r { - case LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverSticky: - return true - } - return false +type LoadBalancerListParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` } -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// 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 LoadBalancerNewParamsSteeringPolicy string - -const ( - LoadBalancerNewParamsSteeringPolicyOff LoadBalancerNewParamsSteeringPolicy = "off" - LoadBalancerNewParamsSteeringPolicyGeo LoadBalancerNewParamsSteeringPolicy = "geo" - LoadBalancerNewParamsSteeringPolicyRandom LoadBalancerNewParamsSteeringPolicy = "random" - LoadBalancerNewParamsSteeringPolicyDynamicLatency LoadBalancerNewParamsSteeringPolicy = "dynamic_latency" - LoadBalancerNewParamsSteeringPolicyProximity LoadBalancerNewParamsSteeringPolicy = "proximity" - LoadBalancerNewParamsSteeringPolicyLeastOutstandingRequests LoadBalancerNewParamsSteeringPolicy = "least_outstanding_requests" - LoadBalancerNewParamsSteeringPolicyLeastConnections LoadBalancerNewParamsSteeringPolicy = "least_connections" - LoadBalancerNewParamsSteeringPolicyEmpty LoadBalancerNewParamsSteeringPolicy = "\"\"" -) +type LoadBalancerDeleteParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} -func (r LoadBalancerNewParamsSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerNewParamsSteeringPolicyOff, LoadBalancerNewParamsSteeringPolicyGeo, LoadBalancerNewParamsSteeringPolicyRandom, LoadBalancerNewParamsSteeringPolicyDynamicLatency, LoadBalancerNewParamsSteeringPolicyProximity, LoadBalancerNewParamsSteeringPolicyLeastOutstandingRequests, LoadBalancerNewParamsSteeringPolicyLeastConnections, LoadBalancerNewParamsSteeringPolicyEmpty: - return true - } - return false +func (r LoadBalancerDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -type LoadBalancerNewResponseEnvelope struct { - Errors []LoadBalancerNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` +type LoadBalancerDeleteResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LoadBalancerDeleteResponse `json:"result,required"` // Whether the API call was successful - Success LoadBalancerNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerNewResponseEnvelopeJSON `json:"-"` + Success LoadBalancerDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerDeleteResponseEnvelopeJSON `json:"-"` } -// loadBalancerNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerNewResponseEnvelope] -type loadBalancerNewResponseEnvelopeJSON struct { +// loadBalancerDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerDeleteResponseEnvelope] +type loadBalancerDeleteResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field Result apijson.Field @@ -2202,105 +2221,59 @@ type loadBalancerNewResponseEnvelopeJSON struct { ExtraFields map[string]apijson.Field } -func (r *LoadBalancerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerNewResponseEnvelopeErrors] -type loadBalancerNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LoadBalancerNewResponseEnvelopeMessages] -type loadBalancerNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *LoadBalancerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r loadBalancerNewResponseEnvelopeMessagesJSON) RawJSON() string { +func (r loadBalancerDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } // Whether the API call was successful -type LoadBalancerNewResponseEnvelopeSuccess bool +type LoadBalancerDeleteResponseEnvelopeSuccess bool const ( - LoadBalancerNewResponseEnvelopeSuccessTrue LoadBalancerNewResponseEnvelopeSuccess = true + LoadBalancerDeleteResponseEnvelopeSuccessTrue LoadBalancerDeleteResponseEnvelopeSuccess = true ) -func (r LoadBalancerNewResponseEnvelopeSuccess) IsKnown() bool { +func (r LoadBalancerDeleteResponseEnvelopeSuccess) IsKnown() bool { switch r { - case LoadBalancerNewResponseEnvelopeSuccessTrue: + case LoadBalancerDeleteResponseEnvelopeSuccessTrue: return true } return false } -type LoadBalancerUpdateParams struct { +type LoadBalancerEditParams 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[[]string] `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 - // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take - // precedence and the DNS record will not be used. - Name param.Field[string] `json:"name,required"` // 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 // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 // response codes. If there is another healthy origin in the same pool, the request // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerUpdateParamsAdaptiveRouting] `json:"adaptive_routing"` + AdaptiveRouting param.Field[AdaptiveRoutingParam] `json:"adaptive_routing"` // A mapping of country codes to a list of pool IDs (ordered by their failover // priority) for the given country. Any country not explicitly defined will fall // back to using the corresponding region_pool mapping if it exists else to // default_pools. 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[[]DefaultPoolsParam] `json:"default_pools"` // Object description. Description param.Field[string] `json:"description"` // Whether to enable (the default) this load balancer. Enabled param.Field[bool] `json:"enabled"` + // 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` // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerUpdateParamsLocationStrategy] `json:"location_strategy"` + LocationStrategy param.Field[LocationStrategyParam] `json:"location_strategy"` + // The DNS hostname to associate with your Load Balancer. If this hostname already + // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take + // precedence and the DNS record will not be used. + Name param.Field[string] `json:"name"` // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not // explicitly defined will fall back to using the corresponding country_pool, then @@ -2316,14 +2289,14 @@ type LoadBalancerUpdateParams struct { // pool's outstanding requests. // - `steering_policy="least_connections"`: Use pool weights to scale each pool's // open connections. - RandomSteering param.Field[LoadBalancerUpdateParamsRandomSteering] `json:"random_steering"` + RandomSteering param.Field[RandomSteeringParam] `json:"random_steering"` // A mapping of region codes to a list of pool IDs (ordered by their failover // priority) for the given region. Any regions not explicitly defined will fall // back to using default_pools. 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[[]LoadBalancerUpdateParamsRule] `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: // @@ -2347,9 +2320,9 @@ type LoadBalancerUpdateParams 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[LoadBalancerUpdateParamsSessionAffinity] `json:"session_affinity"` + SessionAffinity param.Field[LoadBalancerEditParamsSessionAffinity] `json:"session_affinity"` // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerUpdateParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` + SessionAffinityAttributes param.Field[SessionAffinityAttributesParam] `json:"session_affinity_attributes"` // Time, in seconds, until a client's session expires after being created. Once the // expiry time has been reached, subsequent requests may get sent to a different // origin server. The accepted ranges per `session_affinity` policy are: @@ -2361,1719 +2334,38 @@ type LoadBalancerUpdateParams struct { // affinity by header, sessions only expire after they haven't been used for the // number of seconds specified. SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // 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[LoadBalancerUpdateParamsSteeringPolicy] `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 LoadBalancerUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerUpdateParamsAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerUpdateParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerUpdateParamsLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerUpdateParamsLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerUpdateParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerUpdateParamsLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerUpdateParamsLocationStrategyMode string - -const ( - LoadBalancerUpdateParamsLocationStrategyModePop LoadBalancerUpdateParamsLocationStrategyMode = "pop" - LoadBalancerUpdateParamsLocationStrategyModeResolverIP LoadBalancerUpdateParamsLocationStrategyMode = "resolver_ip" -) - -func (r LoadBalancerUpdateParamsLocationStrategyMode) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsLocationStrategyModePop, LoadBalancerUpdateParamsLocationStrategyModeResolverIP: - return true - } - return false -} - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerUpdateParamsLocationStrategyPreferEcs string - -const ( - LoadBalancerUpdateParamsLocationStrategyPreferEcsAlways LoadBalancerUpdateParamsLocationStrategyPreferEcs = "always" - LoadBalancerUpdateParamsLocationStrategyPreferEcsNever LoadBalancerUpdateParamsLocationStrategyPreferEcs = "never" - LoadBalancerUpdateParamsLocationStrategyPreferEcsProximity LoadBalancerUpdateParamsLocationStrategyPreferEcs = "proximity" - LoadBalancerUpdateParamsLocationStrategyPreferEcsGeo LoadBalancerUpdateParamsLocationStrategyPreferEcs = "geo" -) - -func (r LoadBalancerUpdateParamsLocationStrategyPreferEcs) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsLocationStrategyPreferEcsAlways, LoadBalancerUpdateParamsLocationStrategyPreferEcsNever, LoadBalancerUpdateParamsLocationStrategyPreferEcsProximity, LoadBalancerUpdateParamsLocationStrategyPreferEcsGeo: - return true - } - return false -} - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerUpdateParamsRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerUpdateParamsRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerUpdateParamsRule 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 - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition param.Field[string] `json:"condition"` - // Disable this specific rule. It will no longer be evaluated by this load - // balancer. - Disabled param.Field[bool] `json:"disabled"` - // 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[LoadBalancerUpdateParamsRulesFixedResponse] `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[LoadBalancerUpdateParamsRulesOverrides] `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 - // a priority. - Priority param.Field[int64] `json:"priority"` - // If this rule's condition is true, this causes rule evaluation to stop after - // processing this rule. - Terminates param.Field[bool] `json:"terminates"` -} - -func (r LoadBalancerUpdateParamsRule) 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 LoadBalancerUpdateParamsRulesFixedResponse 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. - Location param.Field[string] `json:"location"` - // Text to include as the http body. - MessageBody param.Field[string] `json:"message_body"` - // The http status code to respond with. - StatusCode param.Field[int64] `json:"status_code"` -} - -func (r LoadBalancerUpdateParamsRulesFixedResponse) 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 LoadBalancerUpdateParamsRulesOverrides 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 - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - 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[[]string] `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` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategy] `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerUpdateParamsRulesOverridesRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // 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[LoadBalancerUpdateParamsRulesOverridesSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // 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[LoadBalancerUpdateParamsRulesOverridesSteeringPolicy] `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 LoadBalancerUpdateParamsRulesOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerUpdateParamsRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerUpdateParamsRulesOverridesLocationStrategyModePop LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode = "pop" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode = "resolver_ip" -) - -func (r LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsRulesOverridesLocationStrategyModePop, LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP: - return true - } - return false -} - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "geo" -) - -func (r LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways, LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsNever, LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsProximity, LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsGeo: - return true - } - return false -} - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerUpdateParamsRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinity string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityNone LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "none" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "cookie" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityIPCookie LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityHeader LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "header" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityEmpty LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "\"\"" -) - -func (r LoadBalancerUpdateParamsRulesOverridesSessionAffinity) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsRulesOverridesSessionAffinityNone, LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie, LoadBalancerUpdateParamsRulesOverridesSessionAffinityIPCookie, LoadBalancerUpdateParamsRulesOverridesSessionAffinityHeader, LoadBalancerUpdateParamsRulesOverridesSessionAffinityEmpty: - return true - } - return false -} - -// Configures attributes for session affinity. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -func (r LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto, LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteLax, LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteNone, LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -func (r LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto, LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAlways, LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureNever: - return true - } - return false -} - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -func (r LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky: - return true - } - return false -} - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// 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 LoadBalancerUpdateParamsRulesOverridesSteeringPolicy string - -const ( - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyOff LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "off" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyGeo LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "geo" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyRandom LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "random" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyProximity LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "proximity" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyEmpty LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "\"\"" -) - -func (r LoadBalancerUpdateParamsRulesOverridesSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsRulesOverridesSteeringPolicyOff, LoadBalancerUpdateParamsRulesOverridesSteeringPolicyGeo, LoadBalancerUpdateParamsRulesOverridesSteeringPolicyRandom, LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency, LoadBalancerUpdateParamsRulesOverridesSteeringPolicyProximity, LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastOutstandingRequests, LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastConnections, LoadBalancerUpdateParamsRulesOverridesSteeringPolicyEmpty: - return true - } - return false -} - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerUpdateParamsSessionAffinity string - -const ( - LoadBalancerUpdateParamsSessionAffinityNone LoadBalancerUpdateParamsSessionAffinity = "none" - LoadBalancerUpdateParamsSessionAffinityCookie LoadBalancerUpdateParamsSessionAffinity = "cookie" - LoadBalancerUpdateParamsSessionAffinityIPCookie LoadBalancerUpdateParamsSessionAffinity = "ip_cookie" - LoadBalancerUpdateParamsSessionAffinityHeader LoadBalancerUpdateParamsSessionAffinity = "header" - LoadBalancerUpdateParamsSessionAffinityEmpty LoadBalancerUpdateParamsSessionAffinity = "\"\"" -) - -func (r LoadBalancerUpdateParamsSessionAffinity) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsSessionAffinityNone, LoadBalancerUpdateParamsSessionAffinityCookie, LoadBalancerUpdateParamsSessionAffinityIPCookie, LoadBalancerUpdateParamsSessionAffinityHeader, LoadBalancerUpdateParamsSessionAffinityEmpty: - return true - } - return false -} - -// Configures attributes for session affinity. -type LoadBalancerUpdateParamsSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerUpdateParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerUpdateParamsSessionAffinityAttributesSamesite string - -const ( - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteAuto LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Auto" - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteLax LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Lax" - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteNone LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "None" - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteStrict LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Strict" -) - -func (r LoadBalancerUpdateParamsSessionAffinityAttributesSamesite) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteAuto, LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteLax, LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteNone, LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerUpdateParamsSessionAffinityAttributesSecure string - -const ( - LoadBalancerUpdateParamsSessionAffinityAttributesSecureAuto LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Auto" - LoadBalancerUpdateParamsSessionAffinityAttributesSecureAlways LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Always" - LoadBalancerUpdateParamsSessionAffinityAttributesSecureNever LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Never" -) - -func (r LoadBalancerUpdateParamsSessionAffinityAttributesSecure) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsSessionAffinityAttributesSecureAuto, LoadBalancerUpdateParamsSessionAffinityAttributesSecureAlways, LoadBalancerUpdateParamsSessionAffinityAttributesSecureNever: - return true - } - return false -} - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -func (r LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverSticky: - return true - } - return false -} - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// 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 LoadBalancerUpdateParamsSteeringPolicy string - -const ( - LoadBalancerUpdateParamsSteeringPolicyOff LoadBalancerUpdateParamsSteeringPolicy = "off" - LoadBalancerUpdateParamsSteeringPolicyGeo LoadBalancerUpdateParamsSteeringPolicy = "geo" - LoadBalancerUpdateParamsSteeringPolicyRandom LoadBalancerUpdateParamsSteeringPolicy = "random" - LoadBalancerUpdateParamsSteeringPolicyDynamicLatency LoadBalancerUpdateParamsSteeringPolicy = "dynamic_latency" - LoadBalancerUpdateParamsSteeringPolicyProximity LoadBalancerUpdateParamsSteeringPolicy = "proximity" - LoadBalancerUpdateParamsSteeringPolicyLeastOutstandingRequests LoadBalancerUpdateParamsSteeringPolicy = "least_outstanding_requests" - LoadBalancerUpdateParamsSteeringPolicyLeastConnections LoadBalancerUpdateParamsSteeringPolicy = "least_connections" - LoadBalancerUpdateParamsSteeringPolicyEmpty LoadBalancerUpdateParamsSteeringPolicy = "\"\"" -) - -func (r LoadBalancerUpdateParamsSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerUpdateParamsSteeringPolicyOff, LoadBalancerUpdateParamsSteeringPolicyGeo, LoadBalancerUpdateParamsSteeringPolicyRandom, LoadBalancerUpdateParamsSteeringPolicyDynamicLatency, LoadBalancerUpdateParamsSteeringPolicyProximity, LoadBalancerUpdateParamsSteeringPolicyLeastOutstandingRequests, LoadBalancerUpdateParamsSteeringPolicyLeastConnections, LoadBalancerUpdateParamsSteeringPolicyEmpty: - return true - } - return false -} - -type LoadBalancerUpdateResponseEnvelope struct { - Errors []LoadBalancerUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerUpdateResponseEnvelope] -type loadBalancerUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerUpdateResponseEnvelopeErrors] -type loadBalancerUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerUpdateResponseEnvelopeMessages] -type loadBalancerUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancerUpdateResponseEnvelopeSuccessTrue LoadBalancerUpdateResponseEnvelopeSuccess = true -) - -func (r LoadBalancerUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerListParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type LoadBalancerDeleteParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type LoadBalancerDeleteResponseEnvelope struct { - Errors []LoadBalancerDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerDeleteResponseEnvelope] -type loadBalancerDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerDeleteResponseEnvelopeErrors] -type loadBalancerDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerDeleteResponseEnvelopeMessages] -type loadBalancerDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancerDeleteResponseEnvelopeSuccessTrue LoadBalancerDeleteResponseEnvelopeSuccess = true -) - -func (r LoadBalancerDeleteResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerEditParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` - // 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 - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerEditParamsAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - 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[[]string] `json:"default_pools"` - // Object description. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) this load balancer. - Enabled param.Field[bool] `json:"enabled"` - // 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` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerEditParamsLocationStrategy] `json:"location_strategy"` - // The DNS hostname to associate with your Load Balancer. If this hostname already - // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take - // precedence and the DNS record will not be used. - Name param.Field[string] `json:"name"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Whether the hostname should be gray clouded (false) or orange clouded (true). - Proxied param.Field[bool] `json:"proxied"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerEditParamsRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - 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[[]LoadBalancerEditParamsRule] `json:"rules"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // 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[LoadBalancerEditParamsSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerEditParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // 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[LoadBalancerEditParamsSteeringPolicy] `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 LoadBalancerEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerEditParamsAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerEditParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerEditParamsLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerEditParamsLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerEditParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerEditParamsLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerEditParamsLocationStrategyMode string - -const ( - LoadBalancerEditParamsLocationStrategyModePop LoadBalancerEditParamsLocationStrategyMode = "pop" - LoadBalancerEditParamsLocationStrategyModeResolverIP LoadBalancerEditParamsLocationStrategyMode = "resolver_ip" -) - -func (r LoadBalancerEditParamsLocationStrategyMode) IsKnown() bool { - switch r { - case LoadBalancerEditParamsLocationStrategyModePop, LoadBalancerEditParamsLocationStrategyModeResolverIP: - return true - } - return false -} - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerEditParamsLocationStrategyPreferEcs string - -const ( - LoadBalancerEditParamsLocationStrategyPreferEcsAlways LoadBalancerEditParamsLocationStrategyPreferEcs = "always" - LoadBalancerEditParamsLocationStrategyPreferEcsNever LoadBalancerEditParamsLocationStrategyPreferEcs = "never" - LoadBalancerEditParamsLocationStrategyPreferEcsProximity LoadBalancerEditParamsLocationStrategyPreferEcs = "proximity" - LoadBalancerEditParamsLocationStrategyPreferEcsGeo LoadBalancerEditParamsLocationStrategyPreferEcs = "geo" -) - -func (r LoadBalancerEditParamsLocationStrategyPreferEcs) IsKnown() bool { - switch r { - case LoadBalancerEditParamsLocationStrategyPreferEcsAlways, LoadBalancerEditParamsLocationStrategyPreferEcsNever, LoadBalancerEditParamsLocationStrategyPreferEcsProximity, LoadBalancerEditParamsLocationStrategyPreferEcsGeo: - return true - } - return false -} - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerEditParamsRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerEditParamsRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerEditParamsRule 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 - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition param.Field[string] `json:"condition"` - // Disable this specific rule. It will no longer be evaluated by this load - // balancer. - Disabled param.Field[bool] `json:"disabled"` - // 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[LoadBalancerEditParamsRulesFixedResponse] `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[LoadBalancerEditParamsRulesOverrides] `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 - // a priority. - Priority param.Field[int64] `json:"priority"` - // If this rule's condition is true, this causes rule evaluation to stop after - // processing this rule. - Terminates param.Field[bool] `json:"terminates"` -} - -func (r LoadBalancerEditParamsRule) 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 LoadBalancerEditParamsRulesFixedResponse 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. - Location param.Field[string] `json:"location"` - // Text to include as the http body. - MessageBody param.Field[string] `json:"message_body"` - // The http status code to respond with. - StatusCode param.Field[int64] `json:"status_code"` -} - -func (r LoadBalancerEditParamsRulesFixedResponse) 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 LoadBalancerEditParamsRulesOverrides 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 - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerEditParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - 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[[]string] `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` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategy] `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerEditParamsRulesOverridesRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // 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[LoadBalancerEditParamsRulesOverridesSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // 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[LoadBalancerEditParamsRulesOverridesSteeringPolicy] `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 LoadBalancerEditParamsRulesOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// 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 -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerEditParamsRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerEditParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerEditParamsRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerEditParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerEditParamsRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerEditParamsRulesOverridesLocationStrategyModePop LoadBalancerEditParamsRulesOverridesLocationStrategyMode = "pop" - LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerEditParamsRulesOverridesLocationStrategyMode = "resolver_ip" -) - -func (r LoadBalancerEditParamsRulesOverridesLocationStrategyMode) IsKnown() bool { - switch r { - case LoadBalancerEditParamsRulesOverridesLocationStrategyModePop, LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP: - return true - } - return false -} - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "geo" -) - -func (r LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs) IsKnown() bool { - switch r { - case LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways, LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsNever, LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsProximity, LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsGeo: - return true - } - return false -} - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerEditParamsRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerEditParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerEditParamsRulesOverridesSessionAffinity string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityNone LoadBalancerEditParamsRulesOverridesSessionAffinity = "none" - LoadBalancerEditParamsRulesOverridesSessionAffinityCookie LoadBalancerEditParamsRulesOverridesSessionAffinity = "cookie" - LoadBalancerEditParamsRulesOverridesSessionAffinityIPCookie LoadBalancerEditParamsRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerEditParamsRulesOverridesSessionAffinityHeader LoadBalancerEditParamsRulesOverridesSessionAffinity = "header" - LoadBalancerEditParamsRulesOverridesSessionAffinityEmpty LoadBalancerEditParamsRulesOverridesSessionAffinity = "\"\"" -) - -func (r LoadBalancerEditParamsRulesOverridesSessionAffinity) IsKnown() bool { - switch r { - case LoadBalancerEditParamsRulesOverridesSessionAffinityNone, LoadBalancerEditParamsRulesOverridesSessionAffinityCookie, LoadBalancerEditParamsRulesOverridesSessionAffinityIPCookie, LoadBalancerEditParamsRulesOverridesSessionAffinityHeader, LoadBalancerEditParamsRulesOverridesSessionAffinityEmpty: - return true - } - return false -} - -// Configures attributes for session affinity. -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: + // Steering Policy for this load balancer. // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // 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[LoadBalancerEditParamsSteeringPolicy] `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 LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { +func (r LoadBalancerEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -func (r LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite) IsKnown() bool { - switch r { - case LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto, LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteLax, LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteNone, LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -func (r LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure) IsKnown() bool { - switch r { - case LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto, LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAlways, LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureNever: - return true - } - return false -} - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -func (r LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { - switch r { - case LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky: - return true - } - return false -} - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// 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 LoadBalancerEditParamsRulesOverridesSteeringPolicy string - -const ( - LoadBalancerEditParamsRulesOverridesSteeringPolicyOff LoadBalancerEditParamsRulesOverridesSteeringPolicy = "off" - LoadBalancerEditParamsRulesOverridesSteeringPolicyGeo LoadBalancerEditParamsRulesOverridesSteeringPolicy = "geo" - LoadBalancerEditParamsRulesOverridesSteeringPolicyRandom LoadBalancerEditParamsRulesOverridesSteeringPolicy = "random" - LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerEditParamsRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerEditParamsRulesOverridesSteeringPolicyProximity LoadBalancerEditParamsRulesOverridesSteeringPolicy = "proximity" - LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerEditParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerEditParamsRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerEditParamsRulesOverridesSteeringPolicyEmpty LoadBalancerEditParamsRulesOverridesSteeringPolicy = "\"\"" -) - -func (r LoadBalancerEditParamsRulesOverridesSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerEditParamsRulesOverridesSteeringPolicyOff, LoadBalancerEditParamsRulesOverridesSteeringPolicyGeo, LoadBalancerEditParamsRulesOverridesSteeringPolicyRandom, LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency, LoadBalancerEditParamsRulesOverridesSteeringPolicyProximity, LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastOutstandingRequests, LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastConnections, LoadBalancerEditParamsRulesOverridesSteeringPolicyEmpty: - return true - } - return false -} - // Specifies the type of session affinity the load balancer should use unless // specified as `"none"` or "" (default). The supported types are: // @@ -4115,125 +2407,6 @@ func (r LoadBalancerEditParamsSessionAffinity) IsKnown() bool { return false } -// Configures attributes for session affinity. -type LoadBalancerEditParamsSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerEditParamsSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerEditParamsSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerEditParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerEditParamsSessionAffinityAttributesSamesite string - -const ( - LoadBalancerEditParamsSessionAffinityAttributesSamesiteAuto LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Auto" - LoadBalancerEditParamsSessionAffinityAttributesSamesiteLax LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Lax" - LoadBalancerEditParamsSessionAffinityAttributesSamesiteNone LoadBalancerEditParamsSessionAffinityAttributesSamesite = "None" - LoadBalancerEditParamsSessionAffinityAttributesSamesiteStrict LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Strict" -) - -func (r LoadBalancerEditParamsSessionAffinityAttributesSamesite) IsKnown() bool { - switch r { - case LoadBalancerEditParamsSessionAffinityAttributesSamesiteAuto, LoadBalancerEditParamsSessionAffinityAttributesSamesiteLax, LoadBalancerEditParamsSessionAffinityAttributesSamesiteNone, LoadBalancerEditParamsSessionAffinityAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerEditParamsSessionAffinityAttributesSecure string - -const ( - LoadBalancerEditParamsSessionAffinityAttributesSecureAuto LoadBalancerEditParamsSessionAffinityAttributesSecure = "Auto" - LoadBalancerEditParamsSessionAffinityAttributesSecureAlways LoadBalancerEditParamsSessionAffinityAttributesSecure = "Always" - LoadBalancerEditParamsSessionAffinityAttributesSecureNever LoadBalancerEditParamsSessionAffinityAttributesSecure = "Never" -) - -func (r LoadBalancerEditParamsSessionAffinityAttributesSecure) IsKnown() bool { - switch r { - case LoadBalancerEditParamsSessionAffinityAttributesSecureAuto, LoadBalancerEditParamsSessionAffinityAttributesSecureAlways, LoadBalancerEditParamsSessionAffinityAttributesSecureNever: - return true - } - return false -} - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -func (r LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover) IsKnown() bool { - switch r { - case LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverNone, LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary, LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverSticky: - return true - } - return false -} - // Steering Policy for this load balancer. // // - `"off"`: Use `default_pools`. @@ -4278,9 +2451,9 @@ func (r LoadBalancerEditParamsSteeringPolicy) IsKnown() bool { } type LoadBalancerEditResponseEnvelope struct { - Errors []LoadBalancerEditResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerEditResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LoadBalancer `json:"result,required"` // Whether the API call was successful Success LoadBalancerEditResponseEnvelopeSuccess `json:"success,required"` JSON loadBalancerEditResponseEnvelopeJSON `json:"-"` @@ -4305,52 +2478,6 @@ func (r loadBalancerEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LoadBalancerEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerEditResponseEnvelopeErrors] -type loadBalancerEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LoadBalancerEditResponseEnvelopeMessages] -type loadBalancerEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LoadBalancerEditResponseEnvelopeSuccess bool @@ -4371,9 +2498,9 @@ type LoadBalancerGetParams struct { } type LoadBalancerGetResponseEnvelope struct { - Errors []LoadBalancerGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerGetResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LoadBalancer `json:"result,required"` // Whether the API call was successful Success LoadBalancerGetResponseEnvelopeSuccess `json:"success,required"` JSON loadBalancerGetResponseEnvelopeJSON `json:"-"` @@ -4398,52 +2525,6 @@ func (r loadBalancerGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LoadBalancerGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerGetResponseEnvelopeErrors] -type loadBalancerGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LoadBalancerGetResponseEnvelopeMessages] -type loadBalancerGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LoadBalancerGetResponseEnvelopeSuccess bool diff --git a/load_balancers/loadbalancer_test.go b/load_balancers/loadbalancer_test.go index 90932a4744c..ce92749b2f3 100644 --- a/load_balancers/loadbalancer_test.go +++ b/load_balancers/loadbalancer_test.go @@ -30,10 +30,10 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { ) _, err := client.LoadBalancers.New(context.TODO(), load_balancers.LoadBalancerNewParams{ ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - DefaultPools: cloudflare.F([]string{"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.LoadBalancerNewParamsAdaptiveRouting{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -46,9 +46,9 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { }, }), Description: cloudflare.F("Load Balancer for www.example.com"), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -64,7 +64,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { }, }), Proxied: cloudflare.F(true), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -80,18 +80,18 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - Rules: cloudflare.F([]load_balancers.LoadBalancerNewParamsRule{{ + Rules: cloudflare.F([]load_balancers.RulesParam{{ Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesFixedResponse{ + 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.LoadBalancerNewParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -103,11 +103,11 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -122,7 +122,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -138,17 +138,17 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -156,15 +156,15 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesFixedResponse{ + 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.LoadBalancerNewParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -176,11 +176,11 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -195,7 +195,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -211,17 +211,17 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -229,15 +229,15 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesFixedResponse{ + 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.LoadBalancerNewParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -249,11 +249,11 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -268,7 +268,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -284,30 +284,30 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), Terminates: cloudflare.F(true), }}), SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributes{ + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsSteeringPolicyDynamicLatency), @@ -341,10 +341,10 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "699d98642c564d2e855e9661899b7252", load_balancers.LoadBalancerUpdateParams{ ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - DefaultPools: cloudflare.F([]string{"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.LoadBalancerUpdateParamsAdaptiveRouting{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -358,9 +358,9 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { }), Description: cloudflare.F("Load Balancer for www.example.com"), Enabled: cloudflare.F(true), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -376,7 +376,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { }, }), Proxied: cloudflare.F(true), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -392,18 +392,18 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - Rules: cloudflare.F([]load_balancers.LoadBalancerUpdateParamsRule{{ + Rules: cloudflare.F([]load_balancers.RulesParam{{ Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesFixedResponse{ + 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.LoadBalancerUpdateParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -415,11 +415,11 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -434,7 +434,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -450,17 +450,17 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -468,15 +468,15 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesFixedResponse{ + 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.LoadBalancerUpdateParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -488,11 +488,11 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -507,7 +507,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -523,17 +523,17 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -541,15 +541,15 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesFixedResponse{ + 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.LoadBalancerUpdateParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -561,11 +561,11 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -580,7 +580,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -596,30 +596,30 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), Terminates: cloudflare.F(true), }}), SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributes{ + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSteeringPolicyDynamicLatency), @@ -680,6 +680,7 @@ func TestLoadBalancerDelete(t *testing.T) { "699d98642c564d2e855e9661899b7252", load_balancers.LoadBalancerDeleteParams{ ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -710,7 +711,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "699d98642c564d2e855e9661899b7252", load_balancers.LoadBalancerEditParams{ ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsAdaptiveRouting{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -722,13 +723,13 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"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{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), Name: cloudflare.F("www.example.com"), PopPools: cloudflare.F[any](map[string]interface{}{ @@ -745,7 +746,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { }, }), Proxied: cloudflare.F(true), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -761,18 +762,18 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - Rules: cloudflare.F([]load_balancers.LoadBalancerEditParamsRule{{ + Rules: cloudflare.F([]load_balancers.RulesParam{{ Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesFixedResponse{ + 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.LoadBalancerEditParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -784,11 +785,11 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -803,7 +804,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -819,17 +820,17 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -837,15 +838,15 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesFixedResponse{ + 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.LoadBalancerEditParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -857,11 +858,11 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -876,7 +877,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -892,17 +893,17 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -910,15 +911,15 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesFixedResponse{ + 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.LoadBalancerEditParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ + AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), CountryPools: cloudflare.F[any](map[string]interface{}{ @@ -930,11 +931,11 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), + LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ + Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LocationStrategyPreferEcsAlways), }), PopPools: cloudflare.F[any](map[string]interface{}{ "LAX": map[string]interface{}{ @@ -949,7 +950,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "0": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesRandomSteering{ + RandomSteering: cloudflare.F(load_balancers.RandomSteeringParam{ DefaultWeight: cloudflare.F(0.200000), PoolWeights: cloudflare.F[any](map[string]interface{}{ "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, @@ -965,30 +966,30 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), Terminates: cloudflare.F(true), }}), SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributes{ + SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), + Samesite: cloudflare.F(load_balancers.SessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.SessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsSteeringPolicyDynamicLatency), diff --git a/load_balancers/monitor.go b/load_balancers/monitor.go index 5f66cf202cd..1fdd2f373f0 100644 --- a/load_balancers/monitor.go +++ b/load_balancers/monitor.go @@ -6,13 +6,14 @@ 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" - "github.com/cloudflare/cloudflare-go/v2/user" ) // MonitorService contains methods and other services that help with interacting @@ -37,7 +38,7 @@ func NewMonitorService(opts ...option.RequestOption) (r *MonitorService) { } // Create a configured monitor. -func (r *MonitorService) New(ctx context.Context, params MonitorNewParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { +func (r *MonitorService) New(ctx context.Context, params MonitorNewParams, opts ...option.RequestOption) (res *Monitor, err error) { opts = append(r.Options[:], opts...) var env MonitorNewResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/monitors", params.AccountID) @@ -50,7 +51,7 @@ func (r *MonitorService) New(ctx context.Context, params MonitorNewParams, opts } // Modify a configured monitor. -func (r *MonitorService) Update(ctx context.Context, monitorID string, params MonitorUpdateParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { +func (r *MonitorService) Update(ctx context.Context, monitorID string, params MonitorUpdateParams, opts ...option.RequestOption) (res *Monitor, err error) { opts = append(r.Options[:], opts...) var env MonitorUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID) @@ -63,7 +64,7 @@ func (r *MonitorService) Update(ctx context.Context, monitorID string, params Mo } // List configured monitors for an account. -func (r *MonitorService) List(ctx context.Context, query MonitorListParams, opts ...option.RequestOption) (res *pagination.SinglePage[user.LoadBalancingMonitor], err error) { +func (r *MonitorService) List(ctx context.Context, query MonitorListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Monitor], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -81,15 +82,15 @@ func (r *MonitorService) List(ctx context.Context, query MonitorListParams, opts } // List configured monitors for an account. -func (r *MonitorService) ListAutoPaging(ctx context.Context, query MonitorListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[user.LoadBalancingMonitor] { +func (r *MonitorService) ListAutoPaging(ctx context.Context, query MonitorListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Monitor] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete a configured monitor. -func (r *MonitorService) Delete(ctx context.Context, monitorID string, body MonitorDeleteParams, opts ...option.RequestOption) (res *MonitorDeleteResponse, err error) { +func (r *MonitorService) Delete(ctx context.Context, monitorID string, params MonitorDeleteParams, opts ...option.RequestOption) (res *MonitorDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env MonitorDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", body.AccountID, monitorID) + path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -99,7 +100,7 @@ func (r *MonitorService) Delete(ctx context.Context, monitorID string, body Moni } // Apply changes to an existing monitor, overwriting the supplied properties. -func (r *MonitorService) Edit(ctx context.Context, monitorID string, params MonitorEditParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { +func (r *MonitorService) Edit(ctx context.Context, monitorID string, params MonitorEditParams, opts ...option.RequestOption) (res *Monitor, err error) { opts = append(r.Options[:], opts...) var env MonitorEditResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID) @@ -112,7 +113,7 @@ func (r *MonitorService) Edit(ctx context.Context, monitorID string, params Moni } // List a single configured monitor for an account. -func (r *MonitorService) Get(ctx context.Context, monitorID string, query MonitorGetParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { +func (r *MonitorService) Get(ctx context.Context, monitorID string, query MonitorGetParams, opts ...option.RequestOption) (res *Monitor, err error) { opts = append(r.Options[:], opts...) var env MonitorGetResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", query.AccountID, monitorID) @@ -124,6 +125,116 @@ func (r *MonitorService) Get(ctx context.Context, monitorID string, query Monito return } +type Monitor 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 MonitorType `json:"type"` + JSON monitorJSON `json:"-"` +} + +// monitorJSON contains the JSON metadata for the struct [Monitor] +type monitorJSON 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 *Monitor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorJSON) 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 MonitorType string + +const ( + MonitorTypeHTTP MonitorType = "http" + MonitorTypeHTTPS MonitorType = "https" + MonitorTypeTCP MonitorType = "tcp" + MonitorTypeUdpIcmp MonitorType = "udp_icmp" + MonitorTypeIcmpPing MonitorType = "icmp_ping" + MonitorTypeSmtp MonitorType = "smtp" +) + +func (r MonitorType) IsKnown() bool { + switch r { + case MonitorTypeHTTP, MonitorTypeHTTPS, MonitorTypeTCP, MonitorTypeUdpIcmp, MonitorTypeIcmpPing, MonitorTypeSmtp: + return true + } + return false +} + type MonitorDeleteResponse struct { ID string `json:"id"` JSON monitorDeleteResponseJSON `json:"-"` @@ -210,7 +321,7 @@ type MonitorNewParamsType string const ( MonitorNewParamsTypeHTTP MonitorNewParamsType = "http" MonitorNewParamsTypeHTTPS MonitorNewParamsType = "https" - MonitorNewParamsTypeTcp MonitorNewParamsType = "tcp" + MonitorNewParamsTypeTCP MonitorNewParamsType = "tcp" MonitorNewParamsTypeUdpIcmp MonitorNewParamsType = "udp_icmp" MonitorNewParamsTypeIcmpPing MonitorNewParamsType = "icmp_ping" MonitorNewParamsTypeSmtp MonitorNewParamsType = "smtp" @@ -218,16 +329,16 @@ const ( func (r MonitorNewParamsType) IsKnown() bool { switch r { - case MonitorNewParamsTypeHTTP, MonitorNewParamsTypeHTTPS, MonitorNewParamsTypeTcp, MonitorNewParamsTypeUdpIcmp, MonitorNewParamsTypeIcmpPing, MonitorNewParamsTypeSmtp: + case MonitorNewParamsTypeHTTP, MonitorNewParamsTypeHTTPS, MonitorNewParamsTypeTCP, MonitorNewParamsTypeUdpIcmp, MonitorNewParamsTypeIcmpPing, MonitorNewParamsTypeSmtp: return true } return false } type MonitorNewResponseEnvelope struct { - Errors []MonitorNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MonitorNewResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingMonitor `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Monitor `json:"result,required"` // Whether the API call was successful Success MonitorNewResponseEnvelopeSuccess `json:"success,required"` JSON monitorNewResponseEnvelopeJSON `json:"-"` @@ -252,52 +363,6 @@ func (r monitorNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MonitorNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// monitorNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MonitorNewResponseEnvelopeErrors] -type monitorNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MonitorNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// monitorNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [MonitorNewResponseEnvelopeMessages] -type monitorNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MonitorNewResponseEnvelopeSuccess bool @@ -378,7 +443,7 @@ type MonitorUpdateParamsType string const ( MonitorUpdateParamsTypeHTTP MonitorUpdateParamsType = "http" MonitorUpdateParamsTypeHTTPS MonitorUpdateParamsType = "https" - MonitorUpdateParamsTypeTcp MonitorUpdateParamsType = "tcp" + MonitorUpdateParamsTypeTCP MonitorUpdateParamsType = "tcp" MonitorUpdateParamsTypeUdpIcmp MonitorUpdateParamsType = "udp_icmp" MonitorUpdateParamsTypeIcmpPing MonitorUpdateParamsType = "icmp_ping" MonitorUpdateParamsTypeSmtp MonitorUpdateParamsType = "smtp" @@ -386,16 +451,16 @@ const ( func (r MonitorUpdateParamsType) IsKnown() bool { switch r { - case MonitorUpdateParamsTypeHTTP, MonitorUpdateParamsTypeHTTPS, MonitorUpdateParamsTypeTcp, MonitorUpdateParamsTypeUdpIcmp, MonitorUpdateParamsTypeIcmpPing, MonitorUpdateParamsTypeSmtp: + case MonitorUpdateParamsTypeHTTP, MonitorUpdateParamsTypeHTTPS, MonitorUpdateParamsTypeTCP, MonitorUpdateParamsTypeUdpIcmp, MonitorUpdateParamsTypeIcmpPing, MonitorUpdateParamsTypeSmtp: return true } return false } type MonitorUpdateResponseEnvelope struct { - Errors []MonitorUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MonitorUpdateResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingMonitor `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Monitor `json:"result,required"` // Whether the API call was successful Success MonitorUpdateResponseEnvelopeSuccess `json:"success,required"` JSON monitorUpdateResponseEnvelopeJSON `json:"-"` @@ -420,52 +485,6 @@ func (r monitorUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MonitorUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// monitorUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MonitorUpdateResponseEnvelopeErrors] -type monitorUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MonitorUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// monitorUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MonitorUpdateResponseEnvelopeMessages] -type monitorUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MonitorUpdateResponseEnvelopeSuccess bool @@ -489,12 +508,17 @@ type MonitorListParams struct { type MonitorDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r MonitorDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type MonitorDeleteResponseEnvelope struct { - Errors []MonitorDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MonitorDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MonitorDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MonitorDeleteResponse `json:"result,required"` // Whether the API call was successful Success MonitorDeleteResponseEnvelopeSuccess `json:"success,required"` JSON monitorDeleteResponseEnvelopeJSON `json:"-"` @@ -519,52 +543,6 @@ func (r monitorDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MonitorDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// monitorDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MonitorDeleteResponseEnvelopeErrors] -type monitorDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MonitorDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// monitorDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MonitorDeleteResponseEnvelopeMessages] -type monitorDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MonitorDeleteResponseEnvelopeSuccess bool @@ -645,7 +623,7 @@ type MonitorEditParamsType string const ( MonitorEditParamsTypeHTTP MonitorEditParamsType = "http" MonitorEditParamsTypeHTTPS MonitorEditParamsType = "https" - MonitorEditParamsTypeTcp MonitorEditParamsType = "tcp" + MonitorEditParamsTypeTCP MonitorEditParamsType = "tcp" MonitorEditParamsTypeUdpIcmp MonitorEditParamsType = "udp_icmp" MonitorEditParamsTypeIcmpPing MonitorEditParamsType = "icmp_ping" MonitorEditParamsTypeSmtp MonitorEditParamsType = "smtp" @@ -653,16 +631,16 @@ const ( func (r MonitorEditParamsType) IsKnown() bool { switch r { - case MonitorEditParamsTypeHTTP, MonitorEditParamsTypeHTTPS, MonitorEditParamsTypeTcp, MonitorEditParamsTypeUdpIcmp, MonitorEditParamsTypeIcmpPing, MonitorEditParamsTypeSmtp: + case MonitorEditParamsTypeHTTP, MonitorEditParamsTypeHTTPS, MonitorEditParamsTypeTCP, MonitorEditParamsTypeUdpIcmp, MonitorEditParamsTypeIcmpPing, MonitorEditParamsTypeSmtp: return true } return false } type MonitorEditResponseEnvelope struct { - Errors []MonitorEditResponseEnvelopeErrors `json:"errors,required"` - Messages []MonitorEditResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingMonitor `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Monitor `json:"result,required"` // Whether the API call was successful Success MonitorEditResponseEnvelopeSuccess `json:"success,required"` JSON monitorEditResponseEnvelopeJSON `json:"-"` @@ -687,52 +665,6 @@ func (r monitorEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MonitorEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// monitorEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MonitorEditResponseEnvelopeErrors] -type monitorEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MonitorEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// monitorEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MonitorEditResponseEnvelopeMessages] -type monitorEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MonitorEditResponseEnvelopeSuccess bool @@ -754,9 +686,9 @@ type MonitorGetParams struct { } type MonitorGetResponseEnvelope struct { - Errors []MonitorGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MonitorGetResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingMonitor `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Monitor `json:"result,required"` // Whether the API call was successful Success MonitorGetResponseEnvelopeSuccess `json:"success,required"` JSON monitorGetResponseEnvelopeJSON `json:"-"` @@ -781,52 +713,6 @@ func (r monitorGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MonitorGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// monitorGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MonitorGetResponseEnvelopeErrors] -type monitorGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MonitorGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// monitorGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [MonitorGetResponseEnvelopeMessages] -type monitorGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MonitorGetResponseEnvelopeSuccess bool diff --git a/load_balancers/monitor_test.go b/load_balancers/monitor_test.go index 10fc985fc58..60066c91079 100644 --- a/load_balancers/monitor_test.go +++ b/load_balancers/monitor_test.go @@ -161,6 +161,7 @@ func TestMonitorDelete(t *testing.T) { "f1aba936b94213e5b8dca0c0dbf1f9cc", load_balancers.MonitorDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/load_balancers/monitorpreview.go b/load_balancers/monitorpreview.go index 5b6a75818a1..23d97881a81 100644 --- a/load_balancers/monitorpreview.go +++ b/load_balancers/monitorpreview.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -134,7 +135,7 @@ type MonitorPreviewNewParamsType string const ( MonitorPreviewNewParamsTypeHTTP MonitorPreviewNewParamsType = "http" MonitorPreviewNewParamsTypeHTTPS MonitorPreviewNewParamsType = "https" - MonitorPreviewNewParamsTypeTcp MonitorPreviewNewParamsType = "tcp" + MonitorPreviewNewParamsTypeTCP MonitorPreviewNewParamsType = "tcp" MonitorPreviewNewParamsTypeUdpIcmp MonitorPreviewNewParamsType = "udp_icmp" MonitorPreviewNewParamsTypeIcmpPing MonitorPreviewNewParamsType = "icmp_ping" MonitorPreviewNewParamsTypeSmtp MonitorPreviewNewParamsType = "smtp" @@ -142,16 +143,16 @@ const ( func (r MonitorPreviewNewParamsType) IsKnown() bool { switch r { - case MonitorPreviewNewParamsTypeHTTP, MonitorPreviewNewParamsTypeHTTPS, MonitorPreviewNewParamsTypeTcp, MonitorPreviewNewParamsTypeUdpIcmp, MonitorPreviewNewParamsTypeIcmpPing, MonitorPreviewNewParamsTypeSmtp: + case MonitorPreviewNewParamsTypeHTTP, MonitorPreviewNewParamsTypeHTTPS, MonitorPreviewNewParamsTypeTCP, MonitorPreviewNewParamsTypeUdpIcmp, MonitorPreviewNewParamsTypeIcmpPing, MonitorPreviewNewParamsTypeSmtp: return true } return false } type MonitorPreviewNewResponseEnvelope struct { - Errors []MonitorPreviewNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MonitorPreviewNewResponseEnvelopeMessages `json:"messages,required"` - Result MonitorPreviewNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MonitorPreviewNewResponse `json:"result,required"` // Whether the API call was successful Success MonitorPreviewNewResponseEnvelopeSuccess `json:"success,required"` JSON monitorPreviewNewResponseEnvelopeJSON `json:"-"` @@ -176,52 +177,6 @@ func (r monitorPreviewNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MonitorPreviewNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorPreviewNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// monitorPreviewNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MonitorPreviewNewResponseEnvelopeErrors] -type monitorPreviewNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorPreviewNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorPreviewNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MonitorPreviewNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorPreviewNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// monitorPreviewNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MonitorPreviewNewResponseEnvelopeMessages] -type monitorPreviewNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorPreviewNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorPreviewNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MonitorPreviewNewResponseEnvelopeSuccess bool diff --git a/load_balancers/monitorreference.go b/load_balancers/monitorreference.go index fa880ef1c2b..07d46aa5b04 100644 --- a/load_balancers/monitorreference.go +++ b/load_balancers/monitorreference.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -93,8 +94,8 @@ type MonitorReferenceGetParams struct { } type MonitorReferenceGetResponseEnvelope struct { - Errors []MonitorReferenceGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MonitorReferenceGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // List of resources that reference a given monitor. Result []MonitorReferenceGetResponse `json:"result,required,nullable"` // Whether the API call was successful @@ -123,52 +124,6 @@ func (r monitorReferenceGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MonitorReferenceGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorReferenceGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// monitorReferenceGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MonitorReferenceGetResponseEnvelopeErrors] -type monitorReferenceGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorReferenceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorReferenceGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MonitorReferenceGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON monitorReferenceGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// monitorReferenceGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MonitorReferenceGetResponseEnvelopeMessages] -type monitorReferenceGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MonitorReferenceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r monitorReferenceGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MonitorReferenceGetResponseEnvelopeSuccess bool diff --git a/load_balancers/pool.go b/load_balancers/pool.go index 18985558b41..49a79ff74a6 100644 --- a/load_balancers/pool.go +++ b/load_balancers/pool.go @@ -7,14 +7,15 @@ import ( "fmt" "net/http" "net/url" + "time" "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/cloudflare/cloudflare-go/v2/user" ) // PoolService contains methods and other services that help with interacting with @@ -39,7 +40,7 @@ func NewPoolService(opts ...option.RequestOption) (r *PoolService) { } // Create a new pool. -func (r *PoolService) New(ctx context.Context, params PoolNewParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { +func (r *PoolService) New(ctx context.Context, params PoolNewParams, opts ...option.RequestOption) (res *Pool, err error) { opts = append(r.Options[:], opts...) var env PoolNewResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/pools", params.AccountID) @@ -52,7 +53,7 @@ func (r *PoolService) New(ctx context.Context, params PoolNewParams, opts ...opt } // Modify a configured pool. -func (r *PoolService) Update(ctx context.Context, poolID string, params PoolUpdateParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { +func (r *PoolService) Update(ctx context.Context, poolID string, params PoolUpdateParams, opts ...option.RequestOption) (res *Pool, err error) { opts = append(r.Options[:], opts...) var env PoolUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", params.AccountID, poolID) @@ -65,7 +66,7 @@ func (r *PoolService) Update(ctx context.Context, poolID string, params PoolUpda } // List configured pools. -func (r *PoolService) List(ctx context.Context, params PoolListParams, opts ...option.RequestOption) (res *pagination.SinglePage[user.LoadBalancingPool], err error) { +func (r *PoolService) List(ctx context.Context, params PoolListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Pool], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -83,15 +84,15 @@ func (r *PoolService) List(ctx context.Context, params PoolListParams, opts ...o } // List configured pools. -func (r *PoolService) ListAutoPaging(ctx context.Context, params PoolListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[user.LoadBalancingPool] { +func (r *PoolService) ListAutoPaging(ctx context.Context, params PoolListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Pool] { return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...)) } // Delete a configured pool. -func (r *PoolService) Delete(ctx context.Context, poolID string, body PoolDeleteParams, opts ...option.RequestOption) (res *PoolDeleteResponse, err error) { +func (r *PoolService) Delete(ctx context.Context, poolID string, params PoolDeleteParams, opts ...option.RequestOption) (res *PoolDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env PoolDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", body.AccountID, poolID) + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", params.AccountID, poolID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -101,7 +102,7 @@ func (r *PoolService) Delete(ctx context.Context, poolID string, body PoolDelete } // Apply changes to an existing pool, overwriting the supplied properties. -func (r *PoolService) Edit(ctx context.Context, poolID string, params PoolEditParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { +func (r *PoolService) Edit(ctx context.Context, poolID string, params PoolEditParams, opts ...option.RequestOption) (res *Pool, err error) { opts = append(r.Options[:], opts...) var env PoolEditResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", params.AccountID, poolID) @@ -114,7 +115,7 @@ func (r *PoolService) Edit(ctx context.Context, poolID string, params PoolEditPa } // Fetch a single configured pool. -func (r *PoolService) Get(ctx context.Context, poolID string, query PoolGetParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { +func (r *PoolService) Get(ctx context.Context, poolID string, query PoolGetParams, opts ...option.RequestOption) (res *Pool, err error) { opts = append(r.Options[:], opts...) var env PoolGetResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", query.AccountID, poolID) @@ -126,6 +127,89 @@ func (r *PoolService) Get(ctx context.Context, poolID string, query PoolGetParam return } +type Pool struct { + ID string `json:"id"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + CheckRegions []CheckRegion `json:"check_regions,nullable"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // A human-readable description of the pool. + Description string `json:"description"` + // This field shows up only if the pool is disabled. This field is set with the + // time the pool was disabled at. + DisabledAt time.Time `json:"disabled_at" format:"date-time"` + // 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 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 float64 `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding LoadShedding `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude float64 `json:"longitude"` + // 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 int64 `json:"minimum_origins"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor interface{} `json:"monitor"` + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name 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 string `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter NotificationFilter `json:"notification_filter,nullable"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering OriginSteering `json:"origin_steering"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins []Origin `json:"origins"` + JSON poolJSON `json:"-"` +} + +// poolJSON contains the JSON metadata for the struct [Pool] +type poolJSON struct { + ID apijson.Field + CheckRegions apijson.Field + CreatedOn apijson.Field + Description apijson.Field + DisabledAt apijson.Field + Enabled apijson.Field + Latitude apijson.Field + LoadShedding apijson.Field + Longitude apijson.Field + MinimumOrigins apijson.Field + ModifiedOn apijson.Field + Monitor apijson.Field + Name apijson.Field + NotificationEmail apijson.Field + NotificationFilter apijson.Field + OriginSteering apijson.Field + Origins apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Pool) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolJSON) RawJSON() string { + return r.raw +} + type PoolDeleteResponse struct { ID string `json:"id"` JSON poolDeleteResponseJSON `json:"-"` @@ -155,7 +239,7 @@ type PoolNewParams struct { Name param.Field[string] `json:"name,required"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]PoolNewParamsOrigin] `json:"origins,required"` + Origins param.Field[[]OriginParam] `json:"origins,required"` // A human-readable description of the pool. Description param.Field[string] `json:"description"` // Whether to enable (the default) or disable this pool. Disabled pools will not @@ -166,7 +250,7 @@ type PoolNewParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[PoolNewParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -185,218 +269,20 @@ type PoolNewParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[PoolNewParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[PoolNewParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[OriginSteeringParam] `json:"origin_steering"` } func (r PoolNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PoolNewParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[PoolNewParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r PoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type PoolNewParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r PoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures load shedding policies and percentages for the pool. -type PoolNewParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[PoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[PoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r PoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type PoolNewParamsLoadSheddingDefaultPolicy string - -const ( - PoolNewParamsLoadSheddingDefaultPolicyRandom PoolNewParamsLoadSheddingDefaultPolicy = "random" - PoolNewParamsLoadSheddingDefaultPolicyHash PoolNewParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r PoolNewParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case PoolNewParamsLoadSheddingDefaultPolicyRandom, PoolNewParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type PoolNewParamsLoadSheddingSessionPolicy string - -const ( - PoolNewParamsLoadSheddingSessionPolicyHash PoolNewParamsLoadSheddingSessionPolicy = "hash" -) - -func (r PoolNewParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case PoolNewParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type PoolNewParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[PoolNewParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[PoolNewParamsNotificationFilterPool] `json:"pool"` -} - -func (r PoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolNewParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolNewParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type PoolNewParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[PoolNewParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r PoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type PoolNewParamsOriginSteeringPolicy string - -const ( - PoolNewParamsOriginSteeringPolicyRandom PoolNewParamsOriginSteeringPolicy = "random" - PoolNewParamsOriginSteeringPolicyHash PoolNewParamsOriginSteeringPolicy = "hash" - PoolNewParamsOriginSteeringPolicyLeastOutstandingRequests PoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" - PoolNewParamsOriginSteeringPolicyLeastConnections PoolNewParamsOriginSteeringPolicy = "least_connections" -) - -func (r PoolNewParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case PoolNewParamsOriginSteeringPolicyRandom, PoolNewParamsOriginSteeringPolicyHash, PoolNewParamsOriginSteeringPolicyLeastOutstandingRequests, PoolNewParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - type PoolNewResponseEnvelope struct { - Errors []PoolNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolNewResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingPool `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Pool `json:"result,required"` // Whether the API call was successful Success PoolNewResponseEnvelopeSuccess `json:"success,required"` JSON poolNewResponseEnvelopeJSON `json:"-"` @@ -421,52 +307,6 @@ func (r poolNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PoolNewResponseEnvelopeErrors] -type poolNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PoolNewResponseEnvelopeMessages] -type poolNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolNewResponseEnvelopeSuccess bool @@ -490,10 +330,10 @@ type PoolUpdateParams struct { Name param.Field[string] `json:"name,required"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]PoolUpdateParamsOrigin] `json:"origins,required"` + Origins param.Field[[]OriginParam] `json:"origins,required"` // A list of regions from which to run health checks. Null means every Cloudflare // data center. - CheckRegions param.Field[[]PoolUpdateParamsCheckRegion] `json:"check_regions"` + CheckRegions param.Field[[]CheckRegion] `json:"check_regions"` // A human-readable description of the pool. Description param.Field[string] `json:"description"` // Whether to enable (the default) or disable this pool. Disabled pools will not @@ -504,7 +344,7 @@ type PoolUpdateParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[PoolUpdateParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -523,250 +363,20 @@ type PoolUpdateParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[PoolUpdateParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[PoolUpdateParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[OriginSteeringParam] `json:"origin_steering"` } func (r PoolUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PoolUpdateParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[PoolUpdateParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r PoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type PoolUpdateParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r PoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type PoolUpdateParamsCheckRegion string - -const ( - PoolUpdateParamsCheckRegionWnam PoolUpdateParamsCheckRegion = "WNAM" - PoolUpdateParamsCheckRegionEnam PoolUpdateParamsCheckRegion = "ENAM" - PoolUpdateParamsCheckRegionWeu PoolUpdateParamsCheckRegion = "WEU" - PoolUpdateParamsCheckRegionEeu PoolUpdateParamsCheckRegion = "EEU" - PoolUpdateParamsCheckRegionNsam PoolUpdateParamsCheckRegion = "NSAM" - PoolUpdateParamsCheckRegionSsam PoolUpdateParamsCheckRegion = "SSAM" - PoolUpdateParamsCheckRegionOc PoolUpdateParamsCheckRegion = "OC" - PoolUpdateParamsCheckRegionMe PoolUpdateParamsCheckRegion = "ME" - PoolUpdateParamsCheckRegionNaf PoolUpdateParamsCheckRegion = "NAF" - PoolUpdateParamsCheckRegionSaf PoolUpdateParamsCheckRegion = "SAF" - PoolUpdateParamsCheckRegionSas PoolUpdateParamsCheckRegion = "SAS" - PoolUpdateParamsCheckRegionSeas PoolUpdateParamsCheckRegion = "SEAS" - PoolUpdateParamsCheckRegionNeas PoolUpdateParamsCheckRegion = "NEAS" - PoolUpdateParamsCheckRegionAllRegions PoolUpdateParamsCheckRegion = "ALL_REGIONS" -) - -func (r PoolUpdateParamsCheckRegion) IsKnown() bool { - switch r { - case PoolUpdateParamsCheckRegionWnam, PoolUpdateParamsCheckRegionEnam, PoolUpdateParamsCheckRegionWeu, PoolUpdateParamsCheckRegionEeu, PoolUpdateParamsCheckRegionNsam, PoolUpdateParamsCheckRegionSsam, PoolUpdateParamsCheckRegionOc, PoolUpdateParamsCheckRegionMe, PoolUpdateParamsCheckRegionNaf, PoolUpdateParamsCheckRegionSaf, PoolUpdateParamsCheckRegionSas, PoolUpdateParamsCheckRegionSeas, PoolUpdateParamsCheckRegionNeas, PoolUpdateParamsCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type PoolUpdateParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[PoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[PoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r PoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type PoolUpdateParamsLoadSheddingDefaultPolicy string - -const ( - PoolUpdateParamsLoadSheddingDefaultPolicyRandom PoolUpdateParamsLoadSheddingDefaultPolicy = "random" - PoolUpdateParamsLoadSheddingDefaultPolicyHash PoolUpdateParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r PoolUpdateParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case PoolUpdateParamsLoadSheddingDefaultPolicyRandom, PoolUpdateParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type PoolUpdateParamsLoadSheddingSessionPolicy string - -const ( - PoolUpdateParamsLoadSheddingSessionPolicyHash PoolUpdateParamsLoadSheddingSessionPolicy = "hash" -) - -func (r PoolUpdateParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case PoolUpdateParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type PoolUpdateParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[PoolUpdateParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[PoolUpdateParamsNotificationFilterPool] `json:"pool"` -} - -func (r PoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolUpdateParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolUpdateParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type PoolUpdateParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[PoolUpdateParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r PoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type PoolUpdateParamsOriginSteeringPolicy string - -const ( - PoolUpdateParamsOriginSteeringPolicyRandom PoolUpdateParamsOriginSteeringPolicy = "random" - PoolUpdateParamsOriginSteeringPolicyHash PoolUpdateParamsOriginSteeringPolicy = "hash" - PoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests PoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" - PoolUpdateParamsOriginSteeringPolicyLeastConnections PoolUpdateParamsOriginSteeringPolicy = "least_connections" -) - -func (r PoolUpdateParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case PoolUpdateParamsOriginSteeringPolicyRandom, PoolUpdateParamsOriginSteeringPolicyHash, PoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests, PoolUpdateParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - type PoolUpdateResponseEnvelope struct { - Errors []PoolUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolUpdateResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingPool `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Pool `json:"result,required"` // Whether the API call was successful Success PoolUpdateResponseEnvelopeSuccess `json:"success,required"` JSON poolUpdateResponseEnvelopeJSON `json:"-"` @@ -791,52 +401,6 @@ func (r poolUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PoolUpdateResponseEnvelopeErrors] -type poolUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PoolUpdateResponseEnvelopeMessages] -type poolUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolUpdateResponseEnvelopeSuccess bool @@ -863,7 +427,7 @@ type PoolListParams struct { // URLQuery serializes [PoolListParams]'s query parameters as `url.Values`. func (r PoolListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -871,12 +435,17 @@ func (r PoolListParams) URLQuery() (v url.Values) { type PoolDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r PoolDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type PoolDeleteResponseEnvelope struct { - Errors []PoolDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PoolDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PoolDeleteResponse `json:"result,required"` // Whether the API call was successful Success PoolDeleteResponseEnvelopeSuccess `json:"success,required"` JSON poolDeleteResponseEnvelopeJSON `json:"-"` @@ -901,52 +470,6 @@ func (r poolDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PoolDeleteResponseEnvelopeErrors] -type poolDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PoolDeleteResponseEnvelopeMessages] -type poolDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolDeleteResponseEnvelopeSuccess bool @@ -967,7 +490,7 @@ type PoolEditParams struct { AccountID param.Field[string] `path:"account_id,required"` // A list of regions from which to run health checks. Null means every Cloudflare // data center. - CheckRegions param.Field[[]PoolEditParamsCheckRegion] `json:"check_regions"` + CheckRegions param.Field[[]CheckRegion] `json:"check_regions"` // A human-readable description of the pool. Description param.Field[string] `json:"description"` // Whether to enable (the default) or disable this pool. Disabled pools will not @@ -978,7 +501,7 @@ type PoolEditParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[PoolEditParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -1000,253 +523,23 @@ type PoolEditParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[PoolEditParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[PoolEditParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[OriginSteeringParam] `json:"origin_steering"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]PoolEditParamsOrigin] `json:"origins"` + Origins param.Field[[]OriginParam] `json:"origins"` } func (r PoolEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type PoolEditParamsCheckRegion string - -const ( - PoolEditParamsCheckRegionWnam PoolEditParamsCheckRegion = "WNAM" - PoolEditParamsCheckRegionEnam PoolEditParamsCheckRegion = "ENAM" - PoolEditParamsCheckRegionWeu PoolEditParamsCheckRegion = "WEU" - PoolEditParamsCheckRegionEeu PoolEditParamsCheckRegion = "EEU" - PoolEditParamsCheckRegionNsam PoolEditParamsCheckRegion = "NSAM" - PoolEditParamsCheckRegionSsam PoolEditParamsCheckRegion = "SSAM" - PoolEditParamsCheckRegionOc PoolEditParamsCheckRegion = "OC" - PoolEditParamsCheckRegionMe PoolEditParamsCheckRegion = "ME" - PoolEditParamsCheckRegionNaf PoolEditParamsCheckRegion = "NAF" - PoolEditParamsCheckRegionSaf PoolEditParamsCheckRegion = "SAF" - PoolEditParamsCheckRegionSas PoolEditParamsCheckRegion = "SAS" - PoolEditParamsCheckRegionSeas PoolEditParamsCheckRegion = "SEAS" - PoolEditParamsCheckRegionNeas PoolEditParamsCheckRegion = "NEAS" - PoolEditParamsCheckRegionAllRegions PoolEditParamsCheckRegion = "ALL_REGIONS" -) - -func (r PoolEditParamsCheckRegion) IsKnown() bool { - switch r { - case PoolEditParamsCheckRegionWnam, PoolEditParamsCheckRegionEnam, PoolEditParamsCheckRegionWeu, PoolEditParamsCheckRegionEeu, PoolEditParamsCheckRegionNsam, PoolEditParamsCheckRegionSsam, PoolEditParamsCheckRegionOc, PoolEditParamsCheckRegionMe, PoolEditParamsCheckRegionNaf, PoolEditParamsCheckRegionSaf, PoolEditParamsCheckRegionSas, PoolEditParamsCheckRegionSeas, PoolEditParamsCheckRegionNeas, PoolEditParamsCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type PoolEditParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[PoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[PoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r PoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type PoolEditParamsLoadSheddingDefaultPolicy string - -const ( - PoolEditParamsLoadSheddingDefaultPolicyRandom PoolEditParamsLoadSheddingDefaultPolicy = "random" - PoolEditParamsLoadSheddingDefaultPolicyHash PoolEditParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r PoolEditParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case PoolEditParamsLoadSheddingDefaultPolicyRandom, PoolEditParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type PoolEditParamsLoadSheddingSessionPolicy string - -const ( - PoolEditParamsLoadSheddingSessionPolicyHash PoolEditParamsLoadSheddingSessionPolicy = "hash" -) - -func (r PoolEditParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case PoolEditParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type PoolEditParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[PoolEditParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[PoolEditParamsNotificationFilterPool] `json:"pool"` -} - -func (r PoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolEditParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolEditParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type PoolEditParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[PoolEditParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r PoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type PoolEditParamsOriginSteeringPolicy string - -const ( - PoolEditParamsOriginSteeringPolicyRandom PoolEditParamsOriginSteeringPolicy = "random" - PoolEditParamsOriginSteeringPolicyHash PoolEditParamsOriginSteeringPolicy = "hash" - PoolEditParamsOriginSteeringPolicyLeastOutstandingRequests PoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" - PoolEditParamsOriginSteeringPolicyLeastConnections PoolEditParamsOriginSteeringPolicy = "least_connections" -) - -func (r PoolEditParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case PoolEditParamsOriginSteeringPolicyRandom, PoolEditParamsOriginSteeringPolicyHash, PoolEditParamsOriginSteeringPolicyLeastOutstandingRequests, PoolEditParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type PoolEditParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[PoolEditParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r PoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type PoolEditParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r PoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type PoolEditResponseEnvelope struct { - Errors []PoolEditResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolEditResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingPool `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Pool `json:"result,required"` // Whether the API call was successful Success PoolEditResponseEnvelopeSuccess `json:"success,required"` JSON poolEditResponseEnvelopeJSON `json:"-"` @@ -1271,52 +564,6 @@ func (r poolEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PoolEditResponseEnvelopeErrors] -type poolEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PoolEditResponseEnvelopeMessages] -type poolEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolEditResponseEnvelopeSuccess bool @@ -1338,9 +585,9 @@ type PoolGetParams struct { } type PoolGetResponseEnvelope struct { - Errors []PoolGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolGetResponseEnvelopeMessages `json:"messages,required"` - Result user.LoadBalancingPool `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Pool `json:"result,required"` // Whether the API call was successful Success PoolGetResponseEnvelopeSuccess `json:"success,required"` JSON poolGetResponseEnvelopeJSON `json:"-"` @@ -1365,52 +612,6 @@ func (r poolGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PoolGetResponseEnvelopeErrors] -type poolGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PoolGetResponseEnvelopeMessages] -type poolGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolGetResponseEnvelopeSuccess bool diff --git a/load_balancers/pool_test.go b/load_balancers/pool_test.go index 0d0d72f3875..2d164435952 100644 --- a/load_balancers/pool_test.go +++ b/load_balancers/pool_test.go @@ -31,11 +31,11 @@ func TestPoolNewWithOptionalParams(t *testing.T) { _, err := client.LoadBalancers.Pools.New(context.TODO(), load_balancers.PoolNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]load_balancers.PoolNewParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -43,8 +43,8 @@ func TestPoolNewWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -52,8 +52,8 @@ func TestPoolNewWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -62,28 +62,28 @@ func TestPoolNewWithOptionalParams(t *testing.T) { Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(load_balancers.PoolNewParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.PoolNewParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(load_balancers.PoolNewParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(load_balancers.PoolNewParamsNotificationFilter{ - Origin: cloudflare.F(load_balancers.PoolNewParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(load_balancers.PoolNewParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(load_balancers.PoolNewParamsOriginSteering{ - Policy: cloudflare.F(load_balancers.PoolNewParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), }) if err != nil { @@ -115,11 +115,11 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { load_balancers.PoolUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]load_balancers.PoolUpdateParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -127,8 +127,8 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -136,39 +136,39 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), Weight: cloudflare.F(0.600000), }}), - CheckRegions: cloudflare.F([]load_balancers.PoolUpdateParamsCheckRegion{load_balancers.PoolUpdateParamsCheckRegionWeu, load_balancers.PoolUpdateParamsCheckRegionEnam}), + CheckRegions: cloudflare.F([]load_balancers.CheckRegion{load_balancers.CheckRegionWeu, load_balancers.CheckRegionEnam}), Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(load_balancers.PoolUpdateParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.PoolUpdateParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(load_balancers.PoolUpdateParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilter{ - Origin: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(load_balancers.PoolUpdateParamsOriginSteering{ - Policy: cloudflare.F(load_balancers.PoolUpdateParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), }, ) @@ -227,6 +227,7 @@ func TestPoolDelete(t *testing.T) { "17b5962d775c646f3f9725cbc7a53df4", load_balancers.PoolDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -257,39 +258,39 @@ func TestPoolEditWithOptionalParams(t *testing.T) { "17b5962d775c646f3f9725cbc7a53df4", load_balancers.PoolEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - CheckRegions: cloudflare.F([]load_balancers.PoolEditParamsCheckRegion{load_balancers.PoolEditParamsCheckRegionWeu, load_balancers.PoolEditParamsCheckRegionEnam}), + CheckRegions: cloudflare.F([]load_balancers.CheckRegion{load_balancers.CheckRegionWeu, load_balancers.CheckRegionEnam}), Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(load_balancers.PoolEditParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.PoolEditParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(load_balancers.PoolEditParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), Name: cloudflare.F("primary-dc-1"), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(load_balancers.PoolEditParamsNotificationFilter{ - Origin: cloudflare.F(load_balancers.PoolEditParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(load_balancers.PoolEditParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(load_balancers.PoolEditParamsOriginSteering{ - Policy: cloudflare.F(load_balancers.PoolEditParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), - Origins: cloudflare.F([]load_balancers.PoolEditParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -297,8 +298,8 @@ func TestPoolEditWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -306,8 +307,8 @@ func TestPoolEditWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), diff --git a/load_balancers/poolhealth.go b/load_balancers/poolhealth.go index c198eb279e3..a6a7af85312 100644 --- a/load_balancers/poolhealth.go +++ b/load_balancers/poolhealth.go @@ -48,7 +48,7 @@ func (r *PoolHealthService) New(ctx context.Context, poolID string, params PoolH } // Fetch the latest pool health status for a single pool. -func (r *PoolHealthService) Get(ctx context.Context, poolID string, query PoolHealthGetParams, opts ...option.RequestOption) (res *PoolHealthGetResponse, err error) { +func (r *PoolHealthService) Get(ctx context.Context, poolID string, query PoolHealthGetParams, opts ...option.RequestOption) (res *PoolHealthGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PoolHealthGetResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s/health", query.AccountID, poolID) @@ -89,13 +89,13 @@ func (r poolHealthNewResponseJSON) RawJSON() string { // // Union satisfied by [load_balancers.PoolHealthGetResponseUnknown] or // [shared.UnionString]. -type PoolHealthGetResponse interface { - ImplementsLoadBalancersPoolHealthGetResponse() +type PoolHealthGetResponseUnion interface { + ImplementsLoadBalancersPoolHealthGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PoolHealthGetResponse)(nil)).Elem(), + reflect.TypeOf((*PoolHealthGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -169,7 +169,7 @@ type PoolHealthNewParamsType string const ( PoolHealthNewParamsTypeHTTP PoolHealthNewParamsType = "http" PoolHealthNewParamsTypeHTTPS PoolHealthNewParamsType = "https" - PoolHealthNewParamsTypeTcp PoolHealthNewParamsType = "tcp" + PoolHealthNewParamsTypeTCP PoolHealthNewParamsType = "tcp" PoolHealthNewParamsTypeUdpIcmp PoolHealthNewParamsType = "udp_icmp" PoolHealthNewParamsTypeIcmpPing PoolHealthNewParamsType = "icmp_ping" PoolHealthNewParamsTypeSmtp PoolHealthNewParamsType = "smtp" @@ -177,16 +177,16 @@ const ( func (r PoolHealthNewParamsType) IsKnown() bool { switch r { - case PoolHealthNewParamsTypeHTTP, PoolHealthNewParamsTypeHTTPS, PoolHealthNewParamsTypeTcp, PoolHealthNewParamsTypeUdpIcmp, PoolHealthNewParamsTypeIcmpPing, PoolHealthNewParamsTypeSmtp: + case PoolHealthNewParamsTypeHTTP, PoolHealthNewParamsTypeHTTPS, PoolHealthNewParamsTypeTCP, PoolHealthNewParamsTypeUdpIcmp, PoolHealthNewParamsTypeIcmpPing, PoolHealthNewParamsTypeSmtp: return true } return false } type PoolHealthNewResponseEnvelope struct { - Errors []PoolHealthNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolHealthNewResponseEnvelopeMessages `json:"messages,required"` - Result PoolHealthNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PoolHealthNewResponse `json:"result,required"` // Whether the API call was successful Success PoolHealthNewResponseEnvelopeSuccess `json:"success,required"` JSON poolHealthNewResponseEnvelopeJSON `json:"-"` @@ -211,52 +211,6 @@ func (r poolHealthNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolHealthNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolHealthNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolHealthNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PoolHealthNewResponseEnvelopeErrors] -type poolHealthNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolHealthNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolHealthNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolHealthNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolHealthNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolHealthNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PoolHealthNewResponseEnvelopeMessages] -type poolHealthNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolHealthNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolHealthNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolHealthNewResponseEnvelopeSuccess bool @@ -278,11 +232,11 @@ type PoolHealthGetParams struct { } type PoolHealthGetResponseEnvelope struct { - Errors []PoolHealthGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolHealthGetResponseEnvelopeMessages `json:"messages,required"` + 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 PoolHealthGetResponse `json:"result,required"` + Result PoolHealthGetResponseUnion `json:"result,required"` // Whether the API call was successful Success PoolHealthGetResponseEnvelopeSuccess `json:"success,required"` JSON poolHealthGetResponseEnvelopeJSON `json:"-"` @@ -307,52 +261,6 @@ func (r poolHealthGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolHealthGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolHealthGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolHealthGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PoolHealthGetResponseEnvelopeErrors] -type poolHealthGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolHealthGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolHealthGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolHealthGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolHealthGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolHealthGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PoolHealthGetResponseEnvelopeMessages] -type poolHealthGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolHealthGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolHealthGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolHealthGetResponseEnvelopeSuccess bool diff --git a/load_balancers/poolreference.go b/load_balancers/poolreference.go index b884bd0ee7e..a58458f9b83 100644 --- a/load_balancers/poolreference.go +++ b/load_balancers/poolreference.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -93,8 +94,8 @@ type PoolReferenceGetParams struct { } type PoolReferenceGetResponseEnvelope struct { - Errors []PoolReferenceGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PoolReferenceGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // List of resources that reference a given pool. Result []PoolReferenceGetResponse `json:"result,required,nullable"` // Whether the API call was successful @@ -123,52 +124,6 @@ func (r poolReferenceGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PoolReferenceGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolReferenceGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// poolReferenceGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PoolReferenceGetResponseEnvelopeErrors] -type poolReferenceGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolReferenceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolReferenceGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PoolReferenceGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON poolReferenceGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// poolReferenceGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PoolReferenceGetResponseEnvelopeMessages] -type poolReferenceGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolReferenceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolReferenceGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PoolReferenceGetResponseEnvelopeSuccess bool diff --git a/load_balancers/preview.go b/load_balancers/preview.go index 89401ed77ec..8efc9f8d74a 100644 --- a/load_balancers/preview.go +++ b/load_balancers/preview.go @@ -10,8 +10,8 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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/cloudflare/cloudflare-go/v2/user" ) // PreviewService contains methods and other services that help with interacting @@ -32,7 +32,7 @@ func NewPreviewService(opts ...option.RequestOption) (r *PreviewService) { } // Get the result of a previous preview operation using the provided preview_id. -func (r *PreviewService) Get(ctx context.Context, previewID string, query PreviewGetParams, opts ...option.RequestOption) (res *user.LoadBalancingPreview, err error) { +func (r *PreviewService) Get(ctx context.Context, previewID string, query PreviewGetParams, opts ...option.RequestOption) (res *PreviewGetResponse, err error) { opts = append(r.Options[:], opts...) var env PreviewGetResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/preview/%s", query.AccountID, previewID) @@ -44,16 +44,18 @@ func (r *PreviewService) Get(ctx context.Context, previewID string, query Previe return } +type PreviewGetResponse map[string]PreviewGetResponse + type PreviewGetParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` } type PreviewGetResponseEnvelope struct { - Errors []PreviewGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PreviewGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Resulting health data from a preview operation. - Result user.LoadBalancingPreview `json:"result,required"` + Result PreviewGetResponse `json:"result,required"` // Whether the API call was successful Success PreviewGetResponseEnvelopeSuccess `json:"success,required"` JSON previewGetResponseEnvelopeJSON `json:"-"` @@ -78,52 +80,6 @@ func (r previewGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PreviewGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// previewGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PreviewGetResponseEnvelopeErrors] -type previewGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PreviewGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON previewGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// previewGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PreviewGetResponseEnvelopeMessages] -type previewGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r previewGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PreviewGetResponseEnvelopeSuccess bool diff --git a/load_balancers/region.go b/load_balancers/region.go index abff3a0ad09..11438b44492 100644 --- a/load_balancers/region.go +++ b/load_balancers/region.go @@ -36,7 +36,7 @@ func NewRegionService(opts ...option.RequestOption) (r *RegionService) { } // List all region mappings. -func (r *RegionService) List(ctx context.Context, params RegionListParams, opts ...option.RequestOption) (res *RegionListResponse, err error) { +func (r *RegionService) List(ctx context.Context, params RegionListParams, opts ...option.RequestOption) (res *RegionListResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RegionListResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/regions", params.AccountID) @@ -49,7 +49,7 @@ func (r *RegionService) List(ctx context.Context, params RegionListParams, opts } // Get a single region mapping. -func (r *RegionService) Get(ctx context.Context, regionID RegionGetParamsRegionID, query RegionGetParams, opts ...option.RequestOption) (res *RegionGetResponse, err error) { +func (r *RegionService) Get(ctx context.Context, regionID RegionGetParamsRegionID, query RegionGetParams, opts ...option.RequestOption) (res *RegionGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RegionGetResponseEnvelope path := fmt.Sprintf("accounts/%s/load_balancers/regions/%v", query.AccountID, regionID) @@ -63,13 +63,13 @@ func (r *RegionService) Get(ctx context.Context, regionID RegionGetParamsRegionI // Union satisfied by [load_balancers.RegionListResponseUnknown] or // [shared.UnionString]. -type RegionListResponse interface { - ImplementsLoadBalancersRegionListResponse() +type RegionListResponseUnion interface { + ImplementsLoadBalancersRegionListResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RegionListResponse)(nil)).Elem(), + reflect.TypeOf((*RegionListResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -82,13 +82,13 @@ func init() { // // Union satisfied by [load_balancers.RegionGetResponseUnknown] or // [shared.UnionString]. -type RegionGetResponse interface { - ImplementsLoadBalancersRegionGetResponse() +type RegionGetResponseUnion interface { + ImplementsLoadBalancersRegionGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RegionGetResponse)(nil)).Elem(), + reflect.TypeOf((*RegionGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -111,15 +111,15 @@ type RegionListParams struct { // URLQuery serializes [RegionListParams]'s query parameters as `url.Values`. func (r RegionListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type RegionListResponseEnvelope struct { - Errors []RegionListResponseEnvelopeErrors `json:"errors,required"` - Messages []RegionListResponseEnvelopeMessages `json:"messages,required"` - Result RegionListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RegionListResponseUnion `json:"result,required"` // Whether the API call was successful Success RegionListResponseEnvelopeSuccess `json:"success,required"` JSON regionListResponseEnvelopeJSON `json:"-"` @@ -144,52 +144,6 @@ func (r regionListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RegionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// regionListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RegionListResponseEnvelopeErrors] -type regionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RegionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// regionListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RegionListResponseEnvelopeMessages] -type regionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RegionListResponseEnvelopeSuccess bool @@ -242,10 +196,10 @@ func (r RegionGetParamsRegionID) IsKnown() bool { } type RegionGetResponseEnvelope struct { - Errors []RegionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RegionGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A list of countries and subdivisions mapped to a region. - Result RegionGetResponse `json:"result,required"` + Result RegionGetResponseUnion `json:"result,required"` // Whether the API call was successful Success RegionGetResponseEnvelopeSuccess `json:"success,required"` JSON regionGetResponseEnvelopeJSON `json:"-"` @@ -270,52 +224,6 @@ func (r regionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RegionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// regionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RegionGetResponseEnvelopeErrors] -type regionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RegionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON regionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// regionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RegionGetResponseEnvelopeMessages] -type regionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r regionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RegionGetResponseEnvelopeSuccess bool diff --git a/load_balancers/search.go b/load_balancers/search.go index c6c1236b67e..7ea13c99201 100644 --- a/load_balancers/search.go +++ b/load_balancers/search.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -58,7 +59,7 @@ type SearchGetParams struct { // URLQuery serializes [SearchGetParams]'s query parameters as `url.Values`. func (r SearchGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -74,7 +75,7 @@ type SearchGetParamsSearchParams struct { // `url.Values`. func (r SearchGetParamsSearchParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -98,9 +99,9 @@ func (r SearchGetParamsSearchParamsReferences) IsKnown() bool { } type SearchGetResponseEnvelope struct { - Errors []SearchGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SearchGetResponseEnvelopeMessages `json:"messages,required"` - Result []SearchGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SearchGetResponse `json:"result,required,nullable"` // Whether the API call was successful Success SearchGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo SearchGetResponseEnvelopeResultInfo `json:"result_info"` @@ -127,52 +128,6 @@ func (r searchGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SearchGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON searchGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// searchGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SearchGetResponseEnvelopeErrors] -type searchGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SearchGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r searchGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SearchGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON searchGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// searchGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SearchGetResponseEnvelopeMessages] -type searchGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SearchGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r searchGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SearchGetResponseEnvelopeSuccess bool diff --git a/logpush/aliases.go b/logpush/aliases.go index 52ea9e38174..c09f30f272e 100644 --- a/logpush/aliases.go +++ b/logpush/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/logpush/datasetfield.go b/logpush/datasetfield.go index 58f1861bbbc..cbd9333255d 100644 --- a/logpush/datasetfield.go +++ b/logpush/datasetfield.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -64,9 +65,9 @@ type DatasetFieldGetParams struct { } type DatasetFieldGetResponseEnvelope struct { - Errors []DatasetFieldGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DatasetFieldGetResponseEnvelopeMessages `json:"messages,required"` - Result DatasetFieldGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DatasetFieldGetResponse `json:"result,required"` // Whether the API call was successful Success DatasetFieldGetResponseEnvelopeSuccess `json:"success,required"` JSON datasetFieldGetResponseEnvelopeJSON `json:"-"` @@ -91,52 +92,6 @@ func (r datasetFieldGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DatasetFieldGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON datasetFieldGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// datasetFieldGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DatasetFieldGetResponseEnvelopeErrors] -type datasetFieldGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatasetFieldGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r datasetFieldGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DatasetFieldGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON datasetFieldGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// datasetFieldGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DatasetFieldGetResponseEnvelopeMessages] -type datasetFieldGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatasetFieldGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r datasetFieldGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DatasetFieldGetResponseEnvelopeSuccess bool diff --git a/logpush/datasetjob.go b/logpush/datasetjob.go index b988c704979..64746b08f8c 100644 --- a/logpush/datasetjob.go +++ b/logpush/datasetjob.go @@ -6,11 +6,11 @@ import ( "context" "fmt" "net/http" - "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -53,197 +53,6 @@ func (r *DatasetJobService) Get(ctx context.Context, datasetID string, query Dat return } -type LogpushJob struct { - // Unique id of the job. - ID int64 `json:"id"` - // Name of the dataset. - Dataset string `json:"dataset,nullable"` - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf string `json:"destination_conf" format:"uri"` - // Flag that indicates if the job is enabled. - Enabled bool `json:"enabled"` - // If not null, the job is currently failing. Failures are usually repetitive - // (example: no permissions to write to destination bucket). Only the last failure - // is recorded. On successful execution of a job the error_message and last_error - // are set to null. - ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency LogpushJobFrequency `json:"frequency,nullable"` - // Records the last time for which logs have been successfully pushed. If the last - // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z - // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never - // run or has just been enabled and hasn't run yet then the field will be empty. - LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` - // Records the last time the job failed. If not null, the job is currently failing. - // If null, the job has either never failed or has run successfully at least once - // since last failure. See also the error_message field. - LastError time.Time `json:"last_error,nullable" format:"date-time"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` - // Optional human readable job name. Not unique. Cloudflare suggests that you set - // this to a meaningful string, like the domain name, to make it easier to identify - // your job. - Name string `json:"name,nullable"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions LogpushJobOutputOptions `json:"output_options,nullable"` - JSON logpushJobJSON `json:"-"` -} - -// logpushJobJSON contains the JSON metadata for the struct [LogpushJob] -type logpushJobJSON struct { - ID apijson.Field - Dataset apijson.Field - DestinationConf apijson.Field - Enabled apijson.Field - ErrorMessage apijson.Field - Frequency apijson.Field - LastComplete apijson.Field - LastError apijson.Field - LogpullOptions apijson.Field - Name apijson.Field - OutputOptions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJob) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobJSON) RawJSON() string { - return r.raw -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushJobFrequency string - -const ( - LogpushJobFrequencyHigh LogpushJobFrequency = "high" - LogpushJobFrequencyLow LogpushJobFrequency = "low" -) - -func (r LogpushJobFrequency) IsKnown() bool { - switch r { - case LogpushJobFrequencyHigh, LogpushJobFrequencyLow: - return true - } - return false -} - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushJobOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix string `json:"batch_prefix,nullable"` - // String to be appended after each batch. - BatchSuffix string `json:"batch_suffix,nullable"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter string `json:"field_delimiter,nullable"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames []string `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType LogpushJobOutputOptionsOutputType `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter string `json:"record_delimiter,nullable"` - // String to be prepended before each record. - RecordPrefix string `json:"record_prefix,nullable"` - // String to be appended after each record. - RecordSuffix string `json:"record_suffix,nullable"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate string `json:"record_template,nullable"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate float64 `json:"sample_rate,nullable"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat LogpushJobOutputOptionsTimestampFormat `json:"timestamp_format"` - JSON logpushJobOutputOptionsJSON `json:"-"` -} - -// logpushJobOutputOptionsJSON contains the JSON metadata for the struct -// [LogpushJobOutputOptions] -type logpushJobOutputOptionsJSON struct { - BatchPrefix apijson.Field - BatchSuffix apijson.Field - Cve2021_4428 apijson.Field - FieldDelimiter apijson.Field - FieldNames apijson.Field - OutputType apijson.Field - RecordDelimiter apijson.Field - RecordPrefix apijson.Field - RecordSuffix apijson.Field - RecordTemplate apijson.Field - SampleRate apijson.Field - TimestampFormat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobOutputOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobOutputOptionsJSON) RawJSON() string { - return r.raw -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushJobOutputOptionsOutputType string - -const ( - LogpushJobOutputOptionsOutputTypeNdjson LogpushJobOutputOptionsOutputType = "ndjson" - LogpushJobOutputOptionsOutputTypeCsv LogpushJobOutputOptionsOutputType = "csv" -) - -func (r LogpushJobOutputOptionsOutputType) IsKnown() bool { - switch r { - case LogpushJobOutputOptionsOutputTypeNdjson, LogpushJobOutputOptionsOutputTypeCsv: - return true - } - return false -} - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushJobOutputOptionsTimestampFormat string - -const ( - LogpushJobOutputOptionsTimestampFormatUnixnano LogpushJobOutputOptionsTimestampFormat = "unixnano" - LogpushJobOutputOptionsTimestampFormatUnix LogpushJobOutputOptionsTimestampFormat = "unix" - LogpushJobOutputOptionsTimestampFormatRfc3339 LogpushJobOutputOptionsTimestampFormat = "rfc3339" -) - -func (r LogpushJobOutputOptionsTimestampFormat) IsKnown() bool { - switch r { - case LogpushJobOutputOptionsTimestampFormatUnixnano, LogpushJobOutputOptionsTimestampFormatUnix, LogpushJobOutputOptionsTimestampFormatRfc3339: - return true - } - return false -} - type DatasetJobGetParams struct { // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. AccountID param.Field[string] `path:"account_id"` @@ -252,9 +61,9 @@ type DatasetJobGetParams struct { } type DatasetJobGetResponseEnvelope struct { - Errors []DatasetJobGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DatasetJobGetResponseEnvelopeMessages `json:"messages,required"` - Result []LogpushJob `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []LogpushJob `json:"result,required"` // Whether the API call was successful Success DatasetJobGetResponseEnvelopeSuccess `json:"success,required"` JSON datasetJobGetResponseEnvelopeJSON `json:"-"` @@ -279,52 +88,6 @@ func (r datasetJobGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DatasetJobGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON datasetJobGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// datasetJobGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DatasetJobGetResponseEnvelopeErrors] -type datasetJobGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatasetJobGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r datasetJobGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DatasetJobGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON datasetJobGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// datasetJobGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DatasetJobGetResponseEnvelopeMessages] -type datasetJobGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DatasetJobGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r datasetJobGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DatasetJobGetResponseEnvelopeSuccess bool diff --git a/logpush/edge.go b/logpush/edge.go index 5c9b314cdba..695af6949f5 100644 --- a/logpush/edge.go +++ b/logpush/edge.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -108,9 +109,9 @@ func (r EdgeNewParams) MarshalJSON() (data []byte, err error) { } type EdgeNewResponseEnvelope struct { - Errors []EdgeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []EdgeNewResponseEnvelopeMessages `json:"messages,required"` - Result InstantLogpushJob `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result InstantLogpushJob `json:"result,required,nullable"` // Whether the API call was successful Success EdgeNewResponseEnvelopeSuccess `json:"success,required"` JSON edgeNewResponseEnvelopeJSON `json:"-"` @@ -135,52 +136,6 @@ func (r edgeNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type EdgeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON edgeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// edgeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [EdgeNewResponseEnvelopeErrors] -type edgeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EdgeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r edgeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EdgeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON edgeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// edgeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [EdgeNewResponseEnvelopeMessages] -type edgeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EdgeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r edgeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type EdgeNewResponseEnvelopeSuccess bool @@ -202,9 +157,9 @@ type EdgeGetParams struct { } type EdgeGetResponseEnvelope struct { - Errors []EdgeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []EdgeGetResponseEnvelopeMessages `json:"messages,required"` - Result []InstantLogpushJob `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []InstantLogpushJob `json:"result,required"` // Whether the API call was successful Success EdgeGetResponseEnvelopeSuccess `json:"success,required"` JSON edgeGetResponseEnvelopeJSON `json:"-"` @@ -229,52 +184,6 @@ func (r edgeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type EdgeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON edgeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// edgeGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [EdgeGetResponseEnvelopeErrors] -type edgeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EdgeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r edgeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EdgeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON edgeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// edgeGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [EdgeGetResponseEnvelopeMessages] -type edgeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EdgeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r edgeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type EdgeGetResponseEnvelopeSuccess bool diff --git a/logpush/job.go b/logpush/job.go index 2e11a3c149c..c1e5a9866c6 100644 --- a/logpush/job.go +++ b/logpush/job.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "reflect" + "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" @@ -111,17 +112,17 @@ func (r *JobService) ListAutoPaging(ctx context.Context, query JobListParams, op } // Deletes a Logpush job. -func (r *JobService) Delete(ctx context.Context, jobID int64, body JobDeleteParams, opts ...option.RequestOption) (res *JobDeleteResponse, err error) { +func (r *JobService) Delete(ctx context.Context, jobID int64, params JobDeleteParams, opts ...option.RequestOption) (res *JobDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env JobDeleteResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if body.AccountID.Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = body.AccountID + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = body.ZoneID + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/logpush/jobs/%v", accountOrZone, accountOrZoneID, jobID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) @@ -154,82 +155,89 @@ func (r *JobService) Get(ctx context.Context, jobID int64, query JobGetParams, o return } -// Union satisfied by [logpush.JobDeleteResponseUnknown], -// [logpush.JobDeleteResponseArray] or [shared.UnionString]. -type JobDeleteResponse interface { - ImplementsLogpushJobDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*JobDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(JobDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type JobDeleteResponseArray []interface{} - -func (r JobDeleteResponseArray) ImplementsLogpushJobDeleteResponse() {} - -type JobNewParams struct { +type LogpushJob struct { + // Unique id of the job. + ID int64 `json:"id"` + // Name of the dataset. + Dataset string `json:"dataset,nullable"` // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. // Additional configuration parameters supported by the destination may be // included. - DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` - // 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. - ZoneID param.Field[string] `path:"zone_id"` - // Name of the dataset. - Dataset param.Field[string] `json:"dataset"` + DestinationConf string `json:"destination_conf" format:"uri"` // Flag that indicates if the job is enabled. - Enabled param.Field[bool] `json:"enabled"` + Enabled bool `json:"enabled"` + // If not null, the job is currently failing. Failures are usually repetitive + // (example: no permissions to write to destination bucket). Only the last failure + // is recorded. On successful execution of a job the error_message and last_error + // are set to null. + ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` // The frequency at which Cloudflare sends batches of logs to your destination. // Setting frequency to high sends your logs in larger quantities of smaller files. // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency param.Field[JobNewParamsFrequency] `json:"frequency"` + Frequency LogpushJobFrequency `json:"frequency,nullable"` + // Records the last time for which logs have been successfully pushed. If the last + // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z + // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never + // run or has just been enabled and hasn't run yet then the field will be empty. + LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` + // Records the last time the job failed. If not null, the job is currently failing. + // If null, the job has either never failed or has run successfully at least once + // since last failure. See also the error_message field. + LastError time.Time `json:"last_error,nullable" format:"date-time"` // This field is deprecated. Use `output_options` instead. Configuration string. It // specifies things like requested fields and timestamp formats. If migrating from // the logpull api, copy the url (full url or just the query string) of your call // here, and logpush will keep on making this call for you, setting start and end // times appropriately. - LogpullOptions param.Field[string] `json:"logpull_options" format:"uri-reference"` + LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` // Optional human readable job name. Not unique. Cloudflare suggests that you set // this to a meaningful string, like the domain name, to make it easier to identify // your job. - Name param.Field[string] `json:"name"` + Name string `json:"name,nullable"` // The structured replacement for `logpull_options`. When including this field, the // `logpull_option` field will be ignored. - OutputOptions param.Field[JobNewParamsOutputOptions] `json:"output_options"` - // Ownership challenge token to prove destination ownership. - OwnershipChallenge param.Field[string] `json:"ownership_challenge"` + OutputOptions OutputOptions `json:"output_options,nullable"` + JSON logpushJobJSON `json:"-"` +} + +// logpushJobJSON contains the JSON metadata for the struct [LogpushJob] +type logpushJobJSON struct { + ID apijson.Field + Dataset apijson.Field + DestinationConf apijson.Field + Enabled apijson.Field + ErrorMessage apijson.Field + Frequency apijson.Field + LastComplete apijson.Field + LastError apijson.Field + LogpullOptions apijson.Field + Name apijson.Field + OutputOptions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogpushJob) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r JobNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r logpushJobJSON) RawJSON() string { + return r.raw } // The frequency at which Cloudflare sends batches of logs to your destination. // Setting frequency to high sends your logs in larger quantities of smaller files. // Setting frequency to low sends logs in smaller quantities of larger files. -type JobNewParamsFrequency string +type LogpushJobFrequency string const ( - JobNewParamsFrequencyHigh JobNewParamsFrequency = "high" - JobNewParamsFrequencyLow JobNewParamsFrequency = "low" + LogpushJobFrequencyHigh LogpushJobFrequency = "high" + LogpushJobFrequencyLow LogpushJobFrequency = "low" ) -func (r JobNewParamsFrequency) IsKnown() bool { +func (r LogpushJobFrequency) IsKnown() bool { switch r { - case JobNewParamsFrequencyHigh, JobNewParamsFrequencyLow: + case LogpushJobFrequencyHigh, LogpushJobFrequencyLow: return true } return false @@ -237,60 +245,83 @@ func (r JobNewParamsFrequency) IsKnown() bool { // The structured replacement for `logpull_options`. When including this field, the // `logpull_option` field will be ignored. -type JobNewParamsOutputOptions struct { +type OutputOptions struct { // String to be prepended before each batch. - BatchPrefix param.Field[string] `json:"batch_prefix"` + BatchPrefix string `json:"batch_prefix,nullable"` // String to be appended after each batch. - BatchSuffix param.Field[string] `json:"batch_suffix"` + BatchSuffix string `json:"batch_suffix,nullable"` // If set to true, will cause all occurrences of `${` in the generated files to be // replaced with `x{`. - Cve2021_4428 param.Field[bool] `json:"CVE-2021-4428"` + Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter param.Field[string] `json:"field_delimiter"` + FieldDelimiter string `json:"field_delimiter,nullable"` // List of field names to be included in the Logpush output. For the moment, there // is no option to add all fields at once, so you must specify all the fields names // you are interested in. - FieldNames param.Field[[]string] `json:"field_names"` + FieldNames []string `json:"field_names"` // Specifies the output type, such as `ndjson` or `csv`. This sets default values // for the rest of the settings, depending on the chosen output type. Some // formatting rules, like string quoting, are different between output types. - OutputType param.Field[JobNewParamsOutputOptionsOutputType] `json:"output_type"` + OutputType OutputOptionsOutputType `json:"output_type"` // String to be inserted in-between the records as separator. - RecordDelimiter param.Field[string] `json:"record_delimiter"` + RecordDelimiter string `json:"record_delimiter,nullable"` // String to be prepended before each record. - RecordPrefix param.Field[string] `json:"record_prefix"` + RecordPrefix string `json:"record_prefix,nullable"` // String to be appended after each record. - RecordSuffix param.Field[string] `json:"record_suffix"` + RecordSuffix string `json:"record_suffix,nullable"` // String to use as template for each record instead of the default comma-separated // list. All fields used in the template must be present in `field_names` as well, // otherwise they will end up as null. Format as a Go `text/template` without any // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate param.Field[string] `json:"record_template"` + RecordTemplate string `json:"record_template,nullable"` // Floating number to specify sampling rate. Sampling is applied on top of // filtering, and regardless of the current `sample_interval` of the data. - SampleRate param.Field[float64] `json:"sample_rate"` + SampleRate float64 `json:"sample_rate,nullable"` // String to specify the format for timestamps, such as `unixnano`, `unix`, or // `rfc3339`. - TimestampFormat param.Field[JobNewParamsOutputOptionsTimestampFormat] `json:"timestamp_format"` + TimestampFormat OutputOptionsTimestampFormat `json:"timestamp_format"` + JSON outputOptionsJSON `json:"-"` +} + +// outputOptionsJSON contains the JSON metadata for the struct [OutputOptions] +type outputOptionsJSON struct { + BatchPrefix apijson.Field + BatchSuffix apijson.Field + Cve2021_4428 apijson.Field + FieldDelimiter apijson.Field + FieldNames apijson.Field + OutputType apijson.Field + RecordDelimiter apijson.Field + RecordPrefix apijson.Field + RecordSuffix apijson.Field + RecordTemplate apijson.Field + SampleRate apijson.Field + TimestampFormat apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutputOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r JobNewParamsOutputOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r outputOptionsJSON) RawJSON() string { + return r.raw } // Specifies the output type, such as `ndjson` or `csv`. This sets default values // for the rest of the settings, depending on the chosen output type. Some // formatting rules, like string quoting, are different between output types. -type JobNewParamsOutputOptionsOutputType string +type OutputOptionsOutputType string const ( - JobNewParamsOutputOptionsOutputTypeNdjson JobNewParamsOutputOptionsOutputType = "ndjson" - JobNewParamsOutputOptionsOutputTypeCsv JobNewParamsOutputOptionsOutputType = "csv" + OutputOptionsOutputTypeNdjson OutputOptionsOutputType = "ndjson" + OutputOptionsOutputTypeCsv OutputOptionsOutputType = "csv" ) -func (r JobNewParamsOutputOptionsOutputType) IsKnown() bool { +func (r OutputOptionsOutputType) IsKnown() bool { switch r { - case JobNewParamsOutputOptionsOutputTypeNdjson, JobNewParamsOutputOptionsOutputTypeCsv: + case OutputOptionsOutputTypeNdjson, OutputOptionsOutputTypeCsv: return true } return false @@ -298,93 +329,171 @@ func (r JobNewParamsOutputOptionsOutputType) IsKnown() bool { // String to specify the format for timestamps, such as `unixnano`, `unix`, or // `rfc3339`. -type JobNewParamsOutputOptionsTimestampFormat string +type OutputOptionsTimestampFormat string const ( - JobNewParamsOutputOptionsTimestampFormatUnixnano JobNewParamsOutputOptionsTimestampFormat = "unixnano" - JobNewParamsOutputOptionsTimestampFormatUnix JobNewParamsOutputOptionsTimestampFormat = "unix" - JobNewParamsOutputOptionsTimestampFormatRfc3339 JobNewParamsOutputOptionsTimestampFormat = "rfc3339" + OutputOptionsTimestampFormatUnixnano OutputOptionsTimestampFormat = "unixnano" + OutputOptionsTimestampFormatUnix OutputOptionsTimestampFormat = "unix" + OutputOptionsTimestampFormatRfc3339 OutputOptionsTimestampFormat = "rfc3339" ) -func (r JobNewParamsOutputOptionsTimestampFormat) IsKnown() bool { +func (r OutputOptionsTimestampFormat) IsKnown() bool { switch r { - case JobNewParamsOutputOptionsTimestampFormatUnixnano, JobNewParamsOutputOptionsTimestampFormatUnix, JobNewParamsOutputOptionsTimestampFormatRfc3339: + case OutputOptionsTimestampFormatUnixnano, OutputOptionsTimestampFormatUnix, OutputOptionsTimestampFormatRfc3339: return true } return false } -type JobNewResponseEnvelope struct { - Errors []JobNewResponseEnvelopeErrors `json:"errors,required"` - Messages []JobNewResponseEnvelopeMessages `json:"messages,required"` - Result LogpushJob `json:"result,required,nullable"` - // Whether the API call was successful - Success JobNewResponseEnvelopeSuccess `json:"success,required"` - JSON jobNewResponseEnvelopeJSON `json:"-"` +// The structured replacement for `logpull_options`. When including this field, the +// `logpull_option` field will be ignored. +type OutputOptionsParam struct { + // String to be prepended before each batch. + BatchPrefix param.Field[string] `json:"batch_prefix"` + // String to be appended after each batch. + BatchSuffix param.Field[string] `json:"batch_suffix"` + // If set to true, will cause all occurrences of `${` in the generated files to be + // replaced with `x{`. + Cve2021_4428 param.Field[bool] `json:"CVE-2021-4428"` + // String to join fields. This field be ignored when `record_template` is set. + FieldDelimiter param.Field[string] `json:"field_delimiter"` + // List of field names to be included in the Logpush output. For the moment, there + // is no option to add all fields at once, so you must specify all the fields names + // you are interested in. + FieldNames param.Field[[]string] `json:"field_names"` + // Specifies the output type, such as `ndjson` or `csv`. This sets default values + // for the rest of the settings, depending on the chosen output type. Some + // formatting rules, like string quoting, are different between output types. + OutputType param.Field[OutputOptionsOutputType] `json:"output_type"` + // String to be inserted in-between the records as separator. + RecordDelimiter param.Field[string] `json:"record_delimiter"` + // String to be prepended before each record. + RecordPrefix param.Field[string] `json:"record_prefix"` + // String to be appended after each record. + RecordSuffix param.Field[string] `json:"record_suffix"` + // String to use as template for each record instead of the default comma-separated + // list. All fields used in the template must be present in `field_names` as well, + // otherwise they will end up as null. Format as a Go `text/template` without any + // standard functions, like conditionals, loops, sub-templates, etc. + RecordTemplate param.Field[string] `json:"record_template"` + // Floating number to specify sampling rate. Sampling is applied on top of + // filtering, and regardless of the current `sample_interval` of the data. + SampleRate param.Field[float64] `json:"sample_rate"` + // String to specify the format for timestamps, such as `unixnano`, `unix`, or + // `rfc3339`. + TimestampFormat param.Field[OutputOptionsTimestampFormat] `json:"timestamp_format"` } -// jobNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [JobNewResponseEnvelope] -type jobNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r OutputOptionsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *JobNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [logpush.JobDeleteResponseUnknown], +// [logpush.JobDeleteResponseArray] or [shared.UnionString]. +type JobDeleteResponseUnion interface { + ImplementsLogpushJobDeleteResponseUnion() } -func (r jobNewResponseEnvelopeJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*JobDeleteResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JobDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -type JobNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobNewResponseEnvelopeErrorsJSON `json:"-"` -} +type JobDeleteResponseArray []interface{} -// jobNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [JobNewResponseEnvelopeErrors] -type jobNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r JobDeleteResponseArray) ImplementsLogpushJobDeleteResponseUnion() {} + +type JobNewParams struct { + // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. + // Additional configuration parameters supported by the destination may be + // included. + DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` + // 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. + ZoneID param.Field[string] `path:"zone_id"` + // Name of the dataset. + Dataset param.Field[string] `json:"dataset"` + // Flag that indicates if the job is enabled. + Enabled param.Field[bool] `json:"enabled"` + // The frequency at which Cloudflare sends batches of logs to your destination. + // Setting frequency to high sends your logs in larger quantities of smaller files. + // Setting frequency to low sends logs in smaller quantities of larger files. + Frequency param.Field[JobNewParamsFrequency] `json:"frequency"` + // This field is deprecated. Use `output_options` instead. Configuration string. It + // specifies things like requested fields and timestamp formats. If migrating from + // the logpull api, copy the url (full url or just the query string) of your call + // here, and logpush will keep on making this call for you, setting start and end + // times appropriately. + LogpullOptions param.Field[string] `json:"logpull_options" format:"uri-reference"` + // Optional human readable job name. Not unique. Cloudflare suggests that you set + // this to a meaningful string, like the domain name, to make it easier to identify + // your job. + Name param.Field[string] `json:"name"` + // The structured replacement for `logpull_options`. When including this field, the + // `logpull_option` field will be ignored. + OutputOptions param.Field[OutputOptionsParam] `json:"output_options"` + // Ownership challenge token to prove destination ownership. + OwnershipChallenge param.Field[string] `json:"ownership_challenge"` } -func (r *JobNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r JobNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r jobNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw +// The frequency at which Cloudflare sends batches of logs to your destination. +// Setting frequency to high sends your logs in larger quantities of smaller files. +// Setting frequency to low sends logs in smaller quantities of larger files. +type JobNewParamsFrequency string + +const ( + JobNewParamsFrequencyHigh JobNewParamsFrequency = "high" + JobNewParamsFrequencyLow JobNewParamsFrequency = "low" +) + +func (r JobNewParamsFrequency) IsKnown() bool { + switch r { + case JobNewParamsFrequencyHigh, JobNewParamsFrequencyLow: + return true + } + return false } -type JobNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobNewResponseEnvelopeMessagesJSON `json:"-"` +type JobNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LogpushJob `json:"result,required,nullable"` + // Whether the API call was successful + Success JobNewResponseEnvelopeSuccess `json:"success,required"` + JSON jobNewResponseEnvelopeJSON `json:"-"` } -// jobNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [JobNewResponseEnvelopeMessages] -type jobNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field +// jobNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [JobNewResponseEnvelope] +type jobNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *JobNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *JobNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r jobNewResponseEnvelopeMessagesJSON) RawJSON() string { +func (r jobNewResponseEnvelopeJSON) RawJSON() string { return r.raw } @@ -426,7 +535,7 @@ type JobUpdateParams struct { LogpullOptions param.Field[string] `json:"logpull_options" format:"uri-reference"` // The structured replacement for `logpull_options`. When including this field, the // `logpull_option` field will be ignored. - OutputOptions param.Field[JobUpdateParamsOutputOptions] `json:"output_options"` + OutputOptions param.Field[OutputOptionsParam] `json:"output_options"` // Ownership challenge token to prove destination ownership. OwnershipChallenge param.Field[string] `json:"ownership_challenge"` } @@ -453,89 +562,10 @@ func (r JobUpdateParamsFrequency) IsKnown() bool { return false } -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type JobUpdateParamsOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix param.Field[string] `json:"batch_prefix"` - // String to be appended after each batch. - BatchSuffix param.Field[string] `json:"batch_suffix"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 param.Field[bool] `json:"CVE-2021-4428"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter param.Field[string] `json:"field_delimiter"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames param.Field[[]string] `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType param.Field[JobUpdateParamsOutputOptionsOutputType] `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter param.Field[string] `json:"record_delimiter"` - // String to be prepended before each record. - RecordPrefix param.Field[string] `json:"record_prefix"` - // String to be appended after each record. - RecordSuffix param.Field[string] `json:"record_suffix"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate param.Field[string] `json:"record_template"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate param.Field[float64] `json:"sample_rate"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat param.Field[JobUpdateParamsOutputOptionsTimestampFormat] `json:"timestamp_format"` -} - -func (r JobUpdateParamsOutputOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type JobUpdateParamsOutputOptionsOutputType string - -const ( - JobUpdateParamsOutputOptionsOutputTypeNdjson JobUpdateParamsOutputOptionsOutputType = "ndjson" - JobUpdateParamsOutputOptionsOutputTypeCsv JobUpdateParamsOutputOptionsOutputType = "csv" -) - -func (r JobUpdateParamsOutputOptionsOutputType) IsKnown() bool { - switch r { - case JobUpdateParamsOutputOptionsOutputTypeNdjson, JobUpdateParamsOutputOptionsOutputTypeCsv: - return true - } - return false -} - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type JobUpdateParamsOutputOptionsTimestampFormat string - -const ( - JobUpdateParamsOutputOptionsTimestampFormatUnixnano JobUpdateParamsOutputOptionsTimestampFormat = "unixnano" - JobUpdateParamsOutputOptionsTimestampFormatUnix JobUpdateParamsOutputOptionsTimestampFormat = "unix" - JobUpdateParamsOutputOptionsTimestampFormatRfc3339 JobUpdateParamsOutputOptionsTimestampFormat = "rfc3339" -) - -func (r JobUpdateParamsOutputOptionsTimestampFormat) IsKnown() bool { - switch r { - case JobUpdateParamsOutputOptionsTimestampFormatUnixnano, JobUpdateParamsOutputOptionsTimestampFormatUnix, JobUpdateParamsOutputOptionsTimestampFormatRfc3339: - return true - } - return false -} - type JobUpdateResponseEnvelope struct { - Errors []JobUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []JobUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LogpushJob `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LogpushJob `json:"result,required,nullable"` // Whether the API call was successful Success JobUpdateResponseEnvelopeSuccess `json:"success,required"` JSON jobUpdateResponseEnvelopeJSON `json:"-"` @@ -560,52 +590,6 @@ func (r jobUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type JobUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// jobUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [JobUpdateResponseEnvelopeErrors] -type jobUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *JobUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r jobUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type JobUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// jobUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [JobUpdateResponseEnvelopeMessages] -type jobUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *JobUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r jobUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type JobUpdateResponseEnvelopeSuccess bool @@ -629,16 +613,21 @@ type JobListParams struct { } type JobDeleteParams struct { + Body interface{} `json:"body,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. ZoneID param.Field[string] `path:"zone_id"` } +func (r JobDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type JobDeleteResponseEnvelope struct { - Errors []JobDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []JobDeleteResponseEnvelopeMessages `json:"messages,required"` - Result JobDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result JobDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success JobDeleteResponseEnvelopeSuccess `json:"success,required"` JSON jobDeleteResponseEnvelopeJSON `json:"-"` @@ -663,52 +652,6 @@ func (r jobDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type JobDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// jobDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [JobDeleteResponseEnvelopeErrors] -type jobDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *JobDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r jobDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type JobDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// jobDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [JobDeleteResponseEnvelopeMessages] -type jobDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *JobDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r jobDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type JobDeleteResponseEnvelopeSuccess bool @@ -732,9 +675,9 @@ type JobGetParams struct { } type JobGetResponseEnvelope struct { - Errors []JobGetResponseEnvelopeErrors `json:"errors,required"` - Messages []JobGetResponseEnvelopeMessages `json:"messages,required"` - Result LogpushJob `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LogpushJob `json:"result,required,nullable"` // Whether the API call was successful Success JobGetResponseEnvelopeSuccess `json:"success,required"` JSON jobGetResponseEnvelopeJSON `json:"-"` @@ -759,52 +702,6 @@ func (r jobGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type JobGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// jobGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [JobGetResponseEnvelopeErrors] -type jobGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *JobGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r jobGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type JobGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON jobGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// jobGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [JobGetResponseEnvelopeMessages] -type jobGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *JobGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r jobGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type JobGetResponseEnvelopeSuccess bool diff --git a/logpush/job_test.go b/logpush/job_test.go index c918f50736c..b1793153a73 100644 --- a/logpush/job_test.go +++ b/logpush/job_test.go @@ -37,19 +37,19 @@ func TestJobNewWithOptionalParams(t *testing.T) { Frequency: cloudflare.F(logpush.JobNewParamsFrequencyHigh), LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), Name: cloudflare.F("example.com"), - OutputOptions: cloudflare.F(logpush.JobNewParamsOutputOptions{ + OutputOptions: cloudflare.F(logpush.OutputOptionsParam{ Cve2021_4428: cloudflare.F(true), BatchPrefix: cloudflare.F("string"), BatchSuffix: cloudflare.F("string"), FieldDelimiter: cloudflare.F("string"), FieldNames: cloudflare.F([]string{"ClientIP", "EdgeStartTimestamp", "RayID"}), - OutputType: cloudflare.F(logpush.JobNewParamsOutputOptionsOutputTypeNdjson), + OutputType: cloudflare.F(logpush.OutputOptionsOutputTypeNdjson), RecordDelimiter: cloudflare.F("string"), RecordPrefix: cloudflare.F("string"), RecordSuffix: cloudflare.F("string"), RecordTemplate: cloudflare.F("string"), SampleRate: cloudflare.F(0.000000), - TimestampFormat: cloudflare.F(logpush.JobNewParamsOutputOptionsTimestampFormatUnixnano), + TimestampFormat: cloudflare.F(logpush.OutputOptionsTimestampFormatUnixnano), }), OwnershipChallenge: cloudflare.F("00000000000000000000"), }) @@ -86,19 +86,19 @@ func TestJobUpdateWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(false), Frequency: cloudflare.F(logpush.JobUpdateParamsFrequencyHigh), LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), - OutputOptions: cloudflare.F(logpush.JobUpdateParamsOutputOptions{ + OutputOptions: cloudflare.F(logpush.OutputOptionsParam{ Cve2021_4428: cloudflare.F(true), BatchPrefix: cloudflare.F("string"), BatchSuffix: cloudflare.F("string"), FieldDelimiter: cloudflare.F("string"), FieldNames: cloudflare.F([]string{"ClientIP", "EdgeStartTimestamp", "RayID"}), - OutputType: cloudflare.F(logpush.JobUpdateParamsOutputOptionsOutputTypeNdjson), + OutputType: cloudflare.F(logpush.OutputOptionsOutputTypeNdjson), RecordDelimiter: cloudflare.F("string"), RecordPrefix: cloudflare.F("string"), RecordSuffix: cloudflare.F("string"), RecordTemplate: cloudflare.F("string"), SampleRate: cloudflare.F(0.000000), - TimestampFormat: cloudflare.F(logpush.JobUpdateParamsOutputOptionsTimestampFormatUnixnano), + TimestampFormat: cloudflare.F(logpush.OutputOptionsTimestampFormatUnixnano), }), OwnershipChallenge: cloudflare.F("00000000000000000000"), }, @@ -157,6 +157,7 @@ func TestJobDeleteWithOptionalParams(t *testing.T) { context.TODO(), int64(1), logpush.JobDeleteParams{ + Body: map[string]interface{}{}, AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), }, diff --git a/logpush/ownership.go b/logpush/ownership.go index 33f5a74ffa6..f9dacc22297 100644 --- a/logpush/ownership.go +++ b/logpush/ownership.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -53,7 +54,7 @@ func (r *OwnershipService) New(ctx context.Context, params OwnershipNewParams, o } // Validates ownership challenge of the destination. -func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidateParams, opts ...option.RequestOption) (res *OwnershipValidateResponse, err error) { +func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidateParams, opts ...option.RequestOption) (res *OwnershipValidation, err error) { opts = append(r.Options[:], opts...) var env OwnershipValidateResponseEnvelope var accountOrZone string @@ -74,49 +75,49 @@ func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidat return } -type OwnershipNewResponse struct { - Filename string `json:"filename"` - Message string `json:"message"` - Valid bool `json:"valid"` - JSON ownershipNewResponseJSON `json:"-"` +type OwnershipValidation struct { + Valid bool `json:"valid"` + JSON ownershipValidationJSON `json:"-"` } -// ownershipNewResponseJSON contains the JSON metadata for the struct -// [OwnershipNewResponse] -type ownershipNewResponseJSON struct { - Filename apijson.Field - Message apijson.Field +// ownershipValidationJSON contains the JSON metadata for the struct +// [OwnershipValidation] +type ownershipValidationJSON struct { Valid apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *OwnershipNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *OwnershipValidation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ownershipNewResponseJSON) RawJSON() string { +func (r ownershipValidationJSON) RawJSON() string { return r.raw } -type OwnershipValidateResponse struct { - Valid bool `json:"valid"` - JSON ownershipValidateResponseJSON `json:"-"` +type OwnershipNewResponse struct { + Filename string `json:"filename"` + Message string `json:"message"` + Valid bool `json:"valid"` + JSON ownershipNewResponseJSON `json:"-"` } -// ownershipValidateResponseJSON contains the JSON metadata for the struct -// [OwnershipValidateResponse] -type ownershipValidateResponseJSON struct { +// ownershipNewResponseJSON contains the JSON metadata for the struct +// [OwnershipNewResponse] +type ownershipNewResponseJSON struct { + Filename apijson.Field + Message apijson.Field Valid apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *OwnershipValidateResponse) UnmarshalJSON(data []byte) (err error) { +func (r *OwnershipNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ownershipValidateResponseJSON) RawJSON() string { +func (r ownershipNewResponseJSON) RawJSON() string { return r.raw } @@ -136,9 +137,9 @@ func (r OwnershipNewParams) MarshalJSON() (data []byte, err error) { } type OwnershipNewResponseEnvelope struct { - Errors []OwnershipNewResponseEnvelopeErrors `json:"errors,required"` - Messages []OwnershipNewResponseEnvelopeMessages `json:"messages,required"` - Result OwnershipNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OwnershipNewResponse `json:"result,required,nullable"` // Whether the API call was successful Success OwnershipNewResponseEnvelopeSuccess `json:"success,required"` JSON ownershipNewResponseEnvelopeJSON `json:"-"` @@ -163,52 +164,6 @@ func (r ownershipNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OwnershipNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ownershipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [OwnershipNewResponseEnvelopeErrors] -type ownershipNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OwnershipNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ownershipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OwnershipNewResponseEnvelopeMessages] -type ownershipNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OwnershipNewResponseEnvelopeSuccess bool @@ -242,9 +197,9 @@ func (r OwnershipValidateParams) MarshalJSON() (data []byte, err error) { } type OwnershipValidateResponseEnvelope struct { - Errors []OwnershipValidateResponseEnvelopeErrors `json:"errors,required"` - Messages []OwnershipValidateResponseEnvelopeMessages `json:"messages,required"` - Result OwnershipValidateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OwnershipValidation `json:"result,required,nullable"` // Whether the API call was successful Success OwnershipValidateResponseEnvelopeSuccess `json:"success,required"` JSON ownershipValidateResponseEnvelopeJSON `json:"-"` @@ -269,52 +224,6 @@ func (r ownershipValidateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OwnershipValidateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipValidateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ownershipValidateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OwnershipValidateResponseEnvelopeErrors] -type ownershipValidateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipValidateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OwnershipValidateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipValidateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ownershipValidateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OwnershipValidateResponseEnvelopeMessages] -type ownershipValidateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipValidateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OwnershipValidateResponseEnvelopeSuccess bool diff --git a/logpush/validate.go b/logpush/validate.go index 9f3bf77a8a8..4f94b6c22b7 100644 --- a/logpush/validate.go +++ b/logpush/validate.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -134,9 +135,9 @@ func (r ValidateDestinationParams) MarshalJSON() (data []byte, err error) { } type ValidateDestinationResponseEnvelope struct { - Errors []ValidateDestinationResponseEnvelopeErrors `json:"errors,required"` - Messages []ValidateDestinationResponseEnvelopeMessages `json:"messages,required"` - Result ValidateDestinationResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ValidateDestinationResponse `json:"result,required,nullable"` // Whether the API call was successful Success ValidateDestinationResponseEnvelopeSuccess `json:"success,required"` JSON validateDestinationResponseEnvelopeJSON `json:"-"` @@ -161,52 +162,6 @@ func (r validateDestinationResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ValidateDestinationResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON validateDestinationResponseEnvelopeErrorsJSON `json:"-"` -} - -// validateDestinationResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ValidateDestinationResponseEnvelopeErrors] -type validateDestinationResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ValidateDestinationResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r validateDestinationResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ValidateDestinationResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON validateDestinationResponseEnvelopeMessagesJSON `json:"-"` -} - -// validateDestinationResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ValidateDestinationResponseEnvelopeMessages] -type validateDestinationResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ValidateDestinationResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r validateDestinationResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ValidateDestinationResponseEnvelopeSuccess bool @@ -240,9 +195,9 @@ func (r ValidateOriginParams) MarshalJSON() (data []byte, err error) { } type ValidateOriginResponseEnvelope struct { - Errors []ValidateOriginResponseEnvelopeErrors `json:"errors,required"` - Messages []ValidateOriginResponseEnvelopeMessages `json:"messages,required"` - Result ValidateOriginResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ValidateOriginResponse `json:"result,required,nullable"` // Whether the API call was successful Success ValidateOriginResponseEnvelopeSuccess `json:"success,required"` JSON validateOriginResponseEnvelopeJSON `json:"-"` @@ -267,52 +222,6 @@ func (r validateOriginResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ValidateOriginResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON validateOriginResponseEnvelopeErrorsJSON `json:"-"` -} - -// validateOriginResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ValidateOriginResponseEnvelopeErrors] -type validateOriginResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ValidateOriginResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r validateOriginResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ValidateOriginResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON validateOriginResponseEnvelopeMessagesJSON `json:"-"` -} - -// validateOriginResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ValidateOriginResponseEnvelopeMessages] -type validateOriginResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ValidateOriginResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r validateOriginResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ValidateOriginResponseEnvelopeSuccess bool diff --git a/logs/aliases.go b/logs/aliases.go index 3334736a349..925139463c1 100644 --- a/logs/aliases.go +++ b/logs/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/logs/controlcmbconfig.go b/logs/controlcmbconfig.go index b81d0073d27..b66ff77cefb 100644 --- a/logs/controlcmbconfig.go +++ b/logs/controlcmbconfig.go @@ -48,10 +48,10 @@ func (r *ControlCmbConfigService) New(ctx context.Context, params ControlCmbConf } // Deletes CMB config. -func (r *ControlCmbConfigService) Delete(ctx context.Context, body ControlCmbConfigDeleteParams, opts ...option.RequestOption) (res *ControlCmbConfigDeleteResponse, err error) { +func (r *ControlCmbConfigService) Delete(ctx context.Context, params ControlCmbConfigDeleteParams, opts ...option.RequestOption) (res *ControlCmbConfigDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ControlCmbConfigDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", body.AccountID) + path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -94,15 +94,24 @@ func (r cmbConfigJSON) RawJSON() string { return r.raw } +type CmbConfigParam struct { + // Comma-separated list of regions. + Regions param.Field[string] `json:"regions"` +} + +func (r CmbConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Union satisfied by [logs.ControlCmbConfigDeleteResponseUnknown], // [logs.ControlCmbConfigDeleteResponseArray] or [shared.UnionString]. -type ControlCmbConfigDeleteResponse interface { - ImplementsLogsControlCmbConfigDeleteResponse() +type ControlCmbConfigDeleteResponseUnion interface { + ImplementsLogsControlCmbConfigDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ControlCmbConfigDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*ControlCmbConfigDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -117,23 +126,22 @@ func init() { type ControlCmbConfigDeleteResponseArray []interface{} -func (r ControlCmbConfigDeleteResponseArray) ImplementsLogsControlCmbConfigDeleteResponse() {} +func (r ControlCmbConfigDeleteResponseArray) ImplementsLogsControlCmbConfigDeleteResponseUnion() {} type ControlCmbConfigNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` - // Comma-separated list of regions. - Regions param.Field[string] `json:"regions"` + CmbConfig CmbConfigParam `json:"cmb_config,required"` } func (r ControlCmbConfigNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.CmbConfig) } type ControlCmbConfigNewResponseEnvelope struct { - Errors []ControlCmbConfigNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ControlCmbConfigNewResponseEnvelopeMessages `json:"messages,required"` - Result CmbConfig `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CmbConfig `json:"result,required,nullable"` // Whether the API call was successful Success ControlCmbConfigNewResponseEnvelopeSuccess `json:"success,required"` JSON controlCmbConfigNewResponseEnvelopeJSON `json:"-"` @@ -158,52 +166,6 @@ func (r controlCmbConfigNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ControlCmbConfigNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlCmbConfigNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// controlCmbConfigNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ControlCmbConfigNewResponseEnvelopeErrors] -type controlCmbConfigNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlCmbConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlCmbConfigNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ControlCmbConfigNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlCmbConfigNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// controlCmbConfigNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ControlCmbConfigNewResponseEnvelopeMessages] -type controlCmbConfigNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlCmbConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlCmbConfigNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ControlCmbConfigNewResponseEnvelopeSuccess bool @@ -222,12 +184,17 @@ func (r ControlCmbConfigNewResponseEnvelopeSuccess) IsKnown() bool { type ControlCmbConfigDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ControlCmbConfigDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ControlCmbConfigDeleteResponseEnvelope struct { - Errors []ControlCmbConfigDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ControlCmbConfigDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ControlCmbConfigDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ControlCmbConfigDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success ControlCmbConfigDeleteResponseEnvelopeSuccess `json:"success,required"` JSON controlCmbConfigDeleteResponseEnvelopeJSON `json:"-"` @@ -252,52 +219,6 @@ func (r controlCmbConfigDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ControlCmbConfigDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlCmbConfigDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// controlCmbConfigDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ControlCmbConfigDeleteResponseEnvelopeErrors] -type controlCmbConfigDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlCmbConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlCmbConfigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ControlCmbConfigDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlCmbConfigDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// controlCmbConfigDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ControlCmbConfigDeleteResponseEnvelopeMessages] -type controlCmbConfigDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlCmbConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlCmbConfigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ControlCmbConfigDeleteResponseEnvelopeSuccess bool @@ -319,9 +240,9 @@ type ControlCmbConfigGetParams struct { } type ControlCmbConfigGetResponseEnvelope struct { - Errors []ControlCmbConfigGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ControlCmbConfigGetResponseEnvelopeMessages `json:"messages,required"` - Result CmbConfig `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CmbConfig `json:"result,required,nullable"` // Whether the API call was successful Success ControlCmbConfigGetResponseEnvelopeSuccess `json:"success,required"` JSON controlCmbConfigGetResponseEnvelopeJSON `json:"-"` @@ -346,52 +267,6 @@ func (r controlCmbConfigGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ControlCmbConfigGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlCmbConfigGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// controlCmbConfigGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ControlCmbConfigGetResponseEnvelopeErrors] -type controlCmbConfigGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlCmbConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlCmbConfigGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ControlCmbConfigGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlCmbConfigGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// controlCmbConfigGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ControlCmbConfigGetResponseEnvelopeMessages] -type controlCmbConfigGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlCmbConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlCmbConfigGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ControlCmbConfigGetResponseEnvelopeSuccess bool diff --git a/logs/controlcmbconfig_test.go b/logs/controlcmbconfig_test.go index bc9464366ba..adad27d9232 100644 --- a/logs/controlcmbconfig_test.go +++ b/logs/controlcmbconfig_test.go @@ -30,7 +30,9 @@ func TestControlCmbConfigNewWithOptionalParams(t *testing.T) { ) _, err := client.Logs.Control.Cmb.Config.New(context.TODO(), logs.ControlCmbConfigNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Regions: cloudflare.F("eu"), + CmbConfig: logs.CmbConfigParam{ + Regions: cloudflare.F("eu"), + }, }) if err != nil { var apierr *cloudflare.Error @@ -57,6 +59,7 @@ func TestControlCmbConfigDelete(t *testing.T) { ) _, err := client.Logs.Control.Cmb.Config.Delete(context.TODO(), logs.ControlCmbConfigDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/logs/controlretentionflag.go b/logs/controlretentionflag.go index ce014e728e3..72dcc38ab67 100644 --- a/logs/controlretentionflag.go +++ b/logs/controlretentionflag.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -109,9 +110,9 @@ func (r ControlRetentionFlagNewParams) MarshalJSON() (data []byte, err error) { } type ControlRetentionFlagNewResponseEnvelope struct { - Errors []ControlRetentionFlagNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ControlRetentionFlagNewResponseEnvelopeMessages `json:"messages,required"` - Result ControlRetentionFlagNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ControlRetentionFlagNewResponse `json:"result,required"` // Whether the API call was successful Success ControlRetentionFlagNewResponseEnvelopeSuccess `json:"success,required"` JSON controlRetentionFlagNewResponseEnvelopeJSON `json:"-"` @@ -136,52 +137,6 @@ func (r controlRetentionFlagNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ControlRetentionFlagNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlRetentionFlagNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// controlRetentionFlagNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ControlRetentionFlagNewResponseEnvelopeErrors] -type controlRetentionFlagNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlRetentionFlagNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlRetentionFlagNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ControlRetentionFlagNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlRetentionFlagNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// controlRetentionFlagNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ControlRetentionFlagNewResponseEnvelopeMessages] -type controlRetentionFlagNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlRetentionFlagNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlRetentionFlagNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ControlRetentionFlagNewResponseEnvelopeSuccess bool @@ -198,9 +153,9 @@ func (r ControlRetentionFlagNewResponseEnvelopeSuccess) IsKnown() bool { } type ControlRetentionFlagGetResponseEnvelope struct { - Errors []ControlRetentionFlagGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ControlRetentionFlagGetResponseEnvelopeMessages `json:"messages,required"` - Result ControlRetentionFlagGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ControlRetentionFlagGetResponse `json:"result,required"` // Whether the API call was successful Success ControlRetentionFlagGetResponseEnvelopeSuccess `json:"success,required"` JSON controlRetentionFlagGetResponseEnvelopeJSON `json:"-"` @@ -225,52 +180,6 @@ func (r controlRetentionFlagGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ControlRetentionFlagGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlRetentionFlagGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// controlRetentionFlagGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ControlRetentionFlagGetResponseEnvelopeErrors] -type controlRetentionFlagGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlRetentionFlagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlRetentionFlagGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ControlRetentionFlagGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON controlRetentionFlagGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// controlRetentionFlagGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ControlRetentionFlagGetResponseEnvelopeMessages] -type controlRetentionFlagGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ControlRetentionFlagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r controlRetentionFlagGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ControlRetentionFlagGetResponseEnvelopeSuccess bool diff --git a/logs/rayid.go b/logs/rayid.go index 3f9d112d861..4b17d837d42 100644 --- a/logs/rayid.go +++ b/logs/rayid.go @@ -37,7 +37,7 @@ func NewRayIDService(opts ...option.RequestOption) (r *RayIDService) { // The `/rayids` api route allows lookups by specific rayid. The rayids route will // return zero, one, or more records (ray ids are not unique). -func (r *RayIDService) Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query RayIDGetParams, opts ...option.RequestOption) (res *RayIDGetResponse, err error) { +func (r *RayIDService) Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query RayIDGetParams, opts ...option.RequestOption) (res *RayIDGetResponseUnion, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("zones/%s/logs/rayids/%s", zoneIdentifier, rayIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) @@ -45,13 +45,13 @@ func (r *RayIDService) Get(ctx context.Context, zoneIdentifier string, rayIdenti } // Union satisfied by [shared.UnionString] or [logs.RayIDGetResponseUnknown]. -type RayIDGetResponse interface { - ImplementsLogsRayIDGetResponse() +type RayIDGetResponseUnion interface { + ImplementsLogsRayIDGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RayIDGetResponse)(nil)).Elem(), + reflect.TypeOf((*RayIDGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -84,7 +84,7 @@ type RayIDGetParams struct { // URLQuery serializes [RayIDGetParams]'s query parameters as `url.Values`. func (r RayIDGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/logs/received.go b/logs/received.go index 6729ee7f72e..64554496485 100644 --- a/logs/received.go +++ b/logs/received.go @@ -45,7 +45,7 @@ func NewReceivedService(opts ...option.RequestOption) (r *ReceivedService) { // `start=2018-05-20T10:00:00Z&end=2018-05-20T10:01:00Z`, then // `start=2018-05-20T10:01:00Z&end=2018-05-20T10:02:00Z` and so on; the overlap // will be handled properly. -func (r *ReceivedService) Get(ctx context.Context, zoneIdentifier string, query ReceivedGetParams, opts ...option.RequestOption) (res *ReceivedGetResponse, err error) { +func (r *ReceivedService) Get(ctx context.Context, zoneIdentifier string, query ReceivedGetParams, opts ...option.RequestOption) (res *ReceivedGetResponseUnion, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("zones/%s/logs/received", zoneIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) @@ -53,13 +53,13 @@ func (r *ReceivedService) Get(ctx context.Context, zoneIdentifier string, query } // Union satisfied by [shared.UnionString] or [logs.ReceivedGetResponseUnknown]. -type ReceivedGetResponse interface { - ImplementsLogsReceivedGetResponse() +type ReceivedGetResponseUnion interface { + ImplementsLogsReceivedGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ReceivedGetResponse)(nil)).Elem(), + reflect.TypeOf((*ReceivedGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -74,7 +74,7 @@ type ReceivedGetParams struct { // RFC 3339. `end` must be at least five minutes earlier than now and must be later // than `start`. Difference between `start` and `end` must be not greater than one // hour. - End param.Field[ReceivedGetParamsEnd] `query:"end,required"` + End param.Field[ReceivedGetParamsEndUnion] `query:"end,required"` // When `?count=` is provided, the response will contain up to `count` results. // Since results are not sorted, you are likely to get different data for repeated // requests. `count` must be an integer > 0. @@ -104,7 +104,7 @@ type ReceivedGetParams struct { // timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to // RFC 3339. At this point in time, it cannot exceed a time in the past greater // than seven days. - Start param.Field[ReceivedGetParamsStart] `query:"start"` + Start param.Field[ReceivedGetParamsStartUnion] `query:"start"` // By default, timestamps in responses are returned as Unix nanosecond integers. // The `?timestamps=` argument can be set to change the format in which response // timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. @@ -116,7 +116,7 @@ type ReceivedGetParams struct { // URLQuery serializes [ReceivedGetParams]'s query parameters as `url.Values`. func (r ReceivedGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -128,8 +128,8 @@ func (r ReceivedGetParams) URLQuery() (v url.Values) { // hour. // // Satisfied by [shared.UnionString], [shared.UnionInt]. -type ReceivedGetParamsEnd interface { - ImplementsLogsReceivedGetParamsEnd() +type ReceivedGetParamsEndUnion interface { + ImplementsLogsReceivedGetParamsEndUnion() } // Sets the (inclusive) beginning of the requested time frame. This can be a unix @@ -138,8 +138,8 @@ type ReceivedGetParamsEnd interface { // than seven days. // // Satisfied by [shared.UnionString], [shared.UnionInt]. -type ReceivedGetParamsStart interface { - ImplementsLogsReceivedGetParamsStart() +type ReceivedGetParamsStartUnion interface { + ImplementsLogsReceivedGetParamsStartUnion() } // By default, timestamps in responses are returned as Unix nanosecond integers. diff --git a/logs/received_test.go b/logs/received_test.go index f35e41f77eb..9f22f9694fa 100644 --- a/logs/received_test.go +++ b/logs/received_test.go @@ -33,11 +33,11 @@ func TestReceivedGetWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", logs.ReceivedGetParams{ - End: cloudflare.F[logs.ReceivedGetParamsEnd](shared.UnionString("2018-05-20T10:01:00Z")), + End: cloudflare.F[logs.ReceivedGetParamsEndUnion](shared.UnionString("2018-05-20T10:01:00Z")), Count: cloudflare.F(int64(1)), Fields: cloudflare.F("ClientIP,RayID,EdgeStartTimestamp"), Sample: cloudflare.F(0.100000), - Start: cloudflare.F[logs.ReceivedGetParamsStart](shared.UnionString("2018-05-20T10:00:00Z")), + Start: cloudflare.F[logs.ReceivedGetParamsStartUnion](shared.UnionString("2018-05-20T10:00:00Z")), Timestamps: cloudflare.F(logs.ReceivedGetParamsTimestampsUnixnano), }, ) diff --git a/magic_network_monitoring/aliases.go b/magic_network_monitoring/aliases.go index 75655b96e31..65590eee672 100644 --- a/magic_network_monitoring/aliases.go +++ b/magic_network_monitoring/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/magic_network_monitoring/config.go b/magic_network_monitoring/config.go index dad8b6bc0e9..9d68c935aa1 100644 --- a/magic_network_monitoring/config.go +++ b/magic_network_monitoring/config.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,10 +34,10 @@ func NewConfigService(opts ...option.RequestOption) (r *ConfigService) { } // Create a new network monitoring configuration. -func (r *ConfigService) New(ctx context.Context, body ConfigNewParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfig, err error) { +func (r *ConfigService) New(ctx context.Context, params ConfigNewParams, opts ...option.RequestOption) (res *Configuration, err error) { opts = append(r.Options[:], opts...) var env ConfigNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/config", body.AccountID) + path := fmt.Sprintf("accounts/%s/mnm/config", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -47,10 +48,10 @@ func (r *ConfigService) New(ctx context.Context, body ConfigNewParams, opts ...o // Update an existing network monitoring configuration, requires the entire // configuration to be updated at once. -func (r *ConfigService) Update(ctx context.Context, body ConfigUpdateParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfig, err error) { +func (r *ConfigService) Update(ctx context.Context, params ConfigUpdateParams, opts ...option.RequestOption) (res *Configuration, err error) { opts = append(r.Options[:], opts...) var env ConfigUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/config", body.AccountID) + path := fmt.Sprintf("accounts/%s/mnm/config", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) if err != nil { return @@ -60,10 +61,10 @@ func (r *ConfigService) Update(ctx context.Context, body ConfigUpdateParams, opt } // Delete an existing network monitoring configuration. -func (r *ConfigService) Delete(ctx context.Context, body ConfigDeleteParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfig, err error) { +func (r *ConfigService) Delete(ctx context.Context, params ConfigDeleteParams, opts ...option.RequestOption) (res *Configuration, err error) { opts = append(r.Options[:], opts...) var env ConfigDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/config", body.AccountID) + path := fmt.Sprintf("accounts/%s/mnm/config", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -73,10 +74,10 @@ func (r *ConfigService) Delete(ctx context.Context, body ConfigDeleteParams, opt } // Update fields in an existing network monitoring configuration. -func (r *ConfigService) Edit(ctx context.Context, body ConfigEditParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfig, err error) { +func (r *ConfigService) Edit(ctx context.Context, params ConfigEditParams, opts ...option.RequestOption) (res *Configuration, err error) { opts = append(r.Options[:], opts...) var env ConfigEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/config", body.AccountID) + path := fmt.Sprintf("accounts/%s/mnm/config", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) if err != nil { return @@ -86,7 +87,7 @@ func (r *ConfigService) Edit(ctx context.Context, body ConfigEditParams, opts .. } // Lists default sampling and router IPs for account. -func (r *ConfigService) Get(ctx context.Context, query ConfigGetParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfig, err error) { +func (r *ConfigService) Get(ctx context.Context, query ConfigGetParams, opts ...option.RequestOption) (res *Configuration, err error) { opts = append(r.Options[:], opts...) var env ConfigGetResponseEnvelope path := fmt.Sprintf("accounts/%s/mnm/config", query.AccountID) @@ -98,19 +99,18 @@ func (r *ConfigService) Get(ctx context.Context, query ConfigGetParams, opts ... return } -type MagicNetworkMonitoringConfig struct { +type Configuration struct { // Fallback sampling rate of flow messages being sent in packets per second. This // should match the packet sampling rate configured on the router. DefaultSampling float64 `json:"default_sampling,required"` // The account name. - Name string `json:"name,required"` - RouterIPs []string `json:"router_ips,required"` - JSON magicNetworkMonitoringConfigJSON `json:"-"` + Name string `json:"name,required"` + RouterIPs []string `json:"router_ips,required"` + JSON configurationJSON `json:"-"` } -// magicNetworkMonitoringConfigJSON contains the JSON metadata for the struct -// [MagicNetworkMonitoringConfig] -type magicNetworkMonitoringConfigJSON struct { +// configurationJSON contains the JSON metadata for the struct [Configuration] +type configurationJSON struct { DefaultSampling apijson.Field Name apijson.Field RouterIPs apijson.Field @@ -118,22 +118,40 @@ type magicNetworkMonitoringConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *MagicNetworkMonitoringConfig) UnmarshalJSON(data []byte) (err error) { +func (r *Configuration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicNetworkMonitoringConfigJSON) RawJSON() string { +func (r configurationJSON) RawJSON() string { return r.raw } +type ConfigurationParam struct { + // Fallback sampling rate of flow messages being sent in packets per second. This + // should match the packet sampling rate configured on the router. + DefaultSampling param.Field[float64] `json:"default_sampling,required"` + // The account name. + Name param.Field[string] `json:"name,required"` + RouterIPs param.Field[[]string] `json:"router_ips,required"` +} + +func (r ConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type ConfigNewParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ConfigNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ConfigNewResponseEnvelope struct { - Errors []ConfigNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfig `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Configuration `json:"result,required"` // Whether the API call was successful Success ConfigNewResponseEnvelopeSuccess `json:"success,required"` JSON configNewResponseEnvelopeJSON `json:"-"` @@ -158,52 +176,6 @@ func (r configNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// configNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigNewResponseEnvelopeErrors] -type configNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// configNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ConfigNewResponseEnvelopeMessages] -type configNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigNewResponseEnvelopeSuccess bool @@ -221,12 +193,17 @@ func (r ConfigNewResponseEnvelopeSuccess) IsKnown() bool { type ConfigUpdateParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ConfigUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ConfigUpdateResponseEnvelope struct { - Errors []ConfigUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfig `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Configuration `json:"result,required"` // Whether the API call was successful Success ConfigUpdateResponseEnvelopeSuccess `json:"success,required"` JSON configUpdateResponseEnvelopeJSON `json:"-"` @@ -251,52 +228,6 @@ func (r configUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// configUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigUpdateResponseEnvelopeErrors] -type configUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// configUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConfigUpdateResponseEnvelopeMessages] -type configUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigUpdateResponseEnvelopeSuccess bool @@ -314,12 +245,17 @@ func (r ConfigUpdateResponseEnvelopeSuccess) IsKnown() bool { type ConfigDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ConfigDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ConfigDeleteResponseEnvelope struct { - Errors []ConfigDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfig `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Configuration `json:"result,required"` // Whether the API call was successful Success ConfigDeleteResponseEnvelopeSuccess `json:"success,required"` JSON configDeleteResponseEnvelopeJSON `json:"-"` @@ -344,52 +280,6 @@ func (r configDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// configDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigDeleteResponseEnvelopeErrors] -type configDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// configDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConfigDeleteResponseEnvelopeMessages] -type configDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigDeleteResponseEnvelopeSuccess bool @@ -407,12 +297,17 @@ func (r ConfigDeleteResponseEnvelopeSuccess) IsKnown() bool { type ConfigEditParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ConfigEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ConfigEditResponseEnvelope struct { - Errors []ConfigEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigEditResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfig `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Configuration `json:"result,required"` // Whether the API call was successful Success ConfigEditResponseEnvelopeSuccess `json:"success,required"` JSON configEditResponseEnvelopeJSON `json:"-"` @@ -437,52 +332,6 @@ func (r configEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// configEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigEditResponseEnvelopeErrors] -type configEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// configEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ConfigEditResponseEnvelopeMessages] -type configEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigEditResponseEnvelopeSuccess bool @@ -503,9 +352,9 @@ type ConfigGetParams struct { } type ConfigGetResponseEnvelope struct { - Errors []ConfigGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfig `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Configuration `json:"result,required"` // Whether the API call was successful Success ConfigGetResponseEnvelopeSuccess `json:"success,required"` JSON configGetResponseEnvelopeJSON `json:"-"` @@ -530,52 +379,6 @@ func (r configGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// configGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConfigGetResponseEnvelopeErrors] -type configGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// configGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ConfigGetResponseEnvelopeMessages] -type configGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigGetResponseEnvelopeSuccess bool diff --git a/magic_network_monitoring/config_test.go b/magic_network_monitoring/config_test.go index 197f0a18454..7cc445edfb9 100644 --- a/magic_network_monitoring/config_test.go +++ b/magic_network_monitoring/config_test.go @@ -30,6 +30,7 @@ func TestConfigNew(t *testing.T) { ) _, err := client.MagicNetworkMonitoring.Configs.New(context.TODO(), magic_network_monitoring.ConfigNewParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -56,6 +57,7 @@ func TestConfigUpdate(t *testing.T) { ) _, err := client.MagicNetworkMonitoring.Configs.Update(context.TODO(), magic_network_monitoring.ConfigUpdateParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -82,6 +84,7 @@ func TestConfigDelete(t *testing.T) { ) _, err := client.MagicNetworkMonitoring.Configs.Delete(context.TODO(), magic_network_monitoring.ConfigDeleteParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -108,6 +111,7 @@ func TestConfigEdit(t *testing.T) { ) _, err := client.MagicNetworkMonitoring.Configs.Edit(context.TODO(), magic_network_monitoring.ConfigEditParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/magic_network_monitoring/configfull.go b/magic_network_monitoring/configfull.go index 4c0cbf22491..29d06bff158 100644 --- a/magic_network_monitoring/configfull.go +++ b/magic_network_monitoring/configfull.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,7 +32,7 @@ func NewConfigFullService(opts ...option.RequestOption) (r *ConfigFullService) { } // Lists default sampling, router IPs, and rules for account. -func (r *ConfigFullService) Get(ctx context.Context, query ConfigFullGetParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfig, err error) { +func (r *ConfigFullService) Get(ctx context.Context, query ConfigFullGetParams, opts ...option.RequestOption) (res *Configuration, err error) { opts = append(r.Options[:], opts...) var env ConfigFullGetResponseEnvelope path := fmt.Sprintf("accounts/%s/mnm/config/full", query.AccountID) @@ -48,9 +49,9 @@ type ConfigFullGetParams struct { } type ConfigFullGetResponseEnvelope struct { - Errors []ConfigFullGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ConfigFullGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfig `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Configuration `json:"result,required"` // Whether the API call was successful Success ConfigFullGetResponseEnvelopeSuccess `json:"success,required"` JSON configFullGetResponseEnvelopeJSON `json:"-"` @@ -75,52 +76,6 @@ func (r configFullGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConfigFullGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configFullGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// configFullGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ConfigFullGetResponseEnvelopeErrors] -type configFullGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigFullGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configFullGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConfigFullGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON configFullGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// configFullGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConfigFullGetResponseEnvelopeMessages] -type configFullGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConfigFullGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r configFullGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConfigFullGetResponseEnvelopeSuccess bool diff --git a/magic_network_monitoring/rule.go b/magic_network_monitoring/rule.go index bc8264702bf..54f907a8f6e 100644 --- a/magic_network_monitoring/rule.go +++ b/magic_network_monitoring/rule.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -35,10 +36,10 @@ func NewRuleService(opts ...option.RequestOption) (r *RuleService) { // Create network monitoring rules for account. Currently only supports creating a // single rule per API request. -func (r *RuleService) New(ctx context.Context, body RuleNewParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { +func (r *RuleService) New(ctx context.Context, params RuleNewParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { opts = append(r.Options[:], opts...) var env RuleNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/rules", body.AccountID) + path := fmt.Sprintf("accounts/%s/mnm/rules", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -48,10 +49,10 @@ func (r *RuleService) New(ctx context.Context, body RuleNewParams, opts ...optio } // Update network monitoring rules for account. -func (r *RuleService) Update(ctx context.Context, body RuleUpdateParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { +func (r *RuleService) Update(ctx context.Context, params RuleUpdateParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { opts = append(r.Options[:], opts...) var env RuleUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/rules", body.AccountID) + path := fmt.Sprintf("accounts/%s/mnm/rules", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) if err != nil { return @@ -84,10 +85,10 @@ func (r *RuleService) ListAutoPaging(ctx context.Context, query RuleListParams, } // Delete a network monitoring rule for account. -func (r *RuleService) Delete(ctx context.Context, ruleID string, body RuleDeleteParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { +func (r *RuleService) Delete(ctx context.Context, ruleID string, params RuleDeleteParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { opts = append(r.Options[:], opts...) var env RuleDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/rules/%s", body.AccountID, ruleID) + path := fmt.Sprintf("accounts/%s/mnm/rules/%s", params.AccountID, ruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -97,10 +98,10 @@ func (r *RuleService) Delete(ctx context.Context, ruleID string, body RuleDelete } // Update a network monitoring rule for account. -func (r *RuleService) Edit(ctx context.Context, ruleID string, body RuleEditParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { +func (r *RuleService) Edit(ctx context.Context, ruleID string, params RuleEditParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRule, err error) { opts = append(r.Options[:], opts...) var env RuleEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/rules/%s", body.AccountID, ruleID) + path := fmt.Sprintf("accounts/%s/mnm/rules/%s", params.AccountID, ruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) if err != nil { return @@ -138,7 +139,8 @@ type MagicNetworkMonitoringRule struct { // the rule name. Max 256 characters. Name string `json:"name,required"` Prefixes []string `json:"prefixes,required"` - ID string `json:"id"` + // The id of the rule. Must be unique. + ID string `json:"id"` // The number of bits per second for the rule. When this value is exceeded for the // set duration, an alert notification is sent. Minimum of 1 and no maximum. BandwidthThreshold float64 `json:"bandwidth_threshold"` @@ -172,12 +174,17 @@ func (r magicNetworkMonitoringRuleJSON) RawJSON() string { type RuleNewParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type RuleNewResponseEnvelope struct { - Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MagicNetworkMonitoringRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleNewResponseEnvelopeSuccess `json:"success,required"` JSON ruleNewResponseEnvelopeJSON `json:"-"` @@ -202,52 +209,6 @@ func (r ruleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeErrors] -type ruleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeMessages] -type ruleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleNewResponseEnvelopeSuccess bool @@ -265,12 +226,17 @@ func (r RuleNewResponseEnvelopeSuccess) IsKnown() bool { type RuleUpdateParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type RuleUpdateResponseEnvelope struct { - Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MagicNetworkMonitoringRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` JSON ruleUpdateResponseEnvelopeJSON `json:"-"` @@ -295,52 +261,6 @@ func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeErrors] -type ruleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeMessages] -type ruleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleUpdateResponseEnvelopeSuccess bool @@ -362,12 +282,17 @@ type RuleListParams struct { type RuleDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RuleDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type RuleDeleteResponseEnvelope struct { - Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MagicNetworkMonitoringRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON ruleDeleteResponseEnvelopeJSON `json:"-"` @@ -392,52 +317,6 @@ func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeErrors] -type ruleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeMessages] -type ruleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleDeleteResponseEnvelopeSuccess bool @@ -455,12 +334,17 @@ func (r RuleDeleteResponseEnvelopeSuccess) IsKnown() bool { type RuleEditParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RuleEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type RuleEditResponseEnvelope struct { - Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MagicNetworkMonitoringRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleEditResponseEnvelopeSuccess `json:"success,required"` JSON ruleEditResponseEnvelopeJSON `json:"-"` @@ -485,52 +369,6 @@ func (r ruleEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleEditResponseEnvelopeErrors] -type ruleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleEditResponseEnvelopeMessages] -type ruleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleEditResponseEnvelopeSuccess bool @@ -551,9 +389,9 @@ type RuleGetParams struct { } type RuleGetResponseEnvelope struct { - Errors []RuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MagicNetworkMonitoringRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleGetResponseEnvelopeSuccess `json:"success,required"` JSON ruleGetResponseEnvelopeJSON `json:"-"` @@ -578,52 +416,6 @@ func (r ruleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleGetResponseEnvelopeErrors] -type ruleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleGetResponseEnvelopeMessages] -type ruleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleGetResponseEnvelopeSuccess bool diff --git a/magic_network_monitoring/rule_test.go b/magic_network_monitoring/rule_test.go index eceda1f762d..711b273f820 100644 --- a/magic_network_monitoring/rule_test.go +++ b/magic_network_monitoring/rule_test.go @@ -30,6 +30,7 @@ func TestRuleNew(t *testing.T) { ) _, err := client.MagicNetworkMonitoring.Rules.New(context.TODO(), magic_network_monitoring.RuleNewParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -56,6 +57,7 @@ func TestRuleUpdate(t *testing.T) { ) _, err := client.MagicNetworkMonitoring.Rules.Update(context.TODO(), magic_network_monitoring.RuleUpdateParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -111,6 +113,7 @@ func TestRuleDelete(t *testing.T) { "2890e6fa406311ed9b5a23f70f6fb8cf", magic_network_monitoring.RuleDeleteParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -141,6 +144,7 @@ func TestRuleEdit(t *testing.T) { "2890e6fa406311ed9b5a23f70f6fb8cf", magic_network_monitoring.RuleEditParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_network_monitoring/ruleadvertisement.go b/magic_network_monitoring/ruleadvertisement.go index 97b69a97c7d..a3ccf7f6bf9 100644 --- a/magic_network_monitoring/ruleadvertisement.go +++ b/magic_network_monitoring/ruleadvertisement.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,10 +33,10 @@ func NewRuleAdvertisementService(opts ...option.RequestOption) (r *RuleAdvertise } // Update advertisement for rule. -func (r *RuleAdvertisementService) Edit(ctx context.Context, ruleID string, body RuleAdvertisementEditParams, opts ...option.RequestOption) (res *MagicNetworkMonitoringRuleAdvertisable, err error) { +func (r *RuleAdvertisementService) Edit(ctx context.Context, ruleID string, params RuleAdvertisementEditParams, opts ...option.RequestOption) (res *Advertisement, err error) { opts = append(r.Options[:], opts...) var env RuleAdvertisementEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/mnm/rules/%s/advertisement", body.AccountID, ruleID) + path := fmt.Sprintf("accounts/%s/mnm/rules/%s/advertisement", params.AccountID, ruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) if err != nil { return @@ -44,38 +45,42 @@ func (r *RuleAdvertisementService) Edit(ctx context.Context, ruleID string, body return } -type MagicNetworkMonitoringRuleAdvertisable struct { +type Advertisement struct { // Toggle on if you would like Cloudflare to automatically advertise the IP // Prefixes within the rule via Magic Transit when the rule is triggered. Only // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - JSON magicNetworkMonitoringRuleAdvertisableJSON `json:"-"` + AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` + JSON advertisementJSON `json:"-"` } -// magicNetworkMonitoringRuleAdvertisableJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringRuleAdvertisable] -type magicNetworkMonitoringRuleAdvertisableJSON struct { +// advertisementJSON contains the JSON metadata for the struct [Advertisement] +type advertisementJSON struct { AutomaticAdvertisement apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *MagicNetworkMonitoringRuleAdvertisable) UnmarshalJSON(data []byte) (err error) { +func (r *Advertisement) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicNetworkMonitoringRuleAdvertisableJSON) RawJSON() string { +func (r advertisementJSON) RawJSON() string { return r.raw } type RuleAdvertisementEditParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RuleAdvertisementEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type RuleAdvertisementEditResponseEnvelope struct { - Errors []RuleAdvertisementEditResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleAdvertisementEditResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRuleAdvertisable `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Advertisement `json:"result,required,nullable"` // Whether the API call was successful Success RuleAdvertisementEditResponseEnvelopeSuccess `json:"success,required"` JSON ruleAdvertisementEditResponseEnvelopeJSON `json:"-"` @@ -100,52 +105,6 @@ func (r ruleAdvertisementEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleAdvertisementEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleAdvertisementEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleAdvertisementEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RuleAdvertisementEditResponseEnvelopeErrors] -type ruleAdvertisementEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleAdvertisementEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleAdvertisementEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleAdvertisementEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleAdvertisementEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleAdvertisementEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RuleAdvertisementEditResponseEnvelopeMessages] -type ruleAdvertisementEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleAdvertisementEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleAdvertisementEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleAdvertisementEditResponseEnvelopeSuccess bool diff --git a/magic_network_monitoring/ruleadvertisement_test.go b/magic_network_monitoring/ruleadvertisement_test.go index 6a7b88379fc..dfe6f09bd81 100644 --- a/magic_network_monitoring/ruleadvertisement_test.go +++ b/magic_network_monitoring/ruleadvertisement_test.go @@ -33,6 +33,7 @@ func TestRuleAdvertisementEdit(t *testing.T) { "2890e6fa406311ed9b5a23f70f6fb8cf", magic_network_monitoring.RuleAdvertisementEditParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_transit/aliases.go b/magic_transit/aliases.go index ae398efd64c..69db7642805 100644 --- a/magic_transit/aliases.go +++ b/magic_transit/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/magic_transit/cfinterconnect.go b/magic_transit/cfinterconnect.go index 12328e5ba95..02d3c17f6e6 100644 --- a/magic_transit/cfinterconnect.go +++ b/magic_transit/cfinterconnect.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -196,13 +197,13 @@ type CfInterconnectListResponseInterconnectsHealthCheck struct { // Determines whether to run healthchecks for a tunnel. Enabled bool `json:"enabled"` // How frequent the health check is run. The default value is `mid`. - Rate CfInterconnectListResponseInterconnectsHealthCheckRate `json:"rate"` + Rate HealthCheckRate `json:"rate"` // The destination address in a request type health check. After the healthcheck is // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded // to this address. This field defaults to `customer_gre_endpoint address`. Target string `json:"target"` // The type of healthcheck to run, reply or request. The default value is `reply`. - Type CfInterconnectListResponseInterconnectsHealthCheckType `json:"type"` + Type HealthCheckType `json:"type"` JSON cfInterconnectListResponseInterconnectsHealthCheckJSON `json:"-"` } @@ -225,39 +226,6 @@ func (r cfInterconnectListResponseInterconnectsHealthCheckJSON) RawJSON() string return r.raw } -// How frequent the health check is run. The default value is `mid`. -type CfInterconnectListResponseInterconnectsHealthCheckRate string - -const ( - CfInterconnectListResponseInterconnectsHealthCheckRateLow CfInterconnectListResponseInterconnectsHealthCheckRate = "low" - CfInterconnectListResponseInterconnectsHealthCheckRateMid CfInterconnectListResponseInterconnectsHealthCheckRate = "mid" - CfInterconnectListResponseInterconnectsHealthCheckRateHigh CfInterconnectListResponseInterconnectsHealthCheckRate = "high" -) - -func (r CfInterconnectListResponseInterconnectsHealthCheckRate) IsKnown() bool { - switch r { - case CfInterconnectListResponseInterconnectsHealthCheckRateLow, CfInterconnectListResponseInterconnectsHealthCheckRateMid, CfInterconnectListResponseInterconnectsHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type CfInterconnectListResponseInterconnectsHealthCheckType string - -const ( - CfInterconnectListResponseInterconnectsHealthCheckTypeReply CfInterconnectListResponseInterconnectsHealthCheckType = "reply" - CfInterconnectListResponseInterconnectsHealthCheckTypeRequest CfInterconnectListResponseInterconnectsHealthCheckType = "request" -) - -func (r CfInterconnectListResponseInterconnectsHealthCheckType) IsKnown() bool { - switch r { - case CfInterconnectListResponseInterconnectsHealthCheckTypeReply, CfInterconnectListResponseInterconnectsHealthCheckTypeRequest: - return true - } - return false -} - type CfInterconnectGetResponse struct { Interconnect interface{} `json:"interconnect"` JSON cfInterconnectGetResponseJSON `json:"-"` @@ -315,56 +283,23 @@ type CfInterconnectUpdateParamsHealthCheck struct { // Determines whether to run healthchecks for a tunnel. Enabled param.Field[bool] `json:"enabled"` // How frequent the health check is run. The default value is `mid`. - Rate param.Field[CfInterconnectUpdateParamsHealthCheckRate] `json:"rate"` + Rate param.Field[HealthCheckRate] `json:"rate"` // The destination address in a request type health check. After the healthcheck is // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded // to this address. This field defaults to `customer_gre_endpoint address`. Target param.Field[string] `json:"target"` // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[CfInterconnectUpdateParamsHealthCheckType] `json:"type"` + Type param.Field[HealthCheckType] `json:"type"` } func (r CfInterconnectUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// How frequent the health check is run. The default value is `mid`. -type CfInterconnectUpdateParamsHealthCheckRate string - -const ( - CfInterconnectUpdateParamsHealthCheckRateLow CfInterconnectUpdateParamsHealthCheckRate = "low" - CfInterconnectUpdateParamsHealthCheckRateMid CfInterconnectUpdateParamsHealthCheckRate = "mid" - CfInterconnectUpdateParamsHealthCheckRateHigh CfInterconnectUpdateParamsHealthCheckRate = "high" -) - -func (r CfInterconnectUpdateParamsHealthCheckRate) IsKnown() bool { - switch r { - case CfInterconnectUpdateParamsHealthCheckRateLow, CfInterconnectUpdateParamsHealthCheckRateMid, CfInterconnectUpdateParamsHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type CfInterconnectUpdateParamsHealthCheckType string - -const ( - CfInterconnectUpdateParamsHealthCheckTypeReply CfInterconnectUpdateParamsHealthCheckType = "reply" - CfInterconnectUpdateParamsHealthCheckTypeRequest CfInterconnectUpdateParamsHealthCheckType = "request" -) - -func (r CfInterconnectUpdateParamsHealthCheckType) IsKnown() bool { - switch r { - case CfInterconnectUpdateParamsHealthCheckTypeReply, CfInterconnectUpdateParamsHealthCheckTypeRequest: - return true - } - return false -} - type CfInterconnectUpdateResponseEnvelope struct { - Errors []CfInterconnectUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CfInterconnectUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CfInterconnectUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CfInterconnectUpdateResponse `json:"result,required"` // Whether the API call was successful Success CfInterconnectUpdateResponseEnvelopeSuccess `json:"success,required"` JSON cfInterconnectUpdateResponseEnvelopeJSON `json:"-"` @@ -389,52 +324,6 @@ func (r cfInterconnectUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CfInterconnectUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cfInterconnectUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// cfInterconnectUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CfInterconnectUpdateResponseEnvelopeErrors] -type cfInterconnectUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CfInterconnectUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cfInterconnectUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CfInterconnectUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cfInterconnectUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// cfInterconnectUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CfInterconnectUpdateResponseEnvelopeMessages] -type cfInterconnectUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CfInterconnectUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cfInterconnectUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CfInterconnectUpdateResponseEnvelopeSuccess bool @@ -456,9 +345,9 @@ type CfInterconnectListParams struct { } type CfInterconnectListResponseEnvelope struct { - Errors []CfInterconnectListResponseEnvelopeErrors `json:"errors,required"` - Messages []CfInterconnectListResponseEnvelopeMessages `json:"messages,required"` - Result CfInterconnectListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CfInterconnectListResponse `json:"result,required"` // Whether the API call was successful Success CfInterconnectListResponseEnvelopeSuccess `json:"success,required"` JSON cfInterconnectListResponseEnvelopeJSON `json:"-"` @@ -483,52 +372,6 @@ func (r cfInterconnectListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CfInterconnectListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cfInterconnectListResponseEnvelopeErrorsJSON `json:"-"` -} - -// cfInterconnectListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CfInterconnectListResponseEnvelopeErrors] -type cfInterconnectListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CfInterconnectListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cfInterconnectListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CfInterconnectListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cfInterconnectListResponseEnvelopeMessagesJSON `json:"-"` -} - -// cfInterconnectListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CfInterconnectListResponseEnvelopeMessages] -type cfInterconnectListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CfInterconnectListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cfInterconnectListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CfInterconnectListResponseEnvelopeSuccess bool @@ -550,9 +393,9 @@ type CfInterconnectGetParams struct { } type CfInterconnectGetResponseEnvelope struct { - Errors []CfInterconnectGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CfInterconnectGetResponseEnvelopeMessages `json:"messages,required"` - Result CfInterconnectGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CfInterconnectGetResponse `json:"result,required"` // Whether the API call was successful Success CfInterconnectGetResponseEnvelopeSuccess `json:"success,required"` JSON cfInterconnectGetResponseEnvelopeJSON `json:"-"` @@ -577,52 +420,6 @@ func (r cfInterconnectGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CfInterconnectGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cfInterconnectGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cfInterconnectGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CfInterconnectGetResponseEnvelopeErrors] -type cfInterconnectGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CfInterconnectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cfInterconnectGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CfInterconnectGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cfInterconnectGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cfInterconnectGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CfInterconnectGetResponseEnvelopeMessages] -type cfInterconnectGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CfInterconnectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cfInterconnectGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CfInterconnectGetResponseEnvelopeSuccess bool diff --git a/magic_transit/cfinterconnect_test.go b/magic_transit/cfinterconnect_test.go index 5d515e5cd1a..49df094f77f 100644 --- a/magic_transit/cfinterconnect_test.go +++ b/magic_transit/cfinterconnect_test.go @@ -39,9 +39,9 @@ func TestCfInterconnectUpdateWithOptionalParams(t *testing.T) { }), HealthCheck: cloudflare.F(magic_transit.CfInterconnectUpdateParamsHealthCheck{ Enabled: cloudflare.F(true), - Rate: cloudflare.F(magic_transit.CfInterconnectUpdateParamsHealthCheckRateLow), + Rate: cloudflare.F(magic_transit.HealthCheckRateLow), Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(magic_transit.CfInterconnectUpdateParamsHealthCheckTypeRequest), + Type: cloudflare.F(magic_transit.HealthCheckTypeRequest), }), InterfaceAddress: cloudflare.F("192.0.2.0/31"), Mtu: cloudflare.F(int64(0)), diff --git a/magic_transit/gretunnel.go b/magic_transit/gretunnel.go index a88581ad2ab..7e522ece0e5 100644 --- a/magic_transit/gretunnel.go +++ b/magic_transit/gretunnel.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -74,10 +75,10 @@ func (r *GRETunnelService) List(ctx context.Context, query GRETunnelListParams, // Disables and removes a specific static GRE tunnel. Use `?validate_only=true` as // an optional query parameter to only run validation without persisting changes. -func (r *GRETunnelService) Delete(ctx context.Context, tunnelIdentifier string, body GRETunnelDeleteParams, opts ...option.RequestOption) (res *GRETunnelDeleteResponse, err error) { +func (r *GRETunnelService) Delete(ctx context.Context, tunnelIdentifier string, params GRETunnelDeleteParams, opts ...option.RequestOption) (res *GRETunnelDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env GRETunnelDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", body.AccountID, tunnelIdentifier) + path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", params.AccountID, tunnelIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -137,8 +138,8 @@ type GRETunnelNewResponseGRETunnel struct { // The date and time the tunnel was created. CreatedOn time.Time `json:"created_on" format:"date-time"` // An optional description of the GRE tunnel. - Description string `json:"description"` - HealthCheck GRETunnelNewResponseGRETunnelsHealthCheck `json:"health_check"` + Description string `json:"description"` + HealthCheck HealthCheck `json:"health_check"` // The date and time the tunnel was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value @@ -175,103 +176,6 @@ func (r greTunnelNewResponseGRETunnelJSON) RawJSON() string { return r.raw } -type GRETunnelNewResponseGRETunnelsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction GRETunnelNewResponseGRETunnelsHealthCheckDirection `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled bool `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate GRETunnelNewResponseGRETunnelsHealthCheckRate `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target string `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type GRETunnelNewResponseGRETunnelsHealthCheckType `json:"type"` - JSON greTunnelNewResponseGRETunnelsHealthCheckJSON `json:"-"` -} - -// greTunnelNewResponseGRETunnelsHealthCheckJSON contains the JSON metadata for the -// struct [GRETunnelNewResponseGRETunnelsHealthCheck] -type greTunnelNewResponseGRETunnelsHealthCheckJSON struct { - Direction apijson.Field - Enabled apijson.Field - Rate apijson.Field - Target apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelNewResponseGRETunnelsHealthCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelNewResponseGRETunnelsHealthCheckJSON) RawJSON() string { - return r.raw -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type GRETunnelNewResponseGRETunnelsHealthCheckDirection string - -const ( - GRETunnelNewResponseGRETunnelsHealthCheckDirectionUnidirectional GRETunnelNewResponseGRETunnelsHealthCheckDirection = "unidirectional" - GRETunnelNewResponseGRETunnelsHealthCheckDirectionBidirectional GRETunnelNewResponseGRETunnelsHealthCheckDirection = "bidirectional" -) - -func (r GRETunnelNewResponseGRETunnelsHealthCheckDirection) IsKnown() bool { - switch r { - case GRETunnelNewResponseGRETunnelsHealthCheckDirectionUnidirectional, GRETunnelNewResponseGRETunnelsHealthCheckDirectionBidirectional: - return true - } - return false -} - -// How frequent the health check is run. The default value is `mid`. -type GRETunnelNewResponseGRETunnelsHealthCheckRate string - -const ( - GRETunnelNewResponseGRETunnelsHealthCheckRateLow GRETunnelNewResponseGRETunnelsHealthCheckRate = "low" - GRETunnelNewResponseGRETunnelsHealthCheckRateMid GRETunnelNewResponseGRETunnelsHealthCheckRate = "mid" - GRETunnelNewResponseGRETunnelsHealthCheckRateHigh GRETunnelNewResponseGRETunnelsHealthCheckRate = "high" -) - -func (r GRETunnelNewResponseGRETunnelsHealthCheckRate) IsKnown() bool { - switch r { - case GRETunnelNewResponseGRETunnelsHealthCheckRateLow, GRETunnelNewResponseGRETunnelsHealthCheckRateMid, GRETunnelNewResponseGRETunnelsHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type GRETunnelNewResponseGRETunnelsHealthCheckType string - -const ( - GRETunnelNewResponseGRETunnelsHealthCheckTypeReply GRETunnelNewResponseGRETunnelsHealthCheckType = "reply" - GRETunnelNewResponseGRETunnelsHealthCheckTypeRequest GRETunnelNewResponseGRETunnelsHealthCheckType = "request" -) - -func (r GRETunnelNewResponseGRETunnelsHealthCheckType) IsKnown() bool { - switch r { - case GRETunnelNewResponseGRETunnelsHealthCheckTypeReply, GRETunnelNewResponseGRETunnelsHealthCheckTypeRequest: - return true - } - return false -} - type GRETunnelUpdateResponse struct { Modified bool `json:"modified"` ModifiedGRETunnel interface{} `json:"modified_gre_tunnel"` @@ -333,8 +237,8 @@ type GRETunnelListResponseGRETunnel struct { // The date and time the tunnel was created. CreatedOn time.Time `json:"created_on" format:"date-time"` // An optional description of the GRE tunnel. - Description string `json:"description"` - HealthCheck GRETunnelListResponseGRETunnelsHealthCheck `json:"health_check"` + Description string `json:"description"` + HealthCheck HealthCheck `json:"health_check"` // The date and time the tunnel was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value @@ -371,103 +275,6 @@ func (r greTunnelListResponseGRETunnelJSON) RawJSON() string { return r.raw } -type GRETunnelListResponseGRETunnelsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction GRETunnelListResponseGRETunnelsHealthCheckDirection `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled bool `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate GRETunnelListResponseGRETunnelsHealthCheckRate `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target string `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type GRETunnelListResponseGRETunnelsHealthCheckType `json:"type"` - JSON greTunnelListResponseGRETunnelsHealthCheckJSON `json:"-"` -} - -// greTunnelListResponseGRETunnelsHealthCheckJSON contains the JSON metadata for -// the struct [GRETunnelListResponseGRETunnelsHealthCheck] -type greTunnelListResponseGRETunnelsHealthCheckJSON struct { - Direction apijson.Field - Enabled apijson.Field - Rate apijson.Field - Target apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelListResponseGRETunnelsHealthCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelListResponseGRETunnelsHealthCheckJSON) RawJSON() string { - return r.raw -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type GRETunnelListResponseGRETunnelsHealthCheckDirection string - -const ( - GRETunnelListResponseGRETunnelsHealthCheckDirectionUnidirectional GRETunnelListResponseGRETunnelsHealthCheckDirection = "unidirectional" - GRETunnelListResponseGRETunnelsHealthCheckDirectionBidirectional GRETunnelListResponseGRETunnelsHealthCheckDirection = "bidirectional" -) - -func (r GRETunnelListResponseGRETunnelsHealthCheckDirection) IsKnown() bool { - switch r { - case GRETunnelListResponseGRETunnelsHealthCheckDirectionUnidirectional, GRETunnelListResponseGRETunnelsHealthCheckDirectionBidirectional: - return true - } - return false -} - -// How frequent the health check is run. The default value is `mid`. -type GRETunnelListResponseGRETunnelsHealthCheckRate string - -const ( - GRETunnelListResponseGRETunnelsHealthCheckRateLow GRETunnelListResponseGRETunnelsHealthCheckRate = "low" - GRETunnelListResponseGRETunnelsHealthCheckRateMid GRETunnelListResponseGRETunnelsHealthCheckRate = "mid" - GRETunnelListResponseGRETunnelsHealthCheckRateHigh GRETunnelListResponseGRETunnelsHealthCheckRate = "high" -) - -func (r GRETunnelListResponseGRETunnelsHealthCheckRate) IsKnown() bool { - switch r { - case GRETunnelListResponseGRETunnelsHealthCheckRateLow, GRETunnelListResponseGRETunnelsHealthCheckRateMid, GRETunnelListResponseGRETunnelsHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type GRETunnelListResponseGRETunnelsHealthCheckType string - -const ( - GRETunnelListResponseGRETunnelsHealthCheckTypeReply GRETunnelListResponseGRETunnelsHealthCheckType = "reply" - GRETunnelListResponseGRETunnelsHealthCheckTypeRequest GRETunnelListResponseGRETunnelsHealthCheckType = "request" -) - -func (r GRETunnelListResponseGRETunnelsHealthCheckType) IsKnown() bool { - switch r { - case GRETunnelListResponseGRETunnelsHealthCheckTypeReply, GRETunnelListResponseGRETunnelsHealthCheckTypeRequest: - return true - } - return false -} - type GRETunnelDeleteResponse struct { Deleted bool `json:"deleted"` DeletedGRETunnel interface{} `json:"deleted_gre_tunnel"` @@ -514,8 +321,8 @@ func (r greTunnelGetResponseJSON) RawJSON() string { type GRETunnelNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r GRETunnelNewParams) MarshalJSON() (data []byte, err error) { @@ -523,9 +330,9 @@ func (r GRETunnelNewParams) MarshalJSON() (data []byte, err error) { } type GRETunnelNewResponseEnvelope struct { - Errors []GRETunnelNewResponseEnvelopeErrors `json:"errors,required"` - Messages []GRETunnelNewResponseEnvelopeMessages `json:"messages,required"` - Result GRETunnelNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GRETunnelNewResponse `json:"result,required"` // Whether the API call was successful Success GRETunnelNewResponseEnvelopeSuccess `json:"success,required"` JSON greTunnelNewResponseEnvelopeJSON `json:"-"` @@ -550,52 +357,6 @@ func (r greTunnelNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GRETunnelNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// greTunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [GRETunnelNewResponseEnvelopeErrors] -type greTunnelNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GRETunnelNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// greTunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GRETunnelNewResponseEnvelopeMessages] -type greTunnelNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GRETunnelNewResponseEnvelopeSuccess bool @@ -626,8 +387,8 @@ type GRETunnelUpdateParams struct { // must be 15 characters or less, and cannot share a name with another GRE tunnel. Name param.Field[string] `json:"name,required"` // An optional description of the GRE tunnel. - Description param.Field[string] `json:"description"` - HealthCheck param.Field[GRETunnelUpdateParamsHealthCheck] `json:"health_check"` + Description param.Field[string] `json:"description"` + HealthCheck param.Field[HealthCheckParam] `json:"health_check"` // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value // is 576. Mtu param.Field[int64] `json:"mtu"` @@ -639,90 +400,10 @@ func (r GRETunnelUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type GRETunnelUpdateParamsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction param.Field[GRETunnelUpdateParamsHealthCheckDirection] `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled param.Field[bool] `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate param.Field[GRETunnelUpdateParamsHealthCheckRate] `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target param.Field[string] `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[GRETunnelUpdateParamsHealthCheckType] `json:"type"` -} - -func (r GRETunnelUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type GRETunnelUpdateParamsHealthCheckDirection string - -const ( - GRETunnelUpdateParamsHealthCheckDirectionUnidirectional GRETunnelUpdateParamsHealthCheckDirection = "unidirectional" - GRETunnelUpdateParamsHealthCheckDirectionBidirectional GRETunnelUpdateParamsHealthCheckDirection = "bidirectional" -) - -func (r GRETunnelUpdateParamsHealthCheckDirection) IsKnown() bool { - switch r { - case GRETunnelUpdateParamsHealthCheckDirectionUnidirectional, GRETunnelUpdateParamsHealthCheckDirectionBidirectional: - return true - } - return false -} - -// How frequent the health check is run. The default value is `mid`. -type GRETunnelUpdateParamsHealthCheckRate string - -const ( - GRETunnelUpdateParamsHealthCheckRateLow GRETunnelUpdateParamsHealthCheckRate = "low" - GRETunnelUpdateParamsHealthCheckRateMid GRETunnelUpdateParamsHealthCheckRate = "mid" - GRETunnelUpdateParamsHealthCheckRateHigh GRETunnelUpdateParamsHealthCheckRate = "high" -) - -func (r GRETunnelUpdateParamsHealthCheckRate) IsKnown() bool { - switch r { - case GRETunnelUpdateParamsHealthCheckRateLow, GRETunnelUpdateParamsHealthCheckRateMid, GRETunnelUpdateParamsHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type GRETunnelUpdateParamsHealthCheckType string - -const ( - GRETunnelUpdateParamsHealthCheckTypeReply GRETunnelUpdateParamsHealthCheckType = "reply" - GRETunnelUpdateParamsHealthCheckTypeRequest GRETunnelUpdateParamsHealthCheckType = "request" -) - -func (r GRETunnelUpdateParamsHealthCheckType) IsKnown() bool { - switch r { - case GRETunnelUpdateParamsHealthCheckTypeReply, GRETunnelUpdateParamsHealthCheckTypeRequest: - return true - } - return false -} - type GRETunnelUpdateResponseEnvelope struct { - Errors []GRETunnelUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []GRETunnelUpdateResponseEnvelopeMessages `json:"messages,required"` - Result GRETunnelUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GRETunnelUpdateResponse `json:"result,required"` // Whether the API call was successful Success GRETunnelUpdateResponseEnvelopeSuccess `json:"success,required"` JSON greTunnelUpdateResponseEnvelopeJSON `json:"-"` @@ -747,52 +428,6 @@ func (r greTunnelUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GRETunnelUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// greTunnelUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GRETunnelUpdateResponseEnvelopeErrors] -type greTunnelUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GRETunnelUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// greTunnelUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GRETunnelUpdateResponseEnvelopeMessages] -type greTunnelUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GRETunnelUpdateResponseEnvelopeSuccess bool @@ -814,9 +449,9 @@ type GRETunnelListParams struct { } type GRETunnelListResponseEnvelope struct { - Errors []GRETunnelListResponseEnvelopeErrors `json:"errors,required"` - Messages []GRETunnelListResponseEnvelopeMessages `json:"messages,required"` - Result GRETunnelListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GRETunnelListResponse `json:"result,required"` // Whether the API call was successful Success GRETunnelListResponseEnvelopeSuccess `json:"success,required"` JSON greTunnelListResponseEnvelopeJSON `json:"-"` @@ -841,52 +476,6 @@ func (r greTunnelListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GRETunnelListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelListResponseEnvelopeErrorsJSON `json:"-"` -} - -// greTunnelListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GRETunnelListResponseEnvelopeErrors] -type greTunnelListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GRETunnelListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelListResponseEnvelopeMessagesJSON `json:"-"` -} - -// greTunnelListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GRETunnelListResponseEnvelopeMessages] -type greTunnelListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GRETunnelListResponseEnvelopeSuccess bool @@ -905,12 +494,17 @@ func (r GRETunnelListResponseEnvelopeSuccess) IsKnown() bool { type GRETunnelDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r GRETunnelDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type GRETunnelDeleteResponseEnvelope struct { - Errors []GRETunnelDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []GRETunnelDeleteResponseEnvelopeMessages `json:"messages,required"` - Result GRETunnelDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GRETunnelDeleteResponse `json:"result,required"` // Whether the API call was successful Success GRETunnelDeleteResponseEnvelopeSuccess `json:"success,required"` JSON greTunnelDeleteResponseEnvelopeJSON `json:"-"` @@ -935,52 +529,6 @@ func (r greTunnelDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GRETunnelDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// greTunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GRETunnelDeleteResponseEnvelopeErrors] -type greTunnelDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GRETunnelDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// greTunnelDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GRETunnelDeleteResponseEnvelopeMessages] -type greTunnelDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GRETunnelDeleteResponseEnvelopeSuccess bool @@ -1002,9 +550,9 @@ type GRETunnelGetParams struct { } type GRETunnelGetResponseEnvelope struct { - Errors []GRETunnelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GRETunnelGetResponseEnvelopeMessages `json:"messages,required"` - Result GRETunnelGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GRETunnelGetResponse `json:"result,required"` // Whether the API call was successful Success GRETunnelGetResponseEnvelopeSuccess `json:"success,required"` JSON greTunnelGetResponseEnvelopeJSON `json:"-"` @@ -1029,52 +577,6 @@ func (r greTunnelGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GRETunnelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// greTunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [GRETunnelGetResponseEnvelopeErrors] -type greTunnelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GRETunnelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON greTunnelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// greTunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GRETunnelGetResponseEnvelopeMessages] -type greTunnelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GRETunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r greTunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GRETunnelGetResponseEnvelopeSuccess bool diff --git a/magic_transit/gretunnel_test.go b/magic_transit/gretunnel_test.go index 6996b22d29a..585c40d1c39 100644 --- a/magic_transit/gretunnel_test.go +++ b/magic_transit/gretunnel_test.go @@ -30,7 +30,7 @@ func TestGRETunnelNew(t *testing.T) { ) _, err := client.MagicTransit.GRETunnels.New(context.TODO(), magic_transit.GRETunnelNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -65,12 +65,12 @@ func TestGRETunnelUpdateWithOptionalParams(t *testing.T) { InterfaceAddress: cloudflare.F("192.0.2.0/31"), Name: cloudflare.F("GRE_1"), Description: cloudflare.F("Tunnel for ISP X"), - HealthCheck: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheck{ - Direction: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheckDirectionBidirectional), + HealthCheck: cloudflare.F(magic_transit.HealthCheckParam{ + Direction: cloudflare.F(magic_transit.HealthCheckDirectionBidirectional), Enabled: cloudflare.F(true), - Rate: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheckRateLow), + Rate: cloudflare.F(magic_transit.HealthCheckRateLow), Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheckTypeRequest), + Type: cloudflare.F(magic_transit.HealthCheckTypeRequest), }), Mtu: cloudflare.F(int64(0)), TTL: cloudflare.F(int64(0)), @@ -130,6 +130,7 @@ func TestGRETunnelDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.GRETunnelDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_transit/ipsectunnel.go b/magic_transit/ipsectunnel.go index 1787cf8b1f0..ce23c8d77c5 100644 --- a/magic_transit/ipsectunnel.go +++ b/magic_transit/ipsectunnel.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -78,10 +79,10 @@ func (r *IPSECTunnelService) List(ctx context.Context, query IPSECTunnelListPara // Disables and removes a specific static IPsec Tunnel associated with an account. // Use `?validate_only=true` as an optional query parameter to only run validation // without persisting changes. -func (r *IPSECTunnelService) Delete(ctx context.Context, tunnelIdentifier string, body IPSECTunnelDeleteParams, opts ...option.RequestOption) (res *IPSECTunnelDeleteResponse, err error) { +func (r *IPSECTunnelService) Delete(ctx context.Context, tunnelIdentifier string, params IPSECTunnelDeleteParams, opts ...option.RequestOption) (res *IPSECTunnelDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env IPSECTunnelDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", body.AccountID, tunnelIdentifier) + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", params.AccountID, tunnelIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -108,10 +109,10 @@ func (r *IPSECTunnelService) Get(ctx context.Context, tunnelIdentifier string, q // without persisting changes. After a PSK is generated, the PSK is immediately // persisted to Cloudflare's edge and cannot be retrieved later. Note the PSK in a // safe place. -func (r *IPSECTunnelService) PSKGenerate(ctx context.Context, tunnelIdentifier string, body IPSECTunnelPSKGenerateParams, opts ...option.RequestOption) (res *IPSECTunnelPSKGenerateResponse, err error) { +func (r *IPSECTunnelService) PSKGenerate(ctx context.Context, tunnelIdentifier string, params IPSECTunnelPSKGenerateParams, opts ...option.RequestOption) (res *IPSECTunnelPSKGenerateResponse, err error) { opts = append(r.Options[:], opts...) var env IPSECTunnelPSKGenerateResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s/psk_generate", body.AccountID, tunnelIdentifier) + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s/psk_generate", params.AccountID, tunnelIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -120,6 +121,28 @@ func (r *IPSECTunnelService) PSKGenerate(ctx context.Context, tunnelIdentifier s return } +// The PSK metadata that includes when the PSK was generated. +type PSKMetadata struct { + // The date and time the tunnel was last modified. + LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` + JSON pskMetadataJSON `json:"-"` +} + +// pskMetadataJSON contains the JSON metadata for the struct [PSKMetadata] +type pskMetadataJSON struct { + LastGeneratedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PSKMetadata) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pskMetadataJSON) RawJSON() string { + return r.raw +} + type IPSECTunnelNewResponse struct { IPSECTunnels []IPSECTunnelNewResponseIPSECTunnel `json:"ipsec_tunnels"` JSON ipsecTunnelNewResponseJSON `json:"-"` @@ -157,14 +180,15 @@ type IPSECTunnelNewResponseIPSECTunnel struct { AllowNullCipher bool `json:"allow_null_cipher"` // The date and time the tunnel was created. CreatedOn time.Time `json:"created_on" format:"date-time"` - // The IP address assigned to the customer side of the IPsec tunnel. + // The IP address assigned to the customer side of the IPsec tunnel. Not required, + // but must be set for proactive traceroutes to work. CustomerEndpoint string `json:"customer_endpoint"` // An optional description forthe IPsec tunnel. Description string `json:"description"` // The date and time the tunnel was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // The PSK metadata that includes when the PSK was generated. - PSKMetadata IPSECTunnelNewResponseIPSECTunnelsPSKMetadata `json:"psk_metadata"` + PSKMetadata PSKMetadata `json:"psk_metadata"` // If `true`, then IPsec replay protection will be supported in the // Cloudflare-to-customer direction. ReplayProtection bool `json:"replay_protection"` @@ -199,40 +223,17 @@ func (r ipsecTunnelNewResponseIPSECTunnelJSON) RawJSON() string { return r.raw } -// The PSK metadata that includes when the PSK was generated. -type IPSECTunnelNewResponseIPSECTunnelsPSKMetadata struct { - // The date and time the tunnel was last modified. - LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` - JSON ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON `json:"-"` -} - -// ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON contains the JSON metadata for -// the struct [IPSECTunnelNewResponseIPSECTunnelsPSKMetadata] -type ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON struct { - LastGeneratedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelNewResponseIPSECTunnelsPSKMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON) RawJSON() string { - return r.raw -} - type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck struct { // Determines whether to run healthchecks for a tunnel. Enabled bool `json:"enabled"` // How frequent the health check is run. The default value is `mid`. - Rate IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate `json:"rate"` + Rate HealthCheckRate `json:"rate"` // The destination address in a request type health check. After the healthcheck is // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded // to this address. This field defaults to `customer_gre_endpoint address`. Target string `json:"target"` // The type of healthcheck to run, reply or request. The default value is `reply`. - Type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType `json:"type"` + Type HealthCheckType `json:"type"` JSON ipsecTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON `json:"-"` } @@ -255,39 +256,6 @@ func (r ipsecTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON) RawJSON() strin return r.raw } -// How frequent the health check is run. The default value is `mid`. -type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate string - -const ( - IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateLow IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "low" - IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateMid IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "mid" - IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateHigh IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "high" -) - -func (r IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate) IsKnown() bool { - switch r { - case IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateLow, IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateMid, IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType string - -const ( - IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeReply IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType = "reply" - IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeRequest IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType = "request" -) - -func (r IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType) IsKnown() bool { - switch r { - case IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeReply, IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeRequest: - return true - } - return false -} - type IPSECTunnelUpdateResponse struct { Modified bool `json:"modified"` ModifiedIPSECTunnel interface{} `json:"modified_ipsec_tunnel"` @@ -348,14 +316,15 @@ type IPSECTunnelListResponseIPSECTunnel struct { AllowNullCipher bool `json:"allow_null_cipher"` // The date and time the tunnel was created. CreatedOn time.Time `json:"created_on" format:"date-time"` - // The IP address assigned to the customer side of the IPsec tunnel. + // The IP address assigned to the customer side of the IPsec tunnel. Not required, + // but must be set for proactive traceroutes to work. CustomerEndpoint string `json:"customer_endpoint"` // An optional description forthe IPsec tunnel. Description string `json:"description"` // The date and time the tunnel was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // The PSK metadata that includes when the PSK was generated. - PSKMetadata IPSECTunnelListResponseIPSECTunnelsPSKMetadata `json:"psk_metadata"` + PSKMetadata PSKMetadata `json:"psk_metadata"` // If `true`, then IPsec replay protection will be supported in the // Cloudflare-to-customer direction. ReplayProtection bool `json:"replay_protection"` @@ -390,40 +359,17 @@ func (r ipsecTunnelListResponseIPSECTunnelJSON) RawJSON() string { return r.raw } -// The PSK metadata that includes when the PSK was generated. -type IPSECTunnelListResponseIPSECTunnelsPSKMetadata struct { - // The date and time the tunnel was last modified. - LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` - JSON ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON `json:"-"` -} - -// ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON contains the JSON metadata -// for the struct [IPSECTunnelListResponseIPSECTunnelsPSKMetadata] -type ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON struct { - LastGeneratedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelListResponseIPSECTunnelsPSKMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON) RawJSON() string { - return r.raw -} - type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck struct { // Determines whether to run healthchecks for a tunnel. Enabled bool `json:"enabled"` // How frequent the health check is run. The default value is `mid`. - Rate IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate `json:"rate"` + Rate HealthCheckRate `json:"rate"` // The destination address in a request type health check. After the healthcheck is // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded // to this address. This field defaults to `customer_gre_endpoint address`. Target string `json:"target"` // The type of healthcheck to run, reply or request. The default value is `reply`. - Type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType `json:"type"` + Type HealthCheckType `json:"type"` JSON ipsecTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON `json:"-"` } @@ -446,39 +392,6 @@ func (r ipsecTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON) RawJSON() stri return r.raw } -// How frequent the health check is run. The default value is `mid`. -type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate string - -const ( - IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateLow IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "low" - IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateMid IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "mid" - IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateHigh IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "high" -) - -func (r IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate) IsKnown() bool { - switch r { - case IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateLow, IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateMid, IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType string - -const ( - IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeReply IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType = "reply" - IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeRequest IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType = "request" -) - -func (r IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType) IsKnown() bool { - switch r { - case IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeReply, IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeRequest: - return true - } - return false -} - type IPSECTunnelDeleteResponse struct { Deleted bool `json:"deleted"` DeletedIPSECTunnel interface{} `json:"deleted_ipsec_tunnel"` @@ -529,8 +442,8 @@ type IPSECTunnelPSKGenerateResponse struct { // A randomly generated or provided string for use in the IPsec tunnel. PSK string `json:"psk"` // The PSK metadata that includes when the PSK was generated. - PSKMetadata IPSECTunnelPSKGenerateResponsePSKMetadata `json:"psk_metadata"` - JSON ipsecTunnelPSKGenerateResponseJSON `json:"-"` + PSKMetadata PSKMetadata `json:"psk_metadata"` + JSON ipsecTunnelPSKGenerateResponseJSON `json:"-"` } // ipsecTunnelPSKGenerateResponseJSON contains the JSON metadata for the struct @@ -551,29 +464,6 @@ func (r ipsecTunnelPSKGenerateResponseJSON) RawJSON() string { return r.raw } -// The PSK metadata that includes when the PSK was generated. -type IPSECTunnelPSKGenerateResponsePSKMetadata struct { - // The date and time the tunnel was last modified. - LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` - JSON ipsecTunnelPSKGenerateResponsePSKMetadataJSON `json:"-"` -} - -// ipsecTunnelPSKGenerateResponsePSKMetadataJSON contains the JSON metadata for the -// struct [IPSECTunnelPSKGenerateResponsePSKMetadata] -type ipsecTunnelPSKGenerateResponsePSKMetadataJSON struct { - LastGeneratedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelPSKGenerateResponsePSKMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelPSKGenerateResponsePSKMetadataJSON) RawJSON() string { - return r.raw -} - type IPSECTunnelNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -585,11 +475,12 @@ type IPSECTunnelNewParams struct { InterfaceAddress param.Field[string] `json:"interface_address,required"` // The name of the IPsec tunnel. The name cannot share a name with other tunnels. Name param.Field[string] `json:"name,required"` - // The IP address assigned to the customer side of the IPsec tunnel. + // The IP address assigned to the customer side of the IPsec tunnel. Not required, + // but must be set for proactive traceroutes to work. CustomerEndpoint param.Field[string] `json:"customer_endpoint"` // An optional description forthe IPsec tunnel. - Description param.Field[string] `json:"description"` - HealthCheck param.Field[IPSECTunnelNewParamsHealthCheck] `json:"health_check"` + Description param.Field[string] `json:"description"` + HealthCheck param.Field[HealthCheckParam] `json:"health_check"` // A randomly generated or provided string for use in the IPsec tunnel. PSK param.Field[string] `json:"psk"` // If `true`, then IPsec replay protection will be supported in the @@ -601,90 +492,10 @@ func (r IPSECTunnelNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type IPSECTunnelNewParamsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction param.Field[IPSECTunnelNewParamsHealthCheckDirection] `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled param.Field[bool] `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate param.Field[IPSECTunnelNewParamsHealthCheckRate] `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target param.Field[string] `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[IPSECTunnelNewParamsHealthCheckType] `json:"type"` -} - -func (r IPSECTunnelNewParamsHealthCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type IPSECTunnelNewParamsHealthCheckDirection string - -const ( - IPSECTunnelNewParamsHealthCheckDirectionUnidirectional IPSECTunnelNewParamsHealthCheckDirection = "unidirectional" - IPSECTunnelNewParamsHealthCheckDirectionBidirectional IPSECTunnelNewParamsHealthCheckDirection = "bidirectional" -) - -func (r IPSECTunnelNewParamsHealthCheckDirection) IsKnown() bool { - switch r { - case IPSECTunnelNewParamsHealthCheckDirectionUnidirectional, IPSECTunnelNewParamsHealthCheckDirectionBidirectional: - return true - } - return false -} - -// How frequent the health check is run. The default value is `mid`. -type IPSECTunnelNewParamsHealthCheckRate string - -const ( - IPSECTunnelNewParamsHealthCheckRateLow IPSECTunnelNewParamsHealthCheckRate = "low" - IPSECTunnelNewParamsHealthCheckRateMid IPSECTunnelNewParamsHealthCheckRate = "mid" - IPSECTunnelNewParamsHealthCheckRateHigh IPSECTunnelNewParamsHealthCheckRate = "high" -) - -func (r IPSECTunnelNewParamsHealthCheckRate) IsKnown() bool { - switch r { - case IPSECTunnelNewParamsHealthCheckRateLow, IPSECTunnelNewParamsHealthCheckRateMid, IPSECTunnelNewParamsHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type IPSECTunnelNewParamsHealthCheckType string - -const ( - IPSECTunnelNewParamsHealthCheckTypeReply IPSECTunnelNewParamsHealthCheckType = "reply" - IPSECTunnelNewParamsHealthCheckTypeRequest IPSECTunnelNewParamsHealthCheckType = "request" -) - -func (r IPSECTunnelNewParamsHealthCheckType) IsKnown() bool { - switch r { - case IPSECTunnelNewParamsHealthCheckTypeReply, IPSECTunnelNewParamsHealthCheckTypeRequest: - return true - } - return false -} - type IPSECTunnelNewResponseEnvelope struct { - Errors []IPSECTunnelNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IPSECTunnelNewResponseEnvelopeMessages `json:"messages,required"` - Result IPSECTunnelNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IPSECTunnelNewResponse `json:"result,required"` // Whether the API call was successful Success IPSECTunnelNewResponseEnvelopeSuccess `json:"success,required"` JSON ipsecTunnelNewResponseEnvelopeJSON `json:"-"` @@ -709,52 +520,6 @@ func (r ipsecTunnelNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPSECTunnelNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipsecTunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IPSECTunnelNewResponseEnvelopeErrors] -type ipsecTunnelNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPSECTunnelNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipsecTunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IPSECTunnelNewResponseEnvelopeMessages] -type ipsecTunnelNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPSECTunnelNewResponseEnvelopeSuccess bool @@ -781,11 +546,12 @@ type IPSECTunnelUpdateParams struct { InterfaceAddress param.Field[string] `json:"interface_address,required"` // The name of the IPsec tunnel. The name cannot share a name with other tunnels. Name param.Field[string] `json:"name,required"` - // The IP address assigned to the customer side of the IPsec tunnel. + // The IP address assigned to the customer side of the IPsec tunnel. Not required, + // but must be set for proactive traceroutes to work. CustomerEndpoint param.Field[string] `json:"customer_endpoint"` // An optional description forthe IPsec tunnel. - Description param.Field[string] `json:"description"` - HealthCheck param.Field[IPSECTunnelUpdateParamsHealthCheck] `json:"health_check"` + Description param.Field[string] `json:"description"` + HealthCheck param.Field[HealthCheckParam] `json:"health_check"` // A randomly generated or provided string for use in the IPsec tunnel. PSK param.Field[string] `json:"psk"` // If `true`, then IPsec replay protection will be supported in the @@ -797,90 +563,10 @@ func (r IPSECTunnelUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type IPSECTunnelUpdateParamsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction param.Field[IPSECTunnelUpdateParamsHealthCheckDirection] `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled param.Field[bool] `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate param.Field[IPSECTunnelUpdateParamsHealthCheckRate] `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target param.Field[string] `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[IPSECTunnelUpdateParamsHealthCheckType] `json:"type"` -} - -func (r IPSECTunnelUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type IPSECTunnelUpdateParamsHealthCheckDirection string - -const ( - IPSECTunnelUpdateParamsHealthCheckDirectionUnidirectional IPSECTunnelUpdateParamsHealthCheckDirection = "unidirectional" - IPSECTunnelUpdateParamsHealthCheckDirectionBidirectional IPSECTunnelUpdateParamsHealthCheckDirection = "bidirectional" -) - -func (r IPSECTunnelUpdateParamsHealthCheckDirection) IsKnown() bool { - switch r { - case IPSECTunnelUpdateParamsHealthCheckDirectionUnidirectional, IPSECTunnelUpdateParamsHealthCheckDirectionBidirectional: - return true - } - return false -} - -// How frequent the health check is run. The default value is `mid`. -type IPSECTunnelUpdateParamsHealthCheckRate string - -const ( - IPSECTunnelUpdateParamsHealthCheckRateLow IPSECTunnelUpdateParamsHealthCheckRate = "low" - IPSECTunnelUpdateParamsHealthCheckRateMid IPSECTunnelUpdateParamsHealthCheckRate = "mid" - IPSECTunnelUpdateParamsHealthCheckRateHigh IPSECTunnelUpdateParamsHealthCheckRate = "high" -) - -func (r IPSECTunnelUpdateParamsHealthCheckRate) IsKnown() bool { - switch r { - case IPSECTunnelUpdateParamsHealthCheckRateLow, IPSECTunnelUpdateParamsHealthCheckRateMid, IPSECTunnelUpdateParamsHealthCheckRateHigh: - return true - } - return false -} - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type IPSECTunnelUpdateParamsHealthCheckType string - -const ( - IPSECTunnelUpdateParamsHealthCheckTypeReply IPSECTunnelUpdateParamsHealthCheckType = "reply" - IPSECTunnelUpdateParamsHealthCheckTypeRequest IPSECTunnelUpdateParamsHealthCheckType = "request" -) - -func (r IPSECTunnelUpdateParamsHealthCheckType) IsKnown() bool { - switch r { - case IPSECTunnelUpdateParamsHealthCheckTypeReply, IPSECTunnelUpdateParamsHealthCheckTypeRequest: - return true - } - return false -} - type IPSECTunnelUpdateResponseEnvelope struct { - Errors []IPSECTunnelUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []IPSECTunnelUpdateResponseEnvelopeMessages `json:"messages,required"` - Result IPSECTunnelUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IPSECTunnelUpdateResponse `json:"result,required"` // Whether the API call was successful Success IPSECTunnelUpdateResponseEnvelopeSuccess `json:"success,required"` JSON ipsecTunnelUpdateResponseEnvelopeJSON `json:"-"` @@ -905,52 +591,6 @@ func (r ipsecTunnelUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPSECTunnelUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipsecTunnelUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IPSECTunnelUpdateResponseEnvelopeErrors] -type ipsecTunnelUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPSECTunnelUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipsecTunnelUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IPSECTunnelUpdateResponseEnvelopeMessages] -type ipsecTunnelUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPSECTunnelUpdateResponseEnvelopeSuccess bool @@ -972,9 +612,9 @@ type IPSECTunnelListParams struct { } type IPSECTunnelListResponseEnvelope struct { - Errors []IPSECTunnelListResponseEnvelopeErrors `json:"errors,required"` - Messages []IPSECTunnelListResponseEnvelopeMessages `json:"messages,required"` - Result IPSECTunnelListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IPSECTunnelListResponse `json:"result,required"` // Whether the API call was successful Success IPSECTunnelListResponseEnvelopeSuccess `json:"success,required"` JSON ipsecTunnelListResponseEnvelopeJSON `json:"-"` @@ -999,52 +639,6 @@ func (r ipsecTunnelListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPSECTunnelListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelListResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipsecTunnelListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IPSECTunnelListResponseEnvelopeErrors] -type ipsecTunnelListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPSECTunnelListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelListResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipsecTunnelListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IPSECTunnelListResponseEnvelopeMessages] -type ipsecTunnelListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPSECTunnelListResponseEnvelopeSuccess bool @@ -1063,12 +657,17 @@ func (r IPSECTunnelListResponseEnvelopeSuccess) IsKnown() bool { type IPSECTunnelDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r IPSECTunnelDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type IPSECTunnelDeleteResponseEnvelope struct { - Errors []IPSECTunnelDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []IPSECTunnelDeleteResponseEnvelopeMessages `json:"messages,required"` - Result IPSECTunnelDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IPSECTunnelDeleteResponse `json:"result,required"` // Whether the API call was successful Success IPSECTunnelDeleteResponseEnvelopeSuccess `json:"success,required"` JSON ipsecTunnelDeleteResponseEnvelopeJSON `json:"-"` @@ -1093,52 +692,6 @@ func (r ipsecTunnelDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPSECTunnelDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipsecTunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IPSECTunnelDeleteResponseEnvelopeErrors] -type ipsecTunnelDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPSECTunnelDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipsecTunnelDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IPSECTunnelDeleteResponseEnvelopeMessages] -type ipsecTunnelDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPSECTunnelDeleteResponseEnvelopeSuccess bool @@ -1160,9 +713,9 @@ type IPSECTunnelGetParams struct { } type IPSECTunnelGetResponseEnvelope struct { - Errors []IPSECTunnelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IPSECTunnelGetResponseEnvelopeMessages `json:"messages,required"` - Result IPSECTunnelGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IPSECTunnelGetResponse `json:"result,required"` // Whether the API call was successful Success IPSECTunnelGetResponseEnvelopeSuccess `json:"success,required"` JSON ipsecTunnelGetResponseEnvelopeJSON `json:"-"` @@ -1187,52 +740,6 @@ func (r ipsecTunnelGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPSECTunnelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipsecTunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IPSECTunnelGetResponseEnvelopeErrors] -type ipsecTunnelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPSECTunnelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipsecTunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IPSECTunnelGetResponseEnvelopeMessages] -type ipsecTunnelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPSECTunnelGetResponseEnvelopeSuccess bool @@ -1251,12 +758,17 @@ func (r IPSECTunnelGetResponseEnvelopeSuccess) IsKnown() bool { type IPSECTunnelPSKGenerateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r IPSECTunnelPSKGenerateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type IPSECTunnelPSKGenerateResponseEnvelope struct { - Errors []IPSECTunnelPSKGenerateResponseEnvelopeErrors `json:"errors,required"` - Messages []IPSECTunnelPSKGenerateResponseEnvelopeMessages `json:"messages,required"` - Result IPSECTunnelPSKGenerateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IPSECTunnelPSKGenerateResponse `json:"result,required"` // Whether the API call was successful Success IPSECTunnelPSKGenerateResponseEnvelopeSuccess `json:"success,required"` JSON ipsecTunnelPSKGenerateResponseEnvelopeJSON `json:"-"` @@ -1281,52 +793,6 @@ func (r ipsecTunnelPSKGenerateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IPSECTunnelPSKGenerateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [IPSECTunnelPSKGenerateResponseEnvelopeErrors] -type ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelPSKGenerateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPSECTunnelPSKGenerateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [IPSECTunnelPSKGenerateResponseEnvelopeMessages] -type ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPSECTunnelPSKGenerateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IPSECTunnelPSKGenerateResponseEnvelopeSuccess bool diff --git a/magic_transit/ipsectunnel_test.go b/magic_transit/ipsectunnel_test.go index e817479fdf2..535200851f8 100644 --- a/magic_transit/ipsectunnel_test.go +++ b/magic_transit/ipsectunnel_test.go @@ -35,12 +35,12 @@ func TestIPSECTunnelNewWithOptionalParams(t *testing.T) { Name: cloudflare.F("IPsec_1"), CustomerEndpoint: cloudflare.F("203.0.113.1"), Description: cloudflare.F("Tunnel for ISP X"), - HealthCheck: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheck{ - Direction: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheckDirectionBidirectional), + HealthCheck: cloudflare.F(magic_transit.HealthCheckParam{ + Direction: cloudflare.F(magic_transit.HealthCheckDirectionBidirectional), Enabled: cloudflare.F(true), - Rate: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheckRateLow), + Rate: cloudflare.F(magic_transit.HealthCheckRateLow), Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheckTypeRequest), + Type: cloudflare.F(magic_transit.HealthCheckTypeRequest), }), PSK: cloudflare.F("O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy"), ReplayProtection: cloudflare.F(false), @@ -78,12 +78,12 @@ func TestIPSECTunnelUpdateWithOptionalParams(t *testing.T) { Name: cloudflare.F("IPsec_1"), CustomerEndpoint: cloudflare.F("203.0.113.1"), Description: cloudflare.F("Tunnel for ISP X"), - HealthCheck: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheck{ - Direction: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheckDirectionBidirectional), + HealthCheck: cloudflare.F(magic_transit.HealthCheckParam{ + Direction: cloudflare.F(magic_transit.HealthCheckDirectionBidirectional), Enabled: cloudflare.F(true), - Rate: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheckRateLow), + Rate: cloudflare.F(magic_transit.HealthCheckRateLow), Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheckTypeRequest), + Type: cloudflare.F(magic_transit.HealthCheckTypeRequest), }), PSK: cloudflare.F("O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy"), ReplayProtection: cloudflare.F(false), @@ -143,6 +143,7 @@ func TestIPSECTunnelDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.IPSECTunnelDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -203,6 +204,7 @@ func TestIPSECTunnelPSKGenerate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.IPSECTunnelPSKGenerateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_transit/magictransit.go b/magic_transit/magictransit.go index 5c2b7a93c20..53b086bee50 100644 --- a/magic_transit/magictransit.go +++ b/magic_transit/magictransit.go @@ -3,6 +3,8 @@ package magic_transit import ( + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -33,3 +35,125 @@ func NewMagicTransitService(opts ...option.RequestOption) (r *MagicTransitServic r.Sites = NewSiteService(opts...) return } + +type HealthCheck struct { + // The direction of the flow of the healthcheck. Either unidirectional, where the + // probe comes to you via the tunnel and the result comes back to Cloudflare via + // the open Internet, or bidirectional where both the probe and result come and go + // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field + // in health_check is ignored as the interface_address is used to send traffic into + // the tunnel. + Direction HealthCheckDirection `json:"direction"` + // Determines whether to run healthchecks for a tunnel. + Enabled bool `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate HealthCheckRate `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. This + // field is ignored for bidirectional healthchecks as the interface_address (not + // assigned to the Cloudflare side of the tunnel) is used as the target. + Target string `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type HealthCheckType `json:"type"` + JSON healthCheckJSON `json:"-"` +} + +// healthCheckJSON contains the JSON metadata for the struct [HealthCheck] +type healthCheckJSON struct { + Direction apijson.Field + Enabled apijson.Field + Rate apijson.Field + Target apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthCheckJSON) RawJSON() string { + return r.raw +} + +// The direction of the flow of the healthcheck. Either unidirectional, where the +// probe comes to you via the tunnel and the result comes back to Cloudflare via +// the open Internet, or bidirectional where both the probe and result come and go +// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field +// in health_check is ignored as the interface_address is used to send traffic into +// the tunnel. +type HealthCheckDirection string + +const ( + HealthCheckDirectionUnidirectional HealthCheckDirection = "unidirectional" + HealthCheckDirectionBidirectional HealthCheckDirection = "bidirectional" +) + +func (r HealthCheckDirection) IsKnown() bool { + switch r { + case HealthCheckDirectionUnidirectional, HealthCheckDirectionBidirectional: + return true + } + return false +} + +type HealthCheckParam struct { + // The direction of the flow of the healthcheck. Either unidirectional, where the + // probe comes to you via the tunnel and the result comes back to Cloudflare via + // the open Internet, or bidirectional where both the probe and result come and go + // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field + // in health_check is ignored as the interface_address is used to send traffic into + // the tunnel. + Direction param.Field[HealthCheckDirection] `json:"direction"` + // Determines whether to run healthchecks for a tunnel. + Enabled param.Field[bool] `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate param.Field[HealthCheckRate] `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. This + // field is ignored for bidirectional healthchecks as the interface_address (not + // assigned to the Cloudflare side of the tunnel) is used as the target. + Target param.Field[string] `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type param.Field[HealthCheckType] `json:"type"` +} + +func (r HealthCheckParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// How frequent the health check is run. The default value is `mid`. +type HealthCheckRate string + +const ( + HealthCheckRateLow HealthCheckRate = "low" + HealthCheckRateMid HealthCheckRate = "mid" + HealthCheckRateHigh HealthCheckRate = "high" +) + +func (r HealthCheckRate) IsKnown() bool { + switch r { + case HealthCheckRateLow, HealthCheckRateMid, HealthCheckRateHigh: + return true + } + return false +} + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type HealthCheckType string + +const ( + HealthCheckTypeReply HealthCheckType = "reply" + HealthCheckTypeRequest HealthCheckType = "request" +) + +func (r HealthCheckType) IsKnown() bool { + switch r { + case HealthCheckTypeReply, HealthCheckTypeRequest: + return true + } + return false +} diff --git a/magic_transit/route.go b/magic_transit/route.go index 45cd6fb6720..7f1a252d679 100644 --- a/magic_transit/route.go +++ b/magic_transit/route.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -73,10 +74,10 @@ func (r *RouteService) List(ctx context.Context, query RouteListParams, opts ... } // Disable and remove a specific Magic static route. -func (r *RouteService) Delete(ctx context.Context, routeIdentifier string, body RouteDeleteParams, opts ...option.RequestOption) (res *RouteDeleteResponse, err error) { +func (r *RouteService) Delete(ctx context.Context, routeIdentifier string, params RouteDeleteParams, opts ...option.RequestOption) (res *RouteDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env RouteDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/routes/%s", body.AccountID, routeIdentifier) + path := fmt.Sprintf("accounts/%s/magic/routes/%s", params.AccountID, routeIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -111,6 +112,51 @@ func (r *RouteService) Get(ctx context.Context, routeIdentifier string, query Ro return } +type ColoName []string + +type ColoNameParam []string + +type ColoRegion []string + +type ColoRegionParam []string + +// Used only for ECMP routes. +type Scope struct { + // List of colo names for the ECMP scope. + ColoNames ColoName `json:"colo_names"` + // List of colo regions for the ECMP scope. + ColoRegions ColoRegion `json:"colo_regions"` + JSON scopeJSON `json:"-"` +} + +// scopeJSON contains the JSON metadata for the struct [Scope] +type scopeJSON struct { + ColoNames apijson.Field + ColoRegions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Scope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scopeJSON) RawJSON() string { + return r.raw +} + +// Used only for ECMP routes. +type ScopeParam struct { + // List of colo names for the ECMP scope. + ColoNames param.Field[ColoNameParam] `json:"colo_names"` + // List of colo regions for the ECMP scope. + ColoRegions param.Field[ColoRegionParam] `json:"colo_regions"` +} + +func (r ScopeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type RouteNewResponse struct { Routes []RouteNewResponseRoute `json:"routes"` JSON routeNewResponseJSON `json:"-"` @@ -148,7 +194,7 @@ type RouteNewResponseRoute struct { // When the route was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Used only for ECMP routes. - Scope RouteNewResponseRoutesScope `json:"scope"` + Scope Scope `json:"scope"` // Optional weight of the ECMP scope - if provided. Weight int64 `json:"weight"` JSON routeNewResponseRouteJSON `json:"-"` @@ -178,32 +224,6 @@ func (r routeNewResponseRouteJSON) RawJSON() string { return r.raw } -// Used only for ECMP routes. -type RouteNewResponseRoutesScope struct { - // List of colo names for the ECMP scope. - ColoNames []string `json:"colo_names"` - // List of colo regions for the ECMP scope. - ColoRegions []string `json:"colo_regions"` - JSON routeNewResponseRoutesScopeJSON `json:"-"` -} - -// routeNewResponseRoutesScopeJSON contains the JSON metadata for the struct -// [RouteNewResponseRoutesScope] -type routeNewResponseRoutesScopeJSON struct { - ColoNames apijson.Field - ColoRegions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteNewResponseRoutesScope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeNewResponseRoutesScopeJSON) RawJSON() string { - return r.raw -} - type RouteUpdateResponse struct { Modified bool `json:"modified"` ModifiedRoute interface{} `json:"modified_route"` @@ -264,7 +284,7 @@ type RouteListResponseRoute struct { // When the route was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Used only for ECMP routes. - Scope RouteListResponseRoutesScope `json:"scope"` + Scope Scope `json:"scope"` // Optional weight of the ECMP scope - if provided. Weight int64 `json:"weight"` JSON routeListResponseRouteJSON `json:"-"` @@ -294,32 +314,6 @@ func (r routeListResponseRouteJSON) RawJSON() string { return r.raw } -// Used only for ECMP routes. -type RouteListResponseRoutesScope struct { - // List of colo names for the ECMP scope. - ColoNames []string `json:"colo_names"` - // List of colo regions for the ECMP scope. - ColoRegions []string `json:"colo_regions"` - JSON routeListResponseRoutesScopeJSON `json:"-"` -} - -// routeListResponseRoutesScopeJSON contains the JSON metadata for the struct -// [RouteListResponseRoutesScope] -type routeListResponseRoutesScopeJSON struct { - ColoNames apijson.Field - ColoRegions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteListResponseRoutesScope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeListResponseRoutesScopeJSON) RawJSON() string { - return r.raw -} - type RouteDeleteResponse struct { Deleted bool `json:"deleted"` DeletedRoute interface{} `json:"deleted_route"` @@ -389,8 +383,8 @@ func (r routeGetResponseJSON) RawJSON() string { type RouteNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r RouteNewParams) MarshalJSON() (data []byte, err error) { @@ -398,9 +392,9 @@ func (r RouteNewParams) MarshalJSON() (data []byte, err error) { } type RouteNewResponseEnvelope struct { - Errors []RouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteNewResponseEnvelopeMessages `json:"messages,required"` - Result RouteNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RouteNewResponse `json:"result,required"` // Whether the API call was successful Success RouteNewResponseEnvelopeSuccess `json:"success,required"` JSON routeNewResponseEnvelopeJSON `json:"-"` @@ -425,52 +419,6 @@ func (r routeNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteNewResponseEnvelopeErrors] -type routeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RouteNewResponseEnvelopeMessages] -type routeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RouteNewResponseEnvelopeSuccess bool @@ -498,7 +446,7 @@ type RouteUpdateParams struct { // An optional human provided description of the static route. Description param.Field[string] `json:"description"` // Used only for ECMP routes. - Scope param.Field[RouteUpdateParamsScope] `json:"scope"` + Scope param.Field[ScopeParam] `json:"scope"` // Optional weight of the ECMP scope - if provided. Weight param.Field[int64] `json:"weight"` } @@ -507,22 +455,10 @@ func (r RouteUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Used only for ECMP routes. -type RouteUpdateParamsScope struct { - // List of colo names for the ECMP scope. - ColoNames param.Field[[]string] `json:"colo_names"` - // List of colo regions for the ECMP scope. - ColoRegions param.Field[[]string] `json:"colo_regions"` -} - -func (r RouteUpdateParamsScope) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type RouteUpdateResponseEnvelope struct { - Errors []RouteUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteUpdateResponseEnvelopeMessages `json:"messages,required"` - Result RouteUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RouteUpdateResponse `json:"result,required"` // Whether the API call was successful Success RouteUpdateResponseEnvelopeSuccess `json:"success,required"` JSON routeUpdateResponseEnvelopeJSON `json:"-"` @@ -547,52 +483,6 @@ func (r routeUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RouteUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteUpdateResponseEnvelopeErrors] -type routeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RouteUpdateResponseEnvelopeMessages] -type routeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RouteUpdateResponseEnvelopeSuccess bool @@ -614,9 +504,9 @@ type RouteListParams struct { } type RouteListResponseEnvelope struct { - Errors []RouteListResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteListResponseEnvelopeMessages `json:"messages,required"` - Result RouteListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RouteListResponse `json:"result,required"` // Whether the API call was successful Success RouteListResponseEnvelopeSuccess `json:"success,required"` JSON routeListResponseEnvelopeJSON `json:"-"` @@ -641,52 +531,6 @@ func (r routeListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RouteListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeListResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteListResponseEnvelopeErrors] -type routeListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeListResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RouteListResponseEnvelopeMessages] -type routeListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RouteListResponseEnvelopeSuccess bool @@ -705,12 +549,17 @@ func (r RouteListResponseEnvelopeSuccess) IsKnown() bool { type RouteDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RouteDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type RouteDeleteResponseEnvelope struct { - Errors []RouteDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteDeleteResponseEnvelopeMessages `json:"messages,required"` - Result RouteDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RouteDeleteResponse `json:"result,required"` // Whether the API call was successful Success RouteDeleteResponseEnvelopeSuccess `json:"success,required"` JSON routeDeleteResponseEnvelopeJSON `json:"-"` @@ -735,52 +584,6 @@ func (r routeDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RouteDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteDeleteResponseEnvelopeErrors] -type routeDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RouteDeleteResponseEnvelopeMessages] -type routeDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RouteDeleteResponseEnvelopeSuccess bool @@ -814,9 +617,9 @@ func (r RouteEmptyParamsRoute) MarshalJSON() (data []byte, err error) { } type RouteEmptyResponseEnvelope struct { - Errors []RouteEmptyResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteEmptyResponseEnvelopeMessages `json:"messages,required"` - Result RouteEmptyResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RouteEmptyResponse `json:"result,required"` // Whether the API call was successful Success RouteEmptyResponseEnvelopeSuccess `json:"success,required"` JSON routeEmptyResponseEnvelopeJSON `json:"-"` @@ -841,52 +644,6 @@ func (r routeEmptyResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RouteEmptyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeEmptyResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeEmptyResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteEmptyResponseEnvelopeErrors] -type routeEmptyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteEmptyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeEmptyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteEmptyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeEmptyResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeEmptyResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RouteEmptyResponseEnvelopeMessages] -type routeEmptyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteEmptyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeEmptyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RouteEmptyResponseEnvelopeSuccess bool @@ -908,9 +665,9 @@ type RouteGetParams struct { } type RouteGetResponseEnvelope struct { - Errors []RouteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteGetResponseEnvelopeMessages `json:"messages,required"` - Result RouteGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RouteGetResponse `json:"result,required"` // Whether the API call was successful Success RouteGetResponseEnvelopeSuccess `json:"success,required"` JSON routeGetResponseEnvelopeJSON `json:"-"` @@ -935,52 +692,6 @@ func (r routeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RouteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteGetResponseEnvelopeErrors] -type routeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RouteGetResponseEnvelopeMessages] -type routeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RouteGetResponseEnvelopeSuccess bool diff --git a/magic_transit/route_test.go b/magic_transit/route_test.go index 625da09164b..bf86a596a0b 100644 --- a/magic_transit/route_test.go +++ b/magic_transit/route_test.go @@ -30,7 +30,7 @@ func TestRouteNew(t *testing.T) { ) _, err := client.MagicTransit.Routes.New(context.TODO(), magic_transit.RouteNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -64,7 +64,7 @@ func TestRouteUpdateWithOptionalParams(t *testing.T) { Prefix: cloudflare.F("192.0.2.0/24"), Priority: cloudflare.F(int64(0)), Description: cloudflare.F("New route for new prefix 203.0.113.1"), - Scope: cloudflare.F(magic_transit.RouteUpdateParamsScope{ + Scope: cloudflare.F(magic_transit.ScopeParam{ ColoNames: cloudflare.F([]string{"den01", "den01", "den01"}), ColoRegions: cloudflare.F([]string{"APAC", "APAC", "APAC"}), }), @@ -125,6 +125,7 @@ func TestRouteDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.RouteDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_transit/site.go b/magic_transit/site.go index 0c1b84097f0..9afad017e40 100644 --- a/magic_transit/site.go +++ b/magic_transit/site.go @@ -6,10 +6,13 @@ import ( "context" "fmt" "net/http" + "net/url" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -65,11 +68,11 @@ func (r *SiteService) Update(ctx context.Context, siteID string, params SiteUpda // Lists Sites associated with an account. Use connector_identifier query param to // return sites where connector_identifier matches either site.ConnectorID or // site.SecondaryConnectorID. -func (r *SiteService) List(ctx context.Context, query SiteListParams, opts ...option.RequestOption) (res *SiteListResponse, err error) { +func (r *SiteService) List(ctx context.Context, params SiteListParams, opts ...option.RequestOption) (res *SiteListResponse, err error) { opts = append(r.Options[:], opts...) var env SiteListResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/sites", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + path := fmt.Sprintf("accounts/%s/magic/sites", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) if err != nil { return } @@ -78,10 +81,10 @@ func (r *SiteService) List(ctx context.Context, query SiteListParams, opts ...op } // Remove a specific Site. -func (r *SiteService) Delete(ctx context.Context, siteID string, body SiteDeleteParams, opts ...option.RequestOption) (res *SiteDeleteResponse, err error) { +func (r *SiteService) Delete(ctx context.Context, siteID string, params SiteDeleteParams, opts ...option.RequestOption) (res *SiteDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env SiteDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/sites/%s", body.AccountID, siteID) + path := fmt.Sprintf("accounts/%s/magic/sites/%s", params.AccountID, siteID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -103,27 +106,7 @@ func (r *SiteService) Get(ctx context.Context, siteID string, query SiteGetParam return } -type SiteNewResponse struct { - Site SiteNewResponseSite `json:"site"` - JSON siteNewResponseJSON `json:"-"` -} - -// siteNewResponseJSON contains the JSON metadata for the struct [SiteNewResponse] -type siteNewResponseJSON struct { - Site apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteNewResponseJSON) RawJSON() string { - return r.raw -} - -type SiteNewResponseSite struct { +type Site struct { // Identifier ID string `json:"id"` // Magic WAN Connector identifier tag. @@ -133,17 +116,16 @@ type SiteNewResponseSite struct { // and runs in high availability mode. HaMode bool `json:"ha_mode"` // Location of site in latitude and longitude. - Location SiteNewResponseSiteLocation `json:"location"` + Location SiteLocation `json:"location"` // The name of the site. Name string `json:"name"` // Magic WAN Connector identifier tag. Used when high availability mode is on. - SecondaryConnectorID string `json:"secondary_connector_id"` - JSON siteNewResponseSiteJSON `json:"-"` + SecondaryConnectorID string `json:"secondary_connector_id"` + JSON siteJSON `json:"-"` } -// siteNewResponseSiteJSON contains the JSON metadata for the struct -// [SiteNewResponseSite] -type siteNewResponseSiteJSON struct { +// siteJSON contains the JSON metadata for the struct [Site] +type siteJSON struct { ID apijson.Field ConnectorID apijson.Field Description apijson.Field @@ -155,130 +137,95 @@ type siteNewResponseSiteJSON struct { ExtraFields map[string]apijson.Field } -func (r *SiteNewResponseSite) UnmarshalJSON(data []byte) (err error) { +func (r *Site) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteNewResponseSiteJSON) RawJSON() string { +func (r siteJSON) RawJSON() string { return r.raw } // Location of site in latitude and longitude. -type SiteNewResponseSiteLocation struct { +type SiteLocation struct { // Latitude Lat string `json:"lat"` // Longitude - Lon string `json:"lon"` - JSON siteNewResponseSiteLocationJSON `json:"-"` + Lon string `json:"lon"` + JSON siteLocationJSON `json:"-"` } -// siteNewResponseSiteLocationJSON contains the JSON metadata for the struct -// [SiteNewResponseSiteLocation] -type siteNewResponseSiteLocationJSON struct { +// siteLocationJSON contains the JSON metadata for the struct [SiteLocation] +type siteLocationJSON struct { Lat apijson.Field Lon apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteNewResponseSiteLocation) UnmarshalJSON(data []byte) (err error) { +func (r *SiteLocation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteNewResponseSiteLocationJSON) RawJSON() string { +func (r siteLocationJSON) RawJSON() string { return r.raw } -type SiteUpdateResponse struct { - Site SiteUpdateResponseSite `json:"site"` - JSON siteUpdateResponseJSON `json:"-"` -} - -// siteUpdateResponseJSON contains the JSON metadata for the struct -// [SiteUpdateResponse] -type siteUpdateResponseJSON struct { - Site apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Location of site in latitude and longitude. +type SiteLocationParam struct { + // Latitude + Lat param.Field[string] `json:"lat"` + // Longitude + Lon param.Field[string] `json:"lon"` } -func (r siteUpdateResponseJSON) RawJSON() string { - return r.raw +func (r SiteLocationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type SiteUpdateResponseSite struct { - // Identifier - ID string `json:"id"` - // Magic WAN Connector identifier tag. - ConnectorID string `json:"connector_id"` - Description string `json:"description"` - // Site high availability mode. If set to true, the site can have two connectors - // and runs in high availability mode. - HaMode bool `json:"ha_mode"` - // Location of site in latitude and longitude. - Location SiteUpdateResponseSiteLocation `json:"location"` - // The name of the site. - Name string `json:"name"` - // Magic WAN Connector identifier tag. Used when high availability mode is on. - SecondaryConnectorID string `json:"secondary_connector_id"` - JSON siteUpdateResponseSiteJSON `json:"-"` +type SiteNewResponse struct { + Site Site `json:"site"` + JSON siteNewResponseJSON `json:"-"` } -// siteUpdateResponseSiteJSON contains the JSON metadata for the struct -// [SiteUpdateResponseSite] -type siteUpdateResponseSiteJSON struct { - ID apijson.Field - ConnectorID apijson.Field - Description apijson.Field - HaMode apijson.Field - Location apijson.Field - Name apijson.Field - SecondaryConnectorID apijson.Field - raw string - ExtraFields map[string]apijson.Field +// siteNewResponseJSON contains the JSON metadata for the struct [SiteNewResponse] +type siteNewResponseJSON struct { + Site apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteUpdateResponseSite) UnmarshalJSON(data []byte) (err error) { +func (r *SiteNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteUpdateResponseSiteJSON) RawJSON() string { +func (r siteNewResponseJSON) RawJSON() string { return r.raw } -// Location of site in latitude and longitude. -type SiteUpdateResponseSiteLocation struct { - // Latitude - Lat string `json:"lat"` - // Longitude - Lon string `json:"lon"` - JSON siteUpdateResponseSiteLocationJSON `json:"-"` +type SiteUpdateResponse struct { + Site Site `json:"site"` + JSON siteUpdateResponseJSON `json:"-"` } -// siteUpdateResponseSiteLocationJSON contains the JSON metadata for the struct -// [SiteUpdateResponseSiteLocation] -type siteUpdateResponseSiteLocationJSON struct { - Lat apijson.Field - Lon apijson.Field +// siteUpdateResponseJSON contains the JSON metadata for the struct +// [SiteUpdateResponse] +type siteUpdateResponseJSON struct { + Site apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteUpdateResponseSiteLocation) UnmarshalJSON(data []byte) (err error) { +func (r *SiteUpdateResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteUpdateResponseSiteLocationJSON) RawJSON() string { +func (r siteUpdateResponseJSON) RawJSON() string { return r.raw } type SiteListResponse struct { - Sites []SiteListResponseSite `json:"sites"` - JSON siteListResponseJSON `json:"-"` + Sites []Site `json:"sites"` + JSON siteListResponseJSON `json:"-"` } // siteListResponseJSON contains the JSON metadata for the struct @@ -297,76 +244,10 @@ func (r siteListResponseJSON) RawJSON() string { return r.raw } -type SiteListResponseSite struct { - // Identifier - ID string `json:"id"` - // Magic WAN Connector identifier tag. - ConnectorID string `json:"connector_id"` - Description string `json:"description"` - // Site high availability mode. If set to true, the site can have two connectors - // and runs in high availability mode. - HaMode bool `json:"ha_mode"` - // Location of site in latitude and longitude. - Location SiteListResponseSitesLocation `json:"location"` - // The name of the site. - Name string `json:"name"` - // Magic WAN Connector identifier tag. Used when high availability mode is on. - SecondaryConnectorID string `json:"secondary_connector_id"` - JSON siteListResponseSiteJSON `json:"-"` -} - -// siteListResponseSiteJSON contains the JSON metadata for the struct -// [SiteListResponseSite] -type siteListResponseSiteJSON struct { - ID apijson.Field - ConnectorID apijson.Field - Description apijson.Field - HaMode apijson.Field - Location apijson.Field - Name apijson.Field - SecondaryConnectorID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteListResponseSite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteListResponseSiteJSON) RawJSON() string { - return r.raw -} - -// Location of site in latitude and longitude. -type SiteListResponseSitesLocation struct { - // Latitude - Lat string `json:"lat"` - // Longitude - Lon string `json:"lon"` - JSON siteListResponseSitesLocationJSON `json:"-"` -} - -// siteListResponseSitesLocationJSON contains the JSON metadata for the struct -// [SiteListResponseSitesLocation] -type siteListResponseSitesLocationJSON struct { - Lat apijson.Field - Lon apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteListResponseSitesLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteListResponseSitesLocationJSON) RawJSON() string { - return r.raw -} - type SiteDeleteResponse struct { - Deleted bool `json:"deleted"` - DeletedSite SiteDeleteResponseDeletedSite `json:"deleted_site"` - JSON siteDeleteResponseJSON `json:"-"` + Deleted bool `json:"deleted"` + DeletedSite Site `json:"deleted_site"` + JSON siteDeleteResponseJSON `json:"-"` } // siteDeleteResponseJSON contains the JSON metadata for the struct @@ -386,74 +267,8 @@ func (r siteDeleteResponseJSON) RawJSON() string { return r.raw } -type SiteDeleteResponseDeletedSite struct { - // Identifier - ID string `json:"id"` - // Magic WAN Connector identifier tag. - ConnectorID string `json:"connector_id"` - Description string `json:"description"` - // Site high availability mode. If set to true, the site can have two connectors - // and runs in high availability mode. - HaMode bool `json:"ha_mode"` - // Location of site in latitude and longitude. - Location SiteDeleteResponseDeletedSiteLocation `json:"location"` - // The name of the site. - Name string `json:"name"` - // Magic WAN Connector identifier tag. Used when high availability mode is on. - SecondaryConnectorID string `json:"secondary_connector_id"` - JSON siteDeleteResponseDeletedSiteJSON `json:"-"` -} - -// siteDeleteResponseDeletedSiteJSON contains the JSON metadata for the struct -// [SiteDeleteResponseDeletedSite] -type siteDeleteResponseDeletedSiteJSON struct { - ID apijson.Field - ConnectorID apijson.Field - Description apijson.Field - HaMode apijson.Field - Location apijson.Field - Name apijson.Field - SecondaryConnectorID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteDeleteResponseDeletedSite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteDeleteResponseDeletedSiteJSON) RawJSON() string { - return r.raw -} - -// Location of site in latitude and longitude. -type SiteDeleteResponseDeletedSiteLocation struct { - // Latitude - Lat string `json:"lat"` - // Longitude - Lon string `json:"lon"` - JSON siteDeleteResponseDeletedSiteLocationJSON `json:"-"` -} - -// siteDeleteResponseDeletedSiteLocationJSON contains the JSON metadata for the -// struct [SiteDeleteResponseDeletedSiteLocation] -type siteDeleteResponseDeletedSiteLocationJSON struct { - Lat apijson.Field - Lon apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteDeleteResponseDeletedSiteLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteDeleteResponseDeletedSiteLocationJSON) RawJSON() string { - return r.raw -} - type SiteGetResponse struct { - Site SiteGetResponseSite `json:"site"` + Site Site `json:"site"` JSON siteGetResponseJSON `json:"-"` } @@ -472,72 +287,6 @@ func (r siteGetResponseJSON) RawJSON() string { return r.raw } -type SiteGetResponseSite struct { - // Identifier - ID string `json:"id"` - // Magic WAN Connector identifier tag. - ConnectorID string `json:"connector_id"` - Description string `json:"description"` - // Site high availability mode. If set to true, the site can have two connectors - // and runs in high availability mode. - HaMode bool `json:"ha_mode"` - // Location of site in latitude and longitude. - Location SiteGetResponseSiteLocation `json:"location"` - // The name of the site. - Name string `json:"name"` - // Magic WAN Connector identifier tag. Used when high availability mode is on. - SecondaryConnectorID string `json:"secondary_connector_id"` - JSON siteGetResponseSiteJSON `json:"-"` -} - -// siteGetResponseSiteJSON contains the JSON metadata for the struct -// [SiteGetResponseSite] -type siteGetResponseSiteJSON struct { - ID apijson.Field - ConnectorID apijson.Field - Description apijson.Field - HaMode apijson.Field - Location apijson.Field - Name apijson.Field - SecondaryConnectorID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteGetResponseSite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteGetResponseSiteJSON) RawJSON() string { - return r.raw -} - -// Location of site in latitude and longitude. -type SiteGetResponseSiteLocation struct { - // Latitude - Lat string `json:"lat"` - // Longitude - Lon string `json:"lon"` - JSON siteGetResponseSiteLocationJSON `json:"-"` -} - -// siteGetResponseSiteLocationJSON contains the JSON metadata for the struct -// [SiteGetResponseSiteLocation] -type siteGetResponseSiteLocationJSON struct { - Lat apijson.Field - Lon apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteGetResponseSiteLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteGetResponseSiteLocationJSON) RawJSON() string { - return r.raw -} - type SiteNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -558,7 +307,7 @@ type SiteNewParamsSite struct { // and runs in high availability mode. HaMode param.Field[bool] `json:"ha_mode"` // Location of site in latitude and longitude. - Location param.Field[SiteNewParamsSiteLocation] `json:"location"` + Location param.Field[SiteLocationParam] `json:"location"` // Magic WAN Connector identifier tag. Used when high availability mode is on. SecondaryConnectorID param.Field[string] `json:"secondary_connector_id"` } @@ -567,22 +316,10 @@ func (r SiteNewParamsSite) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Location of site in latitude and longitude. -type SiteNewParamsSiteLocation struct { - // Latitude - Lat param.Field[string] `json:"lat"` - // Longitude - Lon param.Field[string] `json:"lon"` -} - -func (r SiteNewParamsSiteLocation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SiteNewResponseEnvelope struct { - Errors []SiteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteNewResponseEnvelopeMessages `json:"messages,required"` - Result SiteNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteNewResponse `json:"result,required"` // Whether the API call was successful Success SiteNewResponseEnvelopeSuccess `json:"success,required"` JSON siteNewResponseEnvelopeJSON `json:"-"` @@ -607,52 +344,6 @@ func (r siteNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteNewResponseEnvelopeErrors] -type siteNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteNewResponseEnvelopeMessages] -type siteNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteNewResponseEnvelopeSuccess bool @@ -683,7 +374,7 @@ type SiteUpdateParamsSite struct { ConnectorID param.Field[string] `json:"connector_id"` Description param.Field[string] `json:"description"` // Location of site in latitude and longitude. - Location param.Field[SiteUpdateParamsSiteLocation] `json:"location"` + Location param.Field[SiteLocationParam] `json:"location"` // The name of the site. Name param.Field[string] `json:"name"` // Magic WAN Connector identifier tag. Used when high availability mode is on. @@ -694,22 +385,10 @@ func (r SiteUpdateParamsSite) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Location of site in latitude and longitude. -type SiteUpdateParamsSiteLocation struct { - // Latitude - Lat param.Field[string] `json:"lat"` - // Longitude - Lon param.Field[string] `json:"lon"` -} - -func (r SiteUpdateParamsSiteLocation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SiteUpdateResponseEnvelope struct { - Errors []SiteUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SiteUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteUpdateResponse `json:"result,required"` // Whether the API call was successful Success SiteUpdateResponseEnvelopeSuccess `json:"success,required"` JSON siteUpdateResponseEnvelopeJSON `json:"-"` @@ -734,52 +413,6 @@ func (r siteUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteUpdateResponseEnvelopeErrors] -type siteUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteUpdateResponseEnvelopeMessages] -type siteUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteUpdateResponseEnvelopeSuccess bool @@ -798,12 +431,22 @@ func (r SiteUpdateResponseEnvelopeSuccess) IsKnown() bool { type SiteListParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + // Identifier + ConnectorIdentifier param.Field[string] `query:"connector_identifier"` +} + +// URLQuery serializes [SiteListParams]'s query parameters as `url.Values`. +func (r SiteListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } type SiteListResponseEnvelope struct { - Errors []SiteListResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteListResponseEnvelopeMessages `json:"messages,required"` - Result SiteListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteListResponse `json:"result,required"` // Whether the API call was successful Success SiteListResponseEnvelopeSuccess `json:"success,required"` JSON siteListResponseEnvelopeJSON `json:"-"` @@ -828,52 +471,6 @@ func (r siteListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteListResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteListResponseEnvelopeErrors] -type siteListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteListResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteListResponseEnvelopeMessages] -type siteListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteListResponseEnvelopeSuccess bool @@ -892,12 +489,17 @@ func (r SiteListResponseEnvelopeSuccess) IsKnown() bool { type SiteDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r SiteDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type SiteDeleteResponseEnvelope struct { - Errors []SiteDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SiteDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteDeleteResponse `json:"result,required"` // Whether the API call was successful Success SiteDeleteResponseEnvelopeSuccess `json:"success,required"` JSON siteDeleteResponseEnvelopeJSON `json:"-"` @@ -922,52 +524,6 @@ func (r siteDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteDeleteResponseEnvelopeErrors] -type siteDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteDeleteResponseEnvelopeMessages] -type siteDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteDeleteResponseEnvelopeSuccess bool @@ -989,9 +545,9 @@ type SiteGetParams struct { } type SiteGetResponseEnvelope struct { - Errors []SiteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteGetResponseEnvelopeMessages `json:"messages,required"` - Result SiteGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteGetResponse `json:"result,required"` // Whether the API call was successful Success SiteGetResponseEnvelopeSuccess `json:"success,required"` JSON siteGetResponseEnvelopeJSON `json:"-"` @@ -1016,52 +572,6 @@ func (r siteGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteGetResponseEnvelopeErrors] -type siteGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteGetResponseEnvelopeMessages] -type siteGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteGetResponseEnvelopeSuccess bool diff --git a/magic_transit/site_test.go b/magic_transit/site_test.go index 6a5722abac2..6de303b55db 100644 --- a/magic_transit/site_test.go +++ b/magic_transit/site_test.go @@ -34,7 +34,7 @@ func TestSiteNewWithOptionalParams(t *testing.T) { ConnectorID: cloudflare.F("ac60d3d0435248289d446cedd870bcf4"), Description: cloudflare.F("string"), HaMode: cloudflare.F(true), - Location: cloudflare.F(magic_transit.SiteNewParamsSiteLocation{ + Location: cloudflare.F(magic_transit.SiteLocationParam{ Lat: cloudflare.F("string"), Lon: cloudflare.F("string"), }), @@ -73,7 +73,7 @@ func TestSiteUpdateWithOptionalParams(t *testing.T) { Site: cloudflare.F(magic_transit.SiteUpdateParamsSite{ ConnectorID: cloudflare.F("ac60d3d0435248289d446cedd870bcf4"), Description: cloudflare.F("string"), - Location: cloudflare.F(magic_transit.SiteUpdateParamsSiteLocation{ + Location: cloudflare.F(magic_transit.SiteLocationParam{ Lat: cloudflare.F("string"), Lon: cloudflare.F("string"), }), @@ -91,7 +91,7 @@ func TestSiteUpdateWithOptionalParams(t *testing.T) { } } -func TestSiteList(t *testing.T) { +func TestSiteListWithOptionalParams(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 { @@ -106,7 +106,8 @@ func TestSiteList(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.MagicTransit.Sites.List(context.TODO(), magic_transit.SiteListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ConnectorIdentifier: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { var apierr *cloudflare.Error @@ -136,6 +137,7 @@ func TestSiteDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_transit/siteacl.go b/magic_transit/siteacl.go index e787cae6c62..6eb71dc3a10 100644 --- a/magic_transit/siteacl.go +++ b/magic_transit/siteacl.go @@ -73,10 +73,10 @@ func (r *SiteACLService) List(ctx context.Context, siteID string, query SiteACLL } // Remove a specific Site ACL. -func (r *SiteACLService) Delete(ctx context.Context, siteID string, aclIdentifier string, body SiteACLDeleteParams, opts ...option.RequestOption) (res *SiteACLDeleteResponse, err error) { +func (r *SiteACLService) Delete(ctx context.Context, siteID string, aclIdentifier string, params SiteACLDeleteParams, opts ...option.RequestOption) (res *SiteACLDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env SiteACLDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/sites/%s/acls/%s", body.AccountID, siteID, aclIdentifier) + path := fmt.Sprintf("accounts/%s/magic/sites/%s/acls/%s", params.AccountID, siteID, aclIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -98,63 +98,67 @@ func (r *SiteACLService) Get(ctx context.Context, siteID string, aclIdentifier s return } -type SiteACLNewResponse struct { - ACLs []SiteACLNewResponseACL `json:"acls"` - JSON siteACLNewResponseJSON `json:"-"` +// Bidirectional ACL policy for network traffic within a site. +type ACL struct { + // Identifier + ID string `json:"id"` + // Description for the ACL. + Description string `json:"description"` + // The desired forwarding action for this ACL policy. If set to "false", the policy + // will forward traffic to Cloudflare. If set to "true", the policy will forward + // traffic locally on the Magic WAN Connector. If not included in request, will + // default to false. + ForwardLocally bool `json:"forward_locally"` + LAN1 ACLConfiguration `json:"lan_1"` + LAN2 ACLConfiguration `json:"lan_2"` + // The name of the ACL. + Name string `json:"name"` + Protocols []AllowedProtocol `json:"protocols"` + JSON aclJSON `json:"-"` } -// siteACLNewResponseJSON contains the JSON metadata for the struct -// [SiteACLNewResponse] -type siteACLNewResponseJSON struct { - ACLs apijson.Field - raw string - ExtraFields map[string]apijson.Field +// aclJSON contains the JSON metadata for the struct [ACL] +type aclJSON struct { + ID apijson.Field + Description apijson.Field + ForwardLocally apijson.Field + LAN1 apijson.Field + LAN2 apijson.Field + Name apijson.Field + Protocols apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteACLNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *ACL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteACLNewResponseJSON) RawJSON() string { +func (r aclJSON) RawJSON() string { return r.raw } -// Bidirectional ACL policy for local network traffic within a site. -type SiteACLNewResponseACL struct { - // Identifier - ID string `json:"id"` +// Bidirectional ACL policy for network traffic within a site. +type ACLParam struct { // Description for the ACL. - Description string `json:"description"` - LAN1 SiteACLNewResponseACLsLAN1 `json:"lan_1"` - LAN2 SiteACLNewResponseACLsLAN2 `json:"lan_2"` + Description param.Field[string] `json:"description"` + // The desired forwarding action for this ACL policy. If set to "false", the policy + // will forward traffic to Cloudflare. If set to "true", the policy will forward + // traffic locally on the Magic WAN Connector. If not included in request, will + // default to false. + ForwardLocally param.Field[bool] `json:"forward_locally"` + LAN1 param.Field[ACLConfigurationParam] `json:"lan_1"` + LAN2 param.Field[ACLConfigurationParam] `json:"lan_2"` // The name of the ACL. - Name string `json:"name"` - Protocols []SiteACLNewResponseACLsProtocol `json:"protocols"` - JSON siteACLNewResponseACLJSON `json:"-"` -} - -// siteACLNewResponseACLJSON contains the JSON metadata for the struct -// [SiteACLNewResponseACL] -type siteACLNewResponseACLJSON struct { - ID apijson.Field - Description apijson.Field - LAN1 apijson.Field - LAN2 apijson.Field - Name apijson.Field - Protocols apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLNewResponseACL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + Name param.Field[string] `json:"name"` + Protocols param.Field[[]AllowedProtocol] `json:"protocols"` } -func (r siteACLNewResponseACLJSON) RawJSON() string { - return r.raw +func (r ACLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type SiteACLNewResponseACLsLAN1 struct { +type ACLConfiguration struct { // The identifier for the LAN you want to create an ACL policy with. LANID string `json:"lan_id,required"` // The name of the LAN based on the provided lan_id. @@ -164,13 +168,13 @@ type SiteACLNewResponseACLsLAN1 struct { Ports []int64 `json:"ports"` // Array of subnet IPs within the LAN that will be included in the ACL. If no // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLNewResponseACLsLAN1Subnet `json:"subnets"` - JSON siteACLNewResponseACLsLan1JSON `json:"-"` + Subnets []SubnetUnion `json:"subnets"` + JSON aclConfigurationJSON `json:"-"` } -// siteACLNewResponseACLsLan1JSON contains the JSON metadata for the struct -// [SiteACLNewResponseACLsLAN1] -type siteACLNewResponseACLsLan1JSON struct { +// aclConfigurationJSON contains the JSON metadata for the struct +// [ACLConfiguration] +type aclConfigurationJSON struct { LANID apijson.Field LANName apijson.Field Ports apijson.Field @@ -179,209 +183,59 @@ type siteACLNewResponseACLsLan1JSON struct { ExtraFields map[string]apijson.Field } -func (r *SiteACLNewResponseACLsLAN1) UnmarshalJSON(data []byte) (err error) { +func (r *ACLConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteACLNewResponseACLsLan1JSON) RawJSON() string { +func (r aclConfigurationJSON) RawJSON() string { return r.raw } -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLNewResponseACLsLAN1Subnet interface { - ImplementsMagicTransitSiteACLNewResponseACLsLan1Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLNewResponseACLsLAN1Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SiteACLNewResponseACLsLAN2 struct { +type ACLConfigurationParam struct { // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` + LANID param.Field[string] `json:"lan_id,required"` // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` + LANName param.Field[string] `json:"lan_name"` // Array of ports on the provided LAN that will be included in the ACL. If no ports // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` + Ports param.Field[[]int64] `json:"ports"` // Array of subnet IPs within the LAN that will be included in the ACL. If no // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLNewResponseACLsLAN2Subnet `json:"subnets"` - JSON siteACLNewResponseACLsLan2JSON `json:"-"` -} - -// siteACLNewResponseACLsLan2JSON contains the JSON metadata for the struct -// [SiteACLNewResponseACLsLAN2] -type siteACLNewResponseACLsLan2JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLNewResponseACLsLAN2) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLNewResponseACLsLan2JSON) RawJSON() string { - return r.raw -} - -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLNewResponseACLsLAN2Subnet interface { - ImplementsMagicTransitSiteACLNewResponseACLsLan2Subnet() + Subnets param.Field[[]SubnetUnionParam] `json:"subnets"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLNewResponseACLsLAN2Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) +func (r ACLConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Array of allowed communication protocols between configured LANs. If no // protocols are provided, all protocols are allowed. -type SiteACLNewResponseACLsProtocol string +type AllowedProtocol string const ( - SiteACLNewResponseACLsProtocolTcp SiteACLNewResponseACLsProtocol = "tcp" - SiteACLNewResponseACLsProtocolUdp SiteACLNewResponseACLsProtocol = "udp" - SiteACLNewResponseACLsProtocolIcmp SiteACLNewResponseACLsProtocol = "icmp" + AllowedProtocolTCP AllowedProtocol = "tcp" + AllowedProtocolUdp AllowedProtocol = "udp" + AllowedProtocolIcmp AllowedProtocol = "icmp" ) -func (r SiteACLNewResponseACLsProtocol) IsKnown() bool { +func (r AllowedProtocol) IsKnown() bool { switch r { - case SiteACLNewResponseACLsProtocolTcp, SiteACLNewResponseACLsProtocolUdp, SiteACLNewResponseACLsProtocolIcmp: + case AllowedProtocolTCP, AllowedProtocolUdp, AllowedProtocolIcmp: return true } return false } -type SiteACLUpdateResponse struct { - // Bidirectional ACL policy for local network traffic within a site. - ACL SiteACLUpdateResponseACL `json:"acl"` - JSON siteACLUpdateResponseJSON `json:"-"` -} - -// siteACLUpdateResponseJSON contains the JSON metadata for the struct -// [SiteACLUpdateResponse] -type siteACLUpdateResponseJSON struct { - ACL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Bidirectional ACL policy for local network traffic within a site. -type SiteACLUpdateResponseACL struct { - // Identifier - ID string `json:"id"` - // Description for the ACL. - Description string `json:"description"` - LAN1 SiteACLUpdateResponseACLLAN1 `json:"lan_1"` - LAN2 SiteACLUpdateResponseACLLAN2 `json:"lan_2"` - // The name of the ACL. - Name string `json:"name"` - Protocols []SiteACLUpdateResponseACLProtocol `json:"protocols"` - JSON siteACLUpdateResponseACLJSON `json:"-"` -} - -// siteACLUpdateResponseACLJSON contains the JSON metadata for the struct -// [SiteACLUpdateResponseACL] -type siteACLUpdateResponseACLJSON struct { - ID apijson.Field - Description apijson.Field - LAN1 apijson.Field - LAN2 apijson.Field - Name apijson.Field - Protocols apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLUpdateResponseACL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLUpdateResponseACLJSON) RawJSON() string { - return r.raw -} - -type SiteACLUpdateResponseACLLAN1 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLUpdateResponseACLLAN1Subnet `json:"subnets"` - JSON siteACLUpdateResponseAcllan1JSON `json:"-"` -} - -// siteACLUpdateResponseAcllan1JSON contains the JSON metadata for the struct -// [SiteACLUpdateResponseACLLAN1] -type siteACLUpdateResponseAcllan1JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLUpdateResponseACLLAN1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLUpdateResponseAcllan1JSON) RawJSON() string { - return r.raw -} - // A valid IPv4 address. // // Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLUpdateResponseACLLAN1Subnet interface { - ImplementsMagicTransitSiteACLUpdateResponseAcllan1Subnet() +type SubnetUnion interface { + ImplementsMagicTransitSubnetUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SiteACLUpdateResponseACLLAN1Subnet)(nil)).Elem(), + reflect.TypeOf((*SubnetUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -394,268 +248,82 @@ func init() { ) } -type SiteACLUpdateResponseACLLAN2 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLUpdateResponseACLLAN2Subnet `json:"subnets"` - JSON siteACLUpdateResponseAcllan2JSON `json:"-"` -} - -// siteACLUpdateResponseAcllan2JSON contains the JSON metadata for the struct -// [SiteACLUpdateResponseACLLAN2] -type siteACLUpdateResponseAcllan2JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLUpdateResponseACLLAN2) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLUpdateResponseAcllan2JSON) RawJSON() string { - return r.raw -} - // A valid IPv4 address. // -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLUpdateResponseACLLAN2Subnet interface { - ImplementsMagicTransitSiteACLUpdateResponseAcllan2Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLUpdateResponseACLLAN2Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Array of allowed communication protocols between configured LANs. If no -// protocols are provided, all protocols are allowed. -type SiteACLUpdateResponseACLProtocol string - -const ( - SiteACLUpdateResponseACLProtocolTcp SiteACLUpdateResponseACLProtocol = "tcp" - SiteACLUpdateResponseACLProtocolUdp SiteACLUpdateResponseACLProtocol = "udp" - SiteACLUpdateResponseACLProtocolIcmp SiteACLUpdateResponseACLProtocol = "icmp" -) - -func (r SiteACLUpdateResponseACLProtocol) IsKnown() bool { - switch r { - case SiteACLUpdateResponseACLProtocolTcp, SiteACLUpdateResponseACLProtocolUdp, SiteACLUpdateResponseACLProtocolIcmp: - return true - } - return false +// Satisfied by [shared.UnionString], [shared.UnionString]. +type SubnetUnionParam interface { + ImplementsMagicTransitSubnetUnionParam() } -type SiteACLListResponse struct { - ACLs []SiteACLListResponseACL `json:"acls"` - JSON siteACLListResponseJSON `json:"-"` +type SiteACLNewResponse struct { + ACLs []ACL `json:"acls"` + JSON siteACLNewResponseJSON `json:"-"` } -// siteACLListResponseJSON contains the JSON metadata for the struct -// [SiteACLListResponse] -type siteACLListResponseJSON struct { +// siteACLNewResponseJSON contains the JSON metadata for the struct +// [SiteACLNewResponse] +type siteACLNewResponseJSON struct { ACLs apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteACLListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLListResponseJSON) RawJSON() string { - return r.raw -} - -// Bidirectional ACL policy for local network traffic within a site. -type SiteACLListResponseACL struct { - // Identifier - ID string `json:"id"` - // Description for the ACL. - Description string `json:"description"` - LAN1 SiteACLListResponseACLsLAN1 `json:"lan_1"` - LAN2 SiteACLListResponseACLsLAN2 `json:"lan_2"` - // The name of the ACL. - Name string `json:"name"` - Protocols []SiteACLListResponseACLsProtocol `json:"protocols"` - JSON siteACLListResponseACLJSON `json:"-"` -} - -// siteACLListResponseACLJSON contains the JSON metadata for the struct -// [SiteACLListResponseACL] -type siteACLListResponseACLJSON struct { - ID apijson.Field - Description apijson.Field - LAN1 apijson.Field - LAN2 apijson.Field - Name apijson.Field - Protocols apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLListResponseACL) UnmarshalJSON(data []byte) (err error) { +func (r *SiteACLNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteACLListResponseACLJSON) RawJSON() string { +func (r siteACLNewResponseJSON) RawJSON() string { return r.raw } -type SiteACLListResponseACLsLAN1 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLListResponseACLsLAN1Subnet `json:"subnets"` - JSON siteACLListResponseACLsLan1JSON `json:"-"` +type SiteACLUpdateResponse struct { + // Bidirectional ACL policy for network traffic within a site. + ACL ACL `json:"acl"` + JSON siteACLUpdateResponseJSON `json:"-"` } -// siteACLListResponseACLsLan1JSON contains the JSON metadata for the struct -// [SiteACLListResponseACLsLAN1] -type siteACLListResponseACLsLan1JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field +// siteACLUpdateResponseJSON contains the JSON metadata for the struct +// [SiteACLUpdateResponse] +type siteACLUpdateResponseJSON struct { + ACL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteACLListResponseACLsLAN1) UnmarshalJSON(data []byte) (err error) { +func (r *SiteACLUpdateResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteACLListResponseACLsLan1JSON) RawJSON() string { +func (r siteACLUpdateResponseJSON) RawJSON() string { return r.raw } -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLListResponseACLsLAN1Subnet interface { - ImplementsMagicTransitSiteACLListResponseACLsLan1Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLListResponseACLsLAN1Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SiteACLListResponseACLsLAN2 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLListResponseACLsLAN2Subnet `json:"subnets"` - JSON siteACLListResponseACLsLan2JSON `json:"-"` +type SiteACLListResponse struct { + ACLs []ACL `json:"acls"` + JSON siteACLListResponseJSON `json:"-"` } -// siteACLListResponseACLsLan2JSON contains the JSON metadata for the struct -// [SiteACLListResponseACLsLAN2] -type siteACLListResponseACLsLan2JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field +// siteACLListResponseJSON contains the JSON metadata for the struct +// [SiteACLListResponse] +type siteACLListResponseJSON struct { + ACLs apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteACLListResponseACLsLAN2) UnmarshalJSON(data []byte) (err error) { +func (r *SiteACLListResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteACLListResponseACLsLan2JSON) RawJSON() string { +func (r siteACLListResponseJSON) RawJSON() string { return r.raw } -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLListResponseACLsLAN2Subnet interface { - ImplementsMagicTransitSiteACLListResponseACLsLan2Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLListResponseACLsLAN2Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Array of allowed communication protocols between configured LANs. If no -// protocols are provided, all protocols are allowed. -type SiteACLListResponseACLsProtocol string - -const ( - SiteACLListResponseACLsProtocolTcp SiteACLListResponseACLsProtocol = "tcp" - SiteACLListResponseACLsProtocolUdp SiteACLListResponseACLsProtocol = "udp" - SiteACLListResponseACLsProtocolIcmp SiteACLListResponseACLsProtocol = "icmp" -) - -func (r SiteACLListResponseACLsProtocol) IsKnown() bool { - switch r { - case SiteACLListResponseACLsProtocolTcp, SiteACLListResponseACLsProtocolUdp, SiteACLListResponseACLsProtocolIcmp: - return true - } - return false -} - type SiteACLDeleteResponse struct { Deleted bool `json:"deleted"` - // Bidirectional ACL policy for local network traffic within a site. - DeletedACL SiteACLDeleteResponseDeletedACL `json:"deleted_acl"` - JSON siteACLDeleteResponseJSON `json:"-"` + // Bidirectional ACL policy for network traffic within a site. + DeletedACL ACL `json:"deleted_acl"` + JSON siteACLDeleteResponseJSON `json:"-"` } // siteACLDeleteResponseJSON contains the JSON metadata for the struct @@ -675,354 +343,28 @@ func (r siteACLDeleteResponseJSON) RawJSON() string { return r.raw } -// Bidirectional ACL policy for local network traffic within a site. -type SiteACLDeleteResponseDeletedACL struct { - // Identifier - ID string `json:"id"` - // Description for the ACL. - Description string `json:"description"` - LAN1 SiteACLDeleteResponseDeletedACLLAN1 `json:"lan_1"` - LAN2 SiteACLDeleteResponseDeletedACLLAN2 `json:"lan_2"` - // The name of the ACL. - Name string `json:"name"` - Protocols []SiteACLDeleteResponseDeletedACLProtocol `json:"protocols"` - JSON siteACLDeleteResponseDeletedACLJSON `json:"-"` -} - -// siteACLDeleteResponseDeletedACLJSON contains the JSON metadata for the struct -// [SiteACLDeleteResponseDeletedACL] -type siteACLDeleteResponseDeletedACLJSON struct { - ID apijson.Field - Description apijson.Field - LAN1 apijson.Field - LAN2 apijson.Field - Name apijson.Field - Protocols apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLDeleteResponseDeletedACL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLDeleteResponseDeletedACLJSON) RawJSON() string { - return r.raw -} - -type SiteACLDeleteResponseDeletedACLLAN1 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLDeleteResponseDeletedACLLAN1Subnet `json:"subnets"` - JSON siteACLDeleteResponseDeletedAcllan1JSON `json:"-"` -} - -// siteACLDeleteResponseDeletedAcllan1JSON contains the JSON metadata for the -// struct [SiteACLDeleteResponseDeletedACLLAN1] -type siteACLDeleteResponseDeletedAcllan1JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLDeleteResponseDeletedACLLAN1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLDeleteResponseDeletedAcllan1JSON) RawJSON() string { - return r.raw -} - -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLDeleteResponseDeletedACLLAN1Subnet interface { - ImplementsMagicTransitSiteACLDeleteResponseDeletedAcllan1Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLDeleteResponseDeletedACLLAN1Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SiteACLDeleteResponseDeletedACLLAN2 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLDeleteResponseDeletedACLLAN2Subnet `json:"subnets"` - JSON siteACLDeleteResponseDeletedAcllan2JSON `json:"-"` -} - -// siteACLDeleteResponseDeletedAcllan2JSON contains the JSON metadata for the -// struct [SiteACLDeleteResponseDeletedACLLAN2] -type siteACLDeleteResponseDeletedAcllan2JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLDeleteResponseDeletedACLLAN2) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLDeleteResponseDeletedAcllan2JSON) RawJSON() string { - return r.raw -} - -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLDeleteResponseDeletedACLLAN2Subnet interface { - ImplementsMagicTransitSiteACLDeleteResponseDeletedAcllan2Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLDeleteResponseDeletedACLLAN2Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Array of allowed communication protocols between configured LANs. If no -// protocols are provided, all protocols are allowed. -type SiteACLDeleteResponseDeletedACLProtocol string - -const ( - SiteACLDeleteResponseDeletedACLProtocolTcp SiteACLDeleteResponseDeletedACLProtocol = "tcp" - SiteACLDeleteResponseDeletedACLProtocolUdp SiteACLDeleteResponseDeletedACLProtocol = "udp" - SiteACLDeleteResponseDeletedACLProtocolIcmp SiteACLDeleteResponseDeletedACLProtocol = "icmp" -) - -func (r SiteACLDeleteResponseDeletedACLProtocol) IsKnown() bool { - switch r { - case SiteACLDeleteResponseDeletedACLProtocolTcp, SiteACLDeleteResponseDeletedACLProtocolUdp, SiteACLDeleteResponseDeletedACLProtocolIcmp: - return true - } - return false -} - type SiteACLGetResponse struct { - // Bidirectional ACL policy for local network traffic within a site. - ACL SiteACLGetResponseACL `json:"acl"` + // Bidirectional ACL policy for network traffic within a site. + ACL ACL `json:"acl"` JSON siteACLGetResponseJSON `json:"-"` } // siteACLGetResponseJSON contains the JSON metadata for the struct // [SiteACLGetResponse] type siteACLGetResponseJSON struct { - ACL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLGetResponseJSON) RawJSON() string { - return r.raw -} - -// Bidirectional ACL policy for local network traffic within a site. -type SiteACLGetResponseACL struct { - // Identifier - ID string `json:"id"` - // Description for the ACL. - Description string `json:"description"` - LAN1 SiteACLGetResponseACLLAN1 `json:"lan_1"` - LAN2 SiteACLGetResponseACLLAN2 `json:"lan_2"` - // The name of the ACL. - Name string `json:"name"` - Protocols []SiteACLGetResponseACLProtocol `json:"protocols"` - JSON siteACLGetResponseACLJSON `json:"-"` -} - -// siteACLGetResponseACLJSON contains the JSON metadata for the struct -// [SiteACLGetResponseACL] -type siteACLGetResponseACLJSON struct { - ID apijson.Field - Description apijson.Field - LAN1 apijson.Field - LAN2 apijson.Field - Name apijson.Field - Protocols apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLGetResponseACL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLGetResponseACLJSON) RawJSON() string { - return r.raw -} - -type SiteACLGetResponseACLLAN1 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLGetResponseACLLAN1Subnet `json:"subnets"` - JSON siteACLGetResponseAcllan1JSON `json:"-"` -} - -// siteACLGetResponseAcllan1JSON contains the JSON metadata for the struct -// [SiteACLGetResponseACLLAN1] -type siteACLGetResponseAcllan1JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLGetResponseACLLAN1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLGetResponseAcllan1JSON) RawJSON() string { - return r.raw -} - -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLGetResponseACLLAN1Subnet interface { - ImplementsMagicTransitSiteACLGetResponseAcllan1Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLGetResponseACLLAN1Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SiteACLGetResponseACLLAN2 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID string `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName string `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports []int64 `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets []SiteACLGetResponseACLLAN2Subnet `json:"subnets"` - JSON siteACLGetResponseAcllan2JSON `json:"-"` -} - -// siteACLGetResponseAcllan2JSON contains the JSON metadata for the struct -// [SiteACLGetResponseACLLAN2] -type siteACLGetResponseAcllan2JSON struct { - LANID apijson.Field - LANName apijson.Field - Ports apijson.Field - Subnets apijson.Field + ACL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteACLGetResponseACLLAN2) UnmarshalJSON(data []byte) (err error) { +func (r *SiteACLGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteACLGetResponseAcllan2JSON) RawJSON() string { +func (r siteACLGetResponseJSON) RawJSON() string { return r.raw } -// A valid IPv4 address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type SiteACLGetResponseACLLAN2Subnet interface { - ImplementsMagicTransitSiteACLGetResponseAcllan2Subnet() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SiteACLGetResponseACLLAN2Subnet)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Array of allowed communication protocols between configured LANs. If no -// protocols are provided, all protocols are allowed. -type SiteACLGetResponseACLProtocol string - -const ( - SiteACLGetResponseACLProtocolTcp SiteACLGetResponseACLProtocol = "tcp" - SiteACLGetResponseACLProtocolUdp SiteACLGetResponseACLProtocol = "udp" - SiteACLGetResponseACLProtocolIcmp SiteACLGetResponseACLProtocol = "icmp" -) - -func (r SiteACLGetResponseACLProtocol) IsKnown() bool { - switch r { - case SiteACLGetResponseACLProtocolTcp, SiteACLGetResponseACLProtocolUdp, SiteACLGetResponseACLProtocolIcmp: - return true - } - return false -} - type SiteACLNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -1034,89 +376,28 @@ func (r SiteACLNewParams) MarshalJSON() (data []byte, err error) { } type SiteACLNewParamsACL struct { - LAN1 param.Field[SiteACLNewParamsACLLAN1] `json:"lan_1,required"` - LAN2 param.Field[SiteACLNewParamsACLLAN2] `json:"lan_2,required"` + LAN1 param.Field[ACLConfigurationParam] `json:"lan_1,required"` + LAN2 param.Field[ACLConfigurationParam] `json:"lan_2,required"` // The name of the ACL. Name param.Field[string] `json:"name,required"` // Description for the ACL. - Description param.Field[string] `json:"description"` - Protocols param.Field[[]SiteACLNewParamsACLProtocol] `json:"protocols"` + Description param.Field[string] `json:"description"` + // The desired forwarding action for this ACL policy. If set to "false", the policy + // will forward traffic to Cloudflare. If set to "true", the policy will forward + // traffic locally on the Magic WAN Connector. If not included in request, will + // default to false. + ForwardLocally param.Field[bool] `json:"forward_locally"` + Protocols param.Field[[]AllowedProtocol] `json:"protocols"` } func (r SiteACLNewParamsACL) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SiteACLNewParamsACLLAN1 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID param.Field[string] `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName param.Field[string] `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports param.Field[[]int64] `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets param.Field[[]SiteACLNewParamsACLLAN1Subnet] `json:"subnets"` -} - -func (r SiteACLNewParamsACLLAN1) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A valid IPv4 address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type SiteACLNewParamsACLLAN1Subnet interface { - ImplementsMagicTransitSiteACLNewParamsAcllan1Subnet() -} - -type SiteACLNewParamsACLLAN2 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID param.Field[string] `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName param.Field[string] `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports param.Field[[]int64] `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets param.Field[[]SiteACLNewParamsACLLAN2Subnet] `json:"subnets"` -} - -func (r SiteACLNewParamsACLLAN2) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A valid IPv4 address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type SiteACLNewParamsACLLAN2Subnet interface { - ImplementsMagicTransitSiteACLNewParamsAcllan2Subnet() -} - -// Array of allowed communication protocols between configured LANs. If no -// protocols are provided, all protocols are allowed. -type SiteACLNewParamsACLProtocol string - -const ( - SiteACLNewParamsACLProtocolTcp SiteACLNewParamsACLProtocol = "tcp" - SiteACLNewParamsACLProtocolUdp SiteACLNewParamsACLProtocol = "udp" - SiteACLNewParamsACLProtocolIcmp SiteACLNewParamsACLProtocol = "icmp" -) - -func (r SiteACLNewParamsACLProtocol) IsKnown() bool { - switch r { - case SiteACLNewParamsACLProtocolTcp, SiteACLNewParamsACLProtocolUdp, SiteACLNewParamsACLProtocolIcmp: - return true - } - return false -} - type SiteACLNewResponseEnvelope struct { - Errors []SiteACLNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteACLNewResponseEnvelopeMessages `json:"messages,required"` - Result SiteACLNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteACLNewResponse `json:"result,required"` // Whether the API call was successful Success SiteACLNewResponseEnvelopeSuccess `json:"success,required"` JSON siteACLNewResponseEnvelopeJSON `json:"-"` @@ -1141,52 +422,6 @@ func (r siteACLNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteACLNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteACLNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteACLNewResponseEnvelopeErrors] -type siteACLNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteACLNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteACLNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteACLNewResponseEnvelopeMessages] -type siteACLNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteACLNewResponseEnvelopeSuccess bool @@ -1214,88 +449,27 @@ func (r SiteACLUpdateParams) MarshalJSON() (data []byte, err error) { type SiteACLUpdateParamsACL struct { // Description for the ACL. - Description param.Field[string] `json:"description"` - LAN1 param.Field[SiteACLUpdateParamsACLLAN1] `json:"lan_1"` - LAN2 param.Field[SiteACLUpdateParamsACLLAN2] `json:"lan_2"` + Description param.Field[string] `json:"description"` + // The desired forwarding action for this ACL policy. If set to "false", the policy + // will forward traffic to Cloudflare. If set to "true", the policy will forward + // traffic locally on the Magic WAN Connector. If not included in request, will + // default to false. + ForwardLocally param.Field[bool] `json:"forward_locally"` + LAN1 param.Field[ACLConfigurationParam] `json:"lan_1"` + LAN2 param.Field[ACLConfigurationParam] `json:"lan_2"` // The name of the ACL. - Name param.Field[string] `json:"name"` - Protocols param.Field[[]SiteACLUpdateParamsACLProtocol] `json:"protocols"` + Name param.Field[string] `json:"name"` + Protocols param.Field[[]AllowedProtocol] `json:"protocols"` } func (r SiteACLUpdateParamsACL) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SiteACLUpdateParamsACLLAN1 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID param.Field[string] `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName param.Field[string] `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports param.Field[[]int64] `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets param.Field[[]SiteACLUpdateParamsACLLAN1Subnet] `json:"subnets"` -} - -func (r SiteACLUpdateParamsACLLAN1) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A valid IPv4 address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type SiteACLUpdateParamsACLLAN1Subnet interface { - ImplementsMagicTransitSiteACLUpdateParamsAcllan1Subnet() -} - -type SiteACLUpdateParamsACLLAN2 struct { - // The identifier for the LAN you want to create an ACL policy with. - LANID param.Field[string] `json:"lan_id,required"` - // The name of the LAN based on the provided lan_id. - LANName param.Field[string] `json:"lan_name"` - // Array of ports on the provided LAN that will be included in the ACL. If no ports - // are provided, communication on any port on this LAN is allowed. - Ports param.Field[[]int64] `json:"ports"` - // Array of subnet IPs within the LAN that will be included in the ACL. If no - // subnets are provided, communication on any subnets on this LAN are allowed. - Subnets param.Field[[]SiteACLUpdateParamsACLLAN2Subnet] `json:"subnets"` -} - -func (r SiteACLUpdateParamsACLLAN2) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A valid IPv4 address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type SiteACLUpdateParamsACLLAN2Subnet interface { - ImplementsMagicTransitSiteACLUpdateParamsAcllan2Subnet() -} - -// Array of allowed communication protocols between configured LANs. If no -// protocols are provided, all protocols are allowed. -type SiteACLUpdateParamsACLProtocol string - -const ( - SiteACLUpdateParamsACLProtocolTcp SiteACLUpdateParamsACLProtocol = "tcp" - SiteACLUpdateParamsACLProtocolUdp SiteACLUpdateParamsACLProtocol = "udp" - SiteACLUpdateParamsACLProtocolIcmp SiteACLUpdateParamsACLProtocol = "icmp" -) - -func (r SiteACLUpdateParamsACLProtocol) IsKnown() bool { - switch r { - case SiteACLUpdateParamsACLProtocolTcp, SiteACLUpdateParamsACLProtocolUdp, SiteACLUpdateParamsACLProtocolIcmp: - return true - } - return false -} - type SiteACLUpdateResponseEnvelope struct { - Errors []SiteACLUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteACLUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SiteACLUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteACLUpdateResponse `json:"result,required"` // Whether the API call was successful Success SiteACLUpdateResponseEnvelopeSuccess `json:"success,required"` JSON siteACLUpdateResponseEnvelopeJSON `json:"-"` @@ -1320,52 +494,6 @@ func (r siteACLUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteACLUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteACLUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SiteACLUpdateResponseEnvelopeErrors] -type siteACLUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteACLUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteACLUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteACLUpdateResponseEnvelopeMessages] -type siteACLUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteACLUpdateResponseEnvelopeSuccess bool @@ -1387,9 +515,9 @@ type SiteACLListParams struct { } type SiteACLListResponseEnvelope struct { - Errors []SiteACLListResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteACLListResponseEnvelopeMessages `json:"messages,required"` - Result SiteACLListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteACLListResponse `json:"result,required"` // Whether the API call was successful Success SiteACLListResponseEnvelopeSuccess `json:"success,required"` JSON siteACLListResponseEnvelopeJSON `json:"-"` @@ -1414,52 +542,6 @@ func (r siteACLListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteACLListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLListResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteACLListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteACLListResponseEnvelopeErrors] -type siteACLListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteACLListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLListResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteACLListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteACLListResponseEnvelopeMessages] -type siteACLListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteACLListResponseEnvelopeSuccess bool @@ -1478,12 +560,17 @@ func (r SiteACLListResponseEnvelopeSuccess) IsKnown() bool { type SiteACLDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r SiteACLDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type SiteACLDeleteResponseEnvelope struct { - Errors []SiteACLDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteACLDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SiteACLDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteACLDeleteResponse `json:"result,required"` // Whether the API call was successful Success SiteACLDeleteResponseEnvelopeSuccess `json:"success,required"` JSON siteACLDeleteResponseEnvelopeJSON `json:"-"` @@ -1508,52 +595,6 @@ func (r siteACLDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteACLDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteACLDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SiteACLDeleteResponseEnvelopeErrors] -type siteACLDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteACLDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteACLDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteACLDeleteResponseEnvelopeMessages] -type siteACLDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteACLDeleteResponseEnvelopeSuccess bool @@ -1575,9 +616,9 @@ type SiteACLGetParams struct { } type SiteACLGetResponseEnvelope struct { - Errors []SiteACLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteACLGetResponseEnvelopeMessages `json:"messages,required"` - Result SiteACLGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteACLGetResponse `json:"result,required"` // Whether the API call was successful Success SiteACLGetResponseEnvelopeSuccess `json:"success,required"` JSON siteACLGetResponseEnvelopeJSON `json:"-"` @@ -1602,52 +643,6 @@ func (r siteACLGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteACLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteACLGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteACLGetResponseEnvelopeErrors] -type siteACLGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteACLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteACLGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteACLGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteACLGetResponseEnvelopeMessages] -type siteACLGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteACLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteACLGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteACLGetResponseEnvelopeSuccess bool diff --git a/magic_transit/siteacl_test.go b/magic_transit/siteacl_test.go index d473c2c6f0d..168684be874 100644 --- a/magic_transit/siteacl_test.go +++ b/magic_transit/siteacl_test.go @@ -35,21 +35,22 @@ func TestSiteACLNewWithOptionalParams(t *testing.T) { magic_transit.SiteACLNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), ACL: cloudflare.F(magic_transit.SiteACLNewParamsACL{ - Description: cloudflare.F("Allows local traffic between PIN pads and cash register."), - LAN1: cloudflare.F(magic_transit.SiteACLNewParamsACLLAN1{ + Description: cloudflare.F("Allows local traffic between PIN pads and cash register."), + ForwardLocally: cloudflare.F(true), + LAN1: cloudflare.F(magic_transit.ACLConfigurationParam{ LANID: cloudflare.F("string"), LANName: cloudflare.F("string"), Ports: cloudflare.F([]int64{int64(1), int64(1), int64(1)}), - Subnets: cloudflare.F([]magic_transit.SiteACLNewParamsACLLAN1Subnet{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), + Subnets: cloudflare.F([]magic_transit.SubnetUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), }), - LAN2: cloudflare.F(magic_transit.SiteACLNewParamsACLLAN2{ + LAN2: cloudflare.F(magic_transit.ACLConfigurationParam{ LANID: cloudflare.F("string"), LANName: cloudflare.F("string"), Ports: cloudflare.F([]int64{int64(1), int64(1), int64(1)}), - Subnets: cloudflare.F([]magic_transit.SiteACLNewParamsACLLAN2Subnet{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), + Subnets: cloudflare.F([]magic_transit.SubnetUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), }), Name: cloudflare.F("PIN Pad - Cash Register"), - Protocols: cloudflare.F([]magic_transit.SiteACLNewParamsACLProtocol{magic_transit.SiteACLNewParamsACLProtocolTcp, magic_transit.SiteACLNewParamsACLProtocolUdp, magic_transit.SiteACLNewParamsACLProtocolIcmp}), + Protocols: cloudflare.F([]magic_transit.AllowedProtocol{magic_transit.AllowedProtocolTCP, magic_transit.AllowedProtocolUdp, magic_transit.AllowedProtocolIcmp}), }), }, ) @@ -83,21 +84,22 @@ func TestSiteACLUpdateWithOptionalParams(t *testing.T) { magic_transit.SiteACLUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), ACL: cloudflare.F(magic_transit.SiteACLUpdateParamsACL{ - Description: cloudflare.F("Allows local traffic between PIN pads and cash register."), - LAN1: cloudflare.F(magic_transit.SiteACLUpdateParamsACLLAN1{ + Description: cloudflare.F("Allows local traffic between PIN pads and cash register."), + ForwardLocally: cloudflare.F(true), + LAN1: cloudflare.F(magic_transit.ACLConfigurationParam{ LANID: cloudflare.F("string"), LANName: cloudflare.F("string"), Ports: cloudflare.F([]int64{int64(1), int64(1), int64(1)}), - Subnets: cloudflare.F([]magic_transit.SiteACLUpdateParamsACLLAN1Subnet{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), + Subnets: cloudflare.F([]magic_transit.SubnetUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), }), - LAN2: cloudflare.F(magic_transit.SiteACLUpdateParamsACLLAN2{ + LAN2: cloudflare.F(magic_transit.ACLConfigurationParam{ LANID: cloudflare.F("string"), LANName: cloudflare.F("string"), Ports: cloudflare.F([]int64{int64(1), int64(1), int64(1)}), - Subnets: cloudflare.F([]magic_transit.SiteACLUpdateParamsACLLAN2Subnet{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), + Subnets: cloudflare.F([]magic_transit.SubnetUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1"), shared.UnionString("192.0.2.1")}), }), Name: cloudflare.F("PIN Pad - Cash Register"), - Protocols: cloudflare.F([]magic_transit.SiteACLUpdateParamsACLProtocol{magic_transit.SiteACLUpdateParamsACLProtocolTcp, magic_transit.SiteACLUpdateParamsACLProtocolUdp, magic_transit.SiteACLUpdateParamsACLProtocolIcmp}), + Protocols: cloudflare.F([]magic_transit.AllowedProtocol{magic_transit.AllowedProtocolTCP, magic_transit.AllowedProtocolUdp, magic_transit.AllowedProtocolIcmp}), }), }, ) @@ -160,6 +162,7 @@ func TestSiteACLDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteACLDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_transit/sitelan.go b/magic_transit/sitelan.go index e5bbd27e1e0..219802b42ee 100644 --- a/magic_transit/sitelan.go +++ b/magic_transit/sitelan.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -71,10 +72,10 @@ func (r *SiteLANService) List(ctx context.Context, siteID string, query SiteLANL } // Remove a specific LAN. -func (r *SiteLANService) Delete(ctx context.Context, siteID string, lanID string, body SiteLANDeleteParams, opts ...option.RequestOption) (res *SiteLANDeleteResponse, err error) { +func (r *SiteLANService) Delete(ctx context.Context, siteID string, lanID string, params SiteLANDeleteParams, opts ...option.RequestOption) (res *SiteLANDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env SiteLANDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/sites/%s/lans/%s", body.AccountID, siteID, lanID) + path := fmt.Sprintf("accounts/%s/magic/sites/%s/lans/%s", params.AccountID, siteID, lanID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -96,276 +97,104 @@ func (r *SiteLANService) Get(ctx context.Context, siteID string, lanID string, q return } -type SiteLANNewResponse struct { - LANs []SiteLANNewResponseLAN `json:"lans"` - JSON siteLANNewResponseJSON `json:"-"` -} - -// siteLANNewResponseJSON contains the JSON metadata for the struct -// [SiteLANNewResponse] -type siteLANNewResponseJSON struct { - LANs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANNewResponseJSON) RawJSON() string { - return r.raw -} - -type SiteLANNewResponseLAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - // mark true to use this LAN for HA probing. only works for site with HA turned on. - // only one LAN can be set as the ha_link. - HaLink bool `json:"ha_link"` - Nat SiteLANNewResponseLANsNat `json:"nat"` - Physport int64 `json:"physport"` - RoutedSubnets []SiteLANNewResponseLANsRoutedSubnet `json:"routed_subnets"` - // Identifier - SiteID string `json:"site_id"` - // If the site is not configured in high availability mode, this configuration is - // optional (if omitted, use DHCP). However, if in high availability mode, - // static_address is required along with secondary and virtual address. - StaticAddressing SiteLANNewResponseLANsStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteLANNewResponseLANJSON `json:"-"` -} - -// siteLANNewResponseLANJSON contains the JSON metadata for the struct -// [SiteLANNewResponseLAN] -type siteLANNewResponseLANJSON struct { - ID apijson.Field - Description apijson.Field - HaLink apijson.Field - Nat apijson.Field - Physport apijson.Field - RoutedSubnets apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponseLAN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANNewResponseLANJSON) RawJSON() string { - return r.raw -} - -type SiteLANNewResponseLANsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANNewResponseLANsNatJSON `json:"-"` -} - -// siteLANNewResponseLANsNatJSON contains the JSON metadata for the struct -// [SiteLANNewResponseLANsNat] -type siteLANNewResponseLANsNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponseLANsNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANNewResponseLANsNatJSON) RawJSON() string { - return r.raw -} - -type SiteLANNewResponseLANsRoutedSubnet struct { - // A valid IPv4 address. - NextHop string `json:"next_hop,required"` - // A valid CIDR notation representing an IP range. - Prefix string `json:"prefix,required"` - Nat SiteLANNewResponseLANsRoutedSubnetsNat `json:"nat"` - JSON siteLANNewResponseLANsRoutedSubnetJSON `json:"-"` -} - -// siteLANNewResponseLANsRoutedSubnetJSON contains the JSON metadata for the struct -// [SiteLANNewResponseLANsRoutedSubnet] -type siteLANNewResponseLANsRoutedSubnetJSON struct { - NextHop apijson.Field - Prefix apijson.Field - Nat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponseLANsRoutedSubnet) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANNewResponseLANsRoutedSubnetJSON) RawJSON() string { - return r.raw -} - -type SiteLANNewResponseLANsRoutedSubnetsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANNewResponseLANsRoutedSubnetsNatJSON `json:"-"` -} - -// siteLANNewResponseLANsRoutedSubnetsNatJSON contains the JSON metadata for the -// struct [SiteLANNewResponseLANsRoutedSubnetsNat] -type siteLANNewResponseLANsRoutedSubnetsNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponseLANsRoutedSubnetsNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANNewResponseLANsRoutedSubnetsNatJSON) RawJSON() string { - return r.raw -} - -// If the site is not configured in high availability mode, this configuration is -// optional (if omitted, use DHCP). However, if in high availability mode, -// static_address is required along with secondary and virtual address. -type SiteLANNewResponseLANsStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - DhcpRelay SiteLANNewResponseLANsStaticAddressingDhcpRelay `json:"dhcp_relay"` - DhcpServer SiteLANNewResponseLANsStaticAddressingDhcpServer `json:"dhcp_server"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - // A valid CIDR notation representing an IP range. - VirtualAddress string `json:"virtual_address"` - JSON siteLANNewResponseLANsStaticAddressingJSON `json:"-"` +type DHCPRelay struct { + // List of DHCP server IPs. + ServerAddresses []string `json:"server_addresses"` + JSON dhcpRelayJSON `json:"-"` } -// siteLANNewResponseLANsStaticAddressingJSON contains the JSON metadata for the -// struct [SiteLANNewResponseLANsStaticAddressing] -type siteLANNewResponseLANsStaticAddressingJSON struct { - Address apijson.Field - DhcpRelay apijson.Field - DhcpServer apijson.Field - SecondaryAddress apijson.Field - VirtualAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field +// dhcpRelayJSON contains the JSON metadata for the struct [DHCPRelay] +type dhcpRelayJSON struct { + ServerAddresses apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteLANNewResponseLANsStaticAddressing) UnmarshalJSON(data []byte) (err error) { +func (r *DHCPRelay) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANNewResponseLANsStaticAddressingJSON) RawJSON() string { +func (r dhcpRelayJSON) RawJSON() string { return r.raw } -type SiteLANNewResponseLANsStaticAddressingDhcpRelay struct { +type DHCPRelayParam struct { // List of DHCP server IPs. - ServerAddresses []string `json:"server_addresses"` - JSON siteLANNewResponseLANsStaticAddressingDhcpRelayJSON `json:"-"` -} - -// siteLANNewResponseLANsStaticAddressingDhcpRelayJSON contains the JSON metadata -// for the struct [SiteLANNewResponseLANsStaticAddressingDhcpRelay] -type siteLANNewResponseLANsStaticAddressingDhcpRelayJSON struct { - ServerAddresses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponseLANsStaticAddressingDhcpRelay) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + ServerAddresses param.Field[[]string] `json:"server_addresses"` } -func (r siteLANNewResponseLANsStaticAddressingDhcpRelayJSON) RawJSON() string { - return r.raw +func (r DHCPRelayParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type SiteLANNewResponseLANsStaticAddressingDhcpServer struct { +type DHCPServer struct { // A valid IPv4 address. - DhcpPoolEnd string `json:"dhcp_pool_end"` + DHCPPoolEnd string `json:"dhcp_pool_end"` // A valid IPv4 address. - DhcpPoolStart string `json:"dhcp_pool_start"` + DHCPPoolStart string `json:"dhcp_pool_start"` // A valid IPv4 address. DNSServer string `json:"dns_server"` // Mapping of MAC addresses to IP addresses - Reservations map[string]string `json:"reservations"` - JSON siteLANNewResponseLANsStaticAddressingDhcpServerJSON `json:"-"` + Reservations map[string]string `json:"reservations"` + JSON dhcpServerJSON `json:"-"` } -// siteLANNewResponseLANsStaticAddressingDhcpServerJSON contains the JSON metadata -// for the struct [SiteLANNewResponseLANsStaticAddressingDhcpServer] -type siteLANNewResponseLANsStaticAddressingDhcpServerJSON struct { - DhcpPoolEnd apijson.Field - DhcpPoolStart apijson.Field +// dhcpServerJSON contains the JSON metadata for the struct [DHCPServer] +type dhcpServerJSON struct { + DHCPPoolEnd apijson.Field + DHCPPoolStart apijson.Field DNSServer apijson.Field Reservations apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteLANNewResponseLANsStaticAddressingDhcpServer) UnmarshalJSON(data []byte) (err error) { +func (r *DHCPServer) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANNewResponseLANsStaticAddressingDhcpServerJSON) RawJSON() string { +func (r dhcpServerJSON) RawJSON() string { return r.raw } -type SiteLANUpdateResponse struct { - LAN SiteLANUpdateResponseLAN `json:"lan"` - JSON siteLANUpdateResponseJSON `json:"-"` -} - -// siteLANUpdateResponseJSON contains the JSON metadata for the struct -// [SiteLANUpdateResponse] -type siteLANUpdateResponseJSON struct { - LAN apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type DHCPServerParam struct { + // A valid IPv4 address. + DHCPPoolEnd param.Field[string] `json:"dhcp_pool_end"` + // A valid IPv4 address. + DHCPPoolStart param.Field[string] `json:"dhcp_pool_start"` + // A valid IPv4 address. + DNSServer param.Field[string] `json:"dns_server"` + // Mapping of MAC addresses to IP addresses + Reservations param.Field[map[string]string] `json:"reservations"` } -func (r siteLANUpdateResponseJSON) RawJSON() string { - return r.raw +func (r DHCPServerParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type SiteLANUpdateResponseLAN struct { +type LAN struct { // Identifier ID string `json:"id"` Description string `json:"description"` // mark true to use this LAN for HA probing. only works for site with HA turned on. // only one LAN can be set as the ha_link. - HaLink bool `json:"ha_link"` - Nat SiteLANUpdateResponseLANNat `json:"nat"` - Physport int64 `json:"physport"` - RoutedSubnets []SiteLANUpdateResponseLANRoutedSubnet `json:"routed_subnets"` + HaLink bool `json:"ha_link"` + Nat Nat `json:"nat"` + Physport int64 `json:"physport"` + RoutedSubnets []RoutedSubnet `json:"routed_subnets"` // Identifier SiteID string `json:"site_id"` // If the site is not configured in high availability mode, this configuration is // optional (if omitted, use DHCP). However, if in high availability mode, // static_address is required along with secondary and virtual address. - StaticAddressing SiteLANUpdateResponseLANStaticAddressing `json:"static_addressing"` + StaticAddressing LANStaticAddressing `json:"static_addressing"` // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteLANUpdateResponseLANJSON `json:"-"` + VlanTag int64 `json:"vlan_tag"` + JSON lanJSON `json:"-"` } -// siteLANUpdateResponseLANJSON contains the JSON metadata for the struct -// [SiteLANUpdateResponseLAN] -type siteLANUpdateResponseLANJSON struct { +// lanJSON contains the JSON metadata for the struct [LAN] +type lanJSON struct { ID apijson.Field Description apijson.Field HaLink apijson.Field @@ -379,176 +208,180 @@ type siteLANUpdateResponseLANJSON struct { ExtraFields map[string]apijson.Field } -func (r *SiteLANUpdateResponseLAN) UnmarshalJSON(data []byte) (err error) { +func (r *LAN) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANUpdateResponseLANJSON) RawJSON() string { +func (r lanJSON) RawJSON() string { return r.raw } -type SiteLANUpdateResponseLANNat struct { +// If the site is not configured in high availability mode, this configuration is +// optional (if omitted, use DHCP). However, if in high availability mode, +// static_address is required along with secondary and virtual address. +type LANStaticAddressing struct { + // A valid CIDR notation representing an IP range. + Address string `json:"address,required"` + DHCPRelay DHCPRelay `json:"dhcp_relay"` + DHCPServer DHCPServer `json:"dhcp_server"` // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANUpdateResponseLANNatJSON `json:"-"` + SecondaryAddress string `json:"secondary_address"` + // A valid CIDR notation representing an IP range. + VirtualAddress string `json:"virtual_address"` + JSON lanStaticAddressingJSON `json:"-"` } -// siteLANUpdateResponseLANNatJSON contains the JSON metadata for the struct -// [SiteLANUpdateResponseLANNat] -type siteLANUpdateResponseLANNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field +// lanStaticAddressingJSON contains the JSON metadata for the struct +// [LANStaticAddressing] +type lanStaticAddressingJSON struct { + Address apijson.Field + DHCPRelay apijson.Field + DHCPServer apijson.Field + SecondaryAddress apijson.Field + VirtualAddress apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteLANUpdateResponseLANNat) UnmarshalJSON(data []byte) (err error) { +func (r *LANStaticAddressing) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANUpdateResponseLANNatJSON) RawJSON() string { +func (r lanStaticAddressingJSON) RawJSON() string { return r.raw } -type SiteLANUpdateResponseLANRoutedSubnet struct { - // A valid IPv4 address. - NextHop string `json:"next_hop,required"` +// If the site is not configured in high availability mode, this configuration is +// optional (if omitted, use DHCP). However, if in high availability mode, +// static_address is required along with secondary and virtual address. +type LANStaticAddressingParam struct { // A valid CIDR notation representing an IP range. - Prefix string `json:"prefix,required"` - Nat SiteLANUpdateResponseLANRoutedSubnetsNat `json:"nat"` - JSON siteLANUpdateResponseLANRoutedSubnetJSON `json:"-"` -} - -// siteLANUpdateResponseLANRoutedSubnetJSON contains the JSON metadata for the -// struct [SiteLANUpdateResponseLANRoutedSubnet] -type siteLANUpdateResponseLANRoutedSubnetJSON struct { - NextHop apijson.Field - Prefix apijson.Field - Nat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANUpdateResponseLANRoutedSubnet) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + Address param.Field[string] `json:"address,required"` + DHCPRelay param.Field[DHCPRelayParam] `json:"dhcp_relay"` + DHCPServer param.Field[DHCPServerParam] `json:"dhcp_server"` + // A valid CIDR notation representing an IP range. + SecondaryAddress param.Field[string] `json:"secondary_address"` + // A valid CIDR notation representing an IP range. + VirtualAddress param.Field[string] `json:"virtual_address"` } -func (r siteLANUpdateResponseLANRoutedSubnetJSON) RawJSON() string { - return r.raw +func (r LANStaticAddressingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type SiteLANUpdateResponseLANRoutedSubnetsNat struct { +type Nat struct { // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANUpdateResponseLANRoutedSubnetsNatJSON `json:"-"` + StaticPrefix string `json:"static_prefix"` + JSON natJSON `json:"-"` } -// siteLANUpdateResponseLANRoutedSubnetsNatJSON contains the JSON metadata for the -// struct [SiteLANUpdateResponseLANRoutedSubnetsNat] -type siteLANUpdateResponseLANRoutedSubnetsNatJSON struct { +// natJSON contains the JSON metadata for the struct [Nat] +type natJSON struct { StaticPrefix apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SiteLANUpdateResponseLANRoutedSubnetsNat) UnmarshalJSON(data []byte) (err error) { +func (r *Nat) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANUpdateResponseLANRoutedSubnetsNatJSON) RawJSON() string { +func (r natJSON) RawJSON() string { return r.raw } -// If the site is not configured in high availability mode, this configuration is -// optional (if omitted, use DHCP). However, if in high availability mode, -// static_address is required along with secondary and virtual address. -type SiteLANUpdateResponseLANStaticAddressing struct { +type NatParam struct { // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - DhcpRelay SiteLANUpdateResponseLANStaticAddressingDhcpRelay `json:"dhcp_relay"` - DhcpServer SiteLANUpdateResponseLANStaticAddressingDhcpServer `json:"dhcp_server"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` + StaticPrefix param.Field[string] `json:"static_prefix"` +} + +func (r NatParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RoutedSubnet struct { + // A valid IPv4 address. + NextHop string `json:"next_hop,required"` // A valid CIDR notation representing an IP range. - VirtualAddress string `json:"virtual_address"` - JSON siteLANUpdateResponseLANStaticAddressingJSON `json:"-"` + Prefix string `json:"prefix,required"` + Nat Nat `json:"nat"` + JSON routedSubnetJSON `json:"-"` } -// siteLANUpdateResponseLANStaticAddressingJSON contains the JSON metadata for the -// struct [SiteLANUpdateResponseLANStaticAddressing] -type siteLANUpdateResponseLANStaticAddressingJSON struct { - Address apijson.Field - DhcpRelay apijson.Field - DhcpServer apijson.Field - SecondaryAddress apijson.Field - VirtualAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field +// routedSubnetJSON contains the JSON metadata for the struct [RoutedSubnet] +type routedSubnetJSON struct { + NextHop apijson.Field + Prefix apijson.Field + Nat apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteLANUpdateResponseLANStaticAddressing) UnmarshalJSON(data []byte) (err error) { +func (r *RoutedSubnet) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANUpdateResponseLANStaticAddressingJSON) RawJSON() string { +func (r routedSubnetJSON) RawJSON() string { return r.raw } -type SiteLANUpdateResponseLANStaticAddressingDhcpRelay struct { - // List of DHCP server IPs. - ServerAddresses []string `json:"server_addresses"` - JSON siteLANUpdateResponseLANStaticAddressingDhcpRelayJSON `json:"-"` +type RoutedSubnetParam struct { + // A valid IPv4 address. + NextHop param.Field[string] `json:"next_hop,required"` + // A valid CIDR notation representing an IP range. + Prefix param.Field[string] `json:"prefix,required"` + Nat param.Field[NatParam] `json:"nat"` } -// siteLANUpdateResponseLANStaticAddressingDhcpRelayJSON contains the JSON metadata -// for the struct [SiteLANUpdateResponseLANStaticAddressingDhcpRelay] -type siteLANUpdateResponseLANStaticAddressingDhcpRelayJSON struct { - ServerAddresses apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r RoutedSubnetParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SiteLANNewResponse struct { + LANs []LAN `json:"lans"` + JSON siteLANNewResponseJSON `json:"-"` +} + +// siteLANNewResponseJSON contains the JSON metadata for the struct +// [SiteLANNewResponse] +type siteLANNewResponseJSON struct { + LANs apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteLANUpdateResponseLANStaticAddressingDhcpRelay) UnmarshalJSON(data []byte) (err error) { +func (r *SiteLANNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANUpdateResponseLANStaticAddressingDhcpRelayJSON) RawJSON() string { +func (r siteLANNewResponseJSON) RawJSON() string { return r.raw } -type SiteLANUpdateResponseLANStaticAddressingDhcpServer struct { - // A valid IPv4 address. - DhcpPoolEnd string `json:"dhcp_pool_end"` - // A valid IPv4 address. - DhcpPoolStart string `json:"dhcp_pool_start"` - // A valid IPv4 address. - DNSServer string `json:"dns_server"` - // Mapping of MAC addresses to IP addresses - Reservations map[string]string `json:"reservations"` - JSON siteLANUpdateResponseLANStaticAddressingDhcpServerJSON `json:"-"` +type SiteLANUpdateResponse struct { + LAN LAN `json:"lan"` + JSON siteLANUpdateResponseJSON `json:"-"` } -// siteLANUpdateResponseLANStaticAddressingDhcpServerJSON contains the JSON -// metadata for the struct [SiteLANUpdateResponseLANStaticAddressingDhcpServer] -type siteLANUpdateResponseLANStaticAddressingDhcpServerJSON struct { - DhcpPoolEnd apijson.Field - DhcpPoolStart apijson.Field - DNSServer apijson.Field - Reservations apijson.Field - raw string - ExtraFields map[string]apijson.Field +// siteLANUpdateResponseJSON contains the JSON metadata for the struct +// [SiteLANUpdateResponse] +type siteLANUpdateResponseJSON struct { + LAN apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteLANUpdateResponseLANStaticAddressingDhcpServer) UnmarshalJSON(data []byte) (err error) { +func (r *SiteLANUpdateResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANUpdateResponseLANStaticAddressingDhcpServerJSON) RawJSON() string { +func (r siteLANUpdateResponseJSON) RawJSON() string { return r.raw } type SiteLANListResponse struct { - LANs []SiteLANListResponseLAN `json:"lans"` - JSON siteLANListResponseJSON `json:"-"` + LANs []LAN `json:"lans"` + JSON siteLANListResponseJSON `json:"-"` } // siteLANListResponseJSON contains the JSON metadata for the struct @@ -567,661 +400,47 @@ func (r siteLANListResponseJSON) RawJSON() string { return r.raw } -type SiteLANListResponseLAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - // mark true to use this LAN for HA probing. only works for site with HA turned on. - // only one LAN can be set as the ha_link. - HaLink bool `json:"ha_link"` - Nat SiteLANListResponseLANsNat `json:"nat"` - Physport int64 `json:"physport"` - RoutedSubnets []SiteLANListResponseLANsRoutedSubnet `json:"routed_subnets"` - // Identifier - SiteID string `json:"site_id"` - // If the site is not configured in high availability mode, this configuration is - // optional (if omitted, use DHCP). However, if in high availability mode, - // static_address is required along with secondary and virtual address. - StaticAddressing SiteLANListResponseLANsStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteLANListResponseLANJSON `json:"-"` -} - -// siteLANListResponseLANJSON contains the JSON metadata for the struct -// [SiteLANListResponseLAN] -type siteLANListResponseLANJSON struct { - ID apijson.Field - Description apijson.Field - HaLink apijson.Field - Nat apijson.Field - Physport apijson.Field - RoutedSubnets apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseLAN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseLANJSON) RawJSON() string { - return r.raw -} - -type SiteLANListResponseLANsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANListResponseLANsNatJSON `json:"-"` -} - -// siteLANListResponseLANsNatJSON contains the JSON metadata for the struct -// [SiteLANListResponseLANsNat] -type siteLANListResponseLANsNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseLANsNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseLANsNatJSON) RawJSON() string { - return r.raw -} - -type SiteLANListResponseLANsRoutedSubnet struct { - // A valid IPv4 address. - NextHop string `json:"next_hop,required"` - // A valid CIDR notation representing an IP range. - Prefix string `json:"prefix,required"` - Nat SiteLANListResponseLANsRoutedSubnetsNat `json:"nat"` - JSON siteLANListResponseLANsRoutedSubnetJSON `json:"-"` -} - -// siteLANListResponseLANsRoutedSubnetJSON contains the JSON metadata for the -// struct [SiteLANListResponseLANsRoutedSubnet] -type siteLANListResponseLANsRoutedSubnetJSON struct { - NextHop apijson.Field - Prefix apijson.Field - Nat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseLANsRoutedSubnet) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseLANsRoutedSubnetJSON) RawJSON() string { - return r.raw -} - -type SiteLANListResponseLANsRoutedSubnetsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANListResponseLANsRoutedSubnetsNatJSON `json:"-"` -} - -// siteLANListResponseLANsRoutedSubnetsNatJSON contains the JSON metadata for the -// struct [SiteLANListResponseLANsRoutedSubnetsNat] -type siteLANListResponseLANsRoutedSubnetsNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseLANsRoutedSubnetsNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseLANsRoutedSubnetsNatJSON) RawJSON() string { - return r.raw -} - -// If the site is not configured in high availability mode, this configuration is -// optional (if omitted, use DHCP). However, if in high availability mode, -// static_address is required along with secondary and virtual address. -type SiteLANListResponseLANsStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - DhcpRelay SiteLANListResponseLANsStaticAddressingDhcpRelay `json:"dhcp_relay"` - DhcpServer SiteLANListResponseLANsStaticAddressingDhcpServer `json:"dhcp_server"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - // A valid CIDR notation representing an IP range. - VirtualAddress string `json:"virtual_address"` - JSON siteLANListResponseLANsStaticAddressingJSON `json:"-"` -} - -// siteLANListResponseLANsStaticAddressingJSON contains the JSON metadata for the -// struct [SiteLANListResponseLANsStaticAddressing] -type siteLANListResponseLANsStaticAddressingJSON struct { - Address apijson.Field - DhcpRelay apijson.Field - DhcpServer apijson.Field - SecondaryAddress apijson.Field - VirtualAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseLANsStaticAddressing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseLANsStaticAddressingJSON) RawJSON() string { - return r.raw -} - -type SiteLANListResponseLANsStaticAddressingDhcpRelay struct { - // List of DHCP server IPs. - ServerAddresses []string `json:"server_addresses"` - JSON siteLANListResponseLANsStaticAddressingDhcpRelayJSON `json:"-"` -} - -// siteLANListResponseLANsStaticAddressingDhcpRelayJSON contains the JSON metadata -// for the struct [SiteLANListResponseLANsStaticAddressingDhcpRelay] -type siteLANListResponseLANsStaticAddressingDhcpRelayJSON struct { - ServerAddresses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseLANsStaticAddressingDhcpRelay) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseLANsStaticAddressingDhcpRelayJSON) RawJSON() string { - return r.raw -} - -type SiteLANListResponseLANsStaticAddressingDhcpServer struct { - // A valid IPv4 address. - DhcpPoolEnd string `json:"dhcp_pool_end"` - // A valid IPv4 address. - DhcpPoolStart string `json:"dhcp_pool_start"` - // A valid IPv4 address. - DNSServer string `json:"dns_server"` - // Mapping of MAC addresses to IP addresses - Reservations map[string]string `json:"reservations"` - JSON siteLANListResponseLANsStaticAddressingDhcpServerJSON `json:"-"` -} - -// siteLANListResponseLANsStaticAddressingDhcpServerJSON contains the JSON metadata -// for the struct [SiteLANListResponseLANsStaticAddressingDhcpServer] -type siteLANListResponseLANsStaticAddressingDhcpServerJSON struct { - DhcpPoolEnd apijson.Field - DhcpPoolStart apijson.Field - DNSServer apijson.Field - Reservations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseLANsStaticAddressingDhcpServer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseLANsStaticAddressingDhcpServerJSON) RawJSON() string { - return r.raw -} - type SiteLANDeleteResponse struct { - Deleted bool `json:"deleted"` - DeletedLAN SiteLANDeleteResponseDeletedLAN `json:"deleted_lan"` - JSON siteLANDeleteResponseJSON `json:"-"` -} - -// siteLANDeleteResponseJSON contains the JSON metadata for the struct -// [SiteLANDeleteResponse] -type siteLANDeleteResponseJSON struct { - Deleted apijson.Field - DeletedLAN apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SiteLANDeleteResponseDeletedLAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - // mark true to use this LAN for HA probing. only works for site with HA turned on. - // only one LAN can be set as the ha_link. - HaLink bool `json:"ha_link"` - Nat SiteLANDeleteResponseDeletedLANNat `json:"nat"` - Physport int64 `json:"physport"` - RoutedSubnets []SiteLANDeleteResponseDeletedLANRoutedSubnet `json:"routed_subnets"` - // Identifier - SiteID string `json:"site_id"` - // If the site is not configured in high availability mode, this configuration is - // optional (if omitted, use DHCP). However, if in high availability mode, - // static_address is required along with secondary and virtual address. - StaticAddressing SiteLANDeleteResponseDeletedLANStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteLANDeleteResponseDeletedLANJSON `json:"-"` -} - -// siteLANDeleteResponseDeletedLANJSON contains the JSON metadata for the struct -// [SiteLANDeleteResponseDeletedLAN] -type siteLANDeleteResponseDeletedLANJSON struct { - ID apijson.Field - Description apijson.Field - HaLink apijson.Field - Nat apijson.Field - Physport apijson.Field - RoutedSubnets apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseDeletedLAN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseDeletedLANJSON) RawJSON() string { - return r.raw -} - -type SiteLANDeleteResponseDeletedLANNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANDeleteResponseDeletedLANNatJSON `json:"-"` + Deleted bool `json:"deleted"` + DeletedLAN LAN `json:"deleted_lan"` + JSON siteLANDeleteResponseJSON `json:"-"` } -// siteLANDeleteResponseDeletedLANNatJSON contains the JSON metadata for the struct -// [SiteLANDeleteResponseDeletedLANNat] -type siteLANDeleteResponseDeletedLANNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseDeletedLANNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseDeletedLANNatJSON) RawJSON() string { - return r.raw -} - -type SiteLANDeleteResponseDeletedLANRoutedSubnet struct { - // A valid IPv4 address. - NextHop string `json:"next_hop,required"` - // A valid CIDR notation representing an IP range. - Prefix string `json:"prefix,required"` - Nat SiteLANDeleteResponseDeletedLANRoutedSubnetsNat `json:"nat"` - JSON siteLANDeleteResponseDeletedLANRoutedSubnetJSON `json:"-"` -} - -// siteLANDeleteResponseDeletedLANRoutedSubnetJSON contains the JSON metadata for -// the struct [SiteLANDeleteResponseDeletedLANRoutedSubnet] -type siteLANDeleteResponseDeletedLANRoutedSubnetJSON struct { - NextHop apijson.Field - Prefix apijson.Field - Nat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseDeletedLANRoutedSubnet) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseDeletedLANRoutedSubnetJSON) RawJSON() string { - return r.raw -} - -type SiteLANDeleteResponseDeletedLANRoutedSubnetsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANDeleteResponseDeletedLANRoutedSubnetsNatJSON `json:"-"` -} - -// siteLANDeleteResponseDeletedLANRoutedSubnetsNatJSON contains the JSON metadata -// for the struct [SiteLANDeleteResponseDeletedLANRoutedSubnetsNat] -type siteLANDeleteResponseDeletedLANRoutedSubnetsNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseDeletedLANRoutedSubnetsNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseDeletedLANRoutedSubnetsNatJSON) RawJSON() string { - return r.raw -} - -// If the site is not configured in high availability mode, this configuration is -// optional (if omitted, use DHCP). However, if in high availability mode, -// static_address is required along with secondary and virtual address. -type SiteLANDeleteResponseDeletedLANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - DhcpRelay SiteLANDeleteResponseDeletedLANStaticAddressingDhcpRelay `json:"dhcp_relay"` - DhcpServer SiteLANDeleteResponseDeletedLANStaticAddressingDhcpServer `json:"dhcp_server"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - // A valid CIDR notation representing an IP range. - VirtualAddress string `json:"virtual_address"` - JSON siteLANDeleteResponseDeletedLANStaticAddressingJSON `json:"-"` -} - -// siteLANDeleteResponseDeletedLANStaticAddressingJSON contains the JSON metadata -// for the struct [SiteLANDeleteResponseDeletedLANStaticAddressing] -type siteLANDeleteResponseDeletedLANStaticAddressingJSON struct { - Address apijson.Field - DhcpRelay apijson.Field - DhcpServer apijson.Field - SecondaryAddress apijson.Field - VirtualAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseDeletedLANStaticAddressing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseDeletedLANStaticAddressingJSON) RawJSON() string { - return r.raw -} - -type SiteLANDeleteResponseDeletedLANStaticAddressingDhcpRelay struct { - // List of DHCP server IPs. - ServerAddresses []string `json:"server_addresses"` - JSON siteLANDeleteResponseDeletedLANStaticAddressingDhcpRelayJSON `json:"-"` -} - -// siteLANDeleteResponseDeletedLANStaticAddressingDhcpRelayJSON contains the JSON -// metadata for the struct -// [SiteLANDeleteResponseDeletedLANStaticAddressingDhcpRelay] -type siteLANDeleteResponseDeletedLANStaticAddressingDhcpRelayJSON struct { - ServerAddresses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseDeletedLANStaticAddressingDhcpRelay) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseDeletedLANStaticAddressingDhcpRelayJSON) RawJSON() string { - return r.raw -} - -type SiteLANDeleteResponseDeletedLANStaticAddressingDhcpServer struct { - // A valid IPv4 address. - DhcpPoolEnd string `json:"dhcp_pool_end"` - // A valid IPv4 address. - DhcpPoolStart string `json:"dhcp_pool_start"` - // A valid IPv4 address. - DNSServer string `json:"dns_server"` - // Mapping of MAC addresses to IP addresses - Reservations map[string]string `json:"reservations"` - JSON siteLANDeleteResponseDeletedLANStaticAddressingDhcpServerJSON `json:"-"` -} - -// siteLANDeleteResponseDeletedLANStaticAddressingDhcpServerJSON contains the JSON -// metadata for the struct -// [SiteLANDeleteResponseDeletedLANStaticAddressingDhcpServer] -type siteLANDeleteResponseDeletedLANStaticAddressingDhcpServerJSON struct { - DhcpPoolEnd apijson.Field - DhcpPoolStart apijson.Field - DNSServer apijson.Field - Reservations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseDeletedLANStaticAddressingDhcpServer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseDeletedLANStaticAddressingDhcpServerJSON) RawJSON() string { - return r.raw -} - -type SiteLANGetResponse struct { - LAN SiteLANGetResponseLAN `json:"lan"` - JSON siteLANGetResponseJSON `json:"-"` -} - -// siteLANGetResponseJSON contains the JSON metadata for the struct -// [SiteLANGetResponse] -type siteLANGetResponseJSON struct { - LAN apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseJSON) RawJSON() string { - return r.raw -} - -type SiteLANGetResponseLAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - // mark true to use this LAN for HA probing. only works for site with HA turned on. - // only one LAN can be set as the ha_link. - HaLink bool `json:"ha_link"` - Nat SiteLANGetResponseLANNat `json:"nat"` - Physport int64 `json:"physport"` - RoutedSubnets []SiteLANGetResponseLANRoutedSubnet `json:"routed_subnets"` - // Identifier - SiteID string `json:"site_id"` - // If the site is not configured in high availability mode, this configuration is - // optional (if omitted, use DHCP). However, if in high availability mode, - // static_address is required along with secondary and virtual address. - StaticAddressing SiteLANGetResponseLANStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteLANGetResponseLANJSON `json:"-"` -} - -// siteLANGetResponseLANJSON contains the JSON metadata for the struct -// [SiteLANGetResponseLAN] -type siteLANGetResponseLANJSON struct { - ID apijson.Field - Description apijson.Field - HaLink apijson.Field - Nat apijson.Field - Physport apijson.Field - RoutedSubnets apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponseLAN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseLANJSON) RawJSON() string { - return r.raw -} - -type SiteLANGetResponseLANNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANGetResponseLANNatJSON `json:"-"` -} - -// siteLANGetResponseLANNatJSON contains the JSON metadata for the struct -// [SiteLANGetResponseLANNat] -type siteLANGetResponseLANNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponseLANNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseLANNatJSON) RawJSON() string { - return r.raw -} - -type SiteLANGetResponseLANRoutedSubnet struct { - // A valid IPv4 address. - NextHop string `json:"next_hop,required"` - // A valid CIDR notation representing an IP range. - Prefix string `json:"prefix,required"` - Nat SiteLANGetResponseLANRoutedSubnetsNat `json:"nat"` - JSON siteLANGetResponseLANRoutedSubnetJSON `json:"-"` -} - -// siteLANGetResponseLANRoutedSubnetJSON contains the JSON metadata for the struct -// [SiteLANGetResponseLANRoutedSubnet] -type siteLANGetResponseLANRoutedSubnetJSON struct { - NextHop apijson.Field - Prefix apijson.Field - Nat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponseLANRoutedSubnet) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseLANRoutedSubnetJSON) RawJSON() string { - return r.raw -} - -type SiteLANGetResponseLANRoutedSubnetsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix string `json:"static_prefix"` - JSON siteLANGetResponseLANRoutedSubnetsNatJSON `json:"-"` -} - -// siteLANGetResponseLANRoutedSubnetsNatJSON contains the JSON metadata for the -// struct [SiteLANGetResponseLANRoutedSubnetsNat] -type siteLANGetResponseLANRoutedSubnetsNatJSON struct { - StaticPrefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponseLANRoutedSubnetsNat) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseLANRoutedSubnetsNatJSON) RawJSON() string { - return r.raw -} - -// If the site is not configured in high availability mode, this configuration is -// optional (if omitted, use DHCP). However, if in high availability mode, -// static_address is required along with secondary and virtual address. -type SiteLANGetResponseLANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - DhcpRelay SiteLANGetResponseLANStaticAddressingDhcpRelay `json:"dhcp_relay"` - DhcpServer SiteLANGetResponseLANStaticAddressingDhcpServer `json:"dhcp_server"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - // A valid CIDR notation representing an IP range. - VirtualAddress string `json:"virtual_address"` - JSON siteLANGetResponseLANStaticAddressingJSON `json:"-"` -} - -// siteLANGetResponseLANStaticAddressingJSON contains the JSON metadata for the -// struct [SiteLANGetResponseLANStaticAddressing] -type siteLANGetResponseLANStaticAddressingJSON struct { - Address apijson.Field - DhcpRelay apijson.Field - DhcpServer apijson.Field - SecondaryAddress apijson.Field - VirtualAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponseLANStaticAddressing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseLANStaticAddressingJSON) RawJSON() string { - return r.raw -} - -type SiteLANGetResponseLANStaticAddressingDhcpRelay struct { - // List of DHCP server IPs. - ServerAddresses []string `json:"server_addresses"` - JSON siteLANGetResponseLANStaticAddressingDhcpRelayJSON `json:"-"` -} - -// siteLANGetResponseLANStaticAddressingDhcpRelayJSON contains the JSON metadata -// for the struct [SiteLANGetResponseLANStaticAddressingDhcpRelay] -type siteLANGetResponseLANStaticAddressingDhcpRelayJSON struct { - ServerAddresses apijson.Field - raw string - ExtraFields map[string]apijson.Field +// siteLANDeleteResponseJSON contains the JSON metadata for the struct +// [SiteLANDeleteResponse] +type siteLANDeleteResponseJSON struct { + Deleted apijson.Field + DeletedLAN apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteLANGetResponseLANStaticAddressingDhcpRelay) UnmarshalJSON(data []byte) (err error) { +func (r *SiteLANDeleteResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANGetResponseLANStaticAddressingDhcpRelayJSON) RawJSON() string { +func (r siteLANDeleteResponseJSON) RawJSON() string { return r.raw } -type SiteLANGetResponseLANStaticAddressingDhcpServer struct { - // A valid IPv4 address. - DhcpPoolEnd string `json:"dhcp_pool_end"` - // A valid IPv4 address. - DhcpPoolStart string `json:"dhcp_pool_start"` - // A valid IPv4 address. - DNSServer string `json:"dns_server"` - // Mapping of MAC addresses to IP addresses - Reservations map[string]string `json:"reservations"` - JSON siteLANGetResponseLANStaticAddressingDhcpServerJSON `json:"-"` +type SiteLANGetResponse struct { + LAN LAN `json:"lan"` + JSON siteLANGetResponseJSON `json:"-"` } -// siteLANGetResponseLANStaticAddressingDhcpServerJSON contains the JSON metadata -// for the struct [SiteLANGetResponseLANStaticAddressingDhcpServer] -type siteLANGetResponseLANStaticAddressingDhcpServerJSON struct { - DhcpPoolEnd apijson.Field - DhcpPoolStart apijson.Field - DNSServer apijson.Field - Reservations apijson.Field - raw string - ExtraFields map[string]apijson.Field +// siteLANGetResponseJSON contains the JSON metadata for the struct +// [SiteLANGetResponse] +type siteLANGetResponseJSON struct { + LAN apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteLANGetResponseLANStaticAddressingDhcpServer) UnmarshalJSON(data []byte) (err error) { +func (r *SiteLANGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteLANGetResponseLANStaticAddressingDhcpServerJSON) RawJSON() string { +func (r siteLANGetResponseJSON) RawJSON() string { return r.raw } @@ -1242,95 +461,23 @@ type SiteLANNewParamsLAN struct { Description param.Field[string] `json:"description"` // mark true to use this LAN for HA probing. only works for site with HA turned on. // only one LAN can be set as the ha_link. - HaLink param.Field[bool] `json:"ha_link"` - Nat param.Field[SiteLANNewParamsLANNat] `json:"nat"` - RoutedSubnets param.Field[[]SiteLANNewParamsLANRoutedSubnet] `json:"routed_subnets"` + HaLink param.Field[bool] `json:"ha_link"` + Nat param.Field[NatParam] `json:"nat"` + RoutedSubnets param.Field[[]RoutedSubnetParam] `json:"routed_subnets"` // If the site is not configured in high availability mode, this configuration is // optional (if omitted, use DHCP). However, if in high availability mode, // static_address is required along with secondary and virtual address. - StaticAddressing param.Field[SiteLANNewParamsLANStaticAddressing] `json:"static_addressing"` + StaticAddressing param.Field[LANStaticAddressingParam] `json:"static_addressing"` } func (r SiteLANNewParamsLAN) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SiteLANNewParamsLANNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix param.Field[string] `json:"static_prefix"` -} - -func (r SiteLANNewParamsLANNat) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANNewParamsLANRoutedSubnet struct { - // A valid IPv4 address. - NextHop param.Field[string] `json:"next_hop,required"` - // A valid CIDR notation representing an IP range. - Prefix param.Field[string] `json:"prefix,required"` - Nat param.Field[SiteLANNewParamsLANRoutedSubnetsNat] `json:"nat"` -} - -func (r SiteLANNewParamsLANRoutedSubnet) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANNewParamsLANRoutedSubnetsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix param.Field[string] `json:"static_prefix"` -} - -func (r SiteLANNewParamsLANRoutedSubnetsNat) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// If the site is not configured in high availability mode, this configuration is -// optional (if omitted, use DHCP). However, if in high availability mode, -// static_address is required along with secondary and virtual address. -type SiteLANNewParamsLANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address param.Field[string] `json:"address,required"` - DhcpRelay param.Field[SiteLANNewParamsLANStaticAddressingDhcpRelay] `json:"dhcp_relay"` - DhcpServer param.Field[SiteLANNewParamsLANStaticAddressingDhcpServer] `json:"dhcp_server"` - // A valid CIDR notation representing an IP range. - SecondaryAddress param.Field[string] `json:"secondary_address"` - // A valid CIDR notation representing an IP range. - VirtualAddress param.Field[string] `json:"virtual_address"` -} - -func (r SiteLANNewParamsLANStaticAddressing) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANNewParamsLANStaticAddressingDhcpRelay struct { - // List of DHCP server IPs. - ServerAddresses param.Field[[]string] `json:"server_addresses"` -} - -func (r SiteLANNewParamsLANStaticAddressingDhcpRelay) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANNewParamsLANStaticAddressingDhcpServer struct { - // A valid IPv4 address. - DhcpPoolEnd param.Field[string] `json:"dhcp_pool_end"` - // A valid IPv4 address. - DhcpPoolStart param.Field[string] `json:"dhcp_pool_start"` - // A valid IPv4 address. - DNSServer param.Field[string] `json:"dns_server"` - // Mapping of MAC addresses to IP addresses - Reservations param.Field[map[string]string] `json:"reservations"` -} - -func (r SiteLANNewParamsLANStaticAddressingDhcpServer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SiteLANNewResponseEnvelope struct { - Errors []SiteLANNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteLANNewResponseEnvelopeMessages `json:"messages,required"` - Result SiteLANNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteLANNewResponse `json:"result,required"` // Whether the API call was successful Success SiteLANNewResponseEnvelopeSuccess `json:"success,required"` JSON siteLANNewResponseEnvelopeJSON `json:"-"` @@ -1355,52 +502,6 @@ func (r siteLANNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteLANNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteLANNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteLANNewResponseEnvelopeErrors] -type siteLANNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteLANNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteLANNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteLANNewResponseEnvelopeMessages] -type siteLANNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteLANNewResponseEnvelopeSuccess bool @@ -1427,14 +528,14 @@ func (r SiteLANUpdateParams) MarshalJSON() (data []byte, err error) { } type SiteLANUpdateParamsLAN struct { - Description param.Field[string] `json:"description"` - Nat param.Field[SiteLANUpdateParamsLANNat] `json:"nat"` - Physport param.Field[int64] `json:"physport"` - RoutedSubnets param.Field[[]SiteLANUpdateParamsLANRoutedSubnet] `json:"routed_subnets"` + Description param.Field[string] `json:"description"` + Nat param.Field[NatParam] `json:"nat"` + Physport param.Field[int64] `json:"physport"` + RoutedSubnets param.Field[[]RoutedSubnetParam] `json:"routed_subnets"` // If the site is not configured in high availability mode, this configuration is // optional (if omitted, use DHCP). However, if in high availability mode, // static_address is required along with secondary and virtual address. - StaticAddressing param.Field[SiteLANUpdateParamsLANStaticAddressing] `json:"static_addressing"` + StaticAddressing param.Field[LANStaticAddressingParam] `json:"static_addressing"` // VLAN port number. VlanTag param.Field[int64] `json:"vlan_tag"` } @@ -1443,82 +544,10 @@ func (r SiteLANUpdateParamsLAN) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SiteLANUpdateParamsLANNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix param.Field[string] `json:"static_prefix"` -} - -func (r SiteLANUpdateParamsLANNat) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANUpdateParamsLANRoutedSubnet struct { - // A valid IPv4 address. - NextHop param.Field[string] `json:"next_hop,required"` - // A valid CIDR notation representing an IP range. - Prefix param.Field[string] `json:"prefix,required"` - Nat param.Field[SiteLANUpdateParamsLANRoutedSubnetsNat] `json:"nat"` -} - -func (r SiteLANUpdateParamsLANRoutedSubnet) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANUpdateParamsLANRoutedSubnetsNat struct { - // A valid CIDR notation representing an IP range. - StaticPrefix param.Field[string] `json:"static_prefix"` -} - -func (r SiteLANUpdateParamsLANRoutedSubnetsNat) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// If the site is not configured in high availability mode, this configuration is -// optional (if omitted, use DHCP). However, if in high availability mode, -// static_address is required along with secondary and virtual address. -type SiteLANUpdateParamsLANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address param.Field[string] `json:"address,required"` - DhcpRelay param.Field[SiteLANUpdateParamsLANStaticAddressingDhcpRelay] `json:"dhcp_relay"` - DhcpServer param.Field[SiteLANUpdateParamsLANStaticAddressingDhcpServer] `json:"dhcp_server"` - // A valid CIDR notation representing an IP range. - SecondaryAddress param.Field[string] `json:"secondary_address"` - // A valid CIDR notation representing an IP range. - VirtualAddress param.Field[string] `json:"virtual_address"` -} - -func (r SiteLANUpdateParamsLANStaticAddressing) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANUpdateParamsLANStaticAddressingDhcpRelay struct { - // List of DHCP server IPs. - ServerAddresses param.Field[[]string] `json:"server_addresses"` -} - -func (r SiteLANUpdateParamsLANStaticAddressingDhcpRelay) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SiteLANUpdateParamsLANStaticAddressingDhcpServer struct { - // A valid IPv4 address. - DhcpPoolEnd param.Field[string] `json:"dhcp_pool_end"` - // A valid IPv4 address. - DhcpPoolStart param.Field[string] `json:"dhcp_pool_start"` - // A valid IPv4 address. - DNSServer param.Field[string] `json:"dns_server"` - // Mapping of MAC addresses to IP addresses - Reservations param.Field[map[string]string] `json:"reservations"` -} - -func (r SiteLANUpdateParamsLANStaticAddressingDhcpServer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SiteLANUpdateResponseEnvelope struct { - Errors []SiteLANUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteLANUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SiteLANUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteLANUpdateResponse `json:"result,required"` // Whether the API call was successful Success SiteLANUpdateResponseEnvelopeSuccess `json:"success,required"` JSON siteLANUpdateResponseEnvelopeJSON `json:"-"` @@ -1543,52 +572,6 @@ func (r siteLANUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteLANUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteLANUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SiteLANUpdateResponseEnvelopeErrors] -type siteLANUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteLANUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteLANUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteLANUpdateResponseEnvelopeMessages] -type siteLANUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteLANUpdateResponseEnvelopeSuccess bool @@ -1610,9 +593,9 @@ type SiteLANListParams struct { } type SiteLANListResponseEnvelope struct { - Errors []SiteLANListResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteLANListResponseEnvelopeMessages `json:"messages,required"` - Result SiteLANListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteLANListResponse `json:"result,required"` // Whether the API call was successful Success SiteLANListResponseEnvelopeSuccess `json:"success,required"` JSON siteLANListResponseEnvelopeJSON `json:"-"` @@ -1637,52 +620,6 @@ func (r siteLANListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteLANListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANListResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteLANListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteLANListResponseEnvelopeErrors] -type siteLANListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteLANListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANListResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteLANListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteLANListResponseEnvelopeMessages] -type siteLANListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteLANListResponseEnvelopeSuccess bool @@ -1701,12 +638,17 @@ func (r SiteLANListResponseEnvelopeSuccess) IsKnown() bool { type SiteLANDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r SiteLANDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type SiteLANDeleteResponseEnvelope struct { - Errors []SiteLANDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteLANDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SiteLANDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteLANDeleteResponse `json:"result,required"` // Whether the API call was successful Success SiteLANDeleteResponseEnvelopeSuccess `json:"success,required"` JSON siteLANDeleteResponseEnvelopeJSON `json:"-"` @@ -1731,52 +673,6 @@ func (r siteLANDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteLANDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteLANDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SiteLANDeleteResponseEnvelopeErrors] -type siteLANDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteLANDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteLANDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteLANDeleteResponseEnvelopeMessages] -type siteLANDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteLANDeleteResponseEnvelopeSuccess bool @@ -1798,9 +694,9 @@ type SiteLANGetParams struct { } type SiteLANGetResponseEnvelope struct { - Errors []SiteLANGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteLANGetResponseEnvelopeMessages `json:"messages,required"` - Result SiteLANGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteLANGetResponse `json:"result,required"` // Whether the API call was successful Success SiteLANGetResponseEnvelopeSuccess `json:"success,required"` JSON siteLANGetResponseEnvelopeJSON `json:"-"` @@ -1825,52 +721,6 @@ func (r siteLANGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteLANGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteLANGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteLANGetResponseEnvelopeErrors] -type siteLANGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteLANGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteLANGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteLANGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteLANGetResponseEnvelopeMessages] -type siteLANGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteLANGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteLANGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteLANGetResponseEnvelopeSuccess bool diff --git a/magic_transit/sitelan_test.go b/magic_transit/sitelan_test.go index 4b6fa0afcee..da69bd311e6 100644 --- a/magic_transit/sitelan_test.go +++ b/magic_transit/sitelan_test.go @@ -36,37 +36,37 @@ func TestSiteLANNewWithOptionalParams(t *testing.T) { LAN: cloudflare.F(magic_transit.SiteLANNewParamsLAN{ Description: cloudflare.F("string"), HaLink: cloudflare.F(true), - Nat: cloudflare.F(magic_transit.SiteLANNewParamsLANNat{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), Physport: cloudflare.F(int64(1)), - RoutedSubnets: cloudflare.F([]magic_transit.SiteLANNewParamsLANRoutedSubnet{{ - Nat: cloudflare.F(magic_transit.SiteLANNewParamsLANRoutedSubnetsNat{ + RoutedSubnets: cloudflare.F([]magic_transit.RoutedSubnetParam{{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), NextHop: cloudflare.F("192.0.2.1"), Prefix: cloudflare.F("192.0.2.0/24"), }, { - Nat: cloudflare.F(magic_transit.SiteLANNewParamsLANRoutedSubnetsNat{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), NextHop: cloudflare.F("192.0.2.1"), Prefix: cloudflare.F("192.0.2.0/24"), }, { - Nat: cloudflare.F(magic_transit.SiteLANNewParamsLANRoutedSubnetsNat{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), NextHop: cloudflare.F("192.0.2.1"), Prefix: cloudflare.F("192.0.2.0/24"), }}), - StaticAddressing: cloudflare.F(magic_transit.SiteLANNewParamsLANStaticAddressing{ + StaticAddressing: cloudflare.F(magic_transit.LANStaticAddressingParam{ Address: cloudflare.F("192.0.2.0/24"), - DhcpRelay: cloudflare.F(magic_transit.SiteLANNewParamsLANStaticAddressingDhcpRelay{ + DHCPRelay: cloudflare.F(magic_transit.DHCPRelayParam{ ServerAddresses: cloudflare.F([]string{"192.0.2.1", "192.0.2.1", "192.0.2.1"}), }), - DhcpServer: cloudflare.F(magic_transit.SiteLANNewParamsLANStaticAddressingDhcpServer{ - DhcpPoolEnd: cloudflare.F("192.0.2.1"), - DhcpPoolStart: cloudflare.F("192.0.2.1"), + DHCPServer: cloudflare.F(magic_transit.DHCPServerParam{ + DHCPPoolEnd: cloudflare.F("192.0.2.1"), + DHCPPoolStart: cloudflare.F("192.0.2.1"), DNSServer: cloudflare.F("192.0.2.1"), Reservations: cloudflare.F(map[string]string{ "00:11:22:33:44:55": "192.0.2.100", @@ -111,37 +111,37 @@ func TestSiteLANUpdateWithOptionalParams(t *testing.T) { AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), LAN: cloudflare.F(magic_transit.SiteLANUpdateParamsLAN{ Description: cloudflare.F("string"), - Nat: cloudflare.F(magic_transit.SiteLANUpdateParamsLANNat{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), Physport: cloudflare.F(int64(1)), - RoutedSubnets: cloudflare.F([]magic_transit.SiteLANUpdateParamsLANRoutedSubnet{{ - Nat: cloudflare.F(magic_transit.SiteLANUpdateParamsLANRoutedSubnetsNat{ + RoutedSubnets: cloudflare.F([]magic_transit.RoutedSubnetParam{{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), NextHop: cloudflare.F("192.0.2.1"), Prefix: cloudflare.F("192.0.2.0/24"), }, { - Nat: cloudflare.F(magic_transit.SiteLANUpdateParamsLANRoutedSubnetsNat{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), NextHop: cloudflare.F("192.0.2.1"), Prefix: cloudflare.F("192.0.2.0/24"), }, { - Nat: cloudflare.F(magic_transit.SiteLANUpdateParamsLANRoutedSubnetsNat{ + Nat: cloudflare.F(magic_transit.NatParam{ StaticPrefix: cloudflare.F("192.0.2.0/24"), }), NextHop: cloudflare.F("192.0.2.1"), Prefix: cloudflare.F("192.0.2.0/24"), }}), - StaticAddressing: cloudflare.F(magic_transit.SiteLANUpdateParamsLANStaticAddressing{ + StaticAddressing: cloudflare.F(magic_transit.LANStaticAddressingParam{ Address: cloudflare.F("192.0.2.0/24"), - DhcpRelay: cloudflare.F(magic_transit.SiteLANUpdateParamsLANStaticAddressingDhcpRelay{ + DHCPRelay: cloudflare.F(magic_transit.DHCPRelayParam{ ServerAddresses: cloudflare.F([]string{"192.0.2.1", "192.0.2.1", "192.0.2.1"}), }), - DhcpServer: cloudflare.F(magic_transit.SiteLANUpdateParamsLANStaticAddressingDhcpServer{ - DhcpPoolEnd: cloudflare.F("192.0.2.1"), - DhcpPoolStart: cloudflare.F("192.0.2.1"), + DHCPServer: cloudflare.F(magic_transit.DHCPServerParam{ + DHCPPoolEnd: cloudflare.F("192.0.2.1"), + DHCPPoolStart: cloudflare.F("192.0.2.1"), DNSServer: cloudflare.F("192.0.2.1"), Reservations: cloudflare.F(map[string]string{ "00:11:22:33:44:55": "192.0.2.100", @@ -214,6 +214,7 @@ func TestSiteLANDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteLANDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/magic_transit/sitewan.go b/magic_transit/sitewan.go index a79ac37f3ee..7960714ecb0 100644 --- a/magic_transit/sitewan.go +++ b/magic_transit/sitewan.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -70,10 +71,10 @@ func (r *SiteWANService) List(ctx context.Context, siteID string, query SiteWANL } // Remove a specific WAN. -func (r *SiteWANService) Delete(ctx context.Context, siteID string, wanID string, body SiteWANDeleteParams, opts ...option.RequestOption) (res *SiteWANDeleteResponse, err error) { +func (r *SiteWANService) Delete(ctx context.Context, siteID string, wanID string, params SiteWANDeleteParams, opts ...option.RequestOption) (res *SiteWANDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env SiteWANDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/sites/%s/wans/%s", body.AccountID, siteID, wanID) + path := fmt.Sprintf("accounts/%s/magic/sites/%s/wans/%s", params.AccountID, siteID, wanID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -95,28 +96,7 @@ func (r *SiteWANService) Get(ctx context.Context, siteID string, wanID string, q return } -type SiteWANNewResponse struct { - WANs []SiteWANNewResponseWAN `json:"wans"` - JSON siteWANNewResponseJSON `json:"-"` -} - -// siteWANNewResponseJSON contains the JSON metadata for the struct -// [SiteWANNewResponse] -type siteWANNewResponseJSON struct { - WANs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANNewResponseJSON) RawJSON() string { - return r.raw -} - -type SiteWANNewResponseWAN struct { +type WAN struct { // Identifier ID string `json:"id"` Description string `json:"description"` @@ -127,15 +107,14 @@ type SiteWANNewResponseWAN struct { SiteID string `json:"site_id"` // (optional) if omitted, use DHCP. Submit secondary_address when site is in high // availability mode. - StaticAddressing SiteWANNewResponseWANsStaticAddressing `json:"static_addressing"` + StaticAddressing WANStaticAddressing `json:"static_addressing"` // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteWANNewResponseWANJSON `json:"-"` + VlanTag int64 `json:"vlan_tag"` + JSON wanJSON `json:"-"` } -// siteWANNewResponseWANJSON contains the JSON metadata for the struct -// [SiteWANNewResponseWAN] -type siteWANNewResponseWANJSON struct { +// wanJSON contains the JSON metadata for the struct [WAN] +type wanJSON struct { ID apijson.Field Description apijson.Field Physport apijson.Field @@ -147,29 +126,29 @@ type siteWANNewResponseWANJSON struct { ExtraFields map[string]apijson.Field } -func (r *SiteWANNewResponseWAN) UnmarshalJSON(data []byte) (err error) { +func (r *WAN) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteWANNewResponseWANJSON) RawJSON() string { +func (r wanJSON) RawJSON() string { return r.raw } // (optional) if omitted, use DHCP. Submit secondary_address when site is in high // availability mode. -type SiteWANNewResponseWANsStaticAddressing struct { +type WANStaticAddressing struct { // A valid CIDR notation representing an IP range. Address string `json:"address,required"` // A valid IPv4 address. GatewayAddress string `json:"gateway_address,required"` // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - JSON siteWANNewResponseWANsStaticAddressingJSON `json:"-"` + SecondaryAddress string `json:"secondary_address"` + JSON wanStaticAddressingJSON `json:"-"` } -// siteWANNewResponseWANsStaticAddressingJSON contains the JSON metadata for the -// struct [SiteWANNewResponseWANsStaticAddressing] -type siteWANNewResponseWANsStaticAddressingJSON struct { +// wanStaticAddressingJSON contains the JSON metadata for the struct +// [WANStaticAddressing] +type wanStaticAddressingJSON struct { Address apijson.Field GatewayAddress apijson.Field SecondaryAddress apijson.Field @@ -177,107 +156,74 @@ type siteWANNewResponseWANsStaticAddressingJSON struct { ExtraFields map[string]apijson.Field } -func (r *SiteWANNewResponseWANsStaticAddressing) UnmarshalJSON(data []byte) (err error) { +func (r *WANStaticAddressing) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteWANNewResponseWANsStaticAddressingJSON) RawJSON() string { +func (r wanStaticAddressingJSON) RawJSON() string { return r.raw } -type SiteWANUpdateResponse struct { - WAN SiteWANUpdateResponseWAN `json:"wan"` - JSON siteWANUpdateResponseJSON `json:"-"` -} - -// siteWANUpdateResponseJSON contains the JSON metadata for the struct -// [SiteWANUpdateResponse] -type siteWANUpdateResponseJSON struct { - WAN apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// (optional) if omitted, use DHCP. Submit secondary_address when site is in high +// availability mode. +type WANStaticAddressingParam struct { + // A valid CIDR notation representing an IP range. + Address param.Field[string] `json:"address,required"` + // A valid IPv4 address. + GatewayAddress param.Field[string] `json:"gateway_address,required"` + // A valid CIDR notation representing an IP range. + SecondaryAddress param.Field[string] `json:"secondary_address"` } -func (r siteWANUpdateResponseJSON) RawJSON() string { - return r.raw +func (r WANStaticAddressingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type SiteWANUpdateResponseWAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - Physport int64 `json:"physport"` - // Priority of WAN for traffic loadbalancing. - Priority int64 `json:"priority"` - // Identifier - SiteID string `json:"site_id"` - // (optional) if omitted, use DHCP. Submit secondary_address when site is in high - // availability mode. - StaticAddressing SiteWANUpdateResponseWANStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteWANUpdateResponseWANJSON `json:"-"` +type SiteWANNewResponse struct { + WANs []WAN `json:"wans"` + JSON siteWANNewResponseJSON `json:"-"` } -// siteWANUpdateResponseWANJSON contains the JSON metadata for the struct -// [SiteWANUpdateResponseWAN] -type siteWANUpdateResponseWANJSON struct { - ID apijson.Field - Description apijson.Field - Physport apijson.Field - Priority apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field +// siteWANNewResponseJSON contains the JSON metadata for the struct +// [SiteWANNewResponse] +type siteWANNewResponseJSON struct { + WANs apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteWANUpdateResponseWAN) UnmarshalJSON(data []byte) (err error) { +func (r *SiteWANNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteWANUpdateResponseWANJSON) RawJSON() string { +func (r siteWANNewResponseJSON) RawJSON() string { return r.raw } -// (optional) if omitted, use DHCP. Submit secondary_address when site is in high -// availability mode. -type SiteWANUpdateResponseWANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - // A valid IPv4 address. - GatewayAddress string `json:"gateway_address,required"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - JSON siteWANUpdateResponseWANStaticAddressingJSON `json:"-"` +type SiteWANUpdateResponse struct { + WAN WAN `json:"wan"` + JSON siteWANUpdateResponseJSON `json:"-"` } -// siteWANUpdateResponseWANStaticAddressingJSON contains the JSON metadata for the -// struct [SiteWANUpdateResponseWANStaticAddressing] -type siteWANUpdateResponseWANStaticAddressingJSON struct { - Address apijson.Field - GatewayAddress apijson.Field - SecondaryAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field +// siteWANUpdateResponseJSON contains the JSON metadata for the struct +// [SiteWANUpdateResponse] +type siteWANUpdateResponseJSON struct { + WAN apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SiteWANUpdateResponseWANStaticAddressing) UnmarshalJSON(data []byte) (err error) { +func (r *SiteWANUpdateResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r siteWANUpdateResponseWANStaticAddressingJSON) RawJSON() string { +func (r siteWANUpdateResponseJSON) RawJSON() string { return r.raw } type SiteWANListResponse struct { - WANs []SiteWANListResponseWAN `json:"wans"` - JSON siteWANListResponseJSON `json:"-"` + WANs []WAN `json:"wans"` + JSON siteWANListResponseJSON `json:"-"` } // siteWANListResponseJSON contains the JSON metadata for the struct @@ -296,79 +242,10 @@ func (r siteWANListResponseJSON) RawJSON() string { return r.raw } -type SiteWANListResponseWAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - Physport int64 `json:"physport"` - // Priority of WAN for traffic loadbalancing. - Priority int64 `json:"priority"` - // Identifier - SiteID string `json:"site_id"` - // (optional) if omitted, use DHCP. Submit secondary_address when site is in high - // availability mode. - StaticAddressing SiteWANListResponseWANsStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteWANListResponseWANJSON `json:"-"` -} - -// siteWANListResponseWANJSON contains the JSON metadata for the struct -// [SiteWANListResponseWAN] -type siteWANListResponseWANJSON struct { - ID apijson.Field - Description apijson.Field - Physport apijson.Field - Priority apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANListResponseWAN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANListResponseWANJSON) RawJSON() string { - return r.raw -} - -// (optional) if omitted, use DHCP. Submit secondary_address when site is in high -// availability mode. -type SiteWANListResponseWANsStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - // A valid IPv4 address. - GatewayAddress string `json:"gateway_address,required"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - JSON siteWANListResponseWANsStaticAddressingJSON `json:"-"` -} - -// siteWANListResponseWANsStaticAddressingJSON contains the JSON metadata for the -// struct [SiteWANListResponseWANsStaticAddressing] -type siteWANListResponseWANsStaticAddressingJSON struct { - Address apijson.Field - GatewayAddress apijson.Field - SecondaryAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANListResponseWANsStaticAddressing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANListResponseWANsStaticAddressingJSON) RawJSON() string { - return r.raw -} - type SiteWANDeleteResponse struct { - Deleted bool `json:"deleted"` - DeletedWAN SiteWANDeleteResponseDeletedWAN `json:"deleted_wan"` - JSON siteWANDeleteResponseJSON `json:"-"` + Deleted bool `json:"deleted"` + DeletedWAN WAN `json:"deleted_wan"` + JSON siteWANDeleteResponseJSON `json:"-"` } // siteWANDeleteResponseJSON contains the JSON metadata for the struct @@ -388,77 +265,8 @@ func (r siteWANDeleteResponseJSON) RawJSON() string { return r.raw } -type SiteWANDeleteResponseDeletedWAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - Physport int64 `json:"physport"` - // Priority of WAN for traffic loadbalancing. - Priority int64 `json:"priority"` - // Identifier - SiteID string `json:"site_id"` - // (optional) if omitted, use DHCP. Submit secondary_address when site is in high - // availability mode. - StaticAddressing SiteWANDeleteResponseDeletedWANStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteWANDeleteResponseDeletedWANJSON `json:"-"` -} - -// siteWANDeleteResponseDeletedWANJSON contains the JSON metadata for the struct -// [SiteWANDeleteResponseDeletedWAN] -type siteWANDeleteResponseDeletedWANJSON struct { - ID apijson.Field - Description apijson.Field - Physport apijson.Field - Priority apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANDeleteResponseDeletedWAN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANDeleteResponseDeletedWANJSON) RawJSON() string { - return r.raw -} - -// (optional) if omitted, use DHCP. Submit secondary_address when site is in high -// availability mode. -type SiteWANDeleteResponseDeletedWANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - // A valid IPv4 address. - GatewayAddress string `json:"gateway_address,required"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - JSON siteWANDeleteResponseDeletedWANStaticAddressingJSON `json:"-"` -} - -// siteWANDeleteResponseDeletedWANStaticAddressingJSON contains the JSON metadata -// for the struct [SiteWANDeleteResponseDeletedWANStaticAddressing] -type siteWANDeleteResponseDeletedWANStaticAddressingJSON struct { - Address apijson.Field - GatewayAddress apijson.Field - SecondaryAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANDeleteResponseDeletedWANStaticAddressing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANDeleteResponseDeletedWANStaticAddressingJSON) RawJSON() string { - return r.raw -} - type SiteWANGetResponse struct { - WAN SiteWANGetResponseWAN `json:"wan"` + WAN WAN `json:"wan"` JSON siteWANGetResponseJSON `json:"-"` } @@ -478,75 +286,6 @@ func (r siteWANGetResponseJSON) RawJSON() string { return r.raw } -type SiteWANGetResponseWAN struct { - // Identifier - ID string `json:"id"` - Description string `json:"description"` - Physport int64 `json:"physport"` - // Priority of WAN for traffic loadbalancing. - Priority int64 `json:"priority"` - // Identifier - SiteID string `json:"site_id"` - // (optional) if omitted, use DHCP. Submit secondary_address when site is in high - // availability mode. - StaticAddressing SiteWANGetResponseWANStaticAddressing `json:"static_addressing"` - // VLAN port number. - VlanTag int64 `json:"vlan_tag"` - JSON siteWANGetResponseWANJSON `json:"-"` -} - -// siteWANGetResponseWANJSON contains the JSON metadata for the struct -// [SiteWANGetResponseWAN] -type siteWANGetResponseWANJSON struct { - ID apijson.Field - Description apijson.Field - Physport apijson.Field - Priority apijson.Field - SiteID apijson.Field - StaticAddressing apijson.Field - VlanTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANGetResponseWAN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANGetResponseWANJSON) RawJSON() string { - return r.raw -} - -// (optional) if omitted, use DHCP. Submit secondary_address when site is in high -// availability mode. -type SiteWANGetResponseWANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address string `json:"address,required"` - // A valid IPv4 address. - GatewayAddress string `json:"gateway_address,required"` - // A valid CIDR notation representing an IP range. - SecondaryAddress string `json:"secondary_address"` - JSON siteWANGetResponseWANStaticAddressingJSON `json:"-"` -} - -// siteWANGetResponseWANStaticAddressingJSON contains the JSON metadata for the -// struct [SiteWANGetResponseWANStaticAddressing] -type siteWANGetResponseWANStaticAddressingJSON struct { - Address apijson.Field - GatewayAddress apijson.Field - SecondaryAddress apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANGetResponseWANStaticAddressing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANGetResponseWANStaticAddressingJSON) RawJSON() string { - return r.raw -} - type SiteWANNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -565,32 +304,17 @@ type SiteWANNewParamsWAN struct { Priority param.Field[int64] `json:"priority"` // (optional) if omitted, use DHCP. Submit secondary_address when site is in high // availability mode. - StaticAddressing param.Field[SiteWANNewParamsWANStaticAddressing] `json:"static_addressing"` + StaticAddressing param.Field[WANStaticAddressingParam] `json:"static_addressing"` } func (r SiteWANNewParamsWAN) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// (optional) if omitted, use DHCP. Submit secondary_address when site is in high -// availability mode. -type SiteWANNewParamsWANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address param.Field[string] `json:"address,required"` - // A valid IPv4 address. - GatewayAddress param.Field[string] `json:"gateway_address,required"` - // A valid CIDR notation representing an IP range. - SecondaryAddress param.Field[string] `json:"secondary_address"` -} - -func (r SiteWANNewParamsWANStaticAddressing) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SiteWANNewResponseEnvelope struct { - Errors []SiteWANNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteWANNewResponseEnvelopeMessages `json:"messages,required"` - Result SiteWANNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteWANNewResponse `json:"result,required"` // Whether the API call was successful Success SiteWANNewResponseEnvelopeSuccess `json:"success,required"` JSON siteWANNewResponseEnvelopeJSON `json:"-"` @@ -615,52 +339,6 @@ func (r siteWANNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteWANNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteWANNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteWANNewResponseEnvelopeErrors] -type siteWANNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteWANNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteWANNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteWANNewResponseEnvelopeMessages] -type siteWANNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteWANNewResponseEnvelopeSuccess bool @@ -692,7 +370,7 @@ type SiteWANUpdateParamsWAN struct { Priority param.Field[int64] `json:"priority"` // (optional) if omitted, use DHCP. Submit secondary_address when site is in high // availability mode. - StaticAddressing param.Field[SiteWANUpdateParamsWANStaticAddressing] `json:"static_addressing"` + StaticAddressing param.Field[WANStaticAddressingParam] `json:"static_addressing"` // VLAN port number. VlanTag param.Field[int64] `json:"vlan_tag"` } @@ -701,25 +379,10 @@ func (r SiteWANUpdateParamsWAN) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// (optional) if omitted, use DHCP. Submit secondary_address when site is in high -// availability mode. -type SiteWANUpdateParamsWANStaticAddressing struct { - // A valid CIDR notation representing an IP range. - Address param.Field[string] `json:"address,required"` - // A valid IPv4 address. - GatewayAddress param.Field[string] `json:"gateway_address,required"` - // A valid CIDR notation representing an IP range. - SecondaryAddress param.Field[string] `json:"secondary_address"` -} - -func (r SiteWANUpdateParamsWANStaticAddressing) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SiteWANUpdateResponseEnvelope struct { - Errors []SiteWANUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteWANUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SiteWANUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteWANUpdateResponse `json:"result,required"` // Whether the API call was successful Success SiteWANUpdateResponseEnvelopeSuccess `json:"success,required"` JSON siteWANUpdateResponseEnvelopeJSON `json:"-"` @@ -744,52 +407,6 @@ func (r siteWANUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteWANUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteWANUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SiteWANUpdateResponseEnvelopeErrors] -type siteWANUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteWANUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteWANUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteWANUpdateResponseEnvelopeMessages] -type siteWANUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteWANUpdateResponseEnvelopeSuccess bool @@ -811,9 +428,9 @@ type SiteWANListParams struct { } type SiteWANListResponseEnvelope struct { - Errors []SiteWANListResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteWANListResponseEnvelopeMessages `json:"messages,required"` - Result SiteWANListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteWANListResponse `json:"result,required"` // Whether the API call was successful Success SiteWANListResponseEnvelopeSuccess `json:"success,required"` JSON siteWANListResponseEnvelopeJSON `json:"-"` @@ -838,52 +455,6 @@ func (r siteWANListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteWANListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANListResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteWANListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteWANListResponseEnvelopeErrors] -type siteWANListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteWANListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANListResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteWANListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteWANListResponseEnvelopeMessages] -type siteWANListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteWANListResponseEnvelopeSuccess bool @@ -902,12 +473,17 @@ func (r SiteWANListResponseEnvelopeSuccess) IsKnown() bool { type SiteWANDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r SiteWANDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type SiteWANDeleteResponseEnvelope struct { - Errors []SiteWANDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteWANDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SiteWANDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteWANDeleteResponse `json:"result,required"` // Whether the API call was successful Success SiteWANDeleteResponseEnvelopeSuccess `json:"success,required"` JSON siteWANDeleteResponseEnvelopeJSON `json:"-"` @@ -932,52 +508,6 @@ func (r siteWANDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteWANDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteWANDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SiteWANDeleteResponseEnvelopeErrors] -type siteWANDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteWANDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteWANDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SiteWANDeleteResponseEnvelopeMessages] -type siteWANDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteWANDeleteResponseEnvelopeSuccess bool @@ -999,9 +529,9 @@ type SiteWANGetParams struct { } type SiteWANGetResponseEnvelope struct { - Errors []SiteWANGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SiteWANGetResponseEnvelopeMessages `json:"messages,required"` - Result SiteWANGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SiteWANGetResponse `json:"result,required"` // Whether the API call was successful Success SiteWANGetResponseEnvelopeSuccess `json:"success,required"` JSON siteWANGetResponseEnvelopeJSON `json:"-"` @@ -1026,52 +556,6 @@ func (r siteWANGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SiteWANGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// siteWANGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SiteWANGetResponseEnvelopeErrors] -type siteWANGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SiteWANGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON siteWANGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// siteWANGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SiteWANGetResponseEnvelopeMessages] -type siteWANGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SiteWANGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r siteWANGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SiteWANGetResponseEnvelopeSuccess bool diff --git a/magic_transit/sitewan_test.go b/magic_transit/sitewan_test.go index 307784f8bdb..2f34eff3512 100644 --- a/magic_transit/sitewan_test.go +++ b/magic_transit/sitewan_test.go @@ -37,7 +37,7 @@ func TestSiteWANNewWithOptionalParams(t *testing.T) { Description: cloudflare.F("string"), Physport: cloudflare.F(int64(1)), Priority: cloudflare.F(int64(0)), - StaticAddressing: cloudflare.F(magic_transit.SiteWANNewParamsWANStaticAddressing{ + StaticAddressing: cloudflare.F(magic_transit.WANStaticAddressingParam{ Address: cloudflare.F("192.0.2.0/24"), GatewayAddress: cloudflare.F("192.0.2.1"), SecondaryAddress: cloudflare.F("192.0.2.0/24"), @@ -79,7 +79,7 @@ func TestSiteWANUpdateWithOptionalParams(t *testing.T) { Description: cloudflare.F("string"), Physport: cloudflare.F(int64(1)), Priority: cloudflare.F(int64(0)), - StaticAddressing: cloudflare.F(magic_transit.SiteWANUpdateParamsWANStaticAddressing{ + StaticAddressing: cloudflare.F(magic_transit.WANStaticAddressingParam{ Address: cloudflare.F("192.0.2.0/24"), GatewayAddress: cloudflare.F("192.0.2.1"), SecondaryAddress: cloudflare.F("192.0.2.0/24"), @@ -147,6 +147,7 @@ func TestSiteWANDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.SiteWANDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/managed_headers/aliases.go b/managed_headers/aliases.go index b509cb0d74d..95925ea12de 100644 --- a/managed_headers/aliases.go +++ b/managed_headers/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/managed_headers/managedheader.go b/managed_headers/managedheader.go index 836856ee084..f3c33ab7882 100644 --- a/managed_headers/managedheader.go +++ b/managed_headers/managedheader.go @@ -47,76 +47,61 @@ func (r *ManagedHeaderService) Edit(ctx context.Context, params ManagedHeaderEdi return } -type ManagedHeaderListResponse struct { - ManagedRequestHeaders []ManagedHeaderListResponseManagedRequestHeader `json:"managed_request_headers"` - ManagedResponseHeaders []ManagedHeaderListResponseManagedResponseHeader `json:"managed_response_headers"` - JSON managedHeaderListResponseJSON `json:"-"` -} - -// managedHeaderListResponseJSON contains the JSON metadata for the struct -// [ManagedHeaderListResponse] -type managedHeaderListResponseJSON struct { - ManagedRequestHeaders apijson.Field - ManagedResponseHeaders apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ManagedHeaderListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r managedHeaderListResponseJSON) RawJSON() string { - return r.raw -} - -type ManagedHeaderListResponseManagedRequestHeader struct { +type RequestModel struct { // Human-readable identifier of the Managed Transform. ID string `json:"id"` // When true, the Managed Transform is enabled. - Enabled bool `json:"enabled"` - JSON managedHeaderListResponseManagedRequestHeaderJSON `json:"-"` + Enabled bool `json:"enabled"` + JSON requestModelJSON `json:"-"` } -// managedHeaderListResponseManagedRequestHeaderJSON contains the JSON metadata for -// the struct [ManagedHeaderListResponseManagedRequestHeader] -type managedHeaderListResponseManagedRequestHeaderJSON struct { +// requestModelJSON contains the JSON metadata for the struct [RequestModel] +type requestModelJSON struct { ID apijson.Field Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ManagedHeaderListResponseManagedRequestHeader) UnmarshalJSON(data []byte) (err error) { +func (r *RequestModel) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r managedHeaderListResponseManagedRequestHeaderJSON) RawJSON() string { +func (r requestModelJSON) RawJSON() string { return r.raw } -type ManagedHeaderListResponseManagedResponseHeader struct { +type RequestModelParam struct { // Human-readable identifier of the Managed Transform. - ID string `json:"id"` + ID param.Field[string] `json:"id"` // When true, the Managed Transform is enabled. - Enabled bool `json:"enabled"` - JSON managedHeaderListResponseManagedResponseHeaderJSON `json:"-"` + Enabled param.Field[bool] `json:"enabled"` } -// managedHeaderListResponseManagedResponseHeaderJSON contains the JSON metadata -// for the struct [ManagedHeaderListResponseManagedResponseHeader] -type managedHeaderListResponseManagedResponseHeaderJSON struct { - ID apijson.Field - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r RequestModelParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ManagedHeaderListResponse struct { + ManagedRequestHeaders []RequestModel `json:"managed_request_headers"` + ManagedResponseHeaders []RequestModel `json:"managed_response_headers"` + JSON managedHeaderListResponseJSON `json:"-"` +} + +// managedHeaderListResponseJSON contains the JSON metadata for the struct +// [ManagedHeaderListResponse] +type managedHeaderListResponseJSON struct { + ManagedRequestHeaders apijson.Field + ManagedResponseHeaders apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ManagedHeaderListResponseManagedResponseHeader) UnmarshalJSON(data []byte) (err error) { +func (r *ManagedHeaderListResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r managedHeaderListResponseManagedResponseHeaderJSON) RawJSON() string { +func (r managedHeaderListResponseJSON) RawJSON() string { return r.raw } @@ -206,33 +191,11 @@ type ManagedHeaderListParams struct { type ManagedHeaderEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - ManagedRequestHeaders param.Field[[]ManagedHeaderEditParamsManagedRequestHeader] `json:"managed_request_headers,required"` - ManagedResponseHeaders param.Field[[]ManagedHeaderEditParamsManagedResponseHeader] `json:"managed_response_headers,required"` + ZoneID param.Field[string] `path:"zone_id,required"` + ManagedRequestHeaders param.Field[[]RequestModelParam] `json:"managed_request_headers,required"` + ManagedResponseHeaders param.Field[[]RequestModelParam] `json:"managed_response_headers,required"` } func (r ManagedHeaderEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } - -type ManagedHeaderEditParamsManagedRequestHeader struct { - // Human-readable identifier of the Managed Transform. - ID param.Field[string] `json:"id"` - // When true, the Managed Transform is enabled. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ManagedHeaderEditParamsManagedRequestHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ManagedHeaderEditParamsManagedResponseHeader struct { - // Human-readable identifier of the Managed Transform. - ID param.Field[string] `json:"id"` - // When true, the Managed Transform is enabled. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ManagedHeaderEditParamsManagedResponseHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} diff --git a/managed_headers/managedheader_test.go b/managed_headers/managedheader_test.go index 7aa5a37256d..e0c671db033 100644 --- a/managed_headers/managedheader_test.go +++ b/managed_headers/managedheader_test.go @@ -56,7 +56,7 @@ func TestManagedHeaderEdit(t *testing.T) { ) _, err := client.ManagedHeaders.Edit(context.TODO(), managed_headers.ManagedHeaderEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ManagedRequestHeaders: cloudflare.F([]managed_headers.ManagedHeaderEditParamsManagedRequestHeader{{ + ManagedRequestHeaders: cloudflare.F([]managed_headers.RequestModelParam{{ Enabled: cloudflare.F(true), ID: cloudflare.F("add_cf-bot-score_header"), }, { @@ -66,7 +66,7 @@ func TestManagedHeaderEdit(t *testing.T) { Enabled: cloudflare.F(true), ID: cloudflare.F("add_cf-bot-score_header"), }}), - ManagedResponseHeaders: cloudflare.F([]managed_headers.ManagedHeaderEditParamsManagedResponseHeader{{ + ManagedResponseHeaders: cloudflare.F([]managed_headers.RequestModelParam{{ Enabled: cloudflare.F(true), ID: cloudflare.F("add_cf-bot-score_header"), }, { diff --git a/memberships/aliases.go b/memberships/aliases.go index f5fd441f8ae..e43c70db24b 100644 --- a/memberships/aliases.go +++ b/memberships/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/memberships/membership.go b/memberships/membership.go index 2980bfae139..2d2c95a52aa 100644 --- a/memberships/membership.go +++ b/memberships/membership.go @@ -38,7 +38,7 @@ func NewMembershipService(opts ...option.RequestOption) (r *MembershipService) { } // Accept or reject this account invitation. -func (r *MembershipService) Update(ctx context.Context, membershipID string, body MembershipUpdateParams, opts ...option.RequestOption) (res *MembershipUpdateResponse, err error) { +func (r *MembershipService) Update(ctx context.Context, membershipID string, body MembershipUpdateParams, opts ...option.RequestOption) (res *MembershipUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env MembershipUpdateResponseEnvelope path := fmt.Sprintf("memberships/%s", membershipID) @@ -74,7 +74,7 @@ func (r *MembershipService) ListAutoPaging(ctx context.Context, query Membership } // Remove the associated member from an account. -func (r *MembershipService) Delete(ctx context.Context, membershipID string, opts ...option.RequestOption) (res *MembershipDeleteResponse, err error) { +func (r *MembershipService) Delete(ctx context.Context, membershipID string, body MembershipDeleteParams, opts ...option.RequestOption) (res *MembershipDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env MembershipDeleteResponseEnvelope path := fmt.Sprintf("memberships/%s", membershipID) @@ -87,7 +87,7 @@ func (r *MembershipService) Delete(ctx context.Context, membershipID string, opt } // Get a specific membership. -func (r *MembershipService) Get(ctx context.Context, membershipID string, opts ...option.RequestOption) (res *MembershipGetResponse, err error) { +func (r *MembershipService) Get(ctx context.Context, membershipID string, opts ...option.RequestOption) (res *MembershipGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env MembershipGetResponseEnvelope path := fmt.Sprintf("memberships/%s", membershipID) @@ -140,19 +140,19 @@ func (r membershipJSON) RawJSON() string { // All access permissions for the user at the account. type MembershipPermissions struct { - Analytics MembershipPermissionsAnalytics `json:"analytics"` - Billing MembershipPermissionsBilling `json:"billing"` - CachePurge MembershipPermissionsCachePurge `json:"cache_purge"` - DNS MembershipPermissionsDNS `json:"dns"` - DNSRecords MembershipPermissionsDNSRecords `json:"dns_records"` - Lb MembershipPermissionsLb `json:"lb"` - Logs MembershipPermissionsLogs `json:"logs"` - Organization MembershipPermissionsOrganization `json:"organization"` - SSL MembershipPermissionsSSL `json:"ssl"` - WAF MembershipPermissionsWAF `json:"waf"` - ZoneSettings MembershipPermissionsZoneSettings `json:"zone_settings"` - Zones MembershipPermissionsZones `json:"zones"` - JSON membershipPermissionsJSON `json:"-"` + Analytics shared.PermissionGrant `json:"analytics"` + Billing shared.PermissionGrant `json:"billing"` + CachePurge shared.PermissionGrant `json:"cache_purge"` + DNS shared.PermissionGrant `json:"dns"` + DNSRecords shared.PermissionGrant `json:"dns_records"` + LB shared.PermissionGrant `json:"lb"` + Logs shared.PermissionGrant `json:"logs"` + Organization shared.PermissionGrant `json:"organization"` + SSL shared.PermissionGrant `json:"ssl"` + WAF shared.PermissionGrant `json:"waf"` + ZoneSettings shared.PermissionGrant `json:"zone_settings"` + Zones shared.PermissionGrant `json:"zones"` + JSON membershipPermissionsJSON `json:"-"` } // membershipPermissionsJSON contains the JSON metadata for the struct @@ -163,7 +163,7 @@ type membershipPermissionsJSON struct { CachePurge apijson.Field DNS apijson.Field DNSRecords apijson.Field - Lb apijson.Field + LB apijson.Field Logs apijson.Field Organization apijson.Field SSL apijson.Field @@ -182,282 +182,6 @@ func (r membershipPermissionsJSON) RawJSON() string { return r.raw } -type MembershipPermissionsAnalytics struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsAnalyticsJSON `json:"-"` -} - -// membershipPermissionsAnalyticsJSON contains the JSON metadata for the struct -// [MembershipPermissionsAnalytics] -type membershipPermissionsAnalyticsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsAnalytics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsAnalyticsJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsBilling struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsBillingJSON `json:"-"` -} - -// membershipPermissionsBillingJSON contains the JSON metadata for the struct -// [MembershipPermissionsBilling] -type membershipPermissionsBillingJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsBilling) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsBillingJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsCachePurge struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsCachePurgeJSON `json:"-"` -} - -// membershipPermissionsCachePurgeJSON contains the JSON metadata for the struct -// [MembershipPermissionsCachePurge] -type membershipPermissionsCachePurgeJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsCachePurge) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsCachePurgeJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsDNS struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsDNSJSON `json:"-"` -} - -// membershipPermissionsDNSJSON contains the JSON metadata for the struct -// [MembershipPermissionsDNS] -type membershipPermissionsDNSJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsDNSJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsDNSRecords struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsDNSRecordsJSON `json:"-"` -} - -// membershipPermissionsDNSRecordsJSON contains the JSON metadata for the struct -// [MembershipPermissionsDNSRecords] -type membershipPermissionsDNSRecordsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsDNSRecords) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsDNSRecordsJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsLb struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsLbJSON `json:"-"` -} - -// membershipPermissionsLbJSON contains the JSON metadata for the struct -// [MembershipPermissionsLb] -type membershipPermissionsLbJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsLb) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsLbJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsLogs struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsLogsJSON `json:"-"` -} - -// membershipPermissionsLogsJSON contains the JSON metadata for the struct -// [MembershipPermissionsLogs] -type membershipPermissionsLogsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsLogs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsLogsJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsOrganization struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsOrganizationJSON `json:"-"` -} - -// membershipPermissionsOrganizationJSON contains the JSON metadata for the struct -// [MembershipPermissionsOrganization] -type membershipPermissionsOrganizationJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsOrganizationJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsSSL struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsSSLJSON `json:"-"` -} - -// membershipPermissionsSSLJSON contains the JSON metadata for the struct -// [MembershipPermissionsSSL] -type membershipPermissionsSSLJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsSSLJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsWAF struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsWAFJSON `json:"-"` -} - -// membershipPermissionsWAFJSON contains the JSON metadata for the struct -// [MembershipPermissionsWAF] -type membershipPermissionsWAFJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsWAF) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsWAFJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsZoneSettings struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsZoneSettingsJSON `json:"-"` -} - -// membershipPermissionsZoneSettingsJSON contains the JSON metadata for the struct -// [MembershipPermissionsZoneSettings] -type membershipPermissionsZoneSettingsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsZoneSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsZoneSettingsJSON) RawJSON() string { - return r.raw -} - -type MembershipPermissionsZones struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON membershipPermissionsZonesJSON `json:"-"` -} - -// membershipPermissionsZonesJSON contains the JSON metadata for the struct -// [MembershipPermissionsZones] -type membershipPermissionsZonesJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipPermissionsZones) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipPermissionsZonesJSON) RawJSON() string { - return r.raw -} - // Status of this membership. type MembershipStatus string @@ -477,13 +201,13 @@ func (r MembershipStatus) IsKnown() bool { // Union satisfied by [memberships.MembershipUpdateResponseUnknown] or // [shared.UnionString]. -type MembershipUpdateResponse interface { - ImplementsMembershipsMembershipUpdateResponse() +type MembershipUpdateResponseUnion interface { + ImplementsMembershipsMembershipUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*MembershipUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*MembershipUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -516,13 +240,13 @@ func (r membershipDeleteResponseJSON) RawJSON() string { // Union satisfied by [memberships.MembershipGetResponseUnknown] or // [shared.UnionString]. -type MembershipGetResponse interface { - ImplementsMembershipsMembershipGetResponse() +type MembershipGetResponseUnion interface { + ImplementsMembershipsMembershipGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*MembershipGetResponse)(nil)).Elem(), + reflect.TypeOf((*MembershipGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -557,9 +281,9 @@ func (r MembershipUpdateParamsStatus) IsKnown() bool { } type MembershipUpdateResponseEnvelope struct { - Errors []MembershipUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MembershipUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MembershipUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MembershipUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success MembershipUpdateResponseEnvelopeSuccess `json:"success,required"` JSON membershipUpdateResponseEnvelopeJSON `json:"-"` @@ -584,52 +308,6 @@ func (r membershipUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MembershipUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON membershipUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// membershipUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MembershipUpdateResponseEnvelopeErrors] -type membershipUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MembershipUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON membershipUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// membershipUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MembershipUpdateResponseEnvelopeMessages] -type membershipUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MembershipUpdateResponseEnvelopeSuccess bool @@ -664,7 +342,7 @@ type MembershipListParams struct { // URLQuery serializes [MembershipListParams]'s query parameters as `url.Values`. func (r MembershipListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -678,7 +356,7 @@ type MembershipListParamsAccount struct { // `url.Values`. func (r MembershipListParamsAccount) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -733,10 +411,18 @@ func (r MembershipListParamsStatus) IsKnown() bool { return false } +type MembershipDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r MembershipDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type MembershipDeleteResponseEnvelope struct { - Errors []MembershipDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MembershipDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MembershipDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MembershipDeleteResponse `json:"result,required"` // Whether the API call was successful Success MembershipDeleteResponseEnvelopeSuccess `json:"success,required"` JSON membershipDeleteResponseEnvelopeJSON `json:"-"` @@ -761,52 +447,6 @@ func (r membershipDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MembershipDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON membershipDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// membershipDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MembershipDeleteResponseEnvelopeErrors] -type membershipDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MembershipDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON membershipDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// membershipDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MembershipDeleteResponseEnvelopeMessages] -type membershipDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MembershipDeleteResponseEnvelopeSuccess bool @@ -823,9 +463,9 @@ func (r MembershipDeleteResponseEnvelopeSuccess) IsKnown() bool { } type MembershipGetResponseEnvelope struct { - Errors []MembershipGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MembershipGetResponseEnvelopeMessages `json:"messages,required"` - Result MembershipGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MembershipGetResponseUnion `json:"result,required"` // Whether the API call was successful Success MembershipGetResponseEnvelopeSuccess `json:"success,required"` JSON membershipGetResponseEnvelopeJSON `json:"-"` @@ -850,52 +490,6 @@ func (r membershipGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MembershipGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON membershipGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// membershipGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MembershipGetResponseEnvelopeErrors] -type membershipGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MembershipGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON membershipGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// membershipGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MembershipGetResponseEnvelopeMessages] -type membershipGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MembershipGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r membershipGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MembershipGetResponseEnvelopeSuccess bool diff --git a/memberships/membership_test.go b/memberships/membership_test.go index 0181c24d7f3..cd5c30699ea 100644 --- a/memberships/membership_test.go +++ b/memberships/membership_test.go @@ -92,7 +92,13 @@ func TestMembershipDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Memberships.Delete(context.TODO(), "4536bcfad5faccb111b47003c79917fa") + _, err := client.Memberships.Delete( + context.TODO(), + "4536bcfad5faccb111b47003c79917fa", + memberships.MembershipDeleteParams{ + Body: map[string]interface{}{}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/mtls_certificates/aliases.go b/mtls_certificates/aliases.go index 2cb47116516..e60d6610158 100644 --- a/mtls_certificates/aliases.go +++ b/mtls_certificates/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/mtls_certificates/association.go b/mtls_certificates/association.go index 415b6cf70f6..4cf3e762797 100644 --- a/mtls_certificates/association.go +++ b/mtls_certificates/association.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewAssociationService(opts ...option.RequestOption) (r *AssociationService) } // Lists all active associations between the certificate and Cloudflare services. -func (r *AssociationService) Get(ctx context.Context, mtlsCertificateID string, query AssociationGetParams, opts ...option.RequestOption) (res *[]MTLSCertificateAsssociation, err error) { +func (r *AssociationService) Get(ctx context.Context, mtlsCertificateID string, query AssociationGetParams, opts ...option.RequestOption) (res *[]CertificateAsssociation, err error) { opts = append(r.Options[:], opts...) var env AssociationGetResponseEnvelope path := fmt.Sprintf("accounts/%s/mtls_certificates/%s/associations", query.AccountID, mtlsCertificateID) @@ -44,28 +45,28 @@ func (r *AssociationService) Get(ctx context.Context, mtlsCertificateID string, return } -type MTLSCertificateAsssociation struct { +type CertificateAsssociation struct { // The service using the certificate. Service string `json:"service"` // Certificate deployment status for the given service. - Status string `json:"status"` - JSON mtlsCertificateAsssociationJSON `json:"-"` + Status string `json:"status"` + JSON certificateAsssociationJSON `json:"-"` } -// mtlsCertificateAsssociationJSON contains the JSON metadata for the struct -// [MTLSCertificateAsssociation] -type mtlsCertificateAsssociationJSON struct { +// certificateAsssociationJSON contains the JSON metadata for the struct +// [CertificateAsssociation] +type certificateAsssociationJSON struct { Service apijson.Field Status apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *MTLSCertificateAsssociation) UnmarshalJSON(data []byte) (err error) { +func (r *CertificateAsssociation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r mtlsCertificateAsssociationJSON) RawJSON() string { +func (r certificateAsssociationJSON) RawJSON() string { return r.raw } @@ -75,9 +76,9 @@ type AssociationGetParams struct { } type AssociationGetResponseEnvelope struct { - Errors []AssociationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AssociationGetResponseEnvelopeMessages `json:"messages,required"` - Result []MTLSCertificateAsssociation `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []CertificateAsssociation `json:"result,required,nullable"` // Whether the API call was successful Success AssociationGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo AssociationGetResponseEnvelopeResultInfo `json:"result_info"` @@ -104,52 +105,6 @@ func (r associationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AssociationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON associationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// associationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AssociationGetResponseEnvelopeErrors] -type associationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AssociationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r associationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AssociationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON associationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// associationGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AssociationGetResponseEnvelopeMessages] -type associationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AssociationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r associationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AssociationGetResponseEnvelopeSuccess bool diff --git a/mtls_certificates/mtlscertificate.go b/mtls_certificates/mtlscertificate.go index 7dbdb8c96c0..f6edb7beb2a 100644 --- a/mtls_certificates/mtlscertificate.go +++ b/mtls_certificates/mtlscertificate.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -36,7 +37,7 @@ func NewMTLSCertificateService(opts ...option.RequestOption) (r *MTLSCertificate } // Upload a certificate that you want to use with mTLS-enabled Cloudflare services. -func (r *MTLSCertificateService) New(ctx context.Context, params MTLSCertificateNewParams, opts ...option.RequestOption) (res *MTLSCertificateUpdate, err error) { +func (r *MTLSCertificateService) New(ctx context.Context, params MTLSCertificateNewParams, opts ...option.RequestOption) (res *MTLSCertificateNewResponse, err error) { opts = append(r.Options[:], opts...) var env MTLSCertificateNewResponseEnvelope path := fmt.Sprintf("accounts/%s/mtls_certificates", params.AccountID) @@ -73,10 +74,10 @@ func (r *MTLSCertificateService) ListAutoPaging(ctx context.Context, query MTLSC // Deletes the mTLS certificate unless the certificate is in use by one or more // Cloudflare services. -func (r *MTLSCertificateService) Delete(ctx context.Context, mtlsCertificateID string, body MTLSCertificateDeleteParams, opts ...option.RequestOption) (res *MTLSCertificate, err error) { +func (r *MTLSCertificateService) Delete(ctx context.Context, mtlsCertificateID string, params MTLSCertificateDeleteParams, opts ...option.RequestOption) (res *MTLSCertificate, err error) { opts = append(r.Options[:], opts...) var env MTLSCertificateDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/mtls_certificates/%s", body.AccountID, mtlsCertificateID) + path := fmt.Sprintf("accounts/%s/mtls_certificates/%s", params.AccountID, mtlsCertificateID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -143,7 +144,7 @@ func (r mtlsCertificateJSON) RawJSON() string { return r.raw } -type MTLSCertificateUpdate struct { +type MTLSCertificateNewResponse struct { // Identifier ID string `json:"id"` // Indicates whether the certificate is a CA or leaf certificate. @@ -163,13 +164,13 @@ type MTLSCertificateUpdate struct { // This is the time the certificate was updated. UpdatedAt time.Time `json:"updated_at" format:"date-time"` // This is the time the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON mtlsCertificateUpdateJSON `json:"-"` + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON mtlsCertificateNewResponseJSON `json:"-"` } -// mtlsCertificateUpdateJSON contains the JSON metadata for the struct -// [MTLSCertificateUpdate] -type mtlsCertificateUpdateJSON struct { +// mtlsCertificateNewResponseJSON contains the JSON metadata for the struct +// [MTLSCertificateNewResponse] +type mtlsCertificateNewResponseJSON struct { ID apijson.Field CA apijson.Field Certificates apijson.Field @@ -184,11 +185,11 @@ type mtlsCertificateUpdateJSON struct { ExtraFields map[string]apijson.Field } -func (r *MTLSCertificateUpdate) UnmarshalJSON(data []byte) (err error) { +func (r *MTLSCertificateNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r mtlsCertificateUpdateJSON) RawJSON() string { +func (r mtlsCertificateNewResponseJSON) RawJSON() string { return r.raw } @@ -210,9 +211,9 @@ func (r MTLSCertificateNewParams) MarshalJSON() (data []byte, err error) { } type MTLSCertificateNewResponseEnvelope struct { - Errors []MTLSCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result MTLSCertificateUpdate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MTLSCertificateNewResponse `json:"result,required"` // Whether the API call was successful Success MTLSCertificateNewResponseEnvelopeSuccess `json:"success,required"` JSON mtlsCertificateNewResponseEnvelopeJSON `json:"-"` @@ -237,52 +238,6 @@ func (r mtlsCertificateNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MTLSCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// mtlsCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MTLSCertificateNewResponseEnvelopeErrors] -type mtlsCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// mtlsCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MTLSCertificateNewResponseEnvelopeMessages] -type mtlsCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MTLSCertificateNewResponseEnvelopeSuccess bool @@ -306,12 +261,17 @@ type MTLSCertificateListParams struct { type MTLSCertificateDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r MTLSCertificateDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type MTLSCertificateDeleteResponseEnvelope struct { - Errors []MTLSCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MTLSCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MTLSCertificate `json:"result,required"` // Whether the API call was successful Success MTLSCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON mtlsCertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -336,52 +296,6 @@ func (r mtlsCertificateDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MTLSCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// mtlsCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MTLSCertificateDeleteResponseEnvelopeErrors] -type mtlsCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// mtlsCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MTLSCertificateDeleteResponseEnvelopeMessages] -type mtlsCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MTLSCertificateDeleteResponseEnvelopeSuccess bool @@ -403,9 +317,9 @@ type MTLSCertificateGetParams struct { } type MTLSCertificateGetResponseEnvelope struct { - Errors []MTLSCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result MTLSCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MTLSCertificate `json:"result,required"` // Whether the API call was successful Success MTLSCertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON mtlsCertificateGetResponseEnvelopeJSON `json:"-"` @@ -430,52 +344,6 @@ func (r mtlsCertificateGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MTLSCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// mtlsCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [MTLSCertificateGetResponseEnvelopeErrors] -type mtlsCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// mtlsCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MTLSCertificateGetResponseEnvelopeMessages] -type mtlsCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MTLSCertificateGetResponseEnvelopeSuccess bool diff --git a/mtls_certificates/mtlscertificate_test.go b/mtls_certificates/mtlscertificate_test.go index 7646b992b42..339b113e186 100644 --- a/mtls_certificates/mtlscertificate_test.go +++ b/mtls_certificates/mtlscertificate_test.go @@ -89,6 +89,7 @@ func TestMTLSCertificateDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", mtls_certificates.MTLSCertificateDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/origin_ca_certificates/aliases.go b/origin_ca_certificates/aliases.go index 440084bacbf..5dbf3a3458e 100644 --- a/origin_ca_certificates/aliases.go +++ b/origin_ca_certificates/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/origin_ca_certificates/origincacertificate.go b/origin_ca_certificates/origincacertificate.go index 7470100b0cd..53660efd004 100644 --- a/origin_ca_certificates/origincacertificate.go +++ b/origin_ca_certificates/origincacertificate.go @@ -6,10 +6,12 @@ import ( "context" "fmt" "net/http" + "net/url" "reflect" "time" "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" @@ -38,7 +40,7 @@ func NewOriginCACertificateService(opts ...option.RequestOption) (r *OriginCACer // Create an Origin CA certificate. Use your Origin CA Key as your User Service Key // when calling this endpoint ([see above](#requests)). -func (r *OriginCACertificateService) New(ctx context.Context, body OriginCACertificateNewParams, opts ...option.RequestOption) (res *OriginCACertificateNewResponse, err error) { +func (r *OriginCACertificateService) New(ctx context.Context, body OriginCACertificateNewParams, opts ...option.RequestOption) (res *OriginCACertificateNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OriginCACertificateNewResponseEnvelope path := "certificates" @@ -80,7 +82,7 @@ func (r *OriginCACertificateService) ListAutoPaging(ctx context.Context, query O // Revoke an existing Origin CA certificate by its serial number. Use your Origin // CA Key as your User Service Key when calling this endpoint // ([see above](#requests)). -func (r *OriginCACertificateService) Delete(ctx context.Context, certificateID string, opts ...option.RequestOption) (res *OriginCACertificateDeleteResponse, err error) { +func (r *OriginCACertificateService) Delete(ctx context.Context, certificateID string, body OriginCACertificateDeleteParams, opts ...option.RequestOption) (res *OriginCACertificateDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env OriginCACertificateDeleteResponseEnvelope path := fmt.Sprintf("certificates/%s", certificateID) @@ -95,7 +97,7 @@ func (r *OriginCACertificateService) Delete(ctx context.Context, certificateID s // Get an existing Origin CA certificate by its serial number. Use your Origin CA // Key as your User Service Key when calling this endpoint // ([see above](#requests)). -func (r *OriginCACertificateService) Get(ctx context.Context, certificateID string, opts ...option.RequestOption) (res *OriginCACertificateGetResponse, err error) { +func (r *OriginCACertificateService) Get(ctx context.Context, certificateID string, opts ...option.RequestOption) (res *OriginCACertificateGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OriginCACertificateGetResponseEnvelope path := fmt.Sprintf("certificates/%s", certificateID) @@ -191,13 +193,13 @@ func (r OriginCACertificateRequestedValidity) IsKnown() bool { // Union satisfied by // [origin_ca_certificates.OriginCACertificateNewResponseUnknown] or // [shared.UnionString]. -type OriginCACertificateNewResponse interface { - ImplementsOriginCACertificatesOriginCACertificateNewResponse() +type OriginCACertificateNewResponseUnion interface { + ImplementsOriginCACertificatesOriginCACertificateNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*OriginCACertificateNewResponse)(nil)).Elem(), + reflect.TypeOf((*OriginCACertificateNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -231,13 +233,13 @@ func (r originCACertificateDeleteResponseJSON) RawJSON() string { // Union satisfied by // [origin_ca_certificates.OriginCACertificateGetResponseUnknown] or // [shared.UnionString]. -type OriginCACertificateGetResponse interface { - ImplementsOriginCACertificatesOriginCACertificateGetResponse() +type OriginCACertificateGetResponseUnion interface { + ImplementsOriginCACertificatesOriginCACertificateGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*OriginCACertificateGetResponse)(nil)).Elem(), + reflect.TypeOf((*OriginCACertificateGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -303,9 +305,9 @@ func (r OriginCACertificateNewParamsRequestedValidity) IsKnown() bool { } type OriginCACertificateNewResponseEnvelope struct { - Errors []OriginCACertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginCACertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result OriginCACertificateNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginCACertificateNewResponseUnion `json:"result,required"` // Whether the API call was successful Success OriginCACertificateNewResponseEnvelopeSuccess `json:"success,required"` JSON originCACertificateNewResponseEnvelopeJSON `json:"-"` @@ -330,52 +332,6 @@ func (r originCACertificateNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OriginCACertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originCACertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// originCACertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [OriginCACertificateNewResponseEnvelopeErrors] -type originCACertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginCACertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originCACertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginCACertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originCACertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// originCACertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [OriginCACertificateNewResponseEnvelopeMessages] -type originCACertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginCACertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originCACertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginCACertificateNewResponseEnvelopeSuccess bool @@ -392,12 +348,31 @@ func (r OriginCACertificateNewResponseEnvelopeSuccess) IsKnown() bool { } type OriginCACertificateListParams struct { + // Identifier + Identifier param.Field[string] `query:"identifier"` +} + +// URLQuery serializes [OriginCACertificateListParams]'s query parameters as +// `url.Values`. +func (r OriginCACertificateListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type OriginCACertificateDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r OriginCACertificateDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type OriginCACertificateDeleteResponseEnvelope struct { - Errors []OriginCACertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginCACertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result OriginCACertificateDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginCACertificateDeleteResponse `json:"result,required"` // Whether the API call was successful Success OriginCACertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON originCACertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -422,52 +397,6 @@ func (r originCACertificateDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OriginCACertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originCACertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// originCACertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [OriginCACertificateDeleteResponseEnvelopeErrors] -type originCACertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginCACertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originCACertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginCACertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originCACertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// originCACertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [OriginCACertificateDeleteResponseEnvelopeMessages] -type originCACertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginCACertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originCACertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginCACertificateDeleteResponseEnvelopeSuccess bool @@ -484,9 +413,9 @@ func (r OriginCACertificateDeleteResponseEnvelopeSuccess) IsKnown() bool { } type OriginCACertificateGetResponseEnvelope struct { - Errors []OriginCACertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginCACertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginCACertificateGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginCACertificateGetResponseUnion `json:"result,required"` // Whether the API call was successful Success OriginCACertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON originCACertificateGetResponseEnvelopeJSON `json:"-"` @@ -511,52 +440,6 @@ func (r originCACertificateGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OriginCACertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originCACertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// originCACertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [OriginCACertificateGetResponseEnvelopeErrors] -type originCACertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginCACertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originCACertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginCACertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originCACertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// originCACertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [OriginCACertificateGetResponseEnvelopeMessages] -type originCACertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginCACertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originCACertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginCACertificateGetResponseEnvelopeSuccess bool diff --git a/origin_ca_certificates/origincacertificate_test.go b/origin_ca_certificates/origincacertificate_test.go index 7b017b6151c..d9697157fb1 100644 --- a/origin_ca_certificates/origincacertificate_test.go +++ b/origin_ca_certificates/origincacertificate_test.go @@ -43,7 +43,7 @@ func TestOriginCACertificateNewWithOptionalParams(t *testing.T) { } } -func TestOriginCACertificateList(t *testing.T) { +func TestOriginCACertificateListWithOptionalParams(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 { @@ -57,7 +57,9 @@ func TestOriginCACertificateList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.OriginCACertificates.List(context.TODO(), origin_ca_certificates.OriginCACertificateListParams{}) + _, err := client.OriginCACertificates.List(context.TODO(), origin_ca_certificates.OriginCACertificateListParams{ + Identifier: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -81,7 +83,13 @@ func TestOriginCACertificateDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.OriginCACertificates.Delete(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + _, err := client.OriginCACertificates.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + origin_ca_certificates.OriginCACertificateDeleteParams{ + Body: map[string]interface{}{}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/origin_post_quantum_encryption/aliases.go b/origin_post_quantum_encryption/aliases.go index 087aeba8145..b13e0fd8b6a 100644 --- a/origin_post_quantum_encryption/aliases.go +++ b/origin_post_quantum_encryption/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/origin_post_quantum_encryption/originpostquantumencryption.go b/origin_post_quantum_encryption/originpostquantumencryption.go index 99e5e2c0ed3..19f69f1f495 100644 --- a/origin_post_quantum_encryption/originpostquantumencryption.go +++ b/origin_post_quantum_encryption/originpostquantumencryption.go @@ -40,7 +40,7 @@ func NewOriginPostQuantumEncryptionService(opts ...option.RequestOption) (r *Ori // connections when the origin supports and prefers PQ), supported means that PQ // algorithms are advertised but only used when requested by the origin, and off // means that PQ algorithms are not advertised -func (r *OriginPostQuantumEncryptionService) Update(ctx context.Context, params OriginPostQuantumEncryptionUpdateParams, opts ...option.RequestOption) (res *OriginPostQuantumEncryptionUpdateResponse, err error) { +func (r *OriginPostQuantumEncryptionService) Update(ctx context.Context, params OriginPostQuantumEncryptionUpdateParams, opts ...option.RequestOption) (res *OriginPostQuantumEncryptionUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OriginPostQuantumEncryptionUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/cache/origin_post_quantum_encryption", params.ZoneID) @@ -58,7 +58,7 @@ func (r *OriginPostQuantumEncryptionService) Update(ctx context.Context, params // connections when the origin supports and prefers PQ), supported means that PQ // algorithms are advertised but only used when requested by the origin, and off // means that PQ algorithms are not advertised -func (r *OriginPostQuantumEncryptionService) Get(ctx context.Context, query OriginPostQuantumEncryptionGetParams, opts ...option.RequestOption) (res *OriginPostQuantumEncryptionGetResponse, err error) { +func (r *OriginPostQuantumEncryptionService) Get(ctx context.Context, query OriginPostQuantumEncryptionGetParams, opts ...option.RequestOption) (res *OriginPostQuantumEncryptionGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OriginPostQuantumEncryptionGetResponseEnvelope path := fmt.Sprintf("zones/%s/cache/origin_post_quantum_encryption", query.ZoneID) @@ -73,13 +73,13 @@ func (r *OriginPostQuantumEncryptionService) Get(ctx context.Context, query Orig // Union satisfied by // [origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponseUnknown] // or [shared.UnionString]. -type OriginPostQuantumEncryptionUpdateResponse interface { - ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionUpdateResponse() +type OriginPostQuantumEncryptionUpdateResponseUnion interface { + ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*OriginPostQuantumEncryptionUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*OriginPostQuantumEncryptionUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -91,13 +91,13 @@ func init() { // Union satisfied by // [origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponseUnknown] // or [shared.UnionString]. -type OriginPostQuantumEncryptionGetResponse interface { - ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionGetResponse() +type OriginPostQuantumEncryptionGetResponseUnion interface { + ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*OriginPostQuantumEncryptionGetResponse)(nil)).Elem(), + reflect.TypeOf((*OriginPostQuantumEncryptionGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -135,9 +135,9 @@ func (r OriginPostQuantumEncryptionUpdateParamsValue) IsKnown() bool { } type OriginPostQuantumEncryptionUpdateResponseEnvelope struct { - Errors []OriginPostQuantumEncryptionUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginPostQuantumEncryptionUpdateResponseEnvelopeMessages `json:"messages,required"` - Result OriginPostQuantumEncryptionUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginPostQuantumEncryptionUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success OriginPostQuantumEncryptionUpdateResponseEnvelopeSuccess `json:"success,required"` JSON originPostQuantumEncryptionUpdateResponseEnvelopeJSON `json:"-"` @@ -162,54 +162,6 @@ func (r originPostQuantumEncryptionUpdateResponseEnvelopeJSON) RawJSON() string return r.raw } -type OriginPostQuantumEncryptionUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originPostQuantumEncryptionUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// originPostQuantumEncryptionUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [OriginPostQuantumEncryptionUpdateResponseEnvelopeErrors] -type originPostQuantumEncryptionUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginPostQuantumEncryptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originPostQuantumEncryptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginPostQuantumEncryptionUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originPostQuantumEncryptionUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// originPostQuantumEncryptionUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [OriginPostQuantumEncryptionUpdateResponseEnvelopeMessages] -type originPostQuantumEncryptionUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginPostQuantumEncryptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originPostQuantumEncryptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginPostQuantumEncryptionUpdateResponseEnvelopeSuccess bool @@ -231,9 +183,9 @@ type OriginPostQuantumEncryptionGetParams struct { } type OriginPostQuantumEncryptionGetResponseEnvelope struct { - Errors []OriginPostQuantumEncryptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginPostQuantumEncryptionGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginPostQuantumEncryptionGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginPostQuantumEncryptionGetResponseUnion `json:"result,required"` // Whether the API call was successful Success OriginPostQuantumEncryptionGetResponseEnvelopeSuccess `json:"success,required"` JSON originPostQuantumEncryptionGetResponseEnvelopeJSON `json:"-"` @@ -258,52 +210,6 @@ func (r originPostQuantumEncryptionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OriginPostQuantumEncryptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originPostQuantumEncryptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// originPostQuantumEncryptionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [OriginPostQuantumEncryptionGetResponseEnvelopeErrors] -type originPostQuantumEncryptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginPostQuantumEncryptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originPostQuantumEncryptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginPostQuantumEncryptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originPostQuantumEncryptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// originPostQuantumEncryptionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [OriginPostQuantumEncryptionGetResponseEnvelopeMessages] -type originPostQuantumEncryptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginPostQuantumEncryptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originPostQuantumEncryptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginPostQuantumEncryptionGetResponseEnvelopeSuccess bool diff --git a/origin_tls_client_auth/aliases.go b/origin_tls_client_auth/aliases.go index 2cf0b3dcae5..e6c0265e794 100644 --- a/origin_tls_client_auth/aliases.go +++ b/origin_tls_client_auth/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/origin_tls_client_auth/hostname.go b/origin_tls_client_auth/hostname.go index 623bc117976..ad17b87d8f0 100644 --- a/origin_tls_client_auth/hostname.go +++ b/origin_tls_client_auth/hostname.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -38,7 +39,7 @@ func NewHostnameService(opts ...option.RequestOption) (r *HostnameService) { // even if activated at the zone level. 100 maximum associations on a single // certificate are allowed. Note: Use a null value for parameter _enabled_ to // invalidate the association. -func (r *HostnameService) Update(ctx context.Context, params HostnameUpdateParams, opts ...option.RequestOption) (res *[]OriginTLSClientCertificateID, err error) { +func (r *HostnameService) Update(ctx context.Context, params HostnameUpdateParams, opts ...option.RequestOption) (res *[]AuthenticatedOriginPull, err error) { opts = append(r.Options[:], opts...) var env HostnameUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames", params.ZoneID) @@ -51,7 +52,7 @@ func (r *HostnameService) Update(ctx context.Context, params HostnameUpdateParam } // Get the Hostname Status for Client Authentication -func (r *HostnameService) Get(ctx context.Context, hostname string, query HostnameGetParams, opts ...option.RequestOption) (res *OriginTLSClientCertificateID, err error) { +func (r *HostnameService) Get(ctx context.Context, hostname string, query HostnameGetParams, opts ...option.RequestOption) (res *AuthenticatedOriginPull, err error) { opts = append(r.Options[:], opts...) var env HostnameGetResponseEnvelope path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/%s", query.ZoneID, hostname) @@ -63,11 +64,11 @@ func (r *HostnameService) Get(ctx context.Context, hostname string, query Hostna return } -type OriginTLSClientCertificateID struct { +type AuthenticatedOriginPull struct { // Identifier CERTID string `json:"cert_id"` // Status of the certificate or the association. - CERTStatus OriginTLSClientCertificateIDCERTStatus `json:"cert_status"` + CERTStatus AuthenticatedOriginPullCERTStatus `json:"cert_status"` // The time when the certificate was updated. CERTUpdatedAt time.Time `json:"cert_updated_at" format:"date-time"` // The time when the certificate was uploaded. @@ -91,15 +92,15 @@ type OriginTLSClientCertificateID struct { // The type of hash used for the certificate. Signature string `json:"signature"` // Status of the certificate or the association. - Status OriginTLSClientCertificateIDStatus `json:"status"` + Status AuthenticatedOriginPullStatus `json:"status"` // The time when the certificate was updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON originTLSClientCertificateIDJSON `json:"-"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON authenticatedOriginPullJSON `json:"-"` } -// originTLSClientCertificateIDJSON contains the JSON metadata for the struct -// [OriginTLSClientCertificateID] -type originTLSClientCertificateIDJSON struct { +// authenticatedOriginPullJSON contains the JSON metadata for the struct +// [AuthenticatedOriginPull] +type authenticatedOriginPullJSON struct { CERTID apijson.Field CERTStatus apijson.Field CERTUpdatedAt apijson.Field @@ -118,51 +119,51 @@ type originTLSClientCertificateIDJSON struct { ExtraFields map[string]apijson.Field } -func (r *OriginTLSClientCertificateID) UnmarshalJSON(data []byte) (err error) { +func (r *AuthenticatedOriginPull) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r originTLSClientCertificateIDJSON) RawJSON() string { +func (r authenticatedOriginPullJSON) RawJSON() string { return r.raw } // Status of the certificate or the association. -type OriginTLSClientCertificateIDCERTStatus string +type AuthenticatedOriginPullCERTStatus string const ( - OriginTLSClientCertificateIDCERTStatusInitializing OriginTLSClientCertificateIDCERTStatus = "initializing" - OriginTLSClientCertificateIDCERTStatusPendingDeployment OriginTLSClientCertificateIDCERTStatus = "pending_deployment" - OriginTLSClientCertificateIDCERTStatusPendingDeletion OriginTLSClientCertificateIDCERTStatus = "pending_deletion" - OriginTLSClientCertificateIDCERTStatusActive OriginTLSClientCertificateIDCERTStatus = "active" - OriginTLSClientCertificateIDCERTStatusDeleted OriginTLSClientCertificateIDCERTStatus = "deleted" - OriginTLSClientCertificateIDCERTStatusDeploymentTimedOut OriginTLSClientCertificateIDCERTStatus = "deployment_timed_out" - OriginTLSClientCertificateIDCERTStatusDeletionTimedOut OriginTLSClientCertificateIDCERTStatus = "deletion_timed_out" + AuthenticatedOriginPullCERTStatusInitializing AuthenticatedOriginPullCERTStatus = "initializing" + AuthenticatedOriginPullCERTStatusPendingDeployment AuthenticatedOriginPullCERTStatus = "pending_deployment" + AuthenticatedOriginPullCERTStatusPendingDeletion AuthenticatedOriginPullCERTStatus = "pending_deletion" + AuthenticatedOriginPullCERTStatusActive AuthenticatedOriginPullCERTStatus = "active" + AuthenticatedOriginPullCERTStatusDeleted AuthenticatedOriginPullCERTStatus = "deleted" + AuthenticatedOriginPullCERTStatusDeploymentTimedOut AuthenticatedOriginPullCERTStatus = "deployment_timed_out" + AuthenticatedOriginPullCERTStatusDeletionTimedOut AuthenticatedOriginPullCERTStatus = "deletion_timed_out" ) -func (r OriginTLSClientCertificateIDCERTStatus) IsKnown() bool { +func (r AuthenticatedOriginPullCERTStatus) IsKnown() bool { switch r { - case OriginTLSClientCertificateIDCERTStatusInitializing, OriginTLSClientCertificateIDCERTStatusPendingDeployment, OriginTLSClientCertificateIDCERTStatusPendingDeletion, OriginTLSClientCertificateIDCERTStatusActive, OriginTLSClientCertificateIDCERTStatusDeleted, OriginTLSClientCertificateIDCERTStatusDeploymentTimedOut, OriginTLSClientCertificateIDCERTStatusDeletionTimedOut: + case AuthenticatedOriginPullCERTStatusInitializing, AuthenticatedOriginPullCERTStatusPendingDeployment, AuthenticatedOriginPullCERTStatusPendingDeletion, AuthenticatedOriginPullCERTStatusActive, AuthenticatedOriginPullCERTStatusDeleted, AuthenticatedOriginPullCERTStatusDeploymentTimedOut, AuthenticatedOriginPullCERTStatusDeletionTimedOut: return true } return false } // Status of the certificate or the association. -type OriginTLSClientCertificateIDStatus string +type AuthenticatedOriginPullStatus string const ( - OriginTLSClientCertificateIDStatusInitializing OriginTLSClientCertificateIDStatus = "initializing" - OriginTLSClientCertificateIDStatusPendingDeployment OriginTLSClientCertificateIDStatus = "pending_deployment" - OriginTLSClientCertificateIDStatusPendingDeletion OriginTLSClientCertificateIDStatus = "pending_deletion" - OriginTLSClientCertificateIDStatusActive OriginTLSClientCertificateIDStatus = "active" - OriginTLSClientCertificateIDStatusDeleted OriginTLSClientCertificateIDStatus = "deleted" - OriginTLSClientCertificateIDStatusDeploymentTimedOut OriginTLSClientCertificateIDStatus = "deployment_timed_out" - OriginTLSClientCertificateIDStatusDeletionTimedOut OriginTLSClientCertificateIDStatus = "deletion_timed_out" + AuthenticatedOriginPullStatusInitializing AuthenticatedOriginPullStatus = "initializing" + AuthenticatedOriginPullStatusPendingDeployment AuthenticatedOriginPullStatus = "pending_deployment" + AuthenticatedOriginPullStatusPendingDeletion AuthenticatedOriginPullStatus = "pending_deletion" + AuthenticatedOriginPullStatusActive AuthenticatedOriginPullStatus = "active" + AuthenticatedOriginPullStatusDeleted AuthenticatedOriginPullStatus = "deleted" + AuthenticatedOriginPullStatusDeploymentTimedOut AuthenticatedOriginPullStatus = "deployment_timed_out" + AuthenticatedOriginPullStatusDeletionTimedOut AuthenticatedOriginPullStatus = "deletion_timed_out" ) -func (r OriginTLSClientCertificateIDStatus) IsKnown() bool { +func (r AuthenticatedOriginPullStatus) IsKnown() bool { switch r { - case OriginTLSClientCertificateIDStatusInitializing, OriginTLSClientCertificateIDStatusPendingDeployment, OriginTLSClientCertificateIDStatusPendingDeletion, OriginTLSClientCertificateIDStatusActive, OriginTLSClientCertificateIDStatusDeleted, OriginTLSClientCertificateIDStatusDeploymentTimedOut, OriginTLSClientCertificateIDStatusDeletionTimedOut: + case AuthenticatedOriginPullStatusInitializing, AuthenticatedOriginPullStatusPendingDeployment, AuthenticatedOriginPullStatusPendingDeletion, AuthenticatedOriginPullStatusActive, AuthenticatedOriginPullStatusDeleted, AuthenticatedOriginPullStatusDeploymentTimedOut, AuthenticatedOriginPullStatusDeletionTimedOut: return true } return false @@ -194,9 +195,9 @@ func (r HostnameUpdateParamsConfig) MarshalJSON() (data []byte, err error) { } type HostnameUpdateResponseEnvelope struct { - Errors []HostnameUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []OriginTLSClientCertificateID `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []AuthenticatedOriginPull `json:"result,required,nullable"` // Whether the API call was successful Success HostnameUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo HostnameUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -223,52 +224,6 @@ func (r hostnameUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HostnameUpdateResponseEnvelopeErrors] -type hostnameUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HostnameUpdateResponseEnvelopeMessages] -type hostnameUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameUpdateResponseEnvelopeSuccess bool @@ -321,9 +276,9 @@ type HostnameGetParams struct { } type HostnameGetResponseEnvelope struct { - Errors []HostnameGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientCertificateID `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AuthenticatedOriginPull `json:"result,required"` // Whether the API call was successful Success HostnameGetResponseEnvelopeSuccess `json:"success,required"` JSON hostnameGetResponseEnvelopeJSON `json:"-"` @@ -348,52 +303,6 @@ func (r hostnameGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [HostnameGetResponseEnvelopeErrors] -type hostnameGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HostnameGetResponseEnvelopeMessages] -type hostnameGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameGetResponseEnvelopeSuccess bool diff --git a/origin_tls_client_auth/hostnamecertificate.go b/origin_tls_client_auth/hostnamecertificate.go index 21ee588cc3a..5adecc4d2b3 100644 --- a/origin_tls_client_auth/hostnamecertificate.go +++ b/origin_tls_client_auth/hostnamecertificate.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -35,7 +36,7 @@ func NewHostnameCertificateService(opts ...option.RequestOption) (r *HostnameCer // Upload a certificate to be used for client authentication on a hostname. 10 // hostname certificates per zone are allowed. -func (r *HostnameCertificateService) New(ctx context.Context, params HostnameCertificateNewParams, opts ...option.RequestOption) (res *OriginTLSClientCertificate, err error) { +func (r *HostnameCertificateService) New(ctx context.Context, params HostnameCertificateNewParams, opts ...option.RequestOption) (res *HostnameCertificateNewResponse, err error) { opts = append(r.Options[:], opts...) var env HostnameCertificateNewResponseEnvelope path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates", params.ZoneID) @@ -48,7 +49,7 @@ func (r *HostnameCertificateService) New(ctx context.Context, params HostnameCer } // List Certificates -func (r *HostnameCertificateService) List(ctx context.Context, query HostnameCertificateListParams, opts ...option.RequestOption) (res *pagination.SinglePage[OriginTLSClientCertificateID], err error) { +func (r *HostnameCertificateService) List(ctx context.Context, query HostnameCertificateListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AuthenticatedOriginPull], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -66,15 +67,15 @@ func (r *HostnameCertificateService) List(ctx context.Context, query HostnameCer } // List Certificates -func (r *HostnameCertificateService) ListAutoPaging(ctx context.Context, query HostnameCertificateListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[OriginTLSClientCertificateID] { +func (r *HostnameCertificateService) ListAutoPaging(ctx context.Context, query HostnameCertificateListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AuthenticatedOriginPull] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete Hostname Client Certificate -func (r *HostnameCertificateService) Delete(ctx context.Context, certificateID string, body HostnameCertificateDeleteParams, opts ...option.RequestOption) (res *OriginTLSClientCertificate, err error) { +func (r *HostnameCertificateService) Delete(ctx context.Context, certificateID string, params HostnameCertificateDeleteParams, opts ...option.RequestOption) (res *HostnameCertificateDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env HostnameCertificateDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates/%s", body.ZoneID, certificateID) + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates/%s", params.ZoneID, certificateID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -84,7 +85,7 @@ func (r *HostnameCertificateService) Delete(ctx context.Context, certificateID s } // Get the certificate by ID to be used for client authentication on a hostname. -func (r *HostnameCertificateService) Get(ctx context.Context, certificateID string, query HostnameCertificateGetParams, opts ...option.RequestOption) (res *OriginTLSClientCertificate, err error) { +func (r *HostnameCertificateService) Get(ctx context.Context, certificateID string, query HostnameCertificateGetParams, opts ...option.RequestOption) (res *HostnameCertificateGetResponse, err error) { opts = append(r.Options[:], opts...) var env HostnameCertificateGetResponseEnvelope path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates/%s", query.ZoneID, certificateID) @@ -96,7 +97,7 @@ func (r *HostnameCertificateService) Get(ctx context.Context, certificateID stri return } -type OriginTLSClientCertificate struct { +type Certificate struct { // Identifier ID string `json:"id"` // The hostname certificate. @@ -110,15 +111,14 @@ type OriginTLSClientCertificate struct { // The type of hash used for the certificate. Signature string `json:"signature"` // Status of the certificate or the association. - Status OriginTLSClientCertificateStatus `json:"status"` + Status CertificateStatus `json:"status"` // The time when the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON originTLSClientCertificateJSON `json:"-"` + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON certificateJSON `json:"-"` } -// originTLSClientCertificateJSON contains the JSON metadata for the struct -// [OriginTLSClientCertificate] -type originTLSClientCertificateJSON struct { +// certificateJSON contains the JSON metadata for the struct [Certificate] +type certificateJSON struct { ID apijson.Field Certificate apijson.Field ExpiresOn apijson.Field @@ -131,119 +131,265 @@ type originTLSClientCertificateJSON struct { ExtraFields map[string]apijson.Field } -func (r *OriginTLSClientCertificate) UnmarshalJSON(data []byte) (err error) { +func (r *Certificate) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r originTLSClientCertificateJSON) RawJSON() string { +func (r certificateJSON) RawJSON() string { return r.raw } // Status of the certificate or the association. -type OriginTLSClientCertificateStatus string +type CertificateStatus string const ( - OriginTLSClientCertificateStatusInitializing OriginTLSClientCertificateStatus = "initializing" - OriginTLSClientCertificateStatusPendingDeployment OriginTLSClientCertificateStatus = "pending_deployment" - OriginTLSClientCertificateStatusPendingDeletion OriginTLSClientCertificateStatus = "pending_deletion" - OriginTLSClientCertificateStatusActive OriginTLSClientCertificateStatus = "active" - OriginTLSClientCertificateStatusDeleted OriginTLSClientCertificateStatus = "deleted" - OriginTLSClientCertificateStatusDeploymentTimedOut OriginTLSClientCertificateStatus = "deployment_timed_out" - OriginTLSClientCertificateStatusDeletionTimedOut OriginTLSClientCertificateStatus = "deletion_timed_out" + CertificateStatusInitializing CertificateStatus = "initializing" + CertificateStatusPendingDeployment CertificateStatus = "pending_deployment" + CertificateStatusPendingDeletion CertificateStatus = "pending_deletion" + CertificateStatusActive CertificateStatus = "active" + CertificateStatusDeleted CertificateStatus = "deleted" + CertificateStatusDeploymentTimedOut CertificateStatus = "deployment_timed_out" + CertificateStatusDeletionTimedOut CertificateStatus = "deletion_timed_out" ) -func (r OriginTLSClientCertificateStatus) IsKnown() bool { +func (r CertificateStatus) IsKnown() bool { switch r { - case OriginTLSClientCertificateStatusInitializing, OriginTLSClientCertificateStatusPendingDeployment, OriginTLSClientCertificateStatusPendingDeletion, OriginTLSClientCertificateStatusActive, OriginTLSClientCertificateStatusDeleted, OriginTLSClientCertificateStatusDeploymentTimedOut, OriginTLSClientCertificateStatusDeletionTimedOut: + case CertificateStatusInitializing, CertificateStatusPendingDeployment, CertificateStatusPendingDeletion, CertificateStatusActive, CertificateStatusDeleted, CertificateStatusDeploymentTimedOut, CertificateStatusDeletionTimedOut: return true } return false } -type HostnameCertificateNewParams struct { +type HostnameCertificateNewResponse struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ID string `json:"id"` // The hostname certificate. - Certificate param.Field[string] `json:"certificate,required"` - // The hostname certificate's private key. - PrivateKey param.Field[string] `json:"private_key,required"` + Certificate string `json:"certificate"` + // The date when the certificate expires. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The certificate authority that issued the certificate. + Issuer string `json:"issuer"` + // The serial number on the uploaded certificate. + SerialNumber string `json:"serial_number"` + // The type of hash used for the certificate. + Signature string `json:"signature"` + // Status of the certificate or the association. + Status HostnameCertificateNewResponseStatus `json:"status"` + // The time when the certificate was uploaded. + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON hostnameCertificateNewResponseJSON `json:"-"` } -func (r HostnameCertificateNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// hostnameCertificateNewResponseJSON contains the JSON metadata for the struct +// [HostnameCertificateNewResponse] +type hostnameCertificateNewResponseJSON struct { + ID apijson.Field + Certificate apijson.Field + ExpiresOn apijson.Field + Issuer apijson.Field + SerialNumber apijson.Field + Signature apijson.Field + Status apijson.Field + UploadedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type HostnameCertificateNewResponseEnvelope struct { - Errors []HostnameCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientCertificate `json:"result,required"` - // Whether the API call was successful - Success HostnameCertificateNewResponseEnvelopeSuccess `json:"success,required"` - JSON hostnameCertificateNewResponseEnvelopeJSON `json:"-"` +func (r *HostnameCertificateNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// hostnameCertificateNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [HostnameCertificateNewResponseEnvelope] -type hostnameCertificateNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r hostnameCertificateNewResponseJSON) RawJSON() string { + return r.raw } -func (r *HostnameCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +// Status of the certificate or the association. +type HostnameCertificateNewResponseStatus string + +const ( + HostnameCertificateNewResponseStatusInitializing HostnameCertificateNewResponseStatus = "initializing" + HostnameCertificateNewResponseStatusPendingDeployment HostnameCertificateNewResponseStatus = "pending_deployment" + HostnameCertificateNewResponseStatusPendingDeletion HostnameCertificateNewResponseStatus = "pending_deletion" + HostnameCertificateNewResponseStatusActive HostnameCertificateNewResponseStatus = "active" + HostnameCertificateNewResponseStatusDeleted HostnameCertificateNewResponseStatus = "deleted" + HostnameCertificateNewResponseStatusDeploymentTimedOut HostnameCertificateNewResponseStatus = "deployment_timed_out" + HostnameCertificateNewResponseStatusDeletionTimedOut HostnameCertificateNewResponseStatus = "deletion_timed_out" +) + +func (r HostnameCertificateNewResponseStatus) IsKnown() bool { + switch r { + case HostnameCertificateNewResponseStatusInitializing, HostnameCertificateNewResponseStatusPendingDeployment, HostnameCertificateNewResponseStatusPendingDeletion, HostnameCertificateNewResponseStatusActive, HostnameCertificateNewResponseStatusDeleted, HostnameCertificateNewResponseStatusDeploymentTimedOut, HostnameCertificateNewResponseStatusDeletionTimedOut: + return true + } + return false +} + +type HostnameCertificateDeleteResponse struct { + // Identifier + ID string `json:"id"` + // The hostname certificate. + Certificate string `json:"certificate"` + // The date when the certificate expires. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The certificate authority that issued the certificate. + Issuer string `json:"issuer"` + // The serial number on the uploaded certificate. + SerialNumber string `json:"serial_number"` + // The type of hash used for the certificate. + Signature string `json:"signature"` + // Status of the certificate or the association. + Status HostnameCertificateDeleteResponseStatus `json:"status"` + // The time when the certificate was uploaded. + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON hostnameCertificateDeleteResponseJSON `json:"-"` +} + +// hostnameCertificateDeleteResponseJSON contains the JSON metadata for the struct +// [HostnameCertificateDeleteResponse] +type hostnameCertificateDeleteResponseJSON struct { + ID apijson.Field + Certificate apijson.Field + ExpiresOn apijson.Field + Issuer apijson.Field + SerialNumber apijson.Field + Signature apijson.Field + Status apijson.Field + UploadedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r hostnameCertificateNewResponseEnvelopeJSON) RawJSON() string { +func (r hostnameCertificateDeleteResponseJSON) RawJSON() string { return r.raw } -type HostnameCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameCertificateNewResponseEnvelopeErrorsJSON `json:"-"` +// Status of the certificate or the association. +type HostnameCertificateDeleteResponseStatus string + +const ( + HostnameCertificateDeleteResponseStatusInitializing HostnameCertificateDeleteResponseStatus = "initializing" + HostnameCertificateDeleteResponseStatusPendingDeployment HostnameCertificateDeleteResponseStatus = "pending_deployment" + HostnameCertificateDeleteResponseStatusPendingDeletion HostnameCertificateDeleteResponseStatus = "pending_deletion" + HostnameCertificateDeleteResponseStatusActive HostnameCertificateDeleteResponseStatus = "active" + HostnameCertificateDeleteResponseStatusDeleted HostnameCertificateDeleteResponseStatus = "deleted" + HostnameCertificateDeleteResponseStatusDeploymentTimedOut HostnameCertificateDeleteResponseStatus = "deployment_timed_out" + HostnameCertificateDeleteResponseStatusDeletionTimedOut HostnameCertificateDeleteResponseStatus = "deletion_timed_out" +) + +func (r HostnameCertificateDeleteResponseStatus) IsKnown() bool { + switch r { + case HostnameCertificateDeleteResponseStatusInitializing, HostnameCertificateDeleteResponseStatusPendingDeployment, HostnameCertificateDeleteResponseStatusPendingDeletion, HostnameCertificateDeleteResponseStatusActive, HostnameCertificateDeleteResponseStatusDeleted, HostnameCertificateDeleteResponseStatusDeploymentTimedOut, HostnameCertificateDeleteResponseStatusDeletionTimedOut: + return true + } + return false } -// hostnameCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HostnameCertificateNewResponseEnvelopeErrors] -type hostnameCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +type HostnameCertificateGetResponse struct { + // Identifier + ID string `json:"id"` + // The hostname certificate. + Certificate string `json:"certificate"` + // The date when the certificate expires. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The certificate authority that issued the certificate. + Issuer string `json:"issuer"` + // The serial number on the uploaded certificate. + SerialNumber string `json:"serial_number"` + // The type of hash used for the certificate. + Signature string `json:"signature"` + // Status of the certificate or the association. + Status HostnameCertificateGetResponseStatus `json:"status"` + // The time when the certificate was uploaded. + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON hostnameCertificateGetResponseJSON `json:"-"` +} + +// hostnameCertificateGetResponseJSON contains the JSON metadata for the struct +// [HostnameCertificateGetResponse] +type hostnameCertificateGetResponseJSON struct { + ID apijson.Field + Certificate apijson.Field + ExpiresOn apijson.Field + Issuer apijson.Field + SerialNumber apijson.Field + Signature apijson.Field + Status apijson.Field + UploadedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *HostnameCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { +func (r *HostnameCertificateGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r hostnameCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { +func (r hostnameCertificateGetResponseJSON) RawJSON() string { return r.raw } -type HostnameCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameCertificateNewResponseEnvelopeMessagesJSON `json:"-"` +// Status of the certificate or the association. +type HostnameCertificateGetResponseStatus string + +const ( + HostnameCertificateGetResponseStatusInitializing HostnameCertificateGetResponseStatus = "initializing" + HostnameCertificateGetResponseStatusPendingDeployment HostnameCertificateGetResponseStatus = "pending_deployment" + HostnameCertificateGetResponseStatusPendingDeletion HostnameCertificateGetResponseStatus = "pending_deletion" + HostnameCertificateGetResponseStatusActive HostnameCertificateGetResponseStatus = "active" + HostnameCertificateGetResponseStatusDeleted HostnameCertificateGetResponseStatus = "deleted" + HostnameCertificateGetResponseStatusDeploymentTimedOut HostnameCertificateGetResponseStatus = "deployment_timed_out" + HostnameCertificateGetResponseStatusDeletionTimedOut HostnameCertificateGetResponseStatus = "deletion_timed_out" +) + +func (r HostnameCertificateGetResponseStatus) IsKnown() bool { + switch r { + case HostnameCertificateGetResponseStatusInitializing, HostnameCertificateGetResponseStatusPendingDeployment, HostnameCertificateGetResponseStatusPendingDeletion, HostnameCertificateGetResponseStatusActive, HostnameCertificateGetResponseStatusDeleted, HostnameCertificateGetResponseStatusDeploymentTimedOut, HostnameCertificateGetResponseStatusDeletionTimedOut: + return true + } + return false +} + +type HostnameCertificateNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The hostname certificate. + Certificate param.Field[string] `json:"certificate,required"` + // The hostname certificate's private key. + PrivateKey param.Field[string] `json:"private_key,required"` +} + +func (r HostnameCertificateNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostnameCertificateNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameCertificateNewResponse `json:"result,required"` + // Whether the API call was successful + Success HostnameCertificateNewResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameCertificateNewResponseEnvelopeJSON `json:"-"` } -// hostnameCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HostnameCertificateNewResponseEnvelopeMessages] -type hostnameCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field +// hostnameCertificateNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameCertificateNewResponseEnvelope] +type hostnameCertificateNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *HostnameCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *HostnameCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r hostnameCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { +func (r hostnameCertificateNewResponseEnvelopeJSON) RawJSON() string { return r.raw } @@ -270,12 +416,17 @@ type HostnameCertificateListParams struct { type HostnameCertificateDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r HostnameCertificateDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type HostnameCertificateDeleteResponseEnvelope struct { - Errors []HostnameCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameCertificateDeleteResponse `json:"result,required"` // Whether the API call was successful Success HostnameCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON hostnameCertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -300,52 +451,6 @@ func (r hostnameCertificateDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [HostnameCertificateDeleteResponseEnvelopeErrors] -type hostnameCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HostnameCertificateDeleteResponseEnvelopeMessages] -type hostnameCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameCertificateDeleteResponseEnvelopeSuccess bool @@ -367,9 +472,9 @@ type HostnameCertificateGetParams struct { } type HostnameCertificateGetResponseEnvelope struct { - Errors []HostnameCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientCertificate `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameCertificateGetResponse `json:"result,required"` // Whether the API call was successful Success HostnameCertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON hostnameCertificateGetResponseEnvelopeJSON `json:"-"` @@ -394,52 +499,6 @@ func (r hostnameCertificateGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HostnameCertificateGetResponseEnvelopeErrors] -type hostnameCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HostnameCertificateGetResponseEnvelopeMessages] -type hostnameCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameCertificateGetResponseEnvelopeSuccess bool diff --git a/origin_tls_client_auth/hostnamecertificate_test.go b/origin_tls_client_auth/hostnamecertificate_test.go index 6af3d9f65fd..28868c3714f 100644 --- a/origin_tls_client_auth/hostnamecertificate_test.go +++ b/origin_tls_client_auth/hostnamecertificate_test.go @@ -87,6 +87,7 @@ func TestHostnameCertificateDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", origin_tls_client_auth.HostnameCertificateDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/origin_tls_client_auth/origintlsclientauth.go b/origin_tls_client_auth/origintlsclientauth.go index 5dcf96cc7f6..1c8f62d9672 100644 --- a/origin_tls_client_auth/origintlsclientauth.go +++ b/origin_tls_client_auth/origintlsclientauth.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "reflect" + "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" @@ -44,7 +45,7 @@ func NewOriginTLSClientAuthService(opts ...option.RequestOption) (r *OriginTLSCl // important to keep only one certificate active. Also, make sure to enable // zone-level authenticated origin pulls by making a PUT call to settings endpoint // to see the uploaded certificate in use. -func (r *OriginTLSClientAuthService) New(ctx context.Context, params OriginTLSClientAuthNewParams, opts ...option.RequestOption) (res *OriginTLSClientAuthNewResponse, err error) { +func (r *OriginTLSClientAuthService) New(ctx context.Context, params OriginTLSClientAuthNewParams, opts ...option.RequestOption) (res *OriginTLSClientAuthNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OriginTLSClientAuthNewResponseEnvelope path := fmt.Sprintf("zones/%s/origin_tls_client_auth", params.ZoneID) @@ -57,7 +58,7 @@ func (r *OriginTLSClientAuthService) New(ctx context.Context, params OriginTLSCl } // List Certificates -func (r *OriginTLSClientAuthService) List(ctx context.Context, query OriginTLSClientAuthListParams, opts ...option.RequestOption) (res *pagination.SinglePage[OriginTLSClientAuthListResponse], err error) { +func (r *OriginTLSClientAuthService) List(ctx context.Context, query OriginTLSClientAuthListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZoneAuthenticatedOriginPull], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -75,15 +76,15 @@ func (r *OriginTLSClientAuthService) List(ctx context.Context, query OriginTLSCl } // List Certificates -func (r *OriginTLSClientAuthService) ListAutoPaging(ctx context.Context, query OriginTLSClientAuthListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[OriginTLSClientAuthListResponse] { +func (r *OriginTLSClientAuthService) ListAutoPaging(ctx context.Context, query OriginTLSClientAuthListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZoneAuthenticatedOriginPull] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete Certificate -func (r *OriginTLSClientAuthService) Delete(ctx context.Context, certificateID string, body OriginTLSClientAuthDeleteParams, opts ...option.RequestOption) (res *OriginTLSClientAuthDeleteResponse, err error) { +func (r *OriginTLSClientAuthService) Delete(ctx context.Context, certificateID string, params OriginTLSClientAuthDeleteParams, opts ...option.RequestOption) (res *OriginTLSClientAuthDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OriginTLSClientAuthDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/%s", body.ZoneID, certificateID) + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/%s", params.ZoneID, certificateID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -93,7 +94,7 @@ func (r *OriginTLSClientAuthService) Delete(ctx context.Context, certificateID s } // Get Certificate Details -func (r *OriginTLSClientAuthService) Get(ctx context.Context, certificateID string, query OriginTLSClientAuthGetParams, opts ...option.RequestOption) (res *OriginTLSClientAuthGetResponse, err error) { +func (r *OriginTLSClientAuthService) Get(ctx context.Context, certificateID string, query OriginTLSClientAuthGetParams, opts ...option.RequestOption) (res *OriginTLSClientAuthGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OriginTLSClientAuthGetResponseEnvelope path := fmt.Sprintf("zones/%s/origin_tls_client_auth/%s", query.ZoneID, certificateID) @@ -105,65 +106,95 @@ func (r *OriginTLSClientAuthService) Get(ctx context.Context, certificateID stri return } -// Union satisfied by -// [origin_tls_client_auth.OriginTLSClientAuthNewResponseUnknown] or -// [shared.UnionString]. -type OriginTLSClientAuthNewResponse interface { - ImplementsOriginTLSClientAuthOriginTLSClientAuthNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*OriginTLSClientAuthNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type OriginTLSClientAuthListResponse struct { +type ZoneAuthenticatedOriginPull struct { // Identifier ID string `json:"id"` // The zone's leaf certificate. Certificate string `json:"certificate"` - // Indicates whether zone-level authenticated origin pulls is enabled. - Enabled bool `json:"enabled"` - // The zone's private key. - PrivateKey string `json:"private_key"` - JSON originTLSClientAuthListResponseJSON `json:"-"` -} - -// originTLSClientAuthListResponseJSON contains the JSON metadata for the struct -// [OriginTLSClientAuthListResponse] -type originTLSClientAuthListResponseJSON struct { + // When the certificate from the authority expires. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The certificate authority that issued the certificate. + Issuer string `json:"issuer"` + // The type of hash used for the certificate. + Signature string `json:"signature"` + // Status of the certificate activation. + Status ZoneAuthenticatedOriginPullStatus `json:"status"` + // This is the time the certificate was uploaded. + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON zoneAuthenticatedOriginPullJSON `json:"-"` +} + +// zoneAuthenticatedOriginPullJSON contains the JSON metadata for the struct +// [ZoneAuthenticatedOriginPull] +type zoneAuthenticatedOriginPullJSON struct { ID apijson.Field Certificate apijson.Field - Enabled apijson.Field - PrivateKey apijson.Field + ExpiresOn apijson.Field + Issuer apijson.Field + Signature apijson.Field + Status apijson.Field + UploadedOn apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *OriginTLSClientAuthListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *ZoneAuthenticatedOriginPull) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r originTLSClientAuthListResponseJSON) RawJSON() string { +func (r zoneAuthenticatedOriginPullJSON) RawJSON() string { return r.raw } +// Status of the certificate activation. +type ZoneAuthenticatedOriginPullStatus string + +const ( + ZoneAuthenticatedOriginPullStatusInitializing ZoneAuthenticatedOriginPullStatus = "initializing" + ZoneAuthenticatedOriginPullStatusPendingDeployment ZoneAuthenticatedOriginPullStatus = "pending_deployment" + ZoneAuthenticatedOriginPullStatusPendingDeletion ZoneAuthenticatedOriginPullStatus = "pending_deletion" + ZoneAuthenticatedOriginPullStatusActive ZoneAuthenticatedOriginPullStatus = "active" + ZoneAuthenticatedOriginPullStatusDeleted ZoneAuthenticatedOriginPullStatus = "deleted" + ZoneAuthenticatedOriginPullStatusDeploymentTimedOut ZoneAuthenticatedOriginPullStatus = "deployment_timed_out" + ZoneAuthenticatedOriginPullStatusDeletionTimedOut ZoneAuthenticatedOriginPullStatus = "deletion_timed_out" +) + +func (r ZoneAuthenticatedOriginPullStatus) IsKnown() bool { + switch r { + case ZoneAuthenticatedOriginPullStatusInitializing, ZoneAuthenticatedOriginPullStatusPendingDeployment, ZoneAuthenticatedOriginPullStatusPendingDeletion, ZoneAuthenticatedOriginPullStatusActive, ZoneAuthenticatedOriginPullStatusDeleted, ZoneAuthenticatedOriginPullStatusDeploymentTimedOut, ZoneAuthenticatedOriginPullStatusDeletionTimedOut: + return true + } + return false +} + +// Union satisfied by +// [origin_tls_client_auth.OriginTLSClientAuthNewResponseUnknown] or +// [shared.UnionString]. +type OriginTLSClientAuthNewResponseUnion interface { + ImplementsOriginTLSClientAuthOriginTLSClientAuthNewResponseUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*OriginTLSClientAuthNewResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + // Union satisfied by // [origin_tls_client_auth.OriginTLSClientAuthDeleteResponseUnknown] or // [shared.UnionString]. -type OriginTLSClientAuthDeleteResponse interface { - ImplementsOriginTLSClientAuthOriginTLSClientAuthDeleteResponse() +type OriginTLSClientAuthDeleteResponseUnion interface { + ImplementsOriginTLSClientAuthOriginTLSClientAuthDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*OriginTLSClientAuthDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*OriginTLSClientAuthDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -175,13 +206,13 @@ func init() { // Union satisfied by // [origin_tls_client_auth.OriginTLSClientAuthGetResponseUnknown] or // [shared.UnionString]. -type OriginTLSClientAuthGetResponse interface { - ImplementsOriginTLSClientAuthOriginTLSClientAuthGetResponse() +type OriginTLSClientAuthGetResponseUnion interface { + ImplementsOriginTLSClientAuthOriginTLSClientAuthGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*OriginTLSClientAuthGetResponse)(nil)).Elem(), + reflect.TypeOf((*OriginTLSClientAuthGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -204,9 +235,9 @@ func (r OriginTLSClientAuthNewParams) MarshalJSON() (data []byte, err error) { } type OriginTLSClientAuthNewResponseEnvelope struct { - Errors []OriginTLSClientAuthNewResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthNewResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginTLSClientAuthNewResponseUnion `json:"result,required"` // Whether the API call was successful Success OriginTLSClientAuthNewResponseEnvelopeSuccess `json:"success,required"` JSON originTLSClientAuthNewResponseEnvelopeJSON `json:"-"` @@ -231,52 +262,6 @@ func (r originTLSClientAuthNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OriginTLSClientAuthNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [OriginTLSClientAuthNewResponseEnvelopeErrors] -type originTLSClientAuthNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthNewResponseEnvelopeMessages] -type originTLSClientAuthNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginTLSClientAuthNewResponseEnvelopeSuccess bool @@ -300,12 +285,17 @@ type OriginTLSClientAuthListParams struct { type OriginTLSClientAuthDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r OriginTLSClientAuthDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type OriginTLSClientAuthDeleteResponseEnvelope struct { - Errors []OriginTLSClientAuthDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthDeleteResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginTLSClientAuthDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success OriginTLSClientAuthDeleteResponseEnvelopeSuccess `json:"success,required"` JSON originTLSClientAuthDeleteResponseEnvelopeJSON `json:"-"` @@ -330,52 +320,6 @@ func (r originTLSClientAuthDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OriginTLSClientAuthDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthDeleteResponseEnvelopeErrors] -type originTLSClientAuthDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthDeleteResponseEnvelopeMessages] -type originTLSClientAuthDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginTLSClientAuthDeleteResponseEnvelopeSuccess bool @@ -397,9 +341,9 @@ type OriginTLSClientAuthGetParams struct { } type OriginTLSClientAuthGetResponseEnvelope struct { - Errors []OriginTLSClientAuthGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OriginTLSClientAuthGetResponseUnion `json:"result,required"` // Whether the API call was successful Success OriginTLSClientAuthGetResponseEnvelopeSuccess `json:"success,required"` JSON originTLSClientAuthGetResponseEnvelopeJSON `json:"-"` @@ -424,52 +368,6 @@ func (r originTLSClientAuthGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OriginTLSClientAuthGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [OriginTLSClientAuthGetResponseEnvelopeErrors] -type originTLSClientAuthGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthGetResponseEnvelopeMessages] -type originTLSClientAuthGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OriginTLSClientAuthGetResponseEnvelopeSuccess bool diff --git a/origin_tls_client_auth/origintlsclientauth_test.go b/origin_tls_client_auth/origintlsclientauth_test.go index 2f058c9f0f0..a35d31223c1 100644 --- a/origin_tls_client_auth/origintlsclientauth_test.go +++ b/origin_tls_client_auth/origintlsclientauth_test.go @@ -87,6 +87,7 @@ func TestOriginTLSClientAuthDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", origin_tls_client_auth.OriginTLSClientAuthDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/origin_tls_client_auth/setting.go b/origin_tls_client_auth/setting.go index 17af7114b1a..e24df19eb48 100644 --- a/origin_tls_client_auth/setting.go +++ b/origin_tls_client_auth/setting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -115,9 +116,9 @@ func (r SettingUpdateParams) MarshalJSON() (data []byte, err error) { } type SettingUpdateResponseEnvelope struct { - Errors []SettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SettingUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SettingUpdateResponse `json:"result,required"` // Whether the API call was successful Success SettingUpdateResponseEnvelopeSuccess `json:"success,required"` JSON settingUpdateResponseEnvelopeJSON `json:"-"` @@ -142,52 +143,6 @@ func (r settingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingUpdateResponseEnvelopeErrors] -type settingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingUpdateResponseEnvelopeMessages] -type settingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingUpdateResponseEnvelopeSuccess bool @@ -209,9 +164,9 @@ type SettingGetParams struct { } type SettingGetResponseEnvelope struct { - Errors []SettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingGetResponseEnvelopeMessages `json:"messages,required"` - Result SettingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SettingGetResponse `json:"result,required"` // Whether the API call was successful Success SettingGetResponseEnvelopeSuccess `json:"success,required"` JSON settingGetResponseEnvelopeJSON `json:"-"` @@ -236,52 +191,6 @@ func (r settingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SettingGetResponseEnvelopeErrors] -type settingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SettingGetResponseEnvelopeMessages] -type settingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingGetResponseEnvelopeSuccess bool diff --git a/page_shield/aliases.go b/page_shield/aliases.go index 2304a2ecf3e..f9190339eed 100644 --- a/page_shield/aliases.go +++ b/page_shield/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/page_shield/connection.go b/page_shield/connection.go index 5bfd413a463..994dfd72faa 100644 --- a/page_shield/connection.go +++ b/page_shield/connection.go @@ -34,7 +34,7 @@ func NewConnectionService(opts ...option.RequestOption) (r *ConnectionService) { } // Lists all connections detected by Page Shield. -func (r *ConnectionService) List(ctx context.Context, params ConnectionListParams, opts ...option.RequestOption) (res *pagination.SinglePage[PageShieldConnection], err error) { +func (r *ConnectionService) List(ctx context.Context, params ConnectionListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Connection], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -52,35 +52,34 @@ func (r *ConnectionService) List(ctx context.Context, params ConnectionListParam } // Lists all connections detected by Page Shield. -func (r *ConnectionService) ListAutoPaging(ctx context.Context, params ConnectionListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[PageShieldConnection] { +func (r *ConnectionService) ListAutoPaging(ctx context.Context, params ConnectionListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Connection] { return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...)) } // Fetches a connection detected by Page Shield by connection ID. -func (r *ConnectionService) Get(ctx context.Context, connectionID string, query ConnectionGetParams, opts ...option.RequestOption) (res *PageShieldConnection, err error) { +func (r *ConnectionService) Get(ctx context.Context, connectionID string, query ConnectionGetParams, opts ...option.RequestOption) (res *Connection, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("zones/%s/page_shield/connections/%s", query.ZoneID, connectionID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } -type PageShieldConnection struct { - ID string `json:"id"` - AddedAt string `json:"added_at"` - DomainReportedMalicious bool `json:"domain_reported_malicious"` - FirstPageURL string `json:"first_page_url"` - FirstSeenAt string `json:"first_seen_at"` - Host string `json:"host"` - LastSeenAt string `json:"last_seen_at"` - PageURLs []string `json:"page_urls"` - URL string `json:"url"` - URLContainsCdnCgiPath bool `json:"url_contains_cdn_cgi_path"` - JSON pageShieldConnectionJSON `json:"-"` +type Connection struct { + ID string `json:"id"` + AddedAt string `json:"added_at"` + DomainReportedMalicious bool `json:"domain_reported_malicious"` + FirstPageURL string `json:"first_page_url"` + FirstSeenAt string `json:"first_seen_at"` + Host string `json:"host"` + LastSeenAt string `json:"last_seen_at"` + PageURLs []string `json:"page_urls"` + URL string `json:"url"` + URLContainsCdnCgiPath bool `json:"url_contains_cdn_cgi_path"` + JSON connectionJSON `json:"-"` } -// pageShieldConnectionJSON contains the JSON metadata for the struct -// [PageShieldConnection] -type pageShieldConnectionJSON struct { +// connectionJSON contains the JSON metadata for the struct [Connection] +type connectionJSON struct { ID apijson.Field AddedAt apijson.Field DomainReportedMalicious apijson.Field @@ -95,11 +94,11 @@ type pageShieldConnectionJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageShieldConnection) UnmarshalJSON(data []byte) (err error) { +func (r *Connection) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageShieldConnectionJSON) RawJSON() string { +func (r connectionJSON) RawJSON() string { return r.raw } @@ -157,7 +156,7 @@ type ConnectionListParams struct { // URLQuery serializes [ConnectionListParams]'s query parameters as `url.Values`. func (r ConnectionListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/page_shield/pageshield.go b/page_shield/pageshield.go index fe71b4f3707..8d66f7775a1 100644 --- a/page_shield/pageshield.go +++ b/page_shield/pageshield.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -50,7 +51,7 @@ func (r *PageShieldService) Update(ctx context.Context, params PageShieldUpdateP } // Fetches the Page Shield settings. -func (r *PageShieldService) Get(ctx context.Context, query PageShieldGetParams, opts ...option.RequestOption) (res *PageShieldSetting, err error) { +func (r *PageShieldService) Get(ctx context.Context, query PageShieldGetParams, opts ...option.RequestOption) (res *Setting, err error) { opts = append(r.Options[:], opts...) var env PageShieldGetResponseEnvelope path := fmt.Sprintf("zones/%s/page_shield", query.ZoneID) @@ -62,7 +63,7 @@ func (r *PageShieldService) Get(ctx context.Context, query PageShieldGetParams, return } -type PageShieldSetting struct { +type Setting struct { // When true, indicates that Page Shield is enabled. Enabled bool `json:"enabled"` // The timestamp of when Page Shield was last updated. @@ -71,13 +72,12 @@ type PageShieldSetting struct { // https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report UseCloudflareReportingEndpoint bool `json:"use_cloudflare_reporting_endpoint"` // When true, the paths associated with connections URLs will also be analyzed. - UseConnectionURLPath bool `json:"use_connection_url_path"` - JSON pageShieldSettingJSON `json:"-"` + UseConnectionURLPath bool `json:"use_connection_url_path"` + JSON settingJSON `json:"-"` } -// pageShieldSettingJSON contains the JSON metadata for the struct -// [PageShieldSetting] -type pageShieldSettingJSON struct { +// settingJSON contains the JSON metadata for the struct [Setting] +type settingJSON struct { Enabled apijson.Field UpdatedAt apijson.Field UseCloudflareReportingEndpoint apijson.Field @@ -86,11 +86,11 @@ type pageShieldSettingJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageShieldSetting) UnmarshalJSON(data []byte) (err error) { +func (r *Setting) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageShieldSettingJSON) RawJSON() string { +func (r settingJSON) RawJSON() string { return r.raw } @@ -143,9 +143,9 @@ func (r PageShieldUpdateParams) MarshalJSON() (data []byte, err error) { } type PageShieldUpdateResponseEnvelope struct { - Errors []PageShieldUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []PageShieldUpdateResponseEnvelopeMessages `json:"messages,required"` - Result PageShieldUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PageShieldUpdateResponse `json:"result,required"` // Whether the API call was successful Success PageShieldUpdateResponseEnvelopeSuccess `json:"success,required"` JSON pageShieldUpdateResponseEnvelopeJSON `json:"-"` @@ -170,52 +170,6 @@ func (r pageShieldUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageShieldUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageShieldUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageShieldUpdateResponseEnvelopeErrors] -type pageShieldUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageShieldUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageShieldUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageShieldUpdateResponseEnvelopeMessages] -type pageShieldUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageShieldUpdateResponseEnvelopeSuccess bool @@ -237,9 +191,9 @@ type PageShieldGetParams struct { } type PageShieldGetResponseEnvelope struct { - Errors []PageShieldGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PageShieldGetResponseEnvelopeMessages `json:"messages,required"` - Result PageShieldSetting `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Setting `json:"result,required"` // Whether the API call was successful Success PageShieldGetResponseEnvelopeSuccess `json:"success,required"` JSON pageShieldGetResponseEnvelopeJSON `json:"-"` @@ -264,52 +218,6 @@ func (r pageShieldGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageShieldGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageShieldGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageShieldGetResponseEnvelopeErrors] -type pageShieldGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageShieldGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageShieldGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageShieldGetResponseEnvelopeMessages] -type pageShieldGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageShieldGetResponseEnvelopeSuccess bool diff --git a/page_shield/policy.go b/page_shield/policy.go index aeada3b367d..558860a922d 100644 --- a/page_shield/policy.go +++ b/page_shield/policy.go @@ -32,7 +32,7 @@ func NewPolicyService(opts ...option.RequestOption) (r *PolicyService) { } // Create a Page Shield policy. -func (r *PolicyService) New(ctx context.Context, params PolicyNewParams, opts ...option.RequestOption) (res *PageShieldPolicy, err error) { +func (r *PolicyService) New(ctx context.Context, params PolicyNewParams, opts ...option.RequestOption) (res *Policy, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("zones/%s/page_shield/policies", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) @@ -40,7 +40,7 @@ func (r *PolicyService) New(ctx context.Context, params PolicyNewParams, opts .. } // Update a Page Shield policy by ID. -func (r *PolicyService) Update(ctx context.Context, policyID string, params PolicyUpdateParams, opts ...option.RequestOption) (res *PageShieldPolicy, err error) { +func (r *PolicyService) Update(ctx context.Context, policyID string, params PolicyUpdateParams, opts ...option.RequestOption) (res *Policy, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("zones/%s/page_shield/policies/%s", params.ZoneID, policyID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) @@ -48,7 +48,7 @@ func (r *PolicyService) Update(ctx context.Context, policyID string, params Poli } // Lists all Page Shield policies. -func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[PageShieldPolicy], err error) { +func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Policy], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -66,7 +66,7 @@ func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts . } // Lists all Page Shield policies. -func (r *PolicyService) ListAutoPaging(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[PageShieldPolicy] { +func (r *PolicyService) ListAutoPaging(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Policy] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -80,18 +80,18 @@ func (r *PolicyService) Delete(ctx context.Context, policyID string, body Policy } // Fetches a Page Shield policy by ID. -func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGetParams, opts ...option.RequestOption) (res *PageShieldPolicy, err error) { +func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGetParams, opts ...option.RequestOption) (res *Policy, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("zones/%s/page_shield/policies/%s", query.ZoneID, policyID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) return } -type PageShieldPolicy struct { +type Policy struct { // The ID of the policy ID string `json:"id"` // The action to take if the expression matches - Action PageShieldPolicyAction `json:"action"` + Action PolicyAction `json:"action"` // A description for the policy Description string `json:"description"` // Whether the policy is enabled @@ -100,13 +100,12 @@ type PageShieldPolicy struct { // Cloudflare Firewall rule expression syntax Expression string `json:"expression"` // The policy which will be applied - Value string `json:"value"` - JSON pageShieldPolicyJSON `json:"-"` + Value string `json:"value"` + JSON policyJSON `json:"-"` } -// pageShieldPolicyJSON contains the JSON metadata for the struct -// [PageShieldPolicy] -type pageShieldPolicyJSON struct { +// policyJSON contains the JSON metadata for the struct [Policy] +type policyJSON struct { ID apijson.Field Action apijson.Field Description apijson.Field @@ -117,30 +116,50 @@ type pageShieldPolicyJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageShieldPolicy) UnmarshalJSON(data []byte) (err error) { +func (r *Policy) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageShieldPolicyJSON) RawJSON() string { +func (r policyJSON) RawJSON() string { return r.raw } // The action to take if the expression matches -type PageShieldPolicyAction string +type PolicyAction string const ( - PageShieldPolicyActionAllow PageShieldPolicyAction = "allow" - PageShieldPolicyActionLog PageShieldPolicyAction = "log" + PolicyActionAllow PolicyAction = "allow" + PolicyActionLog PolicyAction = "log" ) -func (r PageShieldPolicyAction) IsKnown() bool { +func (r PolicyAction) IsKnown() bool { switch r { - case PageShieldPolicyActionAllow, PageShieldPolicyActionLog: + case PolicyActionAllow, PolicyActionLog: return true } return false } +type PolicyParam struct { + // The ID of the policy + ID param.Field[string] `json:"id"` + // The action to take if the expression matches + Action param.Field[PolicyAction] `json:"action"` + // A description for the policy + Description param.Field[string] `json:"description"` + // Whether the policy is enabled + Enabled param.Field[bool] `json:"enabled"` + // The expression which must match for the policy to be applied, using the + // Cloudflare Firewall rule expression syntax + Expression param.Field[string] `json:"expression"` + // The policy which will be applied + Value param.Field[string] `json:"value"` +} + +func (r PolicyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type PolicyNewParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` diff --git a/page_shield/script.go b/page_shield/script.go index fe45c3576f3..7c6e1d4d7c4 100644 --- a/page_shield/script.go +++ b/page_shield/script.go @@ -34,7 +34,7 @@ func NewScriptService(opts ...option.RequestOption) (r *ScriptService) { } // Lists all scripts detected by Page Shield. -func (r *ScriptService) List(ctx context.Context, params ScriptListParams, opts ...option.RequestOption) (res *pagination.SinglePage[PageShieldScript], err error) { +func (r *ScriptService) List(ctx context.Context, params ScriptListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Script], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -52,7 +52,7 @@ func (r *ScriptService) List(ctx context.Context, params ScriptListParams, opts } // Lists all scripts detected by Page Shield. -func (r *ScriptService) ListAutoPaging(ctx context.Context, params ScriptListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[PageShieldScript] { +func (r *ScriptService) ListAutoPaging(ctx context.Context, params ScriptListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Script] { return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...)) } @@ -64,28 +64,27 @@ func (r *ScriptService) Get(ctx context.Context, scriptID string, query ScriptGe return } -type PageShieldScript struct { - ID string `json:"id"` - AddedAt string `json:"added_at"` - DataflowScore float64 `json:"dataflow_score"` - DomainReportedMalicious bool `json:"domain_reported_malicious"` - FetchedAt string `json:"fetched_at"` - FirstPageURL string `json:"first_page_url"` - FirstSeenAt string `json:"first_seen_at"` - Hash string `json:"hash"` - Host string `json:"host"` - JsIntegrityScore float64 `json:"js_integrity_score"` - LastSeenAt string `json:"last_seen_at"` - ObfuscationScore float64 `json:"obfuscation_score"` - PageURLs []string `json:"page_urls"` - URL string `json:"url"` - URLContainsCdnCgiPath bool `json:"url_contains_cdn_cgi_path"` - JSON pageShieldScriptJSON `json:"-"` +type Script struct { + ID string `json:"id"` + AddedAt string `json:"added_at"` + DataflowScore float64 `json:"dataflow_score"` + DomainReportedMalicious bool `json:"domain_reported_malicious"` + FetchedAt string `json:"fetched_at"` + FirstPageURL string `json:"first_page_url"` + FirstSeenAt string `json:"first_seen_at"` + Hash string `json:"hash"` + Host string `json:"host"` + JSIntegrityScore float64 `json:"js_integrity_score"` + LastSeenAt string `json:"last_seen_at"` + ObfuscationScore float64 `json:"obfuscation_score"` + PageURLs []string `json:"page_urls"` + URL string `json:"url"` + URLContainsCdnCgiPath bool `json:"url_contains_cdn_cgi_path"` + JSON scriptJSON `json:"-"` } -// pageShieldScriptJSON contains the JSON metadata for the struct -// [PageShieldScript] -type pageShieldScriptJSON struct { +// scriptJSON contains the JSON metadata for the struct [Script] +type scriptJSON struct { ID apijson.Field AddedAt apijson.Field DataflowScore apijson.Field @@ -95,7 +94,7 @@ type pageShieldScriptJSON struct { FirstSeenAt apijson.Field Hash apijson.Field Host apijson.Field - JsIntegrityScore apijson.Field + JSIntegrityScore apijson.Field LastSeenAt apijson.Field ObfuscationScore apijson.Field PageURLs apijson.Field @@ -105,11 +104,11 @@ type pageShieldScriptJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageShieldScript) UnmarshalJSON(data []byte) (err error) { +func (r *Script) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageShieldScriptJSON) RawJSON() string { +func (r scriptJSON) RawJSON() string { return r.raw } @@ -123,7 +122,7 @@ type ScriptGetResponse struct { FirstSeenAt string `json:"first_seen_at"` Hash string `json:"hash"` Host string `json:"host"` - JsIntegrityScore float64 `json:"js_integrity_score"` + JSIntegrityScore float64 `json:"js_integrity_score"` LastSeenAt string `json:"last_seen_at"` ObfuscationScore float64 `json:"obfuscation_score"` PageURLs []string `json:"page_urls"` @@ -145,7 +144,7 @@ type scriptGetResponseJSON struct { FirstSeenAt apijson.Field Hash apijson.Field Host apijson.Field - JsIntegrityScore apijson.Field + JSIntegrityScore apijson.Field LastSeenAt apijson.Field ObfuscationScore apijson.Field PageURLs apijson.Field @@ -173,7 +172,7 @@ type ScriptGetResponseVersion struct { // The computed hash of the analyzed script. Hash string `json:"hash,nullable"` // The integrity score of the JavaScript content. - JsIntegrityScore int64 `json:"js_integrity_score,nullable"` + JSIntegrityScore int64 `json:"js_integrity_score,nullable"` // The obfuscation score of the JavaScript content. ObfuscationScore int64 `json:"obfuscation_score,nullable"` JSON scriptGetResponseVersionJSON `json:"-"` @@ -185,7 +184,7 @@ type scriptGetResponseVersionJSON struct { DataflowScore apijson.Field FetchedAt apijson.Field Hash apijson.Field - JsIntegrityScore apijson.Field + JSIntegrityScore apijson.Field ObfuscationScore apijson.Field raw string ExtraFields map[string]apijson.Field @@ -258,7 +257,7 @@ type ScriptListParams struct { // URLQuery serializes [ScriptListParams]'s query parameters as `url.Values`. func (r ScriptListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/pagerules/aliases.go b/pagerules/aliases.go index ad404f8ac60..ba19b37d0c3 100644 --- a/pagerules/aliases.go +++ b/pagerules/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/pagerules/pagerule.go b/pagerules/pagerule.go index 65acebc17cd..552195ead40 100644 --- a/pagerules/pagerule.go +++ b/pagerules/pagerule.go @@ -39,7 +39,7 @@ func NewPageruleService(opts ...option.RequestOption) (r *PageruleService) { } // Creates a new Page Rule. -func (r *PageruleService) New(ctx context.Context, params PageruleNewParams, opts ...option.RequestOption) (res *PageruleNewResponse, err error) { +func (r *PageruleService) New(ctx context.Context, params PageruleNewParams, opts ...option.RequestOption) (res *PageruleNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PageruleNewResponseEnvelope path := fmt.Sprintf("zones/%s/pagerules", params.ZoneID) @@ -53,7 +53,7 @@ func (r *PageruleService) New(ctx context.Context, params PageruleNewParams, opt // Replaces the configuration of an existing Page Rule. The configuration of the // updated Page Rule will exactly match the data passed in the API request. -func (r *PageruleService) Update(ctx context.Context, pageruleID string, params PageruleUpdateParams, opts ...option.RequestOption) (res *PageruleUpdateResponse, err error) { +func (r *PageruleService) Update(ctx context.Context, pageruleID string, params PageruleUpdateParams, opts ...option.RequestOption) (res *PageruleUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PageruleUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/pagerules/%s", params.ZoneID, pageruleID) @@ -66,7 +66,7 @@ func (r *PageruleService) Update(ctx context.Context, pageruleID string, params } // Fetches Page Rules in a zone. -func (r *PageruleService) List(ctx context.Context, params PageruleListParams, opts ...option.RequestOption) (res *[]ZonesPagerule, err error) { +func (r *PageruleService) List(ctx context.Context, params PageruleListParams, opts ...option.RequestOption) (res *[]PageRule, err error) { opts = append(r.Options[:], opts...) var env PageruleListResponseEnvelope path := fmt.Sprintf("zones/%s/pagerules", params.ZoneID) @@ -79,10 +79,10 @@ func (r *PageruleService) List(ctx context.Context, params PageruleListParams, o } // Deletes an existing Page Rule. -func (r *PageruleService) Delete(ctx context.Context, pageruleID string, body PageruleDeleteParams, opts ...option.RequestOption) (res *PageruleDeleteResponse, err error) { +func (r *PageruleService) Delete(ctx context.Context, pageruleID string, params PageruleDeleteParams, opts ...option.RequestOption) (res *PageruleDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env PageruleDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/pagerules/%s", body.ZoneID, pageruleID) + path := fmt.Sprintf("zones/%s/pagerules/%s", params.ZoneID, pageruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -92,7 +92,7 @@ func (r *PageruleService) Delete(ctx context.Context, pageruleID string, body Pa } // Updates one or more fields of an existing Page Rule. -func (r *PageruleService) Edit(ctx context.Context, pageruleID string, params PageruleEditParams, opts ...option.RequestOption) (res *PageruleEditResponse, err error) { +func (r *PageruleService) Edit(ctx context.Context, pageruleID string, params PageruleEditParams, opts ...option.RequestOption) (res *PageruleEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PageruleEditResponseEnvelope path := fmt.Sprintf("zones/%s/pagerules/%s", params.ZoneID, pageruleID) @@ -105,7 +105,7 @@ func (r *PageruleService) Edit(ctx context.Context, pageruleID string, params Pa } // Fetches the details of a Page Rule. -func (r *PageruleService) Get(ctx context.Context, pageruleID string, query PageruleGetParams, opts ...option.RequestOption) (res *PageruleGetResponse, err error) { +func (r *PageruleService) Get(ctx context.Context, pageruleID string, query PageruleGetParams, opts ...option.RequestOption) (res *PageruleGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env PageruleGetResponseEnvelope path := fmt.Sprintf("zones/%s/pagerules/%s", query.ZoneID, pageruleID) @@ -117,12 +117,12 @@ func (r *PageruleService) Get(ctx context.Context, pageruleID string, query Page return } -type ZonesPagerule struct { +type PageRule struct { // Identifier ID string `json:"id,required"` // The set of actions to perform if the targets of this rule match the request. // Actions can redirect to another URL or override settings, but not both. - Actions []ZonesPageruleAction `json:"actions,required"` + Actions []Route `json:"actions,required"` // The timestamp of when the Page Rule was created. CreatedOn time.Time `json:"created_on,required" format:"date-time"` // The timestamp of when the Page Rule was last modified. @@ -134,14 +134,14 @@ type ZonesPagerule struct { // rule B so it overrides rule A. Priority int64 `json:"priority,required"` // The status of the Page Rule. - Status ZonesPageruleStatus `json:"status,required"` + Status PageRuleStatus `json:"status,required"` // The rule targets to evaluate on each request. - Targets []ZonesPageruleTarget `json:"targets,required"` - JSON zonesPageruleJSON `json:"-"` + Targets []Target `json:"targets,required"` + JSON pageRuleJSON `json:"-"` } -// zonesPageruleJSON contains the JSON metadata for the struct [ZonesPagerule] -type zonesPageruleJSON struct { +// pageRuleJSON contains the JSON metadata for the struct [PageRule] +type pageRuleJSON struct { ID apijson.Field Actions apijson.Field CreatedOn apijson.Field @@ -153,26 +153,41 @@ type zonesPageruleJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZonesPagerule) UnmarshalJSON(data []byte) (err error) { +func (r *PageRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zonesPageruleJSON) RawJSON() string { +func (r pageRuleJSON) RawJSON() string { return r.raw } -type ZonesPageruleAction struct { +// The status of the Page Rule. +type PageRuleStatus string + +const ( + PageRuleStatusActive PageRuleStatus = "active" + PageRuleStatusDisabled PageRuleStatus = "disabled" +) + +func (r PageRuleStatus) IsKnown() bool { + switch r { + case PageRuleStatusActive, PageRuleStatusDisabled: + return true + } + return false +} + +type Route struct { // The timestamp of when the override was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // The type of route. - Name ZonesPageruleActionsName `json:"name"` - Value ZonesPageruleActionsValue `json:"value"` - JSON zonesPageruleActionJSON `json:"-"` + Name RouteName `json:"name"` + Value RouteValue `json:"value"` + JSON routeJSON `json:"-"` } -// zonesPageruleActionJSON contains the JSON metadata for the struct -// [ZonesPageruleAction] -type zonesPageruleActionJSON struct { +// routeJSON contains the JSON metadata for the struct [Route] +type routeJSON struct { ModifiedOn apijson.Field Name apijson.Field Value apijson.Field @@ -180,183 +195,212 @@ type zonesPageruleActionJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZonesPageruleAction) UnmarshalJSON(data []byte) (err error) { +func (r *Route) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zonesPageruleActionJSON) RawJSON() string { +func (r routeJSON) RawJSON() string { return r.raw } // The type of route. -type ZonesPageruleActionsName string +type RouteName string const ( - ZonesPageruleActionsNameForwardURL ZonesPageruleActionsName = "forward_url" + RouteNameForwardURL RouteName = "forward_url" ) -func (r ZonesPageruleActionsName) IsKnown() bool { +func (r RouteName) IsKnown() bool { switch r { - case ZonesPageruleActionsNameForwardURL: + case RouteNameForwardURL: return true } return false } -type ZonesPageruleActionsValue struct { +type RouteValue struct { // The response type for the URL redirect. - Type ZonesPageruleActionsValueType `json:"type"` + Type RouteValueType `json:"type"` // The URL to redirect the request to. Notes: ${num} refers to the position of '\*' // in the constraint value. - URL string `json:"url"` - JSON zonesPageruleActionsValueJSON `json:"-"` + URL string `json:"url"` + JSON routeValueJSON `json:"-"` } -// zonesPageruleActionsValueJSON contains the JSON metadata for the struct -// [ZonesPageruleActionsValue] -type zonesPageruleActionsValueJSON struct { +// routeValueJSON contains the JSON metadata for the struct [RouteValue] +type routeValueJSON struct { Type apijson.Field URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZonesPageruleActionsValue) UnmarshalJSON(data []byte) (err error) { +func (r *RouteValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zonesPageruleActionsValueJSON) RawJSON() string { +func (r routeValueJSON) RawJSON() string { return r.raw } // The response type for the URL redirect. -type ZonesPageruleActionsValueType string +type RouteValueType string const ( - ZonesPageruleActionsValueTypeTemporary ZonesPageruleActionsValueType = "temporary" - ZonesPageruleActionsValueTypePermanent ZonesPageruleActionsValueType = "permanent" + RouteValueTypeTemporary RouteValueType = "temporary" + RouteValueTypePermanent RouteValueType = "permanent" ) -func (r ZonesPageruleActionsValueType) IsKnown() bool { +func (r RouteValueType) IsKnown() bool { switch r { - case ZonesPageruleActionsValueTypeTemporary, ZonesPageruleActionsValueTypePermanent: + case RouteValueTypeTemporary, RouteValueTypePermanent: return true } return false } -// The status of the Page Rule. -type ZonesPageruleStatus string +type RouteParam struct { + // The type of route. + Name param.Field[RouteName] `json:"name"` + Value param.Field[RouteValueParam] `json:"value"` +} -const ( - ZonesPageruleStatusActive ZonesPageruleStatus = "active" - ZonesPageruleStatusDisabled ZonesPageruleStatus = "disabled" -) +func (r RouteParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} -func (r ZonesPageruleStatus) IsKnown() bool { - switch r { - case ZonesPageruleStatusActive, ZonesPageruleStatusDisabled: - return true - } - return false +type RouteValueParam struct { + // The response type for the URL redirect. + Type param.Field[RouteValueType] `json:"type"` + // The URL to redirect the request to. Notes: ${num} refers to the position of '\*' + // in the constraint value. + URL param.Field[string] `json:"url"` +} + +func (r RouteValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // A request condition target. -type ZonesPageruleTarget struct { +type Target struct { // String constraint. - Constraint ZonesPageruleTargetsConstraint `json:"constraint,required"` + Constraint TargetConstraint `json:"constraint,required"` // A target based on the URL of the request. - Target ZonesPageruleTargetsTarget `json:"target,required"` - JSON zonesPageruleTargetJSON `json:"-"` + Target TargetTarget `json:"target,required"` + JSON targetJSON `json:"-"` } -// zonesPageruleTargetJSON contains the JSON metadata for the struct -// [ZonesPageruleTarget] -type zonesPageruleTargetJSON struct { +// targetJSON contains the JSON metadata for the struct [Target] +type targetJSON struct { Constraint apijson.Field Target apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZonesPageruleTarget) UnmarshalJSON(data []byte) (err error) { +func (r *Target) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zonesPageruleTargetJSON) RawJSON() string { +func (r targetJSON) RawJSON() string { return r.raw } // String constraint. -type ZonesPageruleTargetsConstraint struct { +type TargetConstraint struct { // The matches operator can use asterisks and pipes as wildcard and 'or' operators. - Operator ZonesPageruleTargetsConstraintOperator `json:"operator,required"` + Operator TargetConstraintOperator `json:"operator,required"` // The URL pattern to match against the current request. The pattern may contain up // to four asterisks ('\*') as placeholders. - Value string `json:"value,required"` - JSON zonesPageruleTargetsConstraintJSON `json:"-"` + Value string `json:"value,required"` + JSON targetConstraintJSON `json:"-"` } -// zonesPageruleTargetsConstraintJSON contains the JSON metadata for the struct -// [ZonesPageruleTargetsConstraint] -type zonesPageruleTargetsConstraintJSON struct { +// targetConstraintJSON contains the JSON metadata for the struct +// [TargetConstraint] +type targetConstraintJSON struct { Operator apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZonesPageruleTargetsConstraint) UnmarshalJSON(data []byte) (err error) { +func (r *TargetConstraint) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zonesPageruleTargetsConstraintJSON) RawJSON() string { +func (r targetConstraintJSON) RawJSON() string { return r.raw } // The matches operator can use asterisks and pipes as wildcard and 'or' operators. -type ZonesPageruleTargetsConstraintOperator string +type TargetConstraintOperator string const ( - ZonesPageruleTargetsConstraintOperatorMatches ZonesPageruleTargetsConstraintOperator = "matches" - ZonesPageruleTargetsConstraintOperatorContains ZonesPageruleTargetsConstraintOperator = "contains" - ZonesPageruleTargetsConstraintOperatorEquals ZonesPageruleTargetsConstraintOperator = "equals" - ZonesPageruleTargetsConstraintOperatorNotEqual ZonesPageruleTargetsConstraintOperator = "not_equal" - ZonesPageruleTargetsConstraintOperatorNotContain ZonesPageruleTargetsConstraintOperator = "not_contain" + TargetConstraintOperatorMatches TargetConstraintOperator = "matches" + TargetConstraintOperatorContains TargetConstraintOperator = "contains" + TargetConstraintOperatorEquals TargetConstraintOperator = "equals" + TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal" + TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain" ) -func (r ZonesPageruleTargetsConstraintOperator) IsKnown() bool { +func (r TargetConstraintOperator) IsKnown() bool { switch r { - case ZonesPageruleTargetsConstraintOperatorMatches, ZonesPageruleTargetsConstraintOperatorContains, ZonesPageruleTargetsConstraintOperatorEquals, ZonesPageruleTargetsConstraintOperatorNotEqual, ZonesPageruleTargetsConstraintOperatorNotContain: + case TargetConstraintOperatorMatches, TargetConstraintOperatorContains, TargetConstraintOperatorEquals, TargetConstraintOperatorNotEqual, TargetConstraintOperatorNotContain: return true } return false } // A target based on the URL of the request. -type ZonesPageruleTargetsTarget string +type TargetTarget string const ( - ZonesPageruleTargetsTargetURL ZonesPageruleTargetsTarget = "url" + TargetTargetURL TargetTarget = "url" ) -func (r ZonesPageruleTargetsTarget) IsKnown() bool { +func (r TargetTarget) IsKnown() bool { switch r { - case ZonesPageruleTargetsTargetURL: + case TargetTargetURL: return true } return false } +// A request condition target. +type TargetParam struct { + // String constraint. + Constraint param.Field[TargetConstraintParam] `json:"constraint,required"` + // A target based on the URL of the request. + Target param.Field[TargetTarget] `json:"target,required"` +} + +func (r TargetParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// String constraint. +type TargetConstraintParam struct { + // The matches operator can use asterisks and pipes as wildcard and 'or' operators. + Operator param.Field[TargetConstraintOperator] `json:"operator,required"` + // The URL pattern to match against the current request. The pattern may contain up + // to four asterisks ('\*') as placeholders. + Value param.Field[string] `json:"value,required"` +} + +func (r TargetConstraintParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Union satisfied by [pagerules.PageruleNewResponseUnknown] or // [shared.UnionString]. -type PageruleNewResponse interface { - ImplementsPagerulesPageruleNewResponse() +type PageruleNewResponseUnion interface { + ImplementsPagerulesPageruleNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PageruleNewResponse)(nil)).Elem(), + reflect.TypeOf((*PageruleNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -367,13 +411,13 @@ func init() { // Union satisfied by [pagerules.PageruleUpdateResponseUnknown] or // [shared.UnionString]. -type PageruleUpdateResponse interface { - ImplementsPagerulesPageruleUpdateResponse() +type PageruleUpdateResponseUnion interface { + ImplementsPagerulesPageruleUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PageruleUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*PageruleUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -406,13 +450,13 @@ func (r pageruleDeleteResponseJSON) RawJSON() string { // Union satisfied by [pagerules.PageruleEditResponseUnknown] or // [shared.UnionString]. -type PageruleEditResponse interface { - ImplementsPagerulesPageruleEditResponse() +type PageruleEditResponseUnion interface { + ImplementsPagerulesPageruleEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PageruleEditResponse)(nil)).Elem(), + reflect.TypeOf((*PageruleEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -423,13 +467,13 @@ func init() { // Union satisfied by [pagerules.PageruleGetResponseUnknown] or // [shared.UnionString]. -type PageruleGetResponse interface { - ImplementsPagerulesPageruleGetResponse() +type PageruleGetResponseUnion interface { + ImplementsPagerulesPageruleGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*PageruleGetResponse)(nil)).Elem(), + reflect.TypeOf((*PageruleGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -443,9 +487,9 @@ type PageruleNewParams struct { ZoneID param.Field[string] `path:"zone_id,required"` // The set of actions to perform if the targets of this rule match the request. // Actions can redirect to another URL or override settings, but not both. - Actions param.Field[[]PageruleNewParamsAction] `json:"actions,required"` + Actions param.Field[[]RouteParam] `json:"actions,required"` // The rule targets to evaluate on each request. - Targets param.Field[[]PageruleNewParamsTarget] `json:"targets,required"` + Targets param.Field[[]TargetParam] `json:"targets,required"` // The priority of the rule, used to define which Page Rule is processed over // another. A higher number indicates a higher priority. For example, if you have a // catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to @@ -460,118 +504,6 @@ func (r PageruleNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PageruleNewParamsAction struct { - // The type of route. - Name param.Field[PageruleNewParamsActionsName] `json:"name"` - Value param.Field[PageruleNewParamsActionsValue] `json:"value"` -} - -func (r PageruleNewParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of route. -type PageruleNewParamsActionsName string - -const ( - PageruleNewParamsActionsNameForwardURL PageruleNewParamsActionsName = "forward_url" -) - -func (r PageruleNewParamsActionsName) IsKnown() bool { - switch r { - case PageruleNewParamsActionsNameForwardURL: - return true - } - return false -} - -type PageruleNewParamsActionsValue struct { - // The response type for the URL redirect. - Type param.Field[PageruleNewParamsActionsValueType] `json:"type"` - // The URL to redirect the request to. Notes: ${num} refers to the position of '\*' - // in the constraint value. - URL param.Field[string] `json:"url"` -} - -func (r PageruleNewParamsActionsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response type for the URL redirect. -type PageruleNewParamsActionsValueType string - -const ( - PageruleNewParamsActionsValueTypeTemporary PageruleNewParamsActionsValueType = "temporary" - PageruleNewParamsActionsValueTypePermanent PageruleNewParamsActionsValueType = "permanent" -) - -func (r PageruleNewParamsActionsValueType) IsKnown() bool { - switch r { - case PageruleNewParamsActionsValueTypeTemporary, PageruleNewParamsActionsValueTypePermanent: - return true - } - return false -} - -// A request condition target. -type PageruleNewParamsTarget struct { - // String constraint. - Constraint param.Field[PageruleNewParamsTargetsConstraint] `json:"constraint,required"` - // A target based on the URL of the request. - Target param.Field[PageruleNewParamsTargetsTarget] `json:"target,required"` -} - -func (r PageruleNewParamsTarget) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// String constraint. -type PageruleNewParamsTargetsConstraint struct { - // The matches operator can use asterisks and pipes as wildcard and 'or' operators. - Operator param.Field[PageruleNewParamsTargetsConstraintOperator] `json:"operator,required"` - // The URL pattern to match against the current request. The pattern may contain up - // to four asterisks ('\*') as placeholders. - Value param.Field[string] `json:"value,required"` -} - -func (r PageruleNewParamsTargetsConstraint) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The matches operator can use asterisks and pipes as wildcard and 'or' operators. -type PageruleNewParamsTargetsConstraintOperator string - -const ( - PageruleNewParamsTargetsConstraintOperatorMatches PageruleNewParamsTargetsConstraintOperator = "matches" - PageruleNewParamsTargetsConstraintOperatorContains PageruleNewParamsTargetsConstraintOperator = "contains" - PageruleNewParamsTargetsConstraintOperatorEquals PageruleNewParamsTargetsConstraintOperator = "equals" - PageruleNewParamsTargetsConstraintOperatorNotEqual PageruleNewParamsTargetsConstraintOperator = "not_equal" - PageruleNewParamsTargetsConstraintOperatorNotContain PageruleNewParamsTargetsConstraintOperator = "not_contain" -) - -func (r PageruleNewParamsTargetsConstraintOperator) IsKnown() bool { - switch r { - case PageruleNewParamsTargetsConstraintOperatorMatches, PageruleNewParamsTargetsConstraintOperatorContains, PageruleNewParamsTargetsConstraintOperatorEquals, PageruleNewParamsTargetsConstraintOperatorNotEqual, PageruleNewParamsTargetsConstraintOperatorNotContain: - return true - } - return false -} - -// A target based on the URL of the request. -type PageruleNewParamsTargetsTarget string - -const ( - PageruleNewParamsTargetsTargetURL PageruleNewParamsTargetsTarget = "url" -) - -func (r PageruleNewParamsTargetsTarget) IsKnown() bool { - switch r { - case PageruleNewParamsTargetsTargetURL: - return true - } - return false -} - // The status of the Page Rule. type PageruleNewParamsStatus string @@ -589,9 +521,9 @@ func (r PageruleNewParamsStatus) IsKnown() bool { } type PageruleNewResponseEnvelope struct { - Errors []PageruleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PageruleNewResponseEnvelopeMessages `json:"messages,required"` - Result PageruleNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PageruleNewResponseUnion `json:"result,required"` // Whether the API call was successful Success PageruleNewResponseEnvelopeSuccess `json:"success,required"` JSON pageruleNewResponseEnvelopeJSON `json:"-"` @@ -616,52 +548,6 @@ func (r pageruleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageruleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PageruleNewResponseEnvelopeErrors] -type pageruleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageruleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageruleNewResponseEnvelopeMessages] -type pageruleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageruleNewResponseEnvelopeSuccess bool @@ -682,9 +568,9 @@ type PageruleUpdateParams struct { ZoneID param.Field[string] `path:"zone_id,required"` // The set of actions to perform if the targets of this rule match the request. // Actions can redirect to another URL or override settings, but not both. - Actions param.Field[[]PageruleUpdateParamsAction] `json:"actions,required"` + Actions param.Field[[]RouteParam] `json:"actions,required"` // The rule targets to evaluate on each request. - Targets param.Field[[]PageruleUpdateParamsTarget] `json:"targets,required"` + Targets param.Field[[]TargetParam] `json:"targets,required"` // The priority of the rule, used to define which Page Rule is processed over // another. A higher number indicates a higher priority. For example, if you have a // catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to @@ -699,118 +585,6 @@ func (r PageruleUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PageruleUpdateParamsAction struct { - // The type of route. - Name param.Field[PageruleUpdateParamsActionsName] `json:"name"` - Value param.Field[PageruleUpdateParamsActionsValue] `json:"value"` -} - -func (r PageruleUpdateParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of route. -type PageruleUpdateParamsActionsName string - -const ( - PageruleUpdateParamsActionsNameForwardURL PageruleUpdateParamsActionsName = "forward_url" -) - -func (r PageruleUpdateParamsActionsName) IsKnown() bool { - switch r { - case PageruleUpdateParamsActionsNameForwardURL: - return true - } - return false -} - -type PageruleUpdateParamsActionsValue struct { - // The response type for the URL redirect. - Type param.Field[PageruleUpdateParamsActionsValueType] `json:"type"` - // The URL to redirect the request to. Notes: ${num} refers to the position of '\*' - // in the constraint value. - URL param.Field[string] `json:"url"` -} - -func (r PageruleUpdateParamsActionsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response type for the URL redirect. -type PageruleUpdateParamsActionsValueType string - -const ( - PageruleUpdateParamsActionsValueTypeTemporary PageruleUpdateParamsActionsValueType = "temporary" - PageruleUpdateParamsActionsValueTypePermanent PageruleUpdateParamsActionsValueType = "permanent" -) - -func (r PageruleUpdateParamsActionsValueType) IsKnown() bool { - switch r { - case PageruleUpdateParamsActionsValueTypeTemporary, PageruleUpdateParamsActionsValueTypePermanent: - return true - } - return false -} - -// A request condition target. -type PageruleUpdateParamsTarget struct { - // String constraint. - Constraint param.Field[PageruleUpdateParamsTargetsConstraint] `json:"constraint,required"` - // A target based on the URL of the request. - Target param.Field[PageruleUpdateParamsTargetsTarget] `json:"target,required"` -} - -func (r PageruleUpdateParamsTarget) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// String constraint. -type PageruleUpdateParamsTargetsConstraint struct { - // The matches operator can use asterisks and pipes as wildcard and 'or' operators. - Operator param.Field[PageruleUpdateParamsTargetsConstraintOperator] `json:"operator,required"` - // The URL pattern to match against the current request. The pattern may contain up - // to four asterisks ('\*') as placeholders. - Value param.Field[string] `json:"value,required"` -} - -func (r PageruleUpdateParamsTargetsConstraint) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The matches operator can use asterisks and pipes as wildcard and 'or' operators. -type PageruleUpdateParamsTargetsConstraintOperator string - -const ( - PageruleUpdateParamsTargetsConstraintOperatorMatches PageruleUpdateParamsTargetsConstraintOperator = "matches" - PageruleUpdateParamsTargetsConstraintOperatorContains PageruleUpdateParamsTargetsConstraintOperator = "contains" - PageruleUpdateParamsTargetsConstraintOperatorEquals PageruleUpdateParamsTargetsConstraintOperator = "equals" - PageruleUpdateParamsTargetsConstraintOperatorNotEqual PageruleUpdateParamsTargetsConstraintOperator = "not_equal" - PageruleUpdateParamsTargetsConstraintOperatorNotContain PageruleUpdateParamsTargetsConstraintOperator = "not_contain" -) - -func (r PageruleUpdateParamsTargetsConstraintOperator) IsKnown() bool { - switch r { - case PageruleUpdateParamsTargetsConstraintOperatorMatches, PageruleUpdateParamsTargetsConstraintOperatorContains, PageruleUpdateParamsTargetsConstraintOperatorEquals, PageruleUpdateParamsTargetsConstraintOperatorNotEqual, PageruleUpdateParamsTargetsConstraintOperatorNotContain: - return true - } - return false -} - -// A target based on the URL of the request. -type PageruleUpdateParamsTargetsTarget string - -const ( - PageruleUpdateParamsTargetsTargetURL PageruleUpdateParamsTargetsTarget = "url" -) - -func (r PageruleUpdateParamsTargetsTarget) IsKnown() bool { - switch r { - case PageruleUpdateParamsTargetsTargetURL: - return true - } - return false -} - // The status of the Page Rule. type PageruleUpdateParamsStatus string @@ -828,9 +602,9 @@ func (r PageruleUpdateParamsStatus) IsKnown() bool { } type PageruleUpdateResponseEnvelope struct { - Errors []PageruleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []PageruleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result PageruleUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PageruleUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success PageruleUpdateResponseEnvelopeSuccess `json:"success,required"` JSON pageruleUpdateResponseEnvelopeJSON `json:"-"` @@ -855,52 +629,6 @@ func (r pageruleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageruleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageruleUpdateResponseEnvelopeErrors] -type pageruleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageruleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageruleUpdateResponseEnvelopeMessages] -type pageruleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageruleUpdateResponseEnvelopeSuccess bool @@ -933,7 +661,7 @@ type PageruleListParams struct { // URLQuery serializes [PageruleListParams]'s query parameters as `url.Values`. func (r PageruleListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1004,9 +732,9 @@ func (r PageruleListParamsStatus) IsKnown() bool { } type PageruleListResponseEnvelope struct { - Errors []PageruleListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageruleListResponseEnvelopeMessages `json:"messages,required"` - Result []ZonesPagerule `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []PageRule `json:"result,required"` // Whether the API call was successful Success PageruleListResponseEnvelopeSuccess `json:"success,required"` JSON pageruleListResponseEnvelopeJSON `json:"-"` @@ -1031,52 +759,6 @@ func (r pageruleListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageruleListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageruleListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PageruleListResponseEnvelopeErrors] -type pageruleListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageruleListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageruleListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageruleListResponseEnvelopeMessages] -type pageruleListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageruleListResponseEnvelopeSuccess bool @@ -1095,12 +777,17 @@ func (r PageruleListResponseEnvelopeSuccess) IsKnown() bool { type PageruleDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r PageruleDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type PageruleDeleteResponseEnvelope struct { - Errors []PageruleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PageruleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PageruleDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PageruleDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success PageruleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON pageruleDeleteResponseEnvelopeJSON `json:"-"` @@ -1125,52 +812,6 @@ func (r pageruleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageruleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageruleDeleteResponseEnvelopeErrors] -type pageruleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageruleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageruleDeleteResponseEnvelopeMessages] -type pageruleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageruleDeleteResponseEnvelopeSuccess bool @@ -1191,7 +832,7 @@ type PageruleEditParams struct { ZoneID param.Field[string] `path:"zone_id,required"` // The set of actions to perform if the targets of this rule match the request. // Actions can redirect to another URL or override settings, but not both. - Actions param.Field[[]PageruleEditParamsAction] `json:"actions"` + Actions param.Field[[]RouteParam] `json:"actions"` // The priority of the rule, used to define which Page Rule is processed over // another. A higher number indicates a higher priority. For example, if you have a // catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to @@ -1201,66 +842,13 @@ type PageruleEditParams struct { // The status of the Page Rule. Status param.Field[PageruleEditParamsStatus] `json:"status"` // The rule targets to evaluate on each request. - Targets param.Field[[]PageruleEditParamsTarget] `json:"targets"` + Targets param.Field[[]TargetParam] `json:"targets"` } func (r PageruleEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PageruleEditParamsAction struct { - // The type of route. - Name param.Field[PageruleEditParamsActionsName] `json:"name"` - Value param.Field[PageruleEditParamsActionsValue] `json:"value"` -} - -func (r PageruleEditParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of route. -type PageruleEditParamsActionsName string - -const ( - PageruleEditParamsActionsNameForwardURL PageruleEditParamsActionsName = "forward_url" -) - -func (r PageruleEditParamsActionsName) IsKnown() bool { - switch r { - case PageruleEditParamsActionsNameForwardURL: - return true - } - return false -} - -type PageruleEditParamsActionsValue struct { - // The response type for the URL redirect. - Type param.Field[PageruleEditParamsActionsValueType] `json:"type"` - // The URL to redirect the request to. Notes: ${num} refers to the position of '\*' - // in the constraint value. - URL param.Field[string] `json:"url"` -} - -func (r PageruleEditParamsActionsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response type for the URL redirect. -type PageruleEditParamsActionsValueType string - -const ( - PageruleEditParamsActionsValueTypeTemporary PageruleEditParamsActionsValueType = "temporary" - PageruleEditParamsActionsValueTypePermanent PageruleEditParamsActionsValueType = "permanent" -) - -func (r PageruleEditParamsActionsValueType) IsKnown() bool { - switch r { - case PageruleEditParamsActionsValueTypeTemporary, PageruleEditParamsActionsValueTypePermanent: - return true - } - return false -} - // The status of the Page Rule. type PageruleEditParamsStatus string @@ -1277,69 +865,10 @@ func (r PageruleEditParamsStatus) IsKnown() bool { return false } -// A request condition target. -type PageruleEditParamsTarget struct { - // String constraint. - Constraint param.Field[PageruleEditParamsTargetsConstraint] `json:"constraint,required"` - // A target based on the URL of the request. - Target param.Field[PageruleEditParamsTargetsTarget] `json:"target,required"` -} - -func (r PageruleEditParamsTarget) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// String constraint. -type PageruleEditParamsTargetsConstraint struct { - // The matches operator can use asterisks and pipes as wildcard and 'or' operators. - Operator param.Field[PageruleEditParamsTargetsConstraintOperator] `json:"operator,required"` - // The URL pattern to match against the current request. The pattern may contain up - // to four asterisks ('\*') as placeholders. - Value param.Field[string] `json:"value,required"` -} - -func (r PageruleEditParamsTargetsConstraint) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The matches operator can use asterisks and pipes as wildcard and 'or' operators. -type PageruleEditParamsTargetsConstraintOperator string - -const ( - PageruleEditParamsTargetsConstraintOperatorMatches PageruleEditParamsTargetsConstraintOperator = "matches" - PageruleEditParamsTargetsConstraintOperatorContains PageruleEditParamsTargetsConstraintOperator = "contains" - PageruleEditParamsTargetsConstraintOperatorEquals PageruleEditParamsTargetsConstraintOperator = "equals" - PageruleEditParamsTargetsConstraintOperatorNotEqual PageruleEditParamsTargetsConstraintOperator = "not_equal" - PageruleEditParamsTargetsConstraintOperatorNotContain PageruleEditParamsTargetsConstraintOperator = "not_contain" -) - -func (r PageruleEditParamsTargetsConstraintOperator) IsKnown() bool { - switch r { - case PageruleEditParamsTargetsConstraintOperatorMatches, PageruleEditParamsTargetsConstraintOperatorContains, PageruleEditParamsTargetsConstraintOperatorEquals, PageruleEditParamsTargetsConstraintOperatorNotEqual, PageruleEditParamsTargetsConstraintOperatorNotContain: - return true - } - return false -} - -// A target based on the URL of the request. -type PageruleEditParamsTargetsTarget string - -const ( - PageruleEditParamsTargetsTargetURL PageruleEditParamsTargetsTarget = "url" -) - -func (r PageruleEditParamsTargetsTarget) IsKnown() bool { - switch r { - case PageruleEditParamsTargetsTargetURL: - return true - } - return false -} - type PageruleEditResponseEnvelope struct { - Errors []PageruleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []PageruleEditResponseEnvelopeMessages `json:"messages,required"` - Result PageruleEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PageruleEditResponseUnion `json:"result,required"` // Whether the API call was successful Success PageruleEditResponseEnvelopeSuccess `json:"success,required"` JSON pageruleEditResponseEnvelopeJSON `json:"-"` @@ -1364,52 +893,6 @@ func (r pageruleEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageruleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PageruleEditResponseEnvelopeErrors] -type pageruleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageruleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageruleEditResponseEnvelopeMessages] -type pageruleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageruleEditResponseEnvelopeSuccess bool @@ -1431,9 +914,9 @@ type PageruleGetParams struct { } type PageruleGetResponseEnvelope struct { - Errors []PageruleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PageruleGetResponseEnvelopeMessages `json:"messages,required"` - Result PageruleGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PageruleGetResponseUnion `json:"result,required"` // Whether the API call was successful Success PageruleGetResponseEnvelopeSuccess `json:"success,required"` JSON pageruleGetResponseEnvelopeJSON `json:"-"` @@ -1458,52 +941,6 @@ func (r pageruleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PageruleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageruleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PageruleGetResponseEnvelopeErrors] -type pageruleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageruleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageruleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageruleGetResponseEnvelopeMessages] -type pageruleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PageruleGetResponseEnvelopeSuccess bool diff --git a/pagerules/pagerule_test.go b/pagerules/pagerule_test.go index 1c6daacd59d..6901225ca61 100644 --- a/pagerules/pagerule_test.go +++ b/pagerules/pagerule_test.go @@ -30,19 +30,19 @@ func TestPageruleNewWithOptionalParams(t *testing.T) { ) _, err := client.Pagerules.New(context.TODO(), pagerules.PageruleNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Actions: cloudflare.F([]pagerules.PageruleNewParamsAction{{ - Name: cloudflare.F(pagerules.PageruleNewParamsActionsNameForwardURL), - Value: cloudflare.F(pagerules.PageruleNewParamsActionsValue{ - Type: cloudflare.F(pagerules.PageruleNewParamsActionsValueTypeTemporary), + Actions: cloudflare.F([]pagerules.RouteParam{{ + Name: cloudflare.F(pagerules.RouteNameForwardURL), + Value: cloudflare.F(pagerules.RouteValueParam{ + Type: cloudflare.F(pagerules.RouteValueTypeTemporary), URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), }), }}), - Targets: cloudflare.F([]pagerules.PageruleNewParamsTarget{{ - Constraint: cloudflare.F(pagerules.PageruleNewParamsTargetsConstraint{ - Operator: cloudflare.F(pagerules.PageruleNewParamsTargetsConstraintOperatorMatches), + Targets: cloudflare.F([]pagerules.TargetParam{{ + Constraint: cloudflare.F(pagerules.TargetConstraintParam{ + Operator: cloudflare.F(pagerules.TargetConstraintOperatorMatches), Value: cloudflare.F("*example.com/images/*"), }), - Target: cloudflare.F(pagerules.PageruleNewParamsTargetsTargetURL), + Target: cloudflare.F(pagerules.TargetTargetURL), }}), Priority: cloudflare.F(int64(0)), Status: cloudflare.F(pagerules.PageruleNewParamsStatusActive), @@ -75,19 +75,19 @@ func TestPageruleUpdateWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", pagerules.PageruleUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Actions: cloudflare.F([]pagerules.PageruleUpdateParamsAction{{ - Name: cloudflare.F(pagerules.PageruleUpdateParamsActionsNameForwardURL), - Value: cloudflare.F(pagerules.PageruleUpdateParamsActionsValue{ - Type: cloudflare.F(pagerules.PageruleUpdateParamsActionsValueTypeTemporary), + Actions: cloudflare.F([]pagerules.RouteParam{{ + Name: cloudflare.F(pagerules.RouteNameForwardURL), + Value: cloudflare.F(pagerules.RouteValueParam{ + Type: cloudflare.F(pagerules.RouteValueTypeTemporary), URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), }), }}), - Targets: cloudflare.F([]pagerules.PageruleUpdateParamsTarget{{ - Constraint: cloudflare.F(pagerules.PageruleUpdateParamsTargetsConstraint{ - Operator: cloudflare.F(pagerules.PageruleUpdateParamsTargetsConstraintOperatorMatches), + Targets: cloudflare.F([]pagerules.TargetParam{{ + Constraint: cloudflare.F(pagerules.TargetConstraintParam{ + Operator: cloudflare.F(pagerules.TargetConstraintOperatorMatches), Value: cloudflare.F("*example.com/images/*"), }), - Target: cloudflare.F(pagerules.PageruleUpdateParamsTargetsTargetURL), + Target: cloudflare.F(pagerules.TargetTargetURL), }}), Priority: cloudflare.F(int64(0)), Status: cloudflare.F(pagerules.PageruleUpdateParamsStatusActive), @@ -151,6 +151,7 @@ func TestPageruleDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", pagerules.PageruleDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -181,21 +182,21 @@ func TestPageruleEditWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", pagerules.PageruleEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Actions: cloudflare.F([]pagerules.PageruleEditParamsAction{{ - Name: cloudflare.F(pagerules.PageruleEditParamsActionsNameForwardURL), - Value: cloudflare.F(pagerules.PageruleEditParamsActionsValue{ - Type: cloudflare.F(pagerules.PageruleEditParamsActionsValueTypeTemporary), + Actions: cloudflare.F([]pagerules.RouteParam{{ + Name: cloudflare.F(pagerules.RouteNameForwardURL), + Value: cloudflare.F(pagerules.RouteValueParam{ + Type: cloudflare.F(pagerules.RouteValueTypeTemporary), URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), }), }}), Priority: cloudflare.F(int64(0)), Status: cloudflare.F(pagerules.PageruleEditParamsStatusActive), - Targets: cloudflare.F([]pagerules.PageruleEditParamsTarget{{ - Constraint: cloudflare.F(pagerules.PageruleEditParamsTargetsConstraint{ - Operator: cloudflare.F(pagerules.PageruleEditParamsTargetsConstraintOperatorMatches), + Targets: cloudflare.F([]pagerules.TargetParam{{ + Constraint: cloudflare.F(pagerules.TargetConstraintParam{ + Operator: cloudflare.F(pagerules.TargetConstraintOperatorMatches), Value: cloudflare.F("*example.com/images/*"), }), - Target: cloudflare.F(pagerules.PageruleEditParamsTargetsTargetURL), + Target: cloudflare.F(pagerules.TargetTargetURL), }}), }, ) diff --git a/pagerules/setting.go b/pagerules/setting.go index 80e17269169..4532f44bc68 100644 --- a/pagerules/setting.go +++ b/pagerules/setting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewSettingService(opts ...option.RequestOption) (r *SettingService) { // Returns a list of settings (and their details) that Page Rules can apply to // matching requests. -func (r *SettingService) List(ctx context.Context, query SettingListParams, opts ...option.RequestOption) (res *ZonePageruleSettings, err error) { +func (r *SettingService) List(ctx context.Context, query SettingListParams, opts ...option.RequestOption) (res *[]SettingListResponse, err error) { opts = append(r.Options[:], opts...) var env SettingListResponseEnvelope path := fmt.Sprintf("zones/%s/pagerules/settings", query.ZoneID) @@ -44,8 +45,6 @@ func (r *SettingService) List(ctx context.Context, query SettingListParams, opts return } -type ZonePageruleSettings []interface{} - type SettingListResponse = interface{} type SettingListParams struct { @@ -54,10 +53,10 @@ type SettingListParams struct { } type SettingListResponseEnvelope struct { - Errors []SettingListResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingListResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Settings available for the zone. - Result ZonePageruleSettings `json:"result,required"` + Result []SettingListResponse `json:"result,required"` // Whether the API call was successful Success SettingListResponseEnvelopeSuccess `json:"success,required"` JSON settingListResponseEnvelopeJSON `json:"-"` @@ -82,52 +81,6 @@ func (r settingListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingListResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SettingListResponseEnvelopeErrors] -type settingListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingListResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingListResponseEnvelopeMessages] -type settingListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingListResponseEnvelopeSuccess bool diff --git a/pages/aliases.go b/pages/aliases.go index 3e8b1723ad4..00284fdfc04 100644 --- a/pages/aliases.go +++ b/pages/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/pages/project.go b/pages/project.go index 8d538a20266..39d97451126 100644 --- a/pages/project.go +++ b/pages/project.go @@ -40,7 +40,7 @@ func NewProjectService(opts ...option.RequestOption) (r *ProjectService) { } // Create a new project. -func (r *ProjectService) New(ctx context.Context, params ProjectNewParams, opts ...option.RequestOption) (res *ProjectNewResponse, err error) { +func (r *ProjectService) New(ctx context.Context, params ProjectNewParams, opts ...option.RequestOption) (res *ProjectNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ProjectNewResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects", params.AccountID) @@ -53,7 +53,7 @@ func (r *ProjectService) New(ctx context.Context, params ProjectNewParams, opts } // Fetch a list of all user projects. -func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *pagination.SinglePage[PagesDeployments], err error) { +func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Deployment], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -71,21 +71,21 @@ func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts } // Fetch a list of all user projects. -func (r *ProjectService) ListAutoPaging(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[PagesDeployments] { +func (r *ProjectService) ListAutoPaging(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Deployment] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete a project by name. -func (r *ProjectService) Delete(ctx context.Context, projectName string, body ProjectDeleteParams, opts ...option.RequestOption) (res *ProjectDeleteResponse, err error) { +func (r *ProjectService) Delete(ctx context.Context, projectName string, params ProjectDeleteParams, opts ...option.RequestOption) (res *ProjectDeleteResponse, err error) { opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/pages/projects/%s", body.AccountID, projectName) + path := fmt.Sprintf("accounts/%s/pages/projects/%s", params.AccountID, projectName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) return } // Set new attributes for an existing project. Modify environment variables. To // delete an environment variable, set the key to null. -func (r *ProjectService) Edit(ctx context.Context, projectName string, params ProjectEditParams, opts ...option.RequestOption) (res *ProjectEditResponse, err error) { +func (r *ProjectService) Edit(ctx context.Context, projectName string, params ProjectEditParams, opts ...option.RequestOption) (res *ProjectEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ProjectEditResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects/%s", params.AccountID, projectName) @@ -98,7 +98,7 @@ func (r *ProjectService) Edit(ctx context.Context, projectName string, params Pr } // Fetch a project by name. -func (r *ProjectService) Get(ctx context.Context, projectName string, query ProjectGetParams, opts ...option.RequestOption) (res *PagesProjects, err error) { +func (r *ProjectService) Get(ctx context.Context, projectName string, query ProjectGetParams, opts ...option.RequestOption) (res *Project, err error) { opts = append(r.Options[:], opts...) var env ProjectGetResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects/%s", query.AccountID, projectName) @@ -118,7 +118,7 @@ func (r *ProjectService) PurgeBuildCache(ctx context.Context, projectName string return } -type PagesDeployments struct { +type Deployment struct { // Id of the deployment. ID string `json:"id"` // A list of alias URLs pointing to this deployment. @@ -127,7 +127,7 @@ type PagesDeployments struct { // When the deployment was created. CreatedOn time.Time `json:"created_on" format:"date-time"` // Info about what caused the deployment. - DeploymentTrigger PagesDeploymentsDeploymentTrigger `json:"deployment_trigger"` + DeploymentTrigger DeploymentDeploymentTrigger `json:"deployment_trigger"` // A dict of env variables to build this deploy. EnvVars interface{} `json:"env_vars"` // Type of deploy. @@ -145,15 +145,14 @@ type PagesDeployments struct { ShortID string `json:"short_id"` Source interface{} `json:"source"` // List of past stages. - Stages []PagesDeploymentsStage `json:"stages"` + Stages []Stage `json:"stages"` // The live URL to view this deployment. - URL string `json:"url"` - JSON pagesDeploymentsJSON `json:"-"` + URL string `json:"url"` + JSON deploymentJSON `json:"-"` } -// pagesDeploymentsJSON contains the JSON metadata for the struct -// [PagesDeployments] -type pagesDeploymentsJSON struct { +// deploymentJSON contains the JSON metadata for the struct [Deployment] +type deploymentJSON struct { ID apijson.Field Aliases apijson.Field BuildConfig apijson.Field @@ -174,54 +173,54 @@ type pagesDeploymentsJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesDeployments) UnmarshalJSON(data []byte) (err error) { +func (r *Deployment) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesDeploymentsJSON) RawJSON() string { +func (r deploymentJSON) RawJSON() string { return r.raw } // Info about what caused the deployment. -type PagesDeploymentsDeploymentTrigger struct { +type DeploymentDeploymentTrigger struct { // Additional info about the trigger. - Metadata PagesDeploymentsDeploymentTriggerMetadata `json:"metadata"` + Metadata DeploymentDeploymentTriggerMetadata `json:"metadata"` // What caused the deployment. - Type string `json:"type"` - JSON pagesDeploymentsDeploymentTriggerJSON `json:"-"` + Type string `json:"type"` + JSON deploymentDeploymentTriggerJSON `json:"-"` } -// pagesDeploymentsDeploymentTriggerJSON contains the JSON metadata for the struct -// [PagesDeploymentsDeploymentTrigger] -type pagesDeploymentsDeploymentTriggerJSON struct { +// deploymentDeploymentTriggerJSON contains the JSON metadata for the struct +// [DeploymentDeploymentTrigger] +type deploymentDeploymentTriggerJSON struct { Metadata apijson.Field Type apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesDeploymentsDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { +func (r *DeploymentDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesDeploymentsDeploymentTriggerJSON) RawJSON() string { +func (r deploymentDeploymentTriggerJSON) RawJSON() string { return r.raw } // Additional info about the trigger. -type PagesDeploymentsDeploymentTriggerMetadata struct { +type DeploymentDeploymentTriggerMetadata struct { // Where the trigger happened. Branch string `json:"branch"` // Hash of the deployment trigger commit. CommitHash string `json:"commit_hash"` // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pagesDeploymentsDeploymentTriggerMetadataJSON `json:"-"` + CommitMessage string `json:"commit_message"` + JSON deploymentDeploymentTriggerMetadataJSON `json:"-"` } -// pagesDeploymentsDeploymentTriggerMetadataJSON contains the JSON metadata for the -// struct [PagesDeploymentsDeploymentTriggerMetadata] -type pagesDeploymentsDeploymentTriggerMetadataJSON struct { +// deploymentDeploymentTriggerMetadataJSON contains the JSON metadata for the +// struct [DeploymentDeploymentTriggerMetadata] +type deploymentDeploymentTriggerMetadataJSON struct { Branch apijson.Field CommitHash apijson.Field CommitMessage apijson.Field @@ -229,106 +228,64 @@ type pagesDeploymentsDeploymentTriggerMetadataJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesDeploymentsDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { +func (r *DeploymentDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesDeploymentsDeploymentTriggerMetadataJSON) RawJSON() string { +func (r deploymentDeploymentTriggerMetadataJSON) RawJSON() string { return r.raw } -// The status of the deployment. -type PagesDeploymentsStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pagesDeploymentsStageJSON `json:"-"` +type DeploymentParam struct { } -// pagesDeploymentsStageJSON contains the JSON metadata for the struct -// [PagesDeploymentsStage] -type pagesDeploymentsStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PagesDeploymentsStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pagesDeploymentsStageJSON) RawJSON() string { - return r.raw -} - -type PagesDeploymentsParam struct { -} - -func (r PagesDeploymentsParam) MarshalJSON() (data []byte, err error) { +func (r DeploymentParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Info about what caused the deployment. -type PagesDeploymentsDeploymentTriggerParam struct { +type DeploymentDeploymentTriggerParam struct { // Additional info about the trigger. - Metadata param.Field[PagesDeploymentsDeploymentTriggerMetadataParam] `json:"metadata"` + Metadata param.Field[DeploymentDeploymentTriggerMetadataParam] `json:"metadata"` } -func (r PagesDeploymentsDeploymentTriggerParam) MarshalJSON() (data []byte, err error) { +func (r DeploymentDeploymentTriggerParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Additional info about the trigger. -type PagesDeploymentsDeploymentTriggerMetadataParam struct { -} - -func (r PagesDeploymentsDeploymentTriggerMetadataParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type DeploymentDeploymentTriggerMetadataParam struct { } -// The status of the deployment. -type PagesDeploymentsStageParam struct { - // The current build stage. - Name param.Field[string] `json:"name"` -} - -func (r PagesDeploymentsStageParam) MarshalJSON() (data []byte, err error) { +func (r DeploymentDeploymentTriggerMetadataParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PagesProjects struct { +type Project struct { // Id of the project. ID string `json:"id"` // Configs for the project build process. - BuildConfig PagesProjectsBuildConfig `json:"build_config"` - CanonicalDeployment PagesDeployments `json:"canonical_deployment"` + BuildConfig ProjectBuildConfig `json:"build_config"` + CanonicalDeployment Deployment `json:"canonical_deployment"` // When the project was created. CreatedOn time.Time `json:"created_on" format:"date-time"` // Configs for deployments in a project. - DeploymentConfigs PagesProjectsDeploymentConfigs `json:"deployment_configs"` + DeploymentConfigs ProjectDeploymentConfigs `json:"deployment_configs"` // A list of associated custom domains for the project. - Domains []interface{} `json:"domains"` - LatestDeployment PagesDeployments `json:"latest_deployment"` + Domains []interface{} `json:"domains"` + LatestDeployment Deployment `json:"latest_deployment"` // Name of the project. Name string `json:"name"` // Production branch of the project. Used to identify production deployments. ProductionBranch string `json:"production_branch"` Source interface{} `json:"source"` // The Cloudflare subdomain associated with the project. - Subdomain string `json:"subdomain"` - JSON pagesProjectsJSON `json:"-"` + Subdomain string `json:"subdomain"` + JSON projectJSON `json:"-"` } -// pagesProjectsJSON contains the JSON metadata for the struct [PagesProjects] -type pagesProjectsJSON struct { +// projectJSON contains the JSON metadata for the struct [Project] +type projectJSON struct { ID apijson.Field BuildConfig apijson.Field CanonicalDeployment apijson.Field @@ -344,16 +301,16 @@ type pagesProjectsJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesProjects) UnmarshalJSON(data []byte) (err error) { +func (r *Project) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsJSON) RawJSON() string { +func (r projectJSON) RawJSON() string { return r.raw } // Configs for the project build process. -type PagesProjectsBuildConfig struct { +type ProjectBuildConfig struct { // Enable build caching for the project. BuildCaching bool `json:"build_caching,nullable"` // Command used to build project. @@ -365,13 +322,13 @@ type PagesProjectsBuildConfig struct { // The classifying tag for analytics. WebAnalyticsTag string `json:"web_analytics_tag,nullable"` // The auth token for analytics. - WebAnalyticsToken string `json:"web_analytics_token,nullable"` - JSON pagesProjectsBuildConfigJSON `json:"-"` + WebAnalyticsToken string `json:"web_analytics_token,nullable"` + JSON projectBuildConfigJSON `json:"-"` } -// pagesProjectsBuildConfigJSON contains the JSON metadata for the struct -// [PagesProjectsBuildConfig] -type pagesProjectsBuildConfigJSON struct { +// projectBuildConfigJSON contains the JSON metadata for the struct +// [ProjectBuildConfig] +type projectBuildConfigJSON struct { BuildCaching apijson.Field BuildCommand apijson.Field DestinationDir apijson.Field @@ -382,80 +339,80 @@ type pagesProjectsBuildConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesProjectsBuildConfig) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectBuildConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsBuildConfigJSON) RawJSON() string { +func (r projectBuildConfigJSON) RawJSON() string { return r.raw } // Configs for deployments in a project. -type PagesProjectsDeploymentConfigs struct { +type ProjectDeploymentConfigs struct { // Configs for preview deploys. - Preview PagesProjectsDeploymentConfigsPreview `json:"preview"` + Preview ProjectDeploymentConfigsPreview `json:"preview"` // Configs for production deploys. - Production PagesProjectsDeploymentConfigsProduction `json:"production"` - JSON pagesProjectsDeploymentConfigsJSON `json:"-"` + Production ProjectDeploymentConfigsProduction `json:"production"` + JSON projectDeploymentConfigsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsJSON contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigs] -type pagesProjectsDeploymentConfigsJSON struct { +// projectDeploymentConfigsJSON contains the JSON metadata for the struct +// [ProjectDeploymentConfigs] +type projectDeploymentConfigsJSON struct { Preview apijson.Field Production apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigs) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigs) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsJSON) RawJSON() string { +func (r projectDeploymentConfigsJSON) RawJSON() string { return r.raw } // Configs for preview deploys. -type PagesProjectsDeploymentConfigsPreview struct { +type ProjectDeploymentConfigsPreview struct { // Constellation bindings used for Pages Functions. - AIBindings PagesProjectsDeploymentConfigsPreviewAIBindings `json:"ai_bindings,nullable"` + AIBindings ProjectDeploymentConfigsPreviewAIBindings `json:"ai_bindings,nullable"` // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` + AnalyticsEngineDatasets ProjectDeploymentConfigsPreviewAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` // Browser bindings used for Pages Functions. - Browsers PagesProjectsDeploymentConfigsPreviewBrowsers `json:"browsers,nullable"` + Browsers ProjectDeploymentConfigsPreviewBrowsers `json:"browsers,nullable"` // Compatibility date used for Pages Functions. CompatibilityDate string `json:"compatibility_date"` // Compatibility flags used for Pages Functions. CompatibilityFlags []interface{} `json:"compatibility_flags"` // D1 databases used for Pages Functions. - D1Databases PagesProjectsDeploymentConfigsPreviewD1Databases `json:"d1_databases,nullable"` + D1Databases ProjectDeploymentConfigsPreviewD1Databases `json:"d1_databases,nullable"` // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` + DurableObjectNamespaces ProjectDeploymentConfigsPreviewDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` // Environment variables for build configs. - EnvVars PagesProjectsDeploymentConfigsPreviewEnvVars `json:"env_vars,nullable"` + EnvVars ProjectDeploymentConfigsPreviewEnvVars `json:"env_vars,nullable"` // Hyperdrive bindings used for Pages Functions. - HyperdriveBindings PagesProjectsDeploymentConfigsPreviewHyperdriveBindings `json:"hyperdrive_bindings,nullable"` + HyperdriveBindings ProjectDeploymentConfigsPreviewHyperdriveBindings `json:"hyperdrive_bindings,nullable"` // KV namespaces used for Pages Functions. - KVNamespaces PagesProjectsDeploymentConfigsPreviewKVNamespaces `json:"kv_namespaces"` + KVNamespaces ProjectDeploymentConfigsPreviewKVNamespaces `json:"kv_namespaces"` // mTLS bindings used for Pages Functions. - MTLSCertificates PagesProjectsDeploymentConfigsPreviewMTLSCertificates `json:"mtls_certificates,nullable"` + MTLSCertificates ProjectDeploymentConfigsPreviewMTLSCertificates `json:"mtls_certificates,nullable"` // Placement setting used for Pages Functions. - Placement PagesProjectsDeploymentConfigsPreviewPlacement `json:"placement,nullable"` + Placement ProjectDeploymentConfigsPreviewPlacement `json:"placement,nullable"` // Queue Producer bindings used for Pages Functions. - QueueProducers PagesProjectsDeploymentConfigsPreviewQueueProducers `json:"queue_producers,nullable"` + QueueProducers ProjectDeploymentConfigsPreviewQueueProducers `json:"queue_producers,nullable"` // R2 buckets used for Pages Functions. - R2Buckets PagesProjectsDeploymentConfigsPreviewR2Buckets `json:"r2_buckets,nullable"` + R2Buckets ProjectDeploymentConfigsPreviewR2Buckets `json:"r2_buckets,nullable"` // Services used for Pages Functions. - Services PagesProjectsDeploymentConfigsPreviewServices `json:"services,nullable"` + Services ProjectDeploymentConfigsPreviewServices `json:"services,nullable"` // Vectorize bindings used for Pages Functions. - VectorizeBindings PagesProjectsDeploymentConfigsPreviewVectorizeBindings `json:"vectorize_bindings,nullable"` - JSON pagesProjectsDeploymentConfigsPreviewJSON `json:"-"` + VectorizeBindings ProjectDeploymentConfigsPreviewVectorizeBindings `json:"vectorize_bindings,nullable"` + JSON projectDeploymentConfigsPreviewJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewJSON contains the JSON metadata for the -// struct [PagesProjectsDeploymentConfigsPreview] -type pagesProjectsDeploymentConfigsPreviewJSON struct { +// projectDeploymentConfigsPreviewJSON contains the JSON metadata for the struct +// [ProjectDeploymentConfigsPreview] +type projectDeploymentConfigsPreviewJSON struct { AIBindings apijson.Field AnalyticsEngineDatasets apijson.Field Browsers apijson.Field @@ -476,587 +433,578 @@ type pagesProjectsDeploymentConfigsPreviewJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreview) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreview) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewJSON) RawJSON() string { return r.raw } // Constellation bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewAIBindings struct { +type ProjectDeploymentConfigsPreviewAIBindings struct { // AI binding. - AIBinding PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding `json:"AI_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewAIBindingsJSON `json:"-"` + AIBinding ProjectDeploymentConfigsPreviewAIBindingsAIBinding `json:"AI_BINDING"` + JSON projectDeploymentConfigsPreviewAIBindingsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewAIBindingsJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsPreviewAIBindings] -type pagesProjectsDeploymentConfigsPreviewAIBindingsJSON struct { +// projectDeploymentConfigsPreviewAIBindingsJSON contains the JSON metadata for the +// struct [ProjectDeploymentConfigsPreviewAIBindings] +type projectDeploymentConfigsPreviewAIBindingsJSON struct { AIBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewAIBindings) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewAIBindings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewAIBindingsJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewAIBindingsJSON) RawJSON() string { return r.raw } // AI binding. -type PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding struct { - ProjectID interface{} `json:"project_id"` - JSON pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON `json:"-"` +type ProjectDeploymentConfigsPreviewAIBindingsAIBinding struct { + ProjectID interface{} `json:"project_id"` + JSON projectDeploymentConfigsPreviewAIBindingsAIBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding] -type pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON struct { +// projectDeploymentConfigsPreviewAIBindingsAIBindingJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsPreviewAIBindingsAIBinding] +type projectDeploymentConfigsPreviewAIBindingsAIBindingJSON struct { ProjectID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewAIBindingsAIBindingJSON) RawJSON() string { return r.raw } // Analytics Engine bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets struct { +type ProjectDeploymentConfigsPreviewAnalyticsEngineDatasets struct { // Analytics Engine binding. - AnalyticsEngineBinding PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON `json:"-"` + AnalyticsEngineBinding ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` + JSON projectDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets] -type pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON struct { +// projectDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsPreviewAnalyticsEngineDatasets] +type projectDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON struct { AnalyticsEngineBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON) RawJSON() string { return r.raw } // Analytics Engine binding. -type PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding struct { +type ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding struct { // Name of the dataset. - Dataset string `json:"dataset"` - JSON pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` + Dataset string `json:"dataset"` + JSON projectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON +// projectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON // contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] -type pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { +// [ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] +type projectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { Dataset apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { return r.raw } // Browser bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewBrowsers struct { +type ProjectDeploymentConfigsPreviewBrowsers struct { // Browser binding. - Browser interface{} `json:"BROWSER"` - JSON pagesProjectsDeploymentConfigsPreviewBrowsersJSON `json:"-"` + Browser interface{} `json:"BROWSER"` + JSON projectDeploymentConfigsPreviewBrowsersJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewBrowsersJSON contains the JSON metadata for -// the struct [PagesProjectsDeploymentConfigsPreviewBrowsers] -type pagesProjectsDeploymentConfigsPreviewBrowsersJSON struct { +// projectDeploymentConfigsPreviewBrowsersJSON contains the JSON metadata for the +// struct [ProjectDeploymentConfigsPreviewBrowsers] +type projectDeploymentConfigsPreviewBrowsersJSON struct { Browser apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewBrowsers) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewBrowsers) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewBrowsersJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewBrowsersJSON) RawJSON() string { return r.raw } // D1 databases used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewD1Databases struct { +type ProjectDeploymentConfigsPreviewD1Databases struct { // D1 binding. - D1Binding PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding `json:"D1_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON `json:"-"` + D1Binding ProjectDeploymentConfigsPreviewD1DatabasesD1Binding `json:"D1_BINDING"` + JSON projectDeploymentConfigsPreviewD1DatabasesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsPreviewD1Databases] -type pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON struct { +// projectDeploymentConfigsPreviewD1DatabasesJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsPreviewD1Databases] +type projectDeploymentConfigsPreviewD1DatabasesJSON struct { D1Binding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewD1Databases) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewD1Databases) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewD1DatabasesJSON) RawJSON() string { return r.raw } // D1 binding. -type PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding struct { +type ProjectDeploymentConfigsPreviewD1DatabasesD1Binding struct { // UUID of the D1 database. - ID string `json:"id"` - JSON pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON `json:"-"` + ID string `json:"id"` + JSON projectDeploymentConfigsPreviewD1DatabasesD1BindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding] -type pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON struct { +// projectDeploymentConfigsPreviewD1DatabasesD1BindingJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsPreviewD1DatabasesD1Binding] +type projectDeploymentConfigsPreviewD1DatabasesD1BindingJSON struct { ID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewD1DatabasesD1BindingJSON) RawJSON() string { return r.raw } // Durabble Object namespaces used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces struct { +type ProjectDeploymentConfigsPreviewDurableObjectNamespaces struct { // Durabble Object binding. - DoBinding PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding `json:"DO_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON `json:"-"` + DoBinding ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBinding `json:"DO_BINDING"` + JSON projectDeploymentConfigsPreviewDurableObjectNamespacesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces] -type pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON struct { +// projectDeploymentConfigsPreviewDurableObjectNamespacesJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsPreviewDurableObjectNamespaces] +type projectDeploymentConfigsPreviewDurableObjectNamespacesJSON struct { DoBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewDurableObjectNamespacesJSON) RawJSON() string { return r.raw } // Durabble Object binding. -type PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding struct { +type ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBinding struct { // ID of the Durabble Object namespace. - NamespaceID string `json:"namespace_id"` - JSON pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON `json:"-"` + NamespaceID string `json:"namespace_id"` + JSON projectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON -// contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding] -type pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON struct { +// projectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON contains the +// JSON metadata for the struct +// [ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBinding] +type projectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON struct { NamespaceID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON) RawJSON() string { return r.raw } // Environment variables for build configs. -type PagesProjectsDeploymentConfigsPreviewEnvVars struct { +type ProjectDeploymentConfigsPreviewEnvVars struct { // Environment variable. - EnvironmentVariable PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` - JSON pagesProjectsDeploymentConfigsPreviewEnvVarsJSON `json:"-"` + EnvironmentVariable ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` + JSON projectDeploymentConfigsPreviewEnvVarsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewEnvVarsJSON contains the JSON metadata for -// the struct [PagesProjectsDeploymentConfigsPreviewEnvVars] -type pagesProjectsDeploymentConfigsPreviewEnvVarsJSON struct { +// projectDeploymentConfigsPreviewEnvVarsJSON contains the JSON metadata for the +// struct [ProjectDeploymentConfigsPreviewEnvVars] +type projectDeploymentConfigsPreviewEnvVarsJSON struct { EnvironmentVariable apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewEnvVars) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewEnvVars) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewEnvVarsJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewEnvVarsJSON) RawJSON() string { return r.raw } // Environment variable. -type PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable struct { +type ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariable struct { // The type of environment variable (plain text or secret) - Type PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType `json:"type"` + Type ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableType `json:"type"` // Environment variable value. - Value string `json:"value"` - JSON pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON `json:"-"` + Value string `json:"value"` + JSON projectDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable] -type pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON struct { +// projectDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON contains the JSON +// metadata for the struct +// [ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariable] +type projectDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON struct { Type apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON) RawJSON() string { return r.raw } // The type of environment variable (plain text or secret) -type PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType string +type ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableType string const ( - PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "plain_text" - PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "secret_text" + ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "plain_text" + ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "secret_text" ) -func (r PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType) IsKnown() bool { +func (r ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableType) IsKnown() bool { switch r { - case PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText, PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText: + case ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText, ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText: return true } return false } // Hyperdrive bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewHyperdriveBindings struct { +type ProjectDeploymentConfigsPreviewHyperdriveBindings struct { // Hyperdrive binding. - Hyperdrive PagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive `json:"HYPERDRIVE"` - JSON pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsJSON `json:"-"` + Hyperdrive ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdrive `json:"HYPERDRIVE"` + JSON projectDeploymentConfigsPreviewHyperdriveBindingsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewHyperdriveBindings] -type pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsJSON struct { +// projectDeploymentConfigsPreviewHyperdriveBindingsJSON contains the JSON metadata +// for the struct [ProjectDeploymentConfigsPreviewHyperdriveBindings] +type projectDeploymentConfigsPreviewHyperdriveBindingsJSON struct { Hyperdrive apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewHyperdriveBindings) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewHyperdriveBindings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewHyperdriveBindingsJSON) RawJSON() string { return r.raw } // Hyperdrive binding. -type PagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive struct { - ID string `json:"id"` - JSON pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON `json:"-"` +type ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdrive struct { + ID string `json:"id"` + JSON projectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON contains -// the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive] -type pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON struct { +// projectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON contains the +// JSON metadata for the struct +// [ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdrive] +type projectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON struct { ID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdrive) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveJSON) RawJSON() string { return r.raw } // KV namespaces used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewKVNamespaces struct { +type ProjectDeploymentConfigsPreviewKVNamespaces struct { // KV binding. - KVBinding PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding `json:"KV_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON `json:"-"` + KVBinding ProjectDeploymentConfigsPreviewKVNamespacesKVBinding `json:"KV_BINDING"` + JSON projectDeploymentConfigsPreviewKVNamespacesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsPreviewKVNamespaces] -type pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON struct { +// projectDeploymentConfigsPreviewKVNamespacesJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsPreviewKVNamespaces] +type projectDeploymentConfigsPreviewKVNamespacesJSON struct { KVBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewKVNamespaces) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewKVNamespaces) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewKVNamespacesJSON) RawJSON() string { return r.raw } // KV binding. -type PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding struct { +type ProjectDeploymentConfigsPreviewKVNamespacesKVBinding struct { // ID of the KV namespace. - NamespaceID string `json:"namespace_id"` - JSON pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON `json:"-"` + NamespaceID string `json:"namespace_id"` + JSON projectDeploymentConfigsPreviewKVNamespacesKVBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding] -type pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON struct { +// projectDeploymentConfigsPreviewKVNamespacesKVBindingJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsPreviewKVNamespacesKVBinding] +type projectDeploymentConfigsPreviewKVNamespacesKVBindingJSON struct { NamespaceID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewKVNamespacesKVBindingJSON) RawJSON() string { return r.raw } // mTLS bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewMTLSCertificates struct { +type ProjectDeploymentConfigsPreviewMTLSCertificates struct { // mTLS binding. - MTLS PagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLS `json:"MTLS"` - JSON pagesProjectsDeploymentConfigsPreviewMTLSCertificatesJSON `json:"-"` + MTLS ProjectDeploymentConfigsPreviewMTLSCertificatesMTLS `json:"MTLS"` + JSON projectDeploymentConfigsPreviewMTLSCertificatesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewMTLSCertificatesJSON contains the JSON -// metadata for the struct [PagesProjectsDeploymentConfigsPreviewMTLSCertificates] -type pagesProjectsDeploymentConfigsPreviewMTLSCertificatesJSON struct { +// projectDeploymentConfigsPreviewMTLSCertificatesJSON contains the JSON metadata +// for the struct [ProjectDeploymentConfigsPreviewMTLSCertificates] +type projectDeploymentConfigsPreviewMTLSCertificatesJSON struct { MTLS apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewMTLSCertificates) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewMTLSCertificates) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewMTLSCertificatesJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewMTLSCertificatesJSON) RawJSON() string { return r.raw } // mTLS binding. -type PagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLS struct { - CertificateID string `json:"certificate_id"` - JSON pagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLSJSON `json:"-"` +type ProjectDeploymentConfigsPreviewMTLSCertificatesMTLS struct { + CertificateID string `json:"certificate_id"` + JSON projectDeploymentConfigsPreviewMTLSCertificatesMTLSJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLSJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLS] -type pagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLSJSON struct { +// projectDeploymentConfigsPreviewMTLSCertificatesMTLSJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsPreviewMTLSCertificatesMTLS] +type projectDeploymentConfigsPreviewMTLSCertificatesMTLSJSON struct { CertificateID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLS) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewMTLSCertificatesMTLS) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewMTLSCertificatesMTLSJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewMTLSCertificatesMTLSJSON) RawJSON() string { return r.raw } // Placement setting used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewPlacement struct { +type ProjectDeploymentConfigsPreviewPlacement struct { // Placement mode. - Mode string `json:"mode"` - JSON pagesProjectsDeploymentConfigsPreviewPlacementJSON `json:"-"` + Mode string `json:"mode"` + JSON projectDeploymentConfigsPreviewPlacementJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewPlacementJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsPreviewPlacement] -type pagesProjectsDeploymentConfigsPreviewPlacementJSON struct { +// projectDeploymentConfigsPreviewPlacementJSON contains the JSON metadata for the +// struct [ProjectDeploymentConfigsPreviewPlacement] +type projectDeploymentConfigsPreviewPlacementJSON struct { Mode apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewPlacement) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewPlacement) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewPlacementJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewPlacementJSON) RawJSON() string { return r.raw } // Queue Producer bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewQueueProducers struct { +type ProjectDeploymentConfigsPreviewQueueProducers struct { // Queue Producer binding. - QueueProducerBinding PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewQueueProducersJSON `json:"-"` + QueueProducerBinding ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` + JSON projectDeploymentConfigsPreviewQueueProducersJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewQueueProducersJSON contains the JSON -// metadata for the struct [PagesProjectsDeploymentConfigsPreviewQueueProducers] -type pagesProjectsDeploymentConfigsPreviewQueueProducersJSON struct { +// projectDeploymentConfigsPreviewQueueProducersJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsPreviewQueueProducers] +type projectDeploymentConfigsPreviewQueueProducersJSON struct { QueueProducerBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewQueueProducers) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewQueueProducers) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewQueueProducersJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewQueueProducersJSON) RawJSON() string { return r.raw } // Queue Producer binding. -type PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding struct { +type ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBinding struct { // Name of the Queue. - Name string `json:"name"` - JSON pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON `json:"-"` + Name string `json:"name"` + JSON projectDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON -// contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding] -type pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON struct { +// projectDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON contains +// the JSON metadata for the struct +// [ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBinding] +type projectDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON struct { Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON) RawJSON() string { return r.raw } // R2 buckets used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewR2Buckets struct { +type ProjectDeploymentConfigsPreviewR2Buckets struct { // R2 binding. - R2Binding PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding `json:"R2_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewR2BucketsJSON `json:"-"` + R2Binding ProjectDeploymentConfigsPreviewR2BucketsR2Binding `json:"R2_BINDING"` + JSON projectDeploymentConfigsPreviewR2BucketsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewR2BucketsJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsPreviewR2Buckets] -type pagesProjectsDeploymentConfigsPreviewR2BucketsJSON struct { +// projectDeploymentConfigsPreviewR2BucketsJSON contains the JSON metadata for the +// struct [ProjectDeploymentConfigsPreviewR2Buckets] +type projectDeploymentConfigsPreviewR2BucketsJSON struct { R2Binding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewR2Buckets) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewR2Buckets) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewR2BucketsJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewR2BucketsJSON) RawJSON() string { return r.raw } // R2 binding. -type PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding struct { +type ProjectDeploymentConfigsPreviewR2BucketsR2Binding struct { // Name of the R2 bucket. - Name string `json:"name"` - JSON pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON `json:"-"` + Name string `json:"name"` + JSON projectDeploymentConfigsPreviewR2BucketsR2BindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding] -type pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON struct { +// projectDeploymentConfigsPreviewR2BucketsR2BindingJSON contains the JSON metadata +// for the struct [ProjectDeploymentConfigsPreviewR2BucketsR2Binding] +type projectDeploymentConfigsPreviewR2BucketsR2BindingJSON struct { Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewR2BucketsR2BindingJSON) RawJSON() string { return r.raw } // Services used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewServices struct { +type ProjectDeploymentConfigsPreviewServices struct { // Service binding. - ServiceBinding PagesProjectsDeploymentConfigsPreviewServicesServiceBinding `json:"SERVICE_BINDING"` - JSON pagesProjectsDeploymentConfigsPreviewServicesJSON `json:"-"` + ServiceBinding ProjectDeploymentConfigsPreviewServicesServiceBinding `json:"SERVICE_BINDING"` + JSON projectDeploymentConfigsPreviewServicesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewServicesJSON contains the JSON metadata for -// the struct [PagesProjectsDeploymentConfigsPreviewServices] -type pagesProjectsDeploymentConfigsPreviewServicesJSON struct { +// projectDeploymentConfigsPreviewServicesJSON contains the JSON metadata for the +// struct [ProjectDeploymentConfigsPreviewServices] +type projectDeploymentConfigsPreviewServicesJSON struct { ServiceBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewServices) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewServices) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewServicesJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewServicesJSON) RawJSON() string { return r.raw } // Service binding. -type PagesProjectsDeploymentConfigsPreviewServicesServiceBinding struct { +type ProjectDeploymentConfigsPreviewServicesServiceBinding struct { // The entrypoint to bind to. Entrypoint string `json:"entrypoint,nullable"` // The Service environment. Environment string `json:"environment"` // The Service name. - Service string `json:"service"` - JSON pagesProjectsDeploymentConfigsPreviewServicesServiceBindingJSON `json:"-"` + Service string `json:"service"` + JSON projectDeploymentConfigsPreviewServicesServiceBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewServicesServiceBindingJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewServicesServiceBinding] -type pagesProjectsDeploymentConfigsPreviewServicesServiceBindingJSON struct { +// projectDeploymentConfigsPreviewServicesServiceBindingJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsPreviewServicesServiceBinding] +type projectDeploymentConfigsPreviewServicesServiceBindingJSON struct { Entrypoint apijson.Field Environment apijson.Field Service apijson.Field @@ -1064,100 +1012,100 @@ type pagesProjectsDeploymentConfigsPreviewServicesServiceBindingJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewServicesServiceBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewServicesServiceBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewServicesServiceBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewServicesServiceBindingJSON) RawJSON() string { return r.raw } // Vectorize bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsPreviewVectorizeBindings struct { +type ProjectDeploymentConfigsPreviewVectorizeBindings struct { // Vectorize binding. - Vectorize PagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorize `json:"VECTORIZE"` - JSON pagesProjectsDeploymentConfigsPreviewVectorizeBindingsJSON `json:"-"` + Vectorize ProjectDeploymentConfigsPreviewVectorizeBindingsVectorize `json:"VECTORIZE"` + JSON projectDeploymentConfigsPreviewVectorizeBindingsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewVectorizeBindingsJSON contains the JSON -// metadata for the struct [PagesProjectsDeploymentConfigsPreviewVectorizeBindings] -type pagesProjectsDeploymentConfigsPreviewVectorizeBindingsJSON struct { +// projectDeploymentConfigsPreviewVectorizeBindingsJSON contains the JSON metadata +// for the struct [ProjectDeploymentConfigsPreviewVectorizeBindings] +type projectDeploymentConfigsPreviewVectorizeBindingsJSON struct { Vectorize apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewVectorizeBindings) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewVectorizeBindings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewVectorizeBindingsJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewVectorizeBindingsJSON) RawJSON() string { return r.raw } // Vectorize binding. -type PagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorize struct { - IndexName string `json:"index_name"` - JSON pagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON `json:"-"` +type ProjectDeploymentConfigsPreviewVectorizeBindingsVectorize struct { + IndexName string `json:"index_name"` + JSON projectDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON `json:"-"` } -// pagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorize] -type pagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON struct { +// projectDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON contains the JSON +// metadata for the struct +// [ProjectDeploymentConfigsPreviewVectorizeBindingsVectorize] +type projectDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON struct { IndexName apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorize) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsPreviewVectorizeBindingsVectorize) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON) RawJSON() string { +func (r projectDeploymentConfigsPreviewVectorizeBindingsVectorizeJSON) RawJSON() string { return r.raw } // Configs for production deploys. -type PagesProjectsDeploymentConfigsProduction struct { +type ProjectDeploymentConfigsProduction struct { // Constellation bindings used for Pages Functions. - AIBindings PagesProjectsDeploymentConfigsProductionAIBindings `json:"ai_bindings,nullable"` + AIBindings ProjectDeploymentConfigsProductionAIBindings `json:"ai_bindings,nullable"` // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` + AnalyticsEngineDatasets ProjectDeploymentConfigsProductionAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` // Browser bindings used for Pages Functions. - Browsers PagesProjectsDeploymentConfigsProductionBrowsers `json:"browsers,nullable"` + Browsers ProjectDeploymentConfigsProductionBrowsers `json:"browsers,nullable"` // Compatibility date used for Pages Functions. CompatibilityDate string `json:"compatibility_date"` // Compatibility flags used for Pages Functions. CompatibilityFlags []interface{} `json:"compatibility_flags"` // D1 databases used for Pages Functions. - D1Databases PagesProjectsDeploymentConfigsProductionD1Databases `json:"d1_databases,nullable"` + D1Databases ProjectDeploymentConfigsProductionD1Databases `json:"d1_databases,nullable"` // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` + DurableObjectNamespaces ProjectDeploymentConfigsProductionDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` // Environment variables for build configs. - EnvVars PagesProjectsDeploymentConfigsProductionEnvVars `json:"env_vars,nullable"` + EnvVars ProjectDeploymentConfigsProductionEnvVars `json:"env_vars,nullable"` // Hyperdrive bindings used for Pages Functions. - HyperdriveBindings PagesProjectsDeploymentConfigsProductionHyperdriveBindings `json:"hyperdrive_bindings,nullable"` + HyperdriveBindings ProjectDeploymentConfigsProductionHyperdriveBindings `json:"hyperdrive_bindings,nullable"` // KV namespaces used for Pages Functions. - KVNamespaces PagesProjectsDeploymentConfigsProductionKVNamespaces `json:"kv_namespaces"` + KVNamespaces ProjectDeploymentConfigsProductionKVNamespaces `json:"kv_namespaces"` // mTLS bindings used for Pages Functions. - MTLSCertificates PagesProjectsDeploymentConfigsProductionMTLSCertificates `json:"mtls_certificates,nullable"` + MTLSCertificates ProjectDeploymentConfigsProductionMTLSCertificates `json:"mtls_certificates,nullable"` // Placement setting used for Pages Functions. - Placement PagesProjectsDeploymentConfigsProductionPlacement `json:"placement,nullable"` + Placement ProjectDeploymentConfigsProductionPlacement `json:"placement,nullable"` // Queue Producer bindings used for Pages Functions. - QueueProducers PagesProjectsDeploymentConfigsProductionQueueProducers `json:"queue_producers,nullable"` + QueueProducers ProjectDeploymentConfigsProductionQueueProducers `json:"queue_producers,nullable"` // R2 buckets used for Pages Functions. - R2Buckets PagesProjectsDeploymentConfigsProductionR2Buckets `json:"r2_buckets,nullable"` + R2Buckets ProjectDeploymentConfigsProductionR2Buckets `json:"r2_buckets,nullable"` // Services used for Pages Functions. - Services PagesProjectsDeploymentConfigsProductionServices `json:"services,nullable"` + Services ProjectDeploymentConfigsProductionServices `json:"services,nullable"` // Vectorize bindings used for Pages Functions. - VectorizeBindings PagesProjectsDeploymentConfigsProductionVectorizeBindings `json:"vectorize_bindings,nullable"` - JSON pagesProjectsDeploymentConfigsProductionJSON `json:"-"` + VectorizeBindings ProjectDeploymentConfigsProductionVectorizeBindings `json:"vectorize_bindings,nullable"` + JSON projectDeploymentConfigsProductionJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionJSON contains the JSON metadata for the -// struct [PagesProjectsDeploymentConfigsProduction] -type pagesProjectsDeploymentConfigsProductionJSON struct { +// projectDeploymentConfigsProductionJSON contains the JSON metadata for the struct +// [ProjectDeploymentConfigsProduction] +type projectDeploymentConfigsProductionJSON struct { AIBindings apijson.Field AnalyticsEngineDatasets apijson.Field Browsers apijson.Field @@ -1178,588 +1126,582 @@ type pagesProjectsDeploymentConfigsProductionJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProduction) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProduction) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionJSON) RawJSON() string { return r.raw } // Constellation bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionAIBindings struct { +type ProjectDeploymentConfigsProductionAIBindings struct { // AI binding. - AIBinding PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding `json:"AI_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionAIBindingsJSON `json:"-"` + AIBinding ProjectDeploymentConfigsProductionAIBindingsAIBinding `json:"AI_BINDING"` + JSON projectDeploymentConfigsProductionAIBindingsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionAIBindingsJSON contains the JSON -// metadata for the struct [PagesProjectsDeploymentConfigsProductionAIBindings] -type pagesProjectsDeploymentConfigsProductionAIBindingsJSON struct { +// projectDeploymentConfigsProductionAIBindingsJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsProductionAIBindings] +type projectDeploymentConfigsProductionAIBindingsJSON struct { AIBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionAIBindings) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionAIBindings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionAIBindingsJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionAIBindingsJSON) RawJSON() string { return r.raw } // AI binding. -type PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding struct { - ProjectID interface{} `json:"project_id"` - JSON pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON `json:"-"` +type ProjectDeploymentConfigsProductionAIBindingsAIBinding struct { + ProjectID interface{} `json:"project_id"` + JSON projectDeploymentConfigsProductionAIBindingsAIBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding] -type pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON struct { +// projectDeploymentConfigsProductionAIBindingsAIBindingJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsProductionAIBindingsAIBinding] +type projectDeploymentConfigsProductionAIBindingsAIBindingJSON struct { ProjectID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionAIBindingsAIBindingJSON) RawJSON() string { return r.raw } // Analytics Engine bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets struct { +type ProjectDeploymentConfigsProductionAnalyticsEngineDatasets struct { // Analytics Engine binding. - AnalyticsEngineBinding PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON `json:"-"` + AnalyticsEngineBinding ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` + JSON projectDeploymentConfigsProductionAnalyticsEngineDatasetsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets] -type pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON struct { +// projectDeploymentConfigsProductionAnalyticsEngineDatasetsJSON contains the JSON +// metadata for the struct +// [ProjectDeploymentConfigsProductionAnalyticsEngineDatasets] +type projectDeploymentConfigsProductionAnalyticsEngineDatasetsJSON struct { AnalyticsEngineBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionAnalyticsEngineDatasetsJSON) RawJSON() string { return r.raw } // Analytics Engine binding. -type PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding struct { +type ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding struct { // Name of the dataset. - Dataset string `json:"dataset"` - JSON pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` + Dataset string `json:"dataset"` + JSON projectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON +// projectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON // contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] -type pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { +// [ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] +type projectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { Dataset apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { return r.raw } // Browser bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionBrowsers struct { +type ProjectDeploymentConfigsProductionBrowsers struct { // Browser binding. - Browser interface{} `json:"BROWSER"` - JSON pagesProjectsDeploymentConfigsProductionBrowsersJSON `json:"-"` + Browser interface{} `json:"BROWSER"` + JSON projectDeploymentConfigsProductionBrowsersJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionBrowsersJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsProductionBrowsers] -type pagesProjectsDeploymentConfigsProductionBrowsersJSON struct { +// projectDeploymentConfigsProductionBrowsersJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsProductionBrowsers] +type projectDeploymentConfigsProductionBrowsersJSON struct { Browser apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionBrowsers) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionBrowsers) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionBrowsersJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionBrowsersJSON) RawJSON() string { return r.raw } // D1 databases used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionD1Databases struct { +type ProjectDeploymentConfigsProductionD1Databases struct { // D1 binding. - D1Binding PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding `json:"D1_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionD1DatabasesJSON `json:"-"` + D1Binding ProjectDeploymentConfigsProductionD1DatabasesD1Binding `json:"D1_BINDING"` + JSON projectDeploymentConfigsProductionD1DatabasesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionD1DatabasesJSON contains the JSON -// metadata for the struct [PagesProjectsDeploymentConfigsProductionD1Databases] -type pagesProjectsDeploymentConfigsProductionD1DatabasesJSON struct { +// projectDeploymentConfigsProductionD1DatabasesJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsProductionD1Databases] +type projectDeploymentConfigsProductionD1DatabasesJSON struct { D1Binding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionD1Databases) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionD1Databases) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionD1DatabasesJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionD1DatabasesJSON) RawJSON() string { return r.raw } // D1 binding. -type PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding struct { +type ProjectDeploymentConfigsProductionD1DatabasesD1Binding struct { // UUID of the D1 database. - ID string `json:"id"` - JSON pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON `json:"-"` + ID string `json:"id"` + JSON projectDeploymentConfigsProductionD1DatabasesD1BindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding] -type pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON struct { +// projectDeploymentConfigsProductionD1DatabasesD1BindingJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsProductionD1DatabasesD1Binding] +type projectDeploymentConfigsProductionD1DatabasesD1BindingJSON struct { ID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionD1DatabasesD1BindingJSON) RawJSON() string { return r.raw } // Durabble Object namespaces used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces struct { +type ProjectDeploymentConfigsProductionDurableObjectNamespaces struct { // Durabble Object binding. - DoBinding PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding `json:"DO_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON `json:"-"` + DoBinding ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBinding `json:"DO_BINDING"` + JSON projectDeploymentConfigsProductionDurableObjectNamespacesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces] -type pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON struct { +// projectDeploymentConfigsProductionDurableObjectNamespacesJSON contains the JSON +// metadata for the struct +// [ProjectDeploymentConfigsProductionDurableObjectNamespaces] +type projectDeploymentConfigsProductionDurableObjectNamespacesJSON struct { DoBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionDurableObjectNamespacesJSON) RawJSON() string { return r.raw } // Durabble Object binding. -type PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding struct { +type ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBinding struct { // ID of the Durabble Object namespace. - NamespaceID string `json:"namespace_id"` - JSON pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON `json:"-"` + NamespaceID string `json:"namespace_id"` + JSON projectDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON -// contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding] -type pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON struct { +// projectDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON contains +// the JSON metadata for the struct +// [ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBinding] +type projectDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON struct { NamespaceID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON) RawJSON() string { return r.raw } // Environment variables for build configs. -type PagesProjectsDeploymentConfigsProductionEnvVars struct { +type ProjectDeploymentConfigsProductionEnvVars struct { // Environment variable. - EnvironmentVariable PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` - JSON pagesProjectsDeploymentConfigsProductionEnvVarsJSON `json:"-"` + EnvironmentVariable ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` + JSON projectDeploymentConfigsProductionEnvVarsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionEnvVarsJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsProductionEnvVars] -type pagesProjectsDeploymentConfigsProductionEnvVarsJSON struct { +// projectDeploymentConfigsProductionEnvVarsJSON contains the JSON metadata for the +// struct [ProjectDeploymentConfigsProductionEnvVars] +type projectDeploymentConfigsProductionEnvVarsJSON struct { EnvironmentVariable apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionEnvVars) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionEnvVars) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionEnvVarsJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionEnvVarsJSON) RawJSON() string { return r.raw } // Environment variable. -type PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable struct { +type ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariable struct { // The type of environment variable (plain text or secret) - Type PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType `json:"type"` + Type ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableType `json:"type"` // Environment variable value. - Value string `json:"value"` - JSON pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON `json:"-"` + Value string `json:"value"` + JSON projectDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON contains -// the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable] -type pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON struct { +// projectDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON contains the +// JSON metadata for the struct +// [ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariable] +type projectDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON struct { Type apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON) RawJSON() string { return r.raw } // The type of environment variable (plain text or secret) -type PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType string +type ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableType string const ( - PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "plain_text" - PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "secret_text" + ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "plain_text" + ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "secret_text" ) -func (r PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType) IsKnown() bool { +func (r ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableType) IsKnown() bool { switch r { - case PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText, PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText: + case ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText, ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText: return true } return false } // Hyperdrive bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionHyperdriveBindings struct { +type ProjectDeploymentConfigsProductionHyperdriveBindings struct { // Hyperdrive binding. - Hyperdrive PagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdrive `json:"HYPERDRIVE"` - JSON pagesProjectsDeploymentConfigsProductionHyperdriveBindingsJSON `json:"-"` + Hyperdrive ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdrive `json:"HYPERDRIVE"` + JSON projectDeploymentConfigsProductionHyperdriveBindingsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionHyperdriveBindingsJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsProductionHyperdriveBindings] -type pagesProjectsDeploymentConfigsProductionHyperdriveBindingsJSON struct { +// projectDeploymentConfigsProductionHyperdriveBindingsJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsProductionHyperdriveBindings] +type projectDeploymentConfigsProductionHyperdriveBindingsJSON struct { Hyperdrive apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionHyperdriveBindings) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionHyperdriveBindings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionHyperdriveBindingsJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionHyperdriveBindingsJSON) RawJSON() string { return r.raw } // Hyperdrive binding. -type PagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdrive struct { - ID string `json:"id"` - JSON pagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON `json:"-"` +type ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdrive struct { + ID string `json:"id"` + JSON projectDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON -// contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdrive] -type pagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON struct { +// projectDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON contains the +// JSON metadata for the struct +// [ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdrive] +type projectDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON struct { ID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdrive) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdrive) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionHyperdriveBindingsHyperdriveJSON) RawJSON() string { return r.raw } // KV namespaces used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionKVNamespaces struct { +type ProjectDeploymentConfigsProductionKVNamespaces struct { // KV binding. - KVBinding PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding `json:"KV_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionKVNamespacesJSON `json:"-"` + KVBinding ProjectDeploymentConfigsProductionKVNamespacesKVBinding `json:"KV_BINDING"` + JSON projectDeploymentConfigsProductionKVNamespacesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionKVNamespacesJSON contains the JSON -// metadata for the struct [PagesProjectsDeploymentConfigsProductionKVNamespaces] -type pagesProjectsDeploymentConfigsProductionKVNamespacesJSON struct { +// projectDeploymentConfigsProductionKVNamespacesJSON contains the JSON metadata +// for the struct [ProjectDeploymentConfigsProductionKVNamespaces] +type projectDeploymentConfigsProductionKVNamespacesJSON struct { KVBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionKVNamespaces) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionKVNamespaces) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionKVNamespacesJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionKVNamespacesJSON) RawJSON() string { return r.raw } // KV binding. -type PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding struct { +type ProjectDeploymentConfigsProductionKVNamespacesKVBinding struct { // ID of the KV namespace. - NamespaceID string `json:"namespace_id"` - JSON pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON `json:"-"` + NamespaceID string `json:"namespace_id"` + JSON projectDeploymentConfigsProductionKVNamespacesKVBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding] -type pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON struct { +// projectDeploymentConfigsProductionKVNamespacesKVBindingJSON contains the JSON +// metadata for the struct +// [ProjectDeploymentConfigsProductionKVNamespacesKVBinding] +type projectDeploymentConfigsProductionKVNamespacesKVBindingJSON struct { NamespaceID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionKVNamespacesKVBindingJSON) RawJSON() string { return r.raw } // mTLS bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionMTLSCertificates struct { +type ProjectDeploymentConfigsProductionMTLSCertificates struct { // mTLS binding. - MTLS PagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLS `json:"MTLS"` - JSON pagesProjectsDeploymentConfigsProductionMTLSCertificatesJSON `json:"-"` + MTLS ProjectDeploymentConfigsProductionMTLSCertificatesMTLS `json:"MTLS"` + JSON projectDeploymentConfigsProductionMTLSCertificatesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionMTLSCertificatesJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsProductionMTLSCertificates] -type pagesProjectsDeploymentConfigsProductionMTLSCertificatesJSON struct { +// projectDeploymentConfigsProductionMTLSCertificatesJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsProductionMTLSCertificates] +type projectDeploymentConfigsProductionMTLSCertificatesJSON struct { MTLS apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionMTLSCertificates) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionMTLSCertificates) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionMTLSCertificatesJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionMTLSCertificatesJSON) RawJSON() string { return r.raw } // mTLS binding. -type PagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLS struct { - CertificateID string `json:"certificate_id"` - JSON pagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLSJSON `json:"-"` +type ProjectDeploymentConfigsProductionMTLSCertificatesMTLS struct { + CertificateID string `json:"certificate_id"` + JSON projectDeploymentConfigsProductionMTLSCertificatesMTLSJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLSJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLS] -type pagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLSJSON struct { +// projectDeploymentConfigsProductionMTLSCertificatesMTLSJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsProductionMTLSCertificatesMTLS] +type projectDeploymentConfigsProductionMTLSCertificatesMTLSJSON struct { CertificateID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLS) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionMTLSCertificatesMTLS) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionMTLSCertificatesMTLSJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionMTLSCertificatesMTLSJSON) RawJSON() string { return r.raw } // Placement setting used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionPlacement struct { +type ProjectDeploymentConfigsProductionPlacement struct { // Placement mode. - Mode string `json:"mode"` - JSON pagesProjectsDeploymentConfigsProductionPlacementJSON `json:"-"` + Mode string `json:"mode"` + JSON projectDeploymentConfigsProductionPlacementJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionPlacementJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsProductionPlacement] -type pagesProjectsDeploymentConfigsProductionPlacementJSON struct { +// projectDeploymentConfigsProductionPlacementJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsProductionPlacement] +type projectDeploymentConfigsProductionPlacementJSON struct { Mode apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionPlacement) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionPlacement) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionPlacementJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionPlacementJSON) RawJSON() string { return r.raw } // Queue Producer bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionQueueProducers struct { +type ProjectDeploymentConfigsProductionQueueProducers struct { // Queue Producer binding. - QueueProducerBinding PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionQueueProducersJSON `json:"-"` + QueueProducerBinding ProjectDeploymentConfigsProductionQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` + JSON projectDeploymentConfigsProductionQueueProducersJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionQueueProducersJSON contains the JSON -// metadata for the struct [PagesProjectsDeploymentConfigsProductionQueueProducers] -type pagesProjectsDeploymentConfigsProductionQueueProducersJSON struct { +// projectDeploymentConfigsProductionQueueProducersJSON contains the JSON metadata +// for the struct [ProjectDeploymentConfigsProductionQueueProducers] +type projectDeploymentConfigsProductionQueueProducersJSON struct { QueueProducerBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionQueueProducers) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionQueueProducers) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionQueueProducersJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionQueueProducersJSON) RawJSON() string { return r.raw } // Queue Producer binding. -type PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding struct { +type ProjectDeploymentConfigsProductionQueueProducersQueueProducerBinding struct { // Name of the Queue. - Name string `json:"name"` - JSON pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON `json:"-"` + Name string `json:"name"` + JSON projectDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON +// projectDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON // contains the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding] -type pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON struct { +// [ProjectDeploymentConfigsProductionQueueProducersQueueProducerBinding] +type projectDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON struct { Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON) RawJSON() string { return r.raw } // R2 buckets used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionR2Buckets struct { +type ProjectDeploymentConfigsProductionR2Buckets struct { // R2 binding. - R2Binding PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding `json:"R2_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionR2BucketsJSON `json:"-"` + R2Binding ProjectDeploymentConfigsProductionR2BucketsR2Binding `json:"R2_BINDING"` + JSON projectDeploymentConfigsProductionR2BucketsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionR2BucketsJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsProductionR2Buckets] -type pagesProjectsDeploymentConfigsProductionR2BucketsJSON struct { +// projectDeploymentConfigsProductionR2BucketsJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsProductionR2Buckets] +type projectDeploymentConfigsProductionR2BucketsJSON struct { R2Binding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionR2Buckets) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionR2Buckets) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionR2BucketsJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionR2BucketsJSON) RawJSON() string { return r.raw } // R2 binding. -type PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding struct { +type ProjectDeploymentConfigsProductionR2BucketsR2Binding struct { // Name of the R2 bucket. - Name string `json:"name"` - JSON pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON `json:"-"` + Name string `json:"name"` + JSON projectDeploymentConfigsProductionR2BucketsR2BindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding] -type pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON struct { +// projectDeploymentConfigsProductionR2BucketsR2BindingJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsProductionR2BucketsR2Binding] +type projectDeploymentConfigsProductionR2BucketsR2BindingJSON struct { Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionR2BucketsR2BindingJSON) RawJSON() string { return r.raw } // Services used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionServices struct { +type ProjectDeploymentConfigsProductionServices struct { // Service binding. - ServiceBinding PagesProjectsDeploymentConfigsProductionServicesServiceBinding `json:"SERVICE_BINDING"` - JSON pagesProjectsDeploymentConfigsProductionServicesJSON `json:"-"` + ServiceBinding ProjectDeploymentConfigsProductionServicesServiceBinding `json:"SERVICE_BINDING"` + JSON projectDeploymentConfigsProductionServicesJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionServicesJSON contains the JSON metadata -// for the struct [PagesProjectsDeploymentConfigsProductionServices] -type pagesProjectsDeploymentConfigsProductionServicesJSON struct { +// projectDeploymentConfigsProductionServicesJSON contains the JSON metadata for +// the struct [ProjectDeploymentConfigsProductionServices] +type projectDeploymentConfigsProductionServicesJSON struct { ServiceBinding apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionServices) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionServices) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionServicesJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionServicesJSON) RawJSON() string { return r.raw } // Service binding. -type PagesProjectsDeploymentConfigsProductionServicesServiceBinding struct { +type ProjectDeploymentConfigsProductionServicesServiceBinding struct { // The entrypoint to bind to. Entrypoint string `json:"entrypoint,nullable"` // The Service environment. Environment string `json:"environment"` // The Service name. - Service string `json:"service"` - JSON pagesProjectsDeploymentConfigsProductionServicesServiceBindingJSON `json:"-"` + Service string `json:"service"` + JSON projectDeploymentConfigsProductionServicesServiceBindingJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionServicesServiceBindingJSON contains the -// JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionServicesServiceBinding] -type pagesProjectsDeploymentConfigsProductionServicesServiceBindingJSON struct { +// projectDeploymentConfigsProductionServicesServiceBindingJSON contains the JSON +// metadata for the struct +// [ProjectDeploymentConfigsProductionServicesServiceBinding] +type projectDeploymentConfigsProductionServicesServiceBindingJSON struct { Entrypoint apijson.Field Environment apijson.Field Service apijson.Field @@ -1767,136 +1709,79 @@ type pagesProjectsDeploymentConfigsProductionServicesServiceBindingJSON struct { ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionServicesServiceBinding) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionServicesServiceBinding) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionServicesServiceBindingJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionServicesServiceBindingJSON) RawJSON() string { return r.raw } // Vectorize bindings used for Pages Functions. -type PagesProjectsDeploymentConfigsProductionVectorizeBindings struct { +type ProjectDeploymentConfigsProductionVectorizeBindings struct { // Vectorize binding. - Vectorize PagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorize `json:"VECTORIZE"` - JSON pagesProjectsDeploymentConfigsProductionVectorizeBindingsJSON `json:"-"` + Vectorize ProjectDeploymentConfigsProductionVectorizeBindingsVectorize `json:"VECTORIZE"` + JSON projectDeploymentConfigsProductionVectorizeBindingsJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionVectorizeBindingsJSON contains the JSON -// metadata for the struct -// [PagesProjectsDeploymentConfigsProductionVectorizeBindings] -type pagesProjectsDeploymentConfigsProductionVectorizeBindingsJSON struct { +// projectDeploymentConfigsProductionVectorizeBindingsJSON contains the JSON +// metadata for the struct [ProjectDeploymentConfigsProductionVectorizeBindings] +type projectDeploymentConfigsProductionVectorizeBindingsJSON struct { Vectorize apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionVectorizeBindings) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionVectorizeBindings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionVectorizeBindingsJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionVectorizeBindingsJSON) RawJSON() string { return r.raw } // Vectorize binding. -type PagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorize struct { - IndexName string `json:"index_name"` - JSON pagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorizeJSON `json:"-"` +type ProjectDeploymentConfigsProductionVectorizeBindingsVectorize struct { + IndexName string `json:"index_name"` + JSON projectDeploymentConfigsProductionVectorizeBindingsVectorizeJSON `json:"-"` } -// pagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorizeJSON contains -// the JSON metadata for the struct -// [PagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorize] -type pagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorizeJSON struct { +// projectDeploymentConfigsProductionVectorizeBindingsVectorizeJSON contains the +// JSON metadata for the struct +// [ProjectDeploymentConfigsProductionVectorizeBindingsVectorize] +type projectDeploymentConfigsProductionVectorizeBindingsVectorizeJSON struct { IndexName apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorize) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectDeploymentConfigsProductionVectorizeBindingsVectorize) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pagesProjectsDeploymentConfigsProductionVectorizeBindingsVectorizeJSON) RawJSON() string { +func (r projectDeploymentConfigsProductionVectorizeBindingsVectorizeJSON) RawJSON() string { return r.raw } -// Union satisfied by [pages.ProjectNewResponseUnknown], -// [pages.ProjectNewResponseArray] or [shared.UnionString]. -type ProjectNewResponse interface { - ImplementsPagesProjectNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ProjectNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ProjectNewResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ProjectNewResponseArray []interface{} - -func (r ProjectNewResponseArray) ImplementsPagesProjectNewResponse() {} - -type ProjectDeleteResponse = interface{} - -// Union satisfied by [pages.ProjectEditResponseUnknown], -// [pages.ProjectEditResponseArray] or [shared.UnionString]. -type ProjectEditResponse interface { - ImplementsPagesProjectEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ProjectEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ProjectEditResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ProjectEditResponseArray []interface{} - -func (r ProjectEditResponseArray) ImplementsPagesProjectEditResponse() {} - -type ProjectPurgeBuildCacheResponse = interface{} - -type ProjectNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` +type ProjectParam struct { // Configs for the project build process. - BuildConfig param.Field[ProjectNewParamsBuildConfig] `json:"build_config"` - CanonicalDeployment param.Field[PagesDeploymentsParam] `json:"canonical_deployment"` + BuildConfig param.Field[ProjectBuildConfigParam] `json:"build_config"` + CanonicalDeployment param.Field[DeploymentParam] `json:"canonical_deployment"` // Configs for deployments in a project. - DeploymentConfigs param.Field[ProjectNewParamsDeploymentConfigs] `json:"deployment_configs"` - LatestDeployment param.Field[PagesDeploymentsParam] `json:"latest_deployment"` + DeploymentConfigs param.Field[ProjectDeploymentConfigsParam] `json:"deployment_configs"` + LatestDeployment param.Field[DeploymentParam] `json:"latest_deployment"` // Name of the project. Name param.Field[string] `json:"name"` // Production branch of the project. Used to identify production deployments. ProductionBranch param.Field[string] `json:"production_branch"` } -func (r ProjectNewParams) MarshalJSON() (data []byte, err error) { +func (r ProjectParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configs for the project build process. -type ProjectNewParamsBuildConfig struct { +type ProjectBuildConfigParam struct { // Enable build caching for the project. BuildCaching param.Field[bool] `json:"build_caching"` // Command used to build project. @@ -1911,309 +1796,293 @@ type ProjectNewParamsBuildConfig struct { WebAnalyticsToken param.Field[string] `json:"web_analytics_token"` } -func (r ProjectNewParamsBuildConfig) MarshalJSON() (data []byte, err error) { +func (r ProjectBuildConfigParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configs for deployments in a project. -type ProjectNewParamsDeploymentConfigs struct { +type ProjectDeploymentConfigsParam struct { // Configs for preview deploys. - Preview param.Field[ProjectNewParamsDeploymentConfigsPreview] `json:"preview"` + Preview param.Field[ProjectDeploymentConfigsPreviewParam] `json:"preview"` // Configs for production deploys. - Production param.Field[ProjectNewParamsDeploymentConfigsProduction] `json:"production"` + Production param.Field[ProjectDeploymentConfigsProductionParam] `json:"production"` } -func (r ProjectNewParamsDeploymentConfigs) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configs for preview deploys. -type ProjectNewParamsDeploymentConfigsPreview struct { +type ProjectDeploymentConfigsPreviewParam struct { // Constellation bindings used for Pages Functions. - AIBindings param.Field[ProjectNewParamsDeploymentConfigsPreviewAIBindings] `json:"ai_bindings"` + AIBindings param.Field[ProjectDeploymentConfigsPreviewAIBindingsParam] `json:"ai_bindings"` // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets param.Field[ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets] `json:"analytics_engine_datasets"` + AnalyticsEngineDatasets param.Field[ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsParam] `json:"analytics_engine_datasets"` // Browser bindings used for Pages Functions. - Browsers param.Field[ProjectNewParamsDeploymentConfigsPreviewBrowsers] `json:"browsers"` + Browsers param.Field[ProjectDeploymentConfigsPreviewBrowsersParam] `json:"browsers"` // Compatibility date used for Pages Functions. CompatibilityDate param.Field[string] `json:"compatibility_date"` // Compatibility flags used for Pages Functions. CompatibilityFlags param.Field[[]interface{}] `json:"compatibility_flags"` // D1 databases used for Pages Functions. - D1Databases param.Field[ProjectNewParamsDeploymentConfigsPreviewD1Databases] `json:"d1_databases"` + D1Databases param.Field[ProjectDeploymentConfigsPreviewD1DatabasesParam] `json:"d1_databases"` // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces param.Field[ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces] `json:"durable_object_namespaces"` + DurableObjectNamespaces param.Field[ProjectDeploymentConfigsPreviewDurableObjectNamespacesParam] `json:"durable_object_namespaces"` // Environment variables for build configs. - EnvVars param.Field[ProjectNewParamsDeploymentConfigsPreviewEnvVars] `json:"env_vars"` + EnvVars param.Field[ProjectDeploymentConfigsPreviewEnvVarsParam] `json:"env_vars"` // Hyperdrive bindings used for Pages Functions. - HyperdriveBindings param.Field[ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindings] `json:"hyperdrive_bindings"` + HyperdriveBindings param.Field[ProjectDeploymentConfigsPreviewHyperdriveBindingsParam] `json:"hyperdrive_bindings"` // KV namespaces used for Pages Functions. - KVNamespaces param.Field[ProjectNewParamsDeploymentConfigsPreviewKVNamespaces] `json:"kv_namespaces"` + KVNamespaces param.Field[ProjectDeploymentConfigsPreviewKVNamespacesParam] `json:"kv_namespaces"` // mTLS bindings used for Pages Functions. - MTLSCertificates param.Field[ProjectNewParamsDeploymentConfigsPreviewMTLSCertificates] `json:"mtls_certificates"` + MTLSCertificates param.Field[ProjectDeploymentConfigsPreviewMTLSCertificatesParam] `json:"mtls_certificates"` // Placement setting used for Pages Functions. - Placement param.Field[ProjectNewParamsDeploymentConfigsPreviewPlacement] `json:"placement"` + Placement param.Field[ProjectDeploymentConfigsPreviewPlacementParam] `json:"placement"` // Queue Producer bindings used for Pages Functions. - QueueProducers param.Field[ProjectNewParamsDeploymentConfigsPreviewQueueProducers] `json:"queue_producers"` + QueueProducers param.Field[ProjectDeploymentConfigsPreviewQueueProducersParam] `json:"queue_producers"` // R2 buckets used for Pages Functions. - R2Buckets param.Field[ProjectNewParamsDeploymentConfigsPreviewR2Buckets] `json:"r2_buckets"` + R2Buckets param.Field[ProjectDeploymentConfigsPreviewR2BucketsParam] `json:"r2_buckets"` // Services used for Pages Functions. - Services param.Field[ProjectNewParamsDeploymentConfigsPreviewServices] `json:"services"` + Services param.Field[ProjectDeploymentConfigsPreviewServicesParam] `json:"services"` // Vectorize bindings used for Pages Functions. - VectorizeBindings param.Field[ProjectNewParamsDeploymentConfigsPreviewVectorizeBindings] `json:"vectorize_bindings"` + VectorizeBindings param.Field[ProjectDeploymentConfigsPreviewVectorizeBindingsParam] `json:"vectorize_bindings"` } -func (r ProjectNewParamsDeploymentConfigsPreview) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Constellation bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewAIBindings struct { +type ProjectDeploymentConfigsPreviewAIBindingsParam struct { // AI binding. - AIBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding] `json:"AI_BINDING"` + AIBinding param.Field[ProjectDeploymentConfigsPreviewAIBindingsAIBindingParam] `json:"AI_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewAIBindings) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewAIBindingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // AI binding. -type ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding struct { +type ProjectDeploymentConfigsPreviewAIBindingsAIBindingParam struct { ProjectID param.Field[interface{}] `json:"project_id"` } -func (r ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewAIBindingsAIBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Analytics Engine bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets struct { +type ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsParam struct { // Analytics Engine binding. - AnalyticsEngineBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] `json:"ANALYTICS_ENGINE_BINDING"` + AnalyticsEngineBinding param.Field[ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingParam] `json:"ANALYTICS_ENGINE_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Analytics Engine binding. -type ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding struct { +type ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingParam struct { // Name of the dataset. Dataset param.Field[string] `json:"dataset"` } -func (r ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Browser bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewBrowsers struct { +type ProjectDeploymentConfigsPreviewBrowsersParam struct { // Browser binding. Browser param.Field[interface{}] `json:"BROWSER"` } -func (r ProjectNewParamsDeploymentConfigsPreviewBrowsers) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewBrowsersParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // D1 databases used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewD1Databases struct { +type ProjectDeploymentConfigsPreviewD1DatabasesParam struct { // D1 binding. - D1Binding param.Field[ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding] `json:"D1_BINDING"` + D1Binding param.Field[ProjectDeploymentConfigsPreviewD1DatabasesD1BindingParam] `json:"D1_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewD1Databases) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewD1DatabasesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // D1 binding. -type ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding struct { +type ProjectDeploymentConfigsPreviewD1DatabasesD1BindingParam struct { // UUID of the D1 database. ID param.Field[string] `json:"id"` } -func (r ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewD1DatabasesD1BindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Durabble Object namespaces used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces struct { +type ProjectDeploymentConfigsPreviewDurableObjectNamespacesParam struct { // Durabble Object binding. - DoBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding] `json:"DO_BINDING"` + DoBinding param.Field[ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingParam] `json:"DO_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewDurableObjectNamespacesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Durabble Object binding. -type ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding struct { +type ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingParam struct { // ID of the Durabble Object namespace. NamespaceID param.Field[string] `json:"namespace_id"` } -func (r ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Environment variables for build configs. -type ProjectNewParamsDeploymentConfigsPreviewEnvVars struct { +type ProjectDeploymentConfigsPreviewEnvVarsParam struct { // Environment variable. - EnvironmentVariable param.Field[ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable] `json:"ENVIRONMENT_VARIABLE"` + EnvironmentVariable param.Field[ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableParam] `json:"ENVIRONMENT_VARIABLE"` } -func (r ProjectNewParamsDeploymentConfigsPreviewEnvVars) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewEnvVarsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Environment variable. -type ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable struct { +type ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableParam struct { // The type of environment variable (plain text or secret) - Type param.Field[ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType] `json:"type"` + Type param.Field[ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableType] `json:"type"` // Environment variable value. Value param.Field[string] `json:"value"` } -func (r ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The type of environment variable (plain text or secret) -type ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType string - -const ( - ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "plain_text" - ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "secret_text" -) - -func (r ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType) IsKnown() bool { - switch r { - case ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText, ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText: - return true - } - return false -} - // Hyperdrive bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindings struct { +type ProjectDeploymentConfigsPreviewHyperdriveBindingsParam struct { // Hyperdrive binding. - Hyperdrive param.Field[ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive] `json:"HYPERDRIVE"` + Hyperdrive param.Field[ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveParam] `json:"HYPERDRIVE"` } -func (r ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindings) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewHyperdriveBindingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Hyperdrive binding. -type ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive struct { +type ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveParam struct { ID param.Field[string] `json:"id"` } -func (r ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // KV namespaces used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewKVNamespaces struct { +type ProjectDeploymentConfigsPreviewKVNamespacesParam struct { // KV binding. - KVBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding] `json:"KV_BINDING"` + KVBinding param.Field[ProjectDeploymentConfigsPreviewKVNamespacesKVBindingParam] `json:"KV_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewKVNamespaces) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewKVNamespacesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // KV binding. -type ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding struct { +type ProjectDeploymentConfigsPreviewKVNamespacesKVBindingParam struct { // ID of the KV namespace. NamespaceID param.Field[string] `json:"namespace_id"` } -func (r ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewKVNamespacesKVBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // mTLS bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewMTLSCertificates struct { +type ProjectDeploymentConfigsPreviewMTLSCertificatesParam struct { // mTLS binding. - MTLS param.Field[ProjectNewParamsDeploymentConfigsPreviewMTLSCertificatesMTLS] `json:"MTLS"` + MTLS param.Field[ProjectDeploymentConfigsPreviewMTLSCertificatesMTLSParam] `json:"MTLS"` } -func (r ProjectNewParamsDeploymentConfigsPreviewMTLSCertificates) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewMTLSCertificatesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // mTLS binding. -type ProjectNewParamsDeploymentConfigsPreviewMTLSCertificatesMTLS struct { +type ProjectDeploymentConfigsPreviewMTLSCertificatesMTLSParam struct { CertificateID param.Field[string] `json:"certificate_id"` } -func (r ProjectNewParamsDeploymentConfigsPreviewMTLSCertificatesMTLS) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewMTLSCertificatesMTLSParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Placement setting used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewPlacement struct { +type ProjectDeploymentConfigsPreviewPlacementParam struct { // Placement mode. Mode param.Field[string] `json:"mode"` } -func (r ProjectNewParamsDeploymentConfigsPreviewPlacement) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewPlacementParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Queue Producer bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewQueueProducers struct { +type ProjectDeploymentConfigsPreviewQueueProducersParam struct { // Queue Producer binding. - QueueProducerBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding] `json:"QUEUE_PRODUCER_BINDING"` + QueueProducerBinding param.Field[ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBindingParam] `json:"QUEUE_PRODUCER_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewQueueProducers) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewQueueProducersParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Queue Producer binding. -type ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding struct { +type ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBindingParam struct { // Name of the Queue. Name param.Field[string] `json:"name"` } -func (r ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // R2 buckets used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewR2Buckets struct { +type ProjectDeploymentConfigsPreviewR2BucketsParam struct { // R2 binding. - R2Binding param.Field[ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding] `json:"R2_BINDING"` + R2Binding param.Field[ProjectDeploymentConfigsPreviewR2BucketsR2BindingParam] `json:"R2_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewR2Buckets) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewR2BucketsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // R2 binding. -type ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding struct { +type ProjectDeploymentConfigsPreviewR2BucketsR2BindingParam struct { // Name of the R2 bucket. Name param.Field[string] `json:"name"` } -func (r ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewR2BucketsR2BindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Services used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewServices struct { +type ProjectDeploymentConfigsPreviewServicesParam struct { // Service binding. - ServiceBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewServicesServiceBinding] `json:"SERVICE_BINDING"` + ServiceBinding param.Field[ProjectDeploymentConfigsPreviewServicesServiceBindingParam] `json:"SERVICE_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsPreviewServices) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewServicesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Service binding. -type ProjectNewParamsDeploymentConfigsPreviewServicesServiceBinding struct { +type ProjectDeploymentConfigsPreviewServicesServiceBindingParam struct { // The entrypoint to bind to. Entrypoint param.Field[string] `json:"entrypoint"` // The Service environment. @@ -2222,316 +2091,300 @@ type ProjectNewParamsDeploymentConfigsPreviewServicesServiceBinding struct { Service param.Field[string] `json:"service"` } -func (r ProjectNewParamsDeploymentConfigsPreviewServicesServiceBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewServicesServiceBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Vectorize bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsPreviewVectorizeBindings struct { +type ProjectDeploymentConfigsPreviewVectorizeBindingsParam struct { // Vectorize binding. - Vectorize param.Field[ProjectNewParamsDeploymentConfigsPreviewVectorizeBindingsVectorize] `json:"VECTORIZE"` + Vectorize param.Field[ProjectDeploymentConfigsPreviewVectorizeBindingsVectorizeParam] `json:"VECTORIZE"` } -func (r ProjectNewParamsDeploymentConfigsPreviewVectorizeBindings) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewVectorizeBindingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Vectorize binding. -type ProjectNewParamsDeploymentConfigsPreviewVectorizeBindingsVectorize struct { +type ProjectDeploymentConfigsPreviewVectorizeBindingsVectorizeParam struct { IndexName param.Field[string] `json:"index_name"` } -func (r ProjectNewParamsDeploymentConfigsPreviewVectorizeBindingsVectorize) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsPreviewVectorizeBindingsVectorizeParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configs for production deploys. -type ProjectNewParamsDeploymentConfigsProduction struct { +type ProjectDeploymentConfigsProductionParam struct { // Constellation bindings used for Pages Functions. - AIBindings param.Field[ProjectNewParamsDeploymentConfigsProductionAIBindings] `json:"ai_bindings"` + AIBindings param.Field[ProjectDeploymentConfigsProductionAIBindingsParam] `json:"ai_bindings"` // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets param.Field[ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets] `json:"analytics_engine_datasets"` + AnalyticsEngineDatasets param.Field[ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsParam] `json:"analytics_engine_datasets"` // Browser bindings used for Pages Functions. - Browsers param.Field[ProjectNewParamsDeploymentConfigsProductionBrowsers] `json:"browsers"` + Browsers param.Field[ProjectDeploymentConfigsProductionBrowsersParam] `json:"browsers"` // Compatibility date used for Pages Functions. CompatibilityDate param.Field[string] `json:"compatibility_date"` // Compatibility flags used for Pages Functions. CompatibilityFlags param.Field[[]interface{}] `json:"compatibility_flags"` // D1 databases used for Pages Functions. - D1Databases param.Field[ProjectNewParamsDeploymentConfigsProductionD1Databases] `json:"d1_databases"` + D1Databases param.Field[ProjectDeploymentConfigsProductionD1DatabasesParam] `json:"d1_databases"` // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces param.Field[ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces] `json:"durable_object_namespaces"` + DurableObjectNamespaces param.Field[ProjectDeploymentConfigsProductionDurableObjectNamespacesParam] `json:"durable_object_namespaces"` // Environment variables for build configs. - EnvVars param.Field[ProjectNewParamsDeploymentConfigsProductionEnvVars] `json:"env_vars"` + EnvVars param.Field[ProjectDeploymentConfigsProductionEnvVarsParam] `json:"env_vars"` // Hyperdrive bindings used for Pages Functions. - HyperdriveBindings param.Field[ProjectNewParamsDeploymentConfigsProductionHyperdriveBindings] `json:"hyperdrive_bindings"` + HyperdriveBindings param.Field[ProjectDeploymentConfigsProductionHyperdriveBindingsParam] `json:"hyperdrive_bindings"` // KV namespaces used for Pages Functions. - KVNamespaces param.Field[ProjectNewParamsDeploymentConfigsProductionKVNamespaces] `json:"kv_namespaces"` + KVNamespaces param.Field[ProjectDeploymentConfigsProductionKVNamespacesParam] `json:"kv_namespaces"` // mTLS bindings used for Pages Functions. - MTLSCertificates param.Field[ProjectNewParamsDeploymentConfigsProductionMTLSCertificates] `json:"mtls_certificates"` + MTLSCertificates param.Field[ProjectDeploymentConfigsProductionMTLSCertificatesParam] `json:"mtls_certificates"` // Placement setting used for Pages Functions. - Placement param.Field[ProjectNewParamsDeploymentConfigsProductionPlacement] `json:"placement"` + Placement param.Field[ProjectDeploymentConfigsProductionPlacementParam] `json:"placement"` // Queue Producer bindings used for Pages Functions. - QueueProducers param.Field[ProjectNewParamsDeploymentConfigsProductionQueueProducers] `json:"queue_producers"` + QueueProducers param.Field[ProjectDeploymentConfigsProductionQueueProducersParam] `json:"queue_producers"` // R2 buckets used for Pages Functions. - R2Buckets param.Field[ProjectNewParamsDeploymentConfigsProductionR2Buckets] `json:"r2_buckets"` + R2Buckets param.Field[ProjectDeploymentConfigsProductionR2BucketsParam] `json:"r2_buckets"` // Services used for Pages Functions. - Services param.Field[ProjectNewParamsDeploymentConfigsProductionServices] `json:"services"` + Services param.Field[ProjectDeploymentConfigsProductionServicesParam] `json:"services"` // Vectorize bindings used for Pages Functions. - VectorizeBindings param.Field[ProjectNewParamsDeploymentConfigsProductionVectorizeBindings] `json:"vectorize_bindings"` + VectorizeBindings param.Field[ProjectDeploymentConfigsProductionVectorizeBindingsParam] `json:"vectorize_bindings"` } -func (r ProjectNewParamsDeploymentConfigsProduction) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Constellation bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionAIBindings struct { +type ProjectDeploymentConfigsProductionAIBindingsParam struct { // AI binding. - AIBinding param.Field[ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding] `json:"AI_BINDING"` + AIBinding param.Field[ProjectDeploymentConfigsProductionAIBindingsAIBindingParam] `json:"AI_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionAIBindings) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionAIBindingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // AI binding. -type ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding struct { +type ProjectDeploymentConfigsProductionAIBindingsAIBindingParam struct { ProjectID param.Field[interface{}] `json:"project_id"` } -func (r ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionAIBindingsAIBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Analytics Engine bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets struct { +type ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsParam struct { // Analytics Engine binding. - AnalyticsEngineBinding param.Field[ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] `json:"ANALYTICS_ENGINE_BINDING"` + AnalyticsEngineBinding param.Field[ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingParam] `json:"ANALYTICS_ENGINE_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Analytics Engine binding. -type ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding struct { +type ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingParam struct { // Name of the dataset. Dataset param.Field[string] `json:"dataset"` } -func (r ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Browser bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionBrowsers struct { +type ProjectDeploymentConfigsProductionBrowsersParam struct { // Browser binding. Browser param.Field[interface{}] `json:"BROWSER"` } -func (r ProjectNewParamsDeploymentConfigsProductionBrowsers) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionBrowsersParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // D1 databases used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionD1Databases struct { +type ProjectDeploymentConfigsProductionD1DatabasesParam struct { // D1 binding. - D1Binding param.Field[ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding] `json:"D1_BINDING"` + D1Binding param.Field[ProjectDeploymentConfigsProductionD1DatabasesD1BindingParam] `json:"D1_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionD1Databases) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionD1DatabasesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // D1 binding. -type ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding struct { +type ProjectDeploymentConfigsProductionD1DatabasesD1BindingParam struct { // UUID of the D1 database. ID param.Field[string] `json:"id"` } -func (r ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionD1DatabasesD1BindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Durabble Object namespaces used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces struct { +type ProjectDeploymentConfigsProductionDurableObjectNamespacesParam struct { // Durabble Object binding. - DoBinding param.Field[ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding] `json:"DO_BINDING"` + DoBinding param.Field[ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBindingParam] `json:"DO_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionDurableObjectNamespacesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Durabble Object binding. -type ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding struct { +type ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBindingParam struct { // ID of the Durabble Object namespace. NamespaceID param.Field[string] `json:"namespace_id"` } -func (r ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Environment variables for build configs. -type ProjectNewParamsDeploymentConfigsProductionEnvVars struct { +type ProjectDeploymentConfigsProductionEnvVarsParam struct { // Environment variable. - EnvironmentVariable param.Field[ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable] `json:"ENVIRONMENT_VARIABLE"` + EnvironmentVariable param.Field[ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableParam] `json:"ENVIRONMENT_VARIABLE"` } -func (r ProjectNewParamsDeploymentConfigsProductionEnvVars) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionEnvVarsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Environment variable. -type ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable struct { +type ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableParam struct { // The type of environment variable (plain text or secret) - Type param.Field[ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType] `json:"type"` + Type param.Field[ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableType] `json:"type"` // Environment variable value. Value param.Field[string] `json:"value"` } -func (r ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The type of environment variable (plain text or secret) -type ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType string - -const ( - ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "plain_text" - ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "secret_text" -) - -func (r ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType) IsKnown() bool { - switch r { - case ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText, ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText: - return true - } - return false -} - // Hyperdrive bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionHyperdriveBindings struct { +type ProjectDeploymentConfigsProductionHyperdriveBindingsParam struct { // Hyperdrive binding. - Hyperdrive param.Field[ProjectNewParamsDeploymentConfigsProductionHyperdriveBindingsHyperdrive] `json:"HYPERDRIVE"` + Hyperdrive param.Field[ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdriveParam] `json:"HYPERDRIVE"` } -func (r ProjectNewParamsDeploymentConfigsProductionHyperdriveBindings) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionHyperdriveBindingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Hyperdrive binding. -type ProjectNewParamsDeploymentConfigsProductionHyperdriveBindingsHyperdrive struct { +type ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdriveParam struct { ID param.Field[string] `json:"id"` } -func (r ProjectNewParamsDeploymentConfigsProductionHyperdriveBindingsHyperdrive) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdriveParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // KV namespaces used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionKVNamespaces struct { +type ProjectDeploymentConfigsProductionKVNamespacesParam struct { // KV binding. - KVBinding param.Field[ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding] `json:"KV_BINDING"` + KVBinding param.Field[ProjectDeploymentConfigsProductionKVNamespacesKVBindingParam] `json:"KV_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionKVNamespaces) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionKVNamespacesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // KV binding. -type ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding struct { +type ProjectDeploymentConfigsProductionKVNamespacesKVBindingParam struct { // ID of the KV namespace. NamespaceID param.Field[string] `json:"namespace_id"` } -func (r ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionKVNamespacesKVBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // mTLS bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionMTLSCertificates struct { +type ProjectDeploymentConfigsProductionMTLSCertificatesParam struct { // mTLS binding. - MTLS param.Field[ProjectNewParamsDeploymentConfigsProductionMTLSCertificatesMTLS] `json:"MTLS"` + MTLS param.Field[ProjectDeploymentConfigsProductionMTLSCertificatesMTLSParam] `json:"MTLS"` } -func (r ProjectNewParamsDeploymentConfigsProductionMTLSCertificates) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionMTLSCertificatesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // mTLS binding. -type ProjectNewParamsDeploymentConfigsProductionMTLSCertificatesMTLS struct { +type ProjectDeploymentConfigsProductionMTLSCertificatesMTLSParam struct { CertificateID param.Field[string] `json:"certificate_id"` } -func (r ProjectNewParamsDeploymentConfigsProductionMTLSCertificatesMTLS) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionMTLSCertificatesMTLSParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Placement setting used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionPlacement struct { +type ProjectDeploymentConfigsProductionPlacementParam struct { // Placement mode. Mode param.Field[string] `json:"mode"` } -func (r ProjectNewParamsDeploymentConfigsProductionPlacement) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionPlacementParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Queue Producer bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionQueueProducers struct { +type ProjectDeploymentConfigsProductionQueueProducersParam struct { // Queue Producer binding. - QueueProducerBinding param.Field[ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding] `json:"QUEUE_PRODUCER_BINDING"` + QueueProducerBinding param.Field[ProjectDeploymentConfigsProductionQueueProducersQueueProducerBindingParam] `json:"QUEUE_PRODUCER_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionQueueProducers) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionQueueProducersParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Queue Producer binding. -type ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding struct { +type ProjectDeploymentConfigsProductionQueueProducersQueueProducerBindingParam struct { // Name of the Queue. Name param.Field[string] `json:"name"` } -func (r ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionQueueProducersQueueProducerBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // R2 buckets used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionR2Buckets struct { +type ProjectDeploymentConfigsProductionR2BucketsParam struct { // R2 binding. - R2Binding param.Field[ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding] `json:"R2_BINDING"` + R2Binding param.Field[ProjectDeploymentConfigsProductionR2BucketsR2BindingParam] `json:"R2_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionR2Buckets) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionR2BucketsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // R2 binding. -type ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding struct { +type ProjectDeploymentConfigsProductionR2BucketsR2BindingParam struct { // Name of the R2 bucket. Name param.Field[string] `json:"name"` } -func (r ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionR2BucketsR2BindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Services used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionServices struct { +type ProjectDeploymentConfigsProductionServicesParam struct { // Service binding. - ServiceBinding param.Field[ProjectNewParamsDeploymentConfigsProductionServicesServiceBinding] `json:"SERVICE_BINDING"` + ServiceBinding param.Field[ProjectDeploymentConfigsProductionServicesServiceBindingParam] `json:"SERVICE_BINDING"` } -func (r ProjectNewParamsDeploymentConfigsProductionServices) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionServicesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Service binding. -type ProjectNewParamsDeploymentConfigsProductionServicesServiceBinding struct { +type ProjectDeploymentConfigsProductionServicesServiceBindingParam struct { // The entrypoint to bind to. Entrypoint param.Field[string] `json:"entrypoint"` // The Service environment. @@ -2540,100 +2393,159 @@ type ProjectNewParamsDeploymentConfigsProductionServicesServiceBinding struct { Service param.Field[string] `json:"service"` } -func (r ProjectNewParamsDeploymentConfigsProductionServicesServiceBinding) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionServicesServiceBindingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Vectorize bindings used for Pages Functions. -type ProjectNewParamsDeploymentConfigsProductionVectorizeBindings struct { +type ProjectDeploymentConfigsProductionVectorizeBindingsParam struct { // Vectorize binding. - Vectorize param.Field[ProjectNewParamsDeploymentConfigsProductionVectorizeBindingsVectorize] `json:"VECTORIZE"` + Vectorize param.Field[ProjectDeploymentConfigsProductionVectorizeBindingsVectorizeParam] `json:"VECTORIZE"` } -func (r ProjectNewParamsDeploymentConfigsProductionVectorizeBindings) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionVectorizeBindingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Vectorize binding. -type ProjectNewParamsDeploymentConfigsProductionVectorizeBindingsVectorize struct { +type ProjectDeploymentConfigsProductionVectorizeBindingsVectorizeParam struct { IndexName param.Field[string] `json:"index_name"` } -func (r ProjectNewParamsDeploymentConfigsProductionVectorizeBindingsVectorize) MarshalJSON() (data []byte, err error) { +func (r ProjectDeploymentConfigsProductionVectorizeBindingsVectorizeParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type ProjectNewResponseEnvelope struct { - Errors []ProjectNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectNewResponseEnvelopeMessages `json:"messages,required"` - Result ProjectNewResponse `json:"result,required"` - // Whether the API call was successful - Success ProjectNewResponseEnvelopeSuccess `json:"success,required"` - JSON projectNewResponseEnvelopeJSON `json:"-"` +// The status of the deployment. +type Stage struct { + // When the stage ended. + EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` + // The current build stage. + Name string `json:"name"` + // When the stage started. + StartedOn time.Time `json:"started_on,nullable" format:"date-time"` + // State of the current stage. + Status string `json:"status"` + JSON stageJSON `json:"-"` } -// projectNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [ProjectNewResponseEnvelope] -type projectNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field +// stageJSON contains the JSON metadata for the struct [Stage] +type stageJSON struct { + EndedOn apijson.Field + Name apijson.Field + StartedOn apijson.Field + Status apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ProjectNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *Stage) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r projectNewResponseEnvelopeJSON) RawJSON() string { +func (r stageJSON) RawJSON() string { return r.raw } -type ProjectNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectNewResponseEnvelopeErrorsJSON `json:"-"` +// The status of the deployment. +type StageParam struct { + // The current build stage. + Name param.Field[string] `json:"name"` } -// projectNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ProjectNewResponseEnvelopeErrors] -type projectNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r StageParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *ProjectNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [pages.ProjectNewResponseUnknown], +// [pages.ProjectNewResponseArray] or [shared.UnionString]. +type ProjectNewResponseUnion interface { + ImplementsPagesProjectNewResponseUnion() } -func (r projectNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectNewResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectNewResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -type ProjectNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectNewResponseEnvelopeMessagesJSON `json:"-"` +type ProjectNewResponseArray []interface{} + +func (r ProjectNewResponseArray) ImplementsPagesProjectNewResponseUnion() {} + +type ProjectDeleteResponse = interface{} + +// Union satisfied by [pages.ProjectEditResponseUnknown], +// [pages.ProjectEditResponseArray] or [shared.UnionString]. +type ProjectEditResponseUnion interface { + ImplementsPagesProjectEditResponseUnion() } -// projectNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ProjectNewResponseEnvelopeMessages] -type projectNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectEditResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectEditResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProjectEditResponseArray []interface{} + +func (r ProjectEditResponseArray) ImplementsPagesProjectEditResponseUnion() {} + +type ProjectPurgeBuildCacheResponse = interface{} + +type ProjectNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Project ProjectParam `json:"project,required"` +} + +func (r ProjectNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Project) +} + +type ProjectNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProjectNewResponseUnion `json:"result,required"` + // Whether the API call was successful + Success ProjectNewResponseEnvelopeSuccess `json:"success,required"` + JSON projectNewResponseEnvelopeJSON `json:"-"` +} + +// projectNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectNewResponseEnvelope] +type projectNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ProjectNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *ProjectNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r projectNewResponseEnvelopeMessagesJSON) RawJSON() string { +func (r projectNewResponseEnvelopeJSON) RawJSON() string { return r.raw } @@ -2660,12 +2572,17 @@ type ProjectListParams struct { type ProjectDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ProjectDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ProjectEditParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r ProjectEditParams) MarshalJSON() (data []byte, err error) { @@ -2673,9 +2590,9 @@ func (r ProjectEditParams) MarshalJSON() (data []byte, err error) { } type ProjectEditResponseEnvelope struct { - Errors []ProjectEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectEditResponseEnvelopeMessages `json:"messages,required"` - Result ProjectEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProjectEditResponseUnion `json:"result,required"` // Whether the API call was successful Success ProjectEditResponseEnvelopeSuccess `json:"success,required"` JSON projectEditResponseEnvelopeJSON `json:"-"` @@ -2700,52 +2617,6 @@ func (r projectEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ProjectEditResponseEnvelopeErrors] -type projectEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ProjectEditResponseEnvelopeMessages] -type projectEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectEditResponseEnvelopeSuccess bool @@ -2767,9 +2638,9 @@ type ProjectGetParams struct { } type ProjectGetResponseEnvelope struct { - Errors []ProjectGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectGetResponseEnvelopeMessages `json:"messages,required"` - Result PagesProjects `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Project `json:"result,required"` // Whether the API call was successful Success ProjectGetResponseEnvelopeSuccess `json:"success,required"` JSON projectGetResponseEnvelopeJSON `json:"-"` @@ -2794,52 +2665,6 @@ func (r projectGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ProjectGetResponseEnvelopeErrors] -type projectGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ProjectGetResponseEnvelopeMessages] -type projectGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectGetResponseEnvelopeSuccess bool diff --git a/pages/project_test.go b/pages/project_test.go index 37c27509daf..5b8aab66c82 100644 --- a/pages/project_test.go +++ b/pages/project_test.go @@ -30,166 +30,168 @@ func TestProjectNewWithOptionalParams(t *testing.T) { ) _, err := client.Pages.Projects.New(context.TODO(), pages.ProjectNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - BuildConfig: cloudflare.F(pages.ProjectNewParamsBuildConfig{ - BuildCaching: cloudflare.F(true), - BuildCommand: cloudflare.F("npm run build"), - DestinationDir: cloudflare.F("build"), - RootDir: cloudflare.F("/"), - WebAnalyticsTag: cloudflare.F("cee1c73f6e4743d0b5e6bb1a0bcaabcc"), - WebAnalyticsToken: cloudflare.F("021e1057c18547eca7b79f2516f06o7x"), - }), - CanonicalDeployment: cloudflare.F(pages.PagesDeploymentsParam{}), - DeploymentConfigs: cloudflare.F(pages.ProjectNewParamsDeploymentConfigs{ - Preview: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreview{ - AIBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAIBindings{ - AIBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding{ - ProjectID: cloudflare.F[any](map[string]interface{}{}), + Project: pages.ProjectParam{ + BuildConfig: cloudflare.F(pages.ProjectBuildConfigParam{ + BuildCaching: cloudflare.F(true), + BuildCommand: cloudflare.F("npm run build"), + DestinationDir: cloudflare.F("build"), + RootDir: cloudflare.F("/"), + WebAnalyticsTag: cloudflare.F("cee1c73f6e4743d0b5e6bb1a0bcaabcc"), + WebAnalyticsToken: cloudflare.F("021e1057c18547eca7b79f2516f06o7x"), + }), + CanonicalDeployment: cloudflare.F(pages.DeploymentParam{}), + DeploymentConfigs: cloudflare.F(pages.ProjectDeploymentConfigsParam{ + Preview: cloudflare.F(pages.ProjectDeploymentConfigsPreviewParam{ + AIBindings: cloudflare.F(pages.ProjectDeploymentConfigsPreviewAIBindingsParam{ + AIBinding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewAIBindingsAIBindingParam{ + ProjectID: cloudflare.F[any](map[string]interface{}{}), + }), }), - }), - AnalyticsEngineDatasets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets{ - AnalyticsEngineBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding{ - Dataset: cloudflare.F("api_analytics"), + AnalyticsEngineDatasets: cloudflare.F(pages.ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsParam{ + AnalyticsEngineBinding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingParam{ + Dataset: cloudflare.F("api_analytics"), + }), }), - }), - Browsers: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewBrowsers{ - Browser: cloudflare.F[any](map[string]interface{}{}), - }), - CompatibilityDate: cloudflare.F("2022-01-01"), - CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), - D1Databases: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewD1Databases{ - D1Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding{ - ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), + Browsers: cloudflare.F(pages.ProjectDeploymentConfigsPreviewBrowsersParam{ + Browser: cloudflare.F[any](map[string]interface{}{}), }), - }), - DurableObjectNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces{ - DoBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + CompatibilityDate: cloudflare.F("2022-01-01"), + CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), + D1Databases: cloudflare.F(pages.ProjectDeploymentConfigsPreviewD1DatabasesParam{ + D1Binding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewD1DatabasesD1BindingParam{ + ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), + }), }), - }), - EnvVars: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewEnvVars{ - EnvironmentVariable: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable{ - Type: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText), - Value: cloudflare.F("hello world"), + DurableObjectNamespaces: cloudflare.F(pages.ProjectDeploymentConfigsPreviewDurableObjectNamespacesParam{ + DoBinding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewDurableObjectNamespacesDoBindingParam{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), }), - }), - HyperdriveBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindings{ - Hyperdrive: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewHyperdriveBindingsHyperdrive{ - ID: cloudflare.F("a76a99bc342644deb02c38d66082262a"), + EnvVars: cloudflare.F(pages.ProjectDeploymentConfigsPreviewEnvVarsParam{ + EnvironmentVariable: cloudflare.F(pages.ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableParam{ + Type: cloudflare.F(pages.ProjectDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText), + Value: cloudflare.F("hello world"), + }), }), - }), - KVNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewKVNamespaces{ - KVBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + HyperdriveBindings: cloudflare.F(pages.ProjectDeploymentConfigsPreviewHyperdriveBindingsParam{ + Hyperdrive: cloudflare.F(pages.ProjectDeploymentConfigsPreviewHyperdriveBindingsHyperdriveParam{ + ID: cloudflare.F("a76a99bc342644deb02c38d66082262a"), + }), }), - }), - MTLSCertificates: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewMTLSCertificates{ - MTLS: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewMTLSCertificatesMTLS{ - CertificateID: cloudflare.F("d7cdd17c-916f-4cb7-aabe-585eb382ec4e"), + KVNamespaces: cloudflare.F(pages.ProjectDeploymentConfigsPreviewKVNamespacesParam{ + KVBinding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewKVNamespacesKVBindingParam{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), }), - }), - Placement: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewPlacement{ - Mode: cloudflare.F("smart"), - }), - QueueProducers: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewQueueProducers{ - QueueProducerBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding{ - Name: cloudflare.F("some-queue"), + MTLSCertificates: cloudflare.F(pages.ProjectDeploymentConfigsPreviewMTLSCertificatesParam{ + MTLS: cloudflare.F(pages.ProjectDeploymentConfigsPreviewMTLSCertificatesMTLSParam{ + CertificateID: cloudflare.F("d7cdd17c-916f-4cb7-aabe-585eb382ec4e"), + }), }), - }), - R2Buckets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewR2Buckets{ - R2Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding{ - Name: cloudflare.F("some-bucket"), + Placement: cloudflare.F(pages.ProjectDeploymentConfigsPreviewPlacementParam{ + Mode: cloudflare.F("smart"), }), - }), - Services: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewServices{ - ServiceBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewServicesServiceBinding{ - Entrypoint: cloudflare.F("MyHandler"), - Environment: cloudflare.F("production"), - Service: cloudflare.F("example-worker"), + QueueProducers: cloudflare.F(pages.ProjectDeploymentConfigsPreviewQueueProducersParam{ + QueueProducerBinding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewQueueProducersQueueProducerBindingParam{ + Name: cloudflare.F("some-queue"), + }), }), - }), - VectorizeBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewVectorizeBindings{ - Vectorize: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewVectorizeBindingsVectorize{ - IndexName: cloudflare.F("my_index"), + R2Buckets: cloudflare.F(pages.ProjectDeploymentConfigsPreviewR2BucketsParam{ + R2Binding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewR2BucketsR2BindingParam{ + Name: cloudflare.F("some-bucket"), + }), }), - }), - }), - Production: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProduction{ - AIBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAIBindings{ - AIBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding{ - ProjectID: cloudflare.F[any](map[string]interface{}{}), + Services: cloudflare.F(pages.ProjectDeploymentConfigsPreviewServicesParam{ + ServiceBinding: cloudflare.F(pages.ProjectDeploymentConfigsPreviewServicesServiceBindingParam{ + Entrypoint: cloudflare.F("MyHandler"), + Environment: cloudflare.F("production"), + Service: cloudflare.F("example-worker"), + }), }), - }), - AnalyticsEngineDatasets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets{ - AnalyticsEngineBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding{ - Dataset: cloudflare.F("api_analytics"), + VectorizeBindings: cloudflare.F(pages.ProjectDeploymentConfigsPreviewVectorizeBindingsParam{ + Vectorize: cloudflare.F(pages.ProjectDeploymentConfigsPreviewVectorizeBindingsVectorizeParam{ + IndexName: cloudflare.F("my_index"), + }), }), }), - Browsers: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionBrowsers{ - Browser: cloudflare.F[any](map[string]interface{}{}), - }), - CompatibilityDate: cloudflare.F("2022-01-01"), - CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), - D1Databases: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionD1Databases{ - D1Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding{ - ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), + Production: cloudflare.F(pages.ProjectDeploymentConfigsProductionParam{ + AIBindings: cloudflare.F(pages.ProjectDeploymentConfigsProductionAIBindingsParam{ + AIBinding: cloudflare.F(pages.ProjectDeploymentConfigsProductionAIBindingsAIBindingParam{ + ProjectID: cloudflare.F[any](map[string]interface{}{}), + }), }), - }), - DurableObjectNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces{ - DoBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + AnalyticsEngineDatasets: cloudflare.F(pages.ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsParam{ + AnalyticsEngineBinding: cloudflare.F(pages.ProjectDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingParam{ + Dataset: cloudflare.F("api_analytics"), + }), }), - }), - EnvVars: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionEnvVars{ - EnvironmentVariable: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable{ - Type: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText), - Value: cloudflare.F("hello world"), + Browsers: cloudflare.F(pages.ProjectDeploymentConfigsProductionBrowsersParam{ + Browser: cloudflare.F[any](map[string]interface{}{}), }), - }), - HyperdriveBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionHyperdriveBindings{ - Hyperdrive: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionHyperdriveBindingsHyperdrive{ - ID: cloudflare.F("a76a99bc342644deb02c38d66082262a"), + CompatibilityDate: cloudflare.F("2022-01-01"), + CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), + D1Databases: cloudflare.F(pages.ProjectDeploymentConfigsProductionD1DatabasesParam{ + D1Binding: cloudflare.F(pages.ProjectDeploymentConfigsProductionD1DatabasesD1BindingParam{ + ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), + }), }), - }), - KVNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionKVNamespaces{ - KVBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + DurableObjectNamespaces: cloudflare.F(pages.ProjectDeploymentConfigsProductionDurableObjectNamespacesParam{ + DoBinding: cloudflare.F(pages.ProjectDeploymentConfigsProductionDurableObjectNamespacesDoBindingParam{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), }), - }), - MTLSCertificates: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionMTLSCertificates{ - MTLS: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionMTLSCertificatesMTLS{ - CertificateID: cloudflare.F("d7cdd17c-916f-4cb7-aabe-585eb382ec4e"), + EnvVars: cloudflare.F(pages.ProjectDeploymentConfigsProductionEnvVarsParam{ + EnvironmentVariable: cloudflare.F(pages.ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableParam{ + Type: cloudflare.F(pages.ProjectDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText), + Value: cloudflare.F("hello world"), + }), }), - }), - Placement: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionPlacement{ - Mode: cloudflare.F("smart"), - }), - QueueProducers: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionQueueProducers{ - QueueProducerBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding{ - Name: cloudflare.F("some-queue"), + HyperdriveBindings: cloudflare.F(pages.ProjectDeploymentConfigsProductionHyperdriveBindingsParam{ + Hyperdrive: cloudflare.F(pages.ProjectDeploymentConfigsProductionHyperdriveBindingsHyperdriveParam{ + ID: cloudflare.F("a76a99bc342644deb02c38d66082262a"), + }), }), - }), - R2Buckets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionR2Buckets{ - R2Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding{ - Name: cloudflare.F("some-bucket"), + KVNamespaces: cloudflare.F(pages.ProjectDeploymentConfigsProductionKVNamespacesParam{ + KVBinding: cloudflare.F(pages.ProjectDeploymentConfigsProductionKVNamespacesKVBindingParam{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), }), - }), - Services: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionServices{ - ServiceBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionServicesServiceBinding{ - Entrypoint: cloudflare.F("MyHandler"), - Environment: cloudflare.F("production"), - Service: cloudflare.F("example-worker"), + MTLSCertificates: cloudflare.F(pages.ProjectDeploymentConfigsProductionMTLSCertificatesParam{ + MTLS: cloudflare.F(pages.ProjectDeploymentConfigsProductionMTLSCertificatesMTLSParam{ + CertificateID: cloudflare.F("d7cdd17c-916f-4cb7-aabe-585eb382ec4e"), + }), }), - }), - VectorizeBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionVectorizeBindings{ - Vectorize: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionVectorizeBindingsVectorize{ - IndexName: cloudflare.F("my_index"), + Placement: cloudflare.F(pages.ProjectDeploymentConfigsProductionPlacementParam{ + Mode: cloudflare.F("smart"), + }), + QueueProducers: cloudflare.F(pages.ProjectDeploymentConfigsProductionQueueProducersParam{ + QueueProducerBinding: cloudflare.F(pages.ProjectDeploymentConfigsProductionQueueProducersQueueProducerBindingParam{ + Name: cloudflare.F("some-queue"), + }), + }), + R2Buckets: cloudflare.F(pages.ProjectDeploymentConfigsProductionR2BucketsParam{ + R2Binding: cloudflare.F(pages.ProjectDeploymentConfigsProductionR2BucketsR2BindingParam{ + Name: cloudflare.F("some-bucket"), + }), + }), + Services: cloudflare.F(pages.ProjectDeploymentConfigsProductionServicesParam{ + ServiceBinding: cloudflare.F(pages.ProjectDeploymentConfigsProductionServicesServiceBindingParam{ + Entrypoint: cloudflare.F("MyHandler"), + Environment: cloudflare.F("production"), + Service: cloudflare.F("example-worker"), + }), + }), + VectorizeBindings: cloudflare.F(pages.ProjectDeploymentConfigsProductionVectorizeBindingsParam{ + Vectorize: cloudflare.F(pages.ProjectDeploymentConfigsProductionVectorizeBindingsVectorizeParam{ + IndexName: cloudflare.F("my_index"), + }), }), }), }), - }), - LatestDeployment: cloudflare.F(pages.PagesDeploymentsParam{}), - Name: cloudflare.F("NextJS Blog"), - ProductionBranch: cloudflare.F("main"), + LatestDeployment: cloudflare.F(pages.DeploymentParam{}), + Name: cloudflare.F("NextJS Blog"), + ProductionBranch: cloudflare.F("main"), + }, }) if err != nil { var apierr *cloudflare.Error @@ -245,6 +247,7 @@ func TestProjectDelete(t *testing.T) { "this-is-my-project-01", pages.ProjectDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -275,7 +278,7 @@ func TestProjectEdit(t *testing.T) { "this-is-my-project-01", pages.ProjectEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ + Body: map[string]interface{}{ "deployment_configs": map[string]interface{}{ "production": map[string]interface{}{ "compatibility_date": "2022-01-01", @@ -294,7 +297,7 @@ func TestProjectEdit(t *testing.T) { }, }, }, - }), + }, }, ) if err != nil { diff --git a/pages/projectdeployment.go b/pages/projectdeployment.go index a0e696d3b10..2504a97fce3 100644 --- a/pages/projectdeployment.go +++ b/pages/projectdeployment.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -38,7 +39,7 @@ func NewProjectDeploymentService(opts ...option.RequestOption) (r *ProjectDeploy // Start a new deployment from production. The repository and account must have // already been authorized on the Cloudflare Pages dashboard. -func (r *ProjectDeploymentService) New(ctx context.Context, projectName string, params ProjectDeploymentNewParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { +func (r *ProjectDeploymentService) New(ctx context.Context, projectName string, params ProjectDeploymentNewParams, opts ...option.RequestOption) (res *Deployment, err error) { opts = append(r.Options[:], opts...) var env ProjectDeploymentNewResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments", params.AccountID, projectName) @@ -51,7 +52,7 @@ func (r *ProjectDeploymentService) New(ctx context.Context, projectName string, } // Fetch a list of project deployments. -func (r *ProjectDeploymentService) List(ctx context.Context, projectName string, params ProjectDeploymentListParams, opts ...option.RequestOption) (res *pagination.SinglePage[PagesDeployments], err error) { +func (r *ProjectDeploymentService) List(ctx context.Context, projectName string, params ProjectDeploymentListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Deployment], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -69,20 +70,20 @@ func (r *ProjectDeploymentService) List(ctx context.Context, projectName string, } // Fetch a list of project deployments. -func (r *ProjectDeploymentService) ListAutoPaging(ctx context.Context, projectName string, params ProjectDeploymentListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[PagesDeployments] { +func (r *ProjectDeploymentService) ListAutoPaging(ctx context.Context, projectName string, params ProjectDeploymentListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Deployment] { return pagination.NewSinglePageAutoPager(r.List(ctx, projectName, params, opts...)) } // Delete a deployment. -func (r *ProjectDeploymentService) Delete(ctx context.Context, projectName string, deploymentID string, body ProjectDeploymentDeleteParams, opts ...option.RequestOption) (res *ProjectDeploymentDeleteResponse, err error) { +func (r *ProjectDeploymentService) Delete(ctx context.Context, projectName string, deploymentID string, params ProjectDeploymentDeleteParams, opts ...option.RequestOption) (res *ProjectDeploymentDeleteResponse, err error) { opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s", body.AccountID, projectName, deploymentID) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s", params.AccountID, projectName, deploymentID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) return } // Fetch information about a deployment. -func (r *ProjectDeploymentService) Get(ctx context.Context, projectName string, deploymentID string, query ProjectDeploymentGetParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { +func (r *ProjectDeploymentService) Get(ctx context.Context, projectName string, deploymentID string, query ProjectDeploymentGetParams, opts ...option.RequestOption) (res *Deployment, err error) { opts = append(r.Options[:], opts...) var env ProjectDeploymentGetResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s", query.AccountID, projectName, deploymentID) @@ -95,10 +96,10 @@ func (r *ProjectDeploymentService) Get(ctx context.Context, projectName string, } // Retry a previous deployment. -func (r *ProjectDeploymentService) Retry(ctx context.Context, projectName string, deploymentID string, body ProjectDeploymentRetryParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { +func (r *ProjectDeploymentService) Retry(ctx context.Context, projectName string, deploymentID string, params ProjectDeploymentRetryParams, opts ...option.RequestOption) (res *Deployment, err error) { opts = append(r.Options[:], opts...) var env ProjectDeploymentRetryResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/retry", body.AccountID, projectName, deploymentID) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/retry", params.AccountID, projectName, deploymentID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -109,10 +110,10 @@ func (r *ProjectDeploymentService) Retry(ctx context.Context, projectName string // Rollback the production deployment to a previous deployment. You can only // rollback to succesful builds on production. -func (r *ProjectDeploymentService) Rollback(ctx context.Context, projectName string, deploymentID string, body ProjectDeploymentRollbackParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { +func (r *ProjectDeploymentService) Rollback(ctx context.Context, projectName string, deploymentID string, params ProjectDeploymentRollbackParams, opts ...option.RequestOption) (res *Deployment, err error) { opts = append(r.Options[:], opts...) var env ProjectDeploymentRollbackResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/rollback", body.AccountID, projectName, deploymentID) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/rollback", params.AccountID, projectName, deploymentID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -136,9 +137,9 @@ func (r ProjectDeploymentNewParams) MarshalJSON() (data []byte, err error) { } type ProjectDeploymentNewResponseEnvelope struct { - Errors []ProjectDeploymentNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDeploymentNewResponseEnvelopeMessages `json:"messages,required"` - Result PagesDeployments `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Deployment `json:"result,required"` // Whether the API call was successful Success ProjectDeploymentNewResponseEnvelopeSuccess `json:"success,required"` JSON projectDeploymentNewResponseEnvelopeJSON `json:"-"` @@ -163,52 +164,6 @@ func (r projectDeploymentNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDeploymentNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDeploymentNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ProjectDeploymentNewResponseEnvelopeErrors] -type projectDeploymentNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDeploymentNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDeploymentNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ProjectDeploymentNewResponseEnvelopeMessages] -type projectDeploymentNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDeploymentNewResponseEnvelopeSuccess bool @@ -235,7 +190,7 @@ type ProjectDeploymentListParams struct { // `url.Values`. func (r ProjectDeploymentListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -259,6 +214,11 @@ func (r ProjectDeploymentListParamsEnv) IsKnown() bool { type ProjectDeploymentDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ProjectDeploymentDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ProjectDeploymentGetParams struct { @@ -267,9 +227,9 @@ type ProjectDeploymentGetParams struct { } type ProjectDeploymentGetResponseEnvelope struct { - Errors []ProjectDeploymentGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDeploymentGetResponseEnvelopeMessages `json:"messages,required"` - Result PagesDeployments `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Deployment `json:"result,required"` // Whether the API call was successful Success ProjectDeploymentGetResponseEnvelopeSuccess `json:"success,required"` JSON projectDeploymentGetResponseEnvelopeJSON `json:"-"` @@ -294,52 +254,6 @@ func (r projectDeploymentGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDeploymentGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDeploymentGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ProjectDeploymentGetResponseEnvelopeErrors] -type projectDeploymentGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDeploymentGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDeploymentGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ProjectDeploymentGetResponseEnvelopeMessages] -type projectDeploymentGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDeploymentGetResponseEnvelopeSuccess bool @@ -358,12 +272,17 @@ func (r ProjectDeploymentGetResponseEnvelopeSuccess) IsKnown() bool { type ProjectDeploymentRetryParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ProjectDeploymentRetryParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ProjectDeploymentRetryResponseEnvelope struct { - Errors []ProjectDeploymentRetryResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDeploymentRetryResponseEnvelopeMessages `json:"messages,required"` - Result PagesDeployments `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Deployment `json:"result,required"` // Whether the API call was successful Success ProjectDeploymentRetryResponseEnvelopeSuccess `json:"success,required"` JSON projectDeploymentRetryResponseEnvelopeJSON `json:"-"` @@ -388,52 +307,6 @@ func (r projectDeploymentRetryResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDeploymentRetryResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentRetryResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDeploymentRetryResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ProjectDeploymentRetryResponseEnvelopeErrors] -type projectDeploymentRetryResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentRetryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentRetryResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDeploymentRetryResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentRetryResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDeploymentRetryResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ProjectDeploymentRetryResponseEnvelopeMessages] -type projectDeploymentRetryResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentRetryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentRetryResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDeploymentRetryResponseEnvelopeSuccess bool @@ -452,12 +325,17 @@ func (r ProjectDeploymentRetryResponseEnvelopeSuccess) IsKnown() bool { type ProjectDeploymentRollbackParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ProjectDeploymentRollbackParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ProjectDeploymentRollbackResponseEnvelope struct { - Errors []ProjectDeploymentRollbackResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDeploymentRollbackResponseEnvelopeMessages `json:"messages,required"` - Result PagesDeployments `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Deployment `json:"result,required"` // Whether the API call was successful Success ProjectDeploymentRollbackResponseEnvelopeSuccess `json:"success,required"` JSON projectDeploymentRollbackResponseEnvelopeJSON `json:"-"` @@ -482,52 +360,6 @@ func (r projectDeploymentRollbackResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDeploymentRollbackResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentRollbackResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDeploymentRollbackResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ProjectDeploymentRollbackResponseEnvelopeErrors] -type projectDeploymentRollbackResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentRollbackResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentRollbackResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDeploymentRollbackResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentRollbackResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDeploymentRollbackResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ProjectDeploymentRollbackResponseEnvelopeMessages] -type projectDeploymentRollbackResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentRollbackResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentRollbackResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDeploymentRollbackResponseEnvelopeSuccess bool diff --git a/pages/projectdeployment_test.go b/pages/projectdeployment_test.go index e7c4e322bd9..cd560bf2796 100644 --- a/pages/projectdeployment_test.go +++ b/pages/projectdeployment_test.go @@ -96,6 +96,7 @@ func TestProjectDeploymentDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", pages.ProjectDeploymentDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -158,6 +159,7 @@ func TestProjectDeploymentRetry(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", pages.ProjectDeploymentRetryParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -189,6 +191,7 @@ func TestProjectDeploymentRollback(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", pages.ProjectDeploymentRollbackParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/pages/projectdeploymenthistorylog.go b/pages/projectdeploymenthistorylog.go index 589dbdd8cd8..fb7d86be7bb 100644 --- a/pages/projectdeploymenthistorylog.go +++ b/pages/projectdeploymenthistorylog.go @@ -35,7 +35,7 @@ func NewProjectDeploymentHistoryLogService(opts ...option.RequestOption) (r *Pro } // Fetch deployment logs for a project. -func (r *ProjectDeploymentHistoryLogService) Get(ctx context.Context, projectName string, deploymentID string, query ProjectDeploymentHistoryLogGetParams, opts ...option.RequestOption) (res *ProjectDeploymentHistoryLogGetResponse, err error) { +func (r *ProjectDeploymentHistoryLogService) Get(ctx context.Context, projectName string, deploymentID string, query ProjectDeploymentHistoryLogGetParams, opts ...option.RequestOption) (res *ProjectDeploymentHistoryLogGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ProjectDeploymentHistoryLogGetResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/history/logs", query.AccountID, projectName, deploymentID) @@ -49,13 +49,13 @@ func (r *ProjectDeploymentHistoryLogService) Get(ctx context.Context, projectNam // Union satisfied by [pages.ProjectDeploymentHistoryLogGetResponseUnknown], // [pages.ProjectDeploymentHistoryLogGetResponseArray] or [shared.UnionString]. -type ProjectDeploymentHistoryLogGetResponse interface { - ImplementsPagesProjectDeploymentHistoryLogGetResponse() +type ProjectDeploymentHistoryLogGetResponseUnion interface { + ImplementsPagesProjectDeploymentHistoryLogGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ProjectDeploymentHistoryLogGetResponse)(nil)).Elem(), + reflect.TypeOf((*ProjectDeploymentHistoryLogGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -70,7 +70,7 @@ func init() { type ProjectDeploymentHistoryLogGetResponseArray []interface{} -func (r ProjectDeploymentHistoryLogGetResponseArray) ImplementsPagesProjectDeploymentHistoryLogGetResponse() { +func (r ProjectDeploymentHistoryLogGetResponseArray) ImplementsPagesProjectDeploymentHistoryLogGetResponseUnion() { } type ProjectDeploymentHistoryLogGetParams struct { @@ -79,9 +79,9 @@ type ProjectDeploymentHistoryLogGetParams struct { } type ProjectDeploymentHistoryLogGetResponseEnvelope struct { - Errors []ProjectDeploymentHistoryLogGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDeploymentHistoryLogGetResponseEnvelopeMessages `json:"messages,required"` - Result ProjectDeploymentHistoryLogGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProjectDeploymentHistoryLogGetResponseUnion `json:"result,required"` // Whether the API call was successful Success ProjectDeploymentHistoryLogGetResponseEnvelopeSuccess `json:"success,required"` JSON projectDeploymentHistoryLogGetResponseEnvelopeJSON `json:"-"` @@ -106,52 +106,6 @@ func (r projectDeploymentHistoryLogGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDeploymentHistoryLogGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ProjectDeploymentHistoryLogGetResponseEnvelopeErrors] -type projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentHistoryLogGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDeploymentHistoryLogGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ProjectDeploymentHistoryLogGetResponseEnvelopeMessages] -type projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDeploymentHistoryLogGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDeploymentHistoryLogGetResponseEnvelopeSuccess bool diff --git a/pages/projectdomain.go b/pages/projectdomain.go index 597b1597e45..6e86b6b1176 100644 --- a/pages/projectdomain.go +++ b/pages/projectdomain.go @@ -36,7 +36,7 @@ func NewProjectDomainService(opts ...option.RequestOption) (r *ProjectDomainServ } // Add a new domain for the Pages project. -func (r *ProjectDomainService) New(ctx context.Context, projectName string, params ProjectDomainNewParams, opts ...option.RequestOption) (res *ProjectDomainNewResponse, err error) { +func (r *ProjectDomainService) New(ctx context.Context, projectName string, params ProjectDomainNewParams, opts ...option.RequestOption) (res *ProjectDomainNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ProjectDomainNewResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains", params.AccountID, projectName) @@ -72,18 +72,18 @@ func (r *ProjectDomainService) ListAutoPaging(ctx context.Context, projectName s } // Delete a Pages project's domain. -func (r *ProjectDomainService) Delete(ctx context.Context, projectName string, domainName string, body ProjectDomainDeleteParams, opts ...option.RequestOption) (res *ProjectDomainDeleteResponse, err error) { +func (r *ProjectDomainService) Delete(ctx context.Context, projectName string, domainName string, params ProjectDomainDeleteParams, opts ...option.RequestOption) (res *ProjectDomainDeleteResponse, err error) { opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", body.AccountID, projectName, domainName) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", params.AccountID, projectName, domainName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) return } // Retry the validation status of a single domain. -func (r *ProjectDomainService) Edit(ctx context.Context, projectName string, domainName string, body ProjectDomainEditParams, opts ...option.RequestOption) (res *ProjectDomainEditResponse, err error) { +func (r *ProjectDomainService) Edit(ctx context.Context, projectName string, domainName string, params ProjectDomainEditParams, opts ...option.RequestOption) (res *ProjectDomainEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ProjectDomainEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", body.AccountID, projectName, domainName) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", params.AccountID, projectName, domainName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) if err != nil { return @@ -93,7 +93,7 @@ func (r *ProjectDomainService) Edit(ctx context.Context, projectName string, dom } // Fetch a single domain. -func (r *ProjectDomainService) Get(ctx context.Context, projectName string, domainName string, query ProjectDomainGetParams, opts ...option.RequestOption) (res *ProjectDomainGetResponse, err error) { +func (r *ProjectDomainService) Get(ctx context.Context, projectName string, domainName string, query ProjectDomainGetParams, opts ...option.RequestOption) (res *ProjectDomainGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ProjectDomainGetResponseEnvelope path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", query.AccountID, projectName, domainName) @@ -107,13 +107,13 @@ func (r *ProjectDomainService) Get(ctx context.Context, projectName string, doma // Union satisfied by [pages.ProjectDomainNewResponseUnknown], // [pages.ProjectDomainNewResponseArray] or [shared.UnionString]. -type ProjectDomainNewResponse interface { - ImplementsPagesProjectDomainNewResponse() +type ProjectDomainNewResponseUnion interface { + ImplementsPagesProjectDomainNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ProjectDomainNewResponse)(nil)).Elem(), + reflect.TypeOf((*ProjectDomainNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -128,7 +128,7 @@ func init() { type ProjectDomainNewResponseArray []interface{} -func (r ProjectDomainNewResponseArray) ImplementsPagesProjectDomainNewResponse() {} +func (r ProjectDomainNewResponseArray) ImplementsPagesProjectDomainNewResponseUnion() {} type ProjectDomainListResponse = interface{} @@ -136,13 +136,13 @@ type ProjectDomainDeleteResponse = interface{} // Union satisfied by [pages.ProjectDomainEditResponseUnknown], // [pages.ProjectDomainEditResponseArray] or [shared.UnionString]. -type ProjectDomainEditResponse interface { - ImplementsPagesProjectDomainEditResponse() +type ProjectDomainEditResponseUnion interface { + ImplementsPagesProjectDomainEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ProjectDomainEditResponse)(nil)).Elem(), + reflect.TypeOf((*ProjectDomainEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -157,17 +157,17 @@ func init() { type ProjectDomainEditResponseArray []interface{} -func (r ProjectDomainEditResponseArray) ImplementsPagesProjectDomainEditResponse() {} +func (r ProjectDomainEditResponseArray) ImplementsPagesProjectDomainEditResponseUnion() {} // Union satisfied by [pages.ProjectDomainGetResponseUnknown], // [pages.ProjectDomainGetResponseArray] or [shared.UnionString]. -type ProjectDomainGetResponse interface { - ImplementsPagesProjectDomainGetResponse() +type ProjectDomainGetResponseUnion interface { + ImplementsPagesProjectDomainGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ProjectDomainGetResponse)(nil)).Elem(), + reflect.TypeOf((*ProjectDomainGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -182,12 +182,12 @@ func init() { type ProjectDomainGetResponseArray []interface{} -func (r ProjectDomainGetResponseArray) ImplementsPagesProjectDomainGetResponse() {} +func (r ProjectDomainGetResponseArray) ImplementsPagesProjectDomainGetResponseUnion() {} type ProjectDomainNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r ProjectDomainNewParams) MarshalJSON() (data []byte, err error) { @@ -195,9 +195,9 @@ func (r ProjectDomainNewParams) MarshalJSON() (data []byte, err error) { } type ProjectDomainNewResponseEnvelope struct { - Errors []ProjectDomainNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDomainNewResponseEnvelopeMessages `json:"messages,required"` - Result ProjectDomainNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProjectDomainNewResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success ProjectDomainNewResponseEnvelopeSuccess `json:"success,required"` JSON projectDomainNewResponseEnvelopeJSON `json:"-"` @@ -222,52 +222,6 @@ func (r projectDomainNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDomainNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDomainNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDomainNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ProjectDomainNewResponseEnvelopeErrors] -type projectDomainNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDomainNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDomainNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDomainNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDomainNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDomainNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ProjectDomainNewResponseEnvelopeMessages] -type projectDomainNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDomainNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDomainNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDomainNewResponseEnvelopeSuccess bool @@ -291,17 +245,27 @@ type ProjectDomainListParams struct { type ProjectDomainDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ProjectDomainDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ProjectDomainEditParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ProjectDomainEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ProjectDomainEditResponseEnvelope struct { - Errors []ProjectDomainEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDomainEditResponseEnvelopeMessages `json:"messages,required"` - Result ProjectDomainEditResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProjectDomainEditResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success ProjectDomainEditResponseEnvelopeSuccess `json:"success,required"` JSON projectDomainEditResponseEnvelopeJSON `json:"-"` @@ -326,52 +290,6 @@ func (r projectDomainEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDomainEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDomainEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDomainEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ProjectDomainEditResponseEnvelopeErrors] -type projectDomainEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDomainEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDomainEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDomainEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDomainEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDomainEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ProjectDomainEditResponseEnvelopeMessages] -type projectDomainEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDomainEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDomainEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDomainEditResponseEnvelopeSuccess bool @@ -393,9 +311,9 @@ type ProjectDomainGetParams struct { } type ProjectDomainGetResponseEnvelope struct { - Errors []ProjectDomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ProjectDomainGetResponseEnvelopeMessages `json:"messages,required"` - Result ProjectDomainGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProjectDomainGetResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success ProjectDomainGetResponseEnvelopeSuccess `json:"success,required"` JSON projectDomainGetResponseEnvelopeJSON `json:"-"` @@ -420,52 +338,6 @@ func (r projectDomainGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ProjectDomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// projectDomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ProjectDomainGetResponseEnvelopeErrors] -type projectDomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ProjectDomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON projectDomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// projectDomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ProjectDomainGetResponseEnvelopeMessages] -type projectDomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ProjectDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r projectDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ProjectDomainGetResponseEnvelopeSuccess bool diff --git a/pages/projectdomain_test.go b/pages/projectdomain_test.go index 29fd33b2464..6e54698b562 100644 --- a/pages/projectdomain_test.go +++ b/pages/projectdomain_test.go @@ -33,9 +33,9 @@ func TestProjectDomainNew(t *testing.T) { "this-is-my-project-01", pages.ProjectDomainNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ + Body: map[string]interface{}{ "name": "example.com", - }), + }, }, ) if err != nil { @@ -94,9 +94,10 @@ func TestProjectDomainDelete(t *testing.T) { _, err := client.Pages.Projects.Domains.Delete( context.TODO(), "this-is-my-project-01", - "string", + "this-is-my-domain-01.com", pages.ProjectDomainDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -125,9 +126,10 @@ func TestProjectDomainEdit(t *testing.T) { _, err := client.Pages.Projects.Domains.Edit( context.TODO(), "this-is-my-project-01", - "string", + "this-is-my-domain-01.com", pages.ProjectDomainEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -156,7 +158,7 @@ func TestProjectDomainGet(t *testing.T) { _, err := client.Pages.Projects.Domains.Get( context.TODO(), "this-is-my-project-01", - "string", + "this-is-my-domain-01.com", pages.ProjectDomainGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, diff --git a/pcaps/aliases.go b/pcaps/aliases.go index 576b4eab82a..1226de1151b 100644 --- a/pcaps/aliases.go +++ b/pcaps/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/pcaps/ownership.go b/pcaps/ownership.go index 0cd5d370d1e..e664fb91858 100644 --- a/pcaps/ownership.go +++ b/pcaps/ownership.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,7 +32,7 @@ func NewOwnershipService(opts ...option.RequestOption) (r *OwnershipService) { } // Adds an AWS or GCP bucket to use with full packet captures. -func (r *OwnershipService) New(ctx context.Context, params OwnershipNewParams, opts ...option.RequestOption) (res *MagicVisibilityPCAPsOwnership, err error) { +func (r *OwnershipService) New(ctx context.Context, params OwnershipNewParams, opts ...option.RequestOption) (res *Ownership, err error) { opts = append(r.Options[:], opts...) var env OwnershipNewResponseEnvelope path := fmt.Sprintf("accounts/%s/pcaps/ownership", params.AccountID) @@ -53,7 +54,7 @@ func (r *OwnershipService) Delete(ctx context.Context, ownershipID string, body } // List all buckets configured for use with PCAPs API. -func (r *OwnershipService) Get(ctx context.Context, query OwnershipGetParams, opts ...option.RequestOption) (res *[]MagicVisibilityPCAPsOwnership, err error) { +func (r *OwnershipService) Get(ctx context.Context, query OwnershipGetParams, opts ...option.RequestOption) (res *[]Ownership, err error) { opts = append(r.Options[:], opts...) var env OwnershipGetResponseEnvelope path := fmt.Sprintf("accounts/%s/pcaps/ownership", query.AccountID) @@ -66,7 +67,7 @@ func (r *OwnershipService) Get(ctx context.Context, query OwnershipGetParams, op } // Validates buckets added to the packet captures API. -func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidateParams, opts ...option.RequestOption) (res *MagicVisibilityPCAPsOwnership, err error) { +func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidateParams, opts ...option.RequestOption) (res *Ownership, err error) { opts = append(r.Options[:], opts...) var env OwnershipValidateResponseEnvelope path := fmt.Sprintf("accounts/%s/pcaps/ownership/validate", params.AccountID) @@ -78,7 +79,7 @@ func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidat return } -type MagicVisibilityPCAPsOwnership struct { +type Ownership struct { // The bucket ID associated with the packet captures API. ID string `json:"id,required"` // The full URI for the bucket. This field only applies to `full` packet captures. @@ -86,17 +87,16 @@ type MagicVisibilityPCAPsOwnership struct { // The ownership challenge filename stored in the bucket. Filename string `json:"filename,required"` // The status of the ownership challenge. Can be pending, success or failed. - Status MagicVisibilityPCAPsOwnershipStatus `json:"status,required"` + Status OwnershipStatus `json:"status,required"` // The RFC 3339 timestamp when the bucket was added to packet captures API. Submitted string `json:"submitted,required"` // The RFC 3339 timestamp when the bucket was validated. - Validated string `json:"validated"` - JSON magicVisibilityPCAPsOwnershipJSON `json:"-"` + Validated string `json:"validated"` + JSON ownershipJSON `json:"-"` } -// magicVisibilityPCAPsOwnershipJSON contains the JSON metadata for the struct -// [MagicVisibilityPCAPsOwnership] -type magicVisibilityPCAPsOwnershipJSON struct { +// ownershipJSON contains the JSON metadata for the struct [Ownership] +type ownershipJSON struct { ID apijson.Field DestinationConf apijson.Field Filename apijson.Field @@ -107,26 +107,26 @@ type magicVisibilityPCAPsOwnershipJSON struct { ExtraFields map[string]apijson.Field } -func (r *MagicVisibilityPCAPsOwnership) UnmarshalJSON(data []byte) (err error) { +func (r *Ownership) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r magicVisibilityPCAPsOwnershipJSON) RawJSON() string { +func (r ownershipJSON) RawJSON() string { return r.raw } // The status of the ownership challenge. Can be pending, success or failed. -type MagicVisibilityPCAPsOwnershipStatus string +type OwnershipStatus string const ( - MagicVisibilityPCAPsOwnershipStatusPending MagicVisibilityPCAPsOwnershipStatus = "pending" - MagicVisibilityPCAPsOwnershipStatusSuccess MagicVisibilityPCAPsOwnershipStatus = "success" - MagicVisibilityPCAPsOwnershipStatusFailed MagicVisibilityPCAPsOwnershipStatus = "failed" + OwnershipStatusPending OwnershipStatus = "pending" + OwnershipStatusSuccess OwnershipStatus = "success" + OwnershipStatusFailed OwnershipStatus = "failed" ) -func (r MagicVisibilityPCAPsOwnershipStatus) IsKnown() bool { +func (r OwnershipStatus) IsKnown() bool { switch r { - case MagicVisibilityPCAPsOwnershipStatusPending, MagicVisibilityPCAPsOwnershipStatusSuccess, MagicVisibilityPCAPsOwnershipStatusFailed: + case OwnershipStatusPending, OwnershipStatusSuccess, OwnershipStatusFailed: return true } return false @@ -144,9 +144,9 @@ func (r OwnershipNewParams) MarshalJSON() (data []byte, err error) { } type OwnershipNewResponseEnvelope struct { - Errors []OwnershipNewResponseEnvelopeErrors `json:"errors,required"` - Messages []OwnershipNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicVisibilityPCAPsOwnership `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Ownership `json:"result,required"` // Whether the API call was successful Success OwnershipNewResponseEnvelopeSuccess `json:"success,required"` JSON ownershipNewResponseEnvelopeJSON `json:"-"` @@ -171,52 +171,6 @@ func (r ownershipNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OwnershipNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ownershipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [OwnershipNewResponseEnvelopeErrors] -type ownershipNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OwnershipNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ownershipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OwnershipNewResponseEnvelopeMessages] -type ownershipNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OwnershipNewResponseEnvelopeSuccess bool @@ -243,9 +197,9 @@ type OwnershipGetParams struct { } type OwnershipGetResponseEnvelope struct { - Errors []OwnershipGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OwnershipGetResponseEnvelopeMessages `json:"messages,required"` - Result []MagicVisibilityPCAPsOwnership `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Ownership `json:"result,required,nullable"` // Whether the API call was successful Success OwnershipGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo OwnershipGetResponseEnvelopeResultInfo `json:"result_info"` @@ -272,52 +226,6 @@ func (r ownershipGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OwnershipGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ownershipGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [OwnershipGetResponseEnvelopeErrors] -type ownershipGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OwnershipGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ownershipGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OwnershipGetResponseEnvelopeMessages] -type ownershipGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OwnershipGetResponseEnvelopeSuccess bool @@ -378,9 +286,9 @@ func (r OwnershipValidateParams) MarshalJSON() (data []byte, err error) { } type OwnershipValidateResponseEnvelope struct { - Errors []OwnershipValidateResponseEnvelopeErrors `json:"errors,required"` - Messages []OwnershipValidateResponseEnvelopeMessages `json:"messages,required"` - Result MagicVisibilityPCAPsOwnership `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Ownership `json:"result,required"` // Whether the API call was successful Success OwnershipValidateResponseEnvelopeSuccess `json:"success,required"` JSON ownershipValidateResponseEnvelopeJSON `json:"-"` @@ -405,52 +313,6 @@ func (r ownershipValidateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OwnershipValidateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipValidateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ownershipValidateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OwnershipValidateResponseEnvelopeErrors] -type ownershipValidateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipValidateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OwnershipValidateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ownershipValidateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ownershipValidateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OwnershipValidateResponseEnvelopeMessages] -type ownershipValidateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OwnershipValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ownershipValidateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OwnershipValidateResponseEnvelopeSuccess bool diff --git a/pcaps/pcap.go b/pcaps/pcap.go index a8c51fea685..90893ef50b0 100644 --- a/pcaps/pcap.go +++ b/pcaps/pcap.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -41,7 +42,7 @@ func NewPCAPService(opts ...option.RequestOption) (r *PCAPService) { func (r *PCAPService) New(ctx context.Context, params PCAPNewParams, opts ...option.RequestOption) (res *PCAPNewResponse, err error) { opts = append(r.Options[:], opts...) var env PCAPNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/pcaps", params.getAccountID()) + path := fmt.Sprintf("accounts/%s/pcaps", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return @@ -86,49 +87,27 @@ func (r *PCAPService) Get(ctx context.Context, pcapID string, query PCAPGetParam return } -// Union satisfied by [pcaps.PCAPNewResponseMagicVisibilityPCAPsResponseSimple] or -// [pcaps.PCAPNewResponseMagicVisibilityPCAPsResponseFull]. -type PCAPNewResponse interface { - implementsPCAPsPCAPNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PCAPNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PCAPNewResponseMagicVisibilityPCAPsResponseSimple{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PCAPNewResponseMagicVisibilityPCAPsResponseFull{}), - }, - ) -} - -type PCAPNewResponseMagicVisibilityPCAPsResponseSimple struct { +type PCAP struct { // The ID for the packet capture. ID string `json:"id"` // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 PCAPNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1 `json:"filter_v1"` + FilterV1 PCAPFilter `json:"filter_v1"` // The status of the packet capture request. - Status PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus `json:"status"` + Status PCAPStatus `json:"status"` // The RFC 3339 timestamp when the packet capture was created. Submitted string `json:"submitted"` // The system used to collect packet captures. - System PCAPNewResponseMagicVisibilityPCAPsResponseSimpleSystem `json:"system"` + System PCAPSystem `json:"system"` // The packet capture duration in seconds. TimeLimit float64 `json:"time_limit"` // The type of packet capture. `Simple` captures sampled packets, and `full` // captures entire payloads and non-sampled packets. - Type PCAPNewResponseMagicVisibilityPCAPsResponseSimpleType `json:"type"` - JSON pcapNewResponseMagicVisibilityPCAPsResponseSimpleJSON `json:"-"` + Type PCAPType `json:"type"` + JSON pcapJSON `json:"-"` } -// pcapNewResponseMagicVisibilityPCAPsResponseSimpleJSON contains the JSON metadata -// for the struct [PCAPNewResponseMagicVisibilityPCAPsResponseSimple] -type pcapNewResponseMagicVisibilityPCAPsResponseSimpleJSON struct { +// pcapJSON contains the JSON metadata for the struct [PCAP] +type pcapJSON struct { ID apijson.Field FilterV1 apijson.Field Status apijson.Field @@ -140,18 +119,76 @@ type pcapNewResponseMagicVisibilityPCAPsResponseSimpleJSON struct { ExtraFields map[string]apijson.Field } -func (r *PCAPNewResponseMagicVisibilityPCAPsResponseSimple) UnmarshalJSON(data []byte) (err error) { +func (r *PCAP) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pcapNewResponseMagicVisibilityPCAPsResponseSimpleJSON) RawJSON() string { +func (r pcapJSON) RawJSON() string { return r.raw } -func (r PCAPNewResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPsPCAPNewResponse() {} +func (r PCAP) implementsPCAPsPCAPNewResponse() {} + +func (r PCAP) implementsPCAPsPCAPListResponse() {} + +func (r PCAP) implementsPCAPsPCAPGetResponse() {} + +// The status of the packet capture request. +type PCAPStatus string + +const ( + PCAPStatusUnknown PCAPStatus = "unknown" + PCAPStatusSuccess PCAPStatus = "success" + PCAPStatusPending PCAPStatus = "pending" + PCAPStatusRunning PCAPStatus = "running" + PCAPStatusConversionPending PCAPStatus = "conversion_pending" + PCAPStatusConversionRunning PCAPStatus = "conversion_running" + PCAPStatusComplete PCAPStatus = "complete" + PCAPStatusFailed PCAPStatus = "failed" +) + +func (r PCAPStatus) IsKnown() bool { + switch r { + case PCAPStatusUnknown, PCAPStatusSuccess, PCAPStatusPending, PCAPStatusRunning, PCAPStatusConversionPending, PCAPStatusConversionRunning, PCAPStatusComplete, PCAPStatusFailed: + return true + } + return false +} + +// The system used to collect packet captures. +type PCAPSystem string + +const ( + PCAPSystemMagicTransit PCAPSystem = "magic-transit" +) + +func (r PCAPSystem) IsKnown() bool { + switch r { + case PCAPSystemMagicTransit: + return true + } + return false +} + +// The type of packet capture. `Simple` captures sampled packets, and `full` +// captures entire payloads and non-sampled packets. +type PCAPType string + +const ( + PCAPTypeSimple PCAPType = "simple" + PCAPTypeFull PCAPType = "full" +) + +func (r PCAPType) IsKnown() bool { + switch r { + case PCAPTypeSimple, PCAPTypeFull: + return true + } + return false +} // The packet capture filter. When this field is empty, all packets are captured. -type PCAPNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1 struct { +type PCAPFilter struct { // The destination IP address of the packet. DestinationAddress string `json:"destination_address"` // The destination port of the packet. @@ -161,14 +198,12 @@ type PCAPNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1 struct { // The source IP address of the packet. SourceAddress string `json:"source_address"` // The source port of the packet. - SourcePort float64 `json:"source_port"` - JSON pcapNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON `json:"-"` + SourcePort float64 `json:"source_port"` + JSON pcapFilterJSON `json:"-"` } -// pcapNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON contains the JSON -// metadata for the struct -// [PCAPNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1] -type pcapNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON struct { +// pcapFilterJSON contains the JSON metadata for the struct [PCAPFilter] +type pcapFilterJSON struct { DestinationAddress apijson.Field DestinationPort apijson.Field Protocol apijson.Field @@ -178,66 +213,116 @@ type pcapNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON struct { ExtraFields map[string]apijson.Field } -func (r *PCAPNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1) UnmarshalJSON(data []byte) (err error) { +func (r *PCAPFilter) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pcapNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON) RawJSON() string { +func (r pcapFilterJSON) RawJSON() string { return r.raw } -// The status of the packet capture request. -type PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus string +// The packet capture filter. When this field is empty, all packets are captured. +type PCAPFilterParam struct { + // The destination IP address of the packet. + DestinationAddress param.Field[string] `json:"destination_address"` + // The destination port of the packet. + DestinationPort param.Field[float64] `json:"destination_port"` + // The protocol number of the packet. + Protocol param.Field[float64] `json:"protocol"` + // The source IP address of the packet. + SourceAddress param.Field[string] `json:"source_address"` + // The source port of the packet. + SourcePort param.Field[float64] `json:"source_port"` +} -const ( - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusUnknown PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "unknown" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusSuccess PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "success" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusPending PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "pending" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusRunning PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "running" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusConversionPending PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "conversion_pending" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusConversionRunning PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "conversion_running" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusComplete PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "complete" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusFailed PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus = "failed" -) +func (r PCAPFilterParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} -func (r PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatus) IsKnown() bool { - switch r { - case PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusUnknown, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusSuccess, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusPending, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusRunning, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusConversionPending, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusConversionRunning, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusComplete, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleStatusFailed: - return true - } - return false +type PCAPNewResponse struct { + // The packet capture filter. When this field is empty, all packets are captured. + FilterV1 PCAPFilter `json:"filter_v1"` + // The ID for the packet capture. + ID string `json:"id"` + // The status of the packet capture request. + Status PCAPNewResponseStatus `json:"status"` + // The RFC 3339 timestamp when the packet capture was created. + Submitted string `json:"submitted"` + // The system used to collect packet captures. + System PCAPNewResponseSystem `json:"system"` + // The packet capture duration in seconds. + TimeLimit float64 `json:"time_limit"` + // The type of packet capture. `Simple` captures sampled packets, and `full` + // captures entire payloads and non-sampled packets. + Type PCAPNewResponseType `json:"type"` + // The maximum number of bytes to capture. This field only applies to `full` packet + // captures. + ByteLimit float64 `json:"byte_limit"` + // The name of the data center used for the packet capture. This can be a specific + // colo (ord02) or a multi-colo name (ORD). This field only applies to `full` + // packet captures. + ColoName string `json:"colo_name"` + // The full URI for the bucket. This field only applies to `full` packet captures. + DestinationConf string `json:"destination_conf"` + // An error message that describes why the packet capture failed. This field only + // applies to `full` packet captures. + ErrorMessage string `json:"error_message"` + JSON pcapNewResponseJSON `json:"-"` + union PCAPNewResponseUnion } -// The system used to collect packet captures. -type PCAPNewResponseMagicVisibilityPCAPsResponseSimpleSystem string +// pcapNewResponseJSON contains the JSON metadata for the struct [PCAPNewResponse] +type pcapNewResponseJSON struct { + FilterV1 apijson.Field + ID apijson.Field + Status apijson.Field + Submitted apijson.Field + System apijson.Field + TimeLimit apijson.Field + Type apijson.Field + ByteLimit apijson.Field + ColoName apijson.Field + DestinationConf apijson.Field + ErrorMessage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -const ( - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleSystemMagicTransit PCAPNewResponseMagicVisibilityPCAPsResponseSimpleSystem = "magic-transit" -) +func (r pcapNewResponseJSON) RawJSON() string { + return r.raw +} -func (r PCAPNewResponseMagicVisibilityPCAPsResponseSimpleSystem) IsKnown() bool { - switch r { - case PCAPNewResponseMagicVisibilityPCAPsResponseSimpleSystemMagicTransit: - return true +func (r *PCAPNewResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err } - return false + return apijson.Port(r.union, &r) } -// The type of packet capture. `Simple` captures sampled packets, and `full` -// captures entire payloads and non-sampled packets. -type PCAPNewResponseMagicVisibilityPCAPsResponseSimpleType string +func (r PCAPNewResponse) AsUnion() PCAPNewResponseUnion { + return r.union +} -const ( - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleTypeSimple PCAPNewResponseMagicVisibilityPCAPsResponseSimpleType = "simple" - PCAPNewResponseMagicVisibilityPCAPsResponseSimpleTypeFull PCAPNewResponseMagicVisibilityPCAPsResponseSimpleType = "full" -) +// Union satisfied by [pcaps.PCAP] or +// [pcaps.PCAPNewResponseMagicVisibilityPCAPsResponseFull]. +type PCAPNewResponseUnion interface { + implementsPCAPsPCAPNewResponse() +} -func (r PCAPNewResponseMagicVisibilityPCAPsResponseSimpleType) IsKnown() bool { - switch r { - case PCAPNewResponseMagicVisibilityPCAPsResponseSimpleTypeSimple, PCAPNewResponseMagicVisibilityPCAPsResponseSimpleTypeFull: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PCAPNewResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PCAP{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PCAPNewResponseMagicVisibilityPCAPsResponseFull{}), + }, + ) } type PCAPNewResponseMagicVisibilityPCAPsResponseFull struct { @@ -256,7 +341,7 @@ type PCAPNewResponseMagicVisibilityPCAPsResponseFull struct { // applies to `full` packet captures. ErrorMessage string `json:"error_message"` // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 PCAPNewResponseMagicVisibilityPCAPsResponseFullFilterV1 `json:"filter_v1"` + FilterV1 PCAPFilter `json:"filter_v1"` // The status of the packet capture request. Status PCAPNewResponseMagicVisibilityPCAPsResponseFullStatus `json:"status"` // The RFC 3339 timestamp when the packet capture was created. @@ -299,42 +384,6 @@ func (r pcapNewResponseMagicVisibilityPCAPsResponseFullJSON) RawJSON() string { func (r PCAPNewResponseMagicVisibilityPCAPsResponseFull) implementsPCAPsPCAPNewResponse() {} -// The packet capture filter. When this field is empty, all packets are captured. -type PCAPNewResponseMagicVisibilityPCAPsResponseFullFilterV1 struct { - // The destination IP address of the packet. - DestinationAddress string `json:"destination_address"` - // The destination port of the packet. - DestinationPort float64 `json:"destination_port"` - // The protocol number of the packet. - Protocol float64 `json:"protocol"` - // The source IP address of the packet. - SourceAddress string `json:"source_address"` - // The source port of the packet. - SourcePort float64 `json:"source_port"` - JSON pcapNewResponseMagicVisibilityPCAPsResponseFullFilterV1JSON `json:"-"` -} - -// pcapNewResponseMagicVisibilityPCAPsResponseFullFilterV1JSON contains the JSON -// metadata for the struct -// [PCAPNewResponseMagicVisibilityPCAPsResponseFullFilterV1] -type pcapNewResponseMagicVisibilityPCAPsResponseFullFilterV1JSON struct { - DestinationAddress apijson.Field - DestinationPort apijson.Field - Protocol apijson.Field - SourceAddress apijson.Field - SourcePort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPNewResponseMagicVisibilityPCAPsResponseFullFilterV1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapNewResponseMagicVisibilityPCAPsResponseFullFilterV1JSON) RawJSON() string { - return r.raw -} - // The status of the packet capture request. type PCAPNewResponseMagicVisibilityPCAPsResponseFullStatus string @@ -389,138 +438,38 @@ func (r PCAPNewResponseMagicVisibilityPCAPsResponseFullType) IsKnown() bool { return false } -// Union satisfied by [pcaps.PCAPListResponseMagicVisibilityPCAPsResponseSimple] or -// [pcaps.PCAPListResponseMagicVisibilityPCAPsResponseFull]. -type PCAPListResponse interface { - implementsPCAPsPCAPListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PCAPListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PCAPListResponseMagicVisibilityPCAPsResponseSimple{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PCAPListResponseMagicVisibilityPCAPsResponseFull{}), - }, - ) -} - -type PCAPListResponseMagicVisibilityPCAPsResponseSimple struct { - // The ID for the packet capture. - ID string `json:"id"` - // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 PCAPListResponseMagicVisibilityPCAPsResponseSimpleFilterV1 `json:"filter_v1"` - // The status of the packet capture request. - Status PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus `json:"status"` - // The RFC 3339 timestamp when the packet capture was created. - Submitted string `json:"submitted"` - // The system used to collect packet captures. - System PCAPListResponseMagicVisibilityPCAPsResponseSimpleSystem `json:"system"` - // The packet capture duration in seconds. - TimeLimit float64 `json:"time_limit"` - // The type of packet capture. `Simple` captures sampled packets, and `full` - // captures entire payloads and non-sampled packets. - Type PCAPListResponseMagicVisibilityPCAPsResponseSimpleType `json:"type"` - JSON pcapListResponseMagicVisibilityPCAPsResponseSimpleJSON `json:"-"` -} - -// pcapListResponseMagicVisibilityPCAPsResponseSimpleJSON contains the JSON -// metadata for the struct [PCAPListResponseMagicVisibilityPCAPsResponseSimple] -type pcapListResponseMagicVisibilityPCAPsResponseSimpleJSON struct { - ID apijson.Field - FilterV1 apijson.Field - Status apijson.Field - Submitted apijson.Field - System apijson.Field - TimeLimit apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPListResponseMagicVisibilityPCAPsResponseSimple) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapListResponseMagicVisibilityPCAPsResponseSimpleJSON) RawJSON() string { - return r.raw -} - -func (r PCAPListResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPsPCAPListResponse() {} - -// The packet capture filter. When this field is empty, all packets are captured. -type PCAPListResponseMagicVisibilityPCAPsResponseSimpleFilterV1 struct { - // The destination IP address of the packet. - DestinationAddress string `json:"destination_address"` - // The destination port of the packet. - DestinationPort float64 `json:"destination_port"` - // The protocol number of the packet. - Protocol float64 `json:"protocol"` - // The source IP address of the packet. - SourceAddress string `json:"source_address"` - // The source port of the packet. - SourcePort float64 `json:"source_port"` - JSON pcapListResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON `json:"-"` -} - -// pcapListResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON contains the JSON -// metadata for the struct -// [PCAPListResponseMagicVisibilityPCAPsResponseSimpleFilterV1] -type pcapListResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON struct { - DestinationAddress apijson.Field - DestinationPort apijson.Field - Protocol apijson.Field - SourceAddress apijson.Field - SourcePort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPListResponseMagicVisibilityPCAPsResponseSimpleFilterV1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapListResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON) RawJSON() string { - return r.raw -} - // The status of the packet capture request. -type PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus string +type PCAPNewResponseStatus string const ( - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusUnknown PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "unknown" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusSuccess PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "success" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusPending PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "pending" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusRunning PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "running" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusConversionPending PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "conversion_pending" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusConversionRunning PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "conversion_running" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusComplete PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "complete" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusFailed PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus = "failed" + PCAPNewResponseStatusUnknown PCAPNewResponseStatus = "unknown" + PCAPNewResponseStatusSuccess PCAPNewResponseStatus = "success" + PCAPNewResponseStatusPending PCAPNewResponseStatus = "pending" + PCAPNewResponseStatusRunning PCAPNewResponseStatus = "running" + PCAPNewResponseStatusConversionPending PCAPNewResponseStatus = "conversion_pending" + PCAPNewResponseStatusConversionRunning PCAPNewResponseStatus = "conversion_running" + PCAPNewResponseStatusComplete PCAPNewResponseStatus = "complete" + PCAPNewResponseStatusFailed PCAPNewResponseStatus = "failed" ) -func (r PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatus) IsKnown() bool { +func (r PCAPNewResponseStatus) IsKnown() bool { switch r { - case PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusUnknown, PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusSuccess, PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusPending, PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusRunning, PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusConversionPending, PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusConversionRunning, PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusComplete, PCAPListResponseMagicVisibilityPCAPsResponseSimpleStatusFailed: + case PCAPNewResponseStatusUnknown, PCAPNewResponseStatusSuccess, PCAPNewResponseStatusPending, PCAPNewResponseStatusRunning, PCAPNewResponseStatusConversionPending, PCAPNewResponseStatusConversionRunning, PCAPNewResponseStatusComplete, PCAPNewResponseStatusFailed: return true } return false } // The system used to collect packet captures. -type PCAPListResponseMagicVisibilityPCAPsResponseSimpleSystem string +type PCAPNewResponseSystem string const ( - PCAPListResponseMagicVisibilityPCAPsResponseSimpleSystemMagicTransit PCAPListResponseMagicVisibilityPCAPsResponseSimpleSystem = "magic-transit" + PCAPNewResponseSystemMagicTransit PCAPNewResponseSystem = "magic-transit" ) -func (r PCAPListResponseMagicVisibilityPCAPsResponseSimpleSystem) IsKnown() bool { +func (r PCAPNewResponseSystem) IsKnown() bool { switch r { - case PCAPListResponseMagicVisibilityPCAPsResponseSimpleSystemMagicTransit: + case PCAPNewResponseSystemMagicTransit: return true } return false @@ -528,21 +477,108 @@ func (r PCAPListResponseMagicVisibilityPCAPsResponseSimpleSystem) IsKnown() bool // The type of packet capture. `Simple` captures sampled packets, and `full` // captures entire payloads and non-sampled packets. -type PCAPListResponseMagicVisibilityPCAPsResponseSimpleType string +type PCAPNewResponseType string const ( - PCAPListResponseMagicVisibilityPCAPsResponseSimpleTypeSimple PCAPListResponseMagicVisibilityPCAPsResponseSimpleType = "simple" - PCAPListResponseMagicVisibilityPCAPsResponseSimpleTypeFull PCAPListResponseMagicVisibilityPCAPsResponseSimpleType = "full" + PCAPNewResponseTypeSimple PCAPNewResponseType = "simple" + PCAPNewResponseTypeFull PCAPNewResponseType = "full" ) -func (r PCAPListResponseMagicVisibilityPCAPsResponseSimpleType) IsKnown() bool { +func (r PCAPNewResponseType) IsKnown() bool { switch r { - case PCAPListResponseMagicVisibilityPCAPsResponseSimpleTypeSimple, PCAPListResponseMagicVisibilityPCAPsResponseSimpleTypeFull: + case PCAPNewResponseTypeSimple, PCAPNewResponseTypeFull: return true } return false } +type PCAPListResponse struct { + // The packet capture filter. When this field is empty, all packets are captured. + FilterV1 PCAPFilter `json:"filter_v1"` + // The ID for the packet capture. + ID string `json:"id"` + // The status of the packet capture request. + Status PCAPListResponseStatus `json:"status"` + // The RFC 3339 timestamp when the packet capture was created. + Submitted string `json:"submitted"` + // The system used to collect packet captures. + System PCAPListResponseSystem `json:"system"` + // The packet capture duration in seconds. + TimeLimit float64 `json:"time_limit"` + // The type of packet capture. `Simple` captures sampled packets, and `full` + // captures entire payloads and non-sampled packets. + Type PCAPListResponseType `json:"type"` + // The maximum number of bytes to capture. This field only applies to `full` packet + // captures. + ByteLimit float64 `json:"byte_limit"` + // The name of the data center used for the packet capture. This can be a specific + // colo (ord02) or a multi-colo name (ORD). This field only applies to `full` + // packet captures. + ColoName string `json:"colo_name"` + // The full URI for the bucket. This field only applies to `full` packet captures. + DestinationConf string `json:"destination_conf"` + // An error message that describes why the packet capture failed. This field only + // applies to `full` packet captures. + ErrorMessage string `json:"error_message"` + JSON pcapListResponseJSON `json:"-"` + union PCAPListResponseUnion +} + +// pcapListResponseJSON contains the JSON metadata for the struct +// [PCAPListResponse] +type pcapListResponseJSON struct { + FilterV1 apijson.Field + ID apijson.Field + Status apijson.Field + Submitted apijson.Field + System apijson.Field + TimeLimit apijson.Field + Type apijson.Field + ByteLimit apijson.Field + ColoName apijson.Field + DestinationConf apijson.Field + ErrorMessage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r pcapListResponseJSON) RawJSON() string { + return r.raw +} + +func (r *PCAPListResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r PCAPListResponse) AsUnion() PCAPListResponseUnion { + return r.union +} + +// Union satisfied by [pcaps.PCAP] or +// [pcaps.PCAPListResponseMagicVisibilityPCAPsResponseFull]. +type PCAPListResponseUnion interface { + implementsPCAPsPCAPListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PCAPListResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PCAP{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PCAPListResponseMagicVisibilityPCAPsResponseFull{}), + }, + ) +} + type PCAPListResponseMagicVisibilityPCAPsResponseFull struct { // The ID for the packet capture. ID string `json:"id"` @@ -559,7 +595,7 @@ type PCAPListResponseMagicVisibilityPCAPsResponseFull struct { // applies to `full` packet captures. ErrorMessage string `json:"error_message"` // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 PCAPListResponseMagicVisibilityPCAPsResponseFullFilterV1 `json:"filter_v1"` + FilterV1 PCAPFilter `json:"filter_v1"` // The status of the packet capture request. Status PCAPListResponseMagicVisibilityPCAPsResponseFullStatus `json:"status"` // The RFC 3339 timestamp when the packet capture was created. @@ -602,42 +638,6 @@ func (r pcapListResponseMagicVisibilityPCAPsResponseFullJSON) RawJSON() string { func (r PCAPListResponseMagicVisibilityPCAPsResponseFull) implementsPCAPsPCAPListResponse() {} -// The packet capture filter. When this field is empty, all packets are captured. -type PCAPListResponseMagicVisibilityPCAPsResponseFullFilterV1 struct { - // The destination IP address of the packet. - DestinationAddress string `json:"destination_address"` - // The destination port of the packet. - DestinationPort float64 `json:"destination_port"` - // The protocol number of the packet. - Protocol float64 `json:"protocol"` - // The source IP address of the packet. - SourceAddress string `json:"source_address"` - // The source port of the packet. - SourcePort float64 `json:"source_port"` - JSON pcapListResponseMagicVisibilityPCAPsResponseFullFilterV1JSON `json:"-"` -} - -// pcapListResponseMagicVisibilityPCAPsResponseFullFilterV1JSON contains the JSON -// metadata for the struct -// [PCAPListResponseMagicVisibilityPCAPsResponseFullFilterV1] -type pcapListResponseMagicVisibilityPCAPsResponseFullFilterV1JSON struct { - DestinationAddress apijson.Field - DestinationPort apijson.Field - Protocol apijson.Field - SourceAddress apijson.Field - SourcePort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPListResponseMagicVisibilityPCAPsResponseFullFilterV1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapListResponseMagicVisibilityPCAPsResponseFullFilterV1JSON) RawJSON() string { - return r.raw -} - // The status of the packet capture request. type PCAPListResponseMagicVisibilityPCAPsResponseFullStatus string @@ -686,144 +686,44 @@ const ( func (r PCAPListResponseMagicVisibilityPCAPsResponseFullType) IsKnown() bool { switch r { - case PCAPListResponseMagicVisibilityPCAPsResponseFullTypeSimple, PCAPListResponseMagicVisibilityPCAPsResponseFullTypeFull: - return true - } - return false -} - -// Union satisfied by [pcaps.PCAPGetResponseMagicVisibilityPCAPsResponseSimple] or -// [pcaps.PCAPGetResponseMagicVisibilityPCAPsResponseFull]. -type PCAPGetResponse interface { - implementsPCAPsPCAPGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PCAPGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PCAPGetResponseMagicVisibilityPCAPsResponseSimple{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PCAPGetResponseMagicVisibilityPCAPsResponseFull{}), - }, - ) -} - -type PCAPGetResponseMagicVisibilityPCAPsResponseSimple struct { - // The ID for the packet capture. - ID string `json:"id"` - // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 PCAPGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1 `json:"filter_v1"` - // The status of the packet capture request. - Status PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus `json:"status"` - // The RFC 3339 timestamp when the packet capture was created. - Submitted string `json:"submitted"` - // The system used to collect packet captures. - System PCAPGetResponseMagicVisibilityPCAPsResponseSimpleSystem `json:"system"` - // The packet capture duration in seconds. - TimeLimit float64 `json:"time_limit"` - // The type of packet capture. `Simple` captures sampled packets, and `full` - // captures entire payloads and non-sampled packets. - Type PCAPGetResponseMagicVisibilityPCAPsResponseSimpleType `json:"type"` - JSON pcapGetResponseMagicVisibilityPCAPsResponseSimpleJSON `json:"-"` -} - -// pcapGetResponseMagicVisibilityPCAPsResponseSimpleJSON contains the JSON metadata -// for the struct [PCAPGetResponseMagicVisibilityPCAPsResponseSimple] -type pcapGetResponseMagicVisibilityPCAPsResponseSimpleJSON struct { - ID apijson.Field - FilterV1 apijson.Field - Status apijson.Field - Submitted apijson.Field - System apijson.Field - TimeLimit apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPGetResponseMagicVisibilityPCAPsResponseSimple) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapGetResponseMagicVisibilityPCAPsResponseSimpleJSON) RawJSON() string { - return r.raw -} - -func (r PCAPGetResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPsPCAPGetResponse() {} - -// The packet capture filter. When this field is empty, all packets are captured. -type PCAPGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1 struct { - // The destination IP address of the packet. - DestinationAddress string `json:"destination_address"` - // The destination port of the packet. - DestinationPort float64 `json:"destination_port"` - // The protocol number of the packet. - Protocol float64 `json:"protocol"` - // The source IP address of the packet. - SourceAddress string `json:"source_address"` - // The source port of the packet. - SourcePort float64 `json:"source_port"` - JSON pcapGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON `json:"-"` -} - -// pcapGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON contains the JSON -// metadata for the struct -// [PCAPGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1] -type pcapGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON struct { - DestinationAddress apijson.Field - DestinationPort apijson.Field - Protocol apijson.Field - SourceAddress apijson.Field - SourcePort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1JSON) RawJSON() string { - return r.raw + case PCAPListResponseMagicVisibilityPCAPsResponseFullTypeSimple, PCAPListResponseMagicVisibilityPCAPsResponseFullTypeFull: + return true + } + return false } // The status of the packet capture request. -type PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus string +type PCAPListResponseStatus string const ( - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusUnknown PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "unknown" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusSuccess PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "success" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusPending PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "pending" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusRunning PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "running" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusConversionPending PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "conversion_pending" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusConversionRunning PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "conversion_running" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusComplete PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "complete" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusFailed PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus = "failed" + PCAPListResponseStatusUnknown PCAPListResponseStatus = "unknown" + PCAPListResponseStatusSuccess PCAPListResponseStatus = "success" + PCAPListResponseStatusPending PCAPListResponseStatus = "pending" + PCAPListResponseStatusRunning PCAPListResponseStatus = "running" + PCAPListResponseStatusConversionPending PCAPListResponseStatus = "conversion_pending" + PCAPListResponseStatusConversionRunning PCAPListResponseStatus = "conversion_running" + PCAPListResponseStatusComplete PCAPListResponseStatus = "complete" + PCAPListResponseStatusFailed PCAPListResponseStatus = "failed" ) -func (r PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatus) IsKnown() bool { +func (r PCAPListResponseStatus) IsKnown() bool { switch r { - case PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusUnknown, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusSuccess, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusPending, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusRunning, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusConversionPending, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusConversionRunning, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusComplete, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleStatusFailed: + case PCAPListResponseStatusUnknown, PCAPListResponseStatusSuccess, PCAPListResponseStatusPending, PCAPListResponseStatusRunning, PCAPListResponseStatusConversionPending, PCAPListResponseStatusConversionRunning, PCAPListResponseStatusComplete, PCAPListResponseStatusFailed: return true } return false } // The system used to collect packet captures. -type PCAPGetResponseMagicVisibilityPCAPsResponseSimpleSystem string +type PCAPListResponseSystem string const ( - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleSystemMagicTransit PCAPGetResponseMagicVisibilityPCAPsResponseSimpleSystem = "magic-transit" + PCAPListResponseSystemMagicTransit PCAPListResponseSystem = "magic-transit" ) -func (r PCAPGetResponseMagicVisibilityPCAPsResponseSimpleSystem) IsKnown() bool { +func (r PCAPListResponseSystem) IsKnown() bool { switch r { - case PCAPGetResponseMagicVisibilityPCAPsResponseSimpleSystemMagicTransit: + case PCAPListResponseSystemMagicTransit: return true } return false @@ -831,21 +731,107 @@ func (r PCAPGetResponseMagicVisibilityPCAPsResponseSimpleSystem) IsKnown() bool // The type of packet capture. `Simple` captures sampled packets, and `full` // captures entire payloads and non-sampled packets. -type PCAPGetResponseMagicVisibilityPCAPsResponseSimpleType string +type PCAPListResponseType string const ( - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleTypeSimple PCAPGetResponseMagicVisibilityPCAPsResponseSimpleType = "simple" - PCAPGetResponseMagicVisibilityPCAPsResponseSimpleTypeFull PCAPGetResponseMagicVisibilityPCAPsResponseSimpleType = "full" + PCAPListResponseTypeSimple PCAPListResponseType = "simple" + PCAPListResponseTypeFull PCAPListResponseType = "full" ) -func (r PCAPGetResponseMagicVisibilityPCAPsResponseSimpleType) IsKnown() bool { +func (r PCAPListResponseType) IsKnown() bool { switch r { - case PCAPGetResponseMagicVisibilityPCAPsResponseSimpleTypeSimple, PCAPGetResponseMagicVisibilityPCAPsResponseSimpleTypeFull: + case PCAPListResponseTypeSimple, PCAPListResponseTypeFull: return true } return false } +type PCAPGetResponse struct { + // The packet capture filter. When this field is empty, all packets are captured. + FilterV1 PCAPFilter `json:"filter_v1"` + // The ID for the packet capture. + ID string `json:"id"` + // The status of the packet capture request. + Status PCAPGetResponseStatus `json:"status"` + // The RFC 3339 timestamp when the packet capture was created. + Submitted string `json:"submitted"` + // The system used to collect packet captures. + System PCAPGetResponseSystem `json:"system"` + // The packet capture duration in seconds. + TimeLimit float64 `json:"time_limit"` + // The type of packet capture. `Simple` captures sampled packets, and `full` + // captures entire payloads and non-sampled packets. + Type PCAPGetResponseType `json:"type"` + // The maximum number of bytes to capture. This field only applies to `full` packet + // captures. + ByteLimit float64 `json:"byte_limit"` + // The name of the data center used for the packet capture. This can be a specific + // colo (ord02) or a multi-colo name (ORD). This field only applies to `full` + // packet captures. + ColoName string `json:"colo_name"` + // The full URI for the bucket. This field only applies to `full` packet captures. + DestinationConf string `json:"destination_conf"` + // An error message that describes why the packet capture failed. This field only + // applies to `full` packet captures. + ErrorMessage string `json:"error_message"` + JSON pcapGetResponseJSON `json:"-"` + union PCAPGetResponseUnion +} + +// pcapGetResponseJSON contains the JSON metadata for the struct [PCAPGetResponse] +type pcapGetResponseJSON struct { + FilterV1 apijson.Field + ID apijson.Field + Status apijson.Field + Submitted apijson.Field + System apijson.Field + TimeLimit apijson.Field + Type apijson.Field + ByteLimit apijson.Field + ColoName apijson.Field + DestinationConf apijson.Field + ErrorMessage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r pcapGetResponseJSON) RawJSON() string { + return r.raw +} + +func (r *PCAPGetResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r PCAPGetResponse) AsUnion() PCAPGetResponseUnion { + return r.union +} + +// Union satisfied by [pcaps.PCAP] or +// [pcaps.PCAPGetResponseMagicVisibilityPCAPsResponseFull]. +type PCAPGetResponseUnion interface { + implementsPCAPsPCAPGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PCAPGetResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PCAP{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PCAPGetResponseMagicVisibilityPCAPsResponseFull{}), + }, + ) +} + type PCAPGetResponseMagicVisibilityPCAPsResponseFull struct { // The ID for the packet capture. ID string `json:"id"` @@ -862,7 +848,7 @@ type PCAPGetResponseMagicVisibilityPCAPsResponseFull struct { // applies to `full` packet captures. ErrorMessage string `json:"error_message"` // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 PCAPGetResponseMagicVisibilityPCAPsResponseFullFilterV1 `json:"filter_v1"` + FilterV1 PCAPFilter `json:"filter_v1"` // The status of the packet capture request. Status PCAPGetResponseMagicVisibilityPCAPsResponseFullStatus `json:"status"` // The RFC 3339 timestamp when the packet capture was created. @@ -905,42 +891,6 @@ func (r pcapGetResponseMagicVisibilityPCAPsResponseFullJSON) RawJSON() string { func (r PCAPGetResponseMagicVisibilityPCAPsResponseFull) implementsPCAPsPCAPGetResponse() {} -// The packet capture filter. When this field is empty, all packets are captured. -type PCAPGetResponseMagicVisibilityPCAPsResponseFullFilterV1 struct { - // The destination IP address of the packet. - DestinationAddress string `json:"destination_address"` - // The destination port of the packet. - DestinationPort float64 `json:"destination_port"` - // The protocol number of the packet. - Protocol float64 `json:"protocol"` - // The source IP address of the packet. - SourceAddress string `json:"source_address"` - // The source port of the packet. - SourcePort float64 `json:"source_port"` - JSON pcapGetResponseMagicVisibilityPCAPsResponseFullFilterV1JSON `json:"-"` -} - -// pcapGetResponseMagicVisibilityPCAPsResponseFullFilterV1JSON contains the JSON -// metadata for the struct -// [PCAPGetResponseMagicVisibilityPCAPsResponseFullFilterV1] -type pcapGetResponseMagicVisibilityPCAPsResponseFullFilterV1JSON struct { - DestinationAddress apijson.Field - DestinationPort apijson.Field - Protocol apijson.Field - SourceAddress apijson.Field - SourcePort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPGetResponseMagicVisibilityPCAPsResponseFullFilterV1) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapGetResponseMagicVisibilityPCAPsResponseFullFilterV1JSON) RawJSON() string { - return r.raw -} - // The status of the packet capture request. type PCAPGetResponseMagicVisibilityPCAPsResponseFullStatus string @@ -995,53 +945,135 @@ func (r PCAPGetResponseMagicVisibilityPCAPsResponseFullType) IsKnown() bool { return false } -// This interface is a union satisfied by one of the following: -// [PCAPNewParamsMagicVisibilityPCAPsRequestSimple], -// [PCAPNewParamsMagicVisibilityPCAPsRequestFull]. -type PCAPNewParams interface { - ImplementsPCAPNewParams() +// The status of the packet capture request. +type PCAPGetResponseStatus string + +const ( + PCAPGetResponseStatusUnknown PCAPGetResponseStatus = "unknown" + PCAPGetResponseStatusSuccess PCAPGetResponseStatus = "success" + PCAPGetResponseStatusPending PCAPGetResponseStatus = "pending" + PCAPGetResponseStatusRunning PCAPGetResponseStatus = "running" + PCAPGetResponseStatusConversionPending PCAPGetResponseStatus = "conversion_pending" + PCAPGetResponseStatusConversionRunning PCAPGetResponseStatus = "conversion_running" + PCAPGetResponseStatusComplete PCAPGetResponseStatus = "complete" + PCAPGetResponseStatusFailed PCAPGetResponseStatus = "failed" +) + +func (r PCAPGetResponseStatus) IsKnown() bool { + switch r { + case PCAPGetResponseStatusUnknown, PCAPGetResponseStatusSuccess, PCAPGetResponseStatusPending, PCAPGetResponseStatusRunning, PCAPGetResponseStatusConversionPending, PCAPGetResponseStatusConversionRunning, PCAPGetResponseStatusComplete, PCAPGetResponseStatusFailed: + return true + } + return false +} + +// The system used to collect packet captures. +type PCAPGetResponseSystem string + +const ( + PCAPGetResponseSystemMagicTransit PCAPGetResponseSystem = "magic-transit" +) + +func (r PCAPGetResponseSystem) IsKnown() bool { + switch r { + case PCAPGetResponseSystemMagicTransit: + return true + } + return false +} + +// The type of packet capture. `Simple` captures sampled packets, and `full` +// captures entire payloads and non-sampled packets. +type PCAPGetResponseType string - getAccountID() param.Field[string] +const ( + PCAPGetResponseTypeSimple PCAPGetResponseType = "simple" + PCAPGetResponseTypeFull PCAPGetResponseType = "full" +) + +func (r PCAPGetResponseType) IsKnown() bool { + switch r { + case PCAPGetResponseTypeSimple, PCAPGetResponseTypeFull: + return true + } + return false } -type PCAPNewParamsMagicVisibilityPCAPsRequestSimple struct { +type PCAPNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body PCAPNewParamsBodyUnion `json:"body,required"` +} + +func (r PCAPNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type PCAPNewParamsBody struct { + // The packet capture filter. When this field is empty, all packets are captured. + FilterV1 param.Field[PCAPFilterParam] `json:"filter_v1"` // The limit of packets contained in a packet capture. - PacketLimit param.Field[float64] `json:"packet_limit,required"` + PacketLimit param.Field[float64] `json:"packet_limit"` // The system used to collect packet captures. - System param.Field[PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystem] `json:"system,required"` + System param.Field[PCAPNewParamsBodySystem] `json:"system,required"` // The packet capture duration in seconds. TimeLimit param.Field[float64] `json:"time_limit,required"` // The type of packet capture. `Simple` captures sampled packets, and `full` // captures entire payloads and non-sampled packets. - Type param.Field[PCAPNewParamsMagicVisibilityPCAPsRequestSimpleType] `json:"type,required"` - // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 param.Field[PCAPNewParamsMagicVisibilityPCAPsRequestSimpleFilterV1] `json:"filter_v1"` + Type param.Field[PCAPNewParamsBodyType] `json:"type,required"` + // The maximum number of bytes to capture. This field only applies to `full` packet + // captures. + ByteLimit param.Field[float64] `json:"byte_limit"` + // The name of the data center used for the packet capture. This can be a specific + // colo (ord02) or a multi-colo name (ORD). This field only applies to `full` + // packet captures. + ColoName param.Field[string] `json:"colo_name"` + // The full URI for the bucket. This field only applies to `full` packet captures. + DestinationConf param.Field[string] `json:"destination_conf"` } -func (r PCAPNewParamsMagicVisibilityPCAPsRequestSimple) MarshalJSON() (data []byte, err error) { +func (r PCAPNewParamsBody) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r PCAPNewParamsMagicVisibilityPCAPsRequestSimple) getAccountID() param.Field[string] { - return r.AccountID +func (r PCAPNewParamsBody) implementsPCAPsPCAPNewParamsBodyUnion() {} + +// Satisfied by [pcaps.PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimple], +// [pcaps.PCAPNewParamsBodyMagicVisibilityPCAPsRequestFull], [PCAPNewParamsBody]. +type PCAPNewParamsBodyUnion interface { + implementsPCAPsPCAPNewParamsBodyUnion() } -func (PCAPNewParamsMagicVisibilityPCAPsRequestSimple) ImplementsPCAPNewParams() { +type PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimple struct { + // The limit of packets contained in a packet capture. + PacketLimit param.Field[float64] `json:"packet_limit,required"` + // The system used to collect packet captures. + System param.Field[PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleSystem] `json:"system,required"` + // The packet capture duration in seconds. + TimeLimit param.Field[float64] `json:"time_limit,required"` + // The type of packet capture. `Simple` captures sampled packets, and `full` + // captures entire payloads and non-sampled packets. + Type param.Field[PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleType] `json:"type,required"` + // The packet capture filter. When this field is empty, all packets are captured. + FilterV1 param.Field[PCAPFilterParam] `json:"filter_v1"` +} +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimple) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimple) implementsPCAPsPCAPNewParamsBodyUnion() {} + // The system used to collect packet captures. -type PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystem string +type PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleSystem string const ( - PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystemMagicTransit PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystem = "magic-transit" + PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleSystemMagicTransit PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleSystem = "magic-transit" ) -func (r PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystem) IsKnown() bool { +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleSystem) IsKnown() bool { switch r { - case PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystemMagicTransit: + case PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleSystemMagicTransit: return true } return false @@ -1049,42 +1081,22 @@ func (r PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystem) IsKnown() bool { // The type of packet capture. `Simple` captures sampled packets, and `full` // captures entire payloads and non-sampled packets. -type PCAPNewParamsMagicVisibilityPCAPsRequestSimpleType string +type PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleType string const ( - PCAPNewParamsMagicVisibilityPCAPsRequestSimpleTypeSimple PCAPNewParamsMagicVisibilityPCAPsRequestSimpleType = "simple" - PCAPNewParamsMagicVisibilityPCAPsRequestSimpleTypeFull PCAPNewParamsMagicVisibilityPCAPsRequestSimpleType = "full" + PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleTypeSimple PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleType = "simple" + PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleTypeFull PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleType = "full" ) -func (r PCAPNewParamsMagicVisibilityPCAPsRequestSimpleType) IsKnown() bool { +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleType) IsKnown() bool { switch r { - case PCAPNewParamsMagicVisibilityPCAPsRequestSimpleTypeSimple, PCAPNewParamsMagicVisibilityPCAPsRequestSimpleTypeFull: + case PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleTypeSimple, PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleTypeFull: return true } return false } -// The packet capture filter. When this field is empty, all packets are captured. -type PCAPNewParamsMagicVisibilityPCAPsRequestSimpleFilterV1 struct { - // The destination IP address of the packet. - DestinationAddress param.Field[string] `json:"destination_address"` - // The destination port of the packet. - DestinationPort param.Field[float64] `json:"destination_port"` - // The protocol number of the packet. - Protocol param.Field[float64] `json:"protocol"` - // The source IP address of the packet. - SourceAddress param.Field[string] `json:"source_address"` - // The source port of the packet. - SourcePort param.Field[float64] `json:"source_port"` -} - -func (r PCAPNewParamsMagicVisibilityPCAPsRequestSimpleFilterV1) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PCAPNewParamsMagicVisibilityPCAPsRequestFull struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` +type PCAPNewParamsBodyMagicVisibilityPCAPsRequestFull struct { // The name of the data center used for the packet capture. This can be a specific // colo (ord02) or a multi-colo name (ORD). This field only applies to `full` // packet captures. @@ -1092,43 +1104,37 @@ type PCAPNewParamsMagicVisibilityPCAPsRequestFull struct { // The full URI for the bucket. This field only applies to `full` packet captures. DestinationConf param.Field[string] `json:"destination_conf,required"` // The system used to collect packet captures. - System param.Field[PCAPNewParamsMagicVisibilityPCAPsRequestFullSystem] `json:"system,required"` + System param.Field[PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullSystem] `json:"system,required"` // The packet capture duration in seconds. TimeLimit param.Field[float64] `json:"time_limit,required"` // The type of packet capture. `Simple` captures sampled packets, and `full` // captures entire payloads and non-sampled packets. - Type param.Field[PCAPNewParamsMagicVisibilityPCAPsRequestFullType] `json:"type,required"` + Type param.Field[PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullType] `json:"type,required"` // The maximum number of bytes to capture. This field only applies to `full` packet // captures. ByteLimit param.Field[float64] `json:"byte_limit"` // The packet capture filter. When this field is empty, all packets are captured. - FilterV1 param.Field[PCAPNewParamsMagicVisibilityPCAPsRequestFullFilterV1] `json:"filter_v1"` + FilterV1 param.Field[PCAPFilterParam] `json:"filter_v1"` // The limit of packets contained in a packet capture. PacketLimit param.Field[float64] `json:"packet_limit"` } -func (r PCAPNewParamsMagicVisibilityPCAPsRequestFull) MarshalJSON() (data []byte, err error) { +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestFull) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r PCAPNewParamsMagicVisibilityPCAPsRequestFull) getAccountID() param.Field[string] { - return r.AccountID -} - -func (PCAPNewParamsMagicVisibilityPCAPsRequestFull) ImplementsPCAPNewParams() { - -} +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestFull) implementsPCAPsPCAPNewParamsBodyUnion() {} // The system used to collect packet captures. -type PCAPNewParamsMagicVisibilityPCAPsRequestFullSystem string +type PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullSystem string const ( - PCAPNewParamsMagicVisibilityPCAPsRequestFullSystemMagicTransit PCAPNewParamsMagicVisibilityPCAPsRequestFullSystem = "magic-transit" + PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullSystemMagicTransit PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullSystem = "magic-transit" ) -func (r PCAPNewParamsMagicVisibilityPCAPsRequestFullSystem) IsKnown() bool { +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullSystem) IsKnown() bool { switch r { - case PCAPNewParamsMagicVisibilityPCAPsRequestFullSystemMagicTransit: + case PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullSystemMagicTransit: return true } return false @@ -1136,43 +1142,57 @@ func (r PCAPNewParamsMagicVisibilityPCAPsRequestFullSystem) IsKnown() bool { // The type of packet capture. `Simple` captures sampled packets, and `full` // captures entire payloads and non-sampled packets. -type PCAPNewParamsMagicVisibilityPCAPsRequestFullType string +type PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullType string const ( - PCAPNewParamsMagicVisibilityPCAPsRequestFullTypeSimple PCAPNewParamsMagicVisibilityPCAPsRequestFullType = "simple" - PCAPNewParamsMagicVisibilityPCAPsRequestFullTypeFull PCAPNewParamsMagicVisibilityPCAPsRequestFullType = "full" + PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullTypeSimple PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullType = "simple" + PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullTypeFull PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullType = "full" ) -func (r PCAPNewParamsMagicVisibilityPCAPsRequestFullType) IsKnown() bool { +func (r PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullType) IsKnown() bool { switch r { - case PCAPNewParamsMagicVisibilityPCAPsRequestFullTypeSimple, PCAPNewParamsMagicVisibilityPCAPsRequestFullTypeFull: + case PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullTypeSimple, PCAPNewParamsBodyMagicVisibilityPCAPsRequestFullTypeFull: return true } return false } -// The packet capture filter. When this field is empty, all packets are captured. -type PCAPNewParamsMagicVisibilityPCAPsRequestFullFilterV1 struct { - // The destination IP address of the packet. - DestinationAddress param.Field[string] `json:"destination_address"` - // The destination port of the packet. - DestinationPort param.Field[float64] `json:"destination_port"` - // The protocol number of the packet. - Protocol param.Field[float64] `json:"protocol"` - // The source IP address of the packet. - SourceAddress param.Field[string] `json:"source_address"` - // The source port of the packet. - SourcePort param.Field[float64] `json:"source_port"` +// The system used to collect packet captures. +type PCAPNewParamsBodySystem string + +const ( + PCAPNewParamsBodySystemMagicTransit PCAPNewParamsBodySystem = "magic-transit" +) + +func (r PCAPNewParamsBodySystem) IsKnown() bool { + switch r { + case PCAPNewParamsBodySystemMagicTransit: + return true + } + return false } -func (r PCAPNewParamsMagicVisibilityPCAPsRequestFullFilterV1) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// The type of packet capture. `Simple` captures sampled packets, and `full` +// captures entire payloads and non-sampled packets. +type PCAPNewParamsBodyType string + +const ( + PCAPNewParamsBodyTypeSimple PCAPNewParamsBodyType = "simple" + PCAPNewParamsBodyTypeFull PCAPNewParamsBodyType = "full" +) + +func (r PCAPNewParamsBodyType) IsKnown() bool { + switch r { + case PCAPNewParamsBodyTypeSimple, PCAPNewParamsBodyTypeFull: + return true + } + return false } type PCAPNewResponseEnvelope struct { - Errors []PCAPNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PCAPNewResponseEnvelopeMessages `json:"messages,required"` - Result PCAPNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PCAPNewResponse `json:"result,required"` // Whether the API call was successful Success PCAPNewResponseEnvelopeSuccess `json:"success,required"` JSON pcapNewResponseEnvelopeJSON `json:"-"` @@ -1197,52 +1217,6 @@ func (r pcapNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PCAPNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// pcapNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PCAPNewResponseEnvelopeErrors] -type pcapNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PCAPNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// pcapNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PCAPNewResponseEnvelopeMessages] -type pcapNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PCAPNewResponseEnvelopeSuccess bool @@ -1269,9 +1243,9 @@ type PCAPGetParams struct { } type PCAPGetResponseEnvelope struct { - Errors []PCAPGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PCAPGetResponseEnvelopeMessages `json:"messages,required"` - Result PCAPGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PCAPGetResponse `json:"result,required"` // Whether the API call was successful Success PCAPGetResponseEnvelopeSuccess `json:"success,required"` JSON pcapGetResponseEnvelopeJSON `json:"-"` @@ -1296,52 +1270,6 @@ func (r pcapGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PCAPGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pcapGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PCAPGetResponseEnvelopeErrors] -type pcapGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PCAPGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pcapGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PCAPGetResponseEnvelopeMessages] -type pcapGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PCAPGetResponseEnvelopeSuccess bool diff --git a/pcaps/pcap_test.go b/pcaps/pcap_test.go index c993bef8918..d67b4f2e140 100644 --- a/pcaps/pcap_test.go +++ b/pcaps/pcap_test.go @@ -28,19 +28,21 @@ func TestPCAPNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.PCAPs.New(context.TODO(), pcaps.PCAPNewParamsMagicVisibilityPCAPsRequestSimple{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - PacketLimit: cloudflare.F(10000.000000), - System: cloudflare.F(pcaps.PCAPNewParamsMagicVisibilityPCAPsRequestSimpleSystemMagicTransit), - TimeLimit: cloudflare.F(300.000000), - Type: cloudflare.F(pcaps.PCAPNewParamsMagicVisibilityPCAPsRequestSimpleTypeSimple), - FilterV1: cloudflare.F(pcaps.PCAPNewParamsMagicVisibilityPCAPsRequestSimpleFilterV1{ - DestinationAddress: cloudflare.F("1.2.3.4"), - DestinationPort: cloudflare.F(80.000000), - Protocol: cloudflare.F(6.000000), - SourceAddress: cloudflare.F("1.2.3.4"), - SourcePort: cloudflare.F(123.000000), - }), + _, err := client.PCAPs.New(context.TODO(), pcaps.PCAPNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: pcaps.PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimple{ + FilterV1: cloudflare.F(pcaps.PCAPFilterParam{ + DestinationAddress: cloudflare.F("1.2.3.4"), + DestinationPort: cloudflare.F(80.000000), + Protocol: cloudflare.F(6.000000), + SourceAddress: cloudflare.F("1.2.3.4"), + SourcePort: cloudflare.F(123.000000), + }), + PacketLimit: cloudflare.F(10000.000000), + System: cloudflare.F(pcaps.PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleSystemMagicTransit), + TimeLimit: cloudflare.F(300.000000), + Type: cloudflare.F(pcaps.PCAPNewParamsBodyMagicVisibilityPCAPsRequestSimpleTypeSimple), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/plans/aliases.go b/plans/aliases.go index b6534d7e5e9..5c99aff0795 100644 --- a/plans/aliases.go +++ b/plans/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/plans/plan.go b/plans/plan.go index 55b0554a9d1..326175834bc 100644 --- a/plans/plan.go +++ b/plans/plan.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -134,9 +135,9 @@ func (r AvailableRatePlanFrequency) IsKnown() bool { } type PlanGetResponseEnvelope struct { - Errors []PlanGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PlanGetResponseEnvelopeMessages `json:"messages,required"` - Result AvailableRatePlan `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AvailableRatePlan `json:"result,required"` // Whether the API call was successful Success PlanGetResponseEnvelopeSuccess `json:"success,required"` JSON planGetResponseEnvelopeJSON `json:"-"` @@ -161,52 +162,6 @@ func (r planGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PlanGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON planGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// planGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PlanGetResponseEnvelopeErrors] -type planGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PlanGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r planGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PlanGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON planGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// planGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PlanGetResponseEnvelopeMessages] -type planGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PlanGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r planGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PlanGetResponseEnvelopeSuccess bool diff --git a/queues/aliases.go b/queues/aliases.go index 114496ba0e0..d6a0cb83648 100644 --- a/queues/aliases.go +++ b/queues/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/queues/consumer.go b/queues/consumer.go index a8ead39bb02..9ada172c59b 100644 --- a/queues/consumer.go +++ b/queues/consumer.go @@ -60,10 +60,10 @@ func (r *ConsumerService) Update(ctx context.Context, queueID string, consumerID } // Deletes the consumer for a queue. -func (r *ConsumerService) Delete(ctx context.Context, queueID string, consumerID string, body ConsumerDeleteParams, opts ...option.RequestOption) (res *ConsumerDeleteResponse, err error) { +func (r *ConsumerService) Delete(ctx context.Context, queueID string, consumerID string, params ConsumerDeleteParams, opts ...option.RequestOption) (res *ConsumerDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ConsumerDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/queues/%s/consumers/%s", body.AccountID, queueID, consumerID) + path := fmt.Sprintf("accounts/%s/queues/%s/consumers/%s", params.AccountID, queueID, consumerID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -73,7 +73,7 @@ func (r *ConsumerService) Delete(ctx context.Context, queueID string, consumerID } // Returns the consumers for a queue. -func (r *ConsumerService) Get(ctx context.Context, queueID string, query ConsumerGetParams, opts ...option.RequestOption) (res *[]ConsumerGetResponse, err error) { +func (r *ConsumerService) Get(ctx context.Context, queueID string, query ConsumerGetParams, opts ...option.RequestOption) (res *[]Consumer, err error) { opts = append(r.Options[:], opts...) var env ConsumerGetResponseEnvelope path := fmt.Sprintf("accounts/%s/queues/%s/consumers", query.AccountID, queueID) @@ -85,6 +85,60 @@ func (r *ConsumerService) Get(ctx context.Context, queueID string, query Consume return } +type Consumer struct { + CreatedOn interface{} `json:"created_on"` + Environment interface{} `json:"environment"` + QueueName interface{} `json:"queue_name"` + Service interface{} `json:"service"` + Settings ConsumerSettings `json:"settings"` + JSON consumerJSON `json:"-"` +} + +// consumerJSON contains the JSON metadata for the struct [Consumer] +type consumerJSON struct { + CreatedOn apijson.Field + Environment apijson.Field + QueueName apijson.Field + Service apijson.Field + Settings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Consumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerJSON) RawJSON() string { + return r.raw +} + +type ConsumerSettings struct { + // The maximum number of messages to include in a batch + BatchSize float64 `json:"batch_size"` + MaxRetries float64 `json:"max_retries"` + MaxWaitTimeMs float64 `json:"max_wait_time_ms"` + JSON consumerSettingsJSON `json:"-"` +} + +// consumerSettingsJSON contains the JSON metadata for the struct +// [ConsumerSettings] +type consumerSettingsJSON struct { + BatchSize apijson.Field + MaxRetries apijson.Field + MaxWaitTimeMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerSettingsJSON) RawJSON() string { + return r.raw +} + type ConsumerNewResponse struct { CreatedOn interface{} `json:"created_on"` DeadLetterQueue string `json:"dead_letter_queue"` @@ -200,13 +254,13 @@ func (r consumerUpdateResponseSettingsJSON) RawJSON() string { // Union satisfied by [queues.ConsumerDeleteResponseUnknown], // [queues.ConsumerDeleteResponseArray] or [shared.UnionString]. -type ConsumerDeleteResponse interface { - ImplementsQueuesConsumerDeleteResponse() +type ConsumerDeleteResponseUnion interface { + ImplementsQueuesConsumerDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ConsumerDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*ConsumerDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -221,67 +275,12 @@ func init() { type ConsumerDeleteResponseArray []interface{} -func (r ConsumerDeleteResponseArray) ImplementsQueuesConsumerDeleteResponse() {} - -type ConsumerGetResponse struct { - CreatedOn interface{} `json:"created_on"` - Environment interface{} `json:"environment"` - QueueName interface{} `json:"queue_name"` - Service interface{} `json:"service"` - Settings ConsumerGetResponseSettings `json:"settings"` - JSON consumerGetResponseJSON `json:"-"` -} - -// consumerGetResponseJSON contains the JSON metadata for the struct -// [ConsumerGetResponse] -type consumerGetResponseJSON struct { - CreatedOn apijson.Field - Environment apijson.Field - QueueName apijson.Field - Service apijson.Field - Settings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerGetResponseJSON) RawJSON() string { - return r.raw -} - -type ConsumerGetResponseSettings struct { - // The maximum number of messages to include in a batch - BatchSize float64 `json:"batch_size"` - MaxRetries float64 `json:"max_retries"` - MaxWaitTimeMs float64 `json:"max_wait_time_ms"` - JSON consumerGetResponseSettingsJSON `json:"-"` -} - -// consumerGetResponseSettingsJSON contains the JSON metadata for the struct -// [ConsumerGetResponseSettings] -type consumerGetResponseSettingsJSON struct { - BatchSize apijson.Field - MaxRetries apijson.Field - MaxWaitTimeMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerGetResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerGetResponseSettingsJSON) RawJSON() string { - return r.raw -} +func (r ConsumerDeleteResponseArray) ImplementsQueuesConsumerDeleteResponseUnion() {} type ConsumerNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r ConsumerNewParams) MarshalJSON() (data []byte, err error) { @@ -289,9 +288,14 @@ func (r ConsumerNewParams) MarshalJSON() (data []byte, err error) { } type ConsumerNewResponseEnvelope struct { - Errors []ConsumerNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ConsumerNewResponseEnvelopeMessages `json:"messages,required"` - Result ConsumerNewResponse `json:"result,required,nullable"` + CreatedOn interface{} `json:"created_on,required"` + DeadLetterQueue interface{} `json:"dead_letter_queue,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + QueueName interface{} `json:"queue_name,required"` + Result ConsumerNewResponse `json:"result,required,nullable"` + ScriptName interface{} `json:"script_name,required"` + Settings interface{} `json:"settings,required"` // Whether the API call was successful Success ConsumerNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo ConsumerNewResponseEnvelopeResultInfo `json:"result_info"` @@ -301,13 +305,18 @@ type ConsumerNewResponseEnvelope struct { // consumerNewResponseEnvelopeJSON contains the JSON metadata for the struct // [ConsumerNewResponseEnvelope] type consumerNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field + CreatedOn apijson.Field + DeadLetterQueue apijson.Field + Errors apijson.Field + Messages apijson.Field + QueueName apijson.Field + Result apijson.Field + ScriptName apijson.Field + Settings apijson.Field + Success apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *ConsumerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { @@ -318,52 +327,6 @@ func (r consumerNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConsumerNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// consumerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConsumerNewResponseEnvelopeErrors] -type consumerNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConsumerNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// consumerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConsumerNewResponseEnvelopeMessages] -type consumerNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConsumerNewResponseEnvelopeSuccess bool @@ -412,8 +375,8 @@ func (r consumerNewResponseEnvelopeResultInfoJSON) RawJSON() string { type ConsumerUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r ConsumerUpdateParams) MarshalJSON() (data []byte, err error) { @@ -421,9 +384,14 @@ func (r ConsumerUpdateParams) MarshalJSON() (data []byte, err error) { } type ConsumerUpdateResponseEnvelope struct { - Errors []ConsumerUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ConsumerUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ConsumerUpdateResponse `json:"result,required,nullable"` + CreatedOn interface{} `json:"created_on,required"` + DeadLetterQueue interface{} `json:"dead_letter_queue,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + QueueName interface{} `json:"queue_name,required"` + Result ConsumerUpdateResponse `json:"result,required,nullable"` + ScriptName interface{} `json:"script_name,required"` + Settings interface{} `json:"settings,required"` // Whether the API call was successful Success ConsumerUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo ConsumerUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -433,13 +401,18 @@ type ConsumerUpdateResponseEnvelope struct { // consumerUpdateResponseEnvelopeJSON contains the JSON metadata for the struct // [ConsumerUpdateResponseEnvelope] type consumerUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field + CreatedOn apijson.Field + DeadLetterQueue apijson.Field + Errors apijson.Field + Messages apijson.Field + QueueName apijson.Field + Result apijson.Field + ScriptName apijson.Field + Settings apijson.Field + Success apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *ConsumerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { @@ -450,52 +423,6 @@ func (r consumerUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConsumerUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// consumerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ConsumerUpdateResponseEnvelopeErrors] -type consumerUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConsumerUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// consumerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConsumerUpdateResponseEnvelopeMessages] -type consumerUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConsumerUpdateResponseEnvelopeSuccess bool @@ -545,12 +472,17 @@ func (r consumerUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { type ConsumerDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ConsumerDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ConsumerDeleteResponseEnvelope struct { - Errors []ConsumerDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ConsumerDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ConsumerDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ConsumerDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success ConsumerDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo ConsumerDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -577,52 +509,6 @@ func (r consumerDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConsumerDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// consumerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ConsumerDeleteResponseEnvelopeErrors] -type consumerDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConsumerDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// consumerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConsumerDeleteResponseEnvelopeMessages] -type consumerDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConsumerDeleteResponseEnvelopeSuccess bool @@ -675,9 +561,12 @@ type ConsumerGetParams struct { } type ConsumerGetResponseEnvelope struct { - Errors []ConsumerGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ConsumerGetResponseEnvelopeMessages `json:"messages,required"` - Result []ConsumerGetResponse `json:"result,required,nullable"` + CreatedOn interface{} `json:"created_on,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + QueueName interface{} `json:"queue_name,required"` + Result []Consumer `json:"result,required,nullable"` + Settings interface{} `json:"settings,required"` // Whether the API call was successful Success ConsumerGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo ConsumerGetResponseEnvelopeResultInfo `json:"result_info"` @@ -687,9 +576,12 @@ type ConsumerGetResponseEnvelope struct { // consumerGetResponseEnvelopeJSON contains the JSON metadata for the struct // [ConsumerGetResponseEnvelope] type consumerGetResponseEnvelopeJSON struct { + CreatedOn apijson.Field Errors apijson.Field Messages apijson.Field + QueueName apijson.Field Result apijson.Field + Settings apijson.Field Success apijson.Field ResultInfo apijson.Field raw string @@ -704,52 +596,6 @@ func (r consumerGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConsumerGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// consumerGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ConsumerGetResponseEnvelopeErrors] -type consumerGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConsumerGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON consumerGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// consumerGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ConsumerGetResponseEnvelopeMessages] -type consumerGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConsumerGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r consumerGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConsumerGetResponseEnvelopeSuccess bool diff --git a/queues/consumer_test.go b/queues/consumer_test.go index 011bf460f22..f53c3fca042 100644 --- a/queues/consumer_test.go +++ b/queues/consumer_test.go @@ -33,7 +33,7 @@ func TestConsumerNew(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ + Body: map[string]interface{}{ "dead_letter_queue": "example-dlq", "environment": "production", "script_name": "example-consumer", @@ -42,7 +42,7 @@ func TestConsumerNew(t *testing.T) { "max_retries": int64(3), "max_wait_time_ms": int64(5000), }, - }), + }, }, ) if err != nil { @@ -74,14 +74,14 @@ func TestConsumerUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ + Body: map[string]interface{}{ "dead_letter_queue": "updated-example-dlq", "environment": "production", "script_name": "example-consumer", "settings": map[string]interface{}{ "batch_size": int64(100), }, - }), + }, }, ) if err != nil { @@ -113,6 +113,7 @@ func TestConsumerDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", queues.ConsumerDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/queues/message.go b/queues/message.go index 4e034da274f..476acdeae83 100644 --- a/queues/message.go +++ b/queues/message.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -147,9 +148,9 @@ func (r MessageAckParamsRetry) MarshalJSON() (data []byte, err error) { } type MessageAckResponseEnvelope struct { - Errors []MessageAckResponseEnvelopeErrors `json:"errors,required"` - Messages []MessageAckResponseEnvelopeMessages `json:"messages,required"` - Result MessageAckResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result MessageAckResponse `json:"result,required,nullable"` // Whether the API call was successful Success MessageAckResponseEnvelopeSuccess `json:"success,required"` ResultInfo MessageAckResponseEnvelopeResultInfo `json:"result_info"` @@ -176,52 +177,6 @@ func (r messageAckResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MessageAckResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON messageAckResponseEnvelopeErrorsJSON `json:"-"` -} - -// messageAckResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MessageAckResponseEnvelopeErrors] -type messageAckResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessageAckResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messageAckResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MessageAckResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON messageAckResponseEnvelopeMessagesJSON `json:"-"` -} - -// messageAckResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [MessageAckResponseEnvelopeMessages] -type messageAckResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessageAckResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messageAckResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MessageAckResponseEnvelopeSuccess bool @@ -283,9 +238,9 @@ func (r MessagePullParams) MarshalJSON() (data []byte, err error) { } type MessagePullResponseEnvelope struct { - Errors []MessagePullResponseEnvelopeErrors `json:"errors,required"` - Messages []MessagePullResponseEnvelopeMessages `json:"messages,required"` - Result []MessagePullResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []MessagePullResponse `json:"result,required,nullable"` // Whether the API call was successful Success MessagePullResponseEnvelopeSuccess `json:"success,required"` ResultInfo MessagePullResponseEnvelopeResultInfo `json:"result_info"` @@ -312,52 +267,6 @@ func (r messagePullResponseEnvelopeJSON) RawJSON() string { return r.raw } -type MessagePullResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON messagePullResponseEnvelopeErrorsJSON `json:"-"` -} - -// messagePullResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [MessagePullResponseEnvelopeErrors] -type messagePullResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessagePullResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messagePullResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MessagePullResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON messagePullResponseEnvelopeMessagesJSON `json:"-"` -} - -// messagePullResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [MessagePullResponseEnvelopeMessages] -type messagePullResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessagePullResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messagePullResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type MessagePullResponseEnvelopeSuccess bool diff --git a/queues/queue.go b/queues/queue.go index 3c5d674606a..c8ca1468ac5 100644 --- a/queues/queue.go +++ b/queues/queue.go @@ -39,7 +39,7 @@ func NewQueueService(opts ...option.RequestOption) (r *QueueService) { } // Creates a new queue. -func (r *QueueService) New(ctx context.Context, params QueueNewParams, opts ...option.RequestOption) (res *QueueNewResponse, err error) { +func (r *QueueService) New(ctx context.Context, params QueueNewParams, opts ...option.RequestOption) (res *QueueCreated, err error) { opts = append(r.Options[:], opts...) var env QueueNewResponseEnvelope path := fmt.Sprintf("accounts/%s/queues", params.AccountID) @@ -52,7 +52,7 @@ func (r *QueueService) New(ctx context.Context, params QueueNewParams, opts ...o } // Updates a queue. -func (r *QueueService) Update(ctx context.Context, queueID string, params QueueUpdateParams, opts ...option.RequestOption) (res *QueueUpdateResponse, err error) { +func (r *QueueService) Update(ctx context.Context, queueID string, params QueueUpdateParams, opts ...option.RequestOption) (res *QueueUpdated, err error) { opts = append(r.Options[:], opts...) var env QueueUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/queues/%s", params.AccountID, queueID) @@ -65,7 +65,7 @@ func (r *QueueService) Update(ctx context.Context, queueID string, params QueueU } // Returns the queues owned by an account. -func (r *QueueService) List(ctx context.Context, query QueueListParams, opts ...option.RequestOption) (res *pagination.SinglePage[QueueListResponse], err error) { +func (r *QueueService) List(ctx context.Context, query QueueListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Queue], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -83,15 +83,15 @@ func (r *QueueService) List(ctx context.Context, query QueueListParams, opts ... } // Returns the queues owned by an account. -func (r *QueueService) ListAutoPaging(ctx context.Context, query QueueListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[QueueListResponse] { +func (r *QueueService) ListAutoPaging(ctx context.Context, query QueueListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Queue] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a queue. -func (r *QueueService) Delete(ctx context.Context, queueID string, body QueueDeleteParams, opts ...option.RequestOption) (res *QueueDeleteResponse, err error) { +func (r *QueueService) Delete(ctx context.Context, queueID string, params QueueDeleteParams, opts ...option.RequestOption) (res *QueueDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env QueueDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/queues/%s", body.AccountID, queueID) + path := fmt.Sprintf("accounts/%s/queues/%s", params.AccountID, queueID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -101,7 +101,7 @@ func (r *QueueService) Delete(ctx context.Context, queueID string, body QueueDel } // Get information about a specific queue. -func (r *QueueService) Get(ctx context.Context, queueID string, query QueueGetParams, opts ...option.RequestOption) (res *QueueGetResponse, err error) { +func (r *QueueService) Get(ctx context.Context, queueID string, query QueueGetParams, opts ...option.RequestOption) (res *Queue, err error) { opts = append(r.Options[:], opts...) var env QueueGetResponseEnvelope path := fmt.Sprintf("accounts/%s/queues/%s", query.AccountID, queueID) @@ -113,44 +113,50 @@ func (r *QueueService) Get(ctx context.Context, queueID string, query QueueGetPa return } -type QueueNewResponse struct { - CreatedOn interface{} `json:"created_on"` - ModifiedOn interface{} `json:"modified_on"` - QueueID interface{} `json:"queue_id"` - QueueName string `json:"queue_name"` - JSON queueNewResponseJSON `json:"-"` +type Queue struct { + Consumers interface{} `json:"consumers"` + ConsumersTotalCount interface{} `json:"consumers_total_count"` + CreatedOn interface{} `json:"created_on"` + ModifiedOn interface{} `json:"modified_on"` + Producers interface{} `json:"producers"` + ProducersTotalCount interface{} `json:"producers_total_count"` + QueueID string `json:"queue_id"` + QueueName string `json:"queue_name"` + JSON queueJSON `json:"-"` } -// queueNewResponseJSON contains the JSON metadata for the struct -// [QueueNewResponse] -type queueNewResponseJSON struct { - CreatedOn apijson.Field - ModifiedOn apijson.Field - QueueID apijson.Field - QueueName apijson.Field - raw string - ExtraFields map[string]apijson.Field +// queueJSON contains the JSON metadata for the struct [Queue] +type queueJSON struct { + Consumers apijson.Field + ConsumersTotalCount apijson.Field + CreatedOn apijson.Field + ModifiedOn apijson.Field + Producers apijson.Field + ProducersTotalCount apijson.Field + QueueID apijson.Field + QueueName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *QueueNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Queue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r queueNewResponseJSON) RawJSON() string { +func (r queueJSON) RawJSON() string { return r.raw } -type QueueUpdateResponse struct { - CreatedOn interface{} `json:"created_on"` - ModifiedOn interface{} `json:"modified_on"` - QueueID interface{} `json:"queue_id"` - QueueName string `json:"queue_name"` - JSON queueUpdateResponseJSON `json:"-"` +type QueueCreated struct { + CreatedOn interface{} `json:"created_on"` + ModifiedOn interface{} `json:"modified_on"` + QueueID interface{} `json:"queue_id"` + QueueName string `json:"queue_name"` + JSON queueCreatedJSON `json:"-"` } -// queueUpdateResponseJSON contains the JSON metadata for the struct -// [QueueUpdateResponse] -type queueUpdateResponseJSON struct { +// queueCreatedJSON contains the JSON metadata for the struct [QueueCreated] +type queueCreatedJSON struct { CreatedOn apijson.Field ModifiedOn apijson.Field QueueID apijson.Field @@ -159,58 +165,49 @@ type queueUpdateResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *QueueUpdateResponse) UnmarshalJSON(data []byte) (err error) { +func (r *QueueCreated) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r queueUpdateResponseJSON) RawJSON() string { +func (r queueCreatedJSON) RawJSON() string { return r.raw } -type QueueListResponse struct { - Consumers interface{} `json:"consumers"` - ConsumersTotalCount interface{} `json:"consumers_total_count"` - CreatedOn interface{} `json:"created_on"` - ModifiedOn interface{} `json:"modified_on"` - Producers interface{} `json:"producers"` - ProducersTotalCount interface{} `json:"producers_total_count"` - QueueID string `json:"queue_id"` - QueueName string `json:"queue_name"` - JSON queueListResponseJSON `json:"-"` +type QueueUpdated struct { + CreatedOn interface{} `json:"created_on"` + ModifiedOn interface{} `json:"modified_on"` + QueueID interface{} `json:"queue_id"` + QueueName string `json:"queue_name"` + JSON queueUpdatedJSON `json:"-"` } -// queueListResponseJSON contains the JSON metadata for the struct -// [QueueListResponse] -type queueListResponseJSON struct { - Consumers apijson.Field - ConsumersTotalCount apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Producers apijson.Field - ProducersTotalCount apijson.Field - QueueID apijson.Field - QueueName apijson.Field - raw string - ExtraFields map[string]apijson.Field +// queueUpdatedJSON contains the JSON metadata for the struct [QueueUpdated] +type queueUpdatedJSON struct { + CreatedOn apijson.Field + ModifiedOn apijson.Field + QueueID apijson.Field + QueueName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *QueueListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *QueueUpdated) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r queueListResponseJSON) RawJSON() string { +func (r queueUpdatedJSON) RawJSON() string { return r.raw } // Union satisfied by [queues.QueueDeleteResponseUnknown], // [queues.QueueDeleteResponseArray] or [shared.UnionString]. -type QueueDeleteResponse interface { - ImplementsQueuesQueueDeleteResponse() +type QueueDeleteResponseUnion interface { + ImplementsQueuesQueueDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*QueueDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*QueueDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -225,47 +222,12 @@ func init() { type QueueDeleteResponseArray []interface{} -func (r QueueDeleteResponseArray) ImplementsQueuesQueueDeleteResponse() {} - -type QueueGetResponse struct { - Consumers interface{} `json:"consumers"` - ConsumersTotalCount interface{} `json:"consumers_total_count"` - CreatedOn interface{} `json:"created_on"` - ModifiedOn interface{} `json:"modified_on"` - Producers interface{} `json:"producers"` - ProducersTotalCount interface{} `json:"producers_total_count"` - QueueID string `json:"queue_id"` - QueueName string `json:"queue_name"` - JSON queueGetResponseJSON `json:"-"` -} - -// queueGetResponseJSON contains the JSON metadata for the struct -// [QueueGetResponse] -type queueGetResponseJSON struct { - Consumers apijson.Field - ConsumersTotalCount apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Producers apijson.Field - ProducersTotalCount apijson.Field - QueueID apijson.Field - QueueName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueGetResponseJSON) RawJSON() string { - return r.raw -} +func (r QueueDeleteResponseArray) ImplementsQueuesQueueDeleteResponseUnion() {} type QueueNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r QueueNewParams) MarshalJSON() (data []byte, err error) { @@ -273,9 +235,13 @@ func (r QueueNewParams) MarshalJSON() (data []byte, err error) { } type QueueNewResponseEnvelope struct { - Errors []QueueNewResponseEnvelopeErrors `json:"errors,required"` - Messages []QueueNewResponseEnvelopeMessages `json:"messages,required"` - Result QueueNewResponse `json:"result,required,nullable"` + CreatedOn interface{} `json:"created_on,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + ModifiedOn interface{} `json:"modified_on,required"` + QueueID interface{} `json:"queue_id,required"` + QueueName interface{} `json:"queue_name,required"` + Result QueueCreated `json:"result,required,nullable"` // Whether the API call was successful Success QueueNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueNewResponseEnvelopeResultInfo `json:"result_info"` @@ -285,8 +251,12 @@ type QueueNewResponseEnvelope struct { // queueNewResponseEnvelopeJSON contains the JSON metadata for the struct // [QueueNewResponseEnvelope] type queueNewResponseEnvelopeJSON struct { + CreatedOn apijson.Field Errors apijson.Field Messages apijson.Field + ModifiedOn apijson.Field + QueueID apijson.Field + QueueName apijson.Field Result apijson.Field Success apijson.Field ResultInfo apijson.Field @@ -302,52 +272,6 @@ func (r queueNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type QueueNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// queueNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [QueueNewResponseEnvelopeErrors] -type queueNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type QueueNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// queueNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [QueueNewResponseEnvelopeMessages] -type queueNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type QueueNewResponseEnvelopeSuccess bool @@ -396,8 +320,8 @@ func (r queueNewResponseEnvelopeResultInfoJSON) RawJSON() string { type QueueUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r QueueUpdateParams) MarshalJSON() (data []byte, err error) { @@ -405,9 +329,13 @@ func (r QueueUpdateParams) MarshalJSON() (data []byte, err error) { } type QueueUpdateResponseEnvelope struct { - Errors []QueueUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []QueueUpdateResponseEnvelopeMessages `json:"messages,required"` - Result QueueUpdateResponse `json:"result,required,nullable"` + CreatedOn interface{} `json:"created_on,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + ModifiedOn interface{} `json:"modified_on,required"` + QueueID interface{} `json:"queue_id,required"` + QueueName interface{} `json:"queue_name,required"` + Result QueueUpdated `json:"result,required,nullable"` // Whether the API call was successful Success QueueUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -417,8 +345,12 @@ type QueueUpdateResponseEnvelope struct { // queueUpdateResponseEnvelopeJSON contains the JSON metadata for the struct // [QueueUpdateResponseEnvelope] type queueUpdateResponseEnvelopeJSON struct { + CreatedOn apijson.Field Errors apijson.Field Messages apijson.Field + ModifiedOn apijson.Field + QueueID apijson.Field + QueueName apijson.Field Result apijson.Field Success apijson.Field ResultInfo apijson.Field @@ -434,52 +366,6 @@ func (r queueUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type QueueUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// queueUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [QueueUpdateResponseEnvelopeErrors] -type queueUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type QueueUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// queueUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [QueueUpdateResponseEnvelopeMessages] -type queueUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type QueueUpdateResponseEnvelopeSuccess bool @@ -534,12 +420,17 @@ type QueueListParams struct { type QueueDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r QueueDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type QueueDeleteResponseEnvelope struct { - Errors []QueueDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []QueueDeleteResponseEnvelopeMessages `json:"messages,required"` - Result QueueDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result QueueDeleteResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success QueueDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -566,52 +457,6 @@ func (r queueDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type QueueDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// queueDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [QueueDeleteResponseEnvelopeErrors] -type queueDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type QueueDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// queueDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [QueueDeleteResponseEnvelopeMessages] -type queueDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type QueueDeleteResponseEnvelopeSuccess bool @@ -664,9 +509,13 @@ type QueueGetParams struct { } type QueueGetResponseEnvelope struct { - Errors []QueueGetResponseEnvelopeErrors `json:"errors,required"` - Messages []QueueGetResponseEnvelopeMessages `json:"messages,required"` - Result QueueGetResponse `json:"result,required,nullable"` + CreatedOn interface{} `json:"created_on,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + ModifiedOn interface{} `json:"modified_on,required"` + QueueID interface{} `json:"queue_id,required"` + QueueName interface{} `json:"queue_name,required"` + Result Queue `json:"result,required,nullable"` // Whether the API call was successful Success QueueGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueGetResponseEnvelopeResultInfo `json:"result_info"` @@ -676,8 +525,12 @@ type QueueGetResponseEnvelope struct { // queueGetResponseEnvelopeJSON contains the JSON metadata for the struct // [QueueGetResponseEnvelope] type queueGetResponseEnvelopeJSON struct { + CreatedOn apijson.Field Errors apijson.Field Messages apijson.Field + ModifiedOn apijson.Field + QueueID apijson.Field + QueueName apijson.Field Result apijson.Field Success apijson.Field ResultInfo apijson.Field @@ -693,52 +546,6 @@ func (r queueGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type QueueGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// queueGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [QueueGetResponseEnvelopeErrors] -type queueGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type QueueGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// queueGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [QueueGetResponseEnvelopeMessages] -type queueGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type QueueGetResponseEnvelopeSuccess bool diff --git a/queues/queue_test.go b/queues/queue_test.go index 17a96e5f260..3cf77ee8818 100644 --- a/queues/queue_test.go +++ b/queues/queue_test.go @@ -30,9 +30,9 @@ func TestQueueNew(t *testing.T) { ) _, err := client.Queues.New(context.TODO(), queues.QueueNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ + Body: map[string]interface{}{ "queue_name": "example-queue", - }), + }, }) if err != nil { var apierr *cloudflare.Error @@ -62,9 +62,9 @@ func TestQueueUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", queues.QueueUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ + Body: map[string]interface{}{ "queue_name": "renamed-example-queue", - }), + }, }, ) if err != nil { @@ -121,6 +121,7 @@ func TestQueueDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", queues.QueueDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/r2/aliases.go b/r2/aliases.go index e1480d6b12a..b43b2ac0731 100644 --- a/r2/aliases.go +++ b/r2/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/r2/bucket.go b/r2/bucket.go index 6be304a840f..de053114c55 100644 --- a/r2/bucket.go +++ b/r2/bucket.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -34,7 +35,7 @@ func NewBucketService(opts ...option.RequestOption) (r *BucketService) { } // Creates a new R2 bucket. -func (r *BucketService) New(ctx context.Context, params BucketNewParams, opts ...option.RequestOption) (res *R2Bucket, err error) { +func (r *BucketService) New(ctx context.Context, params BucketNewParams, opts ...option.RequestOption) (res *Bucket, err error) { opts = append(r.Options[:], opts...) var env BucketNewResponseEnvelope path := fmt.Sprintf("accounts/%s/r2/buckets", params.AccountID) @@ -47,7 +48,7 @@ func (r *BucketService) New(ctx context.Context, params BucketNewParams, opts .. } // Lists all R2 buckets on your account -func (r *BucketService) List(ctx context.Context, params BucketListParams, opts ...option.RequestOption) (res *pagination.CursorPagination[R2Bucket], err error) { +func (r *BucketService) List(ctx context.Context, params BucketListParams, opts ...option.RequestOption) (res *pagination.CursorPagination[Bucket], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -65,7 +66,7 @@ func (r *BucketService) List(ctx context.Context, params BucketListParams, opts } // Lists all R2 buckets on your account -func (r *BucketService) ListAutoPaging(ctx context.Context, params BucketListParams, opts ...option.RequestOption) *pagination.CursorPaginationAutoPager[R2Bucket] { +func (r *BucketService) ListAutoPaging(ctx context.Context, params BucketListParams, opts ...option.RequestOption) *pagination.CursorPaginationAutoPager[Bucket] { return pagination.NewCursorPaginationAutoPager(r.List(ctx, params, opts...)) } @@ -83,7 +84,7 @@ func (r *BucketService) Delete(ctx context.Context, bucketName string, body Buck } // Gets metadata for an existing R2 bucket. -func (r *BucketService) Get(ctx context.Context, bucketName string, query BucketGetParams, opts ...option.RequestOption) (res *R2Bucket, err error) { +func (r *BucketService) Get(ctx context.Context, bucketName string, query BucketGetParams, opts ...option.RequestOption) (res *Bucket, err error) { opts = append(r.Options[:], opts...) var env BucketGetResponseEnvelope path := fmt.Sprintf("accounts/%s/r2/buckets/%s", query.AccountID, bucketName) @@ -96,18 +97,18 @@ func (r *BucketService) Get(ctx context.Context, bucketName string, query Bucket } // A single R2 bucket -type R2Bucket struct { +type Bucket struct { // Creation timestamp CreationDate string `json:"creation_date"` // Location of the bucket - Location R2BucketLocation `json:"location"` + Location BucketLocation `json:"location"` // Name of the bucket - Name string `json:"name"` - JSON r2BucketJSON `json:"-"` + Name string `json:"name"` + JSON bucketJSON `json:"-"` } -// r2BucketJSON contains the JSON metadata for the struct [R2Bucket] -type r2BucketJSON struct { +// bucketJSON contains the JSON metadata for the struct [Bucket] +type bucketJSON struct { CreationDate apijson.Field Location apijson.Field Name apijson.Field @@ -115,28 +116,28 @@ type r2BucketJSON struct { ExtraFields map[string]apijson.Field } -func (r *R2Bucket) UnmarshalJSON(data []byte) (err error) { +func (r *Bucket) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r r2BucketJSON) RawJSON() string { +func (r bucketJSON) RawJSON() string { return r.raw } // Location of the bucket -type R2BucketLocation string +type BucketLocation string const ( - R2BucketLocationApac R2BucketLocation = "apac" - R2BucketLocationEeur R2BucketLocation = "eeur" - R2BucketLocationEnam R2BucketLocation = "enam" - R2BucketLocationWeur R2BucketLocation = "weur" - R2BucketLocationWnam R2BucketLocation = "wnam" + BucketLocationApac BucketLocation = "apac" + BucketLocationEeur BucketLocation = "eeur" + BucketLocationEnam BucketLocation = "enam" + BucketLocationWeur BucketLocation = "weur" + BucketLocationWnam BucketLocation = "wnam" ) -func (r R2BucketLocation) IsKnown() bool { +func (r BucketLocation) IsKnown() bool { switch r { - case R2BucketLocationApac, R2BucketLocationEeur, R2BucketLocationEnam, R2BucketLocationWeur, R2BucketLocationWnam: + case BucketLocationApac, BucketLocationEeur, BucketLocationEnam, BucketLocationWeur, BucketLocationWnam: return true } return false @@ -177,10 +178,10 @@ func (r BucketNewParamsLocationHint) IsKnown() bool { } type BucketNewResponseEnvelope struct { - Errors []BucketNewResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []string `json:"messages,required"` // A single R2 bucket - Result R2Bucket `json:"result,required"` + Result Bucket `json:"result,required"` // Whether the API call was successful Success BucketNewResponseEnvelopeSuccess `json:"success,required"` JSON bucketNewResponseEnvelopeJSON `json:"-"` @@ -205,29 +206,6 @@ func (r bucketNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BucketNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON bucketNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// bucketNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [BucketNewResponseEnvelopeErrors] -type bucketNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BucketNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bucketNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BucketNewResponseEnvelopeSuccess bool @@ -265,7 +243,7 @@ type BucketListParams struct { // URLQuery serializes [BucketListParams]'s query parameters as `url.Values`. func (r BucketListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -307,9 +285,9 @@ type BucketDeleteParams struct { } type BucketDeleteResponseEnvelope struct { - Errors []BucketDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result BucketDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []string `json:"messages,required"` + Result BucketDeleteResponse `json:"result,required"` // Whether the API call was successful Success BucketDeleteResponseEnvelopeSuccess `json:"success,required"` JSON bucketDeleteResponseEnvelopeJSON `json:"-"` @@ -334,29 +312,6 @@ func (r bucketDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BucketDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON bucketDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// bucketDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [BucketDeleteResponseEnvelopeErrors] -type bucketDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BucketDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bucketDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BucketDeleteResponseEnvelopeSuccess bool @@ -378,10 +333,10 @@ type BucketGetParams struct { } type BucketGetResponseEnvelope struct { - Errors []BucketGetResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []string `json:"messages,required"` // A single R2 bucket - Result R2Bucket `json:"result,required"` + Result Bucket `json:"result,required"` // Whether the API call was successful Success BucketGetResponseEnvelopeSuccess `json:"success,required"` JSON bucketGetResponseEnvelopeJSON `json:"-"` @@ -406,29 +361,6 @@ func (r bucketGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BucketGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON bucketGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// bucketGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [BucketGetResponseEnvelopeErrors] -type bucketGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BucketGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bucketGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BucketGetResponseEnvelopeSuccess bool diff --git a/r2/sippy.go b/r2/sippy.go index 66c085f849a..747a71e64ce 100644 --- a/r2/sippy.go +++ b/r2/sippy.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,10 +32,10 @@ func NewSippyService(opts ...option.RequestOption) (r *SippyService) { } // Sets configuration for Sippy for an existing R2 bucket. -func (r *SippyService) Update(ctx context.Context, bucketName string, params SippyUpdateParams, opts ...option.RequestOption) (res *R2Sippy, err error) { +func (r *SippyService) Update(ctx context.Context, bucketName string, params SippyUpdateParams, opts ...option.RequestOption) (res *Sippy, err error) { opts = append(r.Options[:], opts...) var env SippyUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", params.getAccountID(), bucketName) + path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", params.AccountID, bucketName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return @@ -57,7 +58,7 @@ func (r *SippyService) Delete(ctx context.Context, bucketName string, body Sippy } // Gets configuration for Sippy for an existing R2 bucket. -func (r *SippyService) Get(ctx context.Context, bucketName string, query SippyGetParams, opts ...option.RequestOption) (res *R2Sippy, err error) { +func (r *SippyService) Get(ctx context.Context, bucketName string, query SippyGetParams, opts ...option.RequestOption) (res *Sippy, err error) { opts = append(r.Options[:], opts...) var env SippyGetResponseEnvelope path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", query.AccountID, bucketName) @@ -69,18 +70,32 @@ func (r *SippyService) Get(ctx context.Context, bucketName string, query SippyGe return } -type R2Sippy struct { +type Provider string + +const ( + ProviderR2 Provider = "r2" +) + +func (r Provider) IsKnown() bool { + switch r { + case ProviderR2: + return true + } + return false +} + +type Sippy struct { // Details about the configured destination bucket - Destination R2SippyDestination `json:"destination"` + Destination SippyDestination `json:"destination"` // State of Sippy for this bucket Enabled bool `json:"enabled"` // Details about the configured source bucket - Source R2SippySource `json:"source"` - JSON r2SippyJSON `json:"-"` + Source SippySource `json:"source"` + JSON sippyJSON `json:"-"` } -// r2SippyJSON contains the JSON metadata for the struct [R2Sippy] -type r2SippyJSON struct { +// sippyJSON contains the JSON metadata for the struct [Sippy] +type sippyJSON struct { Destination apijson.Field Enabled apijson.Field Source apijson.Field @@ -88,28 +103,28 @@ type r2SippyJSON struct { ExtraFields map[string]apijson.Field } -func (r *R2Sippy) UnmarshalJSON(data []byte) (err error) { +func (r *Sippy) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r r2SippyJSON) RawJSON() string { +func (r sippyJSON) RawJSON() string { return r.raw } // Details about the configured destination bucket -type R2SippyDestination struct { +type SippyDestination struct { // ID of the Cloudflare API token used when writing objects to this bucket AccessKeyID string `json:"accessKeyId"` Account string `json:"account"` // Name of the bucket on the provider - Bucket string `json:"bucket"` - Provider R2SippyDestinationProvider `json:"provider"` - JSON r2SippyDestinationJSON `json:"-"` + Bucket string `json:"bucket"` + Provider Provider `json:"provider"` + JSON sippyDestinationJSON `json:"-"` } -// r2SippyDestinationJSON contains the JSON metadata for the struct -// [R2SippyDestination] -type r2SippyDestinationJSON struct { +// sippyDestinationJSON contains the JSON metadata for the struct +// [SippyDestination] +type sippyDestinationJSON struct { AccessKeyID apijson.Field Account apijson.Field Bucket apijson.Field @@ -118,40 +133,26 @@ type r2SippyDestinationJSON struct { ExtraFields map[string]apijson.Field } -func (r *R2SippyDestination) UnmarshalJSON(data []byte) (err error) { +func (r *SippyDestination) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r r2SippyDestinationJSON) RawJSON() string { +func (r sippyDestinationJSON) RawJSON() string { return r.raw } -type R2SippyDestinationProvider string - -const ( - R2SippyDestinationProviderR2 R2SippyDestinationProvider = "r2" -) - -func (r R2SippyDestinationProvider) IsKnown() bool { - switch r { - case R2SippyDestinationProviderR2: - return true - } - return false -} - // Details about the configured source bucket -type R2SippySource struct { +type SippySource struct { // Name of the bucket on the provider - Bucket string `json:"bucket"` - Provider R2SippySourceProvider `json:"provider"` + Bucket string `json:"bucket"` + Provider SippySourceProvider `json:"provider"` // Region where the bucket resides (AWS only) - Region string `json:"region,nullable"` - JSON r2SippySourceJSON `json:"-"` + Region string `json:"region,nullable"` + JSON sippySourceJSON `json:"-"` } -// r2SippySourceJSON contains the JSON metadata for the struct [R2SippySource] -type r2SippySourceJSON struct { +// sippySourceJSON contains the JSON metadata for the struct [SippySource] +type sippySourceJSON struct { Bucket apijson.Field Provider apijson.Field Region apijson.Field @@ -159,24 +160,24 @@ type r2SippySourceJSON struct { ExtraFields map[string]apijson.Field } -func (r *R2SippySource) UnmarshalJSON(data []byte) (err error) { +func (r *SippySource) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r r2SippySourceJSON) RawJSON() string { +func (r sippySourceJSON) RawJSON() string { return r.raw } -type R2SippySourceProvider string +type SippySourceProvider string const ( - R2SippySourceProviderAws R2SippySourceProvider = "aws" - R2SippySourceProviderGcs R2SippySourceProvider = "gcs" + SippySourceProviderAws SippySourceProvider = "aws" + SippySourceProviderGcs SippySourceProvider = "gcs" ) -func (r R2SippySourceProvider) IsKnown() bool { +func (r SippySourceProvider) IsKnown() bool { switch r { - case R2SippySourceProviderAws, R2SippySourceProviderGcs: + case SippySourceProviderAws, SippySourceProviderGcs: return true } return false @@ -217,45 +218,56 @@ func (r SippyDeleteResponseEnabled) IsKnown() bool { return false } -// This interface is a union satisfied by one of the following: -// [SippyUpdateParamsR2EnableSippyAws], [SippyUpdateParamsR2EnableSippyGcs]. -type SippyUpdateParams interface { - ImplementsSippyUpdateParams() +type SippyUpdateParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` + Body SippyUpdateParamsBodyUnion `json:"body,required"` +} - getAccountID() param.Field[string] +func (r SippyUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -type SippyUpdateParamsR2EnableSippyAws struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` - // R2 bucket to copy objects to - Destination param.Field[SippyUpdateParamsR2EnableSippyAwsDestination] `json:"destination"` - // AWS S3 bucket to copy objects from - Source param.Field[SippyUpdateParamsR2EnableSippyAwsSource] `json:"source"` +type SippyUpdateParamsBody struct { + Destination param.Field[interface{}] `json:"destination,required"` + Source param.Field[interface{}] `json:"source,required"` } -func (r SippyUpdateParamsR2EnableSippyAws) MarshalJSON() (data []byte, err error) { +func (r SippyUpdateParamsBody) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r SippyUpdateParamsR2EnableSippyAws) getAccountID() param.Field[string] { - return r.AccountID +func (r SippyUpdateParamsBody) implementsR2SippyUpdateParamsBodyUnion() {} + +// Satisfied by [r2.SippyUpdateParamsBodyR2EnableSippyAws], +// [r2.SippyUpdateParamsBodyR2EnableSippyGcs], [SippyUpdateParamsBody]. +type SippyUpdateParamsBodyUnion interface { + implementsR2SippyUpdateParamsBodyUnion() } -func (SippyUpdateParamsR2EnableSippyAws) ImplementsSippyUpdateParams() { +type SippyUpdateParamsBodyR2EnableSippyAws struct { + // R2 bucket to copy objects to + Destination param.Field[SippyUpdateParamsBodyR2EnableSippyAwsDestination] `json:"destination"` + // AWS S3 bucket to copy objects from + Source param.Field[SippyUpdateParamsBodyR2EnableSippyAwsSource] `json:"source"` +} +func (r SippyUpdateParamsBodyR2EnableSippyAws) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } +func (r SippyUpdateParamsBodyR2EnableSippyAws) implementsR2SippyUpdateParamsBodyUnion() {} + // R2 bucket to copy objects to -type SippyUpdateParamsR2EnableSippyAwsDestination struct { +type SippyUpdateParamsBodyR2EnableSippyAwsDestination struct { // ID of a Cloudflare API token. This is the value labelled "Access Key ID" when // creating an API token from the // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). // // Sippy will use this token when writing objects to R2, so it is best to scope // this token to the bucket you're enabling Sippy for. - AccessKeyID param.Field[string] `json:"accessKeyId"` - Provider param.Field[SippyUpdateParamsR2EnableSippyAwsDestinationProvider] `json:"provider"` + AccessKeyID param.Field[string] `json:"accessKeyId"` + Provider param.Field[Provider] `json:"provider"` // Value of a Cloudflare API token. This is the value labelled "Secret Access Key" // when creating an API token from the // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). @@ -265,86 +277,64 @@ type SippyUpdateParamsR2EnableSippyAwsDestination struct { SecretAccessKey param.Field[string] `json:"secretAccessKey"` } -func (r SippyUpdateParamsR2EnableSippyAwsDestination) MarshalJSON() (data []byte, err error) { +func (r SippyUpdateParamsBodyR2EnableSippyAwsDestination) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SippyUpdateParamsR2EnableSippyAwsDestinationProvider string - -const ( - SippyUpdateParamsR2EnableSippyAwsDestinationProviderR2 SippyUpdateParamsR2EnableSippyAwsDestinationProvider = "r2" -) - -func (r SippyUpdateParamsR2EnableSippyAwsDestinationProvider) IsKnown() bool { - switch r { - case SippyUpdateParamsR2EnableSippyAwsDestinationProviderR2: - return true - } - return false -} - // AWS S3 bucket to copy objects from -type SippyUpdateParamsR2EnableSippyAwsSource struct { +type SippyUpdateParamsBodyR2EnableSippyAwsSource struct { // Access Key ID of an IAM credential (ideally scoped to a single S3 bucket) AccessKeyID param.Field[string] `json:"accessKeyId"` // Name of the AWS S3 bucket - Bucket param.Field[string] `json:"bucket"` - Provider param.Field[SippyUpdateParamsR2EnableSippyAwsSourceProvider] `json:"provider"` + Bucket param.Field[string] `json:"bucket"` + Provider param.Field[SippyUpdateParamsBodyR2EnableSippyAwsSourceProvider] `json:"provider"` // Name of the AWS availability zone Region param.Field[string] `json:"region"` // Secret Access Key of an IAM credential (ideally scoped to a single S3 bucket) SecretAccessKey param.Field[string] `json:"secretAccessKey"` } -func (r SippyUpdateParamsR2EnableSippyAwsSource) MarshalJSON() (data []byte, err error) { +func (r SippyUpdateParamsBodyR2EnableSippyAwsSource) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SippyUpdateParamsR2EnableSippyAwsSourceProvider string +type SippyUpdateParamsBodyR2EnableSippyAwsSourceProvider string const ( - SippyUpdateParamsR2EnableSippyAwsSourceProviderAws SippyUpdateParamsR2EnableSippyAwsSourceProvider = "aws" + SippyUpdateParamsBodyR2EnableSippyAwsSourceProviderAws SippyUpdateParamsBodyR2EnableSippyAwsSourceProvider = "aws" ) -func (r SippyUpdateParamsR2EnableSippyAwsSourceProvider) IsKnown() bool { +func (r SippyUpdateParamsBodyR2EnableSippyAwsSourceProvider) IsKnown() bool { switch r { - case SippyUpdateParamsR2EnableSippyAwsSourceProviderAws: + case SippyUpdateParamsBodyR2EnableSippyAwsSourceProviderAws: return true } return false } -type SippyUpdateParamsR2EnableSippyGcs struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` +type SippyUpdateParamsBodyR2EnableSippyGcs struct { // R2 bucket to copy objects to - Destination param.Field[SippyUpdateParamsR2EnableSippyGcsDestination] `json:"destination"` + Destination param.Field[SippyUpdateParamsBodyR2EnableSippyGcsDestination] `json:"destination"` // GCS bucket to copy objects from - Source param.Field[SippyUpdateParamsR2EnableSippyGcsSource] `json:"source"` + Source param.Field[SippyUpdateParamsBodyR2EnableSippyGcsSource] `json:"source"` } -func (r SippyUpdateParamsR2EnableSippyGcs) MarshalJSON() (data []byte, err error) { +func (r SippyUpdateParamsBodyR2EnableSippyGcs) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r SippyUpdateParamsR2EnableSippyGcs) getAccountID() param.Field[string] { - return r.AccountID -} - -func (SippyUpdateParamsR2EnableSippyGcs) ImplementsSippyUpdateParams() { - -} +func (r SippyUpdateParamsBodyR2EnableSippyGcs) implementsR2SippyUpdateParamsBodyUnion() {} // R2 bucket to copy objects to -type SippyUpdateParamsR2EnableSippyGcsDestination struct { +type SippyUpdateParamsBodyR2EnableSippyGcsDestination struct { // ID of a Cloudflare API token. This is the value labelled "Access Key ID" when // creating an API token from the // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). // // Sippy will use this token when writing objects to R2, so it is best to scope // this token to the bucket you're enabling Sippy for. - AccessKeyID param.Field[string] `json:"accessKeyId"` - Provider param.Field[SippyUpdateParamsR2EnableSippyGcsDestinationProvider] `json:"provider"` + AccessKeyID param.Field[string] `json:"accessKeyId"` + Provider param.Field[Provider] `json:"provider"` // Value of a Cloudflare API token. This is the value labelled "Secret Access Key" // when creating an API token from the // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). @@ -354,57 +344,43 @@ type SippyUpdateParamsR2EnableSippyGcsDestination struct { SecretAccessKey param.Field[string] `json:"secretAccessKey"` } -func (r SippyUpdateParamsR2EnableSippyGcsDestination) MarshalJSON() (data []byte, err error) { +func (r SippyUpdateParamsBodyR2EnableSippyGcsDestination) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SippyUpdateParamsR2EnableSippyGcsDestinationProvider string - -const ( - SippyUpdateParamsR2EnableSippyGcsDestinationProviderR2 SippyUpdateParamsR2EnableSippyGcsDestinationProvider = "r2" -) - -func (r SippyUpdateParamsR2EnableSippyGcsDestinationProvider) IsKnown() bool { - switch r { - case SippyUpdateParamsR2EnableSippyGcsDestinationProviderR2: - return true - } - return false -} - // GCS bucket to copy objects from -type SippyUpdateParamsR2EnableSippyGcsSource struct { +type SippyUpdateParamsBodyR2EnableSippyGcsSource struct { // Name of the GCS bucket Bucket param.Field[string] `json:"bucket"` // Client email of an IAM credential (ideally scoped to a single GCS bucket) ClientEmail param.Field[string] `json:"clientEmail"` // Private Key of an IAM credential (ideally scoped to a single GCS bucket) - PrivateKey param.Field[string] `json:"privateKey"` - Provider param.Field[SippyUpdateParamsR2EnableSippyGcsSourceProvider] `json:"provider"` + PrivateKey param.Field[string] `json:"privateKey"` + Provider param.Field[SippyUpdateParamsBodyR2EnableSippyGcsSourceProvider] `json:"provider"` } -func (r SippyUpdateParamsR2EnableSippyGcsSource) MarshalJSON() (data []byte, err error) { +func (r SippyUpdateParamsBodyR2EnableSippyGcsSource) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SippyUpdateParamsR2EnableSippyGcsSourceProvider string +type SippyUpdateParamsBodyR2EnableSippyGcsSourceProvider string const ( - SippyUpdateParamsR2EnableSippyGcsSourceProviderGcs SippyUpdateParamsR2EnableSippyGcsSourceProvider = "gcs" + SippyUpdateParamsBodyR2EnableSippyGcsSourceProviderGcs SippyUpdateParamsBodyR2EnableSippyGcsSourceProvider = "gcs" ) -func (r SippyUpdateParamsR2EnableSippyGcsSourceProvider) IsKnown() bool { +func (r SippyUpdateParamsBodyR2EnableSippyGcsSourceProvider) IsKnown() bool { switch r { - case SippyUpdateParamsR2EnableSippyGcsSourceProviderGcs: + case SippyUpdateParamsBodyR2EnableSippyGcsSourceProviderGcs: return true } return false } type SippyUpdateResponseEnvelope struct { - Errors []SippyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result R2Sippy `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []string `json:"messages,required"` + Result Sippy `json:"result,required"` // Whether the API call was successful Success SippyUpdateResponseEnvelopeSuccess `json:"success,required"` JSON sippyUpdateResponseEnvelopeJSON `json:"-"` @@ -429,29 +405,6 @@ func (r sippyUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SippyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sippyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// sippyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SippyUpdateResponseEnvelopeErrors] -type sippyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SippyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sippyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SippyUpdateResponseEnvelopeSuccess bool @@ -473,9 +426,9 @@ type SippyDeleteParams struct { } type SippyDeleteResponseEnvelope struct { - Errors []SippyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result SippyDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []string `json:"messages,required"` + Result SippyDeleteResponse `json:"result,required"` // Whether the API call was successful Success SippyDeleteResponseEnvelopeSuccess `json:"success,required"` JSON sippyDeleteResponseEnvelopeJSON `json:"-"` @@ -500,29 +453,6 @@ func (r sippyDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SippyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sippyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// sippyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SippyDeleteResponseEnvelopeErrors] -type sippyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SippyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sippyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SippyDeleteResponseEnvelopeSuccess bool @@ -544,9 +474,9 @@ type SippyGetParams struct { } type SippyGetResponseEnvelope struct { - Errors []SippyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result R2Sippy `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []string `json:"messages,required"` + Result Sippy `json:"result,required"` // Whether the API call was successful Success SippyGetResponseEnvelopeSuccess `json:"success,required"` JSON sippyGetResponseEnvelopeJSON `json:"-"` @@ -571,29 +501,6 @@ func (r sippyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SippyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sippyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// sippyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SippyGetResponseEnvelopeErrors] -type sippyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SippyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sippyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SippyGetResponseEnvelopeSuccess bool diff --git a/r2/sippy_test.go b/r2/sippy_test.go index 58ecde3eeb4..b6b699e22e9 100644 --- a/r2/sippy_test.go +++ b/r2/sippy_test.go @@ -31,20 +31,22 @@ func TestSippyUpdateWithOptionalParams(t *testing.T) { _, err := client.R2.Sippy.Update( context.TODO(), "example-bucket", - r2.SippyUpdateParamsR2EnableSippyAws{ + r2.SippyUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Destination: cloudflare.F(r2.SippyUpdateParamsR2EnableSippyAwsDestination{ - AccessKeyID: cloudflare.F("string"), - Provider: cloudflare.F(r2.SippyUpdateParamsR2EnableSippyAwsDestinationProviderR2), - SecretAccessKey: cloudflare.F("string"), - }), - Source: cloudflare.F(r2.SippyUpdateParamsR2EnableSippyAwsSource{ - AccessKeyID: cloudflare.F("string"), - Bucket: cloudflare.F("string"), - Provider: cloudflare.F(r2.SippyUpdateParamsR2EnableSippyAwsSourceProviderAws), - Region: cloudflare.F("string"), - SecretAccessKey: cloudflare.F("string"), - }), + Body: r2.SippyUpdateParamsBodyR2EnableSippyAws{ + Destination: cloudflare.F(r2.SippyUpdateParamsBodyR2EnableSippyAwsDestination{ + AccessKeyID: cloudflare.F("string"), + Provider: cloudflare.F(r2.ProviderR2), + SecretAccessKey: cloudflare.F("string"), + }), + Source: cloudflare.F(r2.SippyUpdateParamsBodyR2EnableSippyAwsSource{ + AccessKeyID: cloudflare.F("string"), + Bucket: cloudflare.F("string"), + Provider: cloudflare.F(r2.SippyUpdateParamsBodyR2EnableSippyAwsSourceProviderAws), + Region: cloudflare.F("string"), + SecretAccessKey: cloudflare.F("string"), + }), + }, }, ) if err != nil { diff --git a/radar/aliases.go b/radar/aliases.go index d3cd15c5b91..2abb0c5f08f 100644 --- a/radar/aliases.go +++ b/radar/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/radar/annotationoutage.go b/radar/annotationoutage.go index fb1cc75faa0..ba3da6c579a 100644 --- a/radar/annotationoutage.go +++ b/radar/annotationoutage.go @@ -290,7 +290,7 @@ type AnnotationOutageGetParams struct { // `url.Values`. func (r AnnotationOutageGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -382,7 +382,7 @@ type AnnotationOutageLocationsParams struct { // `url.Values`. func (r AnnotationOutageLocationsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/as112.go b/radar/as112.go index 2a9ce6dbcd7..0ebeb59be5e 100644 --- a/radar/as112.go +++ b/radar/as112.go @@ -239,7 +239,7 @@ type AS112TimeseriesParams struct { // URLQuery serializes [AS112TimeseriesParams]'s query parameters as `url.Values`. func (r AS112TimeseriesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/as112summary.go b/radar/as112summary.go index 02983c48938..aeb9d7eaabc 100644 --- a/radar/as112summary.go +++ b/radar/as112summary.go @@ -707,7 +707,7 @@ func (r as112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON) RawJSON() } type AS112SummaryProtocolResponseSummary0 struct { - Tcp string `json:"tcp,required"` + TCP string `json:"tcp,required"` Udp string `json:"udp,required"` JSON as112SummaryProtocolResponseSummary0JSON `json:"-"` } @@ -715,7 +715,7 @@ type AS112SummaryProtocolResponseSummary0 struct { // as112SummaryProtocolResponseSummary0JSON contains the JSON metadata for the // struct [AS112SummaryProtocolResponseSummary0] type as112SummaryProtocolResponseSummary0JSON struct { - Tcp apijson.Field + TCP apijson.Field Udp apijson.Field raw string ExtraFields map[string]apijson.Field @@ -1076,7 +1076,7 @@ type AS112SummaryDNSSECParams struct { // `url.Values`. func (r AS112SummaryDNSSECParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1178,7 +1178,7 @@ type AS112SummaryEdnsParams struct { // URLQuery serializes [AS112SummaryEdnsParams]'s query parameters as `url.Values`. func (r AS112SummaryEdnsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1281,7 +1281,7 @@ type AS112SummaryIPVersionParams struct { // `url.Values`. func (r AS112SummaryIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1384,7 +1384,7 @@ type AS112SummaryProtocolParams struct { // `url.Values`. func (r AS112SummaryProtocolParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1487,7 +1487,7 @@ type AS112SummaryQueryTypeParams struct { // `url.Values`. func (r AS112SummaryQueryTypeParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1590,7 +1590,7 @@ type AS112SummaryResponseCodesParams struct { // `url.Values`. func (r AS112SummaryResponseCodesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/as112timeseriesgroup.go b/radar/as112timeseriesgroup.go index ad352347fee..46bee5a8392 100644 --- a/radar/as112timeseriesgroup.go +++ b/radar/as112timeseriesgroup.go @@ -274,7 +274,7 @@ func (r as112TimeseriesGroupProtocolResponseJSON) RawJSON() string { } type AS112TimeseriesGroupProtocolResponseSerie0 struct { - Tcp []string `json:"tcp,required"` + TCP []string `json:"tcp,required"` Udp []string `json:"udp,required"` JSON as112TimeseriesGroupProtocolResponseSerie0JSON `json:"-"` } @@ -282,7 +282,7 @@ type AS112TimeseriesGroupProtocolResponseSerie0 struct { // as112TimeseriesGroupProtocolResponseSerie0JSON contains the JSON metadata for // the struct [AS112TimeseriesGroupProtocolResponseSerie0] type as112TimeseriesGroupProtocolResponseSerie0JSON struct { - Tcp apijson.Field + TCP apijson.Field Udp apijson.Field raw string ExtraFields map[string]apijson.Field @@ -429,7 +429,7 @@ type AS112TimeseriesGroupDNSSECParams struct { // `url.Values`. func (r AS112TimeseriesGroupDNSSECParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -556,7 +556,7 @@ type AS112TimeseriesGroupEdnsParams struct { // `url.Values`. func (r AS112TimeseriesGroupEdnsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -683,7 +683,7 @@ type AS112TimeseriesGroupIPVersionParams struct { // `url.Values`. func (r AS112TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -810,7 +810,7 @@ type AS112TimeseriesGroupProtocolParams struct { // `url.Values`. func (r AS112TimeseriesGroupProtocolParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -937,7 +937,7 @@ type AS112TimeseriesGroupQueryTypeParams struct { // `url.Values`. func (r AS112TimeseriesGroupQueryTypeParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1064,7 +1064,7 @@ type AS112TimeseriesGroupResponseCodesParams struct { // as `url.Values`. func (r AS112TimeseriesGroupResponseCodesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/as112top.go b/radar/as112top.go index d8801ab2e7a..482721e0ae0 100644 --- a/radar/as112top.go +++ b/radar/as112top.go @@ -734,7 +734,7 @@ type AS112TopDNSSECParams struct { // URLQuery serializes [AS112TopDNSSECParams]'s query parameters as `url.Values`. func (r AS112TopDNSSECParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -854,7 +854,7 @@ type AS112TopEdnsParams struct { // URLQuery serializes [AS112TopEdnsParams]'s query parameters as `url.Values`. func (r AS112TopEdnsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -975,7 +975,7 @@ type AS112TopIPVersionParams struct { // `url.Values`. func (r AS112TopIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1096,7 +1096,7 @@ type AS112TopLocationsParams struct { // `url.Values`. func (r AS112TopLocationsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/attacklayer3.go b/radar/attacklayer3.go index e5c43f4966f..072567a43bc 100644 --- a/radar/attacklayer3.go +++ b/radar/attacklayer3.go @@ -76,7 +76,7 @@ func (r attackLayer3TimeseriesResponseJSON) RawJSON() string { } type AttackLayer3TimeseriesResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` Values []string `json:"values,required"` JSON attackLayer3TimeseriesResponseSerie0JSON `json:"-"` } @@ -145,7 +145,7 @@ type AttackLayer3TimeseriesParams struct { // `url.Values`. func (r AttackLayer3TimeseriesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -283,14 +283,14 @@ type AttackLayer3TimeseriesParamsProtocol string const ( AttackLayer3TimeseriesParamsProtocolUdp AttackLayer3TimeseriesParamsProtocol = "UDP" - AttackLayer3TimeseriesParamsProtocolTcp AttackLayer3TimeseriesParamsProtocol = "TCP" + AttackLayer3TimeseriesParamsProtocolTCP AttackLayer3TimeseriesParamsProtocol = "TCP" AttackLayer3TimeseriesParamsProtocolIcmp AttackLayer3TimeseriesParamsProtocol = "ICMP" AttackLayer3TimeseriesParamsProtocolGRE AttackLayer3TimeseriesParamsProtocol = "GRE" ) func (r AttackLayer3TimeseriesParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TimeseriesParamsProtocolUdp, AttackLayer3TimeseriesParamsProtocolTcp, AttackLayer3TimeseriesParamsProtocolIcmp, AttackLayer3TimeseriesParamsProtocolGRE: + case AttackLayer3TimeseriesParamsProtocolUdp, AttackLayer3TimeseriesParamsProtocolTCP, AttackLayer3TimeseriesParamsProtocolIcmp, AttackLayer3TimeseriesParamsProtocolGRE: return true } return false diff --git a/radar/attacklayer3_test.go b/radar/attacklayer3_test.go index 0ed8a256196..448a71e9a59 100644 --- a/radar/attacklayer3_test.go +++ b/radar/attacklayer3_test.go @@ -43,7 +43,7 @@ func TestAttackLayer3TimeseriesWithOptionalParams(t *testing.T) { Metric: cloudflare.F(radar.AttackLayer3TimeseriesParamsMetricBytes), Name: cloudflare.F([]string{"string", "string", "string"}), Normalization: cloudflare.F(radar.AttackLayer3TimeseriesParamsNormalizationMin0Max), - Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesParamsProtocol{radar.AttackLayer3TimeseriesParamsProtocolUdp, radar.AttackLayer3TimeseriesParamsProtocolTcp, radar.AttackLayer3TimeseriesParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesParamsProtocol{radar.AttackLayer3TimeseriesParamsProtocolUdp, radar.AttackLayer3TimeseriesParamsProtocolTCP, radar.AttackLayer3TimeseriesParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error diff --git a/radar/attacklayer3summary.go b/radar/attacklayer3summary.go index 8c1e2fde003..ec363713b2d 100644 --- a/radar/attacklayer3summary.go +++ b/radar/attacklayer3summary.go @@ -567,7 +567,7 @@ func (r attackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON( type AttackLayer3SummaryGetResponseSummary0 struct { GRE string `json:"gre,required"` Icmp string `json:"icmp,required"` - Tcp string `json:"tcp,required"` + TCP string `json:"tcp,required"` Udp string `json:"udp,required"` JSON attackLayer3SummaryGetResponseSummary0JSON `json:"-"` } @@ -577,7 +577,7 @@ type AttackLayer3SummaryGetResponseSummary0 struct { type attackLayer3SummaryGetResponseSummary0JSON struct { GRE apijson.Field Icmp apijson.Field - Tcp apijson.Field + TCP apijson.Field Udp apijson.Field raw string ExtraFields map[string]apijson.Field @@ -881,7 +881,7 @@ func (r attackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON) Raw type AttackLayer3SummaryProtocolResponseSummary0 struct { GRE string `json:"GRE,required"` Icmp string `json:"ICMP,required"` - Tcp string `json:"TCP,required"` + TCP string `json:"TCP,required"` Udp string `json:"UDP,required"` JSON attackLayer3SummaryProtocolResponseSummary0JSON `json:"-"` } @@ -891,7 +891,7 @@ type AttackLayer3SummaryProtocolResponseSummary0 struct { type attackLayer3SummaryProtocolResponseSummary0JSON struct { GRE apijson.Field Icmp apijson.Field - Tcp apijson.Field + TCP apijson.Field Udp apijson.Field raw string ExtraFields map[string]apijson.Field @@ -1071,7 +1071,7 @@ type AttackLayer3SummaryBitrateParams struct { // `url.Values`. func (r AttackLayer3SummaryBitrateParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1156,14 +1156,14 @@ type AttackLayer3SummaryBitrateParamsProtocol string const ( AttackLayer3SummaryBitrateParamsProtocolUdp AttackLayer3SummaryBitrateParamsProtocol = "UDP" - AttackLayer3SummaryBitrateParamsProtocolTcp AttackLayer3SummaryBitrateParamsProtocol = "TCP" + AttackLayer3SummaryBitrateParamsProtocolTCP AttackLayer3SummaryBitrateParamsProtocol = "TCP" AttackLayer3SummaryBitrateParamsProtocolIcmp AttackLayer3SummaryBitrateParamsProtocol = "ICMP" AttackLayer3SummaryBitrateParamsProtocolGRE AttackLayer3SummaryBitrateParamsProtocol = "GRE" ) func (r AttackLayer3SummaryBitrateParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3SummaryBitrateParamsProtocolUdp, AttackLayer3SummaryBitrateParamsProtocolTcp, AttackLayer3SummaryBitrateParamsProtocolIcmp, AttackLayer3SummaryBitrateParamsProtocolGRE: + case AttackLayer3SummaryBitrateParamsProtocolUdp, AttackLayer3SummaryBitrateParamsProtocolTCP, AttackLayer3SummaryBitrateParamsProtocolIcmp, AttackLayer3SummaryBitrateParamsProtocolGRE: return true } return false @@ -1226,7 +1226,7 @@ type AttackLayer3SummaryDurationParams struct { // `url.Values`. func (r AttackLayer3SummaryDurationParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1311,14 +1311,14 @@ type AttackLayer3SummaryDurationParamsProtocol string const ( AttackLayer3SummaryDurationParamsProtocolUdp AttackLayer3SummaryDurationParamsProtocol = "UDP" - AttackLayer3SummaryDurationParamsProtocolTcp AttackLayer3SummaryDurationParamsProtocol = "TCP" + AttackLayer3SummaryDurationParamsProtocolTCP AttackLayer3SummaryDurationParamsProtocol = "TCP" AttackLayer3SummaryDurationParamsProtocolIcmp AttackLayer3SummaryDurationParamsProtocol = "ICMP" AttackLayer3SummaryDurationParamsProtocolGRE AttackLayer3SummaryDurationParamsProtocol = "GRE" ) func (r AttackLayer3SummaryDurationParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3SummaryDurationParamsProtocolUdp, AttackLayer3SummaryDurationParamsProtocolTcp, AttackLayer3SummaryDurationParamsProtocolIcmp, AttackLayer3SummaryDurationParamsProtocolGRE: + case AttackLayer3SummaryDurationParamsProtocolUdp, AttackLayer3SummaryDurationParamsProtocolTCP, AttackLayer3SummaryDurationParamsProtocolIcmp, AttackLayer3SummaryDurationParamsProtocolGRE: return true } return false @@ -1378,7 +1378,7 @@ type AttackLayer3SummaryGetParams struct { // `url.Values`. func (r AttackLayer3SummaryGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1482,7 +1482,7 @@ type AttackLayer3SummaryIPVersionParams struct { // `url.Values`. func (r AttackLayer3SummaryIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1552,14 +1552,14 @@ type AttackLayer3SummaryIPVersionParamsProtocol string const ( AttackLayer3SummaryIPVersionParamsProtocolUdp AttackLayer3SummaryIPVersionParamsProtocol = "UDP" - AttackLayer3SummaryIPVersionParamsProtocolTcp AttackLayer3SummaryIPVersionParamsProtocol = "TCP" + AttackLayer3SummaryIPVersionParamsProtocolTCP AttackLayer3SummaryIPVersionParamsProtocol = "TCP" AttackLayer3SummaryIPVersionParamsProtocolIcmp AttackLayer3SummaryIPVersionParamsProtocol = "ICMP" AttackLayer3SummaryIPVersionParamsProtocolGRE AttackLayer3SummaryIPVersionParamsProtocol = "GRE" ) func (r AttackLayer3SummaryIPVersionParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3SummaryIPVersionParamsProtocolUdp, AttackLayer3SummaryIPVersionParamsProtocolTcp, AttackLayer3SummaryIPVersionParamsProtocolIcmp, AttackLayer3SummaryIPVersionParamsProtocolGRE: + case AttackLayer3SummaryIPVersionParamsProtocolUdp, AttackLayer3SummaryIPVersionParamsProtocolTCP, AttackLayer3SummaryIPVersionParamsProtocolIcmp, AttackLayer3SummaryIPVersionParamsProtocolGRE: return true } return false @@ -1620,7 +1620,7 @@ type AttackLayer3SummaryProtocolParams struct { // `url.Values`. func (r AttackLayer3SummaryProtocolParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1758,7 +1758,7 @@ type AttackLayer3SummaryVectorParams struct { // `url.Values`. func (r AttackLayer3SummaryVectorParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1843,14 +1843,14 @@ type AttackLayer3SummaryVectorParamsProtocol string const ( AttackLayer3SummaryVectorParamsProtocolUdp AttackLayer3SummaryVectorParamsProtocol = "UDP" - AttackLayer3SummaryVectorParamsProtocolTcp AttackLayer3SummaryVectorParamsProtocol = "TCP" + AttackLayer3SummaryVectorParamsProtocolTCP AttackLayer3SummaryVectorParamsProtocol = "TCP" AttackLayer3SummaryVectorParamsProtocolIcmp AttackLayer3SummaryVectorParamsProtocol = "ICMP" AttackLayer3SummaryVectorParamsProtocolGRE AttackLayer3SummaryVectorParamsProtocol = "GRE" ) func (r AttackLayer3SummaryVectorParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3SummaryVectorParamsProtocolUdp, AttackLayer3SummaryVectorParamsProtocolTcp, AttackLayer3SummaryVectorParamsProtocolIcmp, AttackLayer3SummaryVectorParamsProtocolGRE: + case AttackLayer3SummaryVectorParamsProtocolUdp, AttackLayer3SummaryVectorParamsProtocolTCP, AttackLayer3SummaryVectorParamsProtocolIcmp, AttackLayer3SummaryVectorParamsProtocolGRE: return true } return false diff --git a/radar/attacklayer3summary_test.go b/radar/attacklayer3summary_test.go index 15771809aac..409533aa769 100644 --- a/radar/attacklayer3summary_test.go +++ b/radar/attacklayer3summary_test.go @@ -39,7 +39,7 @@ func TestAttackLayer3SummaryBitrateWithOptionalParams(t *testing.T) { IPVersion: cloudflare.F([]radar.AttackLayer3SummaryBitrateParamsIPVersion{radar.AttackLayer3SummaryBitrateParamsIPVersionIPv4, radar.AttackLayer3SummaryBitrateParamsIPVersionIPv6}), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3SummaryBitrateParamsProtocol{radar.AttackLayer3SummaryBitrateParamsProtocolUdp, radar.AttackLayer3SummaryBitrateParamsProtocolTcp, radar.AttackLayer3SummaryBitrateParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryBitrateParamsProtocol{radar.AttackLayer3SummaryBitrateParamsProtocolUdp, radar.AttackLayer3SummaryBitrateParamsProtocolTCP, radar.AttackLayer3SummaryBitrateParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -74,7 +74,7 @@ func TestAttackLayer3SummaryDurationWithOptionalParams(t *testing.T) { IPVersion: cloudflare.F([]radar.AttackLayer3SummaryDurationParamsIPVersion{radar.AttackLayer3SummaryDurationParamsIPVersionIPv4, radar.AttackLayer3SummaryDurationParamsIPVersionIPv6}), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3SummaryDurationParamsProtocol{radar.AttackLayer3SummaryDurationParamsProtocolUdp, radar.AttackLayer3SummaryDurationParamsProtocolTcp, radar.AttackLayer3SummaryDurationParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryDurationParamsProtocol{radar.AttackLayer3SummaryDurationParamsProtocolUdp, radar.AttackLayer3SummaryDurationParamsProtocolTCP, radar.AttackLayer3SummaryDurationParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -141,7 +141,7 @@ func TestAttackLayer3SummaryIPVersionWithOptionalParams(t *testing.T) { Format: cloudflare.F(radar.AttackLayer3SummaryIPVersionParamsFormatJson), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3SummaryIPVersionParamsProtocol{radar.AttackLayer3SummaryIPVersionParamsProtocolUdp, radar.AttackLayer3SummaryIPVersionParamsProtocolTcp, radar.AttackLayer3SummaryIPVersionParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryIPVersionParamsProtocol{radar.AttackLayer3SummaryIPVersionParamsProtocolUdp, radar.AttackLayer3SummaryIPVersionParamsProtocolTCP, radar.AttackLayer3SummaryIPVersionParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -210,7 +210,7 @@ func TestAttackLayer3SummaryVectorWithOptionalParams(t *testing.T) { IPVersion: cloudflare.F([]radar.AttackLayer3SummaryVectorParamsIPVersion{radar.AttackLayer3SummaryVectorParamsIPVersionIPv4, radar.AttackLayer3SummaryVectorParamsIPVersionIPv6}), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3SummaryVectorParamsProtocol{radar.AttackLayer3SummaryVectorParamsProtocolUdp, radar.AttackLayer3SummaryVectorParamsProtocolTcp, radar.AttackLayer3SummaryVectorParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryVectorParamsProtocol{radar.AttackLayer3SummaryVectorParamsProtocolUdp, radar.AttackLayer3SummaryVectorParamsProtocolTCP, radar.AttackLayer3SummaryVectorParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error diff --git a/radar/attacklayer3timeseriesgroup.go b/radar/attacklayer3timeseriesgroup.go index adb2ef44f41..f9a17c00f0b 100644 --- a/radar/attacklayer3timeseriesgroup.go +++ b/radar/attacklayer3timeseriesgroup.go @@ -384,7 +384,7 @@ func (r attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON) type AttackLayer3TimeseriesGroupGetResponseSerie0 struct { GRE []string `json:"gre,required"` Icmp []string `json:"icmp,required"` - Tcp []string `json:"tcp,required"` + TCP []string `json:"tcp,required"` Timestamps []string `json:"timestamps,required"` Udp []string `json:"udp,required"` JSON attackLayer3TimeseriesGroupGetResponseSerie0JSON `json:"-"` @@ -395,7 +395,7 @@ type AttackLayer3TimeseriesGroupGetResponseSerie0 struct { type attackLayer3TimeseriesGroupGetResponseSerie0JSON struct { GRE apijson.Field Icmp apijson.Field - Tcp apijson.Field + TCP apijson.Field Timestamps apijson.Field Udp apijson.Field raw string @@ -529,7 +529,7 @@ func (r attackLayer3TimeseriesGroupProtocolResponseJSON) RawJSON() string { type AttackLayer3TimeseriesGroupProtocolResponseSerie0 struct { GRE []string `json:"GRE,required"` Icmp []string `json:"ICMP,required"` - Tcp []string `json:"TCP,required"` + TCP []string `json:"TCP,required"` Timestamps []string `json:"timestamps,required"` Udp []string `json:"UDP,required"` JSON attackLayer3TimeseriesGroupProtocolResponseSerie0JSON `json:"-"` @@ -540,7 +540,7 @@ type AttackLayer3TimeseriesGroupProtocolResponseSerie0 struct { type attackLayer3TimeseriesGroupProtocolResponseSerie0JSON struct { GRE apijson.Field Icmp apijson.Field - Tcp apijson.Field + TCP apijson.Field Timestamps apijson.Field Udp apijson.Field raw string @@ -686,7 +686,7 @@ type AttackLayer3TimeseriesGroupBitrateParams struct { // parameters as `url.Values`. func (r AttackLayer3TimeseriesGroupBitrateParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -808,14 +808,14 @@ type AttackLayer3TimeseriesGroupBitrateParamsProtocol string const ( AttackLayer3TimeseriesGroupBitrateParamsProtocolUdp AttackLayer3TimeseriesGroupBitrateParamsProtocol = "UDP" - AttackLayer3TimeseriesGroupBitrateParamsProtocolTcp AttackLayer3TimeseriesGroupBitrateParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupBitrateParamsProtocolTCP AttackLayer3TimeseriesGroupBitrateParamsProtocol = "TCP" AttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp AttackLayer3TimeseriesGroupBitrateParamsProtocol = "ICMP" AttackLayer3TimeseriesGroupBitrateParamsProtocolGRE AttackLayer3TimeseriesGroupBitrateParamsProtocol = "GRE" ) func (r AttackLayer3TimeseriesGroupBitrateParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TimeseriesGroupBitrateParamsProtocolUdp, AttackLayer3TimeseriesGroupBitrateParamsProtocolTcp, AttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp, AttackLayer3TimeseriesGroupBitrateParamsProtocolGRE: + case AttackLayer3TimeseriesGroupBitrateParamsProtocolUdp, AttackLayer3TimeseriesGroupBitrateParamsProtocolTCP, AttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp, AttackLayer3TimeseriesGroupBitrateParamsProtocolGRE: return true } return false @@ -885,7 +885,7 @@ type AttackLayer3TimeseriesGroupDurationParams struct { // parameters as `url.Values`. func (r AttackLayer3TimeseriesGroupDurationParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1007,14 +1007,14 @@ type AttackLayer3TimeseriesGroupDurationParamsProtocol string const ( AttackLayer3TimeseriesGroupDurationParamsProtocolUdp AttackLayer3TimeseriesGroupDurationParamsProtocol = "UDP" - AttackLayer3TimeseriesGroupDurationParamsProtocolTcp AttackLayer3TimeseriesGroupDurationParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupDurationParamsProtocolTCP AttackLayer3TimeseriesGroupDurationParamsProtocol = "TCP" AttackLayer3TimeseriesGroupDurationParamsProtocolIcmp AttackLayer3TimeseriesGroupDurationParamsProtocol = "ICMP" AttackLayer3TimeseriesGroupDurationParamsProtocolGRE AttackLayer3TimeseriesGroupDurationParamsProtocol = "GRE" ) func (r AttackLayer3TimeseriesGroupDurationParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TimeseriesGroupDurationParamsProtocolUdp, AttackLayer3TimeseriesGroupDurationParamsProtocolTcp, AttackLayer3TimeseriesGroupDurationParamsProtocolIcmp, AttackLayer3TimeseriesGroupDurationParamsProtocolGRE: + case AttackLayer3TimeseriesGroupDurationParamsProtocolUdp, AttackLayer3TimeseriesGroupDurationParamsProtocolTCP, AttackLayer3TimeseriesGroupDurationParamsProtocolIcmp, AttackLayer3TimeseriesGroupDurationParamsProtocolGRE: return true } return false @@ -1078,7 +1078,7 @@ type AttackLayer3TimeseriesGroupGetParams struct { // `url.Values`. func (r AttackLayer3TimeseriesGroupGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1212,7 +1212,7 @@ type AttackLayer3TimeseriesGroupIndustryParams struct { // parameters as `url.Values`. func (r AttackLayer3TimeseriesGroupIndustryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1392,7 +1392,7 @@ type AttackLayer3TimeseriesGroupIPVersionParams struct { // parameters as `url.Values`. func (r AttackLayer3TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1499,14 +1499,14 @@ type AttackLayer3TimeseriesGroupIPVersionParamsProtocol string const ( AttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "UDP" - AttackLayer3TimeseriesGroupIPVersionParamsProtocolTcp AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupIPVersionParamsProtocolTCP AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "TCP" AttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "ICMP" AttackLayer3TimeseriesGroupIPVersionParamsProtocolGRE AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "GRE" ) func (r AttackLayer3TimeseriesGroupIPVersionParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp, AttackLayer3TimeseriesGroupIPVersionParamsProtocolTcp, AttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp, AttackLayer3TimeseriesGroupIPVersionParamsProtocolGRE: + case AttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp, AttackLayer3TimeseriesGroupIPVersionParamsProtocolTCP, AttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp, AttackLayer3TimeseriesGroupIPVersionParamsProtocolGRE: return true } return false @@ -1574,7 +1574,7 @@ type AttackLayer3TimeseriesGroupProtocolParams struct { // parameters as `url.Values`. func (r AttackLayer3TimeseriesGroupProtocolParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1759,7 +1759,7 @@ type AttackLayer3TimeseriesGroupVectorParams struct { // as `url.Values`. func (r AttackLayer3TimeseriesGroupVectorParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1881,14 +1881,14 @@ type AttackLayer3TimeseriesGroupVectorParamsProtocol string const ( AttackLayer3TimeseriesGroupVectorParamsProtocolUdp AttackLayer3TimeseriesGroupVectorParamsProtocol = "UDP" - AttackLayer3TimeseriesGroupVectorParamsProtocolTcp AttackLayer3TimeseriesGroupVectorParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupVectorParamsProtocolTCP AttackLayer3TimeseriesGroupVectorParamsProtocol = "TCP" AttackLayer3TimeseriesGroupVectorParamsProtocolIcmp AttackLayer3TimeseriesGroupVectorParamsProtocol = "ICMP" AttackLayer3TimeseriesGroupVectorParamsProtocolGRE AttackLayer3TimeseriesGroupVectorParamsProtocol = "GRE" ) func (r AttackLayer3TimeseriesGroupVectorParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TimeseriesGroupVectorParamsProtocolUdp, AttackLayer3TimeseriesGroupVectorParamsProtocolTcp, AttackLayer3TimeseriesGroupVectorParamsProtocolIcmp, AttackLayer3TimeseriesGroupVectorParamsProtocolGRE: + case AttackLayer3TimeseriesGroupVectorParamsProtocolUdp, AttackLayer3TimeseriesGroupVectorParamsProtocolTCP, AttackLayer3TimeseriesGroupVectorParamsProtocolIcmp, AttackLayer3TimeseriesGroupVectorParamsProtocolGRE: return true } return false @@ -1959,7 +1959,7 @@ type AttackLayer3TimeseriesGroupVerticalParams struct { // parameters as `url.Values`. func (r AttackLayer3TimeseriesGroupVerticalParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/attacklayer3timeseriesgroup_test.go b/radar/attacklayer3timeseriesgroup_test.go index e73c143d0c0..12865a68a3b 100644 --- a/radar/attacklayer3timeseriesgroup_test.go +++ b/radar/attacklayer3timeseriesgroup_test.go @@ -41,7 +41,7 @@ func TestAttackLayer3TimeseriesGroupBitrateWithOptionalParams(t *testing.T) { Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupBitrateParamsNormalizationPercentage), - Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupBitrateParamsProtocol{radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupBitrateParamsProtocol{radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolTCP, radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -78,7 +78,7 @@ func TestAttackLayer3TimeseriesGroupDurationWithOptionalParams(t *testing.T) { Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupDurationParamsNormalizationPercentage), - Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupDurationParamsProtocol{radar.AttackLayer3TimeseriesGroupDurationParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupDurationParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupDurationParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupDurationParamsProtocol{radar.AttackLayer3TimeseriesGroupDurationParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupDurationParamsProtocolTCP, radar.AttackLayer3TimeseriesGroupDurationParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -185,7 +185,7 @@ func TestAttackLayer3TimeseriesGroupIPVersionWithOptionalParams(t *testing.T) { Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupIPVersionParamsNormalizationPercentage), - Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocol{radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocol{radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolTCP, radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -259,7 +259,7 @@ func TestAttackLayer3TimeseriesGroupVectorWithOptionalParams(t *testing.T) { Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupVectorParamsNormalizationPercentage), - Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupVectorParamsProtocol{radar.AttackLayer3TimeseriesGroupVectorParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupVectorParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupVectorParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupVectorParamsProtocol{radar.AttackLayer3TimeseriesGroupVectorParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupVectorParamsProtocolTCP, radar.AttackLayer3TimeseriesGroupVectorParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error diff --git a/radar/attacklayer3top.go b/radar/attacklayer3top.go index 7e729813802..e035f423fb8 100644 --- a/radar/attacklayer3top.go +++ b/radar/attacklayer3top.go @@ -233,9 +233,9 @@ func (r attackLayer3TopAttacksResponseTop0JSON) RawJSON() string { } type AttackLayer3TopIndustryResponse struct { - Meta AttackLayer3TopIndustryResponseMeta `json:"meta,required"` - Top0 []AttackLayer3TopIndustryResponseTop0 `json:"top_0,required"` - JSON attackLayer3TopIndustryResponseJSON `json:"-"` + Meta AttackLayer3TopIndustryResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON attackLayer3TopIndustryResponseJSON `json:"-"` } // attackLayer3TopIndustryResponseJSON contains the JSON metadata for the struct @@ -362,33 +362,10 @@ func (r attackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON) RawJSON return r.raw } -type AttackLayer3TopIndustryResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON attackLayer3TopIndustryResponseTop0JSON `json:"-"` -} - -// attackLayer3TopIndustryResponseTop0JSON contains the JSON metadata for the -// struct [AttackLayer3TopIndustryResponseTop0] -type attackLayer3TopIndustryResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackLayer3TopIndustryResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackLayer3TopIndustryResponseTop0JSON) RawJSON() string { - return r.raw -} - type AttackLayer3TopVerticalResponse struct { - Meta AttackLayer3TopVerticalResponseMeta `json:"meta,required"` - Top0 []AttackLayer3TopVerticalResponseTop0 `json:"top_0,required"` - JSON attackLayer3TopVerticalResponseJSON `json:"-"` + Meta AttackLayer3TopVerticalResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON attackLayer3TopVerticalResponseJSON `json:"-"` } // attackLayer3TopVerticalResponseJSON contains the JSON metadata for the struct @@ -515,29 +492,6 @@ func (r attackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON) RawJSON return r.raw } -type AttackLayer3TopVerticalResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON attackLayer3TopVerticalResponseTop0JSON `json:"-"` -} - -// attackLayer3TopVerticalResponseTop0JSON contains the JSON metadata for the -// struct [AttackLayer3TopVerticalResponseTop0] -type attackLayer3TopVerticalResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackLayer3TopVerticalResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackLayer3TopVerticalResponseTop0JSON) RawJSON() string { - return r.raw -} - type AttackLayer3TopAttacksParams struct { // Array of comma separated list of continents (alpha-2 continent codes). Start // with `-` to exclude from results. For example, `-EU,NA` excludes results from @@ -578,7 +532,7 @@ type AttackLayer3TopAttacksParams struct { // `url.Values`. func (r AttackLayer3TopAttacksParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -664,14 +618,14 @@ type AttackLayer3TopAttacksParamsProtocol string const ( AttackLayer3TopAttacksParamsProtocolUdp AttackLayer3TopAttacksParamsProtocol = "UDP" - AttackLayer3TopAttacksParamsProtocolTcp AttackLayer3TopAttacksParamsProtocol = "TCP" + AttackLayer3TopAttacksParamsProtocolTCP AttackLayer3TopAttacksParamsProtocol = "TCP" AttackLayer3TopAttacksParamsProtocolIcmp AttackLayer3TopAttacksParamsProtocol = "ICMP" AttackLayer3TopAttacksParamsProtocolGRE AttackLayer3TopAttacksParamsProtocol = "GRE" ) func (r AttackLayer3TopAttacksParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TopAttacksParamsProtocolUdp, AttackLayer3TopAttacksParamsProtocolTcp, AttackLayer3TopAttacksParamsProtocolIcmp, AttackLayer3TopAttacksParamsProtocolGRE: + case AttackLayer3TopAttacksParamsProtocolUdp, AttackLayer3TopAttacksParamsProtocolTCP, AttackLayer3TopAttacksParamsProtocolIcmp, AttackLayer3TopAttacksParamsProtocolGRE: return true } return false @@ -733,7 +687,7 @@ type AttackLayer3TopIndustryParams struct { // `url.Values`. func (r AttackLayer3TopIndustryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -801,14 +755,14 @@ type AttackLayer3TopIndustryParamsProtocol string const ( AttackLayer3TopIndustryParamsProtocolUdp AttackLayer3TopIndustryParamsProtocol = "UDP" - AttackLayer3TopIndustryParamsProtocolTcp AttackLayer3TopIndustryParamsProtocol = "TCP" + AttackLayer3TopIndustryParamsProtocolTCP AttackLayer3TopIndustryParamsProtocol = "TCP" AttackLayer3TopIndustryParamsProtocolIcmp AttackLayer3TopIndustryParamsProtocol = "ICMP" AttackLayer3TopIndustryParamsProtocolGRE AttackLayer3TopIndustryParamsProtocol = "GRE" ) func (r AttackLayer3TopIndustryParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TopIndustryParamsProtocolUdp, AttackLayer3TopIndustryParamsProtocolTcp, AttackLayer3TopIndustryParamsProtocolIcmp, AttackLayer3TopIndustryParamsProtocolGRE: + case AttackLayer3TopIndustryParamsProtocolUdp, AttackLayer3TopIndustryParamsProtocolTCP, AttackLayer3TopIndustryParamsProtocolIcmp, AttackLayer3TopIndustryParamsProtocolGRE: return true } return false @@ -870,7 +824,7 @@ type AttackLayer3TopVerticalParams struct { // `url.Values`. func (r AttackLayer3TopVerticalParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -938,14 +892,14 @@ type AttackLayer3TopVerticalParamsProtocol string const ( AttackLayer3TopVerticalParamsProtocolUdp AttackLayer3TopVerticalParamsProtocol = "UDP" - AttackLayer3TopVerticalParamsProtocolTcp AttackLayer3TopVerticalParamsProtocol = "TCP" + AttackLayer3TopVerticalParamsProtocolTCP AttackLayer3TopVerticalParamsProtocol = "TCP" AttackLayer3TopVerticalParamsProtocolIcmp AttackLayer3TopVerticalParamsProtocol = "ICMP" AttackLayer3TopVerticalParamsProtocolGRE AttackLayer3TopVerticalParamsProtocol = "GRE" ) func (r AttackLayer3TopVerticalParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TopVerticalParamsProtocolUdp, AttackLayer3TopVerticalParamsProtocolTcp, AttackLayer3TopVerticalParamsProtocolIcmp, AttackLayer3TopVerticalParamsProtocolGRE: + case AttackLayer3TopVerticalParamsProtocolUdp, AttackLayer3TopVerticalParamsProtocolTCP, AttackLayer3TopVerticalParamsProtocolIcmp, AttackLayer3TopVerticalParamsProtocolGRE: return true } return false diff --git a/radar/attacklayer3top_test.go b/radar/attacklayer3top_test.go index 9abe2101611..c27f5a0365c 100644 --- a/radar/attacklayer3top_test.go +++ b/radar/attacklayer3top_test.go @@ -41,7 +41,7 @@ func TestAttackLayer3TopAttacksWithOptionalParams(t *testing.T) { LimitPerLocation: cloudflare.F(int64(10)), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3TopAttacksParamsProtocol{radar.AttackLayer3TopAttacksParamsProtocolUdp, radar.AttackLayer3TopAttacksParamsProtocolTcp, radar.AttackLayer3TopAttacksParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TopAttacksParamsProtocol{radar.AttackLayer3TopAttacksParamsProtocolUdp, radar.AttackLayer3TopAttacksParamsProtocolTCP, radar.AttackLayer3TopAttacksParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -76,7 +76,7 @@ func TestAttackLayer3TopIndustryWithOptionalParams(t *testing.T) { Limit: cloudflare.F(int64(5)), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3TopIndustryParamsProtocol{radar.AttackLayer3TopIndustryParamsProtocolUdp, radar.AttackLayer3TopIndustryParamsProtocolTcp, radar.AttackLayer3TopIndustryParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TopIndustryParamsProtocol{radar.AttackLayer3TopIndustryParamsProtocolUdp, radar.AttackLayer3TopIndustryParamsProtocolTCP, radar.AttackLayer3TopIndustryParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -111,7 +111,7 @@ func TestAttackLayer3TopVerticalWithOptionalParams(t *testing.T) { Limit: cloudflare.F(int64(5)), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3TopVerticalParamsProtocol{radar.AttackLayer3TopVerticalParamsProtocolUdp, radar.AttackLayer3TopVerticalParamsProtocolTcp, radar.AttackLayer3TopVerticalParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TopVerticalParamsProtocol{radar.AttackLayer3TopVerticalParamsProtocolUdp, radar.AttackLayer3TopVerticalParamsProtocolTCP, radar.AttackLayer3TopVerticalParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error diff --git a/radar/attacklayer3toplocation.go b/radar/attacklayer3toplocation.go index b8b963b4e18..75d8e61b891 100644 --- a/radar/attacklayer3toplocation.go +++ b/radar/attacklayer3toplocation.go @@ -408,7 +408,7 @@ type AttackLayer3TopLocationOriginParams struct { // `url.Values`. func (r AttackLayer3TopLocationOriginParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -476,14 +476,14 @@ type AttackLayer3TopLocationOriginParamsProtocol string const ( AttackLayer3TopLocationOriginParamsProtocolUdp AttackLayer3TopLocationOriginParamsProtocol = "UDP" - AttackLayer3TopLocationOriginParamsProtocolTcp AttackLayer3TopLocationOriginParamsProtocol = "TCP" + AttackLayer3TopLocationOriginParamsProtocolTCP AttackLayer3TopLocationOriginParamsProtocol = "TCP" AttackLayer3TopLocationOriginParamsProtocolIcmp AttackLayer3TopLocationOriginParamsProtocol = "ICMP" AttackLayer3TopLocationOriginParamsProtocolGRE AttackLayer3TopLocationOriginParamsProtocol = "GRE" ) func (r AttackLayer3TopLocationOriginParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TopLocationOriginParamsProtocolUdp, AttackLayer3TopLocationOriginParamsProtocolTcp, AttackLayer3TopLocationOriginParamsProtocolIcmp, AttackLayer3TopLocationOriginParamsProtocolGRE: + case AttackLayer3TopLocationOriginParamsProtocolUdp, AttackLayer3TopLocationOriginParamsProtocolTCP, AttackLayer3TopLocationOriginParamsProtocolIcmp, AttackLayer3TopLocationOriginParamsProtocolGRE: return true } return false @@ -545,7 +545,7 @@ type AttackLayer3TopLocationTargetParams struct { // `url.Values`. func (r AttackLayer3TopLocationTargetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -613,14 +613,14 @@ type AttackLayer3TopLocationTargetParamsProtocol string const ( AttackLayer3TopLocationTargetParamsProtocolUdp AttackLayer3TopLocationTargetParamsProtocol = "UDP" - AttackLayer3TopLocationTargetParamsProtocolTcp AttackLayer3TopLocationTargetParamsProtocol = "TCP" + AttackLayer3TopLocationTargetParamsProtocolTCP AttackLayer3TopLocationTargetParamsProtocol = "TCP" AttackLayer3TopLocationTargetParamsProtocolIcmp AttackLayer3TopLocationTargetParamsProtocol = "ICMP" AttackLayer3TopLocationTargetParamsProtocolGRE AttackLayer3TopLocationTargetParamsProtocol = "GRE" ) func (r AttackLayer3TopLocationTargetParamsProtocol) IsKnown() bool { switch r { - case AttackLayer3TopLocationTargetParamsProtocolUdp, AttackLayer3TopLocationTargetParamsProtocolTcp, AttackLayer3TopLocationTargetParamsProtocolIcmp, AttackLayer3TopLocationTargetParamsProtocolGRE: + case AttackLayer3TopLocationTargetParamsProtocolUdp, AttackLayer3TopLocationTargetParamsProtocolTCP, AttackLayer3TopLocationTargetParamsProtocolIcmp, AttackLayer3TopLocationTargetParamsProtocolGRE: return true } return false diff --git a/radar/attacklayer3toplocation_test.go b/radar/attacklayer3toplocation_test.go index cd3415cb222..3d13f00b268 100644 --- a/radar/attacklayer3toplocation_test.go +++ b/radar/attacklayer3toplocation_test.go @@ -39,7 +39,7 @@ func TestAttackLayer3TopLocationOriginWithOptionalParams(t *testing.T) { Limit: cloudflare.F(int64(5)), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3TopLocationOriginParamsProtocol{radar.AttackLayer3TopLocationOriginParamsProtocolUdp, radar.AttackLayer3TopLocationOriginParamsProtocolTcp, radar.AttackLayer3TopLocationOriginParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TopLocationOriginParamsProtocol{radar.AttackLayer3TopLocationOriginParamsProtocolUdp, radar.AttackLayer3TopLocationOriginParamsProtocolTCP, radar.AttackLayer3TopLocationOriginParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error @@ -74,7 +74,7 @@ func TestAttackLayer3TopLocationTargetWithOptionalParams(t *testing.T) { Limit: cloudflare.F(int64(5)), Location: cloudflare.F([]string{"string", "string", "string"}), Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]radar.AttackLayer3TopLocationTargetParamsProtocol{radar.AttackLayer3TopLocationTargetParamsProtocolUdp, radar.AttackLayer3TopLocationTargetParamsProtocolTcp, radar.AttackLayer3TopLocationTargetParamsProtocolIcmp}), + Protocol: cloudflare.F([]radar.AttackLayer3TopLocationTargetParamsProtocol{radar.AttackLayer3TopLocationTargetParamsProtocolUdp, radar.AttackLayer3TopLocationTargetParamsProtocolTCP, radar.AttackLayer3TopLocationTargetParamsProtocolIcmp}), }) if err != nil { var apierr *cloudflare.Error diff --git a/radar/attacklayer7.go b/radar/attacklayer7.go index bed61a74e2b..04cc9d1dcf5 100644 --- a/radar/attacklayer7.go +++ b/radar/attacklayer7.go @@ -248,7 +248,7 @@ type AttackLayer7TimeseriesParams struct { // `url.Values`. func (r AttackLayer7TimeseriesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/attacklayer7summary.go b/radar/attacklayer7summary.go index d5a9d66465b..ce9306cd91d 100644 --- a/radar/attacklayer7summary.go +++ b/radar/attacklayer7summary.go @@ -1085,7 +1085,7 @@ type AttackLayer7SummaryGetParams struct { // `url.Values`. func (r AttackLayer7SummaryGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1194,7 +1194,7 @@ type AttackLayer7SummaryHTTPMethodParams struct { // `url.Values`. func (r AttackLayer7SummaryHTTPMethodParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1354,7 +1354,7 @@ type AttackLayer7SummaryHTTPVersionParams struct { // `url.Values`. func (r AttackLayer7SummaryHTTPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1557,7 +1557,7 @@ type AttackLayer7SummaryIPVersionParams struct { // `url.Values`. func (r AttackLayer7SummaryIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1763,7 +1763,7 @@ type AttackLayer7SummaryManagedRulesParams struct { // as `url.Values`. func (r AttackLayer7SummaryManagedRulesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1982,7 +1982,7 @@ type AttackLayer7SummaryMitigationProductParams struct { // parameters as `url.Values`. func (r AttackLayer7SummaryMitigationProductParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/attacklayer7timeseriesgroup.go b/radar/attacklayer7timeseriesgroup.go index 1a4e04f9d31..8b65795c287 100644 --- a/radar/attacklayer7timeseriesgroup.go +++ b/radar/attacklayer7timeseriesgroup.go @@ -664,7 +664,7 @@ type AttackLayer7TimeseriesGroupGetParams struct { // `url.Values`. func (r AttackLayer7TimeseriesGroupGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -800,7 +800,7 @@ type AttackLayer7TimeseriesGroupHTTPMethodParams struct { // parameters as `url.Values`. func (r AttackLayer7TimeseriesGroupHTTPMethodParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1004,7 +1004,7 @@ type AttackLayer7TimeseriesGroupHTTPVersionParams struct { // parameters as `url.Values`. func (r AttackLayer7TimeseriesGroupHTTPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1256,7 +1256,7 @@ type AttackLayer7TimeseriesGroupIndustryParams struct { // parameters as `url.Values`. func (r AttackLayer7TimeseriesGroupIndustryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1519,7 +1519,7 @@ type AttackLayer7TimeseriesGroupIPVersionParams struct { // parameters as `url.Values`. func (r AttackLayer7TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1769,7 +1769,7 @@ type AttackLayer7TimeseriesGroupManagedRulesParams struct { // parameters as `url.Values`. func (r AttackLayer7TimeseriesGroupManagedRulesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2033,7 +2033,7 @@ type AttackLayer7TimeseriesGroupMitigationProductParams struct { // parameters as `url.Values`. func (r AttackLayer7TimeseriesGroupMitigationProductParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2282,7 +2282,7 @@ type AttackLayer7TimeseriesGroupVerticalParams struct { // parameters as `url.Values`. func (r AttackLayer7TimeseriesGroupVerticalParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/attacklayer7top.go b/radar/attacklayer7top.go index fa80d02123d..5a30dec91dc 100644 --- a/radar/attacklayer7top.go +++ b/radar/attacklayer7top.go @@ -240,9 +240,9 @@ func (r attackLayer7TopAttacksResponseTop0JSON) RawJSON() string { } type AttackLayer7TopIndustryResponse struct { - Meta AttackLayer7TopIndustryResponseMeta `json:"meta,required"` - Top0 []AttackLayer7TopIndustryResponseTop0 `json:"top_0,required"` - JSON attackLayer7TopIndustryResponseJSON `json:"-"` + Meta AttackLayer7TopIndustryResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON attackLayer7TopIndustryResponseJSON `json:"-"` } // attackLayer7TopIndustryResponseJSON contains the JSON metadata for the struct @@ -369,33 +369,10 @@ func (r attackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON) RawJSON return r.raw } -type AttackLayer7TopIndustryResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON attackLayer7TopIndustryResponseTop0JSON `json:"-"` -} - -// attackLayer7TopIndustryResponseTop0JSON contains the JSON metadata for the -// struct [AttackLayer7TopIndustryResponseTop0] -type attackLayer7TopIndustryResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackLayer7TopIndustryResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackLayer7TopIndustryResponseTop0JSON) RawJSON() string { - return r.raw -} - type AttackLayer7TopVerticalResponse struct { - Meta AttackLayer7TopVerticalResponseMeta `json:"meta,required"` - Top0 []AttackLayer7TopVerticalResponseTop0 `json:"top_0,required"` - JSON attackLayer7TopVerticalResponseJSON `json:"-"` + Meta AttackLayer7TopVerticalResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON attackLayer7TopVerticalResponseJSON `json:"-"` } // attackLayer7TopVerticalResponseJSON contains the JSON metadata for the struct @@ -522,29 +499,6 @@ func (r attackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON) RawJSON return r.raw } -type AttackLayer7TopVerticalResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON attackLayer7TopVerticalResponseTop0JSON `json:"-"` -} - -// attackLayer7TopVerticalResponseTop0JSON contains the JSON metadata for the -// struct [AttackLayer7TopVerticalResponseTop0] -type attackLayer7TopVerticalResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AttackLayer7TopVerticalResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r attackLayer7TopVerticalResponseTop0JSON) RawJSON() string { - return r.raw -} - type AttackLayer7TopAttacksParams struct { // Array of comma separated list of ASNs, start with `-` to exclude from results. // For example, `-174, 3356` excludes results from AS174, but includes results from @@ -588,7 +542,7 @@ type AttackLayer7TopAttacksParams struct { // `url.Values`. func (r AttackLayer7TopAttacksParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -728,7 +682,7 @@ type AttackLayer7TopIndustryParams struct { // `url.Values`. func (r AttackLayer7TopIndustryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -833,7 +787,7 @@ type AttackLayer7TopVerticalParams struct { // `url.Values`. func (r AttackLayer7TopVerticalParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/attacklayer7topase.go b/radar/attacklayer7topase.go index 6d6f01e9f9e..52f89616df0 100644 --- a/radar/attacklayer7topase.go +++ b/radar/attacklayer7topase.go @@ -234,7 +234,7 @@ type AttackLayer7TopAseOriginParams struct { // `url.Values`. func (r AttackLayer7TopAseOriginParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/attacklayer7toplocation.go b/radar/attacklayer7toplocation.go index 546b79add03..21b1d603fb8 100644 --- a/radar/attacklayer7toplocation.go +++ b/radar/attacklayer7toplocation.go @@ -408,7 +408,7 @@ type AttackLayer7TopLocationOriginParams struct { // `url.Values`. func (r AttackLayer7TopLocationOriginParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -505,7 +505,7 @@ type AttackLayer7TopLocationTargetParams struct { // `url.Values`. func (r AttackLayer7TopLocationTargetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/bgp.go b/radar/bgp.go index 6128b9d8d50..f32a36aaa7a 100644 --- a/radar/bgp.go +++ b/radar/bgp.go @@ -239,7 +239,7 @@ type BGPTimeseriesParams struct { // URLQuery serializes [BGPTimeseriesParams]'s query parameters as `url.Values`. func (r BGPTimeseriesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/bgphijack.go b/radar/bgphijack.go index 827bc85bb0b..64d569e7fdd 100644 --- a/radar/bgphijack.go +++ b/radar/bgphijack.go @@ -3,15 +3,6 @@ package radar import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -21,6 +12,7 @@ import ( // service directly, and instead use the [NewBGPHijackService] method instead. type BGPHijackService struct { Options []option.RequestOption + Events *BGPHijackEventService } // NewBGPHijackService generates a new service that applies the given options to @@ -29,321 +21,6 @@ type BGPHijackService struct { func NewBGPHijackService(opts ...option.RequestOption) (r *BGPHijackService) { r = &BGPHijackService{} r.Options = opts + r.Events = NewBGPHijackEventService(opts...) return } - -// Get the BGP hijack events. (Beta) -func (r *BGPHijackService) Events(ctx context.Context, query BGPHijackEventsParams, opts ...option.RequestOption) (res *BGPHijackEventsResponse, err error) { - opts = append(r.Options[:], opts...) - var env BGPHijackEventsResponseEnvelope - path := "radar/bgp/hijacks/events" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type BGPHijackEventsResponse struct { - ASNInfo []BGPHijackEventsResponseASNInfo `json:"asn_info,required"` - Events []BGPHijackEventsResponseEvent `json:"events,required"` - TotalMonitors int64 `json:"total_monitors,required"` - JSON bgpHijackEventsResponseJSON `json:"-"` -} - -// bgpHijackEventsResponseJSON contains the JSON metadata for the struct -// [BGPHijackEventsResponse] -type bgpHijackEventsResponseJSON struct { - ASNInfo apijson.Field - Events apijson.Field - TotalMonitors apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPHijackEventsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpHijackEventsResponseJSON) RawJSON() string { - return r.raw -} - -type BGPHijackEventsResponseASNInfo struct { - ASN int64 `json:"asn,required"` - CountryCode string `json:"country_code,required"` - OrgName string `json:"org_name,required"` - JSON bgpHijackEventsResponseASNInfoJSON `json:"-"` -} - -// bgpHijackEventsResponseASNInfoJSON contains the JSON metadata for the struct -// [BGPHijackEventsResponseASNInfo] -type bgpHijackEventsResponseASNInfoJSON struct { - ASN apijson.Field - CountryCode apijson.Field - OrgName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPHijackEventsResponseASNInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpHijackEventsResponseASNInfoJSON) RawJSON() string { - return r.raw -} - -type BGPHijackEventsResponseEvent struct { - ID int64 `json:"id,required"` - ConfidenceScore int64 `json:"confidence_score,required"` - Duration int64 `json:"duration,required"` - EventType int64 `json:"event_type,required"` - HijackMsgsCount int64 `json:"hijack_msgs_count,required"` - HijackerASN int64 `json:"hijacker_asn,required"` - HijackerCountry string `json:"hijacker_country,required"` - IsStale bool `json:"is_stale,required"` - MaxHijackTs string `json:"max_hijack_ts,required"` - MaxMsgTs string `json:"max_msg_ts,required"` - MinHijackTs string `json:"min_hijack_ts,required"` - OnGoingCount int64 `json:"on_going_count,required"` - PeerASNs []int64 `json:"peer_asns,required"` - PeerIPCount int64 `json:"peer_ip_count,required"` - Prefixes []string `json:"prefixes,required"` - Tags []BGPHijackEventsResponseEventsTag `json:"tags,required"` - VictimASNs []int64 `json:"victim_asns,required"` - VictimCountries []string `json:"victim_countries,required"` - JSON bgpHijackEventsResponseEventJSON `json:"-"` -} - -// bgpHijackEventsResponseEventJSON contains the JSON metadata for the struct -// [BGPHijackEventsResponseEvent] -type bgpHijackEventsResponseEventJSON struct { - ID apijson.Field - ConfidenceScore apijson.Field - Duration apijson.Field - EventType apijson.Field - HijackMsgsCount apijson.Field - HijackerASN apijson.Field - HijackerCountry apijson.Field - IsStale apijson.Field - MaxHijackTs apijson.Field - MaxMsgTs apijson.Field - MinHijackTs apijson.Field - OnGoingCount apijson.Field - PeerASNs apijson.Field - PeerIPCount apijson.Field - Prefixes apijson.Field - Tags apijson.Field - VictimASNs apijson.Field - VictimCountries apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPHijackEventsResponseEvent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpHijackEventsResponseEventJSON) RawJSON() string { - return r.raw -} - -type BGPHijackEventsResponseEventsTag struct { - Name string `json:"name,required"` - Score int64 `json:"score,required"` - JSON bgpHijackEventsResponseEventsTagJSON `json:"-"` -} - -// bgpHijackEventsResponseEventsTagJSON contains the JSON metadata for the struct -// [BGPHijackEventsResponseEventsTag] -type bgpHijackEventsResponseEventsTagJSON struct { - Name apijson.Field - Score apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPHijackEventsResponseEventsTag) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpHijackEventsResponseEventsTagJSON) RawJSON() string { - return r.raw -} - -type BGPHijackEventsParams struct { - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[BGPHijackEventsParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // The unique identifier of a event - EventID param.Field[int64] `query:"eventId"` - // Format results are returned in. - Format param.Field[BGPHijackEventsParamsFormat] `query:"format"` - // The potential hijacker AS of a BGP hijack event - HijackerASN param.Field[int64] `query:"hijackerAsn"` - // The potential hijacker or victim AS of a BGP hijack event - InvolvedASN param.Field[int64] `query:"involvedAsn"` - // The country code of the potential hijacker or victim AS of a BGP hijack event - InvolvedCountry param.Field[string] `query:"involvedCountry"` - // The maximum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) - MaxConfidence param.Field[int64] `query:"maxConfidence"` - // The minimum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) - MinConfidence param.Field[int64] `query:"minConfidence"` - // Current page number, starting from 1 - Page param.Field[int64] `query:"page"` - // Number of entries per page - PerPage param.Field[int64] `query:"per_page"` - // The prefix hijacked during a BGP hijack event - Prefix param.Field[string] `query:"prefix"` - // Sort events by field - SortBy param.Field[BGPHijackEventsParamsSortBy] `query:"sortBy"` - // Sort order - SortOrder param.Field[BGPHijackEventsParamsSortOrder] `query:"sortOrder"` - // The potential victim AS of a BGP hijack event - VictimASN param.Field[int64] `query:"victimAsn"` -} - -// URLQuery serializes [BGPHijackEventsParams]'s query parameters as `url.Values`. -func (r BGPHijackEventsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type BGPHijackEventsParamsDateRange string - -const ( - BGPHijackEventsParamsDateRange1d BGPHijackEventsParamsDateRange = "1d" - BGPHijackEventsParamsDateRange2d BGPHijackEventsParamsDateRange = "2d" - BGPHijackEventsParamsDateRange7d BGPHijackEventsParamsDateRange = "7d" - BGPHijackEventsParamsDateRange14d BGPHijackEventsParamsDateRange = "14d" - BGPHijackEventsParamsDateRange28d BGPHijackEventsParamsDateRange = "28d" - BGPHijackEventsParamsDateRange12w BGPHijackEventsParamsDateRange = "12w" - BGPHijackEventsParamsDateRange24w BGPHijackEventsParamsDateRange = "24w" - BGPHijackEventsParamsDateRange52w BGPHijackEventsParamsDateRange = "52w" - BGPHijackEventsParamsDateRange1dControl BGPHijackEventsParamsDateRange = "1dControl" - BGPHijackEventsParamsDateRange2dControl BGPHijackEventsParamsDateRange = "2dControl" - BGPHijackEventsParamsDateRange7dControl BGPHijackEventsParamsDateRange = "7dControl" - BGPHijackEventsParamsDateRange14dControl BGPHijackEventsParamsDateRange = "14dControl" - BGPHijackEventsParamsDateRange28dControl BGPHijackEventsParamsDateRange = "28dControl" - BGPHijackEventsParamsDateRange12wControl BGPHijackEventsParamsDateRange = "12wControl" - BGPHijackEventsParamsDateRange24wControl BGPHijackEventsParamsDateRange = "24wControl" -) - -func (r BGPHijackEventsParamsDateRange) IsKnown() bool { - switch r { - case BGPHijackEventsParamsDateRange1d, BGPHijackEventsParamsDateRange2d, BGPHijackEventsParamsDateRange7d, BGPHijackEventsParamsDateRange14d, BGPHijackEventsParamsDateRange28d, BGPHijackEventsParamsDateRange12w, BGPHijackEventsParamsDateRange24w, BGPHijackEventsParamsDateRange52w, BGPHijackEventsParamsDateRange1dControl, BGPHijackEventsParamsDateRange2dControl, BGPHijackEventsParamsDateRange7dControl, BGPHijackEventsParamsDateRange14dControl, BGPHijackEventsParamsDateRange28dControl, BGPHijackEventsParamsDateRange12wControl, BGPHijackEventsParamsDateRange24wControl: - return true - } - return false -} - -// Format results are returned in. -type BGPHijackEventsParamsFormat string - -const ( - BGPHijackEventsParamsFormatJson BGPHijackEventsParamsFormat = "JSON" - BGPHijackEventsParamsFormatCsv BGPHijackEventsParamsFormat = "CSV" -) - -func (r BGPHijackEventsParamsFormat) IsKnown() bool { - switch r { - case BGPHijackEventsParamsFormatJson, BGPHijackEventsParamsFormatCsv: - return true - } - return false -} - -// Sort events by field -type BGPHijackEventsParamsSortBy string - -const ( - BGPHijackEventsParamsSortByID BGPHijackEventsParamsSortBy = "ID" - BGPHijackEventsParamsSortByTime BGPHijackEventsParamsSortBy = "TIME" - BGPHijackEventsParamsSortByConfidence BGPHijackEventsParamsSortBy = "CONFIDENCE" -) - -func (r BGPHijackEventsParamsSortBy) IsKnown() bool { - switch r { - case BGPHijackEventsParamsSortByID, BGPHijackEventsParamsSortByTime, BGPHijackEventsParamsSortByConfidence: - return true - } - return false -} - -// Sort order -type BGPHijackEventsParamsSortOrder string - -const ( - BGPHijackEventsParamsSortOrderAsc BGPHijackEventsParamsSortOrder = "ASC" - BGPHijackEventsParamsSortOrderDesc BGPHijackEventsParamsSortOrder = "DESC" -) - -func (r BGPHijackEventsParamsSortOrder) IsKnown() bool { - switch r { - case BGPHijackEventsParamsSortOrderAsc, BGPHijackEventsParamsSortOrderDesc: - return true - } - return false -} - -type BGPHijackEventsResponseEnvelope struct { - Result BGPHijackEventsResponse `json:"result,required"` - ResultInfo BGPHijackEventsResponseEnvelopeResultInfo `json:"result_info,required"` - Success bool `json:"success,required"` - JSON bgpHijackEventsResponseEnvelopeJSON `json:"-"` -} - -// bgpHijackEventsResponseEnvelopeJSON contains the JSON metadata for the struct -// [BGPHijackEventsResponseEnvelope] -type bgpHijackEventsResponseEnvelopeJSON struct { - Result apijson.Field - ResultInfo apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPHijackEventsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpHijackEventsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type BGPHijackEventsResponseEnvelopeResultInfo struct { - Count int64 `json:"count,required"` - Page int64 `json:"page,required"` - PerPage int64 `json:"per_page,required"` - TotalCount int64 `json:"total_count,required"` - JSON bgpHijackEventsResponseEnvelopeResultInfoJSON `json:"-"` -} - -// bgpHijackEventsResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [BGPHijackEventsResponseEnvelopeResultInfo] -type bgpHijackEventsResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPHijackEventsResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpHijackEventsResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/radar/bgphijackevent.go b/radar/bgphijackevent.go new file mode 100644 index 00000000000..14f9652fb06 --- /dev/null +++ b/radar/bgphijackevent.go @@ -0,0 +1,362 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "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/option" +) + +// BGPHijackEventService 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 [NewBGPHijackEventService] method +// instead. +type BGPHijackEventService struct { + Options []option.RequestOption +} + +// NewBGPHijackEventService 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 NewBGPHijackEventService(opts ...option.RequestOption) (r *BGPHijackEventService) { + r = &BGPHijackEventService{} + r.Options = opts + return +} + +// Get the BGP hijack events. (Beta) +func (r *BGPHijackEventService) List(ctx context.Context, query BGPHijackEventListParams, opts ...option.RequestOption) (res *pagination.V4PagePagination[BGPHijackEventListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "radar/bgp/hijacks/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 +} + +// Get the BGP hijack events. (Beta) +func (r *BGPHijackEventService) ListAutoPaging(ctx context.Context, query BGPHijackEventListParams, opts ...option.RequestOption) *pagination.V4PagePaginationAutoPager[BGPHijackEventListResponse] { + return pagination.NewV4PagePaginationAutoPager(r.List(ctx, query, opts...)) +} + +type BGPHijackEventListResponse struct { + Result BGPHijackEventListResponseResult `json:"result,required"` + ResultInfo BGPHijackEventListResponseResultInfo `json:"result_info,required"` + Success bool `json:"success,required"` + JSON bgpHijackEventListResponseJSON `json:"-"` +} + +// bgpHijackEventListResponseJSON contains the JSON metadata for the struct +// [BGPHijackEventListResponse] +type bgpHijackEventListResponseJSON struct { + Result apijson.Field + ResultInfo apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventListResponseJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventListResponseResult struct { + ASNInfo []BGPHijackEventListResponseResultASNInfo `json:"asn_info,required"` + Events []BGPHijackEventListResponseResultEvent `json:"events,required"` + TotalMonitors int64 `json:"total_monitors,required"` + JSON bgpHijackEventListResponseResultJSON `json:"-"` +} + +// bgpHijackEventListResponseResultJSON contains the JSON metadata for the struct +// [BGPHijackEventListResponseResult] +type bgpHijackEventListResponseResultJSON struct { + ASNInfo apijson.Field + Events apijson.Field + TotalMonitors apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventListResponseResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventListResponseResultJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventListResponseResultASNInfo struct { + ASN int64 `json:"asn,required"` + CountryCode string `json:"country_code,required"` + OrgName string `json:"org_name,required"` + JSON bgpHijackEventListResponseResultASNInfoJSON `json:"-"` +} + +// bgpHijackEventListResponseResultASNInfoJSON contains the JSON metadata for the +// struct [BGPHijackEventListResponseResultASNInfo] +type bgpHijackEventListResponseResultASNInfoJSON struct { + ASN apijson.Field + CountryCode apijson.Field + OrgName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventListResponseResultASNInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventListResponseResultASNInfoJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventListResponseResultEvent struct { + ID int64 `json:"id,required"` + ConfidenceScore int64 `json:"confidence_score,required"` + Duration int64 `json:"duration,required"` + EventType int64 `json:"event_type,required"` + HijackMsgsCount int64 `json:"hijack_msgs_count,required"` + HijackerASN int64 `json:"hijacker_asn,required"` + HijackerCountry string `json:"hijacker_country,required"` + IsStale bool `json:"is_stale,required"` + MaxHijackTs string `json:"max_hijack_ts,required"` + MaxMsgTs string `json:"max_msg_ts,required"` + MinHijackTs string `json:"min_hijack_ts,required"` + OnGoingCount int64 `json:"on_going_count,required"` + PeerASNs []int64 `json:"peer_asns,required"` + PeerIPCount int64 `json:"peer_ip_count,required"` + Prefixes []string `json:"prefixes,required"` + Tags []BGPHijackEventListResponseResultEventsTag `json:"tags,required"` + VictimASNs []int64 `json:"victim_asns,required"` + VictimCountries []string `json:"victim_countries,required"` + JSON bgpHijackEventListResponseResultEventJSON `json:"-"` +} + +// bgpHijackEventListResponseResultEventJSON contains the JSON metadata for the +// struct [BGPHijackEventListResponseResultEvent] +type bgpHijackEventListResponseResultEventJSON struct { + ID apijson.Field + ConfidenceScore apijson.Field + Duration apijson.Field + EventType apijson.Field + HijackMsgsCount apijson.Field + HijackerASN apijson.Field + HijackerCountry apijson.Field + IsStale apijson.Field + MaxHijackTs apijson.Field + MaxMsgTs apijson.Field + MinHijackTs apijson.Field + OnGoingCount apijson.Field + PeerASNs apijson.Field + PeerIPCount apijson.Field + Prefixes apijson.Field + Tags apijson.Field + VictimASNs apijson.Field + VictimCountries apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventListResponseResultEvent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventListResponseResultEventJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventListResponseResultEventsTag struct { + Name string `json:"name,required"` + Score int64 `json:"score,required"` + JSON bgpHijackEventListResponseResultEventsTagJSON `json:"-"` +} + +// bgpHijackEventListResponseResultEventsTagJSON contains the JSON metadata for the +// struct [BGPHijackEventListResponseResultEventsTag] +type bgpHijackEventListResponseResultEventsTagJSON struct { + Name apijson.Field + Score apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventListResponseResultEventsTag) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventListResponseResultEventsTagJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventListResponseResultInfo struct { + Count int64 `json:"count,required"` + Page int64 `json:"page,required"` + PerPage int64 `json:"per_page,required"` + TotalCount int64 `json:"total_count,required"` + JSON bgpHijackEventListResponseResultInfoJSON `json:"-"` +} + +// bgpHijackEventListResponseResultInfoJSON contains the JSON metadata for the +// struct [BGPHijackEventListResponseResultInfo] +type bgpHijackEventListResponseResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventListResponseResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventListResponseResultInfoJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventListParams struct { + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[BGPHijackEventListParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // The unique identifier of a event + EventID param.Field[int64] `query:"eventId"` + // Format results are returned in. + Format param.Field[BGPHijackEventListParamsFormat] `query:"format"` + // The potential hijacker AS of a BGP hijack event + HijackerASN param.Field[int64] `query:"hijackerAsn"` + // The potential hijacker or victim AS of a BGP hijack event + InvolvedASN param.Field[int64] `query:"involvedAsn"` + // The country code of the potential hijacker or victim AS of a BGP hijack event + InvolvedCountry param.Field[string] `query:"involvedCountry"` + // The maximum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) + MaxConfidence param.Field[int64] `query:"maxConfidence"` + // The minimum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) + MinConfidence param.Field[int64] `query:"minConfidence"` + // Current page number, starting from 1 + Page param.Field[int64] `query:"page"` + // Number of entries per page + PerPage param.Field[int64] `query:"per_page"` + // The prefix hijacked during a BGP hijack event + Prefix param.Field[string] `query:"prefix"` + // Sort events by field + SortBy param.Field[BGPHijackEventListParamsSortBy] `query:"sortBy"` + // Sort order + SortOrder param.Field[BGPHijackEventListParamsSortOrder] `query:"sortOrder"` + // The potential victim AS of a BGP hijack event + VictimASN param.Field[int64] `query:"victimAsn"` +} + +// URLQuery serializes [BGPHijackEventListParams]'s query parameters as +// `url.Values`. +func (r BGPHijackEventListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type BGPHijackEventListParamsDateRange string + +const ( + BGPHijackEventListParamsDateRange1d BGPHijackEventListParamsDateRange = "1d" + BGPHijackEventListParamsDateRange2d BGPHijackEventListParamsDateRange = "2d" + BGPHijackEventListParamsDateRange7d BGPHijackEventListParamsDateRange = "7d" + BGPHijackEventListParamsDateRange14d BGPHijackEventListParamsDateRange = "14d" + BGPHijackEventListParamsDateRange28d BGPHijackEventListParamsDateRange = "28d" + BGPHijackEventListParamsDateRange12w BGPHijackEventListParamsDateRange = "12w" + BGPHijackEventListParamsDateRange24w BGPHijackEventListParamsDateRange = "24w" + BGPHijackEventListParamsDateRange52w BGPHijackEventListParamsDateRange = "52w" + BGPHijackEventListParamsDateRange1dControl BGPHijackEventListParamsDateRange = "1dControl" + BGPHijackEventListParamsDateRange2dControl BGPHijackEventListParamsDateRange = "2dControl" + BGPHijackEventListParamsDateRange7dControl BGPHijackEventListParamsDateRange = "7dControl" + BGPHijackEventListParamsDateRange14dControl BGPHijackEventListParamsDateRange = "14dControl" + BGPHijackEventListParamsDateRange28dControl BGPHijackEventListParamsDateRange = "28dControl" + BGPHijackEventListParamsDateRange12wControl BGPHijackEventListParamsDateRange = "12wControl" + BGPHijackEventListParamsDateRange24wControl BGPHijackEventListParamsDateRange = "24wControl" +) + +func (r BGPHijackEventListParamsDateRange) IsKnown() bool { + switch r { + case BGPHijackEventListParamsDateRange1d, BGPHijackEventListParamsDateRange2d, BGPHijackEventListParamsDateRange7d, BGPHijackEventListParamsDateRange14d, BGPHijackEventListParamsDateRange28d, BGPHijackEventListParamsDateRange12w, BGPHijackEventListParamsDateRange24w, BGPHijackEventListParamsDateRange52w, BGPHijackEventListParamsDateRange1dControl, BGPHijackEventListParamsDateRange2dControl, BGPHijackEventListParamsDateRange7dControl, BGPHijackEventListParamsDateRange14dControl, BGPHijackEventListParamsDateRange28dControl, BGPHijackEventListParamsDateRange12wControl, BGPHijackEventListParamsDateRange24wControl: + return true + } + return false +} + +// Format results are returned in. +type BGPHijackEventListParamsFormat string + +const ( + BGPHijackEventListParamsFormatJson BGPHijackEventListParamsFormat = "JSON" + BGPHijackEventListParamsFormatCsv BGPHijackEventListParamsFormat = "CSV" +) + +func (r BGPHijackEventListParamsFormat) IsKnown() bool { + switch r { + case BGPHijackEventListParamsFormatJson, BGPHijackEventListParamsFormatCsv: + return true + } + return false +} + +// Sort events by field +type BGPHijackEventListParamsSortBy string + +const ( + BGPHijackEventListParamsSortByID BGPHijackEventListParamsSortBy = "ID" + BGPHijackEventListParamsSortByTime BGPHijackEventListParamsSortBy = "TIME" + BGPHijackEventListParamsSortByConfidence BGPHijackEventListParamsSortBy = "CONFIDENCE" +) + +func (r BGPHijackEventListParamsSortBy) IsKnown() bool { + switch r { + case BGPHijackEventListParamsSortByID, BGPHijackEventListParamsSortByTime, BGPHijackEventListParamsSortByConfidence: + return true + } + return false +} + +// Sort order +type BGPHijackEventListParamsSortOrder string + +const ( + BGPHijackEventListParamsSortOrderAsc BGPHijackEventListParamsSortOrder = "ASC" + BGPHijackEventListParamsSortOrderDesc BGPHijackEventListParamsSortOrder = "DESC" +) + +func (r BGPHijackEventListParamsSortOrder) IsKnown() bool { + switch r { + case BGPHijackEventListParamsSortOrderAsc, BGPHijackEventListParamsSortOrderDesc: + return true + } + return false +} diff --git a/radar/bgphijack_test.go b/radar/bgphijackevent_test.go similarity index 76% rename from radar/bgphijack_test.go rename to radar/bgphijackevent_test.go index e3c10fc8a05..ad36d1ce826 100644 --- a/radar/bgphijack_test.go +++ b/radar/bgphijackevent_test.go @@ -15,7 +15,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/radar" ) -func TestBGPHijackEventsWithOptionalParams(t *testing.T) { +func TestBGPHijackEventListWithOptionalParams(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 { @@ -29,12 +29,12 @@ func TestBGPHijackEventsWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Radar.BGP.Hijacks.Events(context.TODO(), radar.BGPHijackEventsParams{ + _, err := client.Radar.BGP.Hijacks.Events.List(context.TODO(), radar.BGPHijackEventListParams{ DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(radar.BGPHijackEventsParamsDateRange7d), + DateRange: cloudflare.F(radar.BGPHijackEventListParamsDateRange7d), DateStart: cloudflare.F(time.Now()), EventID: cloudflare.F(int64(0)), - Format: cloudflare.F(radar.BGPHijackEventsParamsFormatJson), + Format: cloudflare.F(radar.BGPHijackEventListParamsFormatJson), HijackerASN: cloudflare.F(int64(0)), InvolvedASN: cloudflare.F(int64(0)), InvolvedCountry: cloudflare.F("string"), @@ -43,8 +43,8 @@ func TestBGPHijackEventsWithOptionalParams(t *testing.T) { Page: cloudflare.F(int64(0)), PerPage: cloudflare.F(int64(0)), Prefix: cloudflare.F("string"), - SortBy: cloudflare.F(radar.BGPHijackEventsParamsSortByTime), - SortOrder: cloudflare.F(radar.BGPHijackEventsParamsSortOrderDesc), + SortBy: cloudflare.F(radar.BGPHijackEventListParamsSortByTime), + SortOrder: cloudflare.F(radar.BGPHijackEventListParamsSortOrderDesc), VictimASN: cloudflare.F(int64(0)), }) if err != nil { diff --git a/radar/bgpleak.go b/radar/bgpleak.go index 612b05fa13c..20b630b5e77 100644 --- a/radar/bgpleak.go +++ b/radar/bgpleak.go @@ -3,15 +3,6 @@ package radar import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -21,6 +12,7 @@ import ( // service directly, and instead use the [NewBGPLeakService] method instead. type BGPLeakService struct { Options []option.RequestOption + Events *BGPLeakEventService } // NewBGPLeakService generates a new service that applies the given options to each @@ -29,281 +21,6 @@ type BGPLeakService struct { func NewBGPLeakService(opts ...option.RequestOption) (r *BGPLeakService) { r = &BGPLeakService{} r.Options = opts + r.Events = NewBGPLeakEventService(opts...) return } - -// Get the BGP route leak events (Beta). -func (r *BGPLeakService) Events(ctx context.Context, query BGPLeakEventsParams, opts ...option.RequestOption) (res *BGPLeakEventsResponse, err error) { - opts = append(r.Options[:], opts...) - var env BGPLeakEventsResponseEnvelope - path := "radar/bgp/leaks/events" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type BGPLeakEventsResponse struct { - ASNInfo []BGPLeakEventsResponseASNInfo `json:"asn_info,required"` - Events []BGPLeakEventsResponseEvent `json:"events,required"` - JSON bgpLeakEventsResponseJSON `json:"-"` -} - -// bgpLeakEventsResponseJSON contains the JSON metadata for the struct -// [BGPLeakEventsResponse] -type bgpLeakEventsResponseJSON struct { - ASNInfo apijson.Field - Events apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPLeakEventsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpLeakEventsResponseJSON) RawJSON() string { - return r.raw -} - -type BGPLeakEventsResponseASNInfo struct { - ASN int64 `json:"asn,required"` - CountryCode string `json:"country_code,required"` - OrgName string `json:"org_name,required"` - JSON bgpLeakEventsResponseASNInfoJSON `json:"-"` -} - -// bgpLeakEventsResponseASNInfoJSON contains the JSON metadata for the struct -// [BGPLeakEventsResponseASNInfo] -type bgpLeakEventsResponseASNInfoJSON struct { - ASN apijson.Field - CountryCode apijson.Field - OrgName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPLeakEventsResponseASNInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpLeakEventsResponseASNInfoJSON) RawJSON() string { - return r.raw -} - -type BGPLeakEventsResponseEvent struct { - ID int64 `json:"id,required"` - Countries []string `json:"countries,required"` - DetectedTs string `json:"detected_ts,required"` - Finished bool `json:"finished,required"` - LeakASN int64 `json:"leak_asn,required"` - LeakCount int64 `json:"leak_count,required"` - LeakSeg []int64 `json:"leak_seg,required"` - LeakType int64 `json:"leak_type,required"` - MaxTs string `json:"max_ts,required"` - MinTs string `json:"min_ts,required"` - OriginCount int64 `json:"origin_count,required"` - PeerCount int64 `json:"peer_count,required"` - PrefixCount int64 `json:"prefix_count,required"` - JSON bgpLeakEventsResponseEventJSON `json:"-"` -} - -// bgpLeakEventsResponseEventJSON contains the JSON metadata for the struct -// [BGPLeakEventsResponseEvent] -type bgpLeakEventsResponseEventJSON struct { - ID apijson.Field - Countries apijson.Field - DetectedTs apijson.Field - Finished apijson.Field - LeakASN apijson.Field - LeakCount apijson.Field - LeakSeg apijson.Field - LeakType apijson.Field - MaxTs apijson.Field - MinTs apijson.Field - OriginCount apijson.Field - PeerCount apijson.Field - PrefixCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPLeakEventsResponseEvent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpLeakEventsResponseEventJSON) RawJSON() string { - return r.raw -} - -type BGPLeakEventsParams struct { - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[BGPLeakEventsParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // The unique identifier of a event - EventID param.Field[int64] `query:"eventId"` - // Format results are returned in. - Format param.Field[BGPLeakEventsParamsFormat] `query:"format"` - // ASN that is causing or affected by a route leak event - InvolvedASN param.Field[int64] `query:"involvedAsn"` - // Country code of a involved ASN in a route leak event - InvolvedCountry param.Field[string] `query:"involvedCountry"` - // The leaking AS of a route leak event - LeakASN param.Field[int64] `query:"leakAsn"` - // Current page number, starting from 1 - Page param.Field[int64] `query:"page"` - // Number of entries per page - PerPage param.Field[int64] `query:"per_page"` - // Sort events by field - SortBy param.Field[BGPLeakEventsParamsSortBy] `query:"sortBy"` - // Sort order - SortOrder param.Field[BGPLeakEventsParamsSortOrder] `query:"sortOrder"` -} - -// URLQuery serializes [BGPLeakEventsParams]'s query parameters as `url.Values`. -func (r BGPLeakEventsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type BGPLeakEventsParamsDateRange string - -const ( - BGPLeakEventsParamsDateRange1d BGPLeakEventsParamsDateRange = "1d" - BGPLeakEventsParamsDateRange2d BGPLeakEventsParamsDateRange = "2d" - BGPLeakEventsParamsDateRange7d BGPLeakEventsParamsDateRange = "7d" - BGPLeakEventsParamsDateRange14d BGPLeakEventsParamsDateRange = "14d" - BGPLeakEventsParamsDateRange28d BGPLeakEventsParamsDateRange = "28d" - BGPLeakEventsParamsDateRange12w BGPLeakEventsParamsDateRange = "12w" - BGPLeakEventsParamsDateRange24w BGPLeakEventsParamsDateRange = "24w" - BGPLeakEventsParamsDateRange52w BGPLeakEventsParamsDateRange = "52w" - BGPLeakEventsParamsDateRange1dControl BGPLeakEventsParamsDateRange = "1dControl" - BGPLeakEventsParamsDateRange2dControl BGPLeakEventsParamsDateRange = "2dControl" - BGPLeakEventsParamsDateRange7dControl BGPLeakEventsParamsDateRange = "7dControl" - BGPLeakEventsParamsDateRange14dControl BGPLeakEventsParamsDateRange = "14dControl" - BGPLeakEventsParamsDateRange28dControl BGPLeakEventsParamsDateRange = "28dControl" - BGPLeakEventsParamsDateRange12wControl BGPLeakEventsParamsDateRange = "12wControl" - BGPLeakEventsParamsDateRange24wControl BGPLeakEventsParamsDateRange = "24wControl" -) - -func (r BGPLeakEventsParamsDateRange) IsKnown() bool { - switch r { - case BGPLeakEventsParamsDateRange1d, BGPLeakEventsParamsDateRange2d, BGPLeakEventsParamsDateRange7d, BGPLeakEventsParamsDateRange14d, BGPLeakEventsParamsDateRange28d, BGPLeakEventsParamsDateRange12w, BGPLeakEventsParamsDateRange24w, BGPLeakEventsParamsDateRange52w, BGPLeakEventsParamsDateRange1dControl, BGPLeakEventsParamsDateRange2dControl, BGPLeakEventsParamsDateRange7dControl, BGPLeakEventsParamsDateRange14dControl, BGPLeakEventsParamsDateRange28dControl, BGPLeakEventsParamsDateRange12wControl, BGPLeakEventsParamsDateRange24wControl: - return true - } - return false -} - -// Format results are returned in. -type BGPLeakEventsParamsFormat string - -const ( - BGPLeakEventsParamsFormatJson BGPLeakEventsParamsFormat = "JSON" - BGPLeakEventsParamsFormatCsv BGPLeakEventsParamsFormat = "CSV" -) - -func (r BGPLeakEventsParamsFormat) IsKnown() bool { - switch r { - case BGPLeakEventsParamsFormatJson, BGPLeakEventsParamsFormatCsv: - return true - } - return false -} - -// Sort events by field -type BGPLeakEventsParamsSortBy string - -const ( - BGPLeakEventsParamsSortByID BGPLeakEventsParamsSortBy = "ID" - BGPLeakEventsParamsSortByLeaks BGPLeakEventsParamsSortBy = "LEAKS" - BGPLeakEventsParamsSortByPeers BGPLeakEventsParamsSortBy = "PEERS" - BGPLeakEventsParamsSortByPrefixes BGPLeakEventsParamsSortBy = "PREFIXES" - BGPLeakEventsParamsSortByOrigins BGPLeakEventsParamsSortBy = "ORIGINS" - BGPLeakEventsParamsSortByTime BGPLeakEventsParamsSortBy = "TIME" -) - -func (r BGPLeakEventsParamsSortBy) IsKnown() bool { - switch r { - case BGPLeakEventsParamsSortByID, BGPLeakEventsParamsSortByLeaks, BGPLeakEventsParamsSortByPeers, BGPLeakEventsParamsSortByPrefixes, BGPLeakEventsParamsSortByOrigins, BGPLeakEventsParamsSortByTime: - return true - } - return false -} - -// Sort order -type BGPLeakEventsParamsSortOrder string - -const ( - BGPLeakEventsParamsSortOrderAsc BGPLeakEventsParamsSortOrder = "ASC" - BGPLeakEventsParamsSortOrderDesc BGPLeakEventsParamsSortOrder = "DESC" -) - -func (r BGPLeakEventsParamsSortOrder) IsKnown() bool { - switch r { - case BGPLeakEventsParamsSortOrderAsc, BGPLeakEventsParamsSortOrderDesc: - return true - } - return false -} - -type BGPLeakEventsResponseEnvelope struct { - Result BGPLeakEventsResponse `json:"result,required"` - ResultInfo BGPLeakEventsResponseEnvelopeResultInfo `json:"result_info,required"` - Success bool `json:"success,required"` - JSON bgpLeakEventsResponseEnvelopeJSON `json:"-"` -} - -// bgpLeakEventsResponseEnvelopeJSON contains the JSON metadata for the struct -// [BGPLeakEventsResponseEnvelope] -type bgpLeakEventsResponseEnvelopeJSON struct { - Result apijson.Field - ResultInfo apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPLeakEventsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpLeakEventsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type BGPLeakEventsResponseEnvelopeResultInfo struct { - Count int64 `json:"count,required"` - Page int64 `json:"page,required"` - PerPage int64 `json:"per_page,required"` - TotalCount int64 `json:"total_count,required"` - JSON bgpLeakEventsResponseEnvelopeResultInfoJSON `json:"-"` -} - -// bgpLeakEventsResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [BGPLeakEventsResponseEnvelopeResultInfo] -type bgpLeakEventsResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BGPLeakEventsResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r bgpLeakEventsResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/radar/bgpleakevent.go b/radar/bgpleakevent.go new file mode 100644 index 00000000000..27f5221e71c --- /dev/null +++ b/radar/bgpleakevent.go @@ -0,0 +1,321 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "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/option" +) + +// BGPLeakEventService 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 [NewBGPLeakEventService] method +// instead. +type BGPLeakEventService struct { + Options []option.RequestOption +} + +// NewBGPLeakEventService 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 NewBGPLeakEventService(opts ...option.RequestOption) (r *BGPLeakEventService) { + r = &BGPLeakEventService{} + r.Options = opts + return +} + +// Get the BGP route leak events (Beta). +func (r *BGPLeakEventService) List(ctx context.Context, query BGPLeakEventListParams, opts ...option.RequestOption) (res *pagination.V4PagePagination[BGPLeakEventListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "radar/bgp/leaks/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 +} + +// Get the BGP route leak events (Beta). +func (r *BGPLeakEventService) ListAutoPaging(ctx context.Context, query BGPLeakEventListParams, opts ...option.RequestOption) *pagination.V4PagePaginationAutoPager[BGPLeakEventListResponse] { + return pagination.NewV4PagePaginationAutoPager(r.List(ctx, query, opts...)) +} + +type BGPLeakEventListResponse struct { + Result BGPLeakEventListResponseResult `json:"result,required"` + ResultInfo BGPLeakEventListResponseResultInfo `json:"result_info,required"` + Success bool `json:"success,required"` + JSON bgpLeakEventListResponseJSON `json:"-"` +} + +// bgpLeakEventListResponseJSON contains the JSON metadata for the struct +// [BGPLeakEventListResponse] +type bgpLeakEventListResponseJSON struct { + Result apijson.Field + ResultInfo apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventListResponseJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventListResponseResult struct { + ASNInfo []BGPLeakEventListResponseResultASNInfo `json:"asn_info,required"` + Events []BGPLeakEventListResponseResultEvent `json:"events,required"` + JSON bgpLeakEventListResponseResultJSON `json:"-"` +} + +// bgpLeakEventListResponseResultJSON contains the JSON metadata for the struct +// [BGPLeakEventListResponseResult] +type bgpLeakEventListResponseResultJSON struct { + ASNInfo apijson.Field + Events apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventListResponseResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventListResponseResultJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventListResponseResultASNInfo struct { + ASN int64 `json:"asn,required"` + CountryCode string `json:"country_code,required"` + OrgName string `json:"org_name,required"` + JSON bgpLeakEventListResponseResultASNInfoJSON `json:"-"` +} + +// bgpLeakEventListResponseResultASNInfoJSON contains the JSON metadata for the +// struct [BGPLeakEventListResponseResultASNInfo] +type bgpLeakEventListResponseResultASNInfoJSON struct { + ASN apijson.Field + CountryCode apijson.Field + OrgName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventListResponseResultASNInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventListResponseResultASNInfoJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventListResponseResultEvent struct { + ID int64 `json:"id,required"` + Countries []string `json:"countries,required"` + DetectedTs string `json:"detected_ts,required"` + Finished bool `json:"finished,required"` + LeakASN int64 `json:"leak_asn,required"` + LeakCount int64 `json:"leak_count,required"` + LeakSeg []int64 `json:"leak_seg,required"` + LeakType int64 `json:"leak_type,required"` + MaxTs string `json:"max_ts,required"` + MinTs string `json:"min_ts,required"` + OriginCount int64 `json:"origin_count,required"` + PeerCount int64 `json:"peer_count,required"` + PrefixCount int64 `json:"prefix_count,required"` + JSON bgpLeakEventListResponseResultEventJSON `json:"-"` +} + +// bgpLeakEventListResponseResultEventJSON contains the JSON metadata for the +// struct [BGPLeakEventListResponseResultEvent] +type bgpLeakEventListResponseResultEventJSON struct { + ID apijson.Field + Countries apijson.Field + DetectedTs apijson.Field + Finished apijson.Field + LeakASN apijson.Field + LeakCount apijson.Field + LeakSeg apijson.Field + LeakType apijson.Field + MaxTs apijson.Field + MinTs apijson.Field + OriginCount apijson.Field + PeerCount apijson.Field + PrefixCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventListResponseResultEvent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventListResponseResultEventJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventListResponseResultInfo struct { + Count int64 `json:"count,required"` + Page int64 `json:"page,required"` + PerPage int64 `json:"per_page,required"` + TotalCount int64 `json:"total_count,required"` + JSON bgpLeakEventListResponseResultInfoJSON `json:"-"` +} + +// bgpLeakEventListResponseResultInfoJSON contains the JSON metadata for the struct +// [BGPLeakEventListResponseResultInfo] +type bgpLeakEventListResponseResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventListResponseResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventListResponseResultInfoJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventListParams struct { + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[BGPLeakEventListParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // The unique identifier of a event + EventID param.Field[int64] `query:"eventId"` + // Format results are returned in. + Format param.Field[BGPLeakEventListParamsFormat] `query:"format"` + // ASN that is causing or affected by a route leak event + InvolvedASN param.Field[int64] `query:"involvedAsn"` + // Country code of a involved ASN in a route leak event + InvolvedCountry param.Field[string] `query:"involvedCountry"` + // The leaking AS of a route leak event + LeakASN param.Field[int64] `query:"leakAsn"` + // Current page number, starting from 1 + Page param.Field[int64] `query:"page"` + // Number of entries per page + PerPage param.Field[int64] `query:"per_page"` + // Sort events by field + SortBy param.Field[BGPLeakEventListParamsSortBy] `query:"sortBy"` + // Sort order + SortOrder param.Field[BGPLeakEventListParamsSortOrder] `query:"sortOrder"` +} + +// URLQuery serializes [BGPLeakEventListParams]'s query parameters as `url.Values`. +func (r BGPLeakEventListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type BGPLeakEventListParamsDateRange string + +const ( + BGPLeakEventListParamsDateRange1d BGPLeakEventListParamsDateRange = "1d" + BGPLeakEventListParamsDateRange2d BGPLeakEventListParamsDateRange = "2d" + BGPLeakEventListParamsDateRange7d BGPLeakEventListParamsDateRange = "7d" + BGPLeakEventListParamsDateRange14d BGPLeakEventListParamsDateRange = "14d" + BGPLeakEventListParamsDateRange28d BGPLeakEventListParamsDateRange = "28d" + BGPLeakEventListParamsDateRange12w BGPLeakEventListParamsDateRange = "12w" + BGPLeakEventListParamsDateRange24w BGPLeakEventListParamsDateRange = "24w" + BGPLeakEventListParamsDateRange52w BGPLeakEventListParamsDateRange = "52w" + BGPLeakEventListParamsDateRange1dControl BGPLeakEventListParamsDateRange = "1dControl" + BGPLeakEventListParamsDateRange2dControl BGPLeakEventListParamsDateRange = "2dControl" + BGPLeakEventListParamsDateRange7dControl BGPLeakEventListParamsDateRange = "7dControl" + BGPLeakEventListParamsDateRange14dControl BGPLeakEventListParamsDateRange = "14dControl" + BGPLeakEventListParamsDateRange28dControl BGPLeakEventListParamsDateRange = "28dControl" + BGPLeakEventListParamsDateRange12wControl BGPLeakEventListParamsDateRange = "12wControl" + BGPLeakEventListParamsDateRange24wControl BGPLeakEventListParamsDateRange = "24wControl" +) + +func (r BGPLeakEventListParamsDateRange) IsKnown() bool { + switch r { + case BGPLeakEventListParamsDateRange1d, BGPLeakEventListParamsDateRange2d, BGPLeakEventListParamsDateRange7d, BGPLeakEventListParamsDateRange14d, BGPLeakEventListParamsDateRange28d, BGPLeakEventListParamsDateRange12w, BGPLeakEventListParamsDateRange24w, BGPLeakEventListParamsDateRange52w, BGPLeakEventListParamsDateRange1dControl, BGPLeakEventListParamsDateRange2dControl, BGPLeakEventListParamsDateRange7dControl, BGPLeakEventListParamsDateRange14dControl, BGPLeakEventListParamsDateRange28dControl, BGPLeakEventListParamsDateRange12wControl, BGPLeakEventListParamsDateRange24wControl: + return true + } + return false +} + +// Format results are returned in. +type BGPLeakEventListParamsFormat string + +const ( + BGPLeakEventListParamsFormatJson BGPLeakEventListParamsFormat = "JSON" + BGPLeakEventListParamsFormatCsv BGPLeakEventListParamsFormat = "CSV" +) + +func (r BGPLeakEventListParamsFormat) IsKnown() bool { + switch r { + case BGPLeakEventListParamsFormatJson, BGPLeakEventListParamsFormatCsv: + return true + } + return false +} + +// Sort events by field +type BGPLeakEventListParamsSortBy string + +const ( + BGPLeakEventListParamsSortByID BGPLeakEventListParamsSortBy = "ID" + BGPLeakEventListParamsSortByLeaks BGPLeakEventListParamsSortBy = "LEAKS" + BGPLeakEventListParamsSortByPeers BGPLeakEventListParamsSortBy = "PEERS" + BGPLeakEventListParamsSortByPrefixes BGPLeakEventListParamsSortBy = "PREFIXES" + BGPLeakEventListParamsSortByOrigins BGPLeakEventListParamsSortBy = "ORIGINS" + BGPLeakEventListParamsSortByTime BGPLeakEventListParamsSortBy = "TIME" +) + +func (r BGPLeakEventListParamsSortBy) IsKnown() bool { + switch r { + case BGPLeakEventListParamsSortByID, BGPLeakEventListParamsSortByLeaks, BGPLeakEventListParamsSortByPeers, BGPLeakEventListParamsSortByPrefixes, BGPLeakEventListParamsSortByOrigins, BGPLeakEventListParamsSortByTime: + return true + } + return false +} + +// Sort order +type BGPLeakEventListParamsSortOrder string + +const ( + BGPLeakEventListParamsSortOrderAsc BGPLeakEventListParamsSortOrder = "ASC" + BGPLeakEventListParamsSortOrderDesc BGPLeakEventListParamsSortOrder = "DESC" +) + +func (r BGPLeakEventListParamsSortOrder) IsKnown() bool { + switch r { + case BGPLeakEventListParamsSortOrderAsc, BGPLeakEventListParamsSortOrderDesc: + return true + } + return false +} diff --git a/radar/bgpleak_test.go b/radar/bgpleakevent_test.go similarity index 74% rename from radar/bgpleak_test.go rename to radar/bgpleakevent_test.go index 80997979bb3..7c44f8c02cd 100644 --- a/radar/bgpleak_test.go +++ b/radar/bgpleakevent_test.go @@ -15,7 +15,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/radar" ) -func TestBGPLeakEventsWithOptionalParams(t *testing.T) { +func TestBGPLeakEventListWithOptionalParams(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 { @@ -29,19 +29,19 @@ func TestBGPLeakEventsWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Radar.BGP.Leaks.Events(context.TODO(), radar.BGPLeakEventsParams{ + _, err := client.Radar.BGP.Leaks.Events.List(context.TODO(), radar.BGPLeakEventListParams{ DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(radar.BGPLeakEventsParamsDateRange7d), + DateRange: cloudflare.F(radar.BGPLeakEventListParamsDateRange7d), DateStart: cloudflare.F(time.Now()), EventID: cloudflare.F(int64(0)), - Format: cloudflare.F(radar.BGPLeakEventsParamsFormatJson), + Format: cloudflare.F(radar.BGPLeakEventListParamsFormatJson), InvolvedASN: cloudflare.F(int64(0)), InvolvedCountry: cloudflare.F("string"), LeakASN: cloudflare.F(int64(0)), Page: cloudflare.F(int64(0)), PerPage: cloudflare.F(int64(0)), - SortBy: cloudflare.F(radar.BGPLeakEventsParamsSortByTime), - SortOrder: cloudflare.F(radar.BGPLeakEventsParamsSortOrderDesc), + SortBy: cloudflare.F(radar.BGPLeakEventListParamsSortByTime), + SortOrder: cloudflare.F(radar.BGPLeakEventListParamsSortOrderDesc), }) if err != nil { var apierr *cloudflare.Error diff --git a/radar/bgproute.go b/radar/bgproute.go index 76b4b571e89..90b0202be78 100644 --- a/radar/bgproute.go +++ b/radar/bgproute.go @@ -490,7 +490,7 @@ type BGPRouteMoasParams struct { // URLQuery serializes [BGPRouteMoasParams]'s query parameters as `url.Values`. func (r BGPRouteMoasParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -551,7 +551,7 @@ type BGPRoutePfx2asParams struct { // URLQuery serializes [BGPRoutePfx2asParams]'s query parameters as `url.Values`. func (r BGPRoutePfx2asParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -624,7 +624,7 @@ type BGPRouteStatsParams struct { // URLQuery serializes [BGPRouteStatsParams]'s query parameters as `url.Values`. func (r BGPRouteStatsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -680,6 +680,8 @@ type BGPRouteTimeseriesParams struct { DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` // Format results are returned in. Format param.Field[BGPRouteTimeseriesParamsFormat] `query:"format"` + // Include data delay meta information + IncludeDelay param.Field[bool] `query:"includeDelay"` // Location Alpha2 code. Location param.Field[string] `query:"location"` } @@ -688,7 +690,7 @@ type BGPRouteTimeseriesParams struct { // `url.Values`. func (r BGPRouteTimeseriesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/bgproute_test.go b/radar/bgproute_test.go index f0c67750352..b6da03886e5 100644 --- a/radar/bgproute_test.go +++ b/radar/bgproute_test.go @@ -117,12 +117,13 @@ func TestBGPRouteTimeseriesWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.Radar.BGP.Routes.Timeseries(context.TODO(), radar.BGPRouteTimeseriesParams{ - ASN: cloudflare.F(int64(0)), - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(radar.BGPRouteTimeseriesParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - Format: cloudflare.F(radar.BGPRouteTimeseriesParamsFormatJson), - Location: cloudflare.F("US"), + ASN: cloudflare.F(int64(0)), + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.BGPRouteTimeseriesParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + Format: cloudflare.F(radar.BGPRouteTimeseriesParamsFormatJson), + IncludeDelay: cloudflare.F(true), + Location: cloudflare.F("US"), }) if err != nil { var apierr *cloudflare.Error diff --git a/radar/bgptop.go b/radar/bgptop.go index 2f0750c9bb2..e3cd84dd688 100644 --- a/radar/bgptop.go +++ b/radar/bgptop.go @@ -166,7 +166,7 @@ type BGPTopPrefixesParams struct { // URLQuery serializes [BGPTopPrefixesParams]'s query parameters as `url.Values`. func (r BGPTopPrefixesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/bgptopase.go b/radar/bgptopase.go index cb2e42fc9b4..c86138c0752 100644 --- a/radar/bgptopase.go +++ b/radar/bgptopase.go @@ -260,7 +260,7 @@ type BGPTopAseGetParams struct { // URLQuery serializes [BGPTopAseGetParams]'s query parameters as `url.Values`. func (r BGPTopAseGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -360,7 +360,7 @@ type BGPTopAsePrefixesParams struct { // `url.Values`. func (r BGPTopAsePrefixesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/connectiontampering.go b/radar/connectiontampering.go index 415d9d501c9..ef28e8dd208 100644 --- a/radar/connectiontampering.go +++ b/radar/connectiontampering.go @@ -432,7 +432,7 @@ type ConnectionTamperingSummaryParams struct { // `url.Values`. func (r ConnectionTamperingSummaryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -539,7 +539,7 @@ type ConnectionTamperingTimeseriesGroupsParams struct { // parameters as `url.Values`. func (r ConnectionTamperingTimeseriesGroupsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/dataset.go b/radar/dataset.go index 856703fae42..7b5dbc4d21e 100644 --- a/radar/dataset.go +++ b/radar/dataset.go @@ -177,7 +177,7 @@ type DatasetListParams struct { // URLQuery serializes [DatasetListParams]'s query parameters as `url.Values`. func (r DatasetListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -250,7 +250,7 @@ func (r DatasetDownloadParams) MarshalJSON() (data []byte, err error) { // URLQuery serializes [DatasetDownloadParams]'s query parameters as `url.Values`. func (r DatasetDownloadParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -302,7 +302,7 @@ type DatasetGetParams struct { // URLQuery serializes [DatasetGetParams]'s query parameters as `url.Values`. func (r DatasetGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/dnstop.go b/radar/dnstop.go index 56ea0509675..acc7b7c2579 100644 --- a/radar/dnstop.go +++ b/radar/dnstop.go @@ -397,7 +397,7 @@ type DNSTopAsesParams struct { // URLQuery serializes [DNSTopAsesParams]'s query parameters as `url.Values`. func (r DNSTopAsesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -503,7 +503,7 @@ type DNSTopLocationsParams struct { // URLQuery serializes [DNSTopLocationsParams]'s query parameters as `url.Values`. func (r DNSTopLocationsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/email.go b/radar/email.go index 4c13573b6f1..e453ed12c2b 100644 --- a/radar/email.go +++ b/radar/email.go @@ -3,6 +3,7 @@ package radar import ( + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -26,3 +27,53 @@ func NewEmailService(opts ...option.RequestOption) (r *EmailService) { r.Security = NewEmailSecurityService(opts...) return } + +type RadarEmailSeries struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON radarEmailSeriesJSON `json:"-"` +} + +// radarEmailSeriesJSON contains the JSON metadata for the struct +// [RadarEmailSeries] +type radarEmailSeriesJSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RadarEmailSeries) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r radarEmailSeriesJSON) RawJSON() string { + return r.raw +} + +type RadarEmailSummary struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON radarEmailSummaryJSON `json:"-"` +} + +// radarEmailSummaryJSON contains the JSON metadata for the struct +// [RadarEmailSummary] +type radarEmailSummaryJSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RadarEmailSummary) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r radarEmailSummaryJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailroutingsummary.go b/radar/emailroutingsummary.go index 073baca5737..7ad68960984 100644 --- a/radar/emailroutingsummary.go +++ b/radar/emailroutingsummary.go @@ -112,9 +112,9 @@ func (r *EmailRoutingSummaryService) SPF(ctx context.Context, query EmailRouting } type EmailRoutingSummaryARCResponse struct { - Meta EmailRoutingSummaryARCResponseMeta `json:"meta,required"` - Summary0 EmailRoutingSummaryARCResponseSummary0 `json:"summary_0,required"` - JSON emailRoutingSummaryARCResponseJSON `json:"-"` + Meta EmailRoutingSummaryARCResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailRoutingSummaryARCResponseJSON `json:"-"` } // emailRoutingSummaryARCResponseJSON contains the JSON metadata for the struct @@ -243,35 +243,10 @@ func (r emailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON( return r.raw } -type EmailRoutingSummaryARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailRoutingSummaryARCResponseSummary0JSON `json:"-"` -} - -// emailRoutingSummaryARCResponseSummary0JSON contains the JSON metadata for the -// struct [EmailRoutingSummaryARCResponseSummary0] -type emailRoutingSummaryARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingSummaryARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingSummaryARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingSummaryDKIMResponse struct { - Meta EmailRoutingSummaryDKIMResponseMeta `json:"meta,required"` - Summary0 EmailRoutingSummaryDKIMResponseSummary0 `json:"summary_0,required"` - JSON emailRoutingSummaryDKIMResponseJSON `json:"-"` + Meta EmailRoutingSummaryDKIMResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailRoutingSummaryDKIMResponseJSON `json:"-"` } // emailRoutingSummaryDKIMResponseJSON contains the JSON metadata for the struct @@ -400,35 +375,10 @@ func (r emailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON) RawJSON return r.raw } -type EmailRoutingSummaryDKIMResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailRoutingSummaryDKIMResponseSummary0JSON `json:"-"` -} - -// emailRoutingSummaryDKIMResponseSummary0JSON contains the JSON metadata for the -// struct [EmailRoutingSummaryDKIMResponseSummary0] -type emailRoutingSummaryDKIMResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingSummaryDKIMResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingSummaryDKIMResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingSummaryDMARCResponse struct { - Meta EmailRoutingSummaryDMARCResponseMeta `json:"meta,required"` - Summary0 EmailRoutingSummaryDMARCResponseSummary0 `json:"summary_0,required"` - JSON emailRoutingSummaryDMARCResponseJSON `json:"-"` + Meta EmailRoutingSummaryDMARCResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailRoutingSummaryDMARCResponseJSON `json:"-"` } // emailRoutingSummaryDMARCResponseJSON contains the JSON metadata for the struct @@ -557,31 +507,6 @@ func (r emailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON) RawJSO return r.raw } -type EmailRoutingSummaryDMARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailRoutingSummaryDMARCResponseSummary0JSON `json:"-"` -} - -// emailRoutingSummaryDMARCResponseSummary0JSON contains the JSON metadata for the -// struct [EmailRoutingSummaryDMARCResponseSummary0] -type emailRoutingSummaryDMARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingSummaryDMARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingSummaryDMARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingSummaryEncryptedResponse struct { Meta EmailRoutingSummaryEncryptedResponseMeta `json:"meta,required"` Summary0 EmailRoutingSummaryEncryptedResponseSummary0 `json:"summary_0,required"` @@ -893,9 +818,9 @@ func (r emailRoutingSummaryIPVersionResponseSummary0JSON) RawJSON() string { } type EmailRoutingSummarySPFResponse struct { - Meta EmailRoutingSummarySPFResponseMeta `json:"meta,required"` - Summary0 EmailRoutingSummarySPFResponseSummary0 `json:"summary_0,required"` - JSON emailRoutingSummarySPFResponseJSON `json:"-"` + Meta EmailRoutingSummarySPFResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailRoutingSummarySPFResponseJSON `json:"-"` } // emailRoutingSummarySPFResponseJSON contains the JSON metadata for the struct @@ -1024,31 +949,6 @@ func (r emailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON) RawJSON( return r.raw } -type EmailRoutingSummarySPFResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailRoutingSummarySPFResponseSummary0JSON `json:"-"` -} - -// emailRoutingSummarySPFResponseSummary0JSON contains the JSON metadata for the -// struct [EmailRoutingSummarySPFResponseSummary0] -type emailRoutingSummarySPFResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingSummarySPFResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingSummarySPFResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingSummaryARCParams struct { // End of the date range (inclusive). DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` @@ -1078,7 +978,7 @@ type EmailRoutingSummaryARCParams struct { // `url.Values`. func (r EmailRoutingSummaryARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1257,7 +1157,7 @@ type EmailRoutingSummaryDKIMParams struct { // `url.Values`. func (r EmailRoutingSummaryDKIMParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1436,7 +1336,7 @@ type EmailRoutingSummaryDMARCParams struct { // `url.Values`. func (r EmailRoutingSummaryDMARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1615,7 +1515,7 @@ type EmailRoutingSummaryEncryptedParams struct { // `url.Values`. func (r EmailRoutingSummaryEncryptedParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1795,7 +1695,7 @@ type EmailRoutingSummaryIPVersionParams struct { // `url.Values`. func (r EmailRoutingSummaryIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1975,7 +1875,7 @@ type EmailRoutingSummarySPFParams struct { // `url.Values`. func (r EmailRoutingSummarySPFParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/emailroutingtimeseriesgroup.go b/radar/emailroutingtimeseriesgroup.go index 253ae12fbac..65bf68ef9b5 100644 --- a/radar/emailroutingtimeseriesgroup.go +++ b/radar/emailroutingtimeseriesgroup.go @@ -112,9 +112,9 @@ func (r *EmailRoutingTimeseriesGroupService) SPF(ctx context.Context, query Emai } type EmailRoutingTimeseriesGroupARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailRoutingTimeseriesGroupARCResponseSerie0 `json:"serie_0,required"` - JSON emailRoutingTimeseriesGroupARCResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupARCResponseJSON `json:"-"` } // emailRoutingTimeseriesGroupARCResponseJSON contains the JSON metadata for the @@ -134,35 +134,10 @@ func (r emailRoutingTimeseriesGroupARCResponseJSON) RawJSON() string { return r.raw } -type EmailRoutingTimeseriesGroupARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailRoutingTimeseriesGroupARCResponseSerie0JSON `json:"-"` -} - -// emailRoutingTimeseriesGroupARCResponseSerie0JSON contains the JSON metadata for -// the struct [EmailRoutingTimeseriesGroupARCResponseSerie0] -type emailRoutingTimeseriesGroupARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingTimeseriesGroupARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingTimeseriesGroupARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingTimeseriesGroupDKIMResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailRoutingTimeseriesGroupDKIMResponseSerie0 `json:"serie_0,required"` - JSON emailRoutingTimeseriesGroupDKIMResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupDKIMResponseJSON `json:"-"` } // emailRoutingTimeseriesGroupDKIMResponseJSON contains the JSON metadata for the @@ -182,35 +157,10 @@ func (r emailRoutingTimeseriesGroupDKIMResponseJSON) RawJSON() string { return r.raw } -type EmailRoutingTimeseriesGroupDKIMResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailRoutingTimeseriesGroupDKIMResponseSerie0JSON `json:"-"` -} - -// emailRoutingTimeseriesGroupDKIMResponseSerie0JSON contains the JSON metadata for -// the struct [EmailRoutingTimeseriesGroupDKIMResponseSerie0] -type emailRoutingTimeseriesGroupDKIMResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingTimeseriesGroupDKIMResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingTimeseriesGroupDKIMResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingTimeseriesGroupDMARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailRoutingTimeseriesGroupDMARCResponseSerie0 `json:"serie_0,required"` - JSON emailRoutingTimeseriesGroupDMARCResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupDMARCResponseJSON `json:"-"` } // emailRoutingTimeseriesGroupDMARCResponseJSON contains the JSON metadata for the @@ -230,31 +180,6 @@ func (r emailRoutingTimeseriesGroupDMARCResponseJSON) RawJSON() string { return r.raw } -type EmailRoutingTimeseriesGroupDMARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailRoutingTimeseriesGroupDMARCResponseSerie0JSON `json:"-"` -} - -// emailRoutingTimeseriesGroupDMARCResponseSerie0JSON contains the JSON metadata -// for the struct [EmailRoutingTimeseriesGroupDMARCResponseSerie0] -type emailRoutingTimeseriesGroupDMARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingTimeseriesGroupDMARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingTimeseriesGroupDMARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingTimeseriesGroupEncryptedResponse struct { Meta interface{} `json:"meta,required"` Serie0 EmailRoutingTimeseriesGroupEncryptedResponseSerie0 `json:"serie_0,required"` @@ -348,9 +273,9 @@ func (r emailRoutingTimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string } type EmailRoutingTimeseriesGroupSPFResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailRoutingTimeseriesGroupSPFResponseSerie0 `json:"serie_0,required"` - JSON emailRoutingTimeseriesGroupSPFResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupSPFResponseJSON `json:"-"` } // emailRoutingTimeseriesGroupSPFResponseJSON contains the JSON metadata for the @@ -370,31 +295,6 @@ func (r emailRoutingTimeseriesGroupSPFResponseJSON) RawJSON() string { return r.raw } -type EmailRoutingTimeseriesGroupSPFResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailRoutingTimeseriesGroupSPFResponseSerie0JSON `json:"-"` -} - -// emailRoutingTimeseriesGroupSPFResponseSerie0JSON contains the JSON metadata for -// the struct [EmailRoutingTimeseriesGroupSPFResponseSerie0] -type emailRoutingTimeseriesGroupSPFResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingTimeseriesGroupSPFResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingTimeseriesGroupSPFResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailRoutingTimeseriesGroupARCParams struct { // Aggregation interval results should be returned in (for example, in 15 minutes // or 1 hour intervals). Refer to @@ -428,7 +328,7 @@ type EmailRoutingTimeseriesGroupARCParams struct { // `url.Values`. func (r EmailRoutingTimeseriesGroupARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -631,7 +531,7 @@ type EmailRoutingTimeseriesGroupDKIMParams struct { // as `url.Values`. func (r EmailRoutingTimeseriesGroupDKIMParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -834,7 +734,7 @@ type EmailRoutingTimeseriesGroupDMARCParams struct { // as `url.Values`. func (r EmailRoutingTimeseriesGroupDMARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1037,7 +937,7 @@ type EmailRoutingTimeseriesGroupEncryptedParams struct { // parameters as `url.Values`. func (r EmailRoutingTimeseriesGroupEncryptedParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1241,7 +1141,7 @@ type EmailRoutingTimeseriesGroupIPVersionParams struct { // parameters as `url.Values`. func (r EmailRoutingTimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1445,7 +1345,7 @@ type EmailRoutingTimeseriesGroupSPFParams struct { // `url.Values`. func (r EmailRoutingTimeseriesGroupSPFParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/emailsecuritysummary.go b/radar/emailsecuritysummary.go index c623aca4d3e..d3b67ac5ee8 100644 --- a/radar/emailsecuritysummary.go +++ b/radar/emailsecuritysummary.go @@ -151,9 +151,9 @@ func (r *EmailSecuritySummaryService) TLSVersion(ctx context.Context, query Emai } type EmailSecuritySummaryARCResponse struct { - Meta EmailSecuritySummaryARCResponseMeta `json:"meta,required"` - Summary0 EmailSecuritySummaryARCResponseSummary0 `json:"summary_0,required"` - JSON emailSecuritySummaryARCResponseJSON `json:"-"` + Meta EmailSecuritySummaryARCResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailSecuritySummaryARCResponseJSON `json:"-"` } // emailSecuritySummaryARCResponseJSON contains the JSON metadata for the struct @@ -282,35 +282,10 @@ func (r emailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON return r.raw } -type EmailSecuritySummaryARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailSecuritySummaryARCResponseSummary0JSON `json:"-"` -} - -// emailSecuritySummaryARCResponseSummary0JSON contains the JSON metadata for the -// struct [EmailSecuritySummaryARCResponseSummary0] -type emailSecuritySummaryARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecuritySummaryARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecuritySummaryARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailSecuritySummaryDKIMResponse struct { - Meta EmailSecuritySummaryDKIMResponseMeta `json:"meta,required"` - Summary0 EmailSecuritySummaryDKIMResponseSummary0 `json:"summary_0,required"` - JSON emailSecuritySummaryDKIMResponseJSON `json:"-"` + Meta EmailSecuritySummaryDKIMResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailSecuritySummaryDKIMResponseJSON `json:"-"` } // emailSecuritySummaryDKIMResponseJSON contains the JSON metadata for the struct @@ -439,35 +414,10 @@ func (r emailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON) RawJSO return r.raw } -type EmailSecuritySummaryDKIMResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailSecuritySummaryDKIMResponseSummary0JSON `json:"-"` -} - -// emailSecuritySummaryDKIMResponseSummary0JSON contains the JSON metadata for the -// struct [EmailSecuritySummaryDKIMResponseSummary0] -type emailSecuritySummaryDKIMResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecuritySummaryDKIMResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecuritySummaryDKIMResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailSecuritySummaryDMARCResponse struct { - Meta EmailSecuritySummaryDMARCResponseMeta `json:"meta,required"` - Summary0 EmailSecuritySummaryDMARCResponseSummary0 `json:"summary_0,required"` - JSON emailSecuritySummaryDMARCResponseJSON `json:"-"` + Meta EmailSecuritySummaryDMARCResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailSecuritySummaryDMARCResponseJSON `json:"-"` } // emailSecuritySummaryDMARCResponseJSON contains the JSON metadata for the struct @@ -596,31 +546,6 @@ func (r emailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON) RawJS return r.raw } -type EmailSecuritySummaryDMARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailSecuritySummaryDMARCResponseSummary0JSON `json:"-"` -} - -// emailSecuritySummaryDMARCResponseSummary0JSON contains the JSON metadata for the -// struct [EmailSecuritySummaryDMARCResponseSummary0] -type emailSecuritySummaryDMARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecuritySummaryDMARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecuritySummaryDMARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailSecuritySummaryMaliciousResponse struct { Meta EmailSecuritySummaryMaliciousResponseMeta `json:"meta,required"` Summary0 EmailSecuritySummaryMaliciousResponseSummary0 `json:"summary_0,required"` @@ -933,9 +858,9 @@ func (r emailSecuritySummarySpamResponseSummary0JSON) RawJSON() string { } type EmailSecuritySummarySPFResponse struct { - Meta EmailSecuritySummarySPFResponseMeta `json:"meta,required"` - Summary0 EmailSecuritySummarySPFResponseSummary0 `json:"summary_0,required"` - JSON emailSecuritySummarySPFResponseJSON `json:"-"` + Meta EmailSecuritySummarySPFResponseMeta `json:"meta,required"` + Summary0 RadarEmailSummary `json:"summary_0,required"` + JSON emailSecuritySummarySPFResponseJSON `json:"-"` } // emailSecuritySummarySPFResponseJSON contains the JSON metadata for the struct @@ -1064,31 +989,6 @@ func (r emailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON) RawJSON return r.raw } -type EmailSecuritySummarySPFResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON emailSecuritySummarySPFResponseSummary0JSON `json:"-"` -} - -// emailSecuritySummarySPFResponseSummary0JSON contains the JSON metadata for the -// struct [EmailSecuritySummarySPFResponseSummary0] -type emailSecuritySummarySPFResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecuritySummarySPFResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecuritySummarySPFResponseSummary0JSON) RawJSON() string { - return r.raw -} - type EmailSecuritySummarySpoofResponse struct { Meta EmailSecuritySummarySpoofResponseMeta `json:"meta,required"` Summary0 EmailSecuritySummarySpoofResponseSummary0 `json:"summary_0,required"` @@ -1592,7 +1492,7 @@ type EmailSecuritySummaryARCParams struct { // `url.Values`. func (r EmailSecuritySummaryARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1756,7 +1656,7 @@ type EmailSecuritySummaryDKIMParams struct { // `url.Values`. func (r EmailSecuritySummaryDKIMParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1920,7 +1820,7 @@ type EmailSecuritySummaryDMARCParams struct { // `url.Values`. func (r EmailSecuritySummaryDMARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2086,7 +1986,7 @@ type EmailSecuritySummaryMaliciousParams struct { // `url.Values`. func (r EmailSecuritySummaryMaliciousParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2268,7 +2168,7 @@ type EmailSecuritySummarySpamParams struct { // `url.Values`. func (r EmailSecuritySummarySpamParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2448,7 +2348,7 @@ type EmailSecuritySummarySPFParams struct { // `url.Values`. func (r EmailSecuritySummarySPFParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2614,7 +2514,7 @@ type EmailSecuritySummarySpoofParams struct { // `url.Values`. func (r EmailSecuritySummarySpoofParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2796,7 +2696,7 @@ type EmailSecuritySummaryThreatCategoryParams struct { // parameters as `url.Values`. func (r EmailSecuritySummaryThreatCategoryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2976,7 +2876,7 @@ type EmailSecuritySummaryTLSVersionParams struct { // `url.Values`. func (r EmailSecuritySummaryTLSVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/emailsecuritytimeseriesgroup.go b/radar/emailsecuritytimeseriesgroup.go index dadd3cb7ee8..2aec4252be2 100644 --- a/radar/emailsecuritytimeseriesgroup.go +++ b/radar/emailsecuritytimeseriesgroup.go @@ -151,9 +151,9 @@ func (r *EmailSecurityTimeseriesGroupService) TLSVersion(ctx context.Context, qu } type EmailSecurityTimeseriesGroupARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailSecurityTimeseriesGroupARCResponseSerie0 `json:"serie_0,required"` - JSON emailSecurityTimeseriesGroupARCResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupARCResponseJSON `json:"-"` } // emailSecurityTimeseriesGroupARCResponseJSON contains the JSON metadata for the @@ -173,35 +173,10 @@ func (r emailSecurityTimeseriesGroupARCResponseJSON) RawJSON() string { return r.raw } -type EmailSecurityTimeseriesGroupARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailSecurityTimeseriesGroupARCResponseSerie0JSON `json:"-"` -} - -// emailSecurityTimeseriesGroupARCResponseSerie0JSON contains the JSON metadata for -// the struct [EmailSecurityTimeseriesGroupARCResponseSerie0] -type emailSecurityTimeseriesGroupARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTimeseriesGroupARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTimeseriesGroupARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTimeseriesGroupDKIMResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailSecurityTimeseriesGroupDKIMResponseSerie0 `json:"serie_0,required"` - JSON emailSecurityTimeseriesGroupDKIMResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupDKIMResponseJSON `json:"-"` } // emailSecurityTimeseriesGroupDKIMResponseJSON contains the JSON metadata for the @@ -221,35 +196,10 @@ func (r emailSecurityTimeseriesGroupDKIMResponseJSON) RawJSON() string { return r.raw } -type EmailSecurityTimeseriesGroupDKIMResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailSecurityTimeseriesGroupDKIMResponseSerie0JSON `json:"-"` -} - -// emailSecurityTimeseriesGroupDKIMResponseSerie0JSON contains the JSON metadata -// for the struct [EmailSecurityTimeseriesGroupDKIMResponseSerie0] -type emailSecurityTimeseriesGroupDKIMResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTimeseriesGroupDKIMResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTimeseriesGroupDKIMResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTimeseriesGroupDMARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailSecurityTimeseriesGroupDMARCResponseSerie0 `json:"serie_0,required"` - JSON emailSecurityTimeseriesGroupDMARCResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupDMARCResponseJSON `json:"-"` } // emailSecurityTimeseriesGroupDMARCResponseJSON contains the JSON metadata for the @@ -269,31 +219,6 @@ func (r emailSecurityTimeseriesGroupDMARCResponseJSON) RawJSON() string { return r.raw } -type EmailSecurityTimeseriesGroupDMARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailSecurityTimeseriesGroupDMARCResponseSerie0JSON `json:"-"` -} - -// emailSecurityTimeseriesGroupDMARCResponseSerie0JSON contains the JSON metadata -// for the struct [EmailSecurityTimeseriesGroupDMARCResponseSerie0] -type emailSecurityTimeseriesGroupDMARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTimeseriesGroupDMARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTimeseriesGroupDMARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTimeseriesGroupMaliciousResponse struct { Meta interface{} `json:"meta,required"` Serie0 EmailSecurityTimeseriesGroupMaliciousResponseSerie0 `json:"serie_0,required"` @@ -387,9 +312,9 @@ func (r emailSecurityTimeseriesGroupSpamResponseSerie0JSON) RawJSON() string { } type EmailSecurityTimeseriesGroupSPFResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 EmailSecurityTimeseriesGroupSPFResponseSerie0 `json:"serie_0,required"` - JSON emailSecurityTimeseriesGroupSPFResponseJSON `json:"-"` + Meta interface{} `json:"meta,required"` + Serie0 RadarEmailSeries `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupSPFResponseJSON `json:"-"` } // emailSecurityTimeseriesGroupSPFResponseJSON contains the JSON metadata for the @@ -409,31 +334,6 @@ func (r emailSecurityTimeseriesGroupSPFResponseJSON) RawJSON() string { return r.raw } -type EmailSecurityTimeseriesGroupSPFResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON emailSecurityTimeseriesGroupSPFResponseSerie0JSON `json:"-"` -} - -// emailSecurityTimeseriesGroupSPFResponseSerie0JSON contains the JSON metadata for -// the struct [EmailSecurityTimeseriesGroupSPFResponseSerie0] -type emailSecurityTimeseriesGroupSPFResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTimeseriesGroupSPFResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTimeseriesGroupSPFResponseSerie0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTimeseriesGroupSpoofResponse struct { Meta interface{} `json:"meta,required"` Serie0 EmailSecurityTimeseriesGroupSpoofResponseSerie0 `json:"serie_0,required"` @@ -612,7 +512,7 @@ type EmailSecurityTimeseriesGroupARCParams struct { // as `url.Values`. func (r EmailSecurityTimeseriesGroupARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -800,7 +700,7 @@ type EmailSecurityTimeseriesGroupDKIMParams struct { // as `url.Values`. func (r EmailSecurityTimeseriesGroupDKIMParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -988,7 +888,7 @@ type EmailSecurityTimeseriesGroupDMARCParams struct { // as `url.Values`. func (r EmailSecurityTimeseriesGroupDMARCParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1178,7 +1078,7 @@ type EmailSecurityTimeseriesGroupMaliciousParams struct { // parameters as `url.Values`. func (r EmailSecurityTimeseriesGroupMaliciousParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1384,7 +1284,7 @@ type EmailSecurityTimeseriesGroupSpamParams struct { // as `url.Values`. func (r EmailSecurityTimeseriesGroupSpamParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1588,7 +1488,7 @@ type EmailSecurityTimeseriesGroupSPFParams struct { // as `url.Values`. func (r EmailSecurityTimeseriesGroupSPFParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1778,7 +1678,7 @@ type EmailSecurityTimeseriesGroupSpoofParams struct { // as `url.Values`. func (r EmailSecurityTimeseriesGroupSpoofParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1984,7 +1884,7 @@ type EmailSecurityTimeseriesGroupThreatCategoryParams struct { // parameters as `url.Values`. func (r EmailSecurityTimeseriesGroupThreatCategoryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2189,7 +2089,7 @@ type EmailSecurityTimeseriesGroupTLSVersionParams struct { // parameters as `url.Values`. func (r EmailSecurityTimeseriesGroupTLSVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/emailsecuritytoptld.go b/radar/emailsecuritytoptld.go index 68182a54b06..4fb262ed349 100644 --- a/radar/emailsecuritytoptld.go +++ b/radar/emailsecuritytoptld.go @@ -54,9 +54,9 @@ func (r *EmailSecurityTopTldService) Get(ctx context.Context, query EmailSecurit } type EmailSecurityTopTldGetResponse struct { - Meta EmailSecurityTopTldGetResponseMeta `json:"meta,required"` - Top0 []EmailSecurityTopTldGetResponseTop0 `json:"top_0,required"` - JSON emailSecurityTopTldGetResponseJSON `json:"-"` + Meta EmailSecurityTopTldGetResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON emailSecurityTopTldGetResponseJSON `json:"-"` } // emailSecurityTopTldGetResponseJSON contains the JSON metadata for the struct @@ -183,29 +183,6 @@ func (r emailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON( return r.raw } -type EmailSecurityTopTldGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON emailSecurityTopTldGetResponseTop0JSON `json:"-"` -} - -// emailSecurityTopTldGetResponseTop0JSON contains the JSON metadata for the struct -// [EmailSecurityTopTldGetResponseTop0] -type emailSecurityTopTldGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTopTldGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTopTldGetResponseTop0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTopTldGetParams struct { // Filter for arc (Authenticated Received Chain). ARC param.Field[[]EmailSecurityTopTldGetParamsARC] `query:"arc"` @@ -239,7 +216,7 @@ type EmailSecurityTopTldGetParams struct { // `url.Values`. func (r EmailSecurityTopTldGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/emailsecuritytoptldmalicious.go b/radar/emailsecuritytoptldmalicious.go index fb886804774..177519da6a3 100644 --- a/radar/emailsecuritytoptldmalicious.go +++ b/radar/emailsecuritytoptldmalicious.go @@ -48,9 +48,9 @@ func (r *EmailSecurityTopTldMaliciousService) Get(ctx context.Context, malicious } type EmailSecurityTopTldMaliciousGetResponse struct { - Meta EmailSecurityTopTldMaliciousGetResponseMeta `json:"meta,required"` - Top0 []EmailSecurityTopTldMaliciousGetResponseTop0 `json:"top_0,required"` - JSON emailSecurityTopTldMaliciousGetResponseJSON `json:"-"` + Meta EmailSecurityTopTldMaliciousGetResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON emailSecurityTopTldMaliciousGetResponseJSON `json:"-"` } // emailSecurityTopTldMaliciousGetResponseJSON contains the JSON metadata for the @@ -178,29 +178,6 @@ func (r emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON) return r.raw } -type EmailSecurityTopTldMaliciousGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON emailSecurityTopTldMaliciousGetResponseTop0JSON `json:"-"` -} - -// emailSecurityTopTldMaliciousGetResponseTop0JSON contains the JSON metadata for -// the struct [EmailSecurityTopTldMaliciousGetResponseTop0] -type emailSecurityTopTldMaliciousGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTopTldMaliciousGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTopTldMaliciousGetResponseTop0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTopTldMaliciousGetParams struct { // Filter for arc (Authenticated Received Chain). ARC param.Field[[]EmailSecurityTopTldMaliciousGetParamsARC] `query:"arc"` @@ -234,7 +211,7 @@ type EmailSecurityTopTldMaliciousGetParams struct { // as `url.Values`. func (r EmailSecurityTopTldMaliciousGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/emailsecuritytoptldspam.go b/radar/emailsecuritytoptldspam.go index 5d1a711c706..e64f14a8f89 100644 --- a/radar/emailsecuritytoptldspam.go +++ b/radar/emailsecuritytoptldspam.go @@ -48,9 +48,9 @@ func (r *EmailSecurityTopTldSpamService) Get(ctx context.Context, spam EmailSecu } type EmailSecurityTopTldSpamGetResponse struct { - Meta EmailSecurityTopTldSpamGetResponseMeta `json:"meta,required"` - Top0 []EmailSecurityTopTldSpamGetResponseTop0 `json:"top_0,required"` - JSON emailSecurityTopTldSpamGetResponseJSON `json:"-"` + Meta EmailSecurityTopTldSpamGetResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON emailSecurityTopTldSpamGetResponseJSON `json:"-"` } // emailSecurityTopTldSpamGetResponseJSON contains the JSON metadata for the struct @@ -177,29 +177,6 @@ func (r emailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON) RawJ return r.raw } -type EmailSecurityTopTldSpamGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON emailSecurityTopTldSpamGetResponseTop0JSON `json:"-"` -} - -// emailSecurityTopTldSpamGetResponseTop0JSON contains the JSON metadata for the -// struct [EmailSecurityTopTldSpamGetResponseTop0] -type emailSecurityTopTldSpamGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTopTldSpamGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTopTldSpamGetResponseTop0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTopTldSpamGetParams struct { // Filter for arc (Authenticated Received Chain). ARC param.Field[[]EmailSecurityTopTldSpamGetParamsARC] `query:"arc"` @@ -233,7 +210,7 @@ type EmailSecurityTopTldSpamGetParams struct { // `url.Values`. func (r EmailSecurityTopTldSpamGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/emailsecuritytoptldspoof.go b/radar/emailsecuritytoptldspoof.go index 77a3c3ff8a1..3aad0812c6c 100644 --- a/radar/emailsecuritytoptldspoof.go +++ b/radar/emailsecuritytoptldspoof.go @@ -48,9 +48,9 @@ func (r *EmailSecurityTopTldSpoofService) Get(ctx context.Context, spoof EmailSe } type EmailSecurityTopTldSpoofGetResponse struct { - Meta EmailSecurityTopTldSpoofGetResponseMeta `json:"meta,required"` - Top0 []EmailSecurityTopTldSpoofGetResponseTop0 `json:"top_0,required"` - JSON emailSecurityTopTldSpoofGetResponseJSON `json:"-"` + Meta EmailSecurityTopTldSpoofGetResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON emailSecurityTopTldSpoofGetResponseJSON `json:"-"` } // emailSecurityTopTldSpoofGetResponseJSON contains the JSON metadata for the @@ -177,29 +177,6 @@ func (r emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON) Raw return r.raw } -type EmailSecurityTopTldSpoofGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON emailSecurityTopTldSpoofGetResponseTop0JSON `json:"-"` -} - -// emailSecurityTopTldSpoofGetResponseTop0JSON contains the JSON metadata for the -// struct [EmailSecurityTopTldSpoofGetResponseTop0] -type emailSecurityTopTldSpoofGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailSecurityTopTldSpoofGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailSecurityTopTldSpoofGetResponseTop0JSON) RawJSON() string { - return r.raw -} - type EmailSecurityTopTldSpoofGetParams struct { // Filter for arc (Authenticated Received Chain). ARC param.Field[[]EmailSecurityTopTldSpoofGetParamsARC] `query:"arc"` @@ -233,7 +210,7 @@ type EmailSecurityTopTldSpoofGetParams struct { // `url.Values`. func (r EmailSecurityTopTldSpoofGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/entity.go b/radar/entity.go index 11455f351fd..b0b841f3151 100644 --- a/radar/entity.go +++ b/radar/entity.go @@ -114,7 +114,7 @@ type EntityGetParams struct { // URLQuery serializes [EntityGetParams]'s query parameters as `url.Values`. func (r EntityGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/entityasn.go b/radar/entityasn.go index 3a7dab4c267..94ee32cca0f 100644 --- a/radar/entityasn.go +++ b/radar/entityasn.go @@ -530,7 +530,7 @@ type EntityASNListParams struct { // URLQuery serializes [EntityASNListParams]'s query parameters as `url.Values`. func (r EntityASNListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -598,7 +598,7 @@ type EntityASNGetParams struct { // URLQuery serializes [EntityASNGetParams]'s query parameters as `url.Values`. func (r EntityASNGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -652,7 +652,7 @@ type EntityASNIPParams struct { // URLQuery serializes [EntityASNIPParams]'s query parameters as `url.Values`. func (r EntityASNIPParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -706,7 +706,7 @@ type EntityASNRelParams struct { // URLQuery serializes [EntityASNRelParams]'s query parameters as `url.Values`. func (r EntityASNRelParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/entitylocation.go b/radar/entitylocation.go index a1000413240..175f8a1bb18 100644 --- a/radar/entitylocation.go +++ b/radar/entitylocation.go @@ -178,7 +178,7 @@ type EntityLocationListParams struct { // `url.Values`. func (r EntityLocationListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -231,7 +231,7 @@ type EntityLocationGetParams struct { // `url.Values`. func (r EntityLocationGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpase.go b/radar/httpase.go index 802004bb6d4..9e00f8066da 100644 --- a/radar/httpase.go +++ b/radar/httpase.go @@ -261,7 +261,7 @@ type HTTPAseGetParams struct { // URLQuery serializes [HTTPAseGetParams]'s query parameters as `url.Values`. func (r HTTPAseGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpasebotclass.go b/radar/httpasebotclass.go index 272b0d417b9..b440603bcbf 100644 --- a/radar/httpasebotclass.go +++ b/radar/httpasebotclass.go @@ -249,7 +249,7 @@ type HTTPAseBotClassGetParams struct { // `url.Values`. func (r HTTPAseBotClassGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpasedevicetype.go b/radar/httpasedevicetype.go index 175b9100af5..695486a7f56 100644 --- a/radar/httpasedevicetype.go +++ b/radar/httpasedevicetype.go @@ -249,7 +249,7 @@ type HTTPAseDeviceTypeGetParams struct { // `url.Values`. func (r HTTPAseDeviceTypeGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpasehttpmethod.go b/radar/httpasehttpmethod.go index b39534dec13..fd14f8583d3 100644 --- a/radar/httpasehttpmethod.go +++ b/radar/httpasehttpmethod.go @@ -249,7 +249,7 @@ type HTTPAseHTTPMethodGetParams struct { // `url.Values`. func (r HTTPAseHTTPMethodGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpasehttpprotocol.go b/radar/httpasehttpprotocol.go index 467ec6c287a..93edc4403cf 100644 --- a/radar/httpasehttpprotocol.go +++ b/radar/httpasehttpprotocol.go @@ -247,7 +247,7 @@ type HTTPAseHTTPProtocolGetParams struct { // `url.Values`. func (r HTTPAseHTTPProtocolGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpaseipversion.go b/radar/httpaseipversion.go index 0242a246e0a..b68d5f5a91a 100644 --- a/radar/httpaseipversion.go +++ b/radar/httpaseipversion.go @@ -249,7 +249,7 @@ type HTTPAseIPVersionGetParams struct { // `url.Values`. func (r HTTPAseIPVersionGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpaseos.go b/radar/httpaseos.go index 8893d6bde36..ac10a660f32 100644 --- a/radar/httpaseos.go +++ b/radar/httpaseos.go @@ -246,7 +246,7 @@ type HTTPAseOSGetParams struct { // URLQuery serializes [HTTPAseOSGetParams]'s query parameters as `url.Values`. func (r HTTPAseOSGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpasetlsversion.go b/radar/httpasetlsversion.go index b15826f74de..d3493f585e3 100644 --- a/radar/httpasetlsversion.go +++ b/radar/httpasetlsversion.go @@ -249,7 +249,7 @@ type HTTPAseTLSVersionGetParams struct { // `url.Values`. func (r HTTPAseTLSVersionGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocation.go b/radar/httplocation.go index 21e1f90b3ea..3d961c23941 100644 --- a/radar/httplocation.go +++ b/radar/httplocation.go @@ -262,7 +262,7 @@ type HTTPLocationGetParams struct { // URLQuery serializes [HTTPLocationGetParams]'s query parameters as `url.Values`. func (r HTTPLocationGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocationbotclass.go b/radar/httplocationbotclass.go index 37e0a8df6f0..c06c7981f7e 100644 --- a/radar/httplocationbotclass.go +++ b/radar/httplocationbotclass.go @@ -250,7 +250,7 @@ type HTTPLocationBotClassGetParams struct { // `url.Values`. func (r HTTPLocationBotClassGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocationdevicetype.go b/radar/httplocationdevicetype.go index 63ba0e96002..94f124d91aa 100644 --- a/radar/httplocationdevicetype.go +++ b/radar/httplocationdevicetype.go @@ -249,7 +249,7 @@ type HTTPLocationDeviceTypeGetParams struct { // `url.Values`. func (r HTTPLocationDeviceTypeGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocationhttpmethod.go b/radar/httplocationhttpmethod.go index aaa6d21ea6f..7f40bb1b4ca 100644 --- a/radar/httplocationhttpmethod.go +++ b/radar/httplocationhttpmethod.go @@ -249,7 +249,7 @@ type HTTPLocationHTTPMethodGetParams struct { // `url.Values`. func (r HTTPLocationHTTPMethodGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocationhttpprotocol.go b/radar/httplocationhttpprotocol.go index 79aa4cecdbf..9a06f1e412d 100644 --- a/radar/httplocationhttpprotocol.go +++ b/radar/httplocationhttpprotocol.go @@ -247,7 +247,7 @@ type HTTPLocationHTTPProtocolGetParams struct { // `url.Values`. func (r HTTPLocationHTTPProtocolGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocationipversion.go b/radar/httplocationipversion.go index 31ea74ba7df..e8167dc0d9a 100644 --- a/radar/httplocationipversion.go +++ b/radar/httplocationipversion.go @@ -249,7 +249,7 @@ type HTTPLocationIPVersionGetParams struct { // `url.Values`. func (r HTTPLocationIPVersionGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocationos.go b/radar/httplocationos.go index fc128514442..baa68ac8a74 100644 --- a/radar/httplocationos.go +++ b/radar/httplocationos.go @@ -248,7 +248,7 @@ type HTTPLocationOSGetParams struct { // `url.Values`. func (r HTTPLocationOSGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httplocationtlsversion.go b/radar/httplocationtlsversion.go index 47b405f87d1..84c2022b587 100644 --- a/radar/httplocationtlsversion.go +++ b/radar/httplocationtlsversion.go @@ -249,7 +249,7 @@ type HTTPLocationTLSVersionGetParams struct { // `url.Values`. func (r HTTPLocationTLSVersionGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httpsummary.go b/radar/httpsummary.go index e5e87af93de..58606b03641 100644 --- a/radar/httpsummary.go +++ b/radar/httpsummary.go @@ -1269,7 +1269,7 @@ type HTTPSummaryBotClassParams struct { // `url.Values`. func (r HTTPSummaryBotClassParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1485,7 +1485,7 @@ type HTTPSummaryDeviceTypeParams struct { // `url.Values`. func (r HTTPSummaryDeviceTypeParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1700,7 +1700,7 @@ type HTTPSummaryHTTPProtocolParams struct { // `url.Values`. func (r HTTPSummaryHTTPProtocolParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1916,7 +1916,7 @@ type HTTPSummaryHTTPVersionParams struct { // `url.Values`. func (r HTTPSummaryHTTPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2131,7 +2131,7 @@ type HTTPSummaryIPVersionParams struct { // `url.Values`. func (r HTTPSummaryIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2346,7 +2346,7 @@ type HTTPSummaryOSParams struct { // URLQuery serializes [HTTPSummaryOSParams]'s query parameters as `url.Values`. func (r HTTPSummaryOSParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2557,7 +2557,7 @@ type HTTPSummaryTLSVersionParams struct { // `url.Values`. func (r HTTPSummaryTLSVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httptimeseriesgroup.go b/radar/httptimeseriesgroup.go index 9b16be81693..07dd6fac170 100644 --- a/radar/httptimeseriesgroup.go +++ b/radar/httptimeseriesgroup.go @@ -639,7 +639,7 @@ type HTTPTimeseriesGroupBotClassParams struct { // `url.Values`. func (r HTTPTimeseriesGroupBotClassParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -884,7 +884,7 @@ type HTTPTimeseriesGroupBrowserParams struct { // `url.Values`. func (r HTTPTimeseriesGroupBrowserParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1141,7 +1141,7 @@ type HTTPTimeseriesGroupBrowserFamilyParams struct { // as `url.Values`. func (r HTTPTimeseriesGroupBrowserFamilyParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1396,7 +1396,7 @@ type HTTPTimeseriesGroupDeviceTypeParams struct { // `url.Values`. func (r HTTPTimeseriesGroupDeviceTypeParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1635,7 +1635,7 @@ type HTTPTimeseriesGroupHTTPProtocolParams struct { // as `url.Values`. func (r HTTPTimeseriesGroupHTTPProtocolParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1875,7 +1875,7 @@ type HTTPTimeseriesGroupHTTPVersionParams struct { // `url.Values`. func (r HTTPTimeseriesGroupHTTPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2114,7 +2114,7 @@ type HTTPTimeseriesGroupIPVersionParams struct { // `url.Values`. func (r HTTPTimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2354,7 +2354,7 @@ type HTTPTimeseriesGroupOSParams struct { // `url.Values`. func (r HTTPTimeseriesGroupOSParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -2589,7 +2589,7 @@ type HTTPTimeseriesGroupTLSVersionParams struct { // `url.Values`. func (r HTTPTimeseriesGroupTLSVersionParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/httptop.go b/radar/httptop.go index 67365d799cf..d9b6cfd019c 100644 --- a/radar/httptop.go +++ b/radar/httptop.go @@ -60,10 +60,32 @@ func (r *HTTPTopService) Browsers(ctx context.Context, query HTTPTopBrowsersPara return } +type Browser struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON browserJSON `json:"-"` +} + +// browserJSON contains the JSON metadata for the struct [Browser] +type browserJSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Browser) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r browserJSON) RawJSON() string { + return r.raw +} + type HTTPTopBrowserFamiliesResponse struct { - Meta HTTPTopBrowserFamiliesResponseMeta `json:"meta,required"` - Top0 []HTTPTopBrowserFamiliesResponseTop0 `json:"top_0,required"` - JSON httpTopBrowserFamiliesResponseJSON `json:"-"` + Meta HTTPTopBrowserFamiliesResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON httpTopBrowserFamiliesResponseJSON `json:"-"` } // httpTopBrowserFamiliesResponseJSON contains the JSON metadata for the struct @@ -190,33 +212,10 @@ func (r httpTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON) RawJSON( return r.raw } -type HTTPTopBrowserFamiliesResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON httpTopBrowserFamiliesResponseTop0JSON `json:"-"` -} - -// httpTopBrowserFamiliesResponseTop0JSON contains the JSON metadata for the struct -// [HTTPTopBrowserFamiliesResponseTop0] -type httpTopBrowserFamiliesResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HTTPTopBrowserFamiliesResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r httpTopBrowserFamiliesResponseTop0JSON) RawJSON() string { - return r.raw -} - type HTTPTopBrowsersResponse struct { - Meta HTTPTopBrowsersResponseMeta `json:"meta,required"` - Top0 []HTTPTopBrowsersResponseTop0 `json:"top_0,required"` - JSON httpTopBrowsersResponseJSON `json:"-"` + Meta HTTPTopBrowsersResponseMeta `json:"meta,required"` + Top0 []Browser `json:"top_0,required"` + JSON httpTopBrowsersResponseJSON `json:"-"` } // httpTopBrowsersResponseJSON contains the JSON metadata for the struct @@ -342,29 +341,6 @@ func (r httpTopBrowsersResponseMetaConfidenceInfoAnnotationJSON) RawJSON() strin return r.raw } -type HTTPTopBrowsersResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON httpTopBrowsersResponseTop0JSON `json:"-"` -} - -// httpTopBrowsersResponseTop0JSON contains the JSON metadata for the struct -// [HTTPTopBrowsersResponseTop0] -type httpTopBrowsersResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HTTPTopBrowsersResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r httpTopBrowsersResponseTop0JSON) RawJSON() string { - return r.raw -} - type HTTPTopBrowserFamiliesParams struct { // Array of comma separated list of ASNs, start with `-` to exclude from results. // For example, `-174, 3356` excludes results from AS174, but includes results from @@ -413,7 +389,7 @@ type HTTPTopBrowserFamiliesParams struct { // `url.Values`. func (r HTTPTopBrowserFamiliesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -647,7 +623,7 @@ type HTTPTopBrowsersParams struct { // URLQuery serializes [HTTPTopBrowsersParams]'s query parameters as `url.Values`. func (r HTTPTopBrowsersParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/netflow.go b/radar/netflow.go index f10001d6c98..eb27857499c 100644 --- a/radar/netflow.go +++ b/radar/netflow.go @@ -242,7 +242,7 @@ type NetflowTimeseriesParams struct { // `url.Values`. func (r NetflowTimeseriesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/netflowtop.go b/radar/netflowtop.go index 06190a3cdcb..a41ded64044 100644 --- a/radar/netflowtop.go +++ b/radar/netflowtop.go @@ -184,7 +184,7 @@ type NetflowTopAsesParams struct { // URLQuery serializes [NetflowTopAsesParams]'s query parameters as `url.Values`. func (r NetflowTopAsesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -289,7 +289,7 @@ type NetflowTopLocationsParams struct { // `url.Values`. func (r NetflowTopLocationsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/qualityiqi.go b/radar/qualityiqi.go index d9d09dfb045..64c77ed800e 100644 --- a/radar/qualityiqi.go +++ b/radar/qualityiqi.go @@ -299,7 +299,7 @@ type QualityIQISummaryParams struct { // `url.Values`. func (r QualityIQISummaryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -427,7 +427,7 @@ type QualityIQITimeseriesGroupsParams struct { // `url.Values`. func (r QualityIQITimeseriesGroupsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/qualityspeed.go b/radar/qualityspeed.go index 44ccc48dbd1..03eb578a6e8 100644 --- a/radar/qualityspeed.go +++ b/radar/qualityspeed.go @@ -305,7 +305,7 @@ type QualitySpeedHistogramParams struct { // `url.Values`. func (r QualitySpeedHistogramParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -391,7 +391,7 @@ type QualitySpeedSummaryParams struct { // `url.Values`. func (r QualitySpeedSummaryParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/qualityspeedtop.go b/radar/qualityspeedtop.go index ebd4c4155eb..1b1649ce9bc 100644 --- a/radar/qualityspeedtop.go +++ b/radar/qualityspeedtop.go @@ -430,7 +430,7 @@ type QualitySpeedTopAsesParams struct { // `url.Values`. func (r QualitySpeedTopAsesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -525,7 +525,7 @@ type QualitySpeedTopLocationsParams struct { // `url.Values`. func (r QualitySpeedTopLocationsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/ranking.go b/radar/ranking.go index b4acce7e1fb..d86a9cb4874 100644 --- a/radar/ranking.go +++ b/radar/ranking.go @@ -6,13 +6,16 @@ import ( "context" "net/http" "net/url" + "reflect" "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) // RankingService contains methods and other services that help with interacting @@ -133,9 +136,9 @@ func (r rankingTimeseriesGroupsResponseMetaDateRangeJSON) RawJSON() string { } type RankingTimeseriesGroupsResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]RankingTimeseriesGroupsResponseSerie0 `json:"-,extras"` - JSON rankingTimeseriesGroupsResponseSerie0JSON `json:"-"` + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]RankingTimeseriesGroupsResponseSerie0Union `json:"-,extras"` + JSON rankingTimeseriesGroupsResponseSerie0JSON `json:"-"` } // rankingTimeseriesGroupsResponseSerie0JSON contains the JSON metadata for the @@ -154,6 +157,26 @@ func (r rankingTimeseriesGroupsResponseSerie0JSON) RawJSON() string { return r.raw } +// Union satisfied by [shared.UnionString] or [shared.UnionFloat]. +type RankingTimeseriesGroupsResponseSerie0Union interface { + ImplementsRadarRankingTimeseriesGroupsResponseSerie0Union() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RankingTimeseriesGroupsResponseSerie0Union)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + ) +} + type RankingTopResponse struct { Meta RankingTopResponseMeta `json:"meta,required"` Top0 []RankingTopResponseTop0 `json:"top_0,required"` @@ -299,7 +322,7 @@ type RankingTimeseriesGroupsParams struct { // `url.Values`. func (r RankingTimeseriesGroupsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -406,7 +429,7 @@ type RankingTopParams struct { // URLQuery serializes [RankingTopParams]'s query parameters as `url.Values`. func (r RankingTopParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/rankingdomain.go b/radar/rankingdomain.go index fa9b89e11f7..ecee980692d 100644 --- a/radar/rankingdomain.go +++ b/radar/rankingdomain.go @@ -164,7 +164,7 @@ type RankingDomainGetParams struct { // URLQuery serializes [RankingDomainGetParams]'s query parameters as `url.Values`. func (r RankingDomainGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/search.go b/radar/search.go index e5296044929..96cf7717cb4 100644 --- a/radar/search.go +++ b/radar/search.go @@ -108,7 +108,7 @@ type SearchGlobalParams struct { // URLQuery serializes [SearchGlobalParams]'s query parameters as `url.Values`. func (r SearchGlobalParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/trafficanomaly.go b/radar/trafficanomaly.go index f3d2bd26b2c..0171cdef55b 100644 --- a/radar/trafficanomaly.go +++ b/radar/trafficanomaly.go @@ -204,7 +204,7 @@ type TrafficAnomalyGetParams struct { // `url.Values`. func (r TrafficAnomalyGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/trafficanomalylocation.go b/radar/trafficanomalylocation.go index c80df4c79b0..8f262be51ae 100644 --- a/radar/trafficanomalylocation.go +++ b/radar/trafficanomalylocation.go @@ -113,7 +113,7 @@ type TrafficAnomalyLocationGetParams struct { // `url.Values`. func (r TrafficAnomalyLocationGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/radar/verifiedbottop.go b/radar/verifiedbottop.go index 13f9e158270..0d5e1897c3d 100644 --- a/radar/verifiedbottop.go +++ b/radar/verifiedbottop.go @@ -398,7 +398,7 @@ type VerifiedBotTopBotsParams struct { // `url.Values`. func (r VerifiedBotTopBotsParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -503,7 +503,7 @@ type VerifiedBotTopCategoriesParams struct { // `url.Values`. func (r VerifiedBotTopCategoriesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/rate_limits/aliases.go b/rate_limits/aliases.go index c72f1132d15..39387f63b95 100644 --- a/rate_limits/aliases.go +++ b/rate_limits/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/rate_limits/ratelimit.go b/rate_limits/ratelimit.go index 418a6b13831..4e8b4936a65 100644 --- a/rate_limits/ratelimit.go +++ b/rate_limits/ratelimit.go @@ -38,7 +38,7 @@ func NewRateLimitService(opts ...option.RequestOption) (r *RateLimitService) { // Creates a new rate limit for a zone. Refer to the object definition for a list // of required attributes. -func (r *RateLimitService) New(ctx context.Context, zoneIdentifier string, body RateLimitNewParams, opts ...option.RequestOption) (res *RateLimitNewResponse, err error) { +func (r *RateLimitService) New(ctx context.Context, zoneIdentifier string, body RateLimitNewParams, opts ...option.RequestOption) (res *RateLimitNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RateLimitNewResponseEnvelope path := fmt.Sprintf("zones/%s/rate_limits", zoneIdentifier) @@ -51,7 +51,7 @@ func (r *RateLimitService) New(ctx context.Context, zoneIdentifier string, body } // Fetches the rate limits for a zone. -func (r *RateLimitService) List(ctx context.Context, zoneIdentifier string, query RateLimitListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[RateLimitListResponse], err error) { +func (r *RateLimitService) List(ctx context.Context, zoneIdentifier string, query RateLimitListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[RateLimit], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -69,12 +69,12 @@ func (r *RateLimitService) List(ctx context.Context, zoneIdentifier string, quer } // Fetches the rate limits for a zone. -func (r *RateLimitService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RateLimitListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[RateLimitListResponse] { +func (r *RateLimitService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RateLimitListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[RateLimit] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) } // Deletes an existing rate limit. -func (r *RateLimitService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *RateLimitDeleteResponse, err error) { +func (r *RateLimitService) Delete(ctx context.Context, zoneIdentifier string, id string, body RateLimitDeleteParams, opts ...option.RequestOption) (res *RateLimitDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env RateLimitDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/rate_limits/%s", zoneIdentifier, id) @@ -87,7 +87,7 @@ func (r *RateLimitService) Delete(ctx context.Context, zoneIdentifier string, id } // Updates an existing rate limit. -func (r *RateLimitService) Edit(ctx context.Context, zoneIdentifier string, id string, body RateLimitEditParams, opts ...option.RequestOption) (res *RateLimitEditResponse, err error) { +func (r *RateLimitService) Edit(ctx context.Context, zoneIdentifier string, id string, body RateLimitEditParams, opts ...option.RequestOption) (res *RateLimitEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RateLimitEditResponseEnvelope path := fmt.Sprintf("zones/%s/rate_limits/%s", zoneIdentifier, id) @@ -100,7 +100,7 @@ func (r *RateLimitService) Edit(ctx context.Context, zoneIdentifier string, id s } // Fetches the details of a rate limit. -func (r *RateLimitService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *RateLimitGetResponse, err error) { +func (r *RateLimitService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *RateLimitGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env RateLimitGetResponseEnvelope path := fmt.Sprintf("zones/%s/rate_limits/%s", zoneIdentifier, id) @@ -112,52 +112,77 @@ func (r *RateLimitService) Get(ctx context.Context, zoneIdentifier string, id st return } -// Union satisfied by [rate_limits.RateLimitNewResponseUnknown] or -// [shared.UnionString]. -type RateLimitNewResponse interface { - ImplementsRateLimitsRateLimitNewResponse() +// The action to apply to a matched request. The `log` action is only available on +// an Enterprise plan. +type Action string + +const ( + ActionBlock Action = "block" + ActionChallenge Action = "challenge" + ActionJSChallenge Action = "js_challenge" + ActionManagedChallenge Action = "managed_challenge" + ActionAllow Action = "allow" + ActionLog Action = "log" + ActionBypass Action = "bypass" +) + +func (r Action) IsKnown() bool { + switch r { + case ActionBlock, ActionChallenge, ActionJSChallenge, ActionManagedChallenge, ActionAllow, ActionLog, ActionBypass: + return true + } + return false } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RateLimitNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) +// An HTTP method or `_ALL_` to indicate all methods. +type Methods string + +const ( + MethodsGet Methods = "GET" + MethodsPost Methods = "POST" + MethodsPut Methods = "PUT" + MethodsDelete Methods = "DELETE" + MethodsPatch Methods = "PATCH" + MethodsHead Methods = "HEAD" + Methods_All Methods = "_ALL_" +) + +func (r Methods) IsKnown() bool { + switch r { + case MethodsGet, MethodsPost, MethodsPut, MethodsDelete, MethodsPatch, MethodsHead, Methods_All: + return true + } + return false } -type RateLimitListResponse struct { +type RateLimit struct { // The unique identifier of the rate limit. ID string `json:"id"` // The action to perform when the threshold of matched traffic within the // configured period is exceeded. - Action RateLimitListResponseAction `json:"action"` + Action RateLimitAction `json:"action"` // Criteria specifying when the current rate limit should be bypassed. You can // specify that the rate limit should not apply to one or more URLs. - Bypass []RateLimitListResponseBypass `json:"bypass"` + Bypass []RateLimitBypass `json:"bypass"` // An informative summary of the rate limit. This value is sanitized and any tags // will be removed. Description string `json:"description"` // When true, indicates that the rate limit is currently disabled. Disabled bool `json:"disabled"` // Determines which traffic the rate limit counts towards the threshold. - Match RateLimitListResponseMatch `json:"match"` + Match RateLimitMatch `json:"match"` // The time in seconds (an integer value) to count matching traffic. If the count // exceeds the configured threshold within this period, Cloudflare will perform the // configured action. Period float64 `json:"period"` // The threshold that will trigger the configured mitigation action. Configure this // value along with the `period` property to establish a threshold per period. - Threshold float64 `json:"threshold"` - JSON rateLimitListResponseJSON `json:"-"` + Threshold float64 `json:"threshold"` + JSON rateLimitJSON `json:"-"` } -// rateLimitListResponseJSON contains the JSON metadata for the struct -// [RateLimitListResponse] -type rateLimitListResponseJSON struct { +// rateLimitJSON contains the JSON metadata for the struct [RateLimit] +type rateLimitJSON struct { ID apijson.Field Action apijson.Field Bypass apijson.Field @@ -170,37 +195,36 @@ type rateLimitListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimit) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseJSON) RawJSON() string { +func (r rateLimitJSON) RawJSON() string { return r.raw } // The action to perform when the threshold of matched traffic within the // configured period is exceeded. -type RateLimitListResponseAction struct { +type RateLimitAction struct { // The action to perform. - Mode RateLimitListResponseActionMode `json:"mode"` + Mode RateLimitActionMode `json:"mode"` // A custom content type and reponse to return when the threshold is exceeded. The // custom response configured in this object will override the custom error for the // zone. This object is optional. Notes: If you omit this object, Cloudflare will // use the default HTML error page. If "mode" is "challenge", "managed_challenge", // or "js_challenge", Cloudflare will use the zone challenge pages and you should // not provide the "response" object. - Response RateLimitListResponseActionResponse `json:"response"` + Response RateLimitActionResponse `json:"response"` // The time in seconds during which Cloudflare will perform the mitigation action. // Must be an integer value greater than or equal to the period. Notes: If "mode" // is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the // zone's Challenge Passage time and you should not provide this value. - Timeout float64 `json:"timeout"` - JSON rateLimitListResponseActionJSON `json:"-"` + Timeout float64 `json:"timeout"` + JSON rateLimitActionJSON `json:"-"` } -// rateLimitListResponseActionJSON contains the JSON metadata for the struct -// [RateLimitListResponseAction] -type rateLimitListResponseActionJSON struct { +// rateLimitActionJSON contains the JSON metadata for the struct [RateLimitAction] +type rateLimitActionJSON struct { Mode apijson.Field Response apijson.Field Timeout apijson.Field @@ -208,28 +232,28 @@ type rateLimitListResponseActionJSON struct { ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponseAction) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimitAction) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseActionJSON) RawJSON() string { +func (r rateLimitActionJSON) RawJSON() string { return r.raw } // The action to perform. -type RateLimitListResponseActionMode string +type RateLimitActionMode string const ( - RateLimitListResponseActionModeSimulate RateLimitListResponseActionMode = "simulate" - RateLimitListResponseActionModeBan RateLimitListResponseActionMode = "ban" - RateLimitListResponseActionModeChallenge RateLimitListResponseActionMode = "challenge" - RateLimitListResponseActionModeJsChallenge RateLimitListResponseActionMode = "js_challenge" - RateLimitListResponseActionModeManagedChallenge RateLimitListResponseActionMode = "managed_challenge" + RateLimitActionModeSimulate RateLimitActionMode = "simulate" + RateLimitActionModeBan RateLimitActionMode = "ban" + RateLimitActionModeChallenge RateLimitActionMode = "challenge" + RateLimitActionModeJSChallenge RateLimitActionMode = "js_challenge" + RateLimitActionModeManagedChallenge RateLimitActionMode = "managed_challenge" ) -func (r RateLimitListResponseActionMode) IsKnown() bool { +func (r RateLimitActionMode) IsKnown() bool { switch r { - case RateLimitListResponseActionModeSimulate, RateLimitListResponseActionModeBan, RateLimitListResponseActionModeChallenge, RateLimitListResponseActionModeJsChallenge, RateLimitListResponseActionModeManagedChallenge: + case RateLimitActionModeSimulate, RateLimitActionModeBan, RateLimitActionModeChallenge, RateLimitActionModeJSChallenge, RateLimitActionModeManagedChallenge: return true } return false @@ -241,82 +265,80 @@ func (r RateLimitListResponseActionMode) IsKnown() bool { // use the default HTML error page. If "mode" is "challenge", "managed_challenge", // or "js_challenge", Cloudflare will use the zone challenge pages and you should // not provide the "response" object. -type RateLimitListResponseActionResponse struct { +type RateLimitActionResponse struct { // The response body to return. The value must conform to the configured content // type. Body string `json:"body"` // The content type of the body. Must be one of the following: `text/plain`, // `text/xml`, or `application/json`. - ContentType string `json:"content_type"` - JSON rateLimitListResponseActionResponseJSON `json:"-"` + ContentType string `json:"content_type"` + JSON rateLimitActionResponseJSON `json:"-"` } -// rateLimitListResponseActionResponseJSON contains the JSON metadata for the -// struct [RateLimitListResponseActionResponse] -type rateLimitListResponseActionResponseJSON struct { +// rateLimitActionResponseJSON contains the JSON metadata for the struct +// [RateLimitActionResponse] +type rateLimitActionResponseJSON struct { Body apijson.Field ContentType apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponseActionResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimitActionResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseActionResponseJSON) RawJSON() string { +func (r rateLimitActionResponseJSON) RawJSON() string { return r.raw } -type RateLimitListResponseBypass struct { - Name RateLimitListResponseBypassName `json:"name"` +type RateLimitBypass struct { + Name RateLimitBypassName `json:"name"` // The URL to bypass. - Value string `json:"value"` - JSON rateLimitListResponseBypassJSON `json:"-"` + Value string `json:"value"` + JSON rateLimitBypassJSON `json:"-"` } -// rateLimitListResponseBypassJSON contains the JSON metadata for the struct -// [RateLimitListResponseBypass] -type rateLimitListResponseBypassJSON struct { +// rateLimitBypassJSON contains the JSON metadata for the struct [RateLimitBypass] +type rateLimitBypassJSON struct { Name apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponseBypass) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimitBypass) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseBypassJSON) RawJSON() string { +func (r rateLimitBypassJSON) RawJSON() string { return r.raw } -type RateLimitListResponseBypassName string +type RateLimitBypassName string const ( - RateLimitListResponseBypassNameURL RateLimitListResponseBypassName = "url" + RateLimitBypassNameURL RateLimitBypassName = "url" ) -func (r RateLimitListResponseBypassName) IsKnown() bool { +func (r RateLimitBypassName) IsKnown() bool { switch r { - case RateLimitListResponseBypassNameURL: + case RateLimitBypassNameURL: return true } return false } // Determines which traffic the rate limit counts towards the threshold. -type RateLimitListResponseMatch struct { - Headers []RateLimitListResponseMatchHeader `json:"headers"` - Request RateLimitListResponseMatchRequest `json:"request"` - Response RateLimitListResponseMatchResponse `json:"response"` - JSON rateLimitListResponseMatchJSON `json:"-"` +type RateLimitMatch struct { + Headers []RateLimitMatchHeader `json:"headers"` + Request RateLimitMatchRequest `json:"request"` + Response RateLimitMatchResponse `json:"response"` + JSON rateLimitMatchJSON `json:"-"` } -// rateLimitListResponseMatchJSON contains the JSON metadata for the struct -// [RateLimitListResponseMatch] -type rateLimitListResponseMatchJSON struct { +// rateLimitMatchJSON contains the JSON metadata for the struct [RateLimitMatch] +type rateLimitMatchJSON struct { Headers apijson.Field Request apijson.Field Response apijson.Field @@ -324,27 +346,27 @@ type rateLimitListResponseMatchJSON struct { ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponseMatch) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimitMatch) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseMatchJSON) RawJSON() string { +func (r rateLimitMatchJSON) RawJSON() string { return r.raw } -type RateLimitListResponseMatchHeader struct { +type RateLimitMatchHeader struct { // The name of the response header to match. Name string `json:"name"` // The operator used when matching: `eq` means "equal" and `ne` means "not equal". - Op RateLimitListResponseMatchHeadersOp `json:"op"` + Op RateLimitMatchHeadersOp `json:"op"` // The value of the response header, which must match exactly. - Value string `json:"value"` - JSON rateLimitListResponseMatchHeaderJSON `json:"-"` + Value string `json:"value"` + JSON rateLimitMatchHeaderJSON `json:"-"` } -// rateLimitListResponseMatchHeaderJSON contains the JSON metadata for the struct -// [RateLimitListResponseMatchHeader] -type rateLimitListResponseMatchHeaderJSON struct { +// rateLimitMatchHeaderJSON contains the JSON metadata for the struct +// [RateLimitMatchHeader] +type rateLimitMatchHeaderJSON struct { Name apijson.Field Op apijson.Field Value apijson.Field @@ -352,35 +374,35 @@ type rateLimitListResponseMatchHeaderJSON struct { ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponseMatchHeader) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimitMatchHeader) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseMatchHeaderJSON) RawJSON() string { +func (r rateLimitMatchHeaderJSON) RawJSON() string { return r.raw } // The operator used when matching: `eq` means "equal" and `ne` means "not equal". -type RateLimitListResponseMatchHeadersOp string +type RateLimitMatchHeadersOp string const ( - RateLimitListResponseMatchHeadersOpEq RateLimitListResponseMatchHeadersOp = "eq" - RateLimitListResponseMatchHeadersOpNe RateLimitListResponseMatchHeadersOp = "ne" + RateLimitMatchHeadersOpEq RateLimitMatchHeadersOp = "eq" + RateLimitMatchHeadersOpNe RateLimitMatchHeadersOp = "ne" ) -func (r RateLimitListResponseMatchHeadersOp) IsKnown() bool { +func (r RateLimitMatchHeadersOp) IsKnown() bool { switch r { - case RateLimitListResponseMatchHeadersOpEq, RateLimitListResponseMatchHeadersOpNe: + case RateLimitMatchHeadersOpEq, RateLimitMatchHeadersOpNe: return true } return false } -type RateLimitListResponseMatchRequest struct { +type RateLimitMatchRequest struct { // The HTTP methods to match. You can specify a subset (for example, // `['POST','PUT']`) or all methods (`['_ALL_']`). This field is optional when // creating a rate limit. - Methods []RateLimitListResponseMatchRequestMethod `json:"methods"` + Methods []Methods `json:"methods"` // The HTTP schemes to match. You can specify one scheme (`['HTTPS']`), both // schemes (`['HTTP','HTTPS']`), or all schemes (`['_ALL_']`). This field is // optional. @@ -389,13 +411,13 @@ type RateLimitListResponseMatchRequest struct { // `example.org/path*`. Normalization is applied before the pattern is matched. `*` // wildcards are expanded to match applicable traffic. Query strings are not // matched. Set the value to `*` to match all traffic to your zone. - URL string `json:"url"` - JSON rateLimitListResponseMatchRequestJSON `json:"-"` + URL string `json:"url"` + JSON rateLimitMatchRequestJSON `json:"-"` } -// rateLimitListResponseMatchRequestJSON contains the JSON metadata for the struct -// [RateLimitListResponseMatchRequest] -type rateLimitListResponseMatchRequestJSON struct { +// rateLimitMatchRequestJSON contains the JSON metadata for the struct +// [RateLimitMatchRequest] +type rateLimitMatchRequestJSON struct { Methods apijson.Field Schemes apijson.Field URL apijson.Field @@ -403,61 +425,57 @@ type rateLimitListResponseMatchRequestJSON struct { ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponseMatchRequest) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimitMatchRequest) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseMatchRequestJSON) RawJSON() string { +func (r rateLimitMatchRequestJSON) RawJSON() string { return r.raw } -// An HTTP method or `_ALL_` to indicate all methods. -type RateLimitListResponseMatchRequestMethod string - -const ( - RateLimitListResponseMatchRequestMethodGet RateLimitListResponseMatchRequestMethod = "GET" - RateLimitListResponseMatchRequestMethodPost RateLimitListResponseMatchRequestMethod = "POST" - RateLimitListResponseMatchRequestMethodPut RateLimitListResponseMatchRequestMethod = "PUT" - RateLimitListResponseMatchRequestMethodDelete RateLimitListResponseMatchRequestMethod = "DELETE" - RateLimitListResponseMatchRequestMethodPatch RateLimitListResponseMatchRequestMethod = "PATCH" - RateLimitListResponseMatchRequestMethodHead RateLimitListResponseMatchRequestMethod = "HEAD" - RateLimitListResponseMatchRequestMethod_All RateLimitListResponseMatchRequestMethod = "_ALL_" -) - -func (r RateLimitListResponseMatchRequestMethod) IsKnown() bool { - switch r { - case RateLimitListResponseMatchRequestMethodGet, RateLimitListResponseMatchRequestMethodPost, RateLimitListResponseMatchRequestMethodPut, RateLimitListResponseMatchRequestMethodDelete, RateLimitListResponseMatchRequestMethodPatch, RateLimitListResponseMatchRequestMethodHead, RateLimitListResponseMatchRequestMethod_All: - return true - } - return false -} - -type RateLimitListResponseMatchResponse struct { +type RateLimitMatchResponse struct { // When true, only the uncached traffic served from your origin servers will count // towards rate limiting. In this case, any cached traffic served by Cloudflare // will not count towards rate limiting. This field is optional. Notes: This field // is deprecated. Instead, use response headers and set "origin_traffic" to "false" // to avoid legacy behaviour interacting with the "response_headers" property. - OriginTraffic bool `json:"origin_traffic"` - JSON rateLimitListResponseMatchResponseJSON `json:"-"` + OriginTraffic bool `json:"origin_traffic"` + JSON rateLimitMatchResponseJSON `json:"-"` } -// rateLimitListResponseMatchResponseJSON contains the JSON metadata for the struct -// [RateLimitListResponseMatchResponse] -type rateLimitListResponseMatchResponseJSON struct { +// rateLimitMatchResponseJSON contains the JSON metadata for the struct +// [RateLimitMatchResponse] +type rateLimitMatchResponseJSON struct { OriginTraffic apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RateLimitListResponseMatchResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RateLimitMatchResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rateLimitListResponseMatchResponseJSON) RawJSON() string { +func (r rateLimitMatchResponseJSON) RawJSON() string { return r.raw } +// Union satisfied by [rate_limits.RateLimitNewResponseUnknown] or +// [shared.UnionString]. +type RateLimitNewResponseUnion interface { + ImplementsRateLimitsRateLimitNewResponseUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RateLimitNewResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + type RateLimitDeleteResponse struct { // The unique identifier of the rate limit. ID string `json:"id"` @@ -482,13 +500,13 @@ func (r rateLimitDeleteResponseJSON) RawJSON() string { // Union satisfied by [rate_limits.RateLimitEditResponseUnknown] or // [shared.UnionString]. -type RateLimitEditResponse interface { - ImplementsRateLimitsRateLimitEditResponse() +type RateLimitEditResponseUnion interface { + ImplementsRateLimitsRateLimitEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RateLimitEditResponse)(nil)).Elem(), + reflect.TypeOf((*RateLimitEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -499,13 +517,13 @@ func init() { // Union satisfied by [rate_limits.RateLimitGetResponseUnknown] or // [shared.UnionString]. -type RateLimitGetResponse interface { - ImplementsRateLimitsRateLimitGetResponse() +type RateLimitGetResponseUnion interface { + ImplementsRateLimitsRateLimitGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*RateLimitGetResponse)(nil)).Elem(), + reflect.TypeOf((*RateLimitGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -515,7 +533,7 @@ func init() { } type RateLimitNewParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r RateLimitNewParams) MarshalJSON() (data []byte, err error) { @@ -523,9 +541,9 @@ func (r RateLimitNewParams) MarshalJSON() (data []byte, err error) { } type RateLimitNewResponseEnvelope struct { - Errors []RateLimitNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RateLimitNewResponseEnvelopeMessages `json:"messages,required"` - Result RateLimitNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RateLimitNewResponseUnion `json:"result,required"` // Whether the API call was successful Success RateLimitNewResponseEnvelopeSuccess `json:"success,required"` JSON rateLimitNewResponseEnvelopeJSON `json:"-"` @@ -550,52 +568,6 @@ func (r rateLimitNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RateLimitNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// rateLimitNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RateLimitNewResponseEnvelopeErrors] -type rateLimitNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RateLimitNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// rateLimitNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RateLimitNewResponseEnvelopeMessages] -type rateLimitNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RateLimitNewResponseEnvelopeSuccess bool @@ -622,15 +594,23 @@ type RateLimitListParams struct { // URLQuery serializes [RateLimitListParams]'s query parameters as `url.Values`. func (r RateLimitListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } +type RateLimitDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r RateLimitDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type RateLimitDeleteResponseEnvelope struct { - Errors []RateLimitDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RateLimitDeleteResponseEnvelopeMessages `json:"messages,required"` - Result RateLimitDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RateLimitDeleteResponse `json:"result,required"` // Whether the API call was successful Success RateLimitDeleteResponseEnvelopeSuccess `json:"success,required"` JSON rateLimitDeleteResponseEnvelopeJSON `json:"-"` @@ -655,52 +635,6 @@ func (r rateLimitDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RateLimitDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// rateLimitDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RateLimitDeleteResponseEnvelopeErrors] -type rateLimitDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RateLimitDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// rateLimitDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RateLimitDeleteResponseEnvelopeMessages] -type rateLimitDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RateLimitDeleteResponseEnvelopeSuccess bool @@ -717,7 +651,7 @@ func (r RateLimitDeleteResponseEnvelopeSuccess) IsKnown() bool { } type RateLimitEditParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r RateLimitEditParams) MarshalJSON() (data []byte, err error) { @@ -725,9 +659,9 @@ func (r RateLimitEditParams) MarshalJSON() (data []byte, err error) { } type RateLimitEditResponseEnvelope struct { - Errors []RateLimitEditResponseEnvelopeErrors `json:"errors,required"` - Messages []RateLimitEditResponseEnvelopeMessages `json:"messages,required"` - Result RateLimitEditResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RateLimitEditResponseUnion `json:"result,required"` // Whether the API call was successful Success RateLimitEditResponseEnvelopeSuccess `json:"success,required"` JSON rateLimitEditResponseEnvelopeJSON `json:"-"` @@ -752,52 +686,6 @@ func (r rateLimitEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RateLimitEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// rateLimitEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RateLimitEditResponseEnvelopeErrors] -type rateLimitEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RateLimitEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// rateLimitEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RateLimitEditResponseEnvelopeMessages] -type rateLimitEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RateLimitEditResponseEnvelopeSuccess bool @@ -814,9 +702,9 @@ func (r RateLimitEditResponseEnvelopeSuccess) IsKnown() bool { } type RateLimitGetResponseEnvelope struct { - Errors []RateLimitGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RateLimitGetResponseEnvelopeMessages `json:"messages,required"` - Result RateLimitGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RateLimitGetResponseUnion `json:"result,required"` // Whether the API call was successful Success RateLimitGetResponseEnvelopeSuccess `json:"success,required"` JSON rateLimitGetResponseEnvelopeJSON `json:"-"` @@ -841,52 +729,6 @@ func (r rateLimitGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RateLimitGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// rateLimitGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RateLimitGetResponseEnvelopeErrors] -type rateLimitGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RateLimitGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON rateLimitGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// rateLimitGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RateLimitGetResponseEnvelopeMessages] -type rateLimitGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RateLimitGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rateLimitGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RateLimitGetResponseEnvelopeSuccess bool diff --git a/rate_limits/ratelimit_test.go b/rate_limits/ratelimit_test.go index 4d528fea0f3..596ab863a01 100644 --- a/rate_limits/ratelimit_test.go +++ b/rate_limits/ratelimit_test.go @@ -32,7 +32,7 @@ func TestRateLimitNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", rate_limits.RateLimitNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -93,6 +93,9 @@ func TestRateLimitDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", + rate_limits.RateLimitDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error @@ -122,7 +125,7 @@ func TestRateLimitEdit(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", rate_limits.RateLimitEditParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/rate_plans/aliases.go b/rate_plans/aliases.go index fc63fc16f9a..70a9ad8ac10 100644 --- a/rate_plans/aliases.go +++ b/rate_plans/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/rate_plans/rateplan.go b/rate_plans/rateplan.go index 1ac24069fa9..bf1c3922ad3 100644 --- a/rate_plans/rateplan.go +++ b/rate_plans/rateplan.go @@ -8,7 +8,9 @@ import ( "net/http" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "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" ) @@ -30,7 +32,7 @@ func NewRatePlanService(opts ...option.RequestOption) (r *RatePlanService) { } // Lists all rate plans the zone can subscribe to. -func (r *RatePlanService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]RatePlanGetResponse, err error) { +func (r *RatePlanService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]RatePlan, err error) { opts = append(r.Options[:], opts...) var env RatePlanGetResponseEnvelope path := fmt.Sprintf("zones/%s/available_rate_plans", zoneIdentifier) @@ -42,25 +44,24 @@ func (r *RatePlanService) Get(ctx context.Context, zoneIdentifier string, opts . return } -type RatePlanGetResponse struct { +type RatePlan struct { // Plan identifier tag. ID string `json:"id"` // Array of available components values for the plan. - Components []RatePlanGetResponseComponent `json:"components"` + Components []RatePlanComponent `json:"components"` // The monetary unit in which pricing information is displayed. Currency string `json:"currency"` // The duration of the plan subscription. Duration float64 `json:"duration"` // The frequency at which you will be billed for this plan. - Frequency RatePlanGetResponseFrequency `json:"frequency"` + Frequency RatePlanFrequency `json:"frequency"` // The plan name. - Name string `json:"name"` - JSON ratePlanGetResponseJSON `json:"-"` + Name string `json:"name"` + JSON ratePlanJSON `json:"-"` } -// ratePlanGetResponseJSON contains the JSON metadata for the struct -// [RatePlanGetResponse] -type ratePlanGetResponseJSON struct { +// ratePlanJSON contains the JSON metadata for the struct [RatePlan] +type ratePlanJSON struct { ID apijson.Field Components apijson.Field Currency apijson.Field @@ -71,27 +72,27 @@ type ratePlanGetResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RatePlanGetResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RatePlan) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ratePlanGetResponseJSON) RawJSON() string { +func (r ratePlanJSON) RawJSON() string { return r.raw } -type RatePlanGetResponseComponent struct { +type RatePlanComponent struct { // The default amount allocated. Default float64 `json:"default"` // The unique component. - Name RatePlanGetResponseComponentsName `json:"name"` + Name RatePlanComponentsName `json:"name"` // The unit price of the addon. - UnitPrice float64 `json:"unit_price"` - JSON ratePlanGetResponseComponentJSON `json:"-"` + UnitPrice float64 `json:"unit_price"` + JSON ratePlanComponentJSON `json:"-"` } -// ratePlanGetResponseComponentJSON contains the JSON metadata for the struct -// [RatePlanGetResponseComponent] -type ratePlanGetResponseComponentJSON struct { +// ratePlanComponentJSON contains the JSON metadata for the struct +// [RatePlanComponent] +type ratePlanComponentJSON struct { Default apijson.Field Name apijson.Field UnitPrice apijson.Field @@ -99,54 +100,76 @@ type ratePlanGetResponseComponentJSON struct { ExtraFields map[string]apijson.Field } -func (r *RatePlanGetResponseComponent) UnmarshalJSON(data []byte) (err error) { +func (r *RatePlanComponent) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ratePlanGetResponseComponentJSON) RawJSON() string { +func (r ratePlanComponentJSON) RawJSON() string { return r.raw } // The unique component. -type RatePlanGetResponseComponentsName string +type RatePlanComponentsName string const ( - RatePlanGetResponseComponentsNameZones RatePlanGetResponseComponentsName = "zones" - RatePlanGetResponseComponentsNamePageRules RatePlanGetResponseComponentsName = "page_rules" - RatePlanGetResponseComponentsNameDedicatedCertificates RatePlanGetResponseComponentsName = "dedicated_certificates" - RatePlanGetResponseComponentsNameDedicatedCertificatesCustom RatePlanGetResponseComponentsName = "dedicated_certificates_custom" + RatePlanComponentsNameZones RatePlanComponentsName = "zones" + RatePlanComponentsNamePageRules RatePlanComponentsName = "page_rules" + RatePlanComponentsNameDedicatedCertificates RatePlanComponentsName = "dedicated_certificates" + RatePlanComponentsNameDedicatedCertificatesCustom RatePlanComponentsName = "dedicated_certificates_custom" ) -func (r RatePlanGetResponseComponentsName) IsKnown() bool { +func (r RatePlanComponentsName) IsKnown() bool { switch r { - case RatePlanGetResponseComponentsNameZones, RatePlanGetResponseComponentsNamePageRules, RatePlanGetResponseComponentsNameDedicatedCertificates, RatePlanGetResponseComponentsNameDedicatedCertificatesCustom: + case RatePlanComponentsNameZones, RatePlanComponentsNamePageRules, RatePlanComponentsNameDedicatedCertificates, RatePlanComponentsNameDedicatedCertificatesCustom: return true } return false } // The frequency at which you will be billed for this plan. -type RatePlanGetResponseFrequency string +type RatePlanFrequency string const ( - RatePlanGetResponseFrequencyWeekly RatePlanGetResponseFrequency = "weekly" - RatePlanGetResponseFrequencyMonthly RatePlanGetResponseFrequency = "monthly" - RatePlanGetResponseFrequencyQuarterly RatePlanGetResponseFrequency = "quarterly" - RatePlanGetResponseFrequencyYearly RatePlanGetResponseFrequency = "yearly" + RatePlanFrequencyWeekly RatePlanFrequency = "weekly" + RatePlanFrequencyMonthly RatePlanFrequency = "monthly" + RatePlanFrequencyQuarterly RatePlanFrequency = "quarterly" + RatePlanFrequencyYearly RatePlanFrequency = "yearly" ) -func (r RatePlanGetResponseFrequency) IsKnown() bool { +func (r RatePlanFrequency) IsKnown() bool { switch r { - case RatePlanGetResponseFrequencyWeekly, RatePlanGetResponseFrequencyMonthly, RatePlanGetResponseFrequencyQuarterly, RatePlanGetResponseFrequencyYearly: + case RatePlanFrequencyWeekly, RatePlanFrequencyMonthly, RatePlanFrequencyQuarterly, RatePlanFrequencyYearly: return true } return false } +type RatePlanParam struct { + // Array of available components values for the plan. + Components param.Field[[]RatePlanComponentParam] `json:"components"` + // The duration of the plan subscription. + Duration param.Field[float64] `json:"duration"` +} + +func (r RatePlanParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RatePlanComponentParam struct { + // The default amount allocated. + Default param.Field[float64] `json:"default"` + // The unique component. + Name param.Field[RatePlanComponentsName] `json:"name"` +} + +func (r RatePlanComponentParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type RatePlanGetResponseEnvelope struct { - Errors []RatePlanGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RatePlanGetResponseEnvelopeMessages `json:"messages,required"` - Result []RatePlanGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []RatePlan `json:"result,required,nullable"` // Whether the API call was successful Success RatePlanGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo RatePlanGetResponseEnvelopeResultInfo `json:"result_info"` @@ -173,52 +196,6 @@ func (r ratePlanGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RatePlanGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ratePlanGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// ratePlanGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RatePlanGetResponseEnvelopeErrors] -type ratePlanGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RatePlanGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ratePlanGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RatePlanGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ratePlanGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// ratePlanGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RatePlanGetResponseEnvelopeMessages] -type ratePlanGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RatePlanGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ratePlanGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RatePlanGetResponseEnvelopeSuccess bool diff --git a/registrar/aliases.go b/registrar/aliases.go index e795ba0c32b..d38de0959b8 100644 --- a/registrar/aliases.go +++ b/registrar/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/registrar/domain.go b/registrar/domain.go index 5e456dd3bf0..ee7071b636c 100644 --- a/registrar/domain.go +++ b/registrar/domain.go @@ -36,7 +36,7 @@ func NewDomainService(opts ...option.RequestOption) (r *DomainService) { } // Update individual domain. -func (r *DomainService) Update(ctx context.Context, domainName string, params DomainUpdateParams, opts ...option.RequestOption) (res *DomainUpdateResponse, err error) { +func (r *DomainService) Update(ctx context.Context, domainName string, params DomainUpdateParams, opts ...option.RequestOption) (res *DomainUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DomainUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/registrar/domains/%s", params.AccountID, domainName) @@ -49,7 +49,7 @@ func (r *DomainService) Update(ctx context.Context, domainName string, params Do } // List domains handled by Registrar. -func (r *DomainService) List(ctx context.Context, query DomainListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DomainListResponse], err error) { +func (r *DomainService) List(ctx context.Context, query DomainListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Domain], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -67,12 +67,12 @@ func (r *DomainService) List(ctx context.Context, query DomainListParams, opts . } // List domains handled by Registrar. -func (r *DomainService) ListAutoPaging(ctx context.Context, query DomainListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DomainListResponse] { +func (r *DomainService) ListAutoPaging(ctx context.Context, query DomainListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Domain] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Show individual domain. -func (r *DomainService) Get(ctx context.Context, domainName string, query DomainGetParams, opts ...option.RequestOption) (res *DomainGetResponse, err error) { +func (r *DomainService) Get(ctx context.Context, domainName string, query DomainGetParams, opts ...option.RequestOption) (res *DomainGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DomainGetResponseEnvelope path := fmt.Sprintf("accounts/%s/registrar/domains/%s", query.AccountID, domainName) @@ -84,32 +84,7 @@ func (r *DomainService) Get(ctx context.Context, domainName string, query Domain return } -// Union satisfied by [registrar.DomainUpdateResponseUnknown], -// [registrar.DomainUpdateResponseArray] or [shared.UnionString]. -type DomainUpdateResponse interface { - ImplementsRegistrarDomainUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DomainUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DomainUpdateResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type DomainUpdateResponseArray []interface{} - -func (r DomainUpdateResponseArray) ImplementsRegistrarDomainUpdateResponse() {} - -type DomainListResponse struct { +type Domain struct { // Domain identifier. ID string `json:"id"` // Shows if a domain is available for transferring into Cloudflare Registrar. @@ -125,7 +100,7 @@ type DomainListResponse struct { // Shows whether a registrar lock is in place for a domain. Locked bool `json:"locked"` // Shows contact information for domain registrant. - RegistrantContact DomainListResponseRegistrantContact `json:"registrant_contact"` + RegistrantContact DomainRegistrantContact `json:"registrant_contact"` // A comma-separated list of registry status codes. A full list of status codes can // be found at // [EPP Status Codes](https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en). @@ -135,15 +110,14 @@ type DomainListResponse struct { // supported TLDs. SupportedTld bool `json:"supported_tld"` // Statuses for domain transfers into Cloudflare Registrar. - TransferIn DomainListResponseTransferIn `json:"transfer_in"` + TransferIn DomainTransferIn `json:"transfer_in"` // Last updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON domainListResponseJSON `json:"-"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON domainJSON `json:"-"` } -// domainListResponseJSON contains the JSON metadata for the struct -// [DomainListResponse] -type domainListResponseJSON struct { +// domainJSON contains the JSON metadata for the struct [Domain] +type domainJSON struct { ID apijson.Field Available apijson.Field CanRegister apijson.Field @@ -160,16 +134,16 @@ type domainListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *DomainListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Domain) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r domainListResponseJSON) RawJSON() string { +func (r domainJSON) RawJSON() string { return r.raw } // Shows contact information for domain registrant. -type DomainListResponseRegistrantContact struct { +type DomainRegistrantContact struct { // Address. Address string `json:"address,required"` // City. @@ -195,13 +169,13 @@ type DomainListResponseRegistrantContact struct { // The contact email address of the user. Email string `json:"email"` // Contact fax number. - Fax string `json:"fax"` - JSON domainListResponseRegistrantContactJSON `json:"-"` + Fax string `json:"fax"` + JSON domainRegistrantContactJSON `json:"-"` } -// domainListResponseRegistrantContactJSON contains the JSON metadata for the -// struct [DomainListResponseRegistrantContact] -type domainListResponseRegistrantContactJSON struct { +// domainRegistrantContactJSON contains the JSON metadata for the struct +// [DomainRegistrantContact] +type domainRegistrantContactJSON struct { Address apijson.Field City apijson.Field Country apijson.Field @@ -219,16 +193,16 @@ type domainListResponseRegistrantContactJSON struct { ExtraFields map[string]apijson.Field } -func (r *DomainListResponseRegistrantContact) UnmarshalJSON(data []byte) (err error) { +func (r *DomainRegistrantContact) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r domainListResponseRegistrantContactJSON) RawJSON() string { +func (r domainRegistrantContactJSON) RawJSON() string { return r.raw } // Statuses for domain transfers into Cloudflare Registrar. -type DomainListResponseTransferIn struct { +type DomainTransferIn struct { // Form of authorization has been accepted by the registrant. AcceptFoa string `json:"accept_foa"` // Shows transfer status with the registry. @@ -240,13 +214,13 @@ type DomainListResponseTransferIn struct { // Auth code has been entered and verified. EnterAuthCode string `json:"enter_auth_code"` // Domain is unlocked at the foreign registrar. - UnlockDomain interface{} `json:"unlock_domain"` - JSON domainListResponseTransferInJSON `json:"-"` + UnlockDomain interface{} `json:"unlock_domain"` + JSON domainTransferInJSON `json:"-"` } -// domainListResponseTransferInJSON contains the JSON metadata for the struct -// [DomainListResponseTransferIn] -type domainListResponseTransferInJSON struct { +// domainTransferInJSON contains the JSON metadata for the struct +// [DomainTransferIn] +type domainTransferInJSON struct { AcceptFoa apijson.Field ApproveTransfer apijson.Field CanCancelTransfer apijson.Field @@ -257,23 +231,48 @@ type domainListResponseTransferInJSON struct { ExtraFields map[string]apijson.Field } -func (r *DomainListResponseTransferIn) UnmarshalJSON(data []byte) (err error) { +func (r *DomainTransferIn) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r domainListResponseTransferInJSON) RawJSON() string { +func (r domainTransferInJSON) RawJSON() string { return r.raw } +// Union satisfied by [registrar.DomainUpdateResponseUnknown], +// [registrar.DomainUpdateResponseArray] or [shared.UnionString]. +type DomainUpdateResponseUnion interface { + ImplementsRegistrarDomainUpdateResponseUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DomainUpdateResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DomainUpdateResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DomainUpdateResponseArray []interface{} + +func (r DomainUpdateResponseArray) ImplementsRegistrarDomainUpdateResponseUnion() {} + // Union satisfied by [registrar.DomainGetResponseUnknown], // [registrar.DomainGetResponseArray] or [shared.UnionString]. -type DomainGetResponse interface { - ImplementsRegistrarDomainGetResponse() +type DomainGetResponseUnion interface { + ImplementsRegistrarDomainGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DomainGetResponse)(nil)).Elem(), + reflect.TypeOf((*DomainGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -288,7 +287,7 @@ func init() { type DomainGetResponseArray []interface{} -func (r DomainGetResponseArray) ImplementsRegistrarDomainGetResponse() {} +func (r DomainGetResponseArray) ImplementsRegistrarDomainGetResponseUnion() {} type DomainUpdateParams struct { // Identifier @@ -307,9 +306,9 @@ func (r DomainUpdateParams) MarshalJSON() (data []byte, err error) { } type DomainUpdateResponseEnvelope struct { - Errors []DomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DomainUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DomainUpdateResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success DomainUpdateResponseEnvelopeSuccess `json:"success,required"` JSON domainUpdateResponseEnvelopeJSON `json:"-"` @@ -334,52 +333,6 @@ func (r domainUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// domainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DomainUpdateResponseEnvelopeErrors] -type domainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// domainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DomainUpdateResponseEnvelopeMessages] -type domainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DomainUpdateResponseEnvelopeSuccess bool @@ -406,9 +359,9 @@ type DomainGetParams struct { } type DomainGetResponseEnvelope struct { - Errors []DomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DomainGetResponseEnvelopeMessages `json:"messages,required"` - Result DomainGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DomainGetResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success DomainGetResponseEnvelopeSuccess `json:"success,required"` JSON domainGetResponseEnvelopeJSON `json:"-"` @@ -433,52 +386,6 @@ func (r domainGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// domainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DomainGetResponseEnvelopeErrors] -type domainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// domainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DomainGetResponseEnvelopeMessages] -type domainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DomainGetResponseEnvelopeSuccess bool diff --git a/request_tracers/aliases.go b/request_tracers/aliases.go index 1a77b8a1df2..134dad239d4 100644 --- a/request_tracers/aliases.go +++ b/request_tracers/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/request_tracers/trace.go b/request_tracers/trace.go index 17e71f058dc..4acb42079ab 100644 --- a/request_tracers/trace.go +++ b/request_tracers/trace.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,11 +32,11 @@ func NewTraceService(opts ...option.RequestOption) (r *TraceService) { } // Request Trace -func (r *TraceService) New(ctx context.Context, accountIdentifier string, body TraceNewParams, opts ...option.RequestOption) (res *TraceNewResponse, err error) { +func (r *TraceService) New(ctx context.Context, params TraceNewParams, opts ...option.RequestOption) (res *TraceNewResponse, err error) { opts = append(r.Options[:], opts...) var env TraceNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/request-tracer/trace", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + path := fmt.Sprintf("accounts/%s/request-tracer/trace", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return } @@ -119,6 +120,8 @@ func (r traceNewResponseJSON) RawJSON() string { } type TraceNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` // HTTP Method of tracing request Method param.Field[string] `json:"method,required"` // URL to which perform tracing request @@ -188,8 +191,8 @@ func (r TraceNewParamsContextGeoloc) MarshalJSON() (data []byte, err error) { } type TraceNewResponseEnvelope struct { - Errors []TraceNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TraceNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Trace result with an origin status code Result TraceNewResponse `json:"result,required"` // Whether the API call was successful @@ -216,52 +219,6 @@ func (r traceNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TraceNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON traceNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// traceNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TraceNewResponseEnvelopeErrors] -type traceNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TraceNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r traceNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TraceNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON traceNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// traceNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TraceNewResponseEnvelopeMessages] -type traceNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TraceNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r traceNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TraceNewResponseEnvelopeSuccess bool diff --git a/request_tracers/trace_test.go b/request_tracers/trace_test.go index f4f2bbafde0..26fccf31813 100644 --- a/request_tracers/trace_test.go +++ b/request_tracers/trace_test.go @@ -28,46 +28,43 @@ func TestTraceNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.RequestTracers.Traces.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - request_tracers.TraceNewParams{ - Method: cloudflare.F("PUT"), - URL: cloudflare.F("https://some.zone/some_path"), - Body: cloudflare.F(request_tracers.TraceNewParamsBody{ - Base64: cloudflare.F("c29tZV9yZXF1ZXN0X2JvZHk="), - Json: cloudflare.F[any](map[string]interface{}{}), - PlainText: cloudflare.F("string"), + _, err := client.RequestTracers.Traces.New(context.TODO(), request_tracers.TraceNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Method: cloudflare.F("PUT"), + URL: cloudflare.F("https://some.zone/some_path"), + Body: cloudflare.F(request_tracers.TraceNewParamsBody{ + Base64: cloudflare.F("c29tZV9yZXF1ZXN0X2JvZHk="), + Json: cloudflare.F[any](map[string]interface{}{}), + PlainText: cloudflare.F("string"), + }), + Context: cloudflare.F(request_tracers.TraceNewParamsContext{ + BotScore: cloudflare.F(int64(0)), + Geoloc: cloudflare.F(request_tracers.TraceNewParamsContextGeoloc{ + City: cloudflare.F("London"), + Continent: cloudflare.F("string"), + IsEuCountry: cloudflare.F(true), + ISOCode: cloudflare.F("string"), + Latitude: cloudflare.F(0.000000), + Longitude: cloudflare.F(0.000000), + PostalCode: cloudflare.F("string"), + RegionCode: cloudflare.F("string"), + Subdivision2ISOCode: cloudflare.F("string"), + Timezone: cloudflare.F("string"), }), - Context: cloudflare.F(request_tracers.TraceNewParamsContext{ - BotScore: cloudflare.F(int64(0)), - Geoloc: cloudflare.F(request_tracers.TraceNewParamsContextGeoloc{ - City: cloudflare.F("London"), - Continent: cloudflare.F("string"), - IsEuCountry: cloudflare.F(true), - ISOCode: cloudflare.F("string"), - Latitude: cloudflare.F(0.000000), - Longitude: cloudflare.F(0.000000), - PostalCode: cloudflare.F("string"), - RegionCode: cloudflare.F("string"), - Subdivision2ISOCode: cloudflare.F("string"), - Timezone: cloudflare.F("string"), - }), - SkipChallenge: cloudflare.F(true), - ThreatScore: cloudflare.F(int64(0)), - }), - Cookies: cloudflare.F(map[string]string{ - "cookie_name_1": "cookie_value_1", - "cookie_name_2": "cookie_value_2", - }), - Headers: cloudflare.F(map[string]string{ - "header_name_1": "header_value_1", - "header_name_2": "header_value_2", - }), - Protocol: cloudflare.F("HTTP/1.1"), - SkipResponse: cloudflare.F(true), - }, - ) + SkipChallenge: cloudflare.F(true), + ThreatScore: cloudflare.F(int64(0)), + }), + Cookies: cloudflare.F(map[string]string{ + "cookie_name_1": "cookie_value_1", + "cookie_name_2": "cookie_value_2", + }), + Headers: cloudflare.F(map[string]string{ + "header_name_1": "header_value_1", + "header_name_2": "header_value_2", + }), + Protocol: cloudflare.F("HTTP/1.1"), + SkipResponse: cloudflare.F(true), + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/rules/aliases.go b/rules/aliases.go index 53ca6eac64c..8847c2b1bc6 100644 --- a/rules/aliases.go +++ b/rules/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/rules/list.go b/rules/list.go index dd1ad1603bd..4310bf410bb 100644 --- a/rules/list.go +++ b/rules/list.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -85,10 +86,10 @@ func (r *ListService) ListAutoPaging(ctx context.Context, query ListListParams, } // Deletes a specific list and all its items. -func (r *ListService) Delete(ctx context.Context, listID string, body ListDeleteParams, opts ...option.RequestOption) (res *ListDeleteResponse, err error) { +func (r *ListService) Delete(ctx context.Context, listID string, params ListDeleteParams, opts ...option.RequestOption) (res *ListDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env ListDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists/%s", body.AccountID, listID) + path := fmt.Sprintf("accounts/%s/rules/lists/%s", params.AccountID, listID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -110,6 +111,40 @@ func (r *ListService) Get(ctx context.Context, listID string, query ListGetParam return } +// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from +// 0 to 9, wildcards (\*), and the hyphen (-). +type Hostname struct { + URLHostname string `json:"url_hostname,required"` + JSON hostnameJSON `json:"-"` +} + +// hostnameJSON contains the JSON metadata for the struct [Hostname] +type hostnameJSON struct { + URLHostname apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Hostname) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameJSON) RawJSON() string { + return r.raw +} + +func (r Hostname) ImplementsRulesListItemGetResponseUnion() {} + +// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from +// 0 to 9, wildcards (\*), and the hyphen (-). +type HostnameParam struct { + URLHostname param.Field[string] `json:"url_hostname,required"` +} + +func (r HostnameParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type ListsList struct { // The unique ID of the list. ID string `json:"id"` @@ -172,6 +207,73 @@ func (r ListsListKind) IsKnown() bool { return false } +// The definition of the redirect. +type Redirect struct { + SourceURL string `json:"source_url,required"` + TargetURL string `json:"target_url,required"` + IncludeSubdomains bool `json:"include_subdomains"` + PreservePathSuffix bool `json:"preserve_path_suffix"` + PreserveQueryString bool `json:"preserve_query_string"` + StatusCode RedirectStatusCode `json:"status_code"` + SubpathMatching bool `json:"subpath_matching"` + JSON redirectJSON `json:"-"` +} + +// redirectJSON contains the JSON metadata for the struct [Redirect] +type redirectJSON struct { + SourceURL apijson.Field + TargetURL apijson.Field + IncludeSubdomains apijson.Field + PreservePathSuffix apijson.Field + PreserveQueryString apijson.Field + StatusCode apijson.Field + SubpathMatching apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Redirect) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r redirectJSON) RawJSON() string { + return r.raw +} + +func (r Redirect) ImplementsRulesListItemGetResponseUnion() {} + +type RedirectStatusCode int64 + +const ( + RedirectStatusCode301 RedirectStatusCode = 301 + RedirectStatusCode302 RedirectStatusCode = 302 + RedirectStatusCode307 RedirectStatusCode = 307 + RedirectStatusCode308 RedirectStatusCode = 308 +) + +func (r RedirectStatusCode) IsKnown() bool { + switch r { + case RedirectStatusCode301, RedirectStatusCode302, RedirectStatusCode307, RedirectStatusCode308: + return true + } + return false +} + +// The definition of the redirect. +type RedirectParam struct { + SourceURL param.Field[string] `json:"source_url,required"` + TargetURL param.Field[string] `json:"target_url,required"` + IncludeSubdomains param.Field[bool] `json:"include_subdomains"` + PreservePathSuffix param.Field[bool] `json:"preserve_path_suffix"` + PreserveQueryString param.Field[bool] `json:"preserve_query_string"` + StatusCode param.Field[RedirectStatusCode] `json:"status_code"` + SubpathMatching param.Field[bool] `json:"subpath_matching"` +} + +func (r RedirectParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type ListNewResponse = interface{} type ListUpdateResponse = interface{} @@ -236,9 +338,9 @@ func (r ListNewParamsKind) IsKnown() bool { } type ListNewResponseEnvelope struct { - Errors []ListNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ListNewResponseEnvelopeMessages `json:"messages,required"` - Result ListsList `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ListsList `json:"result,required,nullable"` // Whether the API call was successful Success ListNewResponseEnvelopeSuccess `json:"success,required"` JSON listNewResponseEnvelopeJSON `json:"-"` @@ -263,52 +365,6 @@ func (r listNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// listNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ListNewResponseEnvelopeErrors] -type listNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// listNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ListNewResponseEnvelopeMessages] -type listNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListNewResponseEnvelopeSuccess bool @@ -336,9 +392,9 @@ func (r ListUpdateParams) MarshalJSON() (data []byte, err error) { } type ListUpdateResponseEnvelope struct { - Errors []ListUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ListUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ListsList `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ListsList `json:"result,required,nullable"` // Whether the API call was successful Success ListUpdateResponseEnvelopeSuccess `json:"success,required"` JSON listUpdateResponseEnvelopeJSON `json:"-"` @@ -363,52 +419,6 @@ func (r listUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// listUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ListUpdateResponseEnvelopeErrors] -type listUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// listUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ListUpdateResponseEnvelopeMessages] -type listUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListUpdateResponseEnvelopeSuccess bool @@ -432,12 +442,17 @@ type ListListParams struct { type ListDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ListDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ListDeleteResponseEnvelope struct { - Errors []ListDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ListDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ListDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ListDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success ListDeleteResponseEnvelopeSuccess `json:"success,required"` JSON listDeleteResponseEnvelopeJSON `json:"-"` @@ -462,52 +477,6 @@ func (r listDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// listDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ListDeleteResponseEnvelopeErrors] -type listDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// listDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ListDeleteResponseEnvelopeMessages] -type listDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListDeleteResponseEnvelopeSuccess bool @@ -529,9 +498,9 @@ type ListGetParams struct { } type ListGetResponseEnvelope struct { - Errors []ListGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ListGetResponseEnvelopeMessages `json:"messages,required"` - Result ListsList `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ListsList `json:"result,required,nullable"` // Whether the API call was successful Success ListGetResponseEnvelopeSuccess `json:"success,required"` JSON listGetResponseEnvelopeJSON `json:"-"` @@ -556,52 +525,6 @@ func (r listGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// listGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ListGetResponseEnvelopeErrors] -type listGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// listGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ListGetResponseEnvelopeMessages] -type listGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListGetResponseEnvelopeSuccess bool diff --git a/rules/list_test.go b/rules/list_test.go index 746f9149eab..9273ae14fba 100644 --- a/rules/list_test.go +++ b/rules/list_test.go @@ -119,6 +119,7 @@ func TestListDelete(t *testing.T) { "2c0fc9fa937b11eaa1b71c4d701ab86e", rules.ListDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/rules/listbulkoperation.go b/rules/listbulkoperation.go index 9f1d23b91ca..4a65fdcaa69 100644 --- a/rules/listbulkoperation.go +++ b/rules/listbulkoperation.go @@ -9,6 +9,7 @@ import ( "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" ) @@ -50,9 +51,9 @@ func (r *ListBulkOperationService) Get(ctx context.Context, accountIdentifier st type ListBulkOperationGetResponse = interface{} type ListBulkOperationGetResponseEnvelope struct { - Errors []ListBulkOperationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ListBulkOperationGetResponseEnvelopeMessages `json:"messages,required"` - Result []ListBulkOperationGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []ListBulkOperationGetResponse `json:"result,required,nullable"` // Whether the API call was successful Success ListBulkOperationGetResponseEnvelopeSuccess `json:"success,required"` JSON listBulkOperationGetResponseEnvelopeJSON `json:"-"` @@ -77,52 +78,6 @@ func (r listBulkOperationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListBulkOperationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listBulkOperationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// listBulkOperationGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ListBulkOperationGetResponseEnvelopeErrors] -type listBulkOperationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListBulkOperationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listBulkOperationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListBulkOperationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listBulkOperationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// listBulkOperationGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ListBulkOperationGetResponseEnvelopeMessages] -type listBulkOperationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListBulkOperationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listBulkOperationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListBulkOperationGetResponseEnvelopeSuccess bool diff --git a/rules/listitem.go b/rules/listitem.go index 1c1f77a48e5..c7edaddf411 100644 --- a/rules/listitem.go +++ b/rules/listitem.go @@ -112,7 +112,7 @@ func (r *ListItemService) Delete(ctx context.Context, listID string, params List } // Fetches a list item in the list. -func (r *ListItemService) Get(ctx context.Context, accountIdentifier string, listID string, itemID string, opts ...option.RequestOption) (res *ListItemGetResponse, err error) { +func (r *ListItemService) Get(ctx context.Context, accountIdentifier string, listID string, itemID string, opts ...option.RequestOption) (res *ListItemGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ListItemGetResponseEnvelope path := fmt.Sprintf("accounts/%s/rules/lists/%s/items/%s", accountIdentifier, listID, itemID) @@ -124,6 +124,49 @@ func (r *ListItemService) Get(ctx context.Context, accountIdentifier string, lis return } +type ListCursor struct { + After string `json:"after"` + Before string `json:"before"` + JSON listCursorJSON `json:"-"` +} + +// listCursorJSON contains the JSON metadata for the struct [ListCursor] +type listCursorJSON struct { + After apijson.Field + Before apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListCursor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listCursorJSON) RawJSON() string { + return r.raw +} + +type ListItem struct { + // The unique operation ID of the asynchronous action. + OperationID string `json:"operation_id"` + JSON listItemJSON `json:"-"` +} + +// listItemJSON contains the JSON metadata for the struct [ListItem] +type listItemJSON struct { + OperationID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemJSON) RawJSON() string { + return r.raw +} + type ListItemNewResponse struct { // The unique operation ID of the asynchronous action. OperationID string `json:"operation_id"` @@ -195,16 +238,15 @@ func (r listItemDeleteResponseJSON) RawJSON() string { // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a // maximum of /64. // -// Union satisfied by [shared.UnionString], -// [rules.ListItemGetResponseListsItemRedirect], -// [rules.ListItemGetResponseListsItemHostname] or [shared.UnionInt]. -type ListItemGetResponse interface { - ImplementsRulesListItemGetResponse() +// Union satisfied by [shared.UnionString], [rules.Redirect], [rules.Hostname] or +// [shared.UnionInt]. +type ListItemGetResponseUnion interface { + ImplementsRulesListItemGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ListItemGetResponse)(nil)).Elem(), + reflect.TypeOf((*ListItemGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -212,11 +254,11 @@ func init() { }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ListItemGetResponseListsItemRedirect{}), + Type: reflect.TypeOf(Redirect{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ListItemGetResponseListsItemHostname{}), + Type: reflect.TypeOf(Hostname{}), }, apijson.UnionVariant{ TypeFilter: gjson.Number, @@ -225,88 +267,10 @@ func init() { ) } -// The definition of the redirect. -type ListItemGetResponseListsItemRedirect struct { - SourceURL string `json:"source_url,required"` - TargetURL string `json:"target_url,required"` - IncludeSubdomains bool `json:"include_subdomains"` - PreservePathSuffix bool `json:"preserve_path_suffix"` - PreserveQueryString bool `json:"preserve_query_string"` - StatusCode ListItemGetResponseListsItemRedirectStatusCode `json:"status_code"` - SubpathMatching bool `json:"subpath_matching"` - JSON listItemGetResponseListsItemRedirectJSON `json:"-"` -} - -// listItemGetResponseListsItemRedirectJSON contains the JSON metadata for the -// struct [ListItemGetResponseListsItemRedirect] -type listItemGetResponseListsItemRedirectJSON struct { - SourceURL apijson.Field - TargetURL apijson.Field - IncludeSubdomains apijson.Field - PreservePathSuffix apijson.Field - PreserveQueryString apijson.Field - StatusCode apijson.Field - SubpathMatching apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemGetResponseListsItemRedirect) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemGetResponseListsItemRedirectJSON) RawJSON() string { - return r.raw -} - -func (r ListItemGetResponseListsItemRedirect) ImplementsRulesListItemGetResponse() {} - -type ListItemGetResponseListsItemRedirectStatusCode int64 - -const ( - ListItemGetResponseListsItemRedirectStatusCode301 ListItemGetResponseListsItemRedirectStatusCode = 301 - ListItemGetResponseListsItemRedirectStatusCode302 ListItemGetResponseListsItemRedirectStatusCode = 302 - ListItemGetResponseListsItemRedirectStatusCode307 ListItemGetResponseListsItemRedirectStatusCode = 307 - ListItemGetResponseListsItemRedirectStatusCode308 ListItemGetResponseListsItemRedirectStatusCode = 308 -) - -func (r ListItemGetResponseListsItemRedirectStatusCode) IsKnown() bool { - switch r { - case ListItemGetResponseListsItemRedirectStatusCode301, ListItemGetResponseListsItemRedirectStatusCode302, ListItemGetResponseListsItemRedirectStatusCode307, ListItemGetResponseListsItemRedirectStatusCode308: - return true - } - return false -} - -// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from -// 0 to 9, wildcards (\*), and the hyphen (-). -type ListItemGetResponseListsItemHostname struct { - URLHostname string `json:"url_hostname,required"` - JSON listItemGetResponseListsItemHostnameJSON `json:"-"` -} - -// listItemGetResponseListsItemHostnameJSON contains the JSON metadata for the -// struct [ListItemGetResponseListsItemHostname] -type listItemGetResponseListsItemHostnameJSON struct { - URLHostname apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemGetResponseListsItemHostname) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemGetResponseListsItemHostnameJSON) RawJSON() string { - return r.raw -} - -func (r ListItemGetResponseListsItemHostname) ImplementsRulesListItemGetResponse() {} - type ListItemNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]ListItemNewParamsBody] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body []ListItemNewParamsBody `json:"body,required"` } func (r ListItemNewParams) MarshalJSON() (data []byte, err error) { @@ -320,64 +284,22 @@ type ListItemNewParamsBody struct { Comment param.Field[string] `json:"comment"` // Valid characters for hostnames are ASCII(7) letters from a to z, the digits from // 0 to 9, wildcards (\*), and the hyphen (-). - Hostname param.Field[ListItemNewParamsBodyHostname] `json:"hostname"` + Hostname param.Field[HostnameParam] `json:"hostname"` // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a // maximum of /64. IP param.Field[string] `json:"ip"` // The definition of the redirect. - Redirect param.Field[ListItemNewParamsBodyRedirect] `json:"redirect"` + Redirect param.Field[RedirectParam] `json:"redirect"` } func (r ListItemNewParamsBody) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from -// 0 to 9, wildcards (\*), and the hyphen (-). -type ListItemNewParamsBodyHostname struct { - URLHostname param.Field[string] `json:"url_hostname,required"` -} - -func (r ListItemNewParamsBodyHostname) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The definition of the redirect. -type ListItemNewParamsBodyRedirect struct { - SourceURL param.Field[string] `json:"source_url,required"` - TargetURL param.Field[string] `json:"target_url,required"` - IncludeSubdomains param.Field[bool] `json:"include_subdomains"` - PreservePathSuffix param.Field[bool] `json:"preserve_path_suffix"` - PreserveQueryString param.Field[bool] `json:"preserve_query_string"` - StatusCode param.Field[ListItemNewParamsBodyRedirectStatusCode] `json:"status_code"` - SubpathMatching param.Field[bool] `json:"subpath_matching"` -} - -func (r ListItemNewParamsBodyRedirect) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ListItemNewParamsBodyRedirectStatusCode int64 - -const ( - ListItemNewParamsBodyRedirectStatusCode301 ListItemNewParamsBodyRedirectStatusCode = 301 - ListItemNewParamsBodyRedirectStatusCode302 ListItemNewParamsBodyRedirectStatusCode = 302 - ListItemNewParamsBodyRedirectStatusCode307 ListItemNewParamsBodyRedirectStatusCode = 307 - ListItemNewParamsBodyRedirectStatusCode308 ListItemNewParamsBodyRedirectStatusCode = 308 -) - -func (r ListItemNewParamsBodyRedirectStatusCode) IsKnown() bool { - switch r { - case ListItemNewParamsBodyRedirectStatusCode301, ListItemNewParamsBodyRedirectStatusCode302, ListItemNewParamsBodyRedirectStatusCode307, ListItemNewParamsBodyRedirectStatusCode308: - return true - } - return false -} - type ListItemNewResponseEnvelope struct { - Errors []ListItemNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ListItemNewResponseEnvelopeMessages `json:"messages,required"` - Result ListItemNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ListItemNewResponse `json:"result,required,nullable"` // Whether the API call was successful Success ListItemNewResponseEnvelopeSuccess `json:"success,required"` JSON listItemNewResponseEnvelopeJSON `json:"-"` @@ -402,52 +324,6 @@ func (r listItemNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListItemNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// listItemNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ListItemNewResponseEnvelopeErrors] -type listItemNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListItemNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// listItemNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ListItemNewResponseEnvelopeMessages] -type listItemNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListItemNewResponseEnvelopeSuccess bool @@ -465,8 +341,8 @@ func (r ListItemNewResponseEnvelopeSuccess) IsKnown() bool { type ListItemUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]ListItemUpdateParamsBody] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body []ListItemUpdateParamsBody `json:"body,required"` } func (r ListItemUpdateParams) MarshalJSON() (data []byte, err error) { @@ -480,64 +356,22 @@ type ListItemUpdateParamsBody struct { Comment param.Field[string] `json:"comment"` // Valid characters for hostnames are ASCII(7) letters from a to z, the digits from // 0 to 9, wildcards (\*), and the hyphen (-). - Hostname param.Field[ListItemUpdateParamsBodyHostname] `json:"hostname"` + Hostname param.Field[HostnameParam] `json:"hostname"` // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a // maximum of /64. IP param.Field[string] `json:"ip"` // The definition of the redirect. - Redirect param.Field[ListItemUpdateParamsBodyRedirect] `json:"redirect"` + Redirect param.Field[RedirectParam] `json:"redirect"` } func (r ListItemUpdateParamsBody) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from -// 0 to 9, wildcards (\*), and the hyphen (-). -type ListItemUpdateParamsBodyHostname struct { - URLHostname param.Field[string] `json:"url_hostname,required"` -} - -func (r ListItemUpdateParamsBodyHostname) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The definition of the redirect. -type ListItemUpdateParamsBodyRedirect struct { - SourceURL param.Field[string] `json:"source_url,required"` - TargetURL param.Field[string] `json:"target_url,required"` - IncludeSubdomains param.Field[bool] `json:"include_subdomains"` - PreservePathSuffix param.Field[bool] `json:"preserve_path_suffix"` - PreserveQueryString param.Field[bool] `json:"preserve_query_string"` - StatusCode param.Field[ListItemUpdateParamsBodyRedirectStatusCode] `json:"status_code"` - SubpathMatching param.Field[bool] `json:"subpath_matching"` -} - -func (r ListItemUpdateParamsBodyRedirect) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ListItemUpdateParamsBodyRedirectStatusCode int64 - -const ( - ListItemUpdateParamsBodyRedirectStatusCode301 ListItemUpdateParamsBodyRedirectStatusCode = 301 - ListItemUpdateParamsBodyRedirectStatusCode302 ListItemUpdateParamsBodyRedirectStatusCode = 302 - ListItemUpdateParamsBodyRedirectStatusCode307 ListItemUpdateParamsBodyRedirectStatusCode = 307 - ListItemUpdateParamsBodyRedirectStatusCode308 ListItemUpdateParamsBodyRedirectStatusCode = 308 -) - -func (r ListItemUpdateParamsBodyRedirectStatusCode) IsKnown() bool { - switch r { - case ListItemUpdateParamsBodyRedirectStatusCode301, ListItemUpdateParamsBodyRedirectStatusCode302, ListItemUpdateParamsBodyRedirectStatusCode307, ListItemUpdateParamsBodyRedirectStatusCode308: - return true - } - return false -} - type ListItemUpdateResponseEnvelope struct { - Errors []ListItemUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ListItemUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ListItemUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ListItemUpdateResponse `json:"result,required,nullable"` // Whether the API call was successful Success ListItemUpdateResponseEnvelopeSuccess `json:"success,required"` JSON listItemUpdateResponseEnvelopeJSON `json:"-"` @@ -562,52 +396,6 @@ func (r listItemUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListItemUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// listItemUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ListItemUpdateResponseEnvelopeErrors] -type listItemUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListItemUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// listItemUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ListItemUpdateResponseEnvelopeMessages] -type listItemUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListItemUpdateResponseEnvelopeSuccess bool @@ -643,7 +431,7 @@ type ListItemListParams struct { // URLQuery serializes [ListItemListParams]'s query parameters as `url.Values`. func (r ListItemListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -668,9 +456,9 @@ func (r ListItemDeleteParamsItem) MarshalJSON() (data []byte, err error) { } type ListItemDeleteResponseEnvelope struct { - Errors []ListItemDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ListItemDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ListItemDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ListItemDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success ListItemDeleteResponseEnvelopeSuccess `json:"success,required"` JSON listItemDeleteResponseEnvelopeJSON `json:"-"` @@ -695,52 +483,6 @@ func (r listItemDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListItemDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// listItemDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ListItemDeleteResponseEnvelopeErrors] -type listItemDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListItemDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// listItemDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ListItemDeleteResponseEnvelopeMessages] -type listItemDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListItemDeleteResponseEnvelopeSuccess bool @@ -757,11 +499,11 @@ func (r ListItemDeleteResponseEnvelopeSuccess) IsKnown() bool { } type ListItemGetResponseEnvelope struct { - Errors []ListItemGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ListItemGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a // maximum of /64. - Result ListItemGetResponse `json:"result,required,nullable"` + Result ListItemGetResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success ListItemGetResponseEnvelopeSuccess `json:"success,required"` JSON listItemGetResponseEnvelopeJSON `json:"-"` @@ -786,52 +528,6 @@ func (r listItemGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ListItemGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// listItemGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ListItemGetResponseEnvelopeErrors] -type listItemGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ListItemGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON listItemGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// listItemGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ListItemGetResponseEnvelopeMessages] -type listItemGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ListItemGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r listItemGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ListItemGetResponseEnvelopeSuccess bool diff --git a/rules/listitem_test.go b/rules/listitem_test.go index 3984444e548..f7e0ccdb4d4 100644 --- a/rules/listitem_test.go +++ b/rules/listitem_test.go @@ -33,55 +33,55 @@ func TestListItemNew(t *testing.T) { "2c0fc9fa937b11eaa1b71c4d701ab86e", rules.ListItemNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]rules.ListItemNewParamsBody{{ + Body: []rules.ListItemNewParamsBody{{ ASN: cloudflare.F(int64(5567)), Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(rules.ListItemNewParamsBodyHostname{ + Hostname: cloudflare.F(rules.HostnameParam{ URLHostname: cloudflare.F("example.com"), }), IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(rules.ListItemNewParamsBodyRedirect{ + Redirect: cloudflare.F(rules.RedirectParam{ IncludeSubdomains: cloudflare.F(true), PreservePathSuffix: cloudflare.F(true), PreserveQueryString: cloudflare.F(true), SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(rules.ListItemNewParamsBodyRedirectStatusCode301), + StatusCode: cloudflare.F(rules.RedirectStatusCode301), SubpathMatching: cloudflare.F(true), TargetURL: cloudflare.F("https://archlinux.org/"), }), }, { ASN: cloudflare.F(int64(5567)), Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(rules.ListItemNewParamsBodyHostname{ + Hostname: cloudflare.F(rules.HostnameParam{ URLHostname: cloudflare.F("example.com"), }), IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(rules.ListItemNewParamsBodyRedirect{ + Redirect: cloudflare.F(rules.RedirectParam{ IncludeSubdomains: cloudflare.F(true), PreservePathSuffix: cloudflare.F(true), PreserveQueryString: cloudflare.F(true), SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(rules.ListItemNewParamsBodyRedirectStatusCode301), + StatusCode: cloudflare.F(rules.RedirectStatusCode301), SubpathMatching: cloudflare.F(true), TargetURL: cloudflare.F("https://archlinux.org/"), }), }, { ASN: cloudflare.F(int64(5567)), Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(rules.ListItemNewParamsBodyHostname{ + Hostname: cloudflare.F(rules.HostnameParam{ URLHostname: cloudflare.F("example.com"), }), IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(rules.ListItemNewParamsBodyRedirect{ + Redirect: cloudflare.F(rules.RedirectParam{ IncludeSubdomains: cloudflare.F(true), PreservePathSuffix: cloudflare.F(true), PreserveQueryString: cloudflare.F(true), SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(rules.ListItemNewParamsBodyRedirectStatusCode301), + StatusCode: cloudflare.F(rules.RedirectStatusCode301), SubpathMatching: cloudflare.F(true), TargetURL: cloudflare.F("https://archlinux.org/"), }), - }}), + }}, }, ) if err != nil { @@ -112,55 +112,55 @@ func TestListItemUpdate(t *testing.T) { "2c0fc9fa937b11eaa1b71c4d701ab86e", rules.ListItemUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]rules.ListItemUpdateParamsBody{{ + Body: []rules.ListItemUpdateParamsBody{{ ASN: cloudflare.F(int64(5567)), Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(rules.ListItemUpdateParamsBodyHostname{ + Hostname: cloudflare.F(rules.HostnameParam{ URLHostname: cloudflare.F("example.com"), }), IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(rules.ListItemUpdateParamsBodyRedirect{ + Redirect: cloudflare.F(rules.RedirectParam{ IncludeSubdomains: cloudflare.F(true), PreservePathSuffix: cloudflare.F(true), PreserveQueryString: cloudflare.F(true), SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(rules.ListItemUpdateParamsBodyRedirectStatusCode301), + StatusCode: cloudflare.F(rules.RedirectStatusCode301), SubpathMatching: cloudflare.F(true), TargetURL: cloudflare.F("https://archlinux.org/"), }), }, { ASN: cloudflare.F(int64(5567)), Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(rules.ListItemUpdateParamsBodyHostname{ + Hostname: cloudflare.F(rules.HostnameParam{ URLHostname: cloudflare.F("example.com"), }), IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(rules.ListItemUpdateParamsBodyRedirect{ + Redirect: cloudflare.F(rules.RedirectParam{ IncludeSubdomains: cloudflare.F(true), PreservePathSuffix: cloudflare.F(true), PreserveQueryString: cloudflare.F(true), SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(rules.ListItemUpdateParamsBodyRedirectStatusCode301), + StatusCode: cloudflare.F(rules.RedirectStatusCode301), SubpathMatching: cloudflare.F(true), TargetURL: cloudflare.F("https://archlinux.org/"), }), }, { ASN: cloudflare.F(int64(5567)), Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(rules.ListItemUpdateParamsBodyHostname{ + Hostname: cloudflare.F(rules.HostnameParam{ URLHostname: cloudflare.F("example.com"), }), IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(rules.ListItemUpdateParamsBodyRedirect{ + Redirect: cloudflare.F(rules.RedirectParam{ IncludeSubdomains: cloudflare.F(true), PreservePathSuffix: cloudflare.F(true), PreserveQueryString: cloudflare.F(true), SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(rules.ListItemUpdateParamsBodyRedirectStatusCode301), + StatusCode: cloudflare.F(rules.RedirectStatusCode301), SubpathMatching: cloudflare.F(true), TargetURL: cloudflare.F("https://archlinux.org/"), }), - }}), + }}, }, ) if err != nil { diff --git a/rulesets/aliases.go b/rulesets/aliases.go index e0aa4e63a6f..6273e15c28c 100644 --- a/rulesets/aliases.go +++ b/rulesets/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/rulesets/phase.go b/rulesets/phase.go index 278d9257b3a..832f27b8bd8 100644 --- a/rulesets/phase.go +++ b/rulesets/phase.go @@ -6,11 +6,14 @@ import ( "context" "fmt" "net/http" + "reflect" + "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // PhaseService contains methods and other services that help with interacting with @@ -33,7 +36,7 @@ func NewPhaseService(opts ...option.RequestOption) (r *PhaseService) { } // Updates an account or zone entry point ruleset, creating a new version. -func (r *PhaseService) Update(ctx context.Context, rulesetPhase PhaseUpdateParamsRulesetPhase, params PhaseUpdateParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *PhaseService) Update(ctx context.Context, rulesetPhase PhaseUpdateParamsRulesetPhase, params PhaseUpdateParams, opts ...option.RequestOption) (res *PhaseUpdateResponse, err error) { opts = append(r.Options[:], opts...) var env PhaseUpdateResponseEnvelope var accountOrZone string @@ -56,7 +59,7 @@ func (r *PhaseService) Update(ctx context.Context, rulesetPhase PhaseUpdateParam // Fetches the latest version of the account or zone entry point ruleset for a // given phase. -func (r *PhaseService) Get(ctx context.Context, rulesetPhase PhaseGetParamsRulesetPhase, query PhaseGetParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *PhaseService) Get(ctx context.Context, rulesetPhase PhaseGetParamsRulesetPhase, query PhaseGetParams, opts ...option.RequestOption) (res *PhaseGetResponse, err error) { opts = append(r.Options[:], opts...) var env PhaseGetResponseEnvelope var accountOrZone string @@ -77,529 +80,688 @@ func (r *PhaseService) Get(ctx context.Context, rulesetPhase PhaseGetParamsRules return } -type PhaseUpdateParams struct { +// A ruleset object. +type PhaseUpdateResponse struct { // The unique ID of the ruleset. - ID param.Field[string] `json:"id,required"` - // The list of rules in the ruleset. - Rules param.Field[[]PhaseUpdateParamsRule] `json:"rules,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. - ZoneID param.Field[string] `path:"zone_id"` - // An informative description of the ruleset. - Description param.Field[string] `json:"description"` + ID string `json:"id,required"` // The kind of the ruleset. - Kind param.Field[PhaseUpdateParamsKind] `json:"kind"` + Kind PhaseUpdateResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // The human-readable name of the ruleset. - Name param.Field[string] `json:"name"` + Name string `json:"name,required"` // The phase of the ruleset. - Phase param.Field[PhaseUpdateParamsPhase] `json:"phase"` + Phase PhaseUpdateResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []PhaseUpdateResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON phaseUpdateResponseJSON `json:"-"` +} + +// phaseUpdateResponseJSON contains the JSON metadata for the struct +// [PhaseUpdateResponse] +type phaseUpdateResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r PhaseUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *PhaseUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The phase of the ruleset. -type PhaseUpdateParamsRulesetPhase string +func (r phaseUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type PhaseUpdateResponseKind string const ( - PhaseUpdateParamsRulesetPhaseDDoSL4 PhaseUpdateParamsRulesetPhase = "ddos_l4" - PhaseUpdateParamsRulesetPhaseDDoSL7 PhaseUpdateParamsRulesetPhase = "ddos_l7" - PhaseUpdateParamsRulesetPhaseHTTPConfigSettings PhaseUpdateParamsRulesetPhase = "http_config_settings" - PhaseUpdateParamsRulesetPhaseHTTPCustomErrors PhaseUpdateParamsRulesetPhase = "http_custom_errors" - PhaseUpdateParamsRulesetPhaseHTTPLogCustomFields PhaseUpdateParamsRulesetPhase = "http_log_custom_fields" - PhaseUpdateParamsRulesetPhaseHTTPRatelimit PhaseUpdateParamsRulesetPhase = "http_ratelimit" - PhaseUpdateParamsRulesetPhaseHTTPRequestCacheSettings PhaseUpdateParamsRulesetPhase = "http_request_cache_settings" - PhaseUpdateParamsRulesetPhaseHTTPRequestDynamicRedirect PhaseUpdateParamsRulesetPhase = "http_request_dynamic_redirect" - PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom PhaseUpdateParamsRulesetPhase = "http_request_firewall_custom" - PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallManaged PhaseUpdateParamsRulesetPhase = "http_request_firewall_managed" - PhaseUpdateParamsRulesetPhaseHTTPRequestLateTransform PhaseUpdateParamsRulesetPhase = "http_request_late_transform" - PhaseUpdateParamsRulesetPhaseHTTPRequestOrigin PhaseUpdateParamsRulesetPhase = "http_request_origin" - PhaseUpdateParamsRulesetPhaseHTTPRequestRedirect PhaseUpdateParamsRulesetPhase = "http_request_redirect" - PhaseUpdateParamsRulesetPhaseHTTPRequestSanitize PhaseUpdateParamsRulesetPhase = "http_request_sanitize" - PhaseUpdateParamsRulesetPhaseHTTPRequestSbfm PhaseUpdateParamsRulesetPhase = "http_request_sbfm" - PhaseUpdateParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseUpdateParamsRulesetPhase = "http_request_select_configuration" - PhaseUpdateParamsRulesetPhaseHTTPRequestTransform PhaseUpdateParamsRulesetPhase = "http_request_transform" - PhaseUpdateParamsRulesetPhaseHTTPResponseCompression PhaseUpdateParamsRulesetPhase = "http_response_compression" - PhaseUpdateParamsRulesetPhaseHTTPResponseFirewallManaged PhaseUpdateParamsRulesetPhase = "http_response_firewall_managed" - PhaseUpdateParamsRulesetPhaseHTTPResponseHeadersTransform PhaseUpdateParamsRulesetPhase = "http_response_headers_transform" - PhaseUpdateParamsRulesetPhaseMagicTransit PhaseUpdateParamsRulesetPhase = "magic_transit" - PhaseUpdateParamsRulesetPhaseMagicTransitIDsManaged PhaseUpdateParamsRulesetPhase = "magic_transit_ids_managed" - PhaseUpdateParamsRulesetPhaseMagicTransitManaged PhaseUpdateParamsRulesetPhase = "magic_transit_managed" + PhaseUpdateResponseKindManaged PhaseUpdateResponseKind = "managed" + PhaseUpdateResponseKindCustom PhaseUpdateResponseKind = "custom" + PhaseUpdateResponseKindRoot PhaseUpdateResponseKind = "root" + PhaseUpdateResponseKindZone PhaseUpdateResponseKind = "zone" ) -func (r PhaseUpdateParamsRulesetPhase) IsKnown() bool { +func (r PhaseUpdateResponseKind) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesetPhaseDDoSL4, PhaseUpdateParamsRulesetPhaseDDoSL7, PhaseUpdateParamsRulesetPhaseHTTPConfigSettings, PhaseUpdateParamsRulesetPhaseHTTPCustomErrors, PhaseUpdateParamsRulesetPhaseHTTPLogCustomFields, PhaseUpdateParamsRulesetPhaseHTTPRatelimit, PhaseUpdateParamsRulesetPhaseHTTPRequestCacheSettings, PhaseUpdateParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseUpdateParamsRulesetPhaseHTTPRequestLateTransform, PhaseUpdateParamsRulesetPhaseHTTPRequestOrigin, PhaseUpdateParamsRulesetPhaseHTTPRequestRedirect, PhaseUpdateParamsRulesetPhaseHTTPRequestSanitize, PhaseUpdateParamsRulesetPhaseHTTPRequestSbfm, PhaseUpdateParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseUpdateParamsRulesetPhaseHTTPRequestTransform, PhaseUpdateParamsRulesetPhaseHTTPResponseCompression, PhaseUpdateParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseUpdateParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseUpdateParamsRulesetPhaseMagicTransit, PhaseUpdateParamsRulesetPhaseMagicTransitIDsManaged, PhaseUpdateParamsRulesetPhaseMagicTransitManaged: + case PhaseUpdateResponseKindManaged, PhaseUpdateResponseKindCustom, PhaseUpdateResponseKindRoot, PhaseUpdateResponseKindZone: return true } return false } -// Satisfied by [rulesets.PhaseUpdateParamsRulesRulesetsBlockRule], -// [rulesets.PhaseUpdateParamsRulesRulesetsExecuteRule], -// [rulesets.PhaseUpdateParamsRulesRulesetsLogRule], -// [rulesets.PhaseUpdateParamsRulesRulesetsSkipRule]. -type PhaseUpdateParamsRule interface { - implementsRulesetsPhaseUpdateParamsRule() -} - -type PhaseUpdateParamsRulesRulesetsBlockRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r PhaseUpdateParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r PhaseUpdateParamsRulesRulesetsBlockRule) implementsRulesetsPhaseUpdateParamsRule() {} - -// The action to perform when the rule matches. -type PhaseUpdateParamsRulesRulesetsBlockRuleAction string +// The phase of the ruleset. +type PhaseUpdateResponsePhase string const ( - PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock PhaseUpdateParamsRulesRulesetsBlockRuleAction = "block" + PhaseUpdateResponsePhaseDDoSL4 PhaseUpdateResponsePhase = "ddos_l4" + PhaseUpdateResponsePhaseDDoSL7 PhaseUpdateResponsePhase = "ddos_l7" + PhaseUpdateResponsePhaseHTTPConfigSettings PhaseUpdateResponsePhase = "http_config_settings" + PhaseUpdateResponsePhaseHTTPCustomErrors PhaseUpdateResponsePhase = "http_custom_errors" + PhaseUpdateResponsePhaseHTTPLogCustomFields PhaseUpdateResponsePhase = "http_log_custom_fields" + PhaseUpdateResponsePhaseHTTPRatelimit PhaseUpdateResponsePhase = "http_ratelimit" + PhaseUpdateResponsePhaseHTTPRequestCacheSettings PhaseUpdateResponsePhase = "http_request_cache_settings" + PhaseUpdateResponsePhaseHTTPRequestDynamicRedirect PhaseUpdateResponsePhase = "http_request_dynamic_redirect" + PhaseUpdateResponsePhaseHTTPRequestFirewallCustom PhaseUpdateResponsePhase = "http_request_firewall_custom" + PhaseUpdateResponsePhaseHTTPRequestFirewallManaged PhaseUpdateResponsePhase = "http_request_firewall_managed" + PhaseUpdateResponsePhaseHTTPRequestLateTransform PhaseUpdateResponsePhase = "http_request_late_transform" + PhaseUpdateResponsePhaseHTTPRequestOrigin PhaseUpdateResponsePhase = "http_request_origin" + PhaseUpdateResponsePhaseHTTPRequestRedirect PhaseUpdateResponsePhase = "http_request_redirect" + PhaseUpdateResponsePhaseHTTPRequestSanitize PhaseUpdateResponsePhase = "http_request_sanitize" + PhaseUpdateResponsePhaseHTTPRequestSBFM PhaseUpdateResponsePhase = "http_request_sbfm" + PhaseUpdateResponsePhaseHTTPRequestSelectConfiguration PhaseUpdateResponsePhase = "http_request_select_configuration" + PhaseUpdateResponsePhaseHTTPRequestTransform PhaseUpdateResponsePhase = "http_request_transform" + PhaseUpdateResponsePhaseHTTPResponseCompression PhaseUpdateResponsePhase = "http_response_compression" + PhaseUpdateResponsePhaseHTTPResponseFirewallManaged PhaseUpdateResponsePhase = "http_response_firewall_managed" + PhaseUpdateResponsePhaseHTTPResponseHeadersTransform PhaseUpdateResponsePhase = "http_response_headers_transform" + PhaseUpdateResponsePhaseMagicTransit PhaseUpdateResponsePhase = "magic_transit" + PhaseUpdateResponsePhaseMagicTransitIDsManaged PhaseUpdateResponsePhase = "magic_transit_ids_managed" + PhaseUpdateResponsePhaseMagicTransitManaged PhaseUpdateResponsePhase = "magic_transit_managed" ) -func (r PhaseUpdateParamsRulesRulesetsBlockRuleAction) IsKnown() bool { +func (r PhaseUpdateResponsePhase) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock: + case PhaseUpdateResponsePhaseDDoSL4, PhaseUpdateResponsePhaseDDoSL7, PhaseUpdateResponsePhaseHTTPConfigSettings, PhaseUpdateResponsePhaseHTTPCustomErrors, PhaseUpdateResponsePhaseHTTPLogCustomFields, PhaseUpdateResponsePhaseHTTPRatelimit, PhaseUpdateResponsePhaseHTTPRequestCacheSettings, PhaseUpdateResponsePhaseHTTPRequestDynamicRedirect, PhaseUpdateResponsePhaseHTTPRequestFirewallCustom, PhaseUpdateResponsePhaseHTTPRequestFirewallManaged, PhaseUpdateResponsePhaseHTTPRequestLateTransform, PhaseUpdateResponsePhaseHTTPRequestOrigin, PhaseUpdateResponsePhaseHTTPRequestRedirect, PhaseUpdateResponsePhaseHTTPRequestSanitize, PhaseUpdateResponsePhaseHTTPRequestSBFM, PhaseUpdateResponsePhaseHTTPRequestSelectConfiguration, PhaseUpdateResponsePhaseHTTPRequestTransform, PhaseUpdateResponsePhaseHTTPResponseCompression, PhaseUpdateResponsePhaseHTTPResponseFirewallManaged, PhaseUpdateResponsePhaseHTTPResponseHeadersTransform, PhaseUpdateResponsePhaseMagicTransit, PhaseUpdateResponsePhaseMagicTransitIDsManaged, PhaseUpdateResponsePhaseMagicTransitManaged: return true } return false } -// The parameters configuring the rule's action. -type PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` -} - -func (r PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response to show when the block is applied. -type PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content param.Field[string] `json:"content,required"` - // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` - // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` -} - -func (r PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring the rule's logging behavior. -type PhaseUpdateParamsRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r PhaseUpdateParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PhaseUpdateParamsRulesRulesetsExecuteRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` +type PhaseUpdateResponseRule struct { // The action to perform when the rule matches. - Action param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` + Action PhaseUpdateResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` // An informative description of the rule. - Description param.Field[string] `json:"description"` + Description string `json:"description"` // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` + Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // An object configuring the rule's logging behavior. - Logging param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON phaseUpdateResponseRuleJSON `json:"-"` + union PhaseUpdateResponseRulesUnion +} + +// phaseUpdateResponseRuleJSON contains the JSON metadata for the struct +// [PhaseUpdateResponseRule] +type phaseUpdateResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r phaseUpdateResponseRuleJSON) RawJSON() string { + return r.raw } -func (r PhaseUpdateParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *PhaseUpdateResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r PhaseUpdateResponseRule) AsUnion() PhaseUpdateResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type PhaseUpdateResponseRulesUnion interface { + implementsRulesetsPhaseUpdateResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PhaseUpdateResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) } -func (r PhaseUpdateParamsRulesRulesetsExecuteRule) implementsRulesetsPhaseUpdateParamsRule() {} - // The action to perform when the rule matches. -type PhaseUpdateParamsRulesRulesetsExecuteRuleAction string +type PhaseUpdateResponseRulesAction string const ( - PhaseUpdateParamsRulesRulesetsExecuteRuleActionExecute PhaseUpdateParamsRulesRulesetsExecuteRuleAction = "execute" + PhaseUpdateResponseRulesActionBlock PhaseUpdateResponseRulesAction = "block" + PhaseUpdateResponseRulesActionChallenge PhaseUpdateResponseRulesAction = "challenge" + PhaseUpdateResponseRulesActionCompressResponse PhaseUpdateResponseRulesAction = "compress_response" + PhaseUpdateResponseRulesActionExecute PhaseUpdateResponseRulesAction = "execute" + PhaseUpdateResponseRulesActionJSChallenge PhaseUpdateResponseRulesAction = "js_challenge" + PhaseUpdateResponseRulesActionLog PhaseUpdateResponseRulesAction = "log" + PhaseUpdateResponseRulesActionManagedChallenge PhaseUpdateResponseRulesAction = "managed_challenge" + PhaseUpdateResponseRulesActionRedirect PhaseUpdateResponseRulesAction = "redirect" + PhaseUpdateResponseRulesActionRewrite PhaseUpdateResponseRulesAction = "rewrite" + PhaseUpdateResponseRulesActionRoute PhaseUpdateResponseRulesAction = "route" + PhaseUpdateResponseRulesActionScore PhaseUpdateResponseRulesAction = "score" + PhaseUpdateResponseRulesActionServeError PhaseUpdateResponseRulesAction = "serve_error" + PhaseUpdateResponseRulesActionSetConfig PhaseUpdateResponseRulesAction = "set_config" + PhaseUpdateResponseRulesActionSkip PhaseUpdateResponseRulesAction = "skip" + PhaseUpdateResponseRulesActionSetCacheSettings PhaseUpdateResponseRulesAction = "set_cache_settings" ) -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleAction) IsKnown() bool { +func (r PhaseUpdateResponseRulesAction) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesRulesetsExecuteRuleActionExecute: + case PhaseUpdateResponseRulesActionBlock, PhaseUpdateResponseRulesActionChallenge, PhaseUpdateResponseRulesActionCompressResponse, PhaseUpdateResponseRulesActionExecute, PhaseUpdateResponseRulesActionJSChallenge, PhaseUpdateResponseRulesActionLog, PhaseUpdateResponseRulesActionManagedChallenge, PhaseUpdateResponseRulesActionRedirect, PhaseUpdateResponseRulesActionRewrite, PhaseUpdateResponseRulesActionRoute, PhaseUpdateResponseRulesActionScore, PhaseUpdateResponseRulesActionServeError, PhaseUpdateResponseRulesActionSetConfig, PhaseUpdateResponseRulesActionSkip, PhaseUpdateResponseRulesActionSetCacheSettings: return true } return false } -// The parameters configuring the rule's action. -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` -} - -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration to use for matched data logging. -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` -} - -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A set of overrides to apply to the target ruleset. -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A category-level override -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for rules in the category. -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel) IsKnown() bool { - switch r { - case PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff: - return true - } - return false +// A ruleset object. +type PhaseGetResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind PhaseGetResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase PhaseGetResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []PhaseGetResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON phaseGetResponseJSON `json:"-"` +} + +// phaseGetResponseJSON contains the JSON metadata for the struct +// [PhaseGetResponse] +type phaseGetResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// A rule-level override -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` +func (r *PhaseGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r phaseGetResponseJSON) RawJSON() string { + return r.raw } -// The sensitivity level to use for the rule. -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string +// The kind of the ruleset. +type PhaseGetResponseKind string const ( - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" + PhaseGetResponseKindManaged PhaseGetResponseKind = "managed" + PhaseGetResponseKindCustom PhaseGetResponseKind = "custom" + PhaseGetResponseKindRoot PhaseGetResponseKind = "root" + PhaseGetResponseKindZone PhaseGetResponseKind = "zone" ) -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel) IsKnown() bool { +func (r PhaseGetResponseKind) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff: + case PhaseGetResponseKindManaged, PhaseGetResponseKindCustom, PhaseGetResponseKindRoot, PhaseGetResponseKindZone: return true } return false } -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string +// The phase of the ruleset. +type PhaseGetResponsePhase string const ( - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" + PhaseGetResponsePhaseDDoSL4 PhaseGetResponsePhase = "ddos_l4" + PhaseGetResponsePhaseDDoSL7 PhaseGetResponsePhase = "ddos_l7" + PhaseGetResponsePhaseHTTPConfigSettings PhaseGetResponsePhase = "http_config_settings" + PhaseGetResponsePhaseHTTPCustomErrors PhaseGetResponsePhase = "http_custom_errors" + PhaseGetResponsePhaseHTTPLogCustomFields PhaseGetResponsePhase = "http_log_custom_fields" + PhaseGetResponsePhaseHTTPRatelimit PhaseGetResponsePhase = "http_ratelimit" + PhaseGetResponsePhaseHTTPRequestCacheSettings PhaseGetResponsePhase = "http_request_cache_settings" + PhaseGetResponsePhaseHTTPRequestDynamicRedirect PhaseGetResponsePhase = "http_request_dynamic_redirect" + PhaseGetResponsePhaseHTTPRequestFirewallCustom PhaseGetResponsePhase = "http_request_firewall_custom" + PhaseGetResponsePhaseHTTPRequestFirewallManaged PhaseGetResponsePhase = "http_request_firewall_managed" + PhaseGetResponsePhaseHTTPRequestLateTransform PhaseGetResponsePhase = "http_request_late_transform" + PhaseGetResponsePhaseHTTPRequestOrigin PhaseGetResponsePhase = "http_request_origin" + PhaseGetResponsePhaseHTTPRequestRedirect PhaseGetResponsePhase = "http_request_redirect" + PhaseGetResponsePhaseHTTPRequestSanitize PhaseGetResponsePhase = "http_request_sanitize" + PhaseGetResponsePhaseHTTPRequestSBFM PhaseGetResponsePhase = "http_request_sbfm" + PhaseGetResponsePhaseHTTPRequestSelectConfiguration PhaseGetResponsePhase = "http_request_select_configuration" + PhaseGetResponsePhaseHTTPRequestTransform PhaseGetResponsePhase = "http_request_transform" + PhaseGetResponsePhaseHTTPResponseCompression PhaseGetResponsePhase = "http_response_compression" + PhaseGetResponsePhaseHTTPResponseFirewallManaged PhaseGetResponsePhase = "http_response_firewall_managed" + PhaseGetResponsePhaseHTTPResponseHeadersTransform PhaseGetResponsePhase = "http_response_headers_transform" + PhaseGetResponsePhaseMagicTransit PhaseGetResponsePhase = "magic_transit" + PhaseGetResponsePhaseMagicTransitIDsManaged PhaseGetResponsePhase = "magic_transit_ids_managed" + PhaseGetResponsePhaseMagicTransitManaged PhaseGetResponsePhase = "magic_transit_managed" ) -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel) IsKnown() bool { +func (r PhaseGetResponsePhase) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow, PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff: + case PhaseGetResponsePhaseDDoSL4, PhaseGetResponsePhaseDDoSL7, PhaseGetResponsePhaseHTTPConfigSettings, PhaseGetResponsePhaseHTTPCustomErrors, PhaseGetResponsePhaseHTTPLogCustomFields, PhaseGetResponsePhaseHTTPRatelimit, PhaseGetResponsePhaseHTTPRequestCacheSettings, PhaseGetResponsePhaseHTTPRequestDynamicRedirect, PhaseGetResponsePhaseHTTPRequestFirewallCustom, PhaseGetResponsePhaseHTTPRequestFirewallManaged, PhaseGetResponsePhaseHTTPRequestLateTransform, PhaseGetResponsePhaseHTTPRequestOrigin, PhaseGetResponsePhaseHTTPRequestRedirect, PhaseGetResponsePhaseHTTPRequestSanitize, PhaseGetResponsePhaseHTTPRequestSBFM, PhaseGetResponsePhaseHTTPRequestSelectConfiguration, PhaseGetResponsePhaseHTTPRequestTransform, PhaseGetResponsePhaseHTTPResponseCompression, PhaseGetResponsePhaseHTTPResponseFirewallManaged, PhaseGetResponsePhaseHTTPResponseHeadersTransform, PhaseGetResponsePhaseMagicTransit, PhaseGetResponsePhaseMagicTransitIDsManaged, PhaseGetResponsePhaseMagicTransitManaged: return true } return false } -// An object configuring the rule's logging behavior. -type PhaseUpdateParamsRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r PhaseUpdateParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PhaseUpdateParamsRulesRulesetsLogRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` +type PhaseGetResponseRule struct { // The action to perform when the rule matches. - Action param.Field[PhaseUpdateParamsRulesRulesetsLogRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` + Action PhaseGetResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` // An informative description of the rule. - Description param.Field[string] `json:"description"` + Description string `json:"description"` // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` + Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // An object configuring the rule's logging behavior. - Logging param.Field[PhaseUpdateParamsRulesRulesetsLogRuleLogging] `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON phaseGetResponseRuleJSON `json:"-"` + union PhaseGetResponseRulesUnion +} + +// phaseGetResponseRuleJSON contains the JSON metadata for the struct +// [PhaseGetResponseRule] +type phaseGetResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r phaseGetResponseRuleJSON) RawJSON() string { + return r.raw } -func (r PhaseUpdateParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *PhaseGetResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r PhaseGetResponseRule) AsUnion() PhaseGetResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type PhaseGetResponseRulesUnion interface { + implementsRulesetsPhaseGetResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PhaseGetResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) } -func (r PhaseUpdateParamsRulesRulesetsLogRule) implementsRulesetsPhaseUpdateParamsRule() {} - // The action to perform when the rule matches. -type PhaseUpdateParamsRulesRulesetsLogRuleAction string +type PhaseGetResponseRulesAction string const ( - PhaseUpdateParamsRulesRulesetsLogRuleActionLog PhaseUpdateParamsRulesRulesetsLogRuleAction = "log" + PhaseGetResponseRulesActionBlock PhaseGetResponseRulesAction = "block" + PhaseGetResponseRulesActionChallenge PhaseGetResponseRulesAction = "challenge" + PhaseGetResponseRulesActionCompressResponse PhaseGetResponseRulesAction = "compress_response" + PhaseGetResponseRulesActionExecute PhaseGetResponseRulesAction = "execute" + PhaseGetResponseRulesActionJSChallenge PhaseGetResponseRulesAction = "js_challenge" + PhaseGetResponseRulesActionLog PhaseGetResponseRulesAction = "log" + PhaseGetResponseRulesActionManagedChallenge PhaseGetResponseRulesAction = "managed_challenge" + PhaseGetResponseRulesActionRedirect PhaseGetResponseRulesAction = "redirect" + PhaseGetResponseRulesActionRewrite PhaseGetResponseRulesAction = "rewrite" + PhaseGetResponseRulesActionRoute PhaseGetResponseRulesAction = "route" + PhaseGetResponseRulesActionScore PhaseGetResponseRulesAction = "score" + PhaseGetResponseRulesActionServeError PhaseGetResponseRulesAction = "serve_error" + PhaseGetResponseRulesActionSetConfig PhaseGetResponseRulesAction = "set_config" + PhaseGetResponseRulesActionSkip PhaseGetResponseRulesAction = "skip" + PhaseGetResponseRulesActionSetCacheSettings PhaseGetResponseRulesAction = "set_cache_settings" ) -func (r PhaseUpdateParamsRulesRulesetsLogRuleAction) IsKnown() bool { +func (r PhaseGetResponseRulesAction) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesRulesetsLogRuleActionLog: + case PhaseGetResponseRulesActionBlock, PhaseGetResponseRulesActionChallenge, PhaseGetResponseRulesActionCompressResponse, PhaseGetResponseRulesActionExecute, PhaseGetResponseRulesActionJSChallenge, PhaseGetResponseRulesActionLog, PhaseGetResponseRulesActionManagedChallenge, PhaseGetResponseRulesActionRedirect, PhaseGetResponseRulesActionRewrite, PhaseGetResponseRulesActionRoute, PhaseGetResponseRulesActionScore, PhaseGetResponseRulesActionServeError, PhaseGetResponseRulesActionSetConfig, PhaseGetResponseRulesActionSkip, PhaseGetResponseRulesActionSetCacheSettings: return true } return false } -// An object configuring the rule's logging behavior. -type PhaseUpdateParamsRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r PhaseUpdateParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PhaseUpdateParamsRulesRulesetsSkipRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. +type PhaseUpdateParams struct { + // The list of rules in the ruleset. + Rules param.Field[[]PhaseUpdateParamsRuleUnion] `json:"rules,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. + ZoneID param.Field[string] `path:"zone_id"` + // An informative description of the ruleset. Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` + // The kind of the ruleset. + Kind param.Field[PhaseUpdateParamsKind] `json:"kind"` + // The human-readable name of the ruleset. + Name param.Field[string] `json:"name"` + // The phase of the ruleset. + Phase param.Field[PhaseUpdateParamsPhase] `json:"phase"` } -func (r PhaseUpdateParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { +func (r PhaseUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r PhaseUpdateParamsRulesRulesetsSkipRule) implementsRulesetsPhaseUpdateParamsRule() {} - -// The action to perform when the rule matches. -type PhaseUpdateParamsRulesRulesetsSkipRuleAction string +// The phase of the ruleset. +type PhaseUpdateParamsRulesetPhase string const ( - PhaseUpdateParamsRulesRulesetsSkipRuleActionSkip PhaseUpdateParamsRulesRulesetsSkipRuleAction = "skip" + PhaseUpdateParamsRulesetPhaseDDoSL4 PhaseUpdateParamsRulesetPhase = "ddos_l4" + PhaseUpdateParamsRulesetPhaseDDoSL7 PhaseUpdateParamsRulesetPhase = "ddos_l7" + PhaseUpdateParamsRulesetPhaseHTTPConfigSettings PhaseUpdateParamsRulesetPhase = "http_config_settings" + PhaseUpdateParamsRulesetPhaseHTTPCustomErrors PhaseUpdateParamsRulesetPhase = "http_custom_errors" + PhaseUpdateParamsRulesetPhaseHTTPLogCustomFields PhaseUpdateParamsRulesetPhase = "http_log_custom_fields" + PhaseUpdateParamsRulesetPhaseHTTPRatelimit PhaseUpdateParamsRulesetPhase = "http_ratelimit" + PhaseUpdateParamsRulesetPhaseHTTPRequestCacheSettings PhaseUpdateParamsRulesetPhase = "http_request_cache_settings" + PhaseUpdateParamsRulesetPhaseHTTPRequestDynamicRedirect PhaseUpdateParamsRulesetPhase = "http_request_dynamic_redirect" + PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom PhaseUpdateParamsRulesetPhase = "http_request_firewall_custom" + PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallManaged PhaseUpdateParamsRulesetPhase = "http_request_firewall_managed" + PhaseUpdateParamsRulesetPhaseHTTPRequestLateTransform PhaseUpdateParamsRulesetPhase = "http_request_late_transform" + PhaseUpdateParamsRulesetPhaseHTTPRequestOrigin PhaseUpdateParamsRulesetPhase = "http_request_origin" + PhaseUpdateParamsRulesetPhaseHTTPRequestRedirect PhaseUpdateParamsRulesetPhase = "http_request_redirect" + PhaseUpdateParamsRulesetPhaseHTTPRequestSanitize PhaseUpdateParamsRulesetPhase = "http_request_sanitize" + PhaseUpdateParamsRulesetPhaseHTTPRequestSBFM PhaseUpdateParamsRulesetPhase = "http_request_sbfm" + PhaseUpdateParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseUpdateParamsRulesetPhase = "http_request_select_configuration" + PhaseUpdateParamsRulesetPhaseHTTPRequestTransform PhaseUpdateParamsRulesetPhase = "http_request_transform" + PhaseUpdateParamsRulesetPhaseHTTPResponseCompression PhaseUpdateParamsRulesetPhase = "http_response_compression" + PhaseUpdateParamsRulesetPhaseHTTPResponseFirewallManaged PhaseUpdateParamsRulesetPhase = "http_response_firewall_managed" + PhaseUpdateParamsRulesetPhaseHTTPResponseHeadersTransform PhaseUpdateParamsRulesetPhase = "http_response_headers_transform" + PhaseUpdateParamsRulesetPhaseMagicTransit PhaseUpdateParamsRulesetPhase = "magic_transit" + PhaseUpdateParamsRulesetPhaseMagicTransitIDsManaged PhaseUpdateParamsRulesetPhase = "magic_transit_ids_managed" + PhaseUpdateParamsRulesetPhaseMagicTransitManaged PhaseUpdateParamsRulesetPhase = "magic_transit_managed" ) -func (r PhaseUpdateParamsRulesRulesetsSkipRuleAction) IsKnown() bool { +func (r PhaseUpdateParamsRulesetPhase) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesRulesetsSkipRuleActionSkip: + case PhaseUpdateParamsRulesetPhaseDDoSL4, PhaseUpdateParamsRulesetPhaseDDoSL7, PhaseUpdateParamsRulesetPhaseHTTPConfigSettings, PhaseUpdateParamsRulesetPhaseHTTPCustomErrors, PhaseUpdateParamsRulesetPhaseHTTPLogCustomFields, PhaseUpdateParamsRulesetPhaseHTTPRatelimit, PhaseUpdateParamsRulesetPhaseHTTPRequestCacheSettings, PhaseUpdateParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseUpdateParamsRulesetPhaseHTTPRequestLateTransform, PhaseUpdateParamsRulesetPhaseHTTPRequestOrigin, PhaseUpdateParamsRulesetPhaseHTTPRequestRedirect, PhaseUpdateParamsRulesetPhaseHTTPRequestSanitize, PhaseUpdateParamsRulesetPhaseHTTPRequestSBFM, PhaseUpdateParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseUpdateParamsRulesetPhaseHTTPRequestTransform, PhaseUpdateParamsRulesetPhaseHTTPResponseCompression, PhaseUpdateParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseUpdateParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseUpdateParamsRulesetPhaseMagicTransit, PhaseUpdateParamsRulesetPhaseMagicTransitIDsManaged, PhaseUpdateParamsRulesetPhaseMagicTransitManaged: return true } return false } -// The parameters configuring the rule's action. -type PhaseUpdateParamsRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` -} - -func (r PhaseUpdateParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type PhaseUpdateParamsRule struct { + // The action to perform when the rule matches. + Action param.Field[PhaseUpdateParamsRulesAction] `json:"action"` + ActionParameters param.Field[interface{}] `json:"action_parameters,required"` + Categories param.Field[interface{}] `json:"categories,required"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` } -// A phase to skip the execution of. -type PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase string - -const ( - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL4 PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL7 PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -func (r PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase) IsKnown() bool { - switch r { - case PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL4, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL7, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged: - return true - } - return false +func (r PhaseUpdateParamsRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// The name of a legacy security product to skip the execution of. -type PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct string - -const ( - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) +func (r PhaseUpdateParamsRule) implementsRulesetsPhaseUpdateParamsRuleUnion() {} -func (r PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct) IsKnown() bool { - switch r { - case PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF, PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown: - return true - } - return false +// Satisfied by [rulesets.BlockRuleParam], [rulesets.ChallengeRuleParam], +// [rulesets.CompressResponseRuleParam], [rulesets.ExecuteRuleParam], +// [rulesets.JSChallengeRuleParam], [rulesets.LogRuleParam], +// [rulesets.ManagedChallengeRuleParam], [rulesets.RedirectRuleParam], +// [rulesets.RewriteRuleParam], [rulesets.RouteRuleParam], +// [rulesets.ScoreRuleParam], [rulesets.ServeErrorRuleParam], +// [rulesets.SetConfigRuleParam], [rulesets.SkipRuleParam], +// [rulesets.SetCacheSettingsRuleParam], [PhaseUpdateParamsRule]. +type PhaseUpdateParamsRuleUnion interface { + implementsRulesetsPhaseUpdateParamsRuleUnion() } -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset string +// The action to perform when the rule matches. +type PhaseUpdateParamsRulesAction string const ( - PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" + PhaseUpdateParamsRulesActionBlock PhaseUpdateParamsRulesAction = "block" + PhaseUpdateParamsRulesActionChallenge PhaseUpdateParamsRulesAction = "challenge" + PhaseUpdateParamsRulesActionCompressResponse PhaseUpdateParamsRulesAction = "compress_response" + PhaseUpdateParamsRulesActionExecute PhaseUpdateParamsRulesAction = "execute" + PhaseUpdateParamsRulesActionJSChallenge PhaseUpdateParamsRulesAction = "js_challenge" + PhaseUpdateParamsRulesActionLog PhaseUpdateParamsRulesAction = "log" + PhaseUpdateParamsRulesActionManagedChallenge PhaseUpdateParamsRulesAction = "managed_challenge" + PhaseUpdateParamsRulesActionRedirect PhaseUpdateParamsRulesAction = "redirect" + PhaseUpdateParamsRulesActionRewrite PhaseUpdateParamsRulesAction = "rewrite" + PhaseUpdateParamsRulesActionRoute PhaseUpdateParamsRulesAction = "route" + PhaseUpdateParamsRulesActionScore PhaseUpdateParamsRulesAction = "score" + PhaseUpdateParamsRulesActionServeError PhaseUpdateParamsRulesAction = "serve_error" + PhaseUpdateParamsRulesActionSetConfig PhaseUpdateParamsRulesAction = "set_config" + PhaseUpdateParamsRulesActionSkip PhaseUpdateParamsRulesAction = "skip" + PhaseUpdateParamsRulesActionSetCacheSettings PhaseUpdateParamsRulesAction = "set_cache_settings" ) -func (r PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset) IsKnown() bool { +func (r PhaseUpdateParamsRulesAction) IsKnown() bool { switch r { - case PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent: + case PhaseUpdateParamsRulesActionBlock, PhaseUpdateParamsRulesActionChallenge, PhaseUpdateParamsRulesActionCompressResponse, PhaseUpdateParamsRulesActionExecute, PhaseUpdateParamsRulesActionJSChallenge, PhaseUpdateParamsRulesActionLog, PhaseUpdateParamsRulesActionManagedChallenge, PhaseUpdateParamsRulesActionRedirect, PhaseUpdateParamsRulesActionRewrite, PhaseUpdateParamsRulesActionRoute, PhaseUpdateParamsRulesActionScore, PhaseUpdateParamsRulesActionServeError, PhaseUpdateParamsRulesActionSetConfig, PhaseUpdateParamsRulesActionSkip, PhaseUpdateParamsRulesActionSetCacheSettings: return true } return false } -// An object configuring the rule's logging behavior. -type PhaseUpdateParamsRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r PhaseUpdateParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // The kind of the ruleset. type PhaseUpdateParamsKind string @@ -636,7 +798,7 @@ const ( PhaseUpdateParamsPhaseHTTPRequestOrigin PhaseUpdateParamsPhase = "http_request_origin" PhaseUpdateParamsPhaseHTTPRequestRedirect PhaseUpdateParamsPhase = "http_request_redirect" PhaseUpdateParamsPhaseHTTPRequestSanitize PhaseUpdateParamsPhase = "http_request_sanitize" - PhaseUpdateParamsPhaseHTTPRequestSbfm PhaseUpdateParamsPhase = "http_request_sbfm" + PhaseUpdateParamsPhaseHTTPRequestSBFM PhaseUpdateParamsPhase = "http_request_sbfm" PhaseUpdateParamsPhaseHTTPRequestSelectConfiguration PhaseUpdateParamsPhase = "http_request_select_configuration" PhaseUpdateParamsPhaseHTTPRequestTransform PhaseUpdateParamsPhase = "http_request_transform" PhaseUpdateParamsPhaseHTTPResponseCompression PhaseUpdateParamsPhase = "http_response_compression" @@ -649,7 +811,7 @@ const ( func (r PhaseUpdateParamsPhase) IsKnown() bool { switch r { - case PhaseUpdateParamsPhaseDDoSL4, PhaseUpdateParamsPhaseDDoSL7, PhaseUpdateParamsPhaseHTTPConfigSettings, PhaseUpdateParamsPhaseHTTPCustomErrors, PhaseUpdateParamsPhaseHTTPLogCustomFields, PhaseUpdateParamsPhaseHTTPRatelimit, PhaseUpdateParamsPhaseHTTPRequestCacheSettings, PhaseUpdateParamsPhaseHTTPRequestDynamicRedirect, PhaseUpdateParamsPhaseHTTPRequestFirewallCustom, PhaseUpdateParamsPhaseHTTPRequestFirewallManaged, PhaseUpdateParamsPhaseHTTPRequestLateTransform, PhaseUpdateParamsPhaseHTTPRequestOrigin, PhaseUpdateParamsPhaseHTTPRequestRedirect, PhaseUpdateParamsPhaseHTTPRequestSanitize, PhaseUpdateParamsPhaseHTTPRequestSbfm, PhaseUpdateParamsPhaseHTTPRequestSelectConfiguration, PhaseUpdateParamsPhaseHTTPRequestTransform, PhaseUpdateParamsPhaseHTTPResponseCompression, PhaseUpdateParamsPhaseHTTPResponseFirewallManaged, PhaseUpdateParamsPhaseHTTPResponseHeadersTransform, PhaseUpdateParamsPhaseMagicTransit, PhaseUpdateParamsPhaseMagicTransitIDsManaged, PhaseUpdateParamsPhaseMagicTransitManaged: + case PhaseUpdateParamsPhaseDDoSL4, PhaseUpdateParamsPhaseDDoSL7, PhaseUpdateParamsPhaseHTTPConfigSettings, PhaseUpdateParamsPhaseHTTPCustomErrors, PhaseUpdateParamsPhaseHTTPLogCustomFields, PhaseUpdateParamsPhaseHTTPRatelimit, PhaseUpdateParamsPhaseHTTPRequestCacheSettings, PhaseUpdateParamsPhaseHTTPRequestDynamicRedirect, PhaseUpdateParamsPhaseHTTPRequestFirewallCustom, PhaseUpdateParamsPhaseHTTPRequestFirewallManaged, PhaseUpdateParamsPhaseHTTPRequestLateTransform, PhaseUpdateParamsPhaseHTTPRequestOrigin, PhaseUpdateParamsPhaseHTTPRequestRedirect, PhaseUpdateParamsPhaseHTTPRequestSanitize, PhaseUpdateParamsPhaseHTTPRequestSBFM, PhaseUpdateParamsPhaseHTTPRequestSelectConfiguration, PhaseUpdateParamsPhaseHTTPRequestTransform, PhaseUpdateParamsPhaseHTTPResponseCompression, PhaseUpdateParamsPhaseHTTPResponseFirewallManaged, PhaseUpdateParamsPhaseHTTPResponseHeadersTransform, PhaseUpdateParamsPhaseMagicTransit, PhaseUpdateParamsPhaseMagicTransitIDsManaged, PhaseUpdateParamsPhaseMagicTransitManaged: return true } return false @@ -661,8 +823,8 @@ type PhaseUpdateResponseEnvelope struct { Errors []PhaseUpdateResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []PhaseUpdateResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result PhaseUpdateResponse `json:"result,required"` // Whether the API call was successful. Success PhaseUpdateResponseEnvelopeSuccess `json:"success,required"` JSON phaseUpdateResponseEnvelopeJSON `json:"-"` @@ -831,7 +993,7 @@ const ( PhaseGetParamsRulesetPhaseHTTPRequestOrigin PhaseGetParamsRulesetPhase = "http_request_origin" PhaseGetParamsRulesetPhaseHTTPRequestRedirect PhaseGetParamsRulesetPhase = "http_request_redirect" PhaseGetParamsRulesetPhaseHTTPRequestSanitize PhaseGetParamsRulesetPhase = "http_request_sanitize" - PhaseGetParamsRulesetPhaseHTTPRequestSbfm PhaseGetParamsRulesetPhase = "http_request_sbfm" + PhaseGetParamsRulesetPhaseHTTPRequestSBFM PhaseGetParamsRulesetPhase = "http_request_sbfm" PhaseGetParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseGetParamsRulesetPhase = "http_request_select_configuration" PhaseGetParamsRulesetPhaseHTTPRequestTransform PhaseGetParamsRulesetPhase = "http_request_transform" PhaseGetParamsRulesetPhaseHTTPResponseCompression PhaseGetParamsRulesetPhase = "http_response_compression" @@ -844,7 +1006,7 @@ const ( func (r PhaseGetParamsRulesetPhase) IsKnown() bool { switch r { - case PhaseGetParamsRulesetPhaseDDoSL4, PhaseGetParamsRulesetPhaseDDoSL7, PhaseGetParamsRulesetPhaseHTTPConfigSettings, PhaseGetParamsRulesetPhaseHTTPCustomErrors, PhaseGetParamsRulesetPhaseHTTPLogCustomFields, PhaseGetParamsRulesetPhaseHTTPRatelimit, PhaseGetParamsRulesetPhaseHTTPRequestCacheSettings, PhaseGetParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseGetParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseGetParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseGetParamsRulesetPhaseHTTPRequestLateTransform, PhaseGetParamsRulesetPhaseHTTPRequestOrigin, PhaseGetParamsRulesetPhaseHTTPRequestRedirect, PhaseGetParamsRulesetPhaseHTTPRequestSanitize, PhaseGetParamsRulesetPhaseHTTPRequestSbfm, PhaseGetParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseGetParamsRulesetPhaseHTTPRequestTransform, PhaseGetParamsRulesetPhaseHTTPResponseCompression, PhaseGetParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseGetParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseGetParamsRulesetPhaseMagicTransit, PhaseGetParamsRulesetPhaseMagicTransitIDsManaged, PhaseGetParamsRulesetPhaseMagicTransitManaged: + case PhaseGetParamsRulesetPhaseDDoSL4, PhaseGetParamsRulesetPhaseDDoSL7, PhaseGetParamsRulesetPhaseHTTPConfigSettings, PhaseGetParamsRulesetPhaseHTTPCustomErrors, PhaseGetParamsRulesetPhaseHTTPLogCustomFields, PhaseGetParamsRulesetPhaseHTTPRatelimit, PhaseGetParamsRulesetPhaseHTTPRequestCacheSettings, PhaseGetParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseGetParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseGetParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseGetParamsRulesetPhaseHTTPRequestLateTransform, PhaseGetParamsRulesetPhaseHTTPRequestOrigin, PhaseGetParamsRulesetPhaseHTTPRequestRedirect, PhaseGetParamsRulesetPhaseHTTPRequestSanitize, PhaseGetParamsRulesetPhaseHTTPRequestSBFM, PhaseGetParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseGetParamsRulesetPhaseHTTPRequestTransform, PhaseGetParamsRulesetPhaseHTTPResponseCompression, PhaseGetParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseGetParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseGetParamsRulesetPhaseMagicTransit, PhaseGetParamsRulesetPhaseMagicTransitIDsManaged, PhaseGetParamsRulesetPhaseMagicTransitManaged: return true } return false @@ -856,8 +1018,8 @@ type PhaseGetResponseEnvelope struct { Errors []PhaseGetResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []PhaseGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result PhaseGetResponse `json:"result,required"` // Whether the API call was successful. Success PhaseGetResponseEnvelopeSuccess `json:"success,required"` JSON phaseGetResponseEnvelopeJSON `json:"-"` diff --git a/rulesets/phase_test.go b/rulesets/phase_test.go index 7a32a025e30..8a722986c54 100644 --- a/rulesets/phase_test.go +++ b/rulesets/phase_test.go @@ -32,11 +32,10 @@ func TestPhaseUpdateWithOptionalParams(t *testing.T) { context.TODO(), rulesets.PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom, rulesets.PhaseUpdateParams{ - ID: cloudflare.F("2f2feab2026849078ba485f918791bdc"), - Rules: cloudflare.F([]rulesets.PhaseUpdateParamsRule{rulesets.PhaseUpdateParamsRulesRulesetsBlockRule(rulesets.PhaseUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Rules: cloudflare.F([]rulesets.PhaseUpdateParamsRuleUnion{rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -46,14 +45,14 @@ func TestPhaseUpdateWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - }), rulesets.PhaseUpdateParamsRulesRulesetsBlockRule(rulesets.PhaseUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + }, rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -63,14 +62,14 @@ func TestPhaseUpdateWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - }), rulesets.PhaseUpdateParamsRulesRulesetsBlockRule(rulesets.PhaseUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + }, rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -80,11 +79,11 @@ func TestPhaseUpdateWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - })}), + }}), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), Description: cloudflare.F("My ruleset to execute managed rulesets"), diff --git a/rulesets/phaseversion.go b/rulesets/phaseversion.go index 54b50a3641b..aec42b76acb 100644 --- a/rulesets/phaseversion.go +++ b/rulesets/phaseversion.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "net/http" + "reflect" "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" @@ -13,6 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // PhaseVersionService contains methods and other services that help with @@ -34,7 +36,7 @@ func NewPhaseVersionService(opts ...option.RequestOption) (r *PhaseVersionServic } // Fetches the versions of an account or zone entry point ruleset. -func (r *PhaseVersionService) List(ctx context.Context, rulesetPhase PhaseVersionListParamsRulesetPhase, query PhaseVersionListParams, opts ...option.RequestOption) (res *pagination.SinglePage[PhaseVersionListResponse], err error) { +func (r *PhaseVersionService) List(ctx context.Context, rulesetPhase PhaseVersionListParamsRulesetPhase, query PhaseVersionListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Ruleset], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -61,12 +63,12 @@ func (r *PhaseVersionService) List(ctx context.Context, rulesetPhase PhaseVersio } // Fetches the versions of an account or zone entry point ruleset. -func (r *PhaseVersionService) ListAutoPaging(ctx context.Context, rulesetPhase PhaseVersionListParamsRulesetPhase, query PhaseVersionListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[PhaseVersionListResponse] { +func (r *PhaseVersionService) ListAutoPaging(ctx context.Context, rulesetPhase PhaseVersionListParamsRulesetPhase, query PhaseVersionListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Ruleset] { return pagination.NewSinglePageAutoPager(r.List(ctx, rulesetPhase, query, opts...)) } // Fetches a specific version of an account or zone entry point ruleset. -func (r *PhaseVersionService) Get(ctx context.Context, rulesetPhase PhaseVersionGetParamsRulesetPhase, rulesetVersion string, query PhaseVersionGetParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *PhaseVersionService) Get(ctx context.Context, rulesetPhase PhaseVersionGetParamsRulesetPhase, rulesetVersion string, query PhaseVersionGetParams, opts ...option.RequestOption) (res *PhaseVersionGetResponse, err error) { opts = append(r.Options[:], opts...) var env PhaseVersionGetResponseEnvelope var accountOrZone string @@ -88,96 +90,279 @@ func (r *PhaseVersionService) Get(ctx context.Context, rulesetPhase PhaseVersion } // A ruleset object. -type PhaseVersionListResponse struct { +type PhaseVersionGetResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` // The kind of the ruleset. - Kind PhaseVersionListResponseKind `json:"kind,required"` + Kind PhaseVersionGetResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // The human-readable name of the ruleset. Name string `json:"name,required"` // The phase of the ruleset. - Phase PhaseVersionListResponsePhase `json:"phase,required"` - // The unique ID of the ruleset. - ID string `json:"id"` - // An informative description of the ruleset. - Description string `json:"description"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated" format:"date-time"` + Phase PhaseVersionGetResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []PhaseVersionGetResponseRule `json:"rules,required"` // The version of the ruleset. - Version string `json:"version"` - JSON phaseVersionListResponseJSON `json:"-"` + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON phaseVersionGetResponseJSON `json:"-"` } -// phaseVersionListResponseJSON contains the JSON metadata for the struct -// [PhaseVersionListResponse] -type phaseVersionListResponseJSON struct { +// phaseVersionGetResponseJSON contains the JSON metadata for the struct +// [PhaseVersionGetResponse] +type phaseVersionGetResponseJSON struct { + ID apijson.Field Kind apijson.Field + LastUpdated apijson.Field Name apijson.Field Phase apijson.Field - ID apijson.Field - Description apijson.Field - LastUpdated apijson.Field + Rules apijson.Field Version apijson.Field + Description apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PhaseVersionListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *PhaseVersionGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r phaseVersionListResponseJSON) RawJSON() string { +func (r phaseVersionGetResponseJSON) RawJSON() string { return r.raw } // The kind of the ruleset. -type PhaseVersionListResponseKind string +type PhaseVersionGetResponseKind string const ( - PhaseVersionListResponseKindManaged PhaseVersionListResponseKind = "managed" - PhaseVersionListResponseKindCustom PhaseVersionListResponseKind = "custom" - PhaseVersionListResponseKindRoot PhaseVersionListResponseKind = "root" - PhaseVersionListResponseKindZone PhaseVersionListResponseKind = "zone" + PhaseVersionGetResponseKindManaged PhaseVersionGetResponseKind = "managed" + PhaseVersionGetResponseKindCustom PhaseVersionGetResponseKind = "custom" + PhaseVersionGetResponseKindRoot PhaseVersionGetResponseKind = "root" + PhaseVersionGetResponseKindZone PhaseVersionGetResponseKind = "zone" ) -func (r PhaseVersionListResponseKind) IsKnown() bool { +func (r PhaseVersionGetResponseKind) IsKnown() bool { switch r { - case PhaseVersionListResponseKindManaged, PhaseVersionListResponseKindCustom, PhaseVersionListResponseKindRoot, PhaseVersionListResponseKindZone: + case PhaseVersionGetResponseKindManaged, PhaseVersionGetResponseKindCustom, PhaseVersionGetResponseKindRoot, PhaseVersionGetResponseKindZone: return true } return false } // The phase of the ruleset. -type PhaseVersionListResponsePhase string +type PhaseVersionGetResponsePhase string + +const ( + PhaseVersionGetResponsePhaseDDoSL4 PhaseVersionGetResponsePhase = "ddos_l4" + PhaseVersionGetResponsePhaseDDoSL7 PhaseVersionGetResponsePhase = "ddos_l7" + PhaseVersionGetResponsePhaseHTTPConfigSettings PhaseVersionGetResponsePhase = "http_config_settings" + PhaseVersionGetResponsePhaseHTTPCustomErrors PhaseVersionGetResponsePhase = "http_custom_errors" + PhaseVersionGetResponsePhaseHTTPLogCustomFields PhaseVersionGetResponsePhase = "http_log_custom_fields" + PhaseVersionGetResponsePhaseHTTPRatelimit PhaseVersionGetResponsePhase = "http_ratelimit" + PhaseVersionGetResponsePhaseHTTPRequestCacheSettings PhaseVersionGetResponsePhase = "http_request_cache_settings" + PhaseVersionGetResponsePhaseHTTPRequestDynamicRedirect PhaseVersionGetResponsePhase = "http_request_dynamic_redirect" + PhaseVersionGetResponsePhaseHTTPRequestFirewallCustom PhaseVersionGetResponsePhase = "http_request_firewall_custom" + PhaseVersionGetResponsePhaseHTTPRequestFirewallManaged PhaseVersionGetResponsePhase = "http_request_firewall_managed" + PhaseVersionGetResponsePhaseHTTPRequestLateTransform PhaseVersionGetResponsePhase = "http_request_late_transform" + PhaseVersionGetResponsePhaseHTTPRequestOrigin PhaseVersionGetResponsePhase = "http_request_origin" + PhaseVersionGetResponsePhaseHTTPRequestRedirect PhaseVersionGetResponsePhase = "http_request_redirect" + PhaseVersionGetResponsePhaseHTTPRequestSanitize PhaseVersionGetResponsePhase = "http_request_sanitize" + PhaseVersionGetResponsePhaseHTTPRequestSBFM PhaseVersionGetResponsePhase = "http_request_sbfm" + PhaseVersionGetResponsePhaseHTTPRequestSelectConfiguration PhaseVersionGetResponsePhase = "http_request_select_configuration" + PhaseVersionGetResponsePhaseHTTPRequestTransform PhaseVersionGetResponsePhase = "http_request_transform" + PhaseVersionGetResponsePhaseHTTPResponseCompression PhaseVersionGetResponsePhase = "http_response_compression" + PhaseVersionGetResponsePhaseHTTPResponseFirewallManaged PhaseVersionGetResponsePhase = "http_response_firewall_managed" + PhaseVersionGetResponsePhaseHTTPResponseHeadersTransform PhaseVersionGetResponsePhase = "http_response_headers_transform" + PhaseVersionGetResponsePhaseMagicTransit PhaseVersionGetResponsePhase = "magic_transit" + PhaseVersionGetResponsePhaseMagicTransitIDsManaged PhaseVersionGetResponsePhase = "magic_transit_ids_managed" + PhaseVersionGetResponsePhaseMagicTransitManaged PhaseVersionGetResponsePhase = "magic_transit_managed" +) + +func (r PhaseVersionGetResponsePhase) IsKnown() bool { + switch r { + case PhaseVersionGetResponsePhaseDDoSL4, PhaseVersionGetResponsePhaseDDoSL7, PhaseVersionGetResponsePhaseHTTPConfigSettings, PhaseVersionGetResponsePhaseHTTPCustomErrors, PhaseVersionGetResponsePhaseHTTPLogCustomFields, PhaseVersionGetResponsePhaseHTTPRatelimit, PhaseVersionGetResponsePhaseHTTPRequestCacheSettings, PhaseVersionGetResponsePhaseHTTPRequestDynamicRedirect, PhaseVersionGetResponsePhaseHTTPRequestFirewallCustom, PhaseVersionGetResponsePhaseHTTPRequestFirewallManaged, PhaseVersionGetResponsePhaseHTTPRequestLateTransform, PhaseVersionGetResponsePhaseHTTPRequestOrigin, PhaseVersionGetResponsePhaseHTTPRequestRedirect, PhaseVersionGetResponsePhaseHTTPRequestSanitize, PhaseVersionGetResponsePhaseHTTPRequestSBFM, PhaseVersionGetResponsePhaseHTTPRequestSelectConfiguration, PhaseVersionGetResponsePhaseHTTPRequestTransform, PhaseVersionGetResponsePhaseHTTPResponseCompression, PhaseVersionGetResponsePhaseHTTPResponseFirewallManaged, PhaseVersionGetResponsePhaseHTTPResponseHeadersTransform, PhaseVersionGetResponsePhaseMagicTransit, PhaseVersionGetResponsePhaseMagicTransitIDsManaged, PhaseVersionGetResponsePhaseMagicTransitManaged: + return true + } + return false +} + +type PhaseVersionGetResponseRule struct { + // The action to perform when the rule matches. + Action PhaseVersionGetResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON phaseVersionGetResponseRuleJSON `json:"-"` + union PhaseVersionGetResponseRulesUnion +} + +// phaseVersionGetResponseRuleJSON contains the JSON metadata for the struct +// [PhaseVersionGetResponseRule] +type phaseVersionGetResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r phaseVersionGetResponseRuleJSON) RawJSON() string { + return r.raw +} + +func (r *PhaseVersionGetResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r PhaseVersionGetResponseRule) AsUnion() PhaseVersionGetResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type PhaseVersionGetResponseRulesUnion interface { + implementsRulesetsPhaseVersionGetResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PhaseVersionGetResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) +} + +// The action to perform when the rule matches. +type PhaseVersionGetResponseRulesAction string const ( - PhaseVersionListResponsePhaseDDoSL4 PhaseVersionListResponsePhase = "ddos_l4" - PhaseVersionListResponsePhaseDDoSL7 PhaseVersionListResponsePhase = "ddos_l7" - PhaseVersionListResponsePhaseHTTPConfigSettings PhaseVersionListResponsePhase = "http_config_settings" - PhaseVersionListResponsePhaseHTTPCustomErrors PhaseVersionListResponsePhase = "http_custom_errors" - PhaseVersionListResponsePhaseHTTPLogCustomFields PhaseVersionListResponsePhase = "http_log_custom_fields" - PhaseVersionListResponsePhaseHTTPRatelimit PhaseVersionListResponsePhase = "http_ratelimit" - PhaseVersionListResponsePhaseHTTPRequestCacheSettings PhaseVersionListResponsePhase = "http_request_cache_settings" - PhaseVersionListResponsePhaseHTTPRequestDynamicRedirect PhaseVersionListResponsePhase = "http_request_dynamic_redirect" - PhaseVersionListResponsePhaseHTTPRequestFirewallCustom PhaseVersionListResponsePhase = "http_request_firewall_custom" - PhaseVersionListResponsePhaseHTTPRequestFirewallManaged PhaseVersionListResponsePhase = "http_request_firewall_managed" - PhaseVersionListResponsePhaseHTTPRequestLateTransform PhaseVersionListResponsePhase = "http_request_late_transform" - PhaseVersionListResponsePhaseHTTPRequestOrigin PhaseVersionListResponsePhase = "http_request_origin" - PhaseVersionListResponsePhaseHTTPRequestRedirect PhaseVersionListResponsePhase = "http_request_redirect" - PhaseVersionListResponsePhaseHTTPRequestSanitize PhaseVersionListResponsePhase = "http_request_sanitize" - PhaseVersionListResponsePhaseHTTPRequestSbfm PhaseVersionListResponsePhase = "http_request_sbfm" - PhaseVersionListResponsePhaseHTTPRequestSelectConfiguration PhaseVersionListResponsePhase = "http_request_select_configuration" - PhaseVersionListResponsePhaseHTTPRequestTransform PhaseVersionListResponsePhase = "http_request_transform" - PhaseVersionListResponsePhaseHTTPResponseCompression PhaseVersionListResponsePhase = "http_response_compression" - PhaseVersionListResponsePhaseHTTPResponseFirewallManaged PhaseVersionListResponsePhase = "http_response_firewall_managed" - PhaseVersionListResponsePhaseHTTPResponseHeadersTransform PhaseVersionListResponsePhase = "http_response_headers_transform" - PhaseVersionListResponsePhaseMagicTransit PhaseVersionListResponsePhase = "magic_transit" - PhaseVersionListResponsePhaseMagicTransitIDsManaged PhaseVersionListResponsePhase = "magic_transit_ids_managed" - PhaseVersionListResponsePhaseMagicTransitManaged PhaseVersionListResponsePhase = "magic_transit_managed" + PhaseVersionGetResponseRulesActionBlock PhaseVersionGetResponseRulesAction = "block" + PhaseVersionGetResponseRulesActionChallenge PhaseVersionGetResponseRulesAction = "challenge" + PhaseVersionGetResponseRulesActionCompressResponse PhaseVersionGetResponseRulesAction = "compress_response" + PhaseVersionGetResponseRulesActionExecute PhaseVersionGetResponseRulesAction = "execute" + PhaseVersionGetResponseRulesActionJSChallenge PhaseVersionGetResponseRulesAction = "js_challenge" + PhaseVersionGetResponseRulesActionLog PhaseVersionGetResponseRulesAction = "log" + PhaseVersionGetResponseRulesActionManagedChallenge PhaseVersionGetResponseRulesAction = "managed_challenge" + PhaseVersionGetResponseRulesActionRedirect PhaseVersionGetResponseRulesAction = "redirect" + PhaseVersionGetResponseRulesActionRewrite PhaseVersionGetResponseRulesAction = "rewrite" + PhaseVersionGetResponseRulesActionRoute PhaseVersionGetResponseRulesAction = "route" + PhaseVersionGetResponseRulesActionScore PhaseVersionGetResponseRulesAction = "score" + PhaseVersionGetResponseRulesActionServeError PhaseVersionGetResponseRulesAction = "serve_error" + PhaseVersionGetResponseRulesActionSetConfig PhaseVersionGetResponseRulesAction = "set_config" + PhaseVersionGetResponseRulesActionSkip PhaseVersionGetResponseRulesAction = "skip" + PhaseVersionGetResponseRulesActionSetCacheSettings PhaseVersionGetResponseRulesAction = "set_cache_settings" ) -func (r PhaseVersionListResponsePhase) IsKnown() bool { +func (r PhaseVersionGetResponseRulesAction) IsKnown() bool { switch r { - case PhaseVersionListResponsePhaseDDoSL4, PhaseVersionListResponsePhaseDDoSL7, PhaseVersionListResponsePhaseHTTPConfigSettings, PhaseVersionListResponsePhaseHTTPCustomErrors, PhaseVersionListResponsePhaseHTTPLogCustomFields, PhaseVersionListResponsePhaseHTTPRatelimit, PhaseVersionListResponsePhaseHTTPRequestCacheSettings, PhaseVersionListResponsePhaseHTTPRequestDynamicRedirect, PhaseVersionListResponsePhaseHTTPRequestFirewallCustom, PhaseVersionListResponsePhaseHTTPRequestFirewallManaged, PhaseVersionListResponsePhaseHTTPRequestLateTransform, PhaseVersionListResponsePhaseHTTPRequestOrigin, PhaseVersionListResponsePhaseHTTPRequestRedirect, PhaseVersionListResponsePhaseHTTPRequestSanitize, PhaseVersionListResponsePhaseHTTPRequestSbfm, PhaseVersionListResponsePhaseHTTPRequestSelectConfiguration, PhaseVersionListResponsePhaseHTTPRequestTransform, PhaseVersionListResponsePhaseHTTPResponseCompression, PhaseVersionListResponsePhaseHTTPResponseFirewallManaged, PhaseVersionListResponsePhaseHTTPResponseHeadersTransform, PhaseVersionListResponsePhaseMagicTransit, PhaseVersionListResponsePhaseMagicTransitIDsManaged, PhaseVersionListResponsePhaseMagicTransitManaged: + case PhaseVersionGetResponseRulesActionBlock, PhaseVersionGetResponseRulesActionChallenge, PhaseVersionGetResponseRulesActionCompressResponse, PhaseVersionGetResponseRulesActionExecute, PhaseVersionGetResponseRulesActionJSChallenge, PhaseVersionGetResponseRulesActionLog, PhaseVersionGetResponseRulesActionManagedChallenge, PhaseVersionGetResponseRulesActionRedirect, PhaseVersionGetResponseRulesActionRewrite, PhaseVersionGetResponseRulesActionRoute, PhaseVersionGetResponseRulesActionScore, PhaseVersionGetResponseRulesActionServeError, PhaseVersionGetResponseRulesActionSetConfig, PhaseVersionGetResponseRulesActionSkip, PhaseVersionGetResponseRulesActionSetCacheSettings: return true } return false @@ -208,7 +393,7 @@ const ( PhaseVersionListParamsRulesetPhaseHTTPRequestOrigin PhaseVersionListParamsRulesetPhase = "http_request_origin" PhaseVersionListParamsRulesetPhaseHTTPRequestRedirect PhaseVersionListParamsRulesetPhase = "http_request_redirect" PhaseVersionListParamsRulesetPhaseHTTPRequestSanitize PhaseVersionListParamsRulesetPhase = "http_request_sanitize" - PhaseVersionListParamsRulesetPhaseHTTPRequestSbfm PhaseVersionListParamsRulesetPhase = "http_request_sbfm" + PhaseVersionListParamsRulesetPhaseHTTPRequestSBFM PhaseVersionListParamsRulesetPhase = "http_request_sbfm" PhaseVersionListParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseVersionListParamsRulesetPhase = "http_request_select_configuration" PhaseVersionListParamsRulesetPhaseHTTPRequestTransform PhaseVersionListParamsRulesetPhase = "http_request_transform" PhaseVersionListParamsRulesetPhaseHTTPResponseCompression PhaseVersionListParamsRulesetPhase = "http_response_compression" @@ -221,7 +406,7 @@ const ( func (r PhaseVersionListParamsRulesetPhase) IsKnown() bool { switch r { - case PhaseVersionListParamsRulesetPhaseDDoSL4, PhaseVersionListParamsRulesetPhaseDDoSL7, PhaseVersionListParamsRulesetPhaseHTTPConfigSettings, PhaseVersionListParamsRulesetPhaseHTTPCustomErrors, PhaseVersionListParamsRulesetPhaseHTTPLogCustomFields, PhaseVersionListParamsRulesetPhaseHTTPRatelimit, PhaseVersionListParamsRulesetPhaseHTTPRequestCacheSettings, PhaseVersionListParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseVersionListParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseVersionListParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseVersionListParamsRulesetPhaseHTTPRequestLateTransform, PhaseVersionListParamsRulesetPhaseHTTPRequestOrigin, PhaseVersionListParamsRulesetPhaseHTTPRequestRedirect, PhaseVersionListParamsRulesetPhaseHTTPRequestSanitize, PhaseVersionListParamsRulesetPhaseHTTPRequestSbfm, PhaseVersionListParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseVersionListParamsRulesetPhaseHTTPRequestTransform, PhaseVersionListParamsRulesetPhaseHTTPResponseCompression, PhaseVersionListParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseVersionListParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseVersionListParamsRulesetPhaseMagicTransit, PhaseVersionListParamsRulesetPhaseMagicTransitIDsManaged, PhaseVersionListParamsRulesetPhaseMagicTransitManaged: + case PhaseVersionListParamsRulesetPhaseDDoSL4, PhaseVersionListParamsRulesetPhaseDDoSL7, PhaseVersionListParamsRulesetPhaseHTTPConfigSettings, PhaseVersionListParamsRulesetPhaseHTTPCustomErrors, PhaseVersionListParamsRulesetPhaseHTTPLogCustomFields, PhaseVersionListParamsRulesetPhaseHTTPRatelimit, PhaseVersionListParamsRulesetPhaseHTTPRequestCacheSettings, PhaseVersionListParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseVersionListParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseVersionListParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseVersionListParamsRulesetPhaseHTTPRequestLateTransform, PhaseVersionListParamsRulesetPhaseHTTPRequestOrigin, PhaseVersionListParamsRulesetPhaseHTTPRequestRedirect, PhaseVersionListParamsRulesetPhaseHTTPRequestSanitize, PhaseVersionListParamsRulesetPhaseHTTPRequestSBFM, PhaseVersionListParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseVersionListParamsRulesetPhaseHTTPRequestTransform, PhaseVersionListParamsRulesetPhaseHTTPResponseCompression, PhaseVersionListParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseVersionListParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseVersionListParamsRulesetPhaseMagicTransit, PhaseVersionListParamsRulesetPhaseMagicTransitIDsManaged, PhaseVersionListParamsRulesetPhaseMagicTransitManaged: return true } return false @@ -252,7 +437,7 @@ const ( PhaseVersionGetParamsRulesetPhaseHTTPRequestOrigin PhaseVersionGetParamsRulesetPhase = "http_request_origin" PhaseVersionGetParamsRulesetPhaseHTTPRequestRedirect PhaseVersionGetParamsRulesetPhase = "http_request_redirect" PhaseVersionGetParamsRulesetPhaseHTTPRequestSanitize PhaseVersionGetParamsRulesetPhase = "http_request_sanitize" - PhaseVersionGetParamsRulesetPhaseHTTPRequestSbfm PhaseVersionGetParamsRulesetPhase = "http_request_sbfm" + PhaseVersionGetParamsRulesetPhaseHTTPRequestSBFM PhaseVersionGetParamsRulesetPhase = "http_request_sbfm" PhaseVersionGetParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseVersionGetParamsRulesetPhase = "http_request_select_configuration" PhaseVersionGetParamsRulesetPhaseHTTPRequestTransform PhaseVersionGetParamsRulesetPhase = "http_request_transform" PhaseVersionGetParamsRulesetPhaseHTTPResponseCompression PhaseVersionGetParamsRulesetPhase = "http_response_compression" @@ -265,7 +450,7 @@ const ( func (r PhaseVersionGetParamsRulesetPhase) IsKnown() bool { switch r { - case PhaseVersionGetParamsRulesetPhaseDDoSL4, PhaseVersionGetParamsRulesetPhaseDDoSL7, PhaseVersionGetParamsRulesetPhaseHTTPConfigSettings, PhaseVersionGetParamsRulesetPhaseHTTPCustomErrors, PhaseVersionGetParamsRulesetPhaseHTTPLogCustomFields, PhaseVersionGetParamsRulesetPhaseHTTPRatelimit, PhaseVersionGetParamsRulesetPhaseHTTPRequestCacheSettings, PhaseVersionGetParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseVersionGetParamsRulesetPhaseHTTPRequestLateTransform, PhaseVersionGetParamsRulesetPhaseHTTPRequestOrigin, PhaseVersionGetParamsRulesetPhaseHTTPRequestRedirect, PhaseVersionGetParamsRulesetPhaseHTTPRequestSanitize, PhaseVersionGetParamsRulesetPhaseHTTPRequestSbfm, PhaseVersionGetParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseVersionGetParamsRulesetPhaseHTTPRequestTransform, PhaseVersionGetParamsRulesetPhaseHTTPResponseCompression, PhaseVersionGetParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseVersionGetParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseVersionGetParamsRulesetPhaseMagicTransit, PhaseVersionGetParamsRulesetPhaseMagicTransitIDsManaged, PhaseVersionGetParamsRulesetPhaseMagicTransitManaged: + case PhaseVersionGetParamsRulesetPhaseDDoSL4, PhaseVersionGetParamsRulesetPhaseDDoSL7, PhaseVersionGetParamsRulesetPhaseHTTPConfigSettings, PhaseVersionGetParamsRulesetPhaseHTTPCustomErrors, PhaseVersionGetParamsRulesetPhaseHTTPLogCustomFields, PhaseVersionGetParamsRulesetPhaseHTTPRatelimit, PhaseVersionGetParamsRulesetPhaseHTTPRequestCacheSettings, PhaseVersionGetParamsRulesetPhaseHTTPRequestDynamicRedirect, PhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallCustom, PhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallManaged, PhaseVersionGetParamsRulesetPhaseHTTPRequestLateTransform, PhaseVersionGetParamsRulesetPhaseHTTPRequestOrigin, PhaseVersionGetParamsRulesetPhaseHTTPRequestRedirect, PhaseVersionGetParamsRulesetPhaseHTTPRequestSanitize, PhaseVersionGetParamsRulesetPhaseHTTPRequestSBFM, PhaseVersionGetParamsRulesetPhaseHTTPRequestSelectConfiguration, PhaseVersionGetParamsRulesetPhaseHTTPRequestTransform, PhaseVersionGetParamsRulesetPhaseHTTPResponseCompression, PhaseVersionGetParamsRulesetPhaseHTTPResponseFirewallManaged, PhaseVersionGetParamsRulesetPhaseHTTPResponseHeadersTransform, PhaseVersionGetParamsRulesetPhaseMagicTransit, PhaseVersionGetParamsRulesetPhaseMagicTransitIDsManaged, PhaseVersionGetParamsRulesetPhaseMagicTransitManaged: return true } return false @@ -277,8 +462,8 @@ type PhaseVersionGetResponseEnvelope struct { Errors []PhaseVersionGetResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []PhaseVersionGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result PhaseVersionGetResponse `json:"result,required"` // Whether the API call was successful. Success PhaseVersionGetResponseEnvelopeSuccess `json:"success,required"` JSON phaseVersionGetResponseEnvelopeJSON `json:"-"` diff --git a/rulesets/rule.go b/rulesets/rule.go index e2cee9c041b..4bfabe41fa8 100644 --- a/rulesets/rule.go +++ b/rulesets/rule.go @@ -6,11 +6,14 @@ import ( "context" "fmt" "net/http" + "reflect" + "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // RuleService contains methods and other services that help with interacting with @@ -32,17 +35,17 @@ func NewRuleService(opts ...option.RequestOption) (r *RuleService) { // Adds a new rule to an account or zone ruleset. The rule will be added to the end // of the existing list of rules in the ruleset by default. -func (r *RuleService) New(ctx context.Context, rulesetID string, params RuleNewParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *RuleService) New(ctx context.Context, rulesetID string, params RuleNewParams, opts ...option.RequestOption) (res *RuleNewResponse, err error) { opts = append(r.Options[:], opts...) var env RuleNewResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if params.getAccountID().Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = params.getAccountID() + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = params.getZoneID() + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/rulesets/%s/rules", accountOrZone, accountOrZoneID, rulesetID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) @@ -54,7 +57,7 @@ func (r *RuleService) New(ctx context.Context, rulesetID string, params RuleNewP } // Deletes an existing rule from an account or zone ruleset. -func (r *RuleService) Delete(ctx context.Context, rulesetID string, ruleID string, body RuleDeleteParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *RuleService) Delete(ctx context.Context, rulesetID string, ruleID string, body RuleDeleteParams, opts ...option.RequestOption) (res *RuleDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env RuleDeleteResponseEnvelope var accountOrZone string @@ -76,17 +79,17 @@ func (r *RuleService) Delete(ctx context.Context, rulesetID string, ruleID strin } // Updates an existing rule in an account or zone ruleset. -func (r *RuleService) Edit(ctx context.Context, rulesetID string, ruleID string, params RuleEditParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *RuleService) Edit(ctx context.Context, rulesetID string, ruleID string, params RuleEditParams, opts ...option.RequestOption) (res *RuleEditResponse, err error) { opts = append(r.Options[:], opts...) var env RuleEditResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if params.getAccountID().Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = params.getAccountID() + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = params.getZoneID() + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/rulesets/%s/rules/%s", accountOrZone, accountOrZoneID, rulesetID, ruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) @@ -97,116 +100,153 @@ func (r *RuleService) Edit(ctx context.Context, rulesetID string, ruleID string, return } -// This interface is a union satisfied by one of the following: -// [RuleNewParamsRulesetsBlockRule], [RuleNewParamsRulesetsExecuteRule], -// [RuleNewParamsRulesetsLogRule], [RuleNewParamsRulesetsSkipRule]. -type RuleNewParams interface { - ImplementsRuleNewParams() - - getAccountID() param.Field[string] - - getZoneID() param.Field[string] -} - -type RuleNewParamsRulesetsBlockRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` +type BlockRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` // The unique ID of the rule. - ID param.Field[string] `json:"id"` + ID string `json:"id"` // The action to perform when the rule matches. - Action param.Field[RuleNewParamsRulesetsBlockRuleAction] `json:"action"` + Action BlockRuleAction `json:"action"` // The parameters configuring the rule's action. - ActionParameters param.Field[RuleNewParamsRulesetsBlockRuleActionParameters] `json:"action_parameters"` + ActionParameters BlockRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` // An informative description of the rule. - Description param.Field[string] `json:"description"` + Description string `json:"description"` // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` + Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` + Expression string `json:"expression"` // An object configuring the rule's logging behavior. - Logging param.Field[RuleNewParamsRulesetsBlockRuleLogging] `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` + Ref string `json:"ref"` + JSON blockRuleJSON `json:"-"` +} + +// blockRuleJSON contains the JSON metadata for the struct [BlockRule] +type blockRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BlockRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r RuleNewParamsRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r blockRuleJSON) RawJSON() string { + return r.raw } -func (r RuleNewParamsRulesetsBlockRule) getAccountID() param.Field[string] { - return r.AccountID -} +func (r BlockRule) implementsRulesetsRulesetNewResponseRule() {} -func (r RuleNewParamsRulesetsBlockRule) getZoneID() param.Field[string] { - return r.ZoneID -} +func (r BlockRule) implementsRulesetsRulesetUpdateResponseRule() {} -func (RuleNewParamsRulesetsBlockRule) ImplementsRuleNewParams() { +func (r BlockRule) implementsRulesetsRulesetGetResponseRule() {} -} +func (r BlockRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r BlockRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r BlockRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r BlockRule) implementsRulesetsRuleNewResponseRule() {} + +func (r BlockRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r BlockRule) implementsRulesetsRuleEditResponseRule() {} + +func (r BlockRule) implementsRulesetsVersionGetResponseRule() {} + +func (r BlockRule) implementsRulesetsVersionByTagGetResponseRule() {} // The action to perform when the rule matches. -type RuleNewParamsRulesetsBlockRuleAction string +type BlockRuleAction string const ( - RuleNewParamsRulesetsBlockRuleActionBlock RuleNewParamsRulesetsBlockRuleAction = "block" + BlockRuleActionBlock BlockRuleAction = "block" ) -func (r RuleNewParamsRulesetsBlockRuleAction) IsKnown() bool { +func (r BlockRuleAction) IsKnown() bool { switch r { - case RuleNewParamsRulesetsBlockRuleActionBlock: + case BlockRuleActionBlock: return true } return false } // The parameters configuring the rule's action. -type RuleNewParamsRulesetsBlockRuleActionParameters struct { +type BlockRuleActionParameters struct { // The response to show when the block is applied. - Response param.Field[RuleNewParamsRulesetsBlockRuleActionParametersResponse] `json:"response"` + Response BlockRuleActionParametersResponse `json:"response"` + JSON blockRuleActionParametersJSON `json:"-"` } -func (r RuleNewParamsRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// blockRuleActionParametersJSON contains the JSON metadata for the struct +// [BlockRuleActionParameters] +type blockRuleActionParametersJSON struct { + Response apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r blockRuleActionParametersJSON) RawJSON() string { + return r.raw } // The response to show when the block is applied. -type RuleNewParamsRulesetsBlockRuleActionParametersResponse struct { +type BlockRuleActionParametersResponse struct { // The content to return. - Content param.Field[string] `json:"content,required"` + Content string `json:"content,required"` // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` + ContentType string `json:"content_type,required"` // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` + StatusCode int64 `json:"status_code,required"` + JSON blockRuleActionParametersResponseJSON `json:"-"` } -func (r RuleNewParamsRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// blockRuleActionParametersResponseJSON contains the JSON metadata for the struct +// [BlockRuleActionParametersResponse] +type blockRuleActionParametersResponseJSON struct { + Content apijson.Field + ContentType apijson.Field + StatusCode apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// An object configuring the rule's logging behavior. -type RuleNewParamsRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` +func (r *BlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r RuleNewParamsRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r blockRuleActionParametersResponseJSON) RawJSON() string { + return r.raw } -type RuleNewParamsRulesetsExecuteRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` +type BlockRuleParam struct { // The unique ID of the rule. ID param.Field[string] `json:"id"` // The action to perform when the rule matches. - Action param.Field[RuleNewParamsRulesetsExecuteRuleAction] `json:"action"` + Action param.Field[BlockRuleAction] `json:"action"` // The parameters configuring the rule's action. - ActionParameters param.Field[RuleNewParamsRulesetsExecuteRuleActionParameters] `json:"action_parameters"` + ActionParameters param.Field[BlockRuleActionParametersParam] `json:"action_parameters"` // An informative description of the rule. Description param.Field[string] `json:"description"` // Whether the rule should be executed. @@ -214,198 +254,323 @@ type RuleNewParamsRulesetsExecuteRule struct { // The expression defining which traffic will match the rule. Expression param.Field[string] `json:"expression"` // An object configuring the rule's logging behavior. - Logging param.Field[RuleNewParamsRulesetsExecuteRuleLogging] `json:"logging"` + Logging param.Field[LoggingParam] `json:"logging"` // The reference of the rule (the rule ID by default). Ref param.Field[string] `json:"ref"` } -func (r RuleNewParamsRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { +func (r BlockRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r BlockRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r BlockRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r BlockRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type BlockRuleActionParametersParam struct { + // The response to show when the block is applied. + Response param.Field[BlockRuleActionParametersResponseParam] `json:"response"` +} + +func (r BlockRuleActionParametersParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r RuleNewParamsRulesetsExecuteRule) getAccountID() param.Field[string] { - return r.AccountID +// The response to show when the block is applied. +type BlockRuleActionParametersResponseParam struct { + // The content to return. + Content param.Field[string] `json:"content,required"` + // The type of the content to return. + ContentType param.Field[string] `json:"content_type,required"` + // The status code to return. + StatusCode param.Field[int64] `json:"status_code,required"` } -func (r RuleNewParamsRulesetsExecuteRule) getZoneID() param.Field[string] { - return r.ZoneID +func (r BlockRuleActionParametersResponseParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (RuleNewParamsRulesetsExecuteRule) ImplementsRuleNewParams() { +type ChallengeRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action ChallengeRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters interface{} `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON challengeRuleJSON `json:"-"` +} + +// challengeRuleJSON contains the JSON metadata for the struct [ChallengeRule] +type challengeRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ChallengeRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} +func (r challengeRuleJSON) RawJSON() string { + return r.raw } +func (r ChallengeRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r ChallengeRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r ChallengeRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r ChallengeRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r ChallengeRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r ChallengeRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r ChallengeRule) implementsRulesetsRuleNewResponseRule() {} + +func (r ChallengeRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r ChallengeRule) implementsRulesetsRuleEditResponseRule() {} + +func (r ChallengeRule) implementsRulesetsVersionGetResponseRule() {} + +func (r ChallengeRule) implementsRulesetsVersionByTagGetResponseRule() {} + // The action to perform when the rule matches. -type RuleNewParamsRulesetsExecuteRuleAction string +type ChallengeRuleAction string const ( - RuleNewParamsRulesetsExecuteRuleActionExecute RuleNewParamsRulesetsExecuteRuleAction = "execute" + ChallengeRuleActionChallenge ChallengeRuleAction = "challenge" ) -func (r RuleNewParamsRulesetsExecuteRuleAction) IsKnown() bool { +func (r ChallengeRuleAction) IsKnown() bool { switch r { - case RuleNewParamsRulesetsExecuteRuleActionExecute: + case ChallengeRuleActionChallenge: return true } return false } -// The parameters configuring the rule's action. -type RuleNewParamsRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[RuleNewParamsRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[RuleNewParamsRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` +type ChallengeRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[ChallengeRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[interface{}] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` } -func (r RuleNewParamsRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { +func (r ChallengeRuleParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The configuration to use for matched data logging. -type RuleNewParamsRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` -} +func (r ChallengeRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} -func (r RuleNewParamsRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} +func (r ChallengeRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} -// A set of overrides to apply to the target ruleset. -type RuleNewParamsRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` -} +func (r ChallengeRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} -func (r RuleNewParamsRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type CompressResponseRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action CompressResponseRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters CompressResponseRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON compressResponseRuleJSON `json:"-"` +} + +// compressResponseRuleJSON contains the JSON metadata for the struct +// [CompressResponseRule] +type compressResponseRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CompressResponseRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// A category-level override -type RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` +func (r compressResponseRuleJSON) RawJSON() string { + return r.raw } -func (r RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} +func (r CompressResponseRule) implementsRulesetsRulesetNewResponseRule() {} -// The sensitivity level to use for rules in the category. -type RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string +func (r CompressResponseRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsRuleNewResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsRuleEditResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsVersionGetResponseRule() {} + +func (r CompressResponseRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type CompressResponseRuleAction string const ( - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" + CompressResponseRuleActionCompressResponse CompressResponseRuleAction = "compress_response" ) -func (r RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel) IsKnown() bool { +func (r CompressResponseRuleAction) IsKnown() bool { switch r { - case RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff: + case CompressResponseRuleActionCompressResponse: return true } return false } -// A rule-level override -type RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` +// The parameters configuring the rule's action. +type CompressResponseRuleActionParameters struct { + // Custom order for compression algorithms. + Algorithms []CompressResponseRuleActionParametersAlgorithm `json:"algorithms"` + JSON compressResponseRuleActionParametersJSON `json:"-"` } -func (r RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// compressResponseRuleActionParametersJSON contains the JSON metadata for the +// struct [CompressResponseRuleActionParameters] +type compressResponseRuleActionParametersJSON struct { + Algorithms apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The sensitivity level to use for the rule. -type RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string +func (r *CompressResponseRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} -const ( - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) +func (r compressResponseRuleActionParametersJSON) RawJSON() string { + return r.raw +} -func (r RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel) IsKnown() bool { - switch r { - case RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff: - return true - } - return false +// Compression algorithm to enable. +type CompressResponseRuleActionParametersAlgorithm struct { + // Name of compression algorithm to enable. + Name CompressResponseRuleActionParametersAlgorithmsName `json:"name"` + JSON compressResponseRuleActionParametersAlgorithmJSON `json:"-"` } -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string +// compressResponseRuleActionParametersAlgorithmJSON contains the JSON metadata for +// the struct [CompressResponseRuleActionParametersAlgorithm] +type compressResponseRuleActionParametersAlgorithmJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CompressResponseRuleActionParametersAlgorithm) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r compressResponseRuleActionParametersAlgorithmJSON) RawJSON() string { + return r.raw +} + +// Name of compression algorithm to enable. +type CompressResponseRuleActionParametersAlgorithmsName string const ( - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" + CompressResponseRuleActionParametersAlgorithmsNameNone CompressResponseRuleActionParametersAlgorithmsName = "none" + CompressResponseRuleActionParametersAlgorithmsNameAuto CompressResponseRuleActionParametersAlgorithmsName = "auto" + CompressResponseRuleActionParametersAlgorithmsNameDefault CompressResponseRuleActionParametersAlgorithmsName = "default" + CompressResponseRuleActionParametersAlgorithmsNameGzip CompressResponseRuleActionParametersAlgorithmsName = "gzip" + CompressResponseRuleActionParametersAlgorithmsNameBrotli CompressResponseRuleActionParametersAlgorithmsName = "brotli" ) -func (r RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel) IsKnown() bool { +func (r CompressResponseRuleActionParametersAlgorithmsName) IsKnown() bool { switch r { - case RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow, RuleNewParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff: + case CompressResponseRuleActionParametersAlgorithmsNameNone, CompressResponseRuleActionParametersAlgorithmsNameAuto, CompressResponseRuleActionParametersAlgorithmsNameDefault, CompressResponseRuleActionParametersAlgorithmsNameGzip, CompressResponseRuleActionParametersAlgorithmsNameBrotli: return true } return false } -// An object configuring the rule's logging behavior. -type RuleNewParamsRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RuleNewParamsRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RuleNewParamsRulesetsLogRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` +type CompressResponseRuleParam struct { // The unique ID of the rule. ID param.Field[string] `json:"id"` // The action to perform when the rule matches. - Action param.Field[RuleNewParamsRulesetsLogRuleAction] `json:"action"` + Action param.Field[CompressResponseRuleAction] `json:"action"` // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` + ActionParameters param.Field[CompressResponseRuleActionParametersParam] `json:"action_parameters"` // An informative description of the rule. Description param.Field[string] `json:"description"` // Whether the rule should be executed. @@ -413,1051 +578,5233 @@ type RuleNewParamsRulesetsLogRule struct { // The expression defining which traffic will match the rule. Expression param.Field[string] `json:"expression"` // An object configuring the rule's logging behavior. - Logging param.Field[RuleNewParamsRulesetsLogRuleLogging] `json:"logging"` + Logging param.Field[LoggingParam] `json:"logging"` // The reference of the rule (the rule ID by default). Ref param.Field[string] `json:"ref"` } -func (r RuleNewParamsRulesetsLogRule) MarshalJSON() (data []byte, err error) { +func (r CompressResponseRuleParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r RuleNewParamsRulesetsLogRule) getAccountID() param.Field[string] { - return r.AccountID -} +func (r CompressResponseRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} -func (r RuleNewParamsRulesetsLogRule) getZoneID() param.Field[string] { - return r.ZoneID -} +func (r CompressResponseRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} -func (RuleNewParamsRulesetsLogRule) ImplementsRuleNewParams() { +func (r CompressResponseRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} +// The parameters configuring the rule's action. +type CompressResponseRuleActionParametersParam struct { + // Custom order for compression algorithms. + Algorithms param.Field[[]CompressResponseRuleActionParametersAlgorithmParam] `json:"algorithms"` } -// The action to perform when the rule matches. -type RuleNewParamsRulesetsLogRuleAction string - -const ( - RuleNewParamsRulesetsLogRuleActionLog RuleNewParamsRulesetsLogRuleAction = "log" -) - -func (r RuleNewParamsRulesetsLogRuleAction) IsKnown() bool { - switch r { - case RuleNewParamsRulesetsLogRuleActionLog: - return true - } - return false +func (r CompressResponseRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// An object configuring the rule's logging behavior. -type RuleNewParamsRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` +// Compression algorithm to enable. +type CompressResponseRuleActionParametersAlgorithmParam struct { + // Name of compression algorithm to enable. + Name param.Field[CompressResponseRuleActionParametersAlgorithmsName] `json:"name"` } -func (r RuleNewParamsRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { +func (r CompressResponseRuleActionParametersAlgorithmParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type RuleNewParamsRulesetsSkipRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` +type ExecuteRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` // The unique ID of the rule. - ID param.Field[string] `json:"id"` + ID string `json:"id"` // The action to perform when the rule matches. - Action param.Field[RuleNewParamsRulesetsSkipRuleAction] `json:"action"` + Action ExecuteRuleAction `json:"action"` // The parameters configuring the rule's action. - ActionParameters param.Field[RuleNewParamsRulesetsSkipRuleActionParameters] `json:"action_parameters"` + ActionParameters ExecuteRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` // An informative description of the rule. - Description param.Field[string] `json:"description"` + Description string `json:"description"` // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` + Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` + Expression string `json:"expression"` // An object configuring the rule's logging behavior. - Logging param.Field[RuleNewParamsRulesetsSkipRuleLogging] `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` + Ref string `json:"ref"` + JSON executeRuleJSON `json:"-"` +} + +// executeRuleJSON contains the JSON metadata for the struct [ExecuteRule] +type executeRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ExecuteRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r RuleNewParamsRulesetsSkipRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r executeRuleJSON) RawJSON() string { + return r.raw } -func (r RuleNewParamsRulesetsSkipRule) getAccountID() param.Field[string] { - return r.AccountID -} +func (r ExecuteRule) implementsRulesetsRulesetNewResponseRule() {} -func (r RuleNewParamsRulesetsSkipRule) getZoneID() param.Field[string] { - return r.ZoneID -} +func (r ExecuteRule) implementsRulesetsRulesetUpdateResponseRule() {} -func (RuleNewParamsRulesetsSkipRule) ImplementsRuleNewParams() { +func (r ExecuteRule) implementsRulesetsRulesetGetResponseRule() {} -} +func (r ExecuteRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r ExecuteRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r ExecuteRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r ExecuteRule) implementsRulesetsRuleNewResponseRule() {} + +func (r ExecuteRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r ExecuteRule) implementsRulesetsRuleEditResponseRule() {} + +func (r ExecuteRule) implementsRulesetsVersionGetResponseRule() {} + +func (r ExecuteRule) implementsRulesetsVersionByTagGetResponseRule() {} // The action to perform when the rule matches. -type RuleNewParamsRulesetsSkipRuleAction string +type ExecuteRuleAction string const ( - RuleNewParamsRulesetsSkipRuleActionSkip RuleNewParamsRulesetsSkipRuleAction = "skip" + ExecuteRuleActionExecute ExecuteRuleAction = "execute" ) -func (r RuleNewParamsRulesetsSkipRuleAction) IsKnown() bool { +func (r ExecuteRuleAction) IsKnown() bool { switch r { - case RuleNewParamsRulesetsSkipRuleActionSkip: + case ExecuteRuleActionExecute: return true } return false } // The parameters configuring the rule's action. -type RuleNewParamsRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]RuleNewParamsRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]RuleNewParamsRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[RuleNewParamsRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` -} - -func (r RuleNewParamsRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A phase to skip the execution of. -type RuleNewParamsRulesetsSkipRuleActionParametersPhase string - -const ( - RuleNewParamsRulesetsSkipRuleActionParametersPhaseDDoSL4 RuleNewParamsRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseDDoSL7 RuleNewParamsRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RuleNewParamsRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseMagicTransit RuleNewParamsRulesetsSkipRuleActionParametersPhase = "magic_transit" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RuleNewParamsRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RuleNewParamsRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RuleNewParamsRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -func (r RuleNewParamsRulesetsSkipRuleActionParametersPhase) IsKnown() bool { - switch r { - case RuleNewParamsRulesetsSkipRuleActionParametersPhaseDDoSL4, RuleNewParamsRulesetsSkipRuleActionParametersPhaseDDoSL7, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRatelimit, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged, RuleNewParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform, RuleNewParamsRulesetsSkipRuleActionParametersPhaseMagicTransit, RuleNewParamsRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged, RuleNewParamsRulesetsSkipRuleActionParametersPhaseMagicTransitManaged: - return true - } - return false -} - -// The name of a legacy security product to skip the execution of. -type RuleNewParamsRulesetsSkipRuleActionParametersProduct string - -const ( - RuleNewParamsRulesetsSkipRuleActionParametersProductBic RuleNewParamsRulesetsSkipRuleActionParametersProduct = "bic" - RuleNewParamsRulesetsSkipRuleActionParametersProductHot RuleNewParamsRulesetsSkipRuleActionParametersProduct = "hot" - RuleNewParamsRulesetsSkipRuleActionParametersProductRateLimit RuleNewParamsRulesetsSkipRuleActionParametersProduct = "rateLimit" - RuleNewParamsRulesetsSkipRuleActionParametersProductSecurityLevel RuleNewParamsRulesetsSkipRuleActionParametersProduct = "securityLevel" - RuleNewParamsRulesetsSkipRuleActionParametersProductUABlock RuleNewParamsRulesetsSkipRuleActionParametersProduct = "uaBlock" - RuleNewParamsRulesetsSkipRuleActionParametersProductWAF RuleNewParamsRulesetsSkipRuleActionParametersProduct = "waf" - RuleNewParamsRulesetsSkipRuleActionParametersProductZoneLockdown RuleNewParamsRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -func (r RuleNewParamsRulesetsSkipRuleActionParametersProduct) IsKnown() bool { - switch r { - case RuleNewParamsRulesetsSkipRuleActionParametersProductBic, RuleNewParamsRulesetsSkipRuleActionParametersProductHot, RuleNewParamsRulesetsSkipRuleActionParametersProductRateLimit, RuleNewParamsRulesetsSkipRuleActionParametersProductSecurityLevel, RuleNewParamsRulesetsSkipRuleActionParametersProductUABlock, RuleNewParamsRulesetsSkipRuleActionParametersProductWAF, RuleNewParamsRulesetsSkipRuleActionParametersProductZoneLockdown: - return true - } - return false -} - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RuleNewParamsRulesetsSkipRuleActionParametersRuleset string - -const ( - RuleNewParamsRulesetsSkipRuleActionParametersRulesetCurrent RuleNewParamsRulesetsSkipRuleActionParametersRuleset = "current" -) - -func (r RuleNewParamsRulesetsSkipRuleActionParametersRuleset) IsKnown() bool { - switch r { - case RuleNewParamsRulesetsSkipRuleActionParametersRulesetCurrent: - return true - } - return false -} - -// An object configuring the rule's logging behavior. -type RuleNewParamsRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RuleNewParamsRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A response object. -type RuleNewResponseEnvelope struct { - // A list of error messages. - Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` - // Whether the API call was successful. - Success RuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON ruleNewResponseEnvelopeJSON `json:"-"` +type ExecuteRuleActionParameters struct { + // The ID of the ruleset to execute. + ID string `json:"id,required"` + // The configuration to use for matched data logging. + MatchedData ExecuteRuleActionParametersMatchedData `json:"matched_data"` + // A set of overrides to apply to the target ruleset. + Overrides ExecuteRuleActionParametersOverrides `json:"overrides"` + JSON executeRuleActionParametersJSON `json:"-"` } -// ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelope] -type ruleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field +// executeRuleActionParametersJSON contains the JSON metadata for the struct +// [ExecuteRuleActionParameters] +type executeRuleActionParametersJSON struct { + ID apijson.Field + MatchedData apijson.Field + Overrides apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *ExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleNewResponseEnvelopeJSON) RawJSON() string { +func (r executeRuleActionParametersJSON) RawJSON() string { return r.raw } -// A message. -type RuleNewResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RuleNewResponseEnvelopeErrorsSource `json:"source"` - JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` +// The configuration to use for matched data logging. +type ExecuteRuleActionParametersMatchedData struct { + // The public key to encrypt matched data logs with. + PublicKey string `json:"public_key,required"` + JSON executeRuleActionParametersMatchedDataJSON `json:"-"` } -// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeErrors] -type ruleNewResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field +// executeRuleActionParametersMatchedDataJSON contains the JSON metadata for the +// struct [ExecuteRuleActionParametersMatchedData] +type executeRuleActionParametersMatchedDataJSON struct { + PublicKey apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { +func (r *ExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { +func (r executeRuleActionParametersMatchedDataJSON) RawJSON() string { return r.raw } -// The source of this message. -type RuleNewResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON ruleNewResponseEnvelopeErrorsSourceJSON `json:"-"` +// A set of overrides to apply to the target ruleset. +type ExecuteRuleActionParametersOverrides struct { + // An action to override all rules with. This option has lower precedence than rule + // and category overrides. + Action string `json:"action"` + // A list of category-level overrides. This option has the second-highest + // precedence after rule-level overrides. + Categories []ExecuteRuleActionParametersOverridesCategory `json:"categories"` + // Whether to enable execution of all rules. This option has lower precedence than + // rule and category overrides. + Enabled bool `json:"enabled"` + // A list of rule-level overrides. This option has the highest precedence. + Rules []ExecuteRuleActionParametersOverridesRule `json:"rules"` + // A sensitivity level to set for all rules. This option has lower precedence than + // rule and category overrides and is only applicable for DDoS phases. + SensitivityLevel ExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` + JSON executeRuleActionParametersOverridesJSON `json:"-"` } -// ruleNewResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the -// struct [RuleNewResponseEnvelopeErrorsSource] -type ruleNewResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field +// executeRuleActionParametersOverridesJSON contains the JSON metadata for the +// struct [ExecuteRuleActionParametersOverrides] +type executeRuleActionParametersOverridesJSON struct { + Action apijson.Field + Categories apijson.Field + Enabled apijson.Field + Rules apijson.Field + SensitivityLevel apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *RuleNewResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { +func (r *ExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleNewResponseEnvelopeErrorsSourceJSON) RawJSON() string { +func (r executeRuleActionParametersOverridesJSON) RawJSON() string { return r.raw } -// A message. -type RuleNewResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RuleNewResponseEnvelopeMessagesSource `json:"source"` - JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` +// A category-level override +type ExecuteRuleActionParametersOverridesCategory struct { + // The name of the category to override. + Category string `json:"category,required"` + // The action to override rules in the category with. + Action string `json:"action"` + // Whether to enable execution of rules in the category. + Enabled bool `json:"enabled"` + // The sensitivity level to use for rules in the category. + SensitivityLevel ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` + JSON executeRuleActionParametersOverridesCategoryJSON `json:"-"` } -// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeMessages] -type ruleNewResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field +// executeRuleActionParametersOverridesCategoryJSON contains the JSON metadata for +// the struct [ExecuteRuleActionParametersOverridesCategory] +type executeRuleActionParametersOverridesCategoryJSON struct { + Category apijson.Field + Action apijson.Field + Enabled apijson.Field + SensitivityLevel apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *ExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { +func (r executeRuleActionParametersOverridesCategoryJSON) RawJSON() string { return r.raw } -// The source of this message. -type RuleNewResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON ruleNewResponseEnvelopeMessagesSourceJSON `json:"-"` +// The sensitivity level to use for rules in the category. +type ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string + +const ( + ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" + ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" + ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" + ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" +) + +func (r ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel) IsKnown() bool { + switch r { + case ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault, ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium, ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow, ExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff: + return true + } + return false } -// ruleNewResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the -// struct [RuleNewResponseEnvelopeMessagesSource] -type ruleNewResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field +// A rule-level override +type ExecuteRuleActionParametersOverridesRule struct { + // The ID of the rule to override. + ID string `json:"id,required"` + // The action to override the rule with. + Action string `json:"action"` + // Whether to enable execution of the rule. + Enabled bool `json:"enabled"` + // The score threshold to use for the rule. + ScoreThreshold int64 `json:"score_threshold"` + // The sensitivity level to use for the rule. + SensitivityLevel ExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` + JSON executeRuleActionParametersOverridesRuleJSON `json:"-"` } -func (r *RuleNewResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { +// executeRuleActionParametersOverridesRuleJSON contains the JSON metadata for the +// struct [ExecuteRuleActionParametersOverridesRule] +type executeRuleActionParametersOverridesRuleJSON struct { + ID apijson.Field + Action apijson.Field + Enabled apijson.Field + ScoreThreshold apijson.Field + SensitivityLevel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleNewResponseEnvelopeMessagesSourceJSON) RawJSON() string { +func (r executeRuleActionParametersOverridesRuleJSON) RawJSON() string { return r.raw } -// Whether the API call was successful. -type RuleNewResponseEnvelopeSuccess bool +// The sensitivity level to use for the rule. +type ExecuteRuleActionParametersOverridesRulesSensitivityLevel string const ( - RuleNewResponseEnvelopeSuccessTrue RuleNewResponseEnvelopeSuccess = true + ExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault ExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" + ExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium ExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" + ExecuteRuleActionParametersOverridesRulesSensitivityLevelLow ExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" + ExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff ExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" ) -func (r RuleNewResponseEnvelopeSuccess) IsKnown() bool { +func (r ExecuteRuleActionParametersOverridesRulesSensitivityLevel) IsKnown() bool { switch r { - case RuleNewResponseEnvelopeSuccessTrue: + case ExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault, ExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium, ExecuteRuleActionParametersOverridesRulesSensitivityLevelLow, ExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff: return true } return false } -type RuleDeleteParams struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` -} +// A sensitivity level to set for all rules. This option has lower precedence than +// rule and category overrides and is only applicable for DDoS phases. +type ExecuteRuleActionParametersOverridesSensitivityLevel string -// A response object. -type RuleDeleteResponseEnvelope struct { - // A list of error messages. - Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` - // Whether the API call was successful. - Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON ruleDeleteResponseEnvelopeJSON `json:"-"` -} +const ( + ExecuteRuleActionParametersOverridesSensitivityLevelDefault ExecuteRuleActionParametersOverridesSensitivityLevel = "default" + ExecuteRuleActionParametersOverridesSensitivityLevelMedium ExecuteRuleActionParametersOverridesSensitivityLevel = "medium" + ExecuteRuleActionParametersOverridesSensitivityLevelLow ExecuteRuleActionParametersOverridesSensitivityLevel = "low" + ExecuteRuleActionParametersOverridesSensitivityLevelEoff ExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" +) -// ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelope] -type ruleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r ExecuteRuleActionParametersOverridesSensitivityLevel) IsKnown() bool { + switch r { + case ExecuteRuleActionParametersOverridesSensitivityLevelDefault, ExecuteRuleActionParametersOverridesSensitivityLevelMedium, ExecuteRuleActionParametersOverridesSensitivityLevelLow, ExecuteRuleActionParametersOverridesSensitivityLevelEoff: + return true + } + return false } -func (r *RuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type ExecuteRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[ExecuteRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[ExecuteRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` } -func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw +func (r ExecuteRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// A message. -type RuleDeleteResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RuleDeleteResponseEnvelopeErrorsSource `json:"source"` - JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} +func (r ExecuteRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} -// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeErrors] -type ruleDeleteResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} +func (r ExecuteRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} -func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r ExecuteRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type ExecuteRuleActionParametersParam struct { + // The ID of the ruleset to execute. + ID param.Field[string] `json:"id,required"` + // The configuration to use for matched data logging. + MatchedData param.Field[ExecuteRuleActionParametersMatchedDataParam] `json:"matched_data"` + // A set of overrides to apply to the target ruleset. + Overrides param.Field[ExecuteRuleActionParametersOverridesParam] `json:"overrides"` } -func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw +func (r ExecuteRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// The source of this message. -type RuleDeleteResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON ruleDeleteResponseEnvelopeErrorsSourceJSON `json:"-"` +// The configuration to use for matched data logging. +type ExecuteRuleActionParametersMatchedDataParam struct { + // The public key to encrypt matched data logs with. + PublicKey param.Field[string] `json:"public_key,required"` +} + +func (r ExecuteRuleActionParametersMatchedDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A set of overrides to apply to the target ruleset. +type ExecuteRuleActionParametersOverridesParam struct { + // An action to override all rules with. This option has lower precedence than rule + // and category overrides. + Action param.Field[string] `json:"action"` + // A list of category-level overrides. This option has the second-highest + // precedence after rule-level overrides. + Categories param.Field[[]ExecuteRuleActionParametersOverridesCategoryParam] `json:"categories"` + // Whether to enable execution of all rules. This option has lower precedence than + // rule and category overrides. + Enabled param.Field[bool] `json:"enabled"` + // A list of rule-level overrides. This option has the highest precedence. + Rules param.Field[[]ExecuteRuleActionParametersOverridesRuleParam] `json:"rules"` + // A sensitivity level to set for all rules. This option has lower precedence than + // rule and category overrides and is only applicable for DDoS phases. + SensitivityLevel param.Field[ExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r ExecuteRuleActionParametersOverridesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A category-level override +type ExecuteRuleActionParametersOverridesCategoryParam struct { + // The name of the category to override. + Category param.Field[string] `json:"category,required"` + // The action to override rules in the category with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of rules in the category. + Enabled param.Field[bool] `json:"enabled"` + // The sensitivity level to use for rules in the category. + SensitivityLevel param.Field[ExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r ExecuteRuleActionParametersOverridesCategoryParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A rule-level override +type ExecuteRuleActionParametersOverridesRuleParam struct { + // The ID of the rule to override. + ID param.Field[string] `json:"id,required"` + // The action to override the rule with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of the rule. + Enabled param.Field[bool] `json:"enabled"` + // The score threshold to use for the rule. + ScoreThreshold param.Field[int64] `json:"score_threshold"` + // The sensitivity level to use for the rule. + SensitivityLevel param.Field[ExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r ExecuteRuleActionParametersOverridesRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type JSChallengeRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action JSChallengeRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters interface{} `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON jsChallengeRuleJSON `json:"-"` +} + +// jsChallengeRuleJSON contains the JSON metadata for the struct [JSChallengeRule] +type jsChallengeRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JSChallengeRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jsChallengeRuleJSON) RawJSON() string { + return r.raw +} + +func (r JSChallengeRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsRuleNewResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsRuleEditResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsVersionGetResponseRule() {} + +func (r JSChallengeRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type JSChallengeRuleAction string + +const ( + JSChallengeRuleActionJSChallenge JSChallengeRuleAction = "js_challenge" +) + +func (r JSChallengeRuleAction) IsKnown() bool { + switch r { + case JSChallengeRuleActionJSChallenge: + return true + } + return false +} + +type JSChallengeRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[JSChallengeRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[interface{}] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r JSChallengeRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r JSChallengeRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r JSChallengeRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r JSChallengeRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +type LogRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action LogRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters interface{} `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON logRuleJSON `json:"-"` +} + +// logRuleJSON contains the JSON metadata for the struct [LogRule] +type logRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logRuleJSON) RawJSON() string { + return r.raw +} + +func (r LogRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r LogRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r LogRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r LogRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r LogRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r LogRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r LogRule) implementsRulesetsRuleNewResponseRule() {} + +func (r LogRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r LogRule) implementsRulesetsRuleEditResponseRule() {} + +func (r LogRule) implementsRulesetsVersionGetResponseRule() {} + +func (r LogRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type LogRuleAction string + +const ( + LogRuleActionLog LogRuleAction = "log" +) + +func (r LogRuleAction) IsKnown() bool { + switch r { + case LogRuleActionLog: + return true + } + return false +} + +type LogRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[LogRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[interface{}] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r LogRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r LogRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r LogRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r LogRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// An object configuring the rule's logging behavior. +type Logging struct { + // Whether to generate a log when the rule matches. + Enabled bool `json:"enabled,required"` + JSON loggingJSON `json:"-"` +} + +// loggingJSON contains the JSON metadata for the struct [Logging] +type loggingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Logging) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loggingJSON) RawJSON() string { + return r.raw +} + +// An object configuring the rule's logging behavior. +type LoggingParam struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r LoggingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ManagedChallengeRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action ManagedChallengeRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters interface{} `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON managedChallengeRuleJSON `json:"-"` +} + +// managedChallengeRuleJSON contains the JSON metadata for the struct +// [ManagedChallengeRule] +type managedChallengeRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ManagedChallengeRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r managedChallengeRuleJSON) RawJSON() string { + return r.raw +} + +func (r ManagedChallengeRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsRuleNewResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsRuleEditResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsVersionGetResponseRule() {} + +func (r ManagedChallengeRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type ManagedChallengeRuleAction string + +const ( + ManagedChallengeRuleActionManagedChallenge ManagedChallengeRuleAction = "managed_challenge" +) + +func (r ManagedChallengeRuleAction) IsKnown() bool { + switch r { + case ManagedChallengeRuleActionManagedChallenge: + return true + } + return false +} + +type ManagedChallengeRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[ManagedChallengeRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[interface{}] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r ManagedChallengeRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ManagedChallengeRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r ManagedChallengeRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r ManagedChallengeRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +type RedirectRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action RedirectRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters RedirectRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON redirectRuleJSON `json:"-"` +} + +// redirectRuleJSON contains the JSON metadata for the struct [RedirectRule] +type redirectRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RedirectRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r redirectRuleJSON) RawJSON() string { + return r.raw +} + +func (r RedirectRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r RedirectRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r RedirectRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r RedirectRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r RedirectRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r RedirectRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r RedirectRule) implementsRulesetsRuleNewResponseRule() {} + +func (r RedirectRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r RedirectRule) implementsRulesetsRuleEditResponseRule() {} + +func (r RedirectRule) implementsRulesetsVersionGetResponseRule() {} + +func (r RedirectRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type RedirectRuleAction string + +const ( + RedirectRuleActionRedirect RedirectRuleAction = "redirect" +) + +func (r RedirectRuleAction) IsKnown() bool { + switch r { + case RedirectRuleActionRedirect: + return true + } + return false +} + +// The parameters configuring the rule's action. +type RedirectRuleActionParameters struct { + // Serve a redirect based on a bulk list lookup. + FromList RedirectRuleActionParametersFromList `json:"from_list"` + // Serve a redirect based on the request properties. + FromValue RedirectRuleActionParametersFromValue `json:"from_value"` + JSON redirectRuleActionParametersJSON `json:"-"` +} + +// redirectRuleActionParametersJSON contains the JSON metadata for the struct +// [RedirectRuleActionParameters] +type redirectRuleActionParametersJSON struct { + FromList apijson.Field + FromValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RedirectRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r redirectRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// Serve a redirect based on a bulk list lookup. +type RedirectRuleActionParametersFromList struct { + // Expression that evaluates to the list lookup key. + Key string `json:"key"` + // The name of the list to match against. + Name string `json:"name"` + JSON redirectRuleActionParametersFromListJSON `json:"-"` +} + +// redirectRuleActionParametersFromListJSON contains the JSON metadata for the +// struct [RedirectRuleActionParametersFromList] +type redirectRuleActionParametersFromListJSON struct { + Key apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RedirectRuleActionParametersFromList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r redirectRuleActionParametersFromListJSON) RawJSON() string { + return r.raw +} + +// Serve a redirect based on the request properties. +type RedirectRuleActionParametersFromValue struct { + // Keep the query string of the original request. + PreserveQueryString bool `json:"preserve_query_string"` + // The status code to be used for the redirect. + StatusCode RedirectRuleActionParametersFromValueStatusCode `json:"status_code"` + // The URL to redirect the request to. + TargetURL RedirectRuleActionParametersFromValueTargetURL `json:"target_url"` + JSON redirectRuleActionParametersFromValueJSON `json:"-"` +} + +// redirectRuleActionParametersFromValueJSON contains the JSON metadata for the +// struct [RedirectRuleActionParametersFromValue] +type redirectRuleActionParametersFromValueJSON struct { + PreserveQueryString apijson.Field + StatusCode apijson.Field + TargetURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RedirectRuleActionParametersFromValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r redirectRuleActionParametersFromValueJSON) RawJSON() string { + return r.raw +} + +// The status code to be used for the redirect. +type RedirectRuleActionParametersFromValueStatusCode float64 + +const ( + RedirectRuleActionParametersFromValueStatusCode301 RedirectRuleActionParametersFromValueStatusCode = 301 + RedirectRuleActionParametersFromValueStatusCode302 RedirectRuleActionParametersFromValueStatusCode = 302 + RedirectRuleActionParametersFromValueStatusCode303 RedirectRuleActionParametersFromValueStatusCode = 303 + RedirectRuleActionParametersFromValueStatusCode307 RedirectRuleActionParametersFromValueStatusCode = 307 + RedirectRuleActionParametersFromValueStatusCode308 RedirectRuleActionParametersFromValueStatusCode = 308 +) + +func (r RedirectRuleActionParametersFromValueStatusCode) IsKnown() bool { + switch r { + case RedirectRuleActionParametersFromValueStatusCode301, RedirectRuleActionParametersFromValueStatusCode302, RedirectRuleActionParametersFromValueStatusCode303, RedirectRuleActionParametersFromValueStatusCode307, RedirectRuleActionParametersFromValueStatusCode308: + return true + } + return false +} + +// The URL to redirect the request to. +type RedirectRuleActionParametersFromValueTargetURL struct { + // The URL to redirect the request to. + Value string `json:"value"` + // An expression to evaluate to get the URL to redirect the request to. + Expression string `json:"expression"` + JSON redirectRuleActionParametersFromValueTargetURLJSON `json:"-"` + union RedirectRuleActionParametersFromValueTargetURLUnion +} + +// redirectRuleActionParametersFromValueTargetURLJSON contains the JSON metadata +// for the struct [RedirectRuleActionParametersFromValueTargetURL] +type redirectRuleActionParametersFromValueTargetURLJSON struct { + Value apijson.Field + Expression apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r redirectRuleActionParametersFromValueTargetURLJSON) RawJSON() string { + return r.raw +} + +func (r *RedirectRuleActionParametersFromValueTargetURL) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r RedirectRuleActionParametersFromValueTargetURL) AsUnion() RedirectRuleActionParametersFromValueTargetURLUnion { + return r.union +} + +// The URL to redirect the request to. +// +// Union satisfied by +// [rulesets.RedirectRuleActionParametersFromValueTargetURLStaticURLRedirect] or +// [rulesets.RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect]. +type RedirectRuleActionParametersFromValueTargetURLUnion interface { + implementsRulesetsRedirectRuleActionParametersFromValueTargetURL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RedirectRuleActionParametersFromValueTargetURLUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRuleActionParametersFromValueTargetURLStaticURLRedirect{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect{}), + }, + ) +} + +type RedirectRuleActionParametersFromValueTargetURLStaticURLRedirect struct { + // The URL to redirect the request to. + Value string `json:"value"` + JSON redirectRuleActionParametersFromValueTargetURLStaticURLRedirectJSON `json:"-"` +} + +// redirectRuleActionParametersFromValueTargetURLStaticURLRedirectJSON contains the +// JSON metadata for the struct +// [RedirectRuleActionParametersFromValueTargetURLStaticURLRedirect] +type redirectRuleActionParametersFromValueTargetURLStaticURLRedirectJSON struct { + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RedirectRuleActionParametersFromValueTargetURLStaticURLRedirect) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r redirectRuleActionParametersFromValueTargetURLStaticURLRedirectJSON) RawJSON() string { + return r.raw +} + +func (r RedirectRuleActionParametersFromValueTargetURLStaticURLRedirect) implementsRulesetsRedirectRuleActionParametersFromValueTargetURL() { +} + +type RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect struct { + // An expression to evaluate to get the URL to redirect the request to. + Expression string `json:"expression"` + JSON redirectRuleActionParametersFromValueTargetURLDynamicURLRedirectJSON `json:"-"` +} + +// redirectRuleActionParametersFromValueTargetURLDynamicURLRedirectJSON contains +// the JSON metadata for the struct +// [RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect] +type redirectRuleActionParametersFromValueTargetURLDynamicURLRedirectJSON struct { + Expression apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r redirectRuleActionParametersFromValueTargetURLDynamicURLRedirectJSON) RawJSON() string { + return r.raw +} + +func (r RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirect) implementsRulesetsRedirectRuleActionParametersFromValueTargetURL() { +} + +type RedirectRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RedirectRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RedirectRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RedirectRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RedirectRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r RedirectRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r RedirectRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type RedirectRuleActionParametersParam struct { + // Serve a redirect based on a bulk list lookup. + FromList param.Field[RedirectRuleActionParametersFromListParam] `json:"from_list"` + // Serve a redirect based on the request properties. + FromValue param.Field[RedirectRuleActionParametersFromValueParam] `json:"from_value"` +} + +func (r RedirectRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Serve a redirect based on a bulk list lookup. +type RedirectRuleActionParametersFromListParam struct { + // Expression that evaluates to the list lookup key. + Key param.Field[string] `json:"key"` + // The name of the list to match against. + Name param.Field[string] `json:"name"` +} + +func (r RedirectRuleActionParametersFromListParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Serve a redirect based on the request properties. +type RedirectRuleActionParametersFromValueParam struct { + // Keep the query string of the original request. + PreserveQueryString param.Field[bool] `json:"preserve_query_string"` + // The status code to be used for the redirect. + StatusCode param.Field[RedirectRuleActionParametersFromValueStatusCode] `json:"status_code"` + // The URL to redirect the request to. + TargetURL param.Field[RedirectRuleActionParametersFromValueTargetURLUnionParam] `json:"target_url"` +} + +func (r RedirectRuleActionParametersFromValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The URL to redirect the request to. +type RedirectRuleActionParametersFromValueTargetURLParam struct { + // The URL to redirect the request to. + Value param.Field[string] `json:"value"` + // An expression to evaluate to get the URL to redirect the request to. + Expression param.Field[string] `json:"expression"` +} + +func (r RedirectRuleActionParametersFromValueTargetURLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RedirectRuleActionParametersFromValueTargetURLParam) implementsRulesetsRedirectRuleActionParametersFromValueTargetURLUnionParam() { +} + +// The URL to redirect the request to. +// +// Satisfied by +// [rulesets.RedirectRuleActionParametersFromValueTargetURLStaticURLRedirectParam], +// [rulesets.RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirectParam], +// [RedirectRuleActionParametersFromValueTargetURLParam]. +type RedirectRuleActionParametersFromValueTargetURLUnionParam interface { + implementsRulesetsRedirectRuleActionParametersFromValueTargetURLUnionParam() +} + +type RedirectRuleActionParametersFromValueTargetURLStaticURLRedirectParam struct { + // The URL to redirect the request to. + Value param.Field[string] `json:"value"` +} + +func (r RedirectRuleActionParametersFromValueTargetURLStaticURLRedirectParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RedirectRuleActionParametersFromValueTargetURLStaticURLRedirectParam) implementsRulesetsRedirectRuleActionParametersFromValueTargetURLUnionParam() { +} + +type RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirectParam struct { + // An expression to evaluate to get the URL to redirect the request to. + Expression param.Field[string] `json:"expression"` +} + +func (r RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirectParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RedirectRuleActionParametersFromValueTargetURLDynamicURLRedirectParam) implementsRulesetsRedirectRuleActionParametersFromValueTargetURLUnionParam() { +} + +type RewriteRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action RewriteRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters RewriteRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON rewriteRuleJSON `json:"-"` +} + +// rewriteRuleJSON contains the JSON metadata for the struct [RewriteRule] +type rewriteRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteRuleJSON) RawJSON() string { + return r.raw +} + +func (r RewriteRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r RewriteRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r RewriteRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r RewriteRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r RewriteRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r RewriteRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r RewriteRule) implementsRulesetsRuleNewResponseRule() {} + +func (r RewriteRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r RewriteRule) implementsRulesetsRuleEditResponseRule() {} + +func (r RewriteRule) implementsRulesetsVersionGetResponseRule() {} + +func (r RewriteRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type RewriteRuleAction string + +const ( + RewriteRuleActionRewrite RewriteRuleAction = "rewrite" +) + +func (r RewriteRuleAction) IsKnown() bool { + switch r { + case RewriteRuleActionRewrite: + return true + } + return false +} + +// The parameters configuring the rule's action. +type RewriteRuleActionParameters struct { + // Map of request headers to modify. + Headers map[string]RewriteRuleActionParametersHeader `json:"headers"` + // URI to rewrite the request to. + URI RewriteRuleActionParametersURI `json:"uri"` + JSON rewriteRuleActionParametersJSON `json:"-"` +} + +// rewriteRuleActionParametersJSON contains the JSON metadata for the struct +// [RewriteRuleActionParameters] +type rewriteRuleActionParametersJSON struct { + Headers apijson.Field + URI apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// Remove the header from the request. +type RewriteRuleActionParametersHeader struct { + Operation RewriteRuleActionParametersHeadersOperation `json:"operation,required"` + // Static value for the header. + Value string `json:"value"` + // Expression for the header value. + Expression string `json:"expression"` + JSON rewriteRuleActionParametersHeaderJSON `json:"-"` + union RewriteRuleActionParametersHeadersUnion +} + +// rewriteRuleActionParametersHeaderJSON contains the JSON metadata for the struct +// [RewriteRuleActionParametersHeader] +type rewriteRuleActionParametersHeaderJSON struct { + Operation apijson.Field + Value apijson.Field + Expression apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r rewriteRuleActionParametersHeaderJSON) RawJSON() string { + return r.raw +} + +func (r *RewriteRuleActionParametersHeader) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r RewriteRuleActionParametersHeader) AsUnion() RewriteRuleActionParametersHeadersUnion { + return r.union +} + +// Remove the header from the request. +// +// Union satisfied by [rulesets.RewriteRuleActionParametersHeadersRemoveHeader], +// [rulesets.RewriteRuleActionParametersHeadersStaticHeader] or +// [rulesets.RewriteRuleActionParametersHeadersDynamicHeader]. +type RewriteRuleActionParametersHeadersUnion interface { + implementsRulesetsRewriteRuleActionParametersHeader() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RewriteRuleActionParametersHeadersUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRuleActionParametersHeadersRemoveHeader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRuleActionParametersHeadersStaticHeader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRuleActionParametersHeadersDynamicHeader{}), + }, + ) +} + +// Remove the header from the request. +type RewriteRuleActionParametersHeadersRemoveHeader struct { + Operation RewriteRuleActionParametersHeadersRemoveHeaderOperation `json:"operation,required"` + JSON rewriteRuleActionParametersHeadersRemoveHeaderJSON `json:"-"` +} + +// rewriteRuleActionParametersHeadersRemoveHeaderJSON contains the JSON metadata +// for the struct [RewriteRuleActionParametersHeadersRemoveHeader] +type rewriteRuleActionParametersHeadersRemoveHeaderJSON struct { + Operation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteRuleActionParametersHeadersRemoveHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteRuleActionParametersHeadersRemoveHeaderJSON) RawJSON() string { + return r.raw +} + +func (r RewriteRuleActionParametersHeadersRemoveHeader) implementsRulesetsRewriteRuleActionParametersHeader() { +} + +type RewriteRuleActionParametersHeadersRemoveHeaderOperation string + +const ( + RewriteRuleActionParametersHeadersRemoveHeaderOperationRemove RewriteRuleActionParametersHeadersRemoveHeaderOperation = "remove" +) + +func (r RewriteRuleActionParametersHeadersRemoveHeaderOperation) IsKnown() bool { + switch r { + case RewriteRuleActionParametersHeadersRemoveHeaderOperationRemove: + return true + } + return false +} + +// Set a request header with a static value. +type RewriteRuleActionParametersHeadersStaticHeader struct { + Operation RewriteRuleActionParametersHeadersStaticHeaderOperation `json:"operation,required"` + // Static value for the header. + Value string `json:"value,required"` + JSON rewriteRuleActionParametersHeadersStaticHeaderJSON `json:"-"` +} + +// rewriteRuleActionParametersHeadersStaticHeaderJSON contains the JSON metadata +// for the struct [RewriteRuleActionParametersHeadersStaticHeader] +type rewriteRuleActionParametersHeadersStaticHeaderJSON struct { + Operation apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteRuleActionParametersHeadersStaticHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteRuleActionParametersHeadersStaticHeaderJSON) RawJSON() string { + return r.raw +} + +func (r RewriteRuleActionParametersHeadersStaticHeader) implementsRulesetsRewriteRuleActionParametersHeader() { +} + +type RewriteRuleActionParametersHeadersStaticHeaderOperation string + +const ( + RewriteRuleActionParametersHeadersStaticHeaderOperationSet RewriteRuleActionParametersHeadersStaticHeaderOperation = "set" +) + +func (r RewriteRuleActionParametersHeadersStaticHeaderOperation) IsKnown() bool { + switch r { + case RewriteRuleActionParametersHeadersStaticHeaderOperationSet: + return true + } + return false +} + +// Set a request header with a dynamic value. +type RewriteRuleActionParametersHeadersDynamicHeader struct { + // Expression for the header value. + Expression string `json:"expression,required"` + Operation RewriteRuleActionParametersHeadersDynamicHeaderOperation `json:"operation,required"` + JSON rewriteRuleActionParametersHeadersDynamicHeaderJSON `json:"-"` +} + +// rewriteRuleActionParametersHeadersDynamicHeaderJSON contains the JSON metadata +// for the struct [RewriteRuleActionParametersHeadersDynamicHeader] +type rewriteRuleActionParametersHeadersDynamicHeaderJSON struct { + Expression apijson.Field + Operation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteRuleActionParametersHeadersDynamicHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteRuleActionParametersHeadersDynamicHeaderJSON) RawJSON() string { + return r.raw +} + +func (r RewriteRuleActionParametersHeadersDynamicHeader) implementsRulesetsRewriteRuleActionParametersHeader() { +} + +type RewriteRuleActionParametersHeadersDynamicHeaderOperation string + +const ( + RewriteRuleActionParametersHeadersDynamicHeaderOperationSet RewriteRuleActionParametersHeadersDynamicHeaderOperation = "set" +) + +func (r RewriteRuleActionParametersHeadersDynamicHeaderOperation) IsKnown() bool { + switch r { + case RewriteRuleActionParametersHeadersDynamicHeaderOperationSet: + return true + } + return false +} + +type RewriteRuleActionParametersHeadersOperation string + +const ( + RewriteRuleActionParametersHeadersOperationRemove RewriteRuleActionParametersHeadersOperation = "remove" + RewriteRuleActionParametersHeadersOperationSet RewriteRuleActionParametersHeadersOperation = "set" +) + +func (r RewriteRuleActionParametersHeadersOperation) IsKnown() bool { + switch r { + case RewriteRuleActionParametersHeadersOperationRemove, RewriteRuleActionParametersHeadersOperationSet: + return true + } + return false +} + +// URI to rewrite the request to. +type RewriteRuleActionParametersURI struct { + // Path portion rewrite. + Path RewriteURIPart `json:"path"` + // Query portion rewrite. + Query RewriteURIPart `json:"query"` + JSON rewriteRuleActionParametersURIJSON `json:"-"` +} + +// rewriteRuleActionParametersURIJSON contains the JSON metadata for the struct +// [RewriteRuleActionParametersURI] +type rewriteRuleActionParametersURIJSON struct { + Path apijson.Field + Query apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteRuleActionParametersURI) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteRuleActionParametersURIJSON) RawJSON() string { + return r.raw +} + +type RewriteRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RewriteRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RewriteRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RewriteRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r RewriteRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r RewriteRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type RewriteRuleActionParametersParam struct { + // Map of request headers to modify. + Headers param.Field[map[string]RewriteRuleActionParametersHeadersUnionParam] `json:"headers"` + // URI to rewrite the request to. + URI param.Field[RewriteRuleActionParametersURIParam] `json:"uri"` +} + +func (r RewriteRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Remove the header from the request. +type RewriteRuleActionParametersHeaderParam struct { + Operation param.Field[RewriteRuleActionParametersHeadersOperation] `json:"operation,required"` + // Static value for the header. + Value param.Field[string] `json:"value"` + // Expression for the header value. + Expression param.Field[string] `json:"expression"` +} + +func (r RewriteRuleActionParametersHeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteRuleActionParametersHeaderParam) implementsRulesetsRewriteRuleActionParametersHeadersUnionParam() { +} + +// Remove the header from the request. +// +// Satisfied by [rulesets.RewriteRuleActionParametersHeadersRemoveHeaderParam], +// [rulesets.RewriteRuleActionParametersHeadersStaticHeaderParam], +// [rulesets.RewriteRuleActionParametersHeadersDynamicHeaderParam], +// [RewriteRuleActionParametersHeaderParam]. +type RewriteRuleActionParametersHeadersUnionParam interface { + implementsRulesetsRewriteRuleActionParametersHeadersUnionParam() +} + +// Remove the header from the request. +type RewriteRuleActionParametersHeadersRemoveHeaderParam struct { + Operation param.Field[RewriteRuleActionParametersHeadersRemoveHeaderOperation] `json:"operation,required"` +} + +func (r RewriteRuleActionParametersHeadersRemoveHeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteRuleActionParametersHeadersRemoveHeaderParam) implementsRulesetsRewriteRuleActionParametersHeadersUnionParam() { +} + +// Set a request header with a static value. +type RewriteRuleActionParametersHeadersStaticHeaderParam struct { + Operation param.Field[RewriteRuleActionParametersHeadersStaticHeaderOperation] `json:"operation,required"` + // Static value for the header. + Value param.Field[string] `json:"value,required"` +} + +func (r RewriteRuleActionParametersHeadersStaticHeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteRuleActionParametersHeadersStaticHeaderParam) implementsRulesetsRewriteRuleActionParametersHeadersUnionParam() { +} + +// Set a request header with a dynamic value. +type RewriteRuleActionParametersHeadersDynamicHeaderParam struct { + // Expression for the header value. + Expression param.Field[string] `json:"expression,required"` + Operation param.Field[RewriteRuleActionParametersHeadersDynamicHeaderOperation] `json:"operation,required"` +} + +func (r RewriteRuleActionParametersHeadersDynamicHeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteRuleActionParametersHeadersDynamicHeaderParam) implementsRulesetsRewriteRuleActionParametersHeadersUnionParam() { +} + +// URI to rewrite the request to. +type RewriteRuleActionParametersURIParam struct { + // Path portion rewrite. + Path param.Field[RewriteURIPartUnionParam] `json:"path"` + // Query portion rewrite. + Query param.Field[RewriteURIPartUnionParam] `json:"query"` +} + +func (r RewriteRuleActionParametersURIParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RewriteURIPart struct { + // Predefined replacement value. + Value string `json:"value"` + // Expression to evaluate for the replacement value. + Expression string `json:"expression"` + JSON rewriteURIPartJSON `json:"-"` + union RewriteURIPartUnion +} + +// rewriteURIPartJSON contains the JSON metadata for the struct [RewriteURIPart] +type rewriteURIPartJSON struct { + Value apijson.Field + Expression apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r rewriteURIPartJSON) RawJSON() string { + return r.raw +} + +func (r *RewriteURIPart) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r RewriteURIPart) AsUnion() RewriteURIPartUnion { + return r.union +} + +// Union satisfied by [rulesets.RewriteURIPartStaticValue] or +// [rulesets.RewriteURIPartDynamicValue]. +type RewriteURIPartUnion interface { + implementsRulesetsRewriteURIPart() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RewriteURIPartUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteURIPartStaticValue{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteURIPartDynamicValue{}), + }, + ) +} + +type RewriteURIPartStaticValue struct { + // Predefined replacement value. + Value string `json:"value,required"` + JSON rewriteURIPartStaticValueJSON `json:"-"` +} + +// rewriteURIPartStaticValueJSON contains the JSON metadata for the struct +// [RewriteURIPartStaticValue] +type rewriteURIPartStaticValueJSON struct { + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteURIPartStaticValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteURIPartStaticValueJSON) RawJSON() string { + return r.raw +} + +func (r RewriteURIPartStaticValue) implementsRulesetsRewriteURIPart() {} + +type RewriteURIPartDynamicValue struct { + // Expression to evaluate for the replacement value. + Expression string `json:"expression,required"` + JSON rewriteURIPartDynamicValueJSON `json:"-"` +} + +// rewriteURIPartDynamicValueJSON contains the JSON metadata for the struct +// [RewriteURIPartDynamicValue] +type rewriteURIPartDynamicValueJSON struct { + Expression apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RewriteURIPartDynamicValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rewriteURIPartDynamicValueJSON) RawJSON() string { + return r.raw +} + +func (r RewriteURIPartDynamicValue) implementsRulesetsRewriteURIPart() {} + +type RewriteURIPartParam struct { + // Predefined replacement value. + Value param.Field[string] `json:"value"` + // Expression to evaluate for the replacement value. + Expression param.Field[string] `json:"expression"` +} + +func (r RewriteURIPartParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteURIPartParam) implementsRulesetsRewriteURIPartUnionParam() {} + +// Satisfied by [rulesets.RewriteURIPartStaticValueParam], +// [rulesets.RewriteURIPartDynamicValueParam], [RewriteURIPartParam]. +type RewriteURIPartUnionParam interface { + implementsRulesetsRewriteURIPartUnionParam() +} + +type RewriteURIPartStaticValueParam struct { + // Predefined replacement value. + Value param.Field[string] `json:"value,required"` +} + +func (r RewriteURIPartStaticValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteURIPartStaticValueParam) implementsRulesetsRewriteURIPartUnionParam() {} + +type RewriteURIPartDynamicValueParam struct { + // Expression to evaluate for the replacement value. + Expression param.Field[string] `json:"expression,required"` +} + +func (r RewriteURIPartDynamicValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RewriteURIPartDynamicValueParam) implementsRulesetsRewriteURIPartUnionParam() {} + +type RouteRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action RouteRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters RouteRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON routeRuleJSON `json:"-"` +} + +// routeRuleJSON contains the JSON metadata for the struct [RouteRule] +type routeRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeRuleJSON) RawJSON() string { + return r.raw +} + +func (r RouteRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r RouteRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r RouteRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r RouteRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r RouteRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r RouteRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r RouteRule) implementsRulesetsRuleNewResponseRule() {} + +func (r RouteRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r RouteRule) implementsRulesetsRuleEditResponseRule() {} + +func (r RouteRule) implementsRulesetsVersionGetResponseRule() {} + +func (r RouteRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type RouteRuleAction string + +const ( + RouteRuleActionRoute RouteRuleAction = "route" +) + +func (r RouteRuleAction) IsKnown() bool { + switch r { + case RouteRuleActionRoute: + return true + } + return false +} + +// The parameters configuring the rule's action. +type RouteRuleActionParameters struct { + // Rewrite the HTTP Host header. + HostHeader string `json:"host_header"` + // Override the IP/TCP destination. + Origin RouteRuleActionParametersOrigin `json:"origin"` + // Override the Server Name Indication (SNI). + Sni RouteRuleActionParametersSni `json:"sni"` + JSON routeRuleActionParametersJSON `json:"-"` +} + +// routeRuleActionParametersJSON contains the JSON metadata for the struct +// [RouteRuleActionParameters] +type routeRuleActionParametersJSON struct { + HostHeader apijson.Field + Origin apijson.Field + Sni apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// Override the IP/TCP destination. +type RouteRuleActionParametersOrigin struct { + // Override the resolved hostname. + Host string `json:"host"` + // Override the destination port. + Port float64 `json:"port"` + JSON routeRuleActionParametersOriginJSON `json:"-"` +} + +// routeRuleActionParametersOriginJSON contains the JSON metadata for the struct +// [RouteRuleActionParametersOrigin] +type routeRuleActionParametersOriginJSON struct { + Host apijson.Field + Port apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteRuleActionParametersOrigin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeRuleActionParametersOriginJSON) RawJSON() string { + return r.raw +} + +// Override the Server Name Indication (SNI). +type RouteRuleActionParametersSni struct { + // The SNI override. + Value string `json:"value,required"` + JSON routeRuleActionParametersSniJSON `json:"-"` +} + +// routeRuleActionParametersSniJSON contains the JSON metadata for the struct +// [RouteRuleActionParametersSni] +type routeRuleActionParametersSniJSON struct { + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteRuleActionParametersSni) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeRuleActionParametersSniJSON) RawJSON() string { + return r.raw +} + +type RouteRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RouteRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RouteRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RouteRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RouteRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r RouteRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r RouteRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type RouteRuleActionParametersParam struct { + // Rewrite the HTTP Host header. + HostHeader param.Field[string] `json:"host_header"` + // Override the IP/TCP destination. + Origin param.Field[RouteRuleActionParametersOriginParam] `json:"origin"` + // Override the Server Name Indication (SNI). + Sni param.Field[RouteRuleActionParametersSniParam] `json:"sni"` +} + +func (r RouteRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Override the IP/TCP destination. +type RouteRuleActionParametersOriginParam struct { + // Override the resolved hostname. + Host param.Field[string] `json:"host"` + // Override the destination port. + Port param.Field[float64] `json:"port"` +} + +func (r RouteRuleActionParametersOriginParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Override the Server Name Indication (SNI). +type RouteRuleActionParametersSniParam struct { + // The SNI override. + Value param.Field[string] `json:"value,required"` +} + +func (r RouteRuleActionParametersSniParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScoreRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action ScoreRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters ScoreRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON scoreRuleJSON `json:"-"` +} + +// scoreRuleJSON contains the JSON metadata for the struct [ScoreRule] +type scoreRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScoreRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scoreRuleJSON) RawJSON() string { + return r.raw +} + +func (r ScoreRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r ScoreRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r ScoreRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r ScoreRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r ScoreRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r ScoreRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r ScoreRule) implementsRulesetsRuleNewResponseRule() {} + +func (r ScoreRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r ScoreRule) implementsRulesetsRuleEditResponseRule() {} + +func (r ScoreRule) implementsRulesetsVersionGetResponseRule() {} + +func (r ScoreRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type ScoreRuleAction string + +const ( + ScoreRuleActionScore ScoreRuleAction = "score" +) + +func (r ScoreRuleAction) IsKnown() bool { + switch r { + case ScoreRuleActionScore: + return true + } + return false +} + +// The parameters configuring the rule's action. +type ScoreRuleActionParameters struct { + // Increment contains the delta to change the score and can be either positive or + // negative. + Increment int64 `json:"increment"` + JSON scoreRuleActionParametersJSON `json:"-"` +} + +// scoreRuleActionParametersJSON contains the JSON metadata for the struct +// [ScoreRuleActionParameters] +type scoreRuleActionParametersJSON struct { + Increment apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScoreRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scoreRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +type ScoreRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[ScoreRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[ScoreRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r ScoreRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScoreRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r ScoreRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r ScoreRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type ScoreRuleActionParametersParam struct { + // Increment contains the delta to change the score and can be either positive or + // negative. + Increment param.Field[int64] `json:"increment"` +} + +func (r ScoreRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServeErrorRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action ServeErrorRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters ServeErrorRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON serveErrorRuleJSON `json:"-"` +} + +// serveErrorRuleJSON contains the JSON metadata for the struct [ServeErrorRule] +type serveErrorRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServeErrorRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serveErrorRuleJSON) RawJSON() string { + return r.raw +} + +func (r ServeErrorRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsRuleNewResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsRuleEditResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsVersionGetResponseRule() {} + +func (r ServeErrorRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type ServeErrorRuleAction string + +const ( + ServeErrorRuleActionServeError ServeErrorRuleAction = "serve_error" +) + +func (r ServeErrorRuleAction) IsKnown() bool { + switch r { + case ServeErrorRuleActionServeError: + return true + } + return false +} + +// The parameters configuring the rule's action. +type ServeErrorRuleActionParameters struct { + // Error response content. + Content string `json:"content"` + // Content-type header to set with the response. + ContentType ServeErrorRuleActionParametersContentType `json:"content_type"` + // The status code to use for the error. + StatusCode float64 `json:"status_code"` + JSON serveErrorRuleActionParametersJSON `json:"-"` +} + +// serveErrorRuleActionParametersJSON contains the JSON metadata for the struct +// [ServeErrorRuleActionParameters] +type serveErrorRuleActionParametersJSON struct { + Content apijson.Field + ContentType apijson.Field + StatusCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServeErrorRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serveErrorRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// Content-type header to set with the response. +type ServeErrorRuleActionParametersContentType string + +const ( + ServeErrorRuleActionParametersContentTypeApplicationJson ServeErrorRuleActionParametersContentType = "application/json" + ServeErrorRuleActionParametersContentTypeTextXml ServeErrorRuleActionParametersContentType = "text/xml" + ServeErrorRuleActionParametersContentTypeTextPlain ServeErrorRuleActionParametersContentType = "text/plain" + ServeErrorRuleActionParametersContentTypeTextHTML ServeErrorRuleActionParametersContentType = "text/html" +) + +func (r ServeErrorRuleActionParametersContentType) IsKnown() bool { + switch r { + case ServeErrorRuleActionParametersContentTypeApplicationJson, ServeErrorRuleActionParametersContentTypeTextXml, ServeErrorRuleActionParametersContentTypeTextPlain, ServeErrorRuleActionParametersContentTypeTextHTML: + return true + } + return false +} + +type ServeErrorRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[ServeErrorRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[ServeErrorRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r ServeErrorRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServeErrorRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r ServeErrorRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r ServeErrorRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type ServeErrorRuleActionParametersParam struct { + // Error response content. + Content param.Field[string] `json:"content"` + // Content-type header to set with the response. + ContentType param.Field[ServeErrorRuleActionParametersContentType] `json:"content_type"` + // The status code to use for the error. + StatusCode param.Field[float64] `json:"status_code"` +} + +func (r ServeErrorRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SetCacheSettingsRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action SetCacheSettingsRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters SetCacheSettingsRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON setCacheSettingsRuleJSON `json:"-"` +} + +// setCacheSettingsRuleJSON contains the JSON metadata for the struct +// [SetCacheSettingsRule] +type setCacheSettingsRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleJSON) RawJSON() string { + return r.raw +} + +func (r SetCacheSettingsRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsRuleNewResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsRuleEditResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsVersionGetResponseRule() {} + +func (r SetCacheSettingsRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type SetCacheSettingsRuleAction string + +const ( + SetCacheSettingsRuleActionSetCacheSettings SetCacheSettingsRuleAction = "set_cache_settings" +) + +func (r SetCacheSettingsRuleAction) IsKnown() bool { + switch r { + case SetCacheSettingsRuleActionSetCacheSettings: + return true + } + return false +} + +// The parameters configuring the rule's action. +type SetCacheSettingsRuleActionParameters struct { + // List of additional ports that caching can be enabled on. + AdditionalCacheablePorts []int64 `json:"additional_cacheable_ports"` + // Specify how long client browsers should cache the response. Cloudflare cache + // purge will not purge content cached on client browsers, so high browser TTLs may + // lead to stale content. + BrowserTTL SetCacheSettingsRuleActionParametersBrowserTTL `json:"browser_ttl"` + // Mark whether the request’s response from origin is eligible for caching. Caching + // itself will still depend on the cache-control header and your other caching + // configurations. + Cache bool `json:"cache"` + // Define which components of the request are included or excluded from the cache + // key Cloudflare uses to store the response in cache. + CacheKey SetCacheSettingsRuleActionParametersCacheKey `json:"cache_key"` + // Mark whether the request's response from origin is eligible for Cache Reserve + // (requires a Cache Reserve add-on plan). + CacheReserve SetCacheSettingsRuleActionParametersCacheReserve `json:"cache_reserve"` + // TTL (Time to Live) specifies the maximum time to cache a resource in the + // Cloudflare edge network. + EdgeTTL SetCacheSettingsRuleActionParametersEdgeTTL `json:"edge_ttl"` + // When enabled, Cloudflare will aim to strictly adhere to RFC 7234. + OriginCacheControl bool `json:"origin_cache_control"` + // Generate Cloudflare error pages from issues sent from the origin server. When + // on, error pages will trigger for issues from the origin + OriginErrorPagePassthru bool `json:"origin_error_page_passthru"` + // Define a timeout value between two successive read operations to your origin + // server. Historically, the timeout value between two read options from Cloudflare + // to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + // errors because of timeouts from an origin server, try increasing this timeout + // value. + ReadTimeout int64 `json:"read_timeout"` + // Specify whether or not Cloudflare should respect strong ETag (entity tag) + // headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + RespectStrongEtags bool `json:"respect_strong_etags"` + // Define if Cloudflare should serve stale content while getting the latest content + // from the origin. If on, Cloudflare will not serve stale content while getting + // the latest content from the origin. + ServeStale SetCacheSettingsRuleActionParametersServeStale `json:"serve_stale"` + JSON setCacheSettingsRuleActionParametersJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersJSON contains the JSON metadata for the +// struct [SetCacheSettingsRuleActionParameters] +type setCacheSettingsRuleActionParametersJSON struct { + AdditionalCacheablePorts apijson.Field + BrowserTTL apijson.Field + Cache apijson.Field + CacheKey apijson.Field + CacheReserve apijson.Field + EdgeTTL apijson.Field + OriginCacheControl apijson.Field + OriginErrorPagePassthru apijson.Field + ReadTimeout apijson.Field + RespectStrongEtags apijson.Field + ServeStale apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// Specify how long client browsers should cache the response. Cloudflare cache +// purge will not purge content cached on client browsers, so high browser TTLs may +// lead to stale content. +type SetCacheSettingsRuleActionParametersBrowserTTL struct { + // Determines which browser ttl mode to use. + Mode SetCacheSettingsRuleActionParametersBrowserTTLMode `json:"mode,required"` + // The TTL (in seconds) if you choose override_origin mode. + Default int64 `json:"default"` + JSON setCacheSettingsRuleActionParametersBrowserTTLJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersBrowserTTLJSON contains the JSON metadata +// for the struct [SetCacheSettingsRuleActionParametersBrowserTTL] +type setCacheSettingsRuleActionParametersBrowserTTLJSON struct { + Mode apijson.Field + Default apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersBrowserTTL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersBrowserTTLJSON) RawJSON() string { + return r.raw +} + +// Determines which browser ttl mode to use. +type SetCacheSettingsRuleActionParametersBrowserTTLMode string + +const ( + SetCacheSettingsRuleActionParametersBrowserTTLModeRespectOrigin SetCacheSettingsRuleActionParametersBrowserTTLMode = "respect_origin" + SetCacheSettingsRuleActionParametersBrowserTTLModeBypassByDefault SetCacheSettingsRuleActionParametersBrowserTTLMode = "bypass_by_default" + SetCacheSettingsRuleActionParametersBrowserTTLModeOverrideOrigin SetCacheSettingsRuleActionParametersBrowserTTLMode = "override_origin" +) + +func (r SetCacheSettingsRuleActionParametersBrowserTTLMode) IsKnown() bool { + switch r { + case SetCacheSettingsRuleActionParametersBrowserTTLModeRespectOrigin, SetCacheSettingsRuleActionParametersBrowserTTLModeBypassByDefault, SetCacheSettingsRuleActionParametersBrowserTTLModeOverrideOrigin: + return true + } + return false +} + +// Define which components of the request are included or excluded from the cache +// key Cloudflare uses to store the response in cache. +type SetCacheSettingsRuleActionParametersCacheKey struct { + // Separate cached content based on the visitor’s device type + CacheByDeviceType bool `json:"cache_by_device_type"` + // Protect from web cache deception attacks while allowing static assets to be + // cached + CacheDeceptionArmor bool `json:"cache_deception_armor"` + // Customize which components of the request are included or excluded from the + // cache key. + CustomKey SetCacheSettingsRuleActionParametersCacheKeyCustomKey `json:"custom_key"` + // Treat requests with the same query parameters the same, regardless of the order + // those query parameters are in. A value of true ignores the query strings' order. + IgnoreQueryStringsOrder bool `json:"ignore_query_strings_order"` + JSON setCacheSettingsRuleActionParametersCacheKeyJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyJSON contains the JSON metadata for +// the struct [SetCacheSettingsRuleActionParametersCacheKey] +type setCacheSettingsRuleActionParametersCacheKeyJSON struct { + CacheByDeviceType apijson.Field + CacheDeceptionArmor apijson.Field + CustomKey apijson.Field + IgnoreQueryStringsOrder apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKey) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyJSON) RawJSON() string { + return r.raw +} + +// Customize which components of the request are included or excluded from the +// cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKey struct { + // The cookies to include in building the cache key. + Cookie SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie `json:"cookie"` + // The header names and values to include in building the cache key. + Header SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader `json:"header"` + // Whether to use the original host or the resolved host in the cache key. + Host SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost `json:"host"` + // Use the presence or absence of parameters in the query string to build the cache + // key. + QueryString SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString `json:"query_string"` + // Characteristics of the request user agent used in building the cache key. + User SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser `json:"user"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyJSON contains the JSON +// metadata for the struct [SetCacheSettingsRuleActionParametersCacheKeyCustomKey] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyJSON struct { + Cookie apijson.Field + Header apijson.Field + Host apijson.Field + QueryString apijson.Field + User apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKey) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyJSON) RawJSON() string { + return r.raw +} + +// The cookies to include in building the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie struct { + // Checks for the presence of these cookie names. The presence of these cookies is + // used in building the cache key. + CheckPresence []string `json:"check_presence"` + // Include these cookies' names and their values. + Include []string `json:"include"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyCookieJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyCookieJSON contains the +// JSON metadata for the struct +// [SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyCookieJSON struct { + CheckPresence apijson.Field + Include apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookie) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyCookieJSON) RawJSON() string { + return r.raw +} + +// The header names and values to include in building the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader struct { + // Checks for the presence of these header names. The presence of these headers is + // used in building the cache key. + CheckPresence []string `json:"check_presence"` + // Whether or not to include the origin header. A value of true will exclude the + // origin header in the cache key. + ExcludeOrigin bool `json:"exclude_origin"` + // Include these headers' names and their values. + Include []string `json:"include"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyHeaderJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyHeaderJSON contains the +// JSON metadata for the struct +// [SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyHeaderJSON struct { + CheckPresence apijson.Field + ExcludeOrigin apijson.Field + Include apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyHeaderJSON) RawJSON() string { + return r.raw +} + +// Whether to use the original host or the resolved host in the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost struct { + // Use the resolved host in the cache key. A value of true will use the resolved + // host, while a value or false will use the original host. + Resolved bool `json:"resolved"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyHostJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyHostJSON contains the JSON +// metadata for the struct +// [SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyHostJSON struct { + Resolved apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHost) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyHostJSON) RawJSON() string { + return r.raw +} + +// Use the presence or absence of parameters in the query string to build the cache +// key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString struct { + // build the cache key using all query string parameters EXCECPT these excluded + // parameters + Exclude SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude `json:"exclude"` + // build the cache key using a list of query string parameters that ARE in the + // request. + Include SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude `json:"include"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringJSON contains +// the JSON metadata for the struct +// [SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringJSON struct { + Exclude apijson.Field + Include apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryString) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringJSON) RawJSON() string { + return r.raw +} + +// build the cache key using all query string parameters EXCECPT these excluded +// parameters +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude struct { + // Exclude all query string parameters from use in building the cache key. + All bool `json:"all"` + // A list of query string parameters NOT used to build the cache key. All + // parameters present in the request but missing in this list will be used to build + // the cache key. + List []string `json:"list"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExcludeJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExcludeJSON +// contains the JSON metadata for the struct +// [SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExcludeJSON struct { + All apijson.Field + List apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExclude) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExcludeJSON) RawJSON() string { + return r.raw +} + +// build the cache key using a list of query string parameters that ARE in the +// request. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude struct { + // Use all query string parameters in the cache key. + All bool `json:"all"` + // A list of query string parameters used to build the cache key. + List []string `json:"list"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringIncludeJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringIncludeJSON +// contains the JSON metadata for the struct +// [SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringIncludeJSON struct { + All apijson.Field + List apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringInclude) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringIncludeJSON) RawJSON() string { + return r.raw +} + +// Characteristics of the request user agent used in building the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser struct { + // Use the user agent's device type in the cache key. + DeviceType bool `json:"device_type"` + // Use the user agents's country in the cache key. + Geo bool `json:"geo"` + // Use the user agent's language in the cache key. + Lang bool `json:"lang"` + JSON setCacheSettingsRuleActionParametersCacheKeyCustomKeyUserJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheKeyCustomKeyUserJSON contains the JSON +// metadata for the struct +// [SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser] +type setCacheSettingsRuleActionParametersCacheKeyCustomKeyUserJSON struct { + DeviceType apijson.Field + Geo apijson.Field + Lang apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUser) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheKeyCustomKeyUserJSON) RawJSON() string { + return r.raw +} + +// Mark whether the request's response from origin is eligible for Cache Reserve +// (requires a Cache Reserve add-on plan). +type SetCacheSettingsRuleActionParametersCacheReserve struct { + // Determines whether cache reserve is enabled. If this is true and a request meets + // eligibility criteria, Cloudflare will write the resource to cache reserve. + Eligible bool `json:"eligible,required"` + // The minimum file size eligible for store in cache reserve. + MinFileSize int64 `json:"min_file_size,required"` + JSON setCacheSettingsRuleActionParametersCacheReserveJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersCacheReserveJSON contains the JSON metadata +// for the struct [SetCacheSettingsRuleActionParametersCacheReserve] +type setCacheSettingsRuleActionParametersCacheReserveJSON struct { + Eligible apijson.Field + MinFileSize apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersCacheReserve) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersCacheReserveJSON) RawJSON() string { + return r.raw +} + +// TTL (Time to Live) specifies the maximum time to cache a resource in the +// Cloudflare edge network. +type SetCacheSettingsRuleActionParametersEdgeTTL struct { + // The TTL (in seconds) if you choose override_origin mode. + Default int64 `json:"default,required"` + // edge ttl options + Mode SetCacheSettingsRuleActionParametersEdgeTTLMode `json:"mode,required"` + // List of single status codes, or status code ranges to apply the selected mode + StatusCodeTTL []SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL `json:"status_code_ttl,required"` + JSON setCacheSettingsRuleActionParametersEdgeTTLJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersEdgeTTLJSON contains the JSON metadata for +// the struct [SetCacheSettingsRuleActionParametersEdgeTTL] +type setCacheSettingsRuleActionParametersEdgeTTLJSON struct { + Default apijson.Field + Mode apijson.Field + StatusCodeTTL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersEdgeTTL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersEdgeTTLJSON) RawJSON() string { + return r.raw +} + +// edge ttl options +type SetCacheSettingsRuleActionParametersEdgeTTLMode string + +const ( + SetCacheSettingsRuleActionParametersEdgeTTLModeRespectOrigin SetCacheSettingsRuleActionParametersEdgeTTLMode = "respect_origin" + SetCacheSettingsRuleActionParametersEdgeTTLModeBypassByDefault SetCacheSettingsRuleActionParametersEdgeTTLMode = "bypass_by_default" + SetCacheSettingsRuleActionParametersEdgeTTLModeOverrideOrigin SetCacheSettingsRuleActionParametersEdgeTTLMode = "override_origin" +) + +func (r SetCacheSettingsRuleActionParametersEdgeTTLMode) IsKnown() bool { + switch r { + case SetCacheSettingsRuleActionParametersEdgeTTLModeRespectOrigin, SetCacheSettingsRuleActionParametersEdgeTTLModeBypassByDefault, SetCacheSettingsRuleActionParametersEdgeTTLModeOverrideOrigin: + return true + } + return false +} + +// Specify how long Cloudflare should cache the response based on the status code +// from the origin. Can be a single status code or a range or status codes +type SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL struct { + // Time to cache a response (in seconds). A value of 0 is equivalent to setting the + // Cache-Control header with the value "no-cache". A value of -1 is equivalent to + // setting Cache-Control header with the value of "no-store". + Value int64 `json:"value,required"` + // The range of status codes used to apply the selected mode. + StatusCodeRange SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange `json:"status_code_range"` + // Set the ttl for responses with this specific status code + StatusCodeValue int64 `json:"status_code_value"` + JSON setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLJSON contains the JSON +// metadata for the struct +// [SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL] +type setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLJSON struct { + Value apijson.Field + StatusCodeRange apijson.Field + StatusCodeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLJSON) RawJSON() string { + return r.raw +} + +// The range of status codes used to apply the selected mode. +type SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange struct { + // response status code lower bound + From int64 `json:"from,required"` + // response status code upper bound + To int64 `json:"to,required"` + JSON setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeJSON +// contains the JSON metadata for the struct +// [SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange] +type setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeJSON) RawJSON() string { + return r.raw +} + +// Define if Cloudflare should serve stale content while getting the latest content +// from the origin. If on, Cloudflare will not serve stale content while getting +// the latest content from the origin. +type SetCacheSettingsRuleActionParametersServeStale struct { + // Defines whether Cloudflare should serve stale content while updating. If true, + // Cloudflare will not serve stale content while getting the latest content from + // the origin. + DisableStaleWhileUpdating bool `json:"disable_stale_while_updating,required"` + JSON setCacheSettingsRuleActionParametersServeStaleJSON `json:"-"` +} + +// setCacheSettingsRuleActionParametersServeStaleJSON contains the JSON metadata +// for the struct [SetCacheSettingsRuleActionParametersServeStale] +type setCacheSettingsRuleActionParametersServeStaleJSON struct { + DisableStaleWhileUpdating apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetCacheSettingsRuleActionParametersServeStale) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setCacheSettingsRuleActionParametersServeStaleJSON) RawJSON() string { + return r.raw +} + +type SetCacheSettingsRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[SetCacheSettingsRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[SetCacheSettingsRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r SetCacheSettingsRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SetCacheSettingsRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r SetCacheSettingsRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r SetCacheSettingsRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type SetCacheSettingsRuleActionParametersParam struct { + // List of additional ports that caching can be enabled on. + AdditionalCacheablePorts param.Field[[]int64] `json:"additional_cacheable_ports"` + // Specify how long client browsers should cache the response. Cloudflare cache + // purge will not purge content cached on client browsers, so high browser TTLs may + // lead to stale content. + BrowserTTL param.Field[SetCacheSettingsRuleActionParametersBrowserTTLParam] `json:"browser_ttl"` + // Mark whether the request’s response from origin is eligible for caching. Caching + // itself will still depend on the cache-control header and your other caching + // configurations. + Cache param.Field[bool] `json:"cache"` + // Define which components of the request are included or excluded from the cache + // key Cloudflare uses to store the response in cache. + CacheKey param.Field[SetCacheSettingsRuleActionParametersCacheKeyParam] `json:"cache_key"` + // Mark whether the request's response from origin is eligible for Cache Reserve + // (requires a Cache Reserve add-on plan). + CacheReserve param.Field[SetCacheSettingsRuleActionParametersCacheReserveParam] `json:"cache_reserve"` + // TTL (Time to Live) specifies the maximum time to cache a resource in the + // Cloudflare edge network. + EdgeTTL param.Field[SetCacheSettingsRuleActionParametersEdgeTTLParam] `json:"edge_ttl"` + // When enabled, Cloudflare will aim to strictly adhere to RFC 7234. + OriginCacheControl param.Field[bool] `json:"origin_cache_control"` + // Generate Cloudflare error pages from issues sent from the origin server. When + // on, error pages will trigger for issues from the origin + OriginErrorPagePassthru param.Field[bool] `json:"origin_error_page_passthru"` + // Define a timeout value between two successive read operations to your origin + // server. Historically, the timeout value between two read options from Cloudflare + // to an origin server is 100 seconds. If you are attempting to reduce HTTP 524 + // errors because of timeouts from an origin server, try increasing this timeout + // value. + ReadTimeout param.Field[int64] `json:"read_timeout"` + // Specify whether or not Cloudflare should respect strong ETag (entity tag) + // headers. When off, Cloudflare converts strong ETag headers to weak ETag headers. + RespectStrongEtags param.Field[bool] `json:"respect_strong_etags"` + // Define if Cloudflare should serve stale content while getting the latest content + // from the origin. If on, Cloudflare will not serve stale content while getting + // the latest content from the origin. + ServeStale param.Field[SetCacheSettingsRuleActionParametersServeStaleParam] `json:"serve_stale"` +} + +func (r SetCacheSettingsRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specify how long client browsers should cache the response. Cloudflare cache +// purge will not purge content cached on client browsers, so high browser TTLs may +// lead to stale content. +type SetCacheSettingsRuleActionParametersBrowserTTLParam struct { + // Determines which browser ttl mode to use. + Mode param.Field[SetCacheSettingsRuleActionParametersBrowserTTLMode] `json:"mode,required"` + // The TTL (in seconds) if you choose override_origin mode. + Default param.Field[int64] `json:"default"` +} + +func (r SetCacheSettingsRuleActionParametersBrowserTTLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Define which components of the request are included or excluded from the cache +// key Cloudflare uses to store the response in cache. +type SetCacheSettingsRuleActionParametersCacheKeyParam struct { + // Separate cached content based on the visitor’s device type + CacheByDeviceType param.Field[bool] `json:"cache_by_device_type"` + // Protect from web cache deception attacks while allowing static assets to be + // cached + CacheDeceptionArmor param.Field[bool] `json:"cache_deception_armor"` + // Customize which components of the request are included or excluded from the + // cache key. + CustomKey param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyParam] `json:"custom_key"` + // Treat requests with the same query parameters the same, regardless of the order + // those query parameters are in. A value of true ignores the query strings' order. + IgnoreQueryStringsOrder param.Field[bool] `json:"ignore_query_strings_order"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Customize which components of the request are included or excluded from the +// cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyParam struct { + // The cookies to include in building the cache key. + Cookie param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookieParam] `json:"cookie"` + // The header names and values to include in building the cache key. + Header param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeaderParam] `json:"header"` + // Whether to use the original host or the resolved host in the cache key. + Host param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHostParam] `json:"host"` + // Use the presence or absence of parameters in the query string to build the cache + // key. + QueryString param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringParam] `json:"query_string"` + // Characteristics of the request user agent used in building the cache key. + User param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUserParam] `json:"user"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The cookies to include in building the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookieParam struct { + // Checks for the presence of these cookie names. The presence of these cookies is + // used in building the cache key. + CheckPresence param.Field[[]string] `json:"check_presence"` + // Include these cookies' names and their values. + Include param.Field[[]string] `json:"include"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyCookieParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The header names and values to include in building the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeaderParam struct { + // Checks for the presence of these header names. The presence of these headers is + // used in building the cache key. + CheckPresence param.Field[[]string] `json:"check_presence"` + // Whether or not to include the origin header. A value of true will exclude the + // origin header in the cache key. + ExcludeOrigin param.Field[bool] `json:"exclude_origin"` + // Include these headers' names and their values. + Include param.Field[[]string] `json:"include"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Whether to use the original host or the resolved host in the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHostParam struct { + // Use the resolved host in the cache key. A value of true will use the resolved + // host, while a value or false will use the original host. + Resolved param.Field[bool] `json:"resolved"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyHostParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Use the presence or absence of parameters in the query string to build the cache +// key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringParam struct { + // build the cache key using all query string parameters EXCECPT these excluded + // parameters + Exclude param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExcludeParam] `json:"exclude"` + // build the cache key using a list of query string parameters that ARE in the + // request. + Include param.Field[SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringIncludeParam] `json:"include"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// build the cache key using all query string parameters EXCECPT these excluded +// parameters +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExcludeParam struct { + // Exclude all query string parameters from use in building the cache key. + All param.Field[bool] `json:"all"` + // A list of query string parameters NOT used to build the cache key. All + // parameters present in the request but missing in this list will be used to build + // the cache key. + List param.Field[[]string] `json:"list"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringExcludeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// build the cache key using a list of query string parameters that ARE in the +// request. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringIncludeParam struct { + // Use all query string parameters in the cache key. + All param.Field[bool] `json:"all"` + // A list of query string parameters used to build the cache key. + List param.Field[[]string] `json:"list"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyQueryStringIncludeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Characteristics of the request user agent used in building the cache key. +type SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUserParam struct { + // Use the user agent's device type in the cache key. + DeviceType param.Field[bool] `json:"device_type"` + // Use the user agents's country in the cache key. + Geo param.Field[bool] `json:"geo"` + // Use the user agent's language in the cache key. + Lang param.Field[bool] `json:"lang"` +} + +func (r SetCacheSettingsRuleActionParametersCacheKeyCustomKeyUserParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Mark whether the request's response from origin is eligible for Cache Reserve +// (requires a Cache Reserve add-on plan). +type SetCacheSettingsRuleActionParametersCacheReserveParam struct { + // Determines whether cache reserve is enabled. If this is true and a request meets + // eligibility criteria, Cloudflare will write the resource to cache reserve. + Eligible param.Field[bool] `json:"eligible,required"` + // The minimum file size eligible for store in cache reserve. + MinFileSize param.Field[int64] `json:"min_file_size,required"` +} + +func (r SetCacheSettingsRuleActionParametersCacheReserveParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// TTL (Time to Live) specifies the maximum time to cache a resource in the +// Cloudflare edge network. +type SetCacheSettingsRuleActionParametersEdgeTTLParam struct { + // The TTL (in seconds) if you choose override_origin mode. + Default param.Field[int64] `json:"default,required"` + // edge ttl options + Mode param.Field[SetCacheSettingsRuleActionParametersEdgeTTLMode] `json:"mode,required"` + // List of single status codes, or status code ranges to apply the selected mode + StatusCodeTTL param.Field[[]SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLParam] `json:"status_code_ttl,required"` +} + +func (r SetCacheSettingsRuleActionParametersEdgeTTLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specify how long Cloudflare should cache the response based on the status code +// from the origin. Can be a single status code or a range or status codes +type SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLParam struct { + // Time to cache a response (in seconds). A value of 0 is equivalent to setting the + // Cache-Control header with the value "no-cache". A value of -1 is equivalent to + // setting Cache-Control header with the value of "no-store". + Value param.Field[int64] `json:"value,required"` + // The range of status codes used to apply the selected mode. + StatusCodeRange param.Field[SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeParam] `json:"status_code_range"` + // Set the ttl for responses with this specific status code + StatusCodeValue param.Field[int64] `json:"status_code_value"` +} + +func (r SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The range of status codes used to apply the selected mode. +type SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeParam struct { + // response status code lower bound + From param.Field[int64] `json:"from,required"` + // response status code upper bound + To param.Field[int64] `json:"to,required"` +} + +func (r SetCacheSettingsRuleActionParametersEdgeTTLStatusCodeTTLStatusCodeRangeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Define if Cloudflare should serve stale content while getting the latest content +// from the origin. If on, Cloudflare will not serve stale content while getting +// the latest content from the origin. +type SetCacheSettingsRuleActionParametersServeStaleParam struct { + // Defines whether Cloudflare should serve stale content while updating. If true, + // Cloudflare will not serve stale content while getting the latest content from + // the origin. + DisableStaleWhileUpdating param.Field[bool] `json:"disable_stale_while_updating,required"` +} + +func (r SetCacheSettingsRuleActionParametersServeStaleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SetConfigRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action SetConfigRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters SetConfigRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON setConfigRuleJSON `json:"-"` +} + +// setConfigRuleJSON contains the JSON metadata for the struct [SetConfigRule] +type setConfigRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetConfigRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setConfigRuleJSON) RawJSON() string { + return r.raw +} + +func (r SetConfigRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r SetConfigRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r SetConfigRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r SetConfigRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r SetConfigRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r SetConfigRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r SetConfigRule) implementsRulesetsRuleNewResponseRule() {} + +func (r SetConfigRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r SetConfigRule) implementsRulesetsRuleEditResponseRule() {} + +func (r SetConfigRule) implementsRulesetsVersionGetResponseRule() {} + +func (r SetConfigRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type SetConfigRuleAction string + +const ( + SetConfigRuleActionSetConfig SetConfigRuleAction = "set_config" +) + +func (r SetConfigRuleAction) IsKnown() bool { + switch r { + case SetConfigRuleActionSetConfig: + return true + } + return false +} + +// The parameters configuring the rule's action. +type SetConfigRuleActionParameters struct { + // Turn on or off Automatic HTTPS Rewrites. + AutomaticHTTPSRewrites bool `json:"automatic_https_rewrites"` + // Select which file extensions to minify automatically. + Autominify SetConfigRuleActionParametersAutominify `json:"autominify"` + // Turn on or off Browser Integrity Check. + Bic bool `json:"bic"` + // Turn off all active Cloudflare Apps. + DisableApps bool `json:"disable_apps"` + // Turn off Zaraz. + DisableZaraz bool `json:"disable_zaraz"` + // Turn on or off Email Obfuscation. + EmailObfuscation bool `json:"email_obfuscation"` + // Turn on or off the Hotlink Protection. + HotlinkProtection bool `json:"hotlink_protection"` + // Turn on or off Mirage. + Mirage bool `json:"mirage"` + // Turn on or off Opportunistic Encryption. + OpportunisticEncryption bool `json:"opportunistic_encryption"` + // Configure the Polish level. + Polish SetConfigRuleActionParametersPolish `json:"polish"` + // Turn on or off Rocket Loader + RocketLoader bool `json:"rocket_loader"` + // Configure the Security Level. + SecurityLevel SetConfigRuleActionParametersSecurityLevel `json:"security_level"` + // Turn on or off Server Side Excludes. + ServerSideExcludes bool `json:"server_side_excludes"` + // Configure the SSL level. + SSL SetConfigRuleActionParametersSSL `json:"ssl"` + // Turn on or off Signed Exchanges (SXG). + Sxg bool `json:"sxg"` + JSON setConfigRuleActionParametersJSON `json:"-"` +} + +// setConfigRuleActionParametersJSON contains the JSON metadata for the struct +// [SetConfigRuleActionParameters] +type setConfigRuleActionParametersJSON struct { + AutomaticHTTPSRewrites apijson.Field + Autominify apijson.Field + Bic apijson.Field + DisableApps apijson.Field + DisableZaraz apijson.Field + EmailObfuscation apijson.Field + HotlinkProtection apijson.Field + Mirage apijson.Field + OpportunisticEncryption apijson.Field + Polish apijson.Field + RocketLoader apijson.Field + SecurityLevel apijson.Field + ServerSideExcludes apijson.Field + SSL apijson.Field + Sxg apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SetConfigRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r setConfigRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// Select which file extensions to minify automatically. +type SetConfigRuleActionParametersAutominify struct { + // Minify CSS files. + Css bool `json:"css"` + // Minify HTML files. + HTML bool `json:"html"` + // Minify JS files. + JS bool `json:"js"` + JSON setConfigRuleActionParametersAutominifyJSON `json:"-"` } -// ruleDeleteResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the -// struct [RuleDeleteResponseEnvelopeErrorsSource] -type ruleDeleteResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field +// setConfigRuleActionParametersAutominifyJSON contains the JSON metadata for the +// struct [SetConfigRuleActionParametersAutominify] +type setConfigRuleActionParametersAutominifyJSON struct { + Css apijson.Field + HTML apijson.Field + JS apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleDeleteResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { +func (r *SetConfigRuleActionParametersAutominify) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleDeleteResponseEnvelopeErrorsSourceJSON) RawJSON() string { +func (r setConfigRuleActionParametersAutominifyJSON) RawJSON() string { return r.raw } -// A message. -type RuleDeleteResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RuleDeleteResponseEnvelopeMessagesSource `json:"source"` - JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` +// Configure the Polish level. +type SetConfigRuleActionParametersPolish string + +const ( + SetConfigRuleActionParametersPolishOff SetConfigRuleActionParametersPolish = "off" + SetConfigRuleActionParametersPolishLossless SetConfigRuleActionParametersPolish = "lossless" + SetConfigRuleActionParametersPolishLossy SetConfigRuleActionParametersPolish = "lossy" +) + +func (r SetConfigRuleActionParametersPolish) IsKnown() bool { + switch r { + case SetConfigRuleActionParametersPolishOff, SetConfigRuleActionParametersPolishLossless, SetConfigRuleActionParametersPolishLossy: + return true + } + return false } -// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeMessages] -type ruleDeleteResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field +// Configure the Security Level. +type SetConfigRuleActionParametersSecurityLevel string + +const ( + SetConfigRuleActionParametersSecurityLevelOff SetConfigRuleActionParametersSecurityLevel = "off" + SetConfigRuleActionParametersSecurityLevelEssentiallyOff SetConfigRuleActionParametersSecurityLevel = "essentially_off" + SetConfigRuleActionParametersSecurityLevelLow SetConfigRuleActionParametersSecurityLevel = "low" + SetConfigRuleActionParametersSecurityLevelMedium SetConfigRuleActionParametersSecurityLevel = "medium" + SetConfigRuleActionParametersSecurityLevelHigh SetConfigRuleActionParametersSecurityLevel = "high" + SetConfigRuleActionParametersSecurityLevelUnderAttack SetConfigRuleActionParametersSecurityLevel = "under_attack" +) + +func (r SetConfigRuleActionParametersSecurityLevel) IsKnown() bool { + switch r { + case SetConfigRuleActionParametersSecurityLevelOff, SetConfigRuleActionParametersSecurityLevelEssentiallyOff, SetConfigRuleActionParametersSecurityLevelLow, SetConfigRuleActionParametersSecurityLevelMedium, SetConfigRuleActionParametersSecurityLevelHigh, SetConfigRuleActionParametersSecurityLevelUnderAttack: + return true + } + return false +} + +// Configure the SSL level. +type SetConfigRuleActionParametersSSL string + +const ( + SetConfigRuleActionParametersSSLOff SetConfigRuleActionParametersSSL = "off" + SetConfigRuleActionParametersSSLFlexible SetConfigRuleActionParametersSSL = "flexible" + SetConfigRuleActionParametersSSLFull SetConfigRuleActionParametersSSL = "full" + SetConfigRuleActionParametersSSLStrict SetConfigRuleActionParametersSSL = "strict" + SetConfigRuleActionParametersSSLOriginPull SetConfigRuleActionParametersSSL = "origin_pull" +) + +func (r SetConfigRuleActionParametersSSL) IsKnown() bool { + switch r { + case SetConfigRuleActionParametersSSLOff, SetConfigRuleActionParametersSSLFlexible, SetConfigRuleActionParametersSSLFull, SetConfigRuleActionParametersSSLStrict, SetConfigRuleActionParametersSSLOriginPull: + return true + } + return false +} + +type SetConfigRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[SetConfigRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[SetConfigRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r SetConfigRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SetConfigRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r SetConfigRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r SetConfigRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type SetConfigRuleActionParametersParam struct { + // Turn on or off Automatic HTTPS Rewrites. + AutomaticHTTPSRewrites param.Field[bool] `json:"automatic_https_rewrites"` + // Select which file extensions to minify automatically. + Autominify param.Field[SetConfigRuleActionParametersAutominifyParam] `json:"autominify"` + // Turn on or off Browser Integrity Check. + Bic param.Field[bool] `json:"bic"` + // Turn off all active Cloudflare Apps. + DisableApps param.Field[bool] `json:"disable_apps"` + // Turn off Zaraz. + DisableZaraz param.Field[bool] `json:"disable_zaraz"` + // Turn on or off Email Obfuscation. + EmailObfuscation param.Field[bool] `json:"email_obfuscation"` + // Turn on or off the Hotlink Protection. + HotlinkProtection param.Field[bool] `json:"hotlink_protection"` + // Turn on or off Mirage. + Mirage param.Field[bool] `json:"mirage"` + // Turn on or off Opportunistic Encryption. + OpportunisticEncryption param.Field[bool] `json:"opportunistic_encryption"` + // Configure the Polish level. + Polish param.Field[SetConfigRuleActionParametersPolish] `json:"polish"` + // Turn on or off Rocket Loader + RocketLoader param.Field[bool] `json:"rocket_loader"` + // Configure the Security Level. + SecurityLevel param.Field[SetConfigRuleActionParametersSecurityLevel] `json:"security_level"` + // Turn on or off Server Side Excludes. + ServerSideExcludes param.Field[bool] `json:"server_side_excludes"` + // Configure the SSL level. + SSL param.Field[SetConfigRuleActionParametersSSL] `json:"ssl"` + // Turn on or off Signed Exchanges (SXG). + Sxg param.Field[bool] `json:"sxg"` +} + +func (r SetConfigRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Select which file extensions to minify automatically. +type SetConfigRuleActionParametersAutominifyParam struct { + // Minify CSS files. + Css param.Field[bool] `json:"css"` + // Minify HTML files. + HTML param.Field[bool] `json:"html"` + // Minify JS files. + JS param.Field[bool] `json:"js"` +} + +func (r SetConfigRuleActionParametersAutominifyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SkipRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action SkipRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters SkipRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON skipRuleJSON `json:"-"` +} + +// skipRuleJSON contains the JSON metadata for the struct [SkipRule] +type skipRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SkipRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r skipRuleJSON) RawJSON() string { + return r.raw +} + +func (r SkipRule) implementsRulesetsRulesetNewResponseRule() {} + +func (r SkipRule) implementsRulesetsRulesetUpdateResponseRule() {} + +func (r SkipRule) implementsRulesetsRulesetGetResponseRule() {} + +func (r SkipRule) implementsRulesetsPhaseUpdateResponseRule() {} + +func (r SkipRule) implementsRulesetsPhaseGetResponseRule() {} + +func (r SkipRule) implementsRulesetsPhaseVersionGetResponseRule() {} + +func (r SkipRule) implementsRulesetsRuleNewResponseRule() {} + +func (r SkipRule) implementsRulesetsRuleDeleteResponseRule() {} + +func (r SkipRule) implementsRulesetsRuleEditResponseRule() {} + +func (r SkipRule) implementsRulesetsVersionGetResponseRule() {} + +func (r SkipRule) implementsRulesetsVersionByTagGetResponseRule() {} + +// The action to perform when the rule matches. +type SkipRuleAction string + +const ( + SkipRuleActionSkip SkipRuleAction = "skip" +) + +func (r SkipRuleAction) IsKnown() bool { + switch r { + case SkipRuleActionSkip: + return true + } + return false +} + +// The parameters configuring the rule's action. +type SkipRuleActionParameters struct { + // A list of phases to skip the execution of. This option is incompatible with the + // ruleset and rulesets options. + Phases []SkipRuleActionParametersPhase `json:"phases"` + // A list of legacy security products to skip the execution of. + Products []SkipRuleActionParametersProduct `json:"products"` + // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + // execution of. This option is incompatible with the ruleset option. + Rules map[string][]string `json:"rules"` + // A ruleset to skip the execution of. This option is incompatible with the + // rulesets, rules and phases options. + Ruleset SkipRuleActionParametersRuleset `json:"ruleset"` + // A list of ruleset IDs to skip the execution of. This option is incompatible with + // the ruleset and phases options. + Rulesets []string `json:"rulesets"` + JSON skipRuleActionParametersJSON `json:"-"` +} + +// skipRuleActionParametersJSON contains the JSON metadata for the struct +// [SkipRuleActionParameters] +type skipRuleActionParametersJSON struct { + Phases apijson.Field + Products apijson.Field + Rules apijson.Field + Ruleset apijson.Field + Rulesets apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *SkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { +func (r skipRuleActionParametersJSON) RawJSON() string { return r.raw } -// The source of this message. -type RuleDeleteResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON ruleDeleteResponseEnvelopeMessagesSourceJSON `json:"-"` +// A phase to skip the execution of. +type SkipRuleActionParametersPhase string + +const ( + SkipRuleActionParametersPhaseDDoSL4 SkipRuleActionParametersPhase = "ddos_l4" + SkipRuleActionParametersPhaseDDoSL7 SkipRuleActionParametersPhase = "ddos_l7" + SkipRuleActionParametersPhaseHTTPConfigSettings SkipRuleActionParametersPhase = "http_config_settings" + SkipRuleActionParametersPhaseHTTPCustomErrors SkipRuleActionParametersPhase = "http_custom_errors" + SkipRuleActionParametersPhaseHTTPLogCustomFields SkipRuleActionParametersPhase = "http_log_custom_fields" + SkipRuleActionParametersPhaseHTTPRatelimit SkipRuleActionParametersPhase = "http_ratelimit" + SkipRuleActionParametersPhaseHTTPRequestCacheSettings SkipRuleActionParametersPhase = "http_request_cache_settings" + SkipRuleActionParametersPhaseHTTPRequestDynamicRedirect SkipRuleActionParametersPhase = "http_request_dynamic_redirect" + SkipRuleActionParametersPhaseHTTPRequestFirewallCustom SkipRuleActionParametersPhase = "http_request_firewall_custom" + SkipRuleActionParametersPhaseHTTPRequestFirewallManaged SkipRuleActionParametersPhase = "http_request_firewall_managed" + SkipRuleActionParametersPhaseHTTPRequestLateTransform SkipRuleActionParametersPhase = "http_request_late_transform" + SkipRuleActionParametersPhaseHTTPRequestOrigin SkipRuleActionParametersPhase = "http_request_origin" + SkipRuleActionParametersPhaseHTTPRequestRedirect SkipRuleActionParametersPhase = "http_request_redirect" + SkipRuleActionParametersPhaseHTTPRequestSanitize SkipRuleActionParametersPhase = "http_request_sanitize" + SkipRuleActionParametersPhaseHTTPRequestSBFM SkipRuleActionParametersPhase = "http_request_sbfm" + SkipRuleActionParametersPhaseHTTPRequestSelectConfiguration SkipRuleActionParametersPhase = "http_request_select_configuration" + SkipRuleActionParametersPhaseHTTPRequestTransform SkipRuleActionParametersPhase = "http_request_transform" + SkipRuleActionParametersPhaseHTTPResponseCompression SkipRuleActionParametersPhase = "http_response_compression" + SkipRuleActionParametersPhaseHTTPResponseFirewallManaged SkipRuleActionParametersPhase = "http_response_firewall_managed" + SkipRuleActionParametersPhaseHTTPResponseHeadersTransform SkipRuleActionParametersPhase = "http_response_headers_transform" + SkipRuleActionParametersPhaseMagicTransit SkipRuleActionParametersPhase = "magic_transit" + SkipRuleActionParametersPhaseMagicTransitIDsManaged SkipRuleActionParametersPhase = "magic_transit_ids_managed" + SkipRuleActionParametersPhaseMagicTransitManaged SkipRuleActionParametersPhase = "magic_transit_managed" +) + +func (r SkipRuleActionParametersPhase) IsKnown() bool { + switch r { + case SkipRuleActionParametersPhaseDDoSL4, SkipRuleActionParametersPhaseDDoSL7, SkipRuleActionParametersPhaseHTTPConfigSettings, SkipRuleActionParametersPhaseHTTPCustomErrors, SkipRuleActionParametersPhaseHTTPLogCustomFields, SkipRuleActionParametersPhaseHTTPRatelimit, SkipRuleActionParametersPhaseHTTPRequestCacheSettings, SkipRuleActionParametersPhaseHTTPRequestDynamicRedirect, SkipRuleActionParametersPhaseHTTPRequestFirewallCustom, SkipRuleActionParametersPhaseHTTPRequestFirewallManaged, SkipRuleActionParametersPhaseHTTPRequestLateTransform, SkipRuleActionParametersPhaseHTTPRequestOrigin, SkipRuleActionParametersPhaseHTTPRequestRedirect, SkipRuleActionParametersPhaseHTTPRequestSanitize, SkipRuleActionParametersPhaseHTTPRequestSBFM, SkipRuleActionParametersPhaseHTTPRequestSelectConfiguration, SkipRuleActionParametersPhaseHTTPRequestTransform, SkipRuleActionParametersPhaseHTTPResponseCompression, SkipRuleActionParametersPhaseHTTPResponseFirewallManaged, SkipRuleActionParametersPhaseHTTPResponseHeadersTransform, SkipRuleActionParametersPhaseMagicTransit, SkipRuleActionParametersPhaseMagicTransitIDsManaged, SkipRuleActionParametersPhaseMagicTransitManaged: + return true + } + return false +} + +// The name of a legacy security product to skip the execution of. +type SkipRuleActionParametersProduct string + +const ( + SkipRuleActionParametersProductBic SkipRuleActionParametersProduct = "bic" + SkipRuleActionParametersProductHot SkipRuleActionParametersProduct = "hot" + SkipRuleActionParametersProductRateLimit SkipRuleActionParametersProduct = "rateLimit" + SkipRuleActionParametersProductSecurityLevel SkipRuleActionParametersProduct = "securityLevel" + SkipRuleActionParametersProductUABlock SkipRuleActionParametersProduct = "uaBlock" + SkipRuleActionParametersProductWAF SkipRuleActionParametersProduct = "waf" + SkipRuleActionParametersProductZoneLockdown SkipRuleActionParametersProduct = "zoneLockdown" +) + +func (r SkipRuleActionParametersProduct) IsKnown() bool { + switch r { + case SkipRuleActionParametersProductBic, SkipRuleActionParametersProductHot, SkipRuleActionParametersProductRateLimit, SkipRuleActionParametersProductSecurityLevel, SkipRuleActionParametersProductUABlock, SkipRuleActionParametersProductWAF, SkipRuleActionParametersProductZoneLockdown: + return true + } + return false +} + +// A ruleset to skip the execution of. This option is incompatible with the +// rulesets, rules and phases options. +type SkipRuleActionParametersRuleset string + +const ( + SkipRuleActionParametersRulesetCurrent SkipRuleActionParametersRuleset = "current" +) + +func (r SkipRuleActionParametersRuleset) IsKnown() bool { + switch r { + case SkipRuleActionParametersRulesetCurrent: + return true + } + return false +} + +type SkipRuleParam struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[SkipRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[SkipRuleActionParametersParam] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[LoggingParam] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r SkipRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SkipRuleParam) implementsRulesetsRulesetNewParamsRuleUnion() {} + +func (r SkipRuleParam) implementsRulesetsRulesetUpdateParamsRuleUnion() {} + +func (r SkipRuleParam) implementsRulesetsPhaseUpdateParamsRuleUnion() {} + +// The parameters configuring the rule's action. +type SkipRuleActionParametersParam struct { + // A list of phases to skip the execution of. This option is incompatible with the + // ruleset and rulesets options. + Phases param.Field[[]SkipRuleActionParametersPhase] `json:"phases"` + // A list of legacy security products to skip the execution of. + Products param.Field[[]SkipRuleActionParametersProduct] `json:"products"` + // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + // execution of. This option is incompatible with the ruleset option. + Rules param.Field[map[string][]string] `json:"rules"` + // A ruleset to skip the execution of. This option is incompatible with the + // rulesets, rules and phases options. + Ruleset param.Field[SkipRuleActionParametersRuleset] `json:"ruleset"` + // A list of ruleset IDs to skip the execution of. This option is incompatible with + // the ruleset and phases options. + Rulesets param.Field[[]string] `json:"rulesets"` +} + +func (r SkipRuleActionParametersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A ruleset object. +type RuleNewResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind RuleNewResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RuleNewResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []RuleNewResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON ruleNewResponseJSON `json:"-"` +} + +// ruleNewResponseJSON contains the JSON metadata for the struct [RuleNewResponse] +type ruleNewResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type RuleNewResponseKind string + +const ( + RuleNewResponseKindManaged RuleNewResponseKind = "managed" + RuleNewResponseKindCustom RuleNewResponseKind = "custom" + RuleNewResponseKindRoot RuleNewResponseKind = "root" + RuleNewResponseKindZone RuleNewResponseKind = "zone" +) + +func (r RuleNewResponseKind) IsKnown() bool { + switch r { + case RuleNewResponseKindManaged, RuleNewResponseKindCustom, RuleNewResponseKindRoot, RuleNewResponseKindZone: + return true + } + return false +} + +// The phase of the ruleset. +type RuleNewResponsePhase string + +const ( + RuleNewResponsePhaseDDoSL4 RuleNewResponsePhase = "ddos_l4" + RuleNewResponsePhaseDDoSL7 RuleNewResponsePhase = "ddos_l7" + RuleNewResponsePhaseHTTPConfigSettings RuleNewResponsePhase = "http_config_settings" + RuleNewResponsePhaseHTTPCustomErrors RuleNewResponsePhase = "http_custom_errors" + RuleNewResponsePhaseHTTPLogCustomFields RuleNewResponsePhase = "http_log_custom_fields" + RuleNewResponsePhaseHTTPRatelimit RuleNewResponsePhase = "http_ratelimit" + RuleNewResponsePhaseHTTPRequestCacheSettings RuleNewResponsePhase = "http_request_cache_settings" + RuleNewResponsePhaseHTTPRequestDynamicRedirect RuleNewResponsePhase = "http_request_dynamic_redirect" + RuleNewResponsePhaseHTTPRequestFirewallCustom RuleNewResponsePhase = "http_request_firewall_custom" + RuleNewResponsePhaseHTTPRequestFirewallManaged RuleNewResponsePhase = "http_request_firewall_managed" + RuleNewResponsePhaseHTTPRequestLateTransform RuleNewResponsePhase = "http_request_late_transform" + RuleNewResponsePhaseHTTPRequestOrigin RuleNewResponsePhase = "http_request_origin" + RuleNewResponsePhaseHTTPRequestRedirect RuleNewResponsePhase = "http_request_redirect" + RuleNewResponsePhaseHTTPRequestSanitize RuleNewResponsePhase = "http_request_sanitize" + RuleNewResponsePhaseHTTPRequestSBFM RuleNewResponsePhase = "http_request_sbfm" + RuleNewResponsePhaseHTTPRequestSelectConfiguration RuleNewResponsePhase = "http_request_select_configuration" + RuleNewResponsePhaseHTTPRequestTransform RuleNewResponsePhase = "http_request_transform" + RuleNewResponsePhaseHTTPResponseCompression RuleNewResponsePhase = "http_response_compression" + RuleNewResponsePhaseHTTPResponseFirewallManaged RuleNewResponsePhase = "http_response_firewall_managed" + RuleNewResponsePhaseHTTPResponseHeadersTransform RuleNewResponsePhase = "http_response_headers_transform" + RuleNewResponsePhaseMagicTransit RuleNewResponsePhase = "magic_transit" + RuleNewResponsePhaseMagicTransitIDsManaged RuleNewResponsePhase = "magic_transit_ids_managed" + RuleNewResponsePhaseMagicTransitManaged RuleNewResponsePhase = "magic_transit_managed" +) + +func (r RuleNewResponsePhase) IsKnown() bool { + switch r { + case RuleNewResponsePhaseDDoSL4, RuleNewResponsePhaseDDoSL7, RuleNewResponsePhaseHTTPConfigSettings, RuleNewResponsePhaseHTTPCustomErrors, RuleNewResponsePhaseHTTPLogCustomFields, RuleNewResponsePhaseHTTPRatelimit, RuleNewResponsePhaseHTTPRequestCacheSettings, RuleNewResponsePhaseHTTPRequestDynamicRedirect, RuleNewResponsePhaseHTTPRequestFirewallCustom, RuleNewResponsePhaseHTTPRequestFirewallManaged, RuleNewResponsePhaseHTTPRequestLateTransform, RuleNewResponsePhaseHTTPRequestOrigin, RuleNewResponsePhaseHTTPRequestRedirect, RuleNewResponsePhaseHTTPRequestSanitize, RuleNewResponsePhaseHTTPRequestSBFM, RuleNewResponsePhaseHTTPRequestSelectConfiguration, RuleNewResponsePhaseHTTPRequestTransform, RuleNewResponsePhaseHTTPResponseCompression, RuleNewResponsePhaseHTTPResponseFirewallManaged, RuleNewResponsePhaseHTTPResponseHeadersTransform, RuleNewResponsePhaseMagicTransit, RuleNewResponsePhaseMagicTransitIDsManaged, RuleNewResponsePhaseMagicTransitManaged: + return true + } + return false +} + +type RuleNewResponseRule struct { + // The action to perform when the rule matches. + Action RuleNewResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON ruleNewResponseRuleJSON `json:"-"` + union RuleNewResponseRulesUnion +} + +// ruleNewResponseRuleJSON contains the JSON metadata for the struct +// [RuleNewResponseRule] +type ruleNewResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r ruleNewResponseRuleJSON) RawJSON() string { + return r.raw +} + +func (r *RuleNewResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r RuleNewResponseRule) AsUnion() RuleNewResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type RuleNewResponseRulesUnion interface { + implementsRulesetsRuleNewResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RuleNewResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) +} + +// The action to perform when the rule matches. +type RuleNewResponseRulesAction string + +const ( + RuleNewResponseRulesActionBlock RuleNewResponseRulesAction = "block" + RuleNewResponseRulesActionChallenge RuleNewResponseRulesAction = "challenge" + RuleNewResponseRulesActionCompressResponse RuleNewResponseRulesAction = "compress_response" + RuleNewResponseRulesActionExecute RuleNewResponseRulesAction = "execute" + RuleNewResponseRulesActionJSChallenge RuleNewResponseRulesAction = "js_challenge" + RuleNewResponseRulesActionLog RuleNewResponseRulesAction = "log" + RuleNewResponseRulesActionManagedChallenge RuleNewResponseRulesAction = "managed_challenge" + RuleNewResponseRulesActionRedirect RuleNewResponseRulesAction = "redirect" + RuleNewResponseRulesActionRewrite RuleNewResponseRulesAction = "rewrite" + RuleNewResponseRulesActionRoute RuleNewResponseRulesAction = "route" + RuleNewResponseRulesActionScore RuleNewResponseRulesAction = "score" + RuleNewResponseRulesActionServeError RuleNewResponseRulesAction = "serve_error" + RuleNewResponseRulesActionSetConfig RuleNewResponseRulesAction = "set_config" + RuleNewResponseRulesActionSkip RuleNewResponseRulesAction = "skip" + RuleNewResponseRulesActionSetCacheSettings RuleNewResponseRulesAction = "set_cache_settings" +) + +func (r RuleNewResponseRulesAction) IsKnown() bool { + switch r { + case RuleNewResponseRulesActionBlock, RuleNewResponseRulesActionChallenge, RuleNewResponseRulesActionCompressResponse, RuleNewResponseRulesActionExecute, RuleNewResponseRulesActionJSChallenge, RuleNewResponseRulesActionLog, RuleNewResponseRulesActionManagedChallenge, RuleNewResponseRulesActionRedirect, RuleNewResponseRulesActionRewrite, RuleNewResponseRulesActionRoute, RuleNewResponseRulesActionScore, RuleNewResponseRulesActionServeError, RuleNewResponseRulesActionSetConfig, RuleNewResponseRulesActionSkip, RuleNewResponseRulesActionSetCacheSettings: + return true + } + return false } -// ruleDeleteResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the -// struct [RuleDeleteResponseEnvelopeMessagesSource] -type ruleDeleteResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field +// A ruleset object. +type RuleDeleteResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind RuleDeleteResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RuleDeleteResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []RuleDeleteResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON ruleDeleteResponseJSON `json:"-"` +} + +// ruleDeleteResponseJSON contains the JSON metadata for the struct +// [RuleDeleteResponse] +type ruleDeleteResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleDeleteResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { +func (r *RuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleDeleteResponseEnvelopeMessagesSourceJSON) RawJSON() string { +func (r ruleDeleteResponseJSON) RawJSON() string { return r.raw } -// Whether the API call was successful. -type RuleDeleteResponseEnvelopeSuccess bool +// The kind of the ruleset. +type RuleDeleteResponseKind string const ( - RuleDeleteResponseEnvelopeSuccessTrue RuleDeleteResponseEnvelopeSuccess = true + RuleDeleteResponseKindManaged RuleDeleteResponseKind = "managed" + RuleDeleteResponseKindCustom RuleDeleteResponseKind = "custom" + RuleDeleteResponseKindRoot RuleDeleteResponseKind = "root" + RuleDeleteResponseKindZone RuleDeleteResponseKind = "zone" ) -func (r RuleDeleteResponseEnvelopeSuccess) IsKnown() bool { +func (r RuleDeleteResponseKind) IsKnown() bool { switch r { - case RuleDeleteResponseEnvelopeSuccessTrue: + case RuleDeleteResponseKindManaged, RuleDeleteResponseKindCustom, RuleDeleteResponseKindRoot, RuleDeleteResponseKindZone: return true } return false } -// This interface is a union satisfied by one of the following: -// [RuleEditParamsRulesetsBlockRule], [RuleEditParamsRulesetsExecuteRule], -// [RuleEditParamsRulesetsLogRule], [RuleEditParamsRulesetsSkipRule]. -type RuleEditParams interface { - ImplementsRuleEditParams() +// The phase of the ruleset. +type RuleDeleteResponsePhase string - getAccountID() param.Field[string] +const ( + RuleDeleteResponsePhaseDDoSL4 RuleDeleteResponsePhase = "ddos_l4" + RuleDeleteResponsePhaseDDoSL7 RuleDeleteResponsePhase = "ddos_l7" + RuleDeleteResponsePhaseHTTPConfigSettings RuleDeleteResponsePhase = "http_config_settings" + RuleDeleteResponsePhaseHTTPCustomErrors RuleDeleteResponsePhase = "http_custom_errors" + RuleDeleteResponsePhaseHTTPLogCustomFields RuleDeleteResponsePhase = "http_log_custom_fields" + RuleDeleteResponsePhaseHTTPRatelimit RuleDeleteResponsePhase = "http_ratelimit" + RuleDeleteResponsePhaseHTTPRequestCacheSettings RuleDeleteResponsePhase = "http_request_cache_settings" + RuleDeleteResponsePhaseHTTPRequestDynamicRedirect RuleDeleteResponsePhase = "http_request_dynamic_redirect" + RuleDeleteResponsePhaseHTTPRequestFirewallCustom RuleDeleteResponsePhase = "http_request_firewall_custom" + RuleDeleteResponsePhaseHTTPRequestFirewallManaged RuleDeleteResponsePhase = "http_request_firewall_managed" + RuleDeleteResponsePhaseHTTPRequestLateTransform RuleDeleteResponsePhase = "http_request_late_transform" + RuleDeleteResponsePhaseHTTPRequestOrigin RuleDeleteResponsePhase = "http_request_origin" + RuleDeleteResponsePhaseHTTPRequestRedirect RuleDeleteResponsePhase = "http_request_redirect" + RuleDeleteResponsePhaseHTTPRequestSanitize RuleDeleteResponsePhase = "http_request_sanitize" + RuleDeleteResponsePhaseHTTPRequestSBFM RuleDeleteResponsePhase = "http_request_sbfm" + RuleDeleteResponsePhaseHTTPRequestSelectConfiguration RuleDeleteResponsePhase = "http_request_select_configuration" + RuleDeleteResponsePhaseHTTPRequestTransform RuleDeleteResponsePhase = "http_request_transform" + RuleDeleteResponsePhaseHTTPResponseCompression RuleDeleteResponsePhase = "http_response_compression" + RuleDeleteResponsePhaseHTTPResponseFirewallManaged RuleDeleteResponsePhase = "http_response_firewall_managed" + RuleDeleteResponsePhaseHTTPResponseHeadersTransform RuleDeleteResponsePhase = "http_response_headers_transform" + RuleDeleteResponsePhaseMagicTransit RuleDeleteResponsePhase = "magic_transit" + RuleDeleteResponsePhaseMagicTransitIDsManaged RuleDeleteResponsePhase = "magic_transit_ids_managed" + RuleDeleteResponsePhaseMagicTransitManaged RuleDeleteResponsePhase = "magic_transit_managed" +) - getZoneID() param.Field[string] +func (r RuleDeleteResponsePhase) IsKnown() bool { + switch r { + case RuleDeleteResponsePhaseDDoSL4, RuleDeleteResponsePhaseDDoSL7, RuleDeleteResponsePhaseHTTPConfigSettings, RuleDeleteResponsePhaseHTTPCustomErrors, RuleDeleteResponsePhaseHTTPLogCustomFields, RuleDeleteResponsePhaseHTTPRatelimit, RuleDeleteResponsePhaseHTTPRequestCacheSettings, RuleDeleteResponsePhaseHTTPRequestDynamicRedirect, RuleDeleteResponsePhaseHTTPRequestFirewallCustom, RuleDeleteResponsePhaseHTTPRequestFirewallManaged, RuleDeleteResponsePhaseHTTPRequestLateTransform, RuleDeleteResponsePhaseHTTPRequestOrigin, RuleDeleteResponsePhaseHTTPRequestRedirect, RuleDeleteResponsePhaseHTTPRequestSanitize, RuleDeleteResponsePhaseHTTPRequestSBFM, RuleDeleteResponsePhaseHTTPRequestSelectConfiguration, RuleDeleteResponsePhaseHTTPRequestTransform, RuleDeleteResponsePhaseHTTPResponseCompression, RuleDeleteResponsePhaseHTTPResponseFirewallManaged, RuleDeleteResponsePhaseHTTPResponseHeadersTransform, RuleDeleteResponsePhaseMagicTransit, RuleDeleteResponsePhaseMagicTransitIDsManaged, RuleDeleteResponsePhaseMagicTransitManaged: + return true + } + return false } -type RuleEditParamsRulesetsBlockRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` - // The unique ID of the rule. - ID param.Field[string] `json:"id"` +type RuleDeleteResponseRule struct { // The action to perform when the rule matches. - Action param.Field[RuleEditParamsRulesetsBlockRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RuleEditParamsRulesetsBlockRuleActionParameters] `json:"action_parameters"` + Action RuleDeleteResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` // An informative description of the rule. - Description param.Field[string] `json:"description"` + Description string `json:"description"` // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` + Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // An object configuring the rule's logging behavior. - Logging param.Field[RuleEditParamsRulesetsBlockRuleLogging] `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON ruleDeleteResponseRuleJSON `json:"-"` + union RuleDeleteResponseRulesUnion +} + +// ruleDeleteResponseRuleJSON contains the JSON metadata for the struct +// [RuleDeleteResponseRule] +type ruleDeleteResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r ruleDeleteResponseRuleJSON) RawJSON() string { + return r.raw } -func (r RuleEditParamsRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *RuleDeleteResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r RuleDeleteResponseRule) AsUnion() RuleDeleteResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type RuleDeleteResponseRulesUnion interface { + implementsRulesetsRuleDeleteResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RuleDeleteResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) +} + +// The action to perform when the rule matches. +type RuleDeleteResponseRulesAction string + +const ( + RuleDeleteResponseRulesActionBlock RuleDeleteResponseRulesAction = "block" + RuleDeleteResponseRulesActionChallenge RuleDeleteResponseRulesAction = "challenge" + RuleDeleteResponseRulesActionCompressResponse RuleDeleteResponseRulesAction = "compress_response" + RuleDeleteResponseRulesActionExecute RuleDeleteResponseRulesAction = "execute" + RuleDeleteResponseRulesActionJSChallenge RuleDeleteResponseRulesAction = "js_challenge" + RuleDeleteResponseRulesActionLog RuleDeleteResponseRulesAction = "log" + RuleDeleteResponseRulesActionManagedChallenge RuleDeleteResponseRulesAction = "managed_challenge" + RuleDeleteResponseRulesActionRedirect RuleDeleteResponseRulesAction = "redirect" + RuleDeleteResponseRulesActionRewrite RuleDeleteResponseRulesAction = "rewrite" + RuleDeleteResponseRulesActionRoute RuleDeleteResponseRulesAction = "route" + RuleDeleteResponseRulesActionScore RuleDeleteResponseRulesAction = "score" + RuleDeleteResponseRulesActionServeError RuleDeleteResponseRulesAction = "serve_error" + RuleDeleteResponseRulesActionSetConfig RuleDeleteResponseRulesAction = "set_config" + RuleDeleteResponseRulesActionSkip RuleDeleteResponseRulesAction = "skip" + RuleDeleteResponseRulesActionSetCacheSettings RuleDeleteResponseRulesAction = "set_cache_settings" +) + +func (r RuleDeleteResponseRulesAction) IsKnown() bool { + switch r { + case RuleDeleteResponseRulesActionBlock, RuleDeleteResponseRulesActionChallenge, RuleDeleteResponseRulesActionCompressResponse, RuleDeleteResponseRulesActionExecute, RuleDeleteResponseRulesActionJSChallenge, RuleDeleteResponseRulesActionLog, RuleDeleteResponseRulesActionManagedChallenge, RuleDeleteResponseRulesActionRedirect, RuleDeleteResponseRulesActionRewrite, RuleDeleteResponseRulesActionRoute, RuleDeleteResponseRulesActionScore, RuleDeleteResponseRulesActionServeError, RuleDeleteResponseRulesActionSetConfig, RuleDeleteResponseRulesActionSkip, RuleDeleteResponseRulesActionSetCacheSettings: + return true + } + return false +} + +// A ruleset object. +type RuleEditResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind RuleEditResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RuleEditResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []RuleEditResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON ruleEditResponseJSON `json:"-"` +} + +// ruleEditResponseJSON contains the JSON metadata for the struct +// [RuleEditResponse] +type ruleEditResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseJSON) RawJSON() string { + return r.raw } -func (r RuleEditParamsRulesetsBlockRule) getAccountID() param.Field[string] { - return r.AccountID +// The kind of the ruleset. +type RuleEditResponseKind string + +const ( + RuleEditResponseKindManaged RuleEditResponseKind = "managed" + RuleEditResponseKindCustom RuleEditResponseKind = "custom" + RuleEditResponseKindRoot RuleEditResponseKind = "root" + RuleEditResponseKindZone RuleEditResponseKind = "zone" +) + +func (r RuleEditResponseKind) IsKnown() bool { + switch r { + case RuleEditResponseKindManaged, RuleEditResponseKindCustom, RuleEditResponseKindRoot, RuleEditResponseKindZone: + return true + } + return false } -func (r RuleEditParamsRulesetsBlockRule) getZoneID() param.Field[string] { - return r.ZoneID +// The phase of the ruleset. +type RuleEditResponsePhase string + +const ( + RuleEditResponsePhaseDDoSL4 RuleEditResponsePhase = "ddos_l4" + RuleEditResponsePhaseDDoSL7 RuleEditResponsePhase = "ddos_l7" + RuleEditResponsePhaseHTTPConfigSettings RuleEditResponsePhase = "http_config_settings" + RuleEditResponsePhaseHTTPCustomErrors RuleEditResponsePhase = "http_custom_errors" + RuleEditResponsePhaseHTTPLogCustomFields RuleEditResponsePhase = "http_log_custom_fields" + RuleEditResponsePhaseHTTPRatelimit RuleEditResponsePhase = "http_ratelimit" + RuleEditResponsePhaseHTTPRequestCacheSettings RuleEditResponsePhase = "http_request_cache_settings" + RuleEditResponsePhaseHTTPRequestDynamicRedirect RuleEditResponsePhase = "http_request_dynamic_redirect" + RuleEditResponsePhaseHTTPRequestFirewallCustom RuleEditResponsePhase = "http_request_firewall_custom" + RuleEditResponsePhaseHTTPRequestFirewallManaged RuleEditResponsePhase = "http_request_firewall_managed" + RuleEditResponsePhaseHTTPRequestLateTransform RuleEditResponsePhase = "http_request_late_transform" + RuleEditResponsePhaseHTTPRequestOrigin RuleEditResponsePhase = "http_request_origin" + RuleEditResponsePhaseHTTPRequestRedirect RuleEditResponsePhase = "http_request_redirect" + RuleEditResponsePhaseHTTPRequestSanitize RuleEditResponsePhase = "http_request_sanitize" + RuleEditResponsePhaseHTTPRequestSBFM RuleEditResponsePhase = "http_request_sbfm" + RuleEditResponsePhaseHTTPRequestSelectConfiguration RuleEditResponsePhase = "http_request_select_configuration" + RuleEditResponsePhaseHTTPRequestTransform RuleEditResponsePhase = "http_request_transform" + RuleEditResponsePhaseHTTPResponseCompression RuleEditResponsePhase = "http_response_compression" + RuleEditResponsePhaseHTTPResponseFirewallManaged RuleEditResponsePhase = "http_response_firewall_managed" + RuleEditResponsePhaseHTTPResponseHeadersTransform RuleEditResponsePhase = "http_response_headers_transform" + RuleEditResponsePhaseMagicTransit RuleEditResponsePhase = "magic_transit" + RuleEditResponsePhaseMagicTransitIDsManaged RuleEditResponsePhase = "magic_transit_ids_managed" + RuleEditResponsePhaseMagicTransitManaged RuleEditResponsePhase = "magic_transit_managed" +) + +func (r RuleEditResponsePhase) IsKnown() bool { + switch r { + case RuleEditResponsePhaseDDoSL4, RuleEditResponsePhaseDDoSL7, RuleEditResponsePhaseHTTPConfigSettings, RuleEditResponsePhaseHTTPCustomErrors, RuleEditResponsePhaseHTTPLogCustomFields, RuleEditResponsePhaseHTTPRatelimit, RuleEditResponsePhaseHTTPRequestCacheSettings, RuleEditResponsePhaseHTTPRequestDynamicRedirect, RuleEditResponsePhaseHTTPRequestFirewallCustom, RuleEditResponsePhaseHTTPRequestFirewallManaged, RuleEditResponsePhaseHTTPRequestLateTransform, RuleEditResponsePhaseHTTPRequestOrigin, RuleEditResponsePhaseHTTPRequestRedirect, RuleEditResponsePhaseHTTPRequestSanitize, RuleEditResponsePhaseHTTPRequestSBFM, RuleEditResponsePhaseHTTPRequestSelectConfiguration, RuleEditResponsePhaseHTTPRequestTransform, RuleEditResponsePhaseHTTPResponseCompression, RuleEditResponsePhaseHTTPResponseFirewallManaged, RuleEditResponsePhaseHTTPResponseHeadersTransform, RuleEditResponsePhaseMagicTransit, RuleEditResponsePhaseMagicTransitIDsManaged, RuleEditResponsePhaseMagicTransitManaged: + return true + } + return false } -func (RuleEditParamsRulesetsBlockRule) ImplementsRuleEditParams() { +type RuleEditResponseRule struct { + // The action to perform when the rule matches. + Action RuleEditResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON ruleEditResponseRuleJSON `json:"-"` + union RuleEditResponseRulesUnion +} + +// ruleEditResponseRuleJSON contains the JSON metadata for the struct +// [RuleEditResponseRule] +type ruleEditResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r ruleEditResponseRuleJSON) RawJSON() string { + return r.raw +} +func (r *RuleEditResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r RuleEditResponseRule) AsUnion() RuleEditResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type RuleEditResponseRulesUnion interface { + implementsRulesetsRuleEditResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RuleEditResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) } // The action to perform when the rule matches. -type RuleEditParamsRulesetsBlockRuleAction string +type RuleEditResponseRulesAction string const ( - RuleEditParamsRulesetsBlockRuleActionBlock RuleEditParamsRulesetsBlockRuleAction = "block" + RuleEditResponseRulesActionBlock RuleEditResponseRulesAction = "block" + RuleEditResponseRulesActionChallenge RuleEditResponseRulesAction = "challenge" + RuleEditResponseRulesActionCompressResponse RuleEditResponseRulesAction = "compress_response" + RuleEditResponseRulesActionExecute RuleEditResponseRulesAction = "execute" + RuleEditResponseRulesActionJSChallenge RuleEditResponseRulesAction = "js_challenge" + RuleEditResponseRulesActionLog RuleEditResponseRulesAction = "log" + RuleEditResponseRulesActionManagedChallenge RuleEditResponseRulesAction = "managed_challenge" + RuleEditResponseRulesActionRedirect RuleEditResponseRulesAction = "redirect" + RuleEditResponseRulesActionRewrite RuleEditResponseRulesAction = "rewrite" + RuleEditResponseRulesActionRoute RuleEditResponseRulesAction = "route" + RuleEditResponseRulesActionScore RuleEditResponseRulesAction = "score" + RuleEditResponseRulesActionServeError RuleEditResponseRulesAction = "serve_error" + RuleEditResponseRulesActionSetConfig RuleEditResponseRulesAction = "set_config" + RuleEditResponseRulesActionSkip RuleEditResponseRulesAction = "skip" + RuleEditResponseRulesActionSetCacheSettings RuleEditResponseRulesAction = "set_cache_settings" ) -func (r RuleEditParamsRulesetsBlockRuleAction) IsKnown() bool { +func (r RuleEditResponseRulesAction) IsKnown() bool { switch r { - case RuleEditParamsRulesetsBlockRuleActionBlock: + case RuleEditResponseRulesActionBlock, RuleEditResponseRulesActionChallenge, RuleEditResponseRulesActionCompressResponse, RuleEditResponseRulesActionExecute, RuleEditResponseRulesActionJSChallenge, RuleEditResponseRulesActionLog, RuleEditResponseRulesActionManagedChallenge, RuleEditResponseRulesActionRedirect, RuleEditResponseRulesActionRewrite, RuleEditResponseRulesActionRoute, RuleEditResponseRulesActionScore, RuleEditResponseRulesActionServeError, RuleEditResponseRulesActionSetConfig, RuleEditResponseRulesActionSkip, RuleEditResponseRulesActionSetCacheSettings: return true } return false } -// The parameters configuring the rule's action. -type RuleEditParamsRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response param.Field[RuleEditParamsRulesetsBlockRuleActionParametersResponse] `json:"response"` +type RuleNewParams struct { + // 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. + ZoneID param.Field[string] `path:"zone_id"` + // An object configuring where the rule will be placed. + Position param.Field[RuleNewParamsPositionUnion] `json:"position"` } -func (r RuleEditParamsRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { +func (r RuleNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The response to show when the block is applied. -type RuleEditParamsRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content param.Field[string] `json:"content,required"` - // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` - // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` +// An object configuring where the rule will be placed. +type RuleNewParamsPosition struct { + // The ID of another rule to place the rule before. An empty value causes the rule + // to be placed at the top. + Before param.Field[string] `json:"before"` + // The ID of another rule to place the rule after. An empty value causes the rule + // to be placed at the bottom. + After param.Field[string] `json:"after"` + // An index at which to place the rule, where index 1 is the first rule. + Index param.Field[float64] `json:"index"` } -func (r RuleEditParamsRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { +func (r RuleNewParamsPosition) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// An object configuring the rule's logging behavior. -type RuleEditParamsRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` +func (r RuleNewParamsPosition) implementsRulesetsRuleNewParamsPositionUnion() {} + +// An object configuring where the rule will be placed. +// +// Satisfied by [rulesets.RuleNewParamsPositionBeforePosition], +// [rulesets.RuleNewParamsPositionAfterPosition], +// [rulesets.RuleNewParamsPositionIndexPosition], [RuleNewParamsPosition]. +type RuleNewParamsPositionUnion interface { + implementsRulesetsRuleNewParamsPositionUnion() } -func (r RuleEditParamsRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { +// An object configuring where the rule will be placed. +type RuleNewParamsPositionBeforePosition struct { + // The ID of another rule to place the rule before. An empty value causes the rule + // to be placed at the top. + Before param.Field[string] `json:"before"` +} + +func (r RuleNewParamsPositionBeforePosition) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type RuleEditParamsRulesetsExecuteRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RuleEditParamsRulesetsExecuteRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RuleEditParamsRulesetsExecuteRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RuleEditParamsRulesetsExecuteRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` +func (r RuleNewParamsPositionBeforePosition) implementsRulesetsRuleNewParamsPositionUnion() {} + +// An object configuring where the rule will be placed. +type RuleNewParamsPositionAfterPosition struct { + // The ID of another rule to place the rule after. An empty value causes the rule + // to be placed at the bottom. + After param.Field[string] `json:"after"` } -func (r RuleEditParamsRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { +func (r RuleNewParamsPositionAfterPosition) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r RuleEditParamsRulesetsExecuteRule) getAccountID() param.Field[string] { - return r.AccountID +func (r RuleNewParamsPositionAfterPosition) implementsRulesetsRuleNewParamsPositionUnion() {} + +// An object configuring where the rule will be placed. +type RuleNewParamsPositionIndexPosition struct { + // An index at which to place the rule, where index 1 is the first rule. + Index param.Field[float64] `json:"index"` +} + +func (r RuleNewParamsPositionIndexPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleNewParamsPositionIndexPosition) implementsRulesetsRuleNewParamsPositionUnion() {} + +// A response object. +type RuleNewResponseEnvelope struct { + // A list of error messages. + Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` + // A ruleset object. + Result RuleNewResponse `json:"result,required"` + // Whether the API call was successful. + Success RuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON ruleNewResponseEnvelopeJSON `json:"-"` } -func (r RuleEditParamsRulesetsExecuteRule) getZoneID() param.Field[string] { - return r.ZoneID +// ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelope] +type ruleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (RuleEditParamsRulesetsExecuteRule) ImplementsRuleEditParams() { +func (r *RuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} +func (r ruleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// The action to perform when the rule matches. -type RuleEditParamsRulesetsExecuteRuleAction string +// A message. +type RuleNewResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleNewResponseEnvelopeErrorsSource `json:"source"` + JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` +} -const ( - RuleEditParamsRulesetsExecuteRuleActionExecute RuleEditParamsRulesetsExecuteRuleAction = "execute" -) +// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeErrors] +type ruleNewResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -func (r RuleEditParamsRulesetsExecuteRuleAction) IsKnown() bool { - switch r { - case RuleEditParamsRulesetsExecuteRuleActionExecute: - return true - } - return false +func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The parameters configuring the rule's action. -type RuleEditParamsRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[RuleEditParamsRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[RuleEditParamsRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` +func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw } -func (r RuleEditParamsRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// The source of this message. +type RuleNewResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleNewResponseEnvelopeErrorsSourceJSON `json:"-"` } -// The configuration to use for matched data logging. -type RuleEditParamsRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` +// ruleNewResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RuleNewResponseEnvelopeErrorsSource] +type ruleNewResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r RuleEditParamsRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *RuleNewResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// A set of overrides to apply to the target ruleset. -type RuleEditParamsRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` +func (r ruleNewResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw } -func (r RuleEditParamsRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// A message. +type RuleNewResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleNewResponseEnvelopeMessagesSource `json:"source"` + JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` } -// A category-level override -type RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` +// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeMessages] +type ruleNewResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The sensitivity level to use for rules in the category. -type RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string +func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} -const ( - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) +// The source of this message. +type RuleNewResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleNewResponseEnvelopeMessagesSourceJSON `json:"-"` +} -func (r RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel) IsKnown() bool { - switch r { - case RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff: - return true - } - return false +// ruleNewResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RuleNewResponseEnvelopeMessagesSource] +type ruleNewResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// A rule-level override -type RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` +func (r *RuleNewResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r ruleNewResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw } -// The sensitivity level to use for the rule. -type RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string +// Whether the API call was successful. +type RuleNewResponseEnvelopeSuccess bool const ( - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" + RuleNewResponseEnvelopeSuccessTrue RuleNewResponseEnvelopeSuccess = true ) -func (r RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel) IsKnown() bool { +func (r RuleNewResponseEnvelopeSuccess) IsKnown() bool { switch r { - case RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff: + case RuleNewResponseEnvelopeSuccessTrue: return true } return false } -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) +type RuleDeleteParams struct { + // 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. + ZoneID param.Field[string] `path:"zone_id"` +} -func (r RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevel) IsKnown() bool { - switch r { - case RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow, RuleEditParamsRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff: - return true - } - return false +// A response object. +type RuleDeleteResponseEnvelope struct { + // A list of error messages. + Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` + // A ruleset object. + Result RuleDeleteResponse `json:"result,required"` + // Whether the API call was successful. + Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON ruleDeleteResponseEnvelopeJSON `json:"-"` } -// An object configuring the rule's logging behavior. -type RuleEditParamsRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` +// ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelope] +type ruleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r RuleEditParamsRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *RuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -type RuleEditParamsRulesetsLogRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RuleEditParamsRulesetsLogRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RuleEditParamsRulesetsLogRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` +func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw } -func (r RuleEditParamsRulesetsLogRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// A message. +type RuleDeleteResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleDeleteResponseEnvelopeErrorsSource `json:"source"` + JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` } -func (r RuleEditParamsRulesetsLogRule) getAccountID() param.Field[string] { - return r.AccountID +// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeErrors] +type ruleDeleteResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r RuleEditParamsRulesetsLogRule) getZoneID() param.Field[string] { - return r.ZoneID +func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (RuleEditParamsRulesetsLogRule) ImplementsRuleEditParams() { +func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} +// The source of this message. +type RuleDeleteResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleDeleteResponseEnvelopeErrorsSourceJSON `json:"-"` } -// The action to perform when the rule matches. -type RuleEditParamsRulesetsLogRuleAction string +// ruleDeleteResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RuleDeleteResponseEnvelopeErrorsSource] +type ruleDeleteResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -const ( - RuleEditParamsRulesetsLogRuleActionLog RuleEditParamsRulesetsLogRuleAction = "log" -) +func (r *RuleDeleteResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} -func (r RuleEditParamsRulesetsLogRuleAction) IsKnown() bool { - switch r { - case RuleEditParamsRulesetsLogRuleActionLog: - return true - } - return false +func (r ruleDeleteResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw } -// An object configuring the rule's logging behavior. -type RuleEditParamsRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` +// A message. +type RuleDeleteResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleDeleteResponseEnvelopeMessagesSource `json:"source"` + JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` } -func (r RuleEditParamsRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeMessages] +type ruleDeleteResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type RuleEditParamsRulesetsSkipRule struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RuleEditParamsRulesetsSkipRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RuleEditParamsRulesetsSkipRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RuleEditParamsRulesetsSkipRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` +func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r RuleEditParamsRulesetsSkipRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw } -func (r RuleEditParamsRulesetsSkipRule) getAccountID() param.Field[string] { - return r.AccountID +// The source of this message. +type RuleDeleteResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleDeleteResponseEnvelopeMessagesSourceJSON `json:"-"` } -func (r RuleEditParamsRulesetsSkipRule) getZoneID() param.Field[string] { - return r.ZoneID +// ruleDeleteResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RuleDeleteResponseEnvelopeMessagesSource] +type ruleDeleteResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (RuleEditParamsRulesetsSkipRule) ImplementsRuleEditParams() { +func (r *RuleDeleteResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} +func (r ruleDeleteResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw } -// The action to perform when the rule matches. -type RuleEditParamsRulesetsSkipRuleAction string +// Whether the API call was successful. +type RuleDeleteResponseEnvelopeSuccess bool const ( - RuleEditParamsRulesetsSkipRuleActionSkip RuleEditParamsRulesetsSkipRuleAction = "skip" + RuleDeleteResponseEnvelopeSuccessTrue RuleDeleteResponseEnvelopeSuccess = true ) -func (r RuleEditParamsRulesetsSkipRuleAction) IsKnown() bool { +func (r RuleDeleteResponseEnvelopeSuccess) IsKnown() bool { switch r { - case RuleEditParamsRulesetsSkipRuleActionSkip: + case RuleDeleteResponseEnvelopeSuccessTrue: return true } return false } -// The parameters configuring the rule's action. -type RuleEditParamsRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]RuleEditParamsRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]RuleEditParamsRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[RuleEditParamsRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` +type RuleEditParams struct { + // 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. + ZoneID param.Field[string] `path:"zone_id"` + // An object configuring where the rule will be placed. + Position param.Field[RuleEditParamsPositionUnion] `json:"position"` } -func (r RuleEditParamsRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { +func (r RuleEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A phase to skip the execution of. -type RuleEditParamsRulesetsSkipRuleActionParametersPhase string - -const ( - RuleEditParamsRulesetsSkipRuleActionParametersPhaseDDoSL4 RuleEditParamsRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseDDoSL7 RuleEditParamsRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RuleEditParamsRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseMagicTransit RuleEditParamsRulesetsSkipRuleActionParametersPhase = "magic_transit" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RuleEditParamsRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RuleEditParamsRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RuleEditParamsRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) +// An object configuring where the rule will be placed. +type RuleEditParamsPosition struct { + // The ID of another rule to place the rule before. An empty value causes the rule + // to be placed at the top. + Before param.Field[string] `json:"before"` + // The ID of another rule to place the rule after. An empty value causes the rule + // to be placed at the bottom. + After param.Field[string] `json:"after"` + // An index at which to place the rule, where index 1 is the first rule. + Index param.Field[float64] `json:"index"` +} -func (r RuleEditParamsRulesetsSkipRuleActionParametersPhase) IsKnown() bool { - switch r { - case RuleEditParamsRulesetsSkipRuleActionParametersPhaseDDoSL4, RuleEditParamsRulesetsSkipRuleActionParametersPhaseDDoSL7, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRatelimit, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged, RuleEditParamsRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform, RuleEditParamsRulesetsSkipRuleActionParametersPhaseMagicTransit, RuleEditParamsRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged, RuleEditParamsRulesetsSkipRuleActionParametersPhaseMagicTransitManaged: - return true - } - return false +func (r RuleEditParamsPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// The name of a legacy security product to skip the execution of. -type RuleEditParamsRulesetsSkipRuleActionParametersProduct string +func (r RuleEditParamsPosition) implementsRulesetsRuleEditParamsPositionUnion() {} -const ( - RuleEditParamsRulesetsSkipRuleActionParametersProductBic RuleEditParamsRulesetsSkipRuleActionParametersProduct = "bic" - RuleEditParamsRulesetsSkipRuleActionParametersProductHot RuleEditParamsRulesetsSkipRuleActionParametersProduct = "hot" - RuleEditParamsRulesetsSkipRuleActionParametersProductRateLimit RuleEditParamsRulesetsSkipRuleActionParametersProduct = "rateLimit" - RuleEditParamsRulesetsSkipRuleActionParametersProductSecurityLevel RuleEditParamsRulesetsSkipRuleActionParametersProduct = "securityLevel" - RuleEditParamsRulesetsSkipRuleActionParametersProductUABlock RuleEditParamsRulesetsSkipRuleActionParametersProduct = "uaBlock" - RuleEditParamsRulesetsSkipRuleActionParametersProductWAF RuleEditParamsRulesetsSkipRuleActionParametersProduct = "waf" - RuleEditParamsRulesetsSkipRuleActionParametersProductZoneLockdown RuleEditParamsRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) +// An object configuring where the rule will be placed. +// +// Satisfied by [rulesets.RuleEditParamsPositionBeforePosition], +// [rulesets.RuleEditParamsPositionAfterPosition], +// [rulesets.RuleEditParamsPositionIndexPosition], [RuleEditParamsPosition]. +type RuleEditParamsPositionUnion interface { + implementsRulesetsRuleEditParamsPositionUnion() +} -func (r RuleEditParamsRulesetsSkipRuleActionParametersProduct) IsKnown() bool { - switch r { - case RuleEditParamsRulesetsSkipRuleActionParametersProductBic, RuleEditParamsRulesetsSkipRuleActionParametersProductHot, RuleEditParamsRulesetsSkipRuleActionParametersProductRateLimit, RuleEditParamsRulesetsSkipRuleActionParametersProductSecurityLevel, RuleEditParamsRulesetsSkipRuleActionParametersProductUABlock, RuleEditParamsRulesetsSkipRuleActionParametersProductWAF, RuleEditParamsRulesetsSkipRuleActionParametersProductZoneLockdown: - return true - } - return false +// An object configuring where the rule will be placed. +type RuleEditParamsPositionBeforePosition struct { + // The ID of another rule to place the rule before. An empty value causes the rule + // to be placed at the top. + Before param.Field[string] `json:"before"` } -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RuleEditParamsRulesetsSkipRuleActionParametersRuleset string +func (r RuleEditParamsPositionBeforePosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} -const ( - RuleEditParamsRulesetsSkipRuleActionParametersRulesetCurrent RuleEditParamsRulesetsSkipRuleActionParametersRuleset = "current" -) +func (r RuleEditParamsPositionBeforePosition) implementsRulesetsRuleEditParamsPositionUnion() {} -func (r RuleEditParamsRulesetsSkipRuleActionParametersRuleset) IsKnown() bool { - switch r { - case RuleEditParamsRulesetsSkipRuleActionParametersRulesetCurrent: - return true - } - return false +// An object configuring where the rule will be placed. +type RuleEditParamsPositionAfterPosition struct { + // The ID of another rule to place the rule after. An empty value causes the rule + // to be placed at the bottom. + After param.Field[string] `json:"after"` } -// An object configuring the rule's logging behavior. -type RuleEditParamsRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` +func (r RuleEditParamsPositionAfterPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r RuleEditParamsRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { +func (r RuleEditParamsPositionAfterPosition) implementsRulesetsRuleEditParamsPositionUnion() {} + +// An object configuring where the rule will be placed. +type RuleEditParamsPositionIndexPosition struct { + // An index at which to place the rule, where index 1 is the first rule. + Index param.Field[float64] `json:"index"` +} + +func (r RuleEditParamsPositionIndexPosition) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +func (r RuleEditParamsPositionIndexPosition) implementsRulesetsRuleEditParamsPositionUnion() {} + // A response object. type RuleEditResponseEnvelope struct { // A list of error messages. Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result RuleEditResponse `json:"result,required"` // Whether the API call was successful. Success RuleEditResponseEnvelopeSuccess `json:"success,required"` JSON ruleEditResponseEnvelopeJSON `json:"-"` diff --git a/rulesets/rule_test.go b/rulesets/rule_test.go index 8d8416a722c..d50048511c2 100644 --- a/rulesets/rule_test.go +++ b/rulesets/rule_test.go @@ -31,25 +31,12 @@ func TestRuleNewWithOptionalParams(t *testing.T) { _, err := client.Rulesets.Rules.New( context.TODO(), "2f2feab2026849078ba485f918791bdc", - rulesets.RuleNewParamsRulesetsBlockRule{ + rulesets.RuleNewParams{ AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Action: cloudflare.F(rulesets.RuleNewParamsRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RuleNewParamsRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RuleNewParamsRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), + Position: cloudflare.F[rulesets.RuleNewParamsPositionUnion](rulesets.RuleNewParamsPositionBeforePosition{ + Before: cloudflare.F("da5e8e506c8e7877fe06cdf4c41add54"), }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - Logging: cloudflare.F(rulesets.RuleNewParamsRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), }, ) if err != nil { @@ -111,25 +98,12 @@ func TestRuleEditWithOptionalParams(t *testing.T) { context.TODO(), "2f2feab2026849078ba485f918791bdc", "3a03d665bac047339bb530ecb439a90d", - rulesets.RuleEditParamsRulesetsBlockRule{ + rulesets.RuleEditParams{ AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Action: cloudflare.F(rulesets.RuleEditParamsRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RuleEditParamsRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RuleEditParamsRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - Logging: cloudflare.F(rulesets.RuleEditParamsRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), + Position: cloudflare.F[rulesets.RuleEditParamsPositionUnion](rulesets.RuleEditParamsPositionBeforePosition{ + Before: cloudflare.F("da5e8e506c8e7877fe06cdf4c41add54"), }), - Ref: cloudflare.F("my_ref"), }, ) if err != nil { diff --git a/rulesets/ruleset.go b/rulesets/ruleset.go index a2f0938a51e..1084ed2a79a 100644 --- a/rulesets/ruleset.go +++ b/rulesets/ruleset.go @@ -41,7 +41,7 @@ func NewRulesetService(opts ...option.RequestOption) (r *RulesetService) { } // Creates a ruleset. -func (r *RulesetService) New(ctx context.Context, params RulesetNewParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *RulesetService) New(ctx context.Context, params RulesetNewParams, opts ...option.RequestOption) (res *RulesetNewResponse, err error) { opts = append(r.Options[:], opts...) var env RulesetNewResponseEnvelope var accountOrZone string @@ -63,7 +63,7 @@ func (r *RulesetService) New(ctx context.Context, params RulesetNewParams, opts } // Updates an account or zone ruleset, creating a new version. -func (r *RulesetService) Update(ctx context.Context, rulesetID string, params RulesetUpdateParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *RulesetService) Update(ctx context.Context, rulesetID string, params RulesetUpdateParams, opts ...option.RequestOption) (res *RulesetUpdateResponse, err error) { opts = append(r.Options[:], opts...) var env RulesetUpdateResponseEnvelope var accountOrZone string @@ -85,7 +85,7 @@ func (r *RulesetService) Update(ctx context.Context, rulesetID string, params Ru } // Fetches all rulesets. -func (r *RulesetService) List(ctx context.Context, query RulesetListParams, opts ...option.RequestOption) (res *pagination.SinglePage[RulesetListResponse], err error) { +func (r *RulesetService) List(ctx context.Context, query RulesetListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Ruleset], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -112,7 +112,7 @@ func (r *RulesetService) List(ctx context.Context, query RulesetListParams, opts } // Fetches all rulesets. -func (r *RulesetService) ListAutoPaging(ctx context.Context, query RulesetListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[RulesetListResponse] { +func (r *RulesetService) ListAutoPaging(ctx context.Context, query RulesetListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Ruleset] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -135,7 +135,7 @@ func (r *RulesetService) Delete(ctx context.Context, rulesetID string, body Rule } // Fetches the latest version of an account or zone ruleset. -func (r *RulesetService) Get(ctx context.Context, rulesetID string, query RulesetGetParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *RulesetService) Get(ctx context.Context, rulesetID string, query RulesetGetParams, opts ...option.RequestOption) (res *RulesetGetResponse, err error) { opts = append(r.Options[:], opts...) var env RulesetGetResponseEnvelope var accountOrZone string @@ -160,33 +160,30 @@ func (r *RulesetService) Get(ctx context.Context, rulesetID string, query Rulese type Ruleset struct { // The unique ID of the ruleset. ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetKind `json:"kind,required"` // The timestamp of when the ruleset was last modified. LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetPhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetRule `json:"rules,required"` // The version of the ruleset. Version string `json:"version,required"` // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetJSON `json:"-"` + Description string `json:"description"` + // The kind of the ruleset. + Kind RulesetKind `json:"kind"` + // The human-readable name of the ruleset. + Name string `json:"name"` + // The phase of the ruleset. + Phase RulesetPhase `json:"phase"` + JSON rulesetJSON `json:"-"` } // rulesetJSON contains the JSON metadata for the struct [Ruleset] type rulesetJSON struct { ID apijson.Field - Kind apijson.Field LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field Version apijson.Field Description apijson.Field + Kind apijson.Field + Name apijson.Field + Phase apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -235,7 +232,7 @@ const ( RulesetPhaseHTTPRequestOrigin RulesetPhase = "http_request_origin" RulesetPhaseHTTPRequestRedirect RulesetPhase = "http_request_redirect" RulesetPhaseHTTPRequestSanitize RulesetPhase = "http_request_sanitize" - RulesetPhaseHTTPRequestSbfm RulesetPhase = "http_request_sbfm" + RulesetPhaseHTTPRequestSBFM RulesetPhase = "http_request_sbfm" RulesetPhaseHTTPRequestSelectConfiguration RulesetPhase = "http_request_select_configuration" RulesetPhaseHTTPRequestTransform RulesetPhase = "http_request_transform" RulesetPhaseHTTPResponseCompression RulesetPhase = "http_response_compression" @@ -248,888 +245,844 @@ const ( func (r RulesetPhase) IsKnown() bool { switch r { - case RulesetPhaseDDoSL4, RulesetPhaseDDoSL7, RulesetPhaseHTTPConfigSettings, RulesetPhaseHTTPCustomErrors, RulesetPhaseHTTPLogCustomFields, RulesetPhaseHTTPRatelimit, RulesetPhaseHTTPRequestCacheSettings, RulesetPhaseHTTPRequestDynamicRedirect, RulesetPhaseHTTPRequestFirewallCustom, RulesetPhaseHTTPRequestFirewallManaged, RulesetPhaseHTTPRequestLateTransform, RulesetPhaseHTTPRequestOrigin, RulesetPhaseHTTPRequestRedirect, RulesetPhaseHTTPRequestSanitize, RulesetPhaseHTTPRequestSbfm, RulesetPhaseHTTPRequestSelectConfiguration, RulesetPhaseHTTPRequestTransform, RulesetPhaseHTTPResponseCompression, RulesetPhaseHTTPResponseFirewallManaged, RulesetPhaseHTTPResponseHeadersTransform, RulesetPhaseMagicTransit, RulesetPhaseMagicTransitIDsManaged, RulesetPhaseMagicTransitManaged: + case RulesetPhaseDDoSL4, RulesetPhaseDDoSL7, RulesetPhaseHTTPConfigSettings, RulesetPhaseHTTPCustomErrors, RulesetPhaseHTTPLogCustomFields, RulesetPhaseHTTPRatelimit, RulesetPhaseHTTPRequestCacheSettings, RulesetPhaseHTTPRequestDynamicRedirect, RulesetPhaseHTTPRequestFirewallCustom, RulesetPhaseHTTPRequestFirewallManaged, RulesetPhaseHTTPRequestLateTransform, RulesetPhaseHTTPRequestOrigin, RulesetPhaseHTTPRequestRedirect, RulesetPhaseHTTPRequestSanitize, RulesetPhaseHTTPRequestSBFM, RulesetPhaseHTTPRequestSelectConfiguration, RulesetPhaseHTTPRequestTransform, RulesetPhaseHTTPResponseCompression, RulesetPhaseHTTPResponseFirewallManaged, RulesetPhaseHTTPResponseHeadersTransform, RulesetPhaseMagicTransit, RulesetPhaseMagicTransitIDsManaged, RulesetPhaseMagicTransitManaged: return true } return false } -// Union satisfied by [rulesets.RulesetRulesRulesetsBlockRule], -// [rulesets.RulesetRulesRulesetsExecuteRule], -// [rulesets.RulesetRulesRulesetsLogRule] or -// [rulesets.RulesetRulesRulesetsSkipRule]. -type RulesetRule interface { - implementsRulesetsRulesetRule() +// A ruleset object. +type RulesetNewResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind RulesetNewResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RulesetNewResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []RulesetNewResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON rulesetNewResponseJSON `json:"-"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) +// rulesetNewResponseJSON contains the JSON metadata for the struct +// [RulesetNewResponse] +type rulesetNewResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type RulesetRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` +func (r *RulesetNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetNewResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type RulesetNewResponseKind string + +const ( + RulesetNewResponseKindManaged RulesetNewResponseKind = "managed" + RulesetNewResponseKindCustom RulesetNewResponseKind = "custom" + RulesetNewResponseKindRoot RulesetNewResponseKind = "root" + RulesetNewResponseKindZone RulesetNewResponseKind = "zone" +) + +func (r RulesetNewResponseKind) IsKnown() bool { + switch r { + case RulesetNewResponseKindManaged, RulesetNewResponseKindCustom, RulesetNewResponseKindRoot, RulesetNewResponseKindZone: + return true + } + return false +} + +// The phase of the ruleset. +type RulesetNewResponsePhase string + +const ( + RulesetNewResponsePhaseDDoSL4 RulesetNewResponsePhase = "ddos_l4" + RulesetNewResponsePhaseDDoSL7 RulesetNewResponsePhase = "ddos_l7" + RulesetNewResponsePhaseHTTPConfigSettings RulesetNewResponsePhase = "http_config_settings" + RulesetNewResponsePhaseHTTPCustomErrors RulesetNewResponsePhase = "http_custom_errors" + RulesetNewResponsePhaseHTTPLogCustomFields RulesetNewResponsePhase = "http_log_custom_fields" + RulesetNewResponsePhaseHTTPRatelimit RulesetNewResponsePhase = "http_ratelimit" + RulesetNewResponsePhaseHTTPRequestCacheSettings RulesetNewResponsePhase = "http_request_cache_settings" + RulesetNewResponsePhaseHTTPRequestDynamicRedirect RulesetNewResponsePhase = "http_request_dynamic_redirect" + RulesetNewResponsePhaseHTTPRequestFirewallCustom RulesetNewResponsePhase = "http_request_firewall_custom" + RulesetNewResponsePhaseHTTPRequestFirewallManaged RulesetNewResponsePhase = "http_request_firewall_managed" + RulesetNewResponsePhaseHTTPRequestLateTransform RulesetNewResponsePhase = "http_request_late_transform" + RulesetNewResponsePhaseHTTPRequestOrigin RulesetNewResponsePhase = "http_request_origin" + RulesetNewResponsePhaseHTTPRequestRedirect RulesetNewResponsePhase = "http_request_redirect" + RulesetNewResponsePhaseHTTPRequestSanitize RulesetNewResponsePhase = "http_request_sanitize" + RulesetNewResponsePhaseHTTPRequestSBFM RulesetNewResponsePhase = "http_request_sbfm" + RulesetNewResponsePhaseHTTPRequestSelectConfiguration RulesetNewResponsePhase = "http_request_select_configuration" + RulesetNewResponsePhaseHTTPRequestTransform RulesetNewResponsePhase = "http_request_transform" + RulesetNewResponsePhaseHTTPResponseCompression RulesetNewResponsePhase = "http_response_compression" + RulesetNewResponsePhaseHTTPResponseFirewallManaged RulesetNewResponsePhase = "http_response_firewall_managed" + RulesetNewResponsePhaseHTTPResponseHeadersTransform RulesetNewResponsePhase = "http_response_headers_transform" + RulesetNewResponsePhaseMagicTransit RulesetNewResponsePhase = "magic_transit" + RulesetNewResponsePhaseMagicTransitIDsManaged RulesetNewResponsePhase = "magic_transit_ids_managed" + RulesetNewResponsePhaseMagicTransitManaged RulesetNewResponsePhase = "magic_transit_managed" +) + +func (r RulesetNewResponsePhase) IsKnown() bool { + switch r { + case RulesetNewResponsePhaseDDoSL4, RulesetNewResponsePhaseDDoSL7, RulesetNewResponsePhaseHTTPConfigSettings, RulesetNewResponsePhaseHTTPCustomErrors, RulesetNewResponsePhaseHTTPLogCustomFields, RulesetNewResponsePhaseHTTPRatelimit, RulesetNewResponsePhaseHTTPRequestCacheSettings, RulesetNewResponsePhaseHTTPRequestDynamicRedirect, RulesetNewResponsePhaseHTTPRequestFirewallCustom, RulesetNewResponsePhaseHTTPRequestFirewallManaged, RulesetNewResponsePhaseHTTPRequestLateTransform, RulesetNewResponsePhaseHTTPRequestOrigin, RulesetNewResponsePhaseHTTPRequestRedirect, RulesetNewResponsePhaseHTTPRequestSanitize, RulesetNewResponsePhaseHTTPRequestSBFM, RulesetNewResponsePhaseHTTPRequestSelectConfiguration, RulesetNewResponsePhaseHTTPRequestTransform, RulesetNewResponsePhaseHTTPResponseCompression, RulesetNewResponsePhaseHTTPResponseFirewallManaged, RulesetNewResponsePhaseHTTPResponseHeadersTransform, RulesetNewResponsePhaseMagicTransit, RulesetNewResponsePhaseMagicTransitIDsManaged, RulesetNewResponsePhaseMagicTransitManaged: + return true + } + return false +} + +type RulesetNewResponseRule struct { // The action to perform when the rule matches. - Action RulesetRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` + Action RulesetNewResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` // An informative description of the rule. Description string `json:"description"` // Whether the rule should be executed. Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // An object configuring the rule's logging behavior. - Logging RulesetRulesRulesetsBlockRuleLogging `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRulesRulesetsBlockRuleJSON `json:"-"` + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON rulesetNewResponseRuleJSON `json:"-"` + union RulesetNewResponseRulesUnion } -// rulesetRulesRulesetsBlockRuleJSON contains the JSON metadata for the struct -// [RulesetRulesRulesetsBlockRule] -type rulesetRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field +// rulesetNewResponseRuleJSON contains the JSON metadata for the struct +// [RulesetNewResponseRule] +type rulesetNewResponseRuleJSON struct { Action apijson.Field ActionParameters apijson.Field Categories apijson.Field Description apijson.Field Enabled apijson.Field Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field Logging apijson.Field Ref apijson.Field + Version apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RulesetRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r rulesetNewResponseRuleJSON) RawJSON() string { + return r.raw } -func (r rulesetRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw +func (r *RulesetNewResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r RulesetNewResponseRule) AsUnion() RulesetNewResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type RulesetNewResponseRulesUnion interface { + implementsRulesetsRulesetNewResponseRule() } -func (r RulesetRulesRulesetsBlockRule) implementsRulesetsRulesetRule() {} +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RulesetNewResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) +} // The action to perform when the rule matches. -type RulesetRulesRulesetsBlockRuleAction string +type RulesetNewResponseRulesAction string const ( - RulesetRulesRulesetsBlockRuleActionBlock RulesetRulesRulesetsBlockRuleAction = "block" + RulesetNewResponseRulesActionBlock RulesetNewResponseRulesAction = "block" + RulesetNewResponseRulesActionChallenge RulesetNewResponseRulesAction = "challenge" + RulesetNewResponseRulesActionCompressResponse RulesetNewResponseRulesAction = "compress_response" + RulesetNewResponseRulesActionExecute RulesetNewResponseRulesAction = "execute" + RulesetNewResponseRulesActionJSChallenge RulesetNewResponseRulesAction = "js_challenge" + RulesetNewResponseRulesActionLog RulesetNewResponseRulesAction = "log" + RulesetNewResponseRulesActionManagedChallenge RulesetNewResponseRulesAction = "managed_challenge" + RulesetNewResponseRulesActionRedirect RulesetNewResponseRulesAction = "redirect" + RulesetNewResponseRulesActionRewrite RulesetNewResponseRulesAction = "rewrite" + RulesetNewResponseRulesActionRoute RulesetNewResponseRulesAction = "route" + RulesetNewResponseRulesActionScore RulesetNewResponseRulesAction = "score" + RulesetNewResponseRulesActionServeError RulesetNewResponseRulesAction = "serve_error" + RulesetNewResponseRulesActionSetConfig RulesetNewResponseRulesAction = "set_config" + RulesetNewResponseRulesActionSkip RulesetNewResponseRulesAction = "skip" + RulesetNewResponseRulesActionSetCacheSettings RulesetNewResponseRulesAction = "set_cache_settings" ) -func (r RulesetRulesRulesetsBlockRuleAction) IsKnown() bool { +func (r RulesetNewResponseRulesAction) IsKnown() bool { switch r { - case RulesetRulesRulesetsBlockRuleActionBlock: + case RulesetNewResponseRulesActionBlock, RulesetNewResponseRulesActionChallenge, RulesetNewResponseRulesActionCompressResponse, RulesetNewResponseRulesActionExecute, RulesetNewResponseRulesActionJSChallenge, RulesetNewResponseRulesActionLog, RulesetNewResponseRulesActionManagedChallenge, RulesetNewResponseRulesActionRedirect, RulesetNewResponseRulesActionRewrite, RulesetNewResponseRulesActionRoute, RulesetNewResponseRulesActionScore, RulesetNewResponseRulesActionServeError, RulesetNewResponseRulesActionSetConfig, RulesetNewResponseRulesActionSkip, RulesetNewResponseRulesActionSetCacheSettings: return true } return false } -// The parameters configuring the rule's action. -type RulesetRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetRulesRulesetsBlockRuleActionParametersJSON `json:"-"` +// A ruleset object. +type RulesetUpdateResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind RulesetUpdateResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RulesetUpdateResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []RulesetUpdateResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON rulesetUpdateResponseJSON `json:"-"` } -// rulesetRulesRulesetsBlockRuleActionParametersJSON contains the JSON metadata for -// the struct [RulesetRulesRulesetsBlockRuleActionParameters] -type rulesetRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field +// rulesetUpdateResponseJSON contains the JSON metadata for the struct +// [RulesetUpdateResponse] +type rulesetUpdateResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RulesetRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { +func (r *RulesetUpdateResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rulesetRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { +func (r rulesetUpdateResponseJSON) RawJSON() string { return r.raw } -// The response to show when the block is applied. -type RulesetRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetRulesRulesetsBlockRuleActionParametersResponseJSON contains the JSON -// metadata for the struct [RulesetRulesRulesetsBlockRuleActionParametersResponse] -type rulesetRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +// The kind of the ruleset. +type RulesetUpdateResponseKind string -func (r rulesetRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} +const ( + RulesetUpdateResponseKindManaged RulesetUpdateResponseKind = "managed" + RulesetUpdateResponseKindCustom RulesetUpdateResponseKind = "custom" + RulesetUpdateResponseKindRoot RulesetUpdateResponseKind = "root" + RulesetUpdateResponseKindZone RulesetUpdateResponseKind = "zone" +) -// An object configuring the rule's logging behavior. -type RulesetRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRulesRulesetsBlockRuleLoggingJSON `json:"-"` +func (r RulesetUpdateResponseKind) IsKnown() bool { + switch r { + case RulesetUpdateResponseKindManaged, RulesetUpdateResponseKindCustom, RulesetUpdateResponseKindRoot, RulesetUpdateResponseKindZone: + return true + } + return false } -// rulesetRulesRulesetsBlockRuleLoggingJSON contains the JSON metadata for the -// struct [RulesetRulesRulesetsBlockRuleLogging] -type rulesetRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} +// The phase of the ruleset. +type RulesetUpdateResponsePhase string -func (r *RulesetRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +const ( + RulesetUpdateResponsePhaseDDoSL4 RulesetUpdateResponsePhase = "ddos_l4" + RulesetUpdateResponsePhaseDDoSL7 RulesetUpdateResponsePhase = "ddos_l7" + RulesetUpdateResponsePhaseHTTPConfigSettings RulesetUpdateResponsePhase = "http_config_settings" + RulesetUpdateResponsePhaseHTTPCustomErrors RulesetUpdateResponsePhase = "http_custom_errors" + RulesetUpdateResponsePhaseHTTPLogCustomFields RulesetUpdateResponsePhase = "http_log_custom_fields" + RulesetUpdateResponsePhaseHTTPRatelimit RulesetUpdateResponsePhase = "http_ratelimit" + RulesetUpdateResponsePhaseHTTPRequestCacheSettings RulesetUpdateResponsePhase = "http_request_cache_settings" + RulesetUpdateResponsePhaseHTTPRequestDynamicRedirect RulesetUpdateResponsePhase = "http_request_dynamic_redirect" + RulesetUpdateResponsePhaseHTTPRequestFirewallCustom RulesetUpdateResponsePhase = "http_request_firewall_custom" + RulesetUpdateResponsePhaseHTTPRequestFirewallManaged RulesetUpdateResponsePhase = "http_request_firewall_managed" + RulesetUpdateResponsePhaseHTTPRequestLateTransform RulesetUpdateResponsePhase = "http_request_late_transform" + RulesetUpdateResponsePhaseHTTPRequestOrigin RulesetUpdateResponsePhase = "http_request_origin" + RulesetUpdateResponsePhaseHTTPRequestRedirect RulesetUpdateResponsePhase = "http_request_redirect" + RulesetUpdateResponsePhaseHTTPRequestSanitize RulesetUpdateResponsePhase = "http_request_sanitize" + RulesetUpdateResponsePhaseHTTPRequestSBFM RulesetUpdateResponsePhase = "http_request_sbfm" + RulesetUpdateResponsePhaseHTTPRequestSelectConfiguration RulesetUpdateResponsePhase = "http_request_select_configuration" + RulesetUpdateResponsePhaseHTTPRequestTransform RulesetUpdateResponsePhase = "http_request_transform" + RulesetUpdateResponsePhaseHTTPResponseCompression RulesetUpdateResponsePhase = "http_response_compression" + RulesetUpdateResponsePhaseHTTPResponseFirewallManaged RulesetUpdateResponsePhase = "http_response_firewall_managed" + RulesetUpdateResponsePhaseHTTPResponseHeadersTransform RulesetUpdateResponsePhase = "http_response_headers_transform" + RulesetUpdateResponsePhaseMagicTransit RulesetUpdateResponsePhase = "magic_transit" + RulesetUpdateResponsePhaseMagicTransitIDsManaged RulesetUpdateResponsePhase = "magic_transit_ids_managed" + RulesetUpdateResponsePhaseMagicTransitManaged RulesetUpdateResponsePhase = "magic_transit_managed" +) -func (r rulesetRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw +func (r RulesetUpdateResponsePhase) IsKnown() bool { + switch r { + case RulesetUpdateResponsePhaseDDoSL4, RulesetUpdateResponsePhaseDDoSL7, RulesetUpdateResponsePhaseHTTPConfigSettings, RulesetUpdateResponsePhaseHTTPCustomErrors, RulesetUpdateResponsePhaseHTTPLogCustomFields, RulesetUpdateResponsePhaseHTTPRatelimit, RulesetUpdateResponsePhaseHTTPRequestCacheSettings, RulesetUpdateResponsePhaseHTTPRequestDynamicRedirect, RulesetUpdateResponsePhaseHTTPRequestFirewallCustom, RulesetUpdateResponsePhaseHTTPRequestFirewallManaged, RulesetUpdateResponsePhaseHTTPRequestLateTransform, RulesetUpdateResponsePhaseHTTPRequestOrigin, RulesetUpdateResponsePhaseHTTPRequestRedirect, RulesetUpdateResponsePhaseHTTPRequestSanitize, RulesetUpdateResponsePhaseHTTPRequestSBFM, RulesetUpdateResponsePhaseHTTPRequestSelectConfiguration, RulesetUpdateResponsePhaseHTTPRequestTransform, RulesetUpdateResponsePhaseHTTPResponseCompression, RulesetUpdateResponsePhaseHTTPResponseFirewallManaged, RulesetUpdateResponsePhaseHTTPResponseHeadersTransform, RulesetUpdateResponsePhaseMagicTransit, RulesetUpdateResponsePhaseMagicTransitIDsManaged, RulesetUpdateResponsePhaseMagicTransitManaged: + return true + } + return false } -type RulesetRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` +type RulesetUpdateResponseRule struct { // The action to perform when the rule matches. - Action RulesetRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` + Action RulesetUpdateResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` // An informative description of the rule. Description string `json:"description"` // Whether the rule should be executed. Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // An object configuring the rule's logging behavior. - Logging RulesetRulesRulesetsExecuteRuleLogging `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRulesRulesetsExecuteRuleJSON `json:"-"` + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON rulesetUpdateResponseRuleJSON `json:"-"` + union RulesetUpdateResponseRulesUnion } -// rulesetRulesRulesetsExecuteRuleJSON contains the JSON metadata for the struct -// [RulesetRulesRulesetsExecuteRule] -type rulesetRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field +// rulesetUpdateResponseRuleJSON contains the JSON metadata for the struct +// [RulesetUpdateResponseRule] +type rulesetUpdateResponseRuleJSON struct { Action apijson.Field ActionParameters apijson.Field Categories apijson.Field Description apijson.Field Enabled apijson.Field Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field Logging apijson.Field Ref apijson.Field + Version apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RulesetRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsExecuteRuleJSON) RawJSON() string { +func (r rulesetUpdateResponseRuleJSON) RawJSON() string { return r.raw } -func (r RulesetRulesRulesetsExecuteRule) implementsRulesetsRulesetRule() {} - -// The action to perform when the rule matches. -type RulesetRulesRulesetsExecuteRuleAction string - -const ( - RulesetRulesRulesetsExecuteRuleActionExecute RulesetRulesRulesetsExecuteRuleAction = "execute" -) - -func (r RulesetRulesRulesetsExecuteRuleAction) IsKnown() bool { - switch r { - case RulesetRulesRulesetsExecuteRuleActionExecute: - return true +func (r *RulesetUpdateResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err } - return false + return apijson.Port(r.union, &r) } -// The parameters configuring the rule's action. -type RulesetRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetRulesRulesetsExecuteRuleActionParametersJSON contains the JSON metadata -// for the struct [RulesetRulesRulesetsExecuteRuleActionParameters] -type rulesetRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r RulesetUpdateResponseRule) AsUnion() RulesetUpdateResponseRulesUnion { + return r.union } -func (r *RulesetRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type RulesetUpdateResponseRulesUnion interface { + implementsRulesetsRulesetUpdateResponseRule() } -func (r rulesetRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetRulesRulesetsExecuteRuleActionParametersMatchedDataJSON contains the JSON -// metadata for the struct -// [RulesetRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetRulesRulesetsExecuteRuleActionParametersOverridesJSON contains the JSON -// metadata for the struct -// [RulesetRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON contains -// the JSON metadata for the struct -// [RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RulesetUpdateResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) } -// The sensitivity level to use for rules in the category. -type RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string +// The action to perform when the rule matches. +type RulesetUpdateResponseRulesAction string const ( - RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" + RulesetUpdateResponseRulesActionBlock RulesetUpdateResponseRulesAction = "block" + RulesetUpdateResponseRulesActionChallenge RulesetUpdateResponseRulesAction = "challenge" + RulesetUpdateResponseRulesActionCompressResponse RulesetUpdateResponseRulesAction = "compress_response" + RulesetUpdateResponseRulesActionExecute RulesetUpdateResponseRulesAction = "execute" + RulesetUpdateResponseRulesActionJSChallenge RulesetUpdateResponseRulesAction = "js_challenge" + RulesetUpdateResponseRulesActionLog RulesetUpdateResponseRulesAction = "log" + RulesetUpdateResponseRulesActionManagedChallenge RulesetUpdateResponseRulesAction = "managed_challenge" + RulesetUpdateResponseRulesActionRedirect RulesetUpdateResponseRulesAction = "redirect" + RulesetUpdateResponseRulesActionRewrite RulesetUpdateResponseRulesAction = "rewrite" + RulesetUpdateResponseRulesActionRoute RulesetUpdateResponseRulesAction = "route" + RulesetUpdateResponseRulesActionScore RulesetUpdateResponseRulesAction = "score" + RulesetUpdateResponseRulesActionServeError RulesetUpdateResponseRulesAction = "serve_error" + RulesetUpdateResponseRulesActionSetConfig RulesetUpdateResponseRulesAction = "set_config" + RulesetUpdateResponseRulesActionSkip RulesetUpdateResponseRulesAction = "skip" + RulesetUpdateResponseRulesActionSetCacheSettings RulesetUpdateResponseRulesAction = "set_cache_settings" ) -func (r RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel) IsKnown() bool { +func (r RulesetUpdateResponseRulesAction) IsKnown() bool { switch r { - case RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault, RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium, RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow, RulesetRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff: + case RulesetUpdateResponseRulesActionBlock, RulesetUpdateResponseRulesActionChallenge, RulesetUpdateResponseRulesActionCompressResponse, RulesetUpdateResponseRulesActionExecute, RulesetUpdateResponseRulesActionJSChallenge, RulesetUpdateResponseRulesActionLog, RulesetUpdateResponseRulesActionManagedChallenge, RulesetUpdateResponseRulesActionRedirect, RulesetUpdateResponseRulesActionRewrite, RulesetUpdateResponseRulesActionRoute, RulesetUpdateResponseRulesActionScore, RulesetUpdateResponseRulesActionServeError, RulesetUpdateResponseRulesActionSetConfig, RulesetUpdateResponseRulesActionSkip, RulesetUpdateResponseRulesActionSetCacheSettings: return true } return false } -// A rule-level override -type RulesetRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. +// A ruleset object. +type RulesetGetResponse struct { + // The unique ID of the ruleset. ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` + // The kind of the ruleset. + Kind RulesetGetResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RulesetGetResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []RulesetGetResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON rulesetGetResponseJSON `json:"-"` } -// rulesetRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON contains the -// JSON metadata for the struct -// [RulesetRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field +// rulesetGetResponseJSON contains the JSON metadata for the struct +// [RulesetGetResponse] +type rulesetGetResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *RulesetRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { +func (r *RulesetGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rulesetRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { +func (r rulesetGetResponseJSON) RawJSON() string { return r.raw } -// The sensitivity level to use for the rule. -type RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string +// The kind of the ruleset. +type RulesetGetResponseKind string const ( - RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" + RulesetGetResponseKindManaged RulesetGetResponseKind = "managed" + RulesetGetResponseKindCustom RulesetGetResponseKind = "custom" + RulesetGetResponseKindRoot RulesetGetResponseKind = "root" + RulesetGetResponseKindZone RulesetGetResponseKind = "zone" ) -func (r RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel) IsKnown() bool { +func (r RulesetGetResponseKind) IsKnown() bool { switch r { - case RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault, RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium, RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow, RulesetRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff: + case RulesetGetResponseKindManaged, RulesetGetResponseKindCustom, RulesetGetResponseKindRoot, RulesetGetResponseKindZone: return true } return false } -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string +// The phase of the ruleset. +type RulesetGetResponsePhase string const ( - RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" + RulesetGetResponsePhaseDDoSL4 RulesetGetResponsePhase = "ddos_l4" + RulesetGetResponsePhaseDDoSL7 RulesetGetResponsePhase = "ddos_l7" + RulesetGetResponsePhaseHTTPConfigSettings RulesetGetResponsePhase = "http_config_settings" + RulesetGetResponsePhaseHTTPCustomErrors RulesetGetResponsePhase = "http_custom_errors" + RulesetGetResponsePhaseHTTPLogCustomFields RulesetGetResponsePhase = "http_log_custom_fields" + RulesetGetResponsePhaseHTTPRatelimit RulesetGetResponsePhase = "http_ratelimit" + RulesetGetResponsePhaseHTTPRequestCacheSettings RulesetGetResponsePhase = "http_request_cache_settings" + RulesetGetResponsePhaseHTTPRequestDynamicRedirect RulesetGetResponsePhase = "http_request_dynamic_redirect" + RulesetGetResponsePhaseHTTPRequestFirewallCustom RulesetGetResponsePhase = "http_request_firewall_custom" + RulesetGetResponsePhaseHTTPRequestFirewallManaged RulesetGetResponsePhase = "http_request_firewall_managed" + RulesetGetResponsePhaseHTTPRequestLateTransform RulesetGetResponsePhase = "http_request_late_transform" + RulesetGetResponsePhaseHTTPRequestOrigin RulesetGetResponsePhase = "http_request_origin" + RulesetGetResponsePhaseHTTPRequestRedirect RulesetGetResponsePhase = "http_request_redirect" + RulesetGetResponsePhaseHTTPRequestSanitize RulesetGetResponsePhase = "http_request_sanitize" + RulesetGetResponsePhaseHTTPRequestSBFM RulesetGetResponsePhase = "http_request_sbfm" + RulesetGetResponsePhaseHTTPRequestSelectConfiguration RulesetGetResponsePhase = "http_request_select_configuration" + RulesetGetResponsePhaseHTTPRequestTransform RulesetGetResponsePhase = "http_request_transform" + RulesetGetResponsePhaseHTTPResponseCompression RulesetGetResponsePhase = "http_response_compression" + RulesetGetResponsePhaseHTTPResponseFirewallManaged RulesetGetResponsePhase = "http_response_firewall_managed" + RulesetGetResponsePhaseHTTPResponseHeadersTransform RulesetGetResponsePhase = "http_response_headers_transform" + RulesetGetResponsePhaseMagicTransit RulesetGetResponsePhase = "magic_transit" + RulesetGetResponsePhaseMagicTransitIDsManaged RulesetGetResponsePhase = "magic_transit_ids_managed" + RulesetGetResponsePhaseMagicTransitManaged RulesetGetResponsePhase = "magic_transit_managed" ) -func (r RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel) IsKnown() bool { +func (r RulesetGetResponsePhase) IsKnown() bool { switch r { - case RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault, RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium, RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow, RulesetRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff: + case RulesetGetResponsePhaseDDoSL4, RulesetGetResponsePhaseDDoSL7, RulesetGetResponsePhaseHTTPConfigSettings, RulesetGetResponsePhaseHTTPCustomErrors, RulesetGetResponsePhaseHTTPLogCustomFields, RulesetGetResponsePhaseHTTPRatelimit, RulesetGetResponsePhaseHTTPRequestCacheSettings, RulesetGetResponsePhaseHTTPRequestDynamicRedirect, RulesetGetResponsePhaseHTTPRequestFirewallCustom, RulesetGetResponsePhaseHTTPRequestFirewallManaged, RulesetGetResponsePhaseHTTPRequestLateTransform, RulesetGetResponsePhaseHTTPRequestOrigin, RulesetGetResponsePhaseHTTPRequestRedirect, RulesetGetResponsePhaseHTTPRequestSanitize, RulesetGetResponsePhaseHTTPRequestSBFM, RulesetGetResponsePhaseHTTPRequestSelectConfiguration, RulesetGetResponsePhaseHTTPRequestTransform, RulesetGetResponsePhaseHTTPResponseCompression, RulesetGetResponsePhaseHTTPResponseFirewallManaged, RulesetGetResponsePhaseHTTPResponseHeadersTransform, RulesetGetResponsePhaseMagicTransit, RulesetGetResponsePhaseMagicTransitIDsManaged, RulesetGetResponsePhaseMagicTransitManaged: return true } return false } -// An object configuring the rule's logging behavior. -type RulesetRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetRulesRulesetsExecuteRuleLoggingJSON contains the JSON metadata for the -// struct [RulesetRulesRulesetsExecuteRuleLogging] -type rulesetRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` +type RulesetGetResponseRule struct { // The action to perform when the rule matches. - Action RulesetRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` + Action RulesetGetResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` // An informative description of the rule. Description string `json:"description"` // Whether the rule should be executed. Enabled bool `json:"enabled"` // The expression defining which traffic will match the rule. Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetRulesRulesetsLogRuleJSON contains the JSON metadata for the struct -// [RulesetRulesRulesetsLogRule] -type rulesetRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRulesRulesetsLogRule) implementsRulesetsRulesetRule() {} - -// The action to perform when the rule matches. -type RulesetRulesRulesetsLogRuleAction string - -const ( - RulesetRulesRulesetsLogRuleActionLog RulesetRulesRulesetsLogRuleAction = "log" -) - -func (r RulesetRulesRulesetsLogRuleAction) IsKnown() bool { - switch r { - case RulesetRulesRulesetsLogRuleActionLog: - return true - } - return false -} - -// An object configuring the rule's logging behavior. -type RulesetRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetRulesRulesetsLogRuleLoggingJSON contains the JSON metadata for the struct -// [RulesetRulesRulesetsLogRuleLogging] -type rulesetRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` // The unique ID of the rule. ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // An object configuring the rule's logging behavior. - Logging RulesetRulesRulesetsSkipRuleLogging `json:"logging"` + Logging Logging `json:"logging"` // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRulesRulesetsSkipRuleJSON `json:"-"` + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON rulesetGetResponseRuleJSON `json:"-"` + union RulesetGetResponseRulesUnion } -// rulesetRulesRulesetsSkipRuleJSON contains the JSON metadata for the struct -// [RulesetRulesRulesetsSkipRule] -type rulesetRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field +// rulesetGetResponseRuleJSON contains the JSON metadata for the struct +// [RulesetGetResponseRule] +type rulesetGetResponseRuleJSON struct { Action apijson.Field ActionParameters apijson.Field Categories apijson.Field Description apijson.Field Enabled apijson.Field Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field Logging apijson.Field Ref apijson.Field + Version apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RulesetRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRulesRulesetsSkipRule) implementsRulesetsRulesetRule() {} - -// The action to perform when the rule matches. -type RulesetRulesRulesetsSkipRuleAction string - -const ( - RulesetRulesRulesetsSkipRuleActionSkip RulesetRulesRulesetsSkipRuleAction = "skip" -) - -func (r RulesetRulesRulesetsSkipRuleAction) IsKnown() bool { - switch r { - case RulesetRulesRulesetsSkipRuleActionSkip: - return true - } - return false -} - -// The parameters configuring the rule's action. -type RulesetRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetRulesRulesetsSkipRuleActionParametersJSON contains the JSON metadata for -// the struct [RulesetRulesRulesetsSkipRuleActionParameters] -type rulesetRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetRulesRulesetsSkipRuleActionParametersPhaseDDoSL4 RulesetRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetRulesRulesetsSkipRuleActionParametersPhaseDDoSL7 RulesetRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -func (r RulesetRulesRulesetsSkipRuleActionParametersPhase) IsKnown() bool { - switch r { - case RulesetRulesRulesetsSkipRuleActionParametersPhaseDDoSL4, RulesetRulesRulesetsSkipRuleActionParametersPhaseDDoSL7, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged, RulesetRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform, RulesetRulesRulesetsSkipRuleActionParametersPhaseMagicTransit, RulesetRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged, RulesetRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged: - return true - } - return false -} - -// The name of a legacy security product to skip the execution of. -type RulesetRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetRulesRulesetsSkipRuleActionParametersProductBic RulesetRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetRulesRulesetsSkipRuleActionParametersProductHot RulesetRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetRulesRulesetsSkipRuleActionParametersProductUABlock RulesetRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetRulesRulesetsSkipRuleActionParametersProductWAF RulesetRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -func (r RulesetRulesRulesetsSkipRuleActionParametersProduct) IsKnown() bool { - switch r { - case RulesetRulesRulesetsSkipRuleActionParametersProductBic, RulesetRulesRulesetsSkipRuleActionParametersProductHot, RulesetRulesRulesetsSkipRuleActionParametersProductRateLimit, RulesetRulesRulesetsSkipRuleActionParametersProductSecurityLevel, RulesetRulesRulesetsSkipRuleActionParametersProductUABlock, RulesetRulesRulesetsSkipRuleActionParametersProductWAF, RulesetRulesRulesetsSkipRuleActionParametersProductZoneLockdown: - return true - } - return false -} - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -func (r RulesetRulesRulesetsSkipRuleActionParametersRuleset) IsKnown() bool { - switch r { - case RulesetRulesRulesetsSkipRuleActionParametersRulesetCurrent: - return true - } - return false -} - -// An object configuring the rule's logging behavior. -type RulesetRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetRulesRulesetsSkipRuleLoggingJSON contains the JSON metadata for the -// struct [RulesetRulesRulesetsSkipRuleLogging] -type rulesetRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -// A ruleset object. -type RulesetListResponse struct { - // The kind of the ruleset. - Kind RulesetListResponseKind `json:"kind,required"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetListResponsePhase `json:"phase,required"` - // The unique ID of the ruleset. - ID string `json:"id"` - // An informative description of the ruleset. - Description string `json:"description"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the ruleset. - Version string `json:"version"` - JSON rulesetListResponseJSON `json:"-"` +func (r rulesetGetResponseRuleJSON) RawJSON() string { + return r.raw } -// rulesetListResponseJSON contains the JSON metadata for the struct -// [RulesetListResponse] -type rulesetListResponseJSON struct { - Kind apijson.Field - Name apijson.Field - Phase apijson.Field - ID apijson.Field - Description apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r *RulesetGetResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r *RulesetListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r RulesetGetResponseRule) AsUnion() RulesetGetResponseRulesUnion { + return r.union } -func (r rulesetListResponseJSON) RawJSON() string { - return r.raw +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type RulesetGetResponseRulesUnion interface { + implementsRulesetsRulesetGetResponseRule() } -// The kind of the ruleset. -type RulesetListResponseKind string - -const ( - RulesetListResponseKindManaged RulesetListResponseKind = "managed" - RulesetListResponseKindCustom RulesetListResponseKind = "custom" - RulesetListResponseKindRoot RulesetListResponseKind = "root" - RulesetListResponseKindZone RulesetListResponseKind = "zone" -) - -func (r RulesetListResponseKind) IsKnown() bool { - switch r { - case RulesetListResponseKindManaged, RulesetListResponseKindCustom, RulesetListResponseKindRoot, RulesetListResponseKindZone: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RulesetGetResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) } -// The phase of the ruleset. -type RulesetListResponsePhase string +// The action to perform when the rule matches. +type RulesetGetResponseRulesAction string const ( - RulesetListResponsePhaseDDoSL4 RulesetListResponsePhase = "ddos_l4" - RulesetListResponsePhaseDDoSL7 RulesetListResponsePhase = "ddos_l7" - RulesetListResponsePhaseHTTPConfigSettings RulesetListResponsePhase = "http_config_settings" - RulesetListResponsePhaseHTTPCustomErrors RulesetListResponsePhase = "http_custom_errors" - RulesetListResponsePhaseHTTPLogCustomFields RulesetListResponsePhase = "http_log_custom_fields" - RulesetListResponsePhaseHTTPRatelimit RulesetListResponsePhase = "http_ratelimit" - RulesetListResponsePhaseHTTPRequestCacheSettings RulesetListResponsePhase = "http_request_cache_settings" - RulesetListResponsePhaseHTTPRequestDynamicRedirect RulesetListResponsePhase = "http_request_dynamic_redirect" - RulesetListResponsePhaseHTTPRequestFirewallCustom RulesetListResponsePhase = "http_request_firewall_custom" - RulesetListResponsePhaseHTTPRequestFirewallManaged RulesetListResponsePhase = "http_request_firewall_managed" - RulesetListResponsePhaseHTTPRequestLateTransform RulesetListResponsePhase = "http_request_late_transform" - RulesetListResponsePhaseHTTPRequestOrigin RulesetListResponsePhase = "http_request_origin" - RulesetListResponsePhaseHTTPRequestRedirect RulesetListResponsePhase = "http_request_redirect" - RulesetListResponsePhaseHTTPRequestSanitize RulesetListResponsePhase = "http_request_sanitize" - RulesetListResponsePhaseHTTPRequestSbfm RulesetListResponsePhase = "http_request_sbfm" - RulesetListResponsePhaseHTTPRequestSelectConfiguration RulesetListResponsePhase = "http_request_select_configuration" - RulesetListResponsePhaseHTTPRequestTransform RulesetListResponsePhase = "http_request_transform" - RulesetListResponsePhaseHTTPResponseCompression RulesetListResponsePhase = "http_response_compression" - RulesetListResponsePhaseHTTPResponseFirewallManaged RulesetListResponsePhase = "http_response_firewall_managed" - RulesetListResponsePhaseHTTPResponseHeadersTransform RulesetListResponsePhase = "http_response_headers_transform" - RulesetListResponsePhaseMagicTransit RulesetListResponsePhase = "magic_transit" - RulesetListResponsePhaseMagicTransitIDsManaged RulesetListResponsePhase = "magic_transit_ids_managed" - RulesetListResponsePhaseMagicTransitManaged RulesetListResponsePhase = "magic_transit_managed" + RulesetGetResponseRulesActionBlock RulesetGetResponseRulesAction = "block" + RulesetGetResponseRulesActionChallenge RulesetGetResponseRulesAction = "challenge" + RulesetGetResponseRulesActionCompressResponse RulesetGetResponseRulesAction = "compress_response" + RulesetGetResponseRulesActionExecute RulesetGetResponseRulesAction = "execute" + RulesetGetResponseRulesActionJSChallenge RulesetGetResponseRulesAction = "js_challenge" + RulesetGetResponseRulesActionLog RulesetGetResponseRulesAction = "log" + RulesetGetResponseRulesActionManagedChallenge RulesetGetResponseRulesAction = "managed_challenge" + RulesetGetResponseRulesActionRedirect RulesetGetResponseRulesAction = "redirect" + RulesetGetResponseRulesActionRewrite RulesetGetResponseRulesAction = "rewrite" + RulesetGetResponseRulesActionRoute RulesetGetResponseRulesAction = "route" + RulesetGetResponseRulesActionScore RulesetGetResponseRulesAction = "score" + RulesetGetResponseRulesActionServeError RulesetGetResponseRulesAction = "serve_error" + RulesetGetResponseRulesActionSetConfig RulesetGetResponseRulesAction = "set_config" + RulesetGetResponseRulesActionSkip RulesetGetResponseRulesAction = "skip" + RulesetGetResponseRulesActionSetCacheSettings RulesetGetResponseRulesAction = "set_cache_settings" ) -func (r RulesetListResponsePhase) IsKnown() bool { +func (r RulesetGetResponseRulesAction) IsKnown() bool { switch r { - case RulesetListResponsePhaseDDoSL4, RulesetListResponsePhaseDDoSL7, RulesetListResponsePhaseHTTPConfigSettings, RulesetListResponsePhaseHTTPCustomErrors, RulesetListResponsePhaseHTTPLogCustomFields, RulesetListResponsePhaseHTTPRatelimit, RulesetListResponsePhaseHTTPRequestCacheSettings, RulesetListResponsePhaseHTTPRequestDynamicRedirect, RulesetListResponsePhaseHTTPRequestFirewallCustom, RulesetListResponsePhaseHTTPRequestFirewallManaged, RulesetListResponsePhaseHTTPRequestLateTransform, RulesetListResponsePhaseHTTPRequestOrigin, RulesetListResponsePhaseHTTPRequestRedirect, RulesetListResponsePhaseHTTPRequestSanitize, RulesetListResponsePhaseHTTPRequestSbfm, RulesetListResponsePhaseHTTPRequestSelectConfiguration, RulesetListResponsePhaseHTTPRequestTransform, RulesetListResponsePhaseHTTPResponseCompression, RulesetListResponsePhaseHTTPResponseFirewallManaged, RulesetListResponsePhaseHTTPResponseHeadersTransform, RulesetListResponsePhaseMagicTransit, RulesetListResponsePhaseMagicTransitIDsManaged, RulesetListResponsePhaseMagicTransitManaged: + case RulesetGetResponseRulesActionBlock, RulesetGetResponseRulesActionChallenge, RulesetGetResponseRulesActionCompressResponse, RulesetGetResponseRulesActionExecute, RulesetGetResponseRulesActionJSChallenge, RulesetGetResponseRulesActionLog, RulesetGetResponseRulesActionManagedChallenge, RulesetGetResponseRulesActionRedirect, RulesetGetResponseRulesActionRewrite, RulesetGetResponseRulesActionRoute, RulesetGetResponseRulesActionScore, RulesetGetResponseRulesActionServeError, RulesetGetResponseRulesActionSetConfig, RulesetGetResponseRulesActionSkip, RulesetGetResponseRulesActionSetCacheSettings: return true } return false @@ -1143,7 +1096,7 @@ type RulesetNewParams struct { // The phase of the ruleset. Phase param.Field[RulesetNewParamsPhase] `json:"phase,required"` // The list of rules in the ruleset. - Rules param.Field[[]RulesetNewParamsRule] `json:"rules,required"` + Rules param.Field[[]RulesetNewParamsRuleUnion] `json:"rules,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. @@ -1192,7 +1145,7 @@ const ( RulesetNewParamsPhaseHTTPRequestOrigin RulesetNewParamsPhase = "http_request_origin" RulesetNewParamsPhaseHTTPRequestRedirect RulesetNewParamsPhase = "http_request_redirect" RulesetNewParamsPhaseHTTPRequestSanitize RulesetNewParamsPhase = "http_request_sanitize" - RulesetNewParamsPhaseHTTPRequestSbfm RulesetNewParamsPhase = "http_request_sbfm" + RulesetNewParamsPhaseHTTPRequestSBFM RulesetNewParamsPhase = "http_request_sbfm" RulesetNewParamsPhaseHTTPRequestSelectConfiguration RulesetNewParamsPhase = "http_request_select_configuration" RulesetNewParamsPhaseHTTPRequestTransform RulesetNewParamsPhase = "http_request_transform" RulesetNewParamsPhaseHTTPResponseCompression RulesetNewParamsPhase = "http_response_compression" @@ -1205,483 +1158,86 @@ const ( func (r RulesetNewParamsPhase) IsKnown() bool { switch r { - case RulesetNewParamsPhaseDDoSL4, RulesetNewParamsPhaseDDoSL7, RulesetNewParamsPhaseHTTPConfigSettings, RulesetNewParamsPhaseHTTPCustomErrors, RulesetNewParamsPhaseHTTPLogCustomFields, RulesetNewParamsPhaseHTTPRatelimit, RulesetNewParamsPhaseHTTPRequestCacheSettings, RulesetNewParamsPhaseHTTPRequestDynamicRedirect, RulesetNewParamsPhaseHTTPRequestFirewallCustom, RulesetNewParamsPhaseHTTPRequestFirewallManaged, RulesetNewParamsPhaseHTTPRequestLateTransform, RulesetNewParamsPhaseHTTPRequestOrigin, RulesetNewParamsPhaseHTTPRequestRedirect, RulesetNewParamsPhaseHTTPRequestSanitize, RulesetNewParamsPhaseHTTPRequestSbfm, RulesetNewParamsPhaseHTTPRequestSelectConfiguration, RulesetNewParamsPhaseHTTPRequestTransform, RulesetNewParamsPhaseHTTPResponseCompression, RulesetNewParamsPhaseHTTPResponseFirewallManaged, RulesetNewParamsPhaseHTTPResponseHeadersTransform, RulesetNewParamsPhaseMagicTransit, RulesetNewParamsPhaseMagicTransitIDsManaged, RulesetNewParamsPhaseMagicTransitManaged: - return true - } - return false -} - -// Satisfied by [rulesets.RulesetNewParamsRulesRulesetsBlockRule], -// [rulesets.RulesetNewParamsRulesRulesetsExecuteRule], -// [rulesets.RulesetNewParamsRulesRulesetsLogRule], -// [rulesets.RulesetNewParamsRulesRulesetsSkipRule]. -type RulesetNewParamsRule interface { - implementsRulesetsRulesetNewParamsRule() -} - -type RulesetNewParamsRulesRulesetsBlockRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsBlockRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetNewParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsBlockRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsBlockRule) implementsRulesetsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsBlockRuleAction string - -const ( - RulesetNewParamsRulesRulesetsBlockRuleActionBlock RulesetNewParamsRulesRulesetsBlockRuleAction = "block" -) - -func (r RulesetNewParamsRulesRulesetsBlockRuleAction) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsBlockRuleActionBlock: - return true - } - return false -} - -// The parameters configuring the rule's action. -type RulesetNewParamsRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response param.Field[RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response to show when the block is applied. -type RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content param.Field[string] `json:"content,required"` - // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` - // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetNewParamsRulesRulesetsExecuteRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsExecuteRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsExecuteRule) implementsRulesetsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsExecuteRuleAction string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionExecute RulesetNewParamsRulesRulesetsExecuteRuleAction = "execute" -) - -func (r RulesetNewParamsRulesRulesetsExecuteRuleAction) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsExecuteRuleActionExecute: - return true - } - return false -} - -// The parameters configuring the rule's action. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration to use for matched data logging. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A set of overrides to apply to the target ruleset. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A category-level override -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for rules in the category. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff: - return true - } - return false -} - -// A rule-level override -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for the rule. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff: - return true - } - return false -} - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow, RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff: - return true - } - return false -} - -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetNewParamsRulesRulesetsLogRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsLogRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsLogRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetNewParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsLogRule) implementsRulesetsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsLogRuleAction string - -const ( - RulesetNewParamsRulesRulesetsLogRuleActionLog RulesetNewParamsRulesRulesetsLogRuleAction = "log" -) - -func (r RulesetNewParamsRulesRulesetsLogRuleAction) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsLogRuleActionLog: + case RulesetNewParamsPhaseDDoSL4, RulesetNewParamsPhaseDDoSL7, RulesetNewParamsPhaseHTTPConfigSettings, RulesetNewParamsPhaseHTTPCustomErrors, RulesetNewParamsPhaseHTTPLogCustomFields, RulesetNewParamsPhaseHTTPRatelimit, RulesetNewParamsPhaseHTTPRequestCacheSettings, RulesetNewParamsPhaseHTTPRequestDynamicRedirect, RulesetNewParamsPhaseHTTPRequestFirewallCustom, RulesetNewParamsPhaseHTTPRequestFirewallManaged, RulesetNewParamsPhaseHTTPRequestLateTransform, RulesetNewParamsPhaseHTTPRequestOrigin, RulesetNewParamsPhaseHTTPRequestRedirect, RulesetNewParamsPhaseHTTPRequestSanitize, RulesetNewParamsPhaseHTTPRequestSBFM, RulesetNewParamsPhaseHTTPRequestSelectConfiguration, RulesetNewParamsPhaseHTTPRequestTransform, RulesetNewParamsPhaseHTTPResponseCompression, RulesetNewParamsPhaseHTTPResponseFirewallManaged, RulesetNewParamsPhaseHTTPResponseHeadersTransform, RulesetNewParamsPhaseMagicTransit, RulesetNewParamsPhaseMagicTransitIDsManaged, RulesetNewParamsPhaseMagicTransitManaged: return true } return false } -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetNewParamsRulesRulesetsSkipRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` +type RulesetNewParamsRule struct { // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsSkipRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetNewParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` + Action param.Field[RulesetNewParamsRulesAction] `json:"action"` + ActionParameters param.Field[interface{}] `json:"action_parameters,required"` + Categories param.Field[interface{}] `json:"categories,required"` // An informative description of the rule. Description param.Field[string] `json:"description"` // Whether the rule should be executed. Enabled param.Field[bool] `json:"enabled"` // The expression defining which traffic will match the rule. Expression param.Field[string] `json:"expression"` + // The unique ID of the rule. + ID param.Field[string] `json:"id"` // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsSkipRuleLogging] `json:"logging"` + Logging param.Field[LoggingParam] `json:"logging"` // The reference of the rule (the rule ID by default). Ref param.Field[string] `json:"ref"` } -func (r RulesetNewParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsSkipRule) implementsRulesetsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsSkipRuleAction string - -const ( - RulesetNewParamsRulesRulesetsSkipRuleActionSkip RulesetNewParamsRulesRulesetsSkipRuleAction = "skip" -) - -func (r RulesetNewParamsRulesRulesetsSkipRuleAction) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsSkipRuleActionSkip: - return true - } - return false -} - -// The parameters configuring the rule's action. -type RulesetNewParamsRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` -} - -func (r RulesetNewParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { +func (r RulesetNewParamsRule) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A phase to skip the execution of. -type RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL4 RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL7 RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -func (r RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL4, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL7, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged, RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged: - return true - } - return false -} - -// The name of a legacy security product to skip the execution of. -type RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductBic RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductHot RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductUABlock RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductWAF RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) +func (r RulesetNewParamsRule) implementsRulesetsRulesetNewParamsRuleUnion() {} -func (r RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct) IsKnown() bool { - switch r { - case RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductBic, RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductHot, RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductRateLimit, RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel, RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductUABlock, RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductWAF, RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown: - return true - } - return false +// Satisfied by [rulesets.BlockRuleParam], [rulesets.ChallengeRuleParam], +// [rulesets.CompressResponseRuleParam], [rulesets.ExecuteRuleParam], +// [rulesets.JSChallengeRuleParam], [rulesets.LogRuleParam], +// [rulesets.ManagedChallengeRuleParam], [rulesets.RedirectRuleParam], +// [rulesets.RewriteRuleParam], [rulesets.RouteRuleParam], +// [rulesets.ScoreRuleParam], [rulesets.ServeErrorRuleParam], +// [rulesets.SetConfigRuleParam], [rulesets.SkipRuleParam], +// [rulesets.SetCacheSettingsRuleParam], [RulesetNewParamsRule]. +type RulesetNewParamsRuleUnion interface { + implementsRulesetsRulesetNewParamsRuleUnion() } -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset string +// The action to perform when the rule matches. +type RulesetNewParamsRulesAction string const ( - RulesetNewParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" + RulesetNewParamsRulesActionBlock RulesetNewParamsRulesAction = "block" + RulesetNewParamsRulesActionChallenge RulesetNewParamsRulesAction = "challenge" + RulesetNewParamsRulesActionCompressResponse RulesetNewParamsRulesAction = "compress_response" + RulesetNewParamsRulesActionExecute RulesetNewParamsRulesAction = "execute" + RulesetNewParamsRulesActionJSChallenge RulesetNewParamsRulesAction = "js_challenge" + RulesetNewParamsRulesActionLog RulesetNewParamsRulesAction = "log" + RulesetNewParamsRulesActionManagedChallenge RulesetNewParamsRulesAction = "managed_challenge" + RulesetNewParamsRulesActionRedirect RulesetNewParamsRulesAction = "redirect" + RulesetNewParamsRulesActionRewrite RulesetNewParamsRulesAction = "rewrite" + RulesetNewParamsRulesActionRoute RulesetNewParamsRulesAction = "route" + RulesetNewParamsRulesActionScore RulesetNewParamsRulesAction = "score" + RulesetNewParamsRulesActionServeError RulesetNewParamsRulesAction = "serve_error" + RulesetNewParamsRulesActionSetConfig RulesetNewParamsRulesAction = "set_config" + RulesetNewParamsRulesActionSkip RulesetNewParamsRulesAction = "skip" + RulesetNewParamsRulesActionSetCacheSettings RulesetNewParamsRulesAction = "set_cache_settings" ) -func (r RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset) IsKnown() bool { +func (r RulesetNewParamsRulesAction) IsKnown() bool { switch r { - case RulesetNewParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent: + case RulesetNewParamsRulesActionBlock, RulesetNewParamsRulesActionChallenge, RulesetNewParamsRulesActionCompressResponse, RulesetNewParamsRulesActionExecute, RulesetNewParamsRulesActionJSChallenge, RulesetNewParamsRulesActionLog, RulesetNewParamsRulesActionManagedChallenge, RulesetNewParamsRulesActionRedirect, RulesetNewParamsRulesActionRewrite, RulesetNewParamsRulesActionRoute, RulesetNewParamsRulesActionScore, RulesetNewParamsRulesActionServeError, RulesetNewParamsRulesActionSetConfig, RulesetNewParamsRulesActionSkip, RulesetNewParamsRulesActionSetCacheSettings: return true } return false } -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // A response object. type RulesetNewResponseEnvelope struct { // A list of error messages. Errors []RulesetNewResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []RulesetNewResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result RulesetNewResponse `json:"result,required"` // Whether the API call was successful. Success RulesetNewResponseEnvelopeSuccess `json:"success,required"` JSON rulesetNewResponseEnvelopeJSON `json:"-"` @@ -1826,10 +1382,8 @@ func (r RulesetNewResponseEnvelopeSuccess) IsKnown() bool { } type RulesetUpdateParams struct { - // The unique ID of the ruleset. - ID param.Field[string] `json:"id,required"` // The list of rules in the ruleset. - Rules param.Field[[]RulesetUpdateParamsRule] `json:"rules,required"` + Rules param.Field[[]RulesetUpdateParamsRuleUnion] `json:"rules,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. @@ -1848,469 +1402,72 @@ func (r RulesetUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Satisfied by [rulesets.RulesetUpdateParamsRulesRulesetsBlockRule], -// [rulesets.RulesetUpdateParamsRulesRulesetsExecuteRule], -// [rulesets.RulesetUpdateParamsRulesRulesetsLogRule], -// [rulesets.RulesetUpdateParamsRulesRulesetsSkipRule]. -type RulesetUpdateParamsRule interface { - implementsRulesetsRulesetUpdateParamsRule() -} - -type RulesetUpdateParamsRulesRulesetsBlockRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRule) implementsRulesetsRulesetUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsBlockRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock RulesetUpdateParamsRulesRulesetsBlockRuleAction = "block" -) - -func (r RulesetUpdateParamsRulesRulesetsBlockRuleAction) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock: - return true - } - return false -} - -// The parameters configuring the rule's action. -type RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response to show when the block is applied. -type RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content param.Field[string] `json:"content,required"` - // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` - // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetUpdateParamsRulesRulesetsExecuteRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` +type RulesetUpdateParamsRule struct { // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` + Action param.Field[RulesetUpdateParamsRulesAction] `json:"action"` + ActionParameters param.Field[interface{}] `json:"action_parameters,required"` + Categories param.Field[interface{}] `json:"categories,required"` // An informative description of the rule. Description param.Field[string] `json:"description"` // Whether the rule should be executed. Enabled param.Field[bool] `json:"enabled"` // The expression defining which traffic will match the rule. Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRule) implementsRulesetsRulesetUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsExecuteRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionExecute RulesetUpdateParamsRulesRulesetsExecuteRuleAction = "execute" -) - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleAction) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsExecuteRuleActionExecute: - return true - } - return false -} - -// The parameters configuring the rule's action. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration to use for matched data logging. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A set of overrides to apply to the target ruleset. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A category-level override -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for rules in the category. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff: - return true - } - return false -} - -// A rule-level override -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for the rule. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff: - return true - } - return false -} - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow, RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff: - return true - } - return false -} - -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetUpdateParamsRulesRulesetsLogRule struct { // The unique ID of the rule. ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsLogRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsLogRuleLogging] `json:"logging"` + Logging param.Field[LoggingParam] `json:"logging"` // The reference of the rule (the rule ID by default). Ref param.Field[string] `json:"ref"` } -func (r RulesetUpdateParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetUpdateParamsRulesRulesetsLogRule) implementsRulesetsRulesetUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsLogRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsLogRuleActionLog RulesetUpdateParamsRulesRulesetsLogRuleAction = "log" -) - -func (r RulesetUpdateParamsRulesRulesetsLogRuleAction) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsLogRuleActionLog: - return true - } - return false -} - -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { +func (r RulesetUpdateParamsRule) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type RulesetUpdateParamsRulesRulesetsSkipRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} +func (r RulesetUpdateParamsRule) implementsRulesetsRulesetUpdateParamsRuleUnion() {} -func (r RulesetUpdateParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// Satisfied by [rulesets.BlockRuleParam], [rulesets.ChallengeRuleParam], +// [rulesets.CompressResponseRuleParam], [rulesets.ExecuteRuleParam], +// [rulesets.JSChallengeRuleParam], [rulesets.LogRuleParam], +// [rulesets.ManagedChallengeRuleParam], [rulesets.RedirectRuleParam], +// [rulesets.RewriteRuleParam], [rulesets.RouteRuleParam], +// [rulesets.ScoreRuleParam], [rulesets.ServeErrorRuleParam], +// [rulesets.SetConfigRuleParam], [rulesets.SkipRuleParam], +// [rulesets.SetCacheSettingsRuleParam], [RulesetUpdateParamsRule]. +type RulesetUpdateParamsRuleUnion interface { + implementsRulesetsRulesetUpdateParamsRuleUnion() } -func (r RulesetUpdateParamsRulesRulesetsSkipRule) implementsRulesetsRulesetUpdateParamsRule() {} - // The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsSkipRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionSkip RulesetUpdateParamsRulesRulesetsSkipRuleAction = "skip" -) - -func (r RulesetUpdateParamsRulesRulesetsSkipRuleAction) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsSkipRuleActionSkip: - return true - } - return false -} - -// The parameters configuring the rule's action. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` -} - -func (r RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A phase to skip the execution of. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL4 RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL7 RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -func (r RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL4, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDoSL7, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged: - return true - } - return false -} - -// The name of a legacy security product to skip the execution of. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -func (r RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct) IsKnown() bool { - switch r { - case RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF, RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown: - return true - } - return false -} - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset string +type RulesetUpdateParamsRulesAction string const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" + RulesetUpdateParamsRulesActionBlock RulesetUpdateParamsRulesAction = "block" + RulesetUpdateParamsRulesActionChallenge RulesetUpdateParamsRulesAction = "challenge" + RulesetUpdateParamsRulesActionCompressResponse RulesetUpdateParamsRulesAction = "compress_response" + RulesetUpdateParamsRulesActionExecute RulesetUpdateParamsRulesAction = "execute" + RulesetUpdateParamsRulesActionJSChallenge RulesetUpdateParamsRulesAction = "js_challenge" + RulesetUpdateParamsRulesActionLog RulesetUpdateParamsRulesAction = "log" + RulesetUpdateParamsRulesActionManagedChallenge RulesetUpdateParamsRulesAction = "managed_challenge" + RulesetUpdateParamsRulesActionRedirect RulesetUpdateParamsRulesAction = "redirect" + RulesetUpdateParamsRulesActionRewrite RulesetUpdateParamsRulesAction = "rewrite" + RulesetUpdateParamsRulesActionRoute RulesetUpdateParamsRulesAction = "route" + RulesetUpdateParamsRulesActionScore RulesetUpdateParamsRulesAction = "score" + RulesetUpdateParamsRulesActionServeError RulesetUpdateParamsRulesAction = "serve_error" + RulesetUpdateParamsRulesActionSetConfig RulesetUpdateParamsRulesAction = "set_config" + RulesetUpdateParamsRulesActionSkip RulesetUpdateParamsRulesAction = "skip" + RulesetUpdateParamsRulesActionSetCacheSettings RulesetUpdateParamsRulesAction = "set_cache_settings" ) -func (r RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset) IsKnown() bool { +func (r RulesetUpdateParamsRulesAction) IsKnown() bool { switch r { - case RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent: + case RulesetUpdateParamsRulesActionBlock, RulesetUpdateParamsRulesActionChallenge, RulesetUpdateParamsRulesActionCompressResponse, RulesetUpdateParamsRulesActionExecute, RulesetUpdateParamsRulesActionJSChallenge, RulesetUpdateParamsRulesActionLog, RulesetUpdateParamsRulesActionManagedChallenge, RulesetUpdateParamsRulesActionRedirect, RulesetUpdateParamsRulesActionRewrite, RulesetUpdateParamsRulesActionRoute, RulesetUpdateParamsRulesActionScore, RulesetUpdateParamsRulesActionServeError, RulesetUpdateParamsRulesActionSetConfig, RulesetUpdateParamsRulesActionSkip, RulesetUpdateParamsRulesActionSetCacheSettings: return true } return false } -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // The kind of the ruleset. type RulesetUpdateParamsKind string @@ -2347,7 +1504,7 @@ const ( RulesetUpdateParamsPhaseHTTPRequestOrigin RulesetUpdateParamsPhase = "http_request_origin" RulesetUpdateParamsPhaseHTTPRequestRedirect RulesetUpdateParamsPhase = "http_request_redirect" RulesetUpdateParamsPhaseHTTPRequestSanitize RulesetUpdateParamsPhase = "http_request_sanitize" - RulesetUpdateParamsPhaseHTTPRequestSbfm RulesetUpdateParamsPhase = "http_request_sbfm" + RulesetUpdateParamsPhaseHTTPRequestSBFM RulesetUpdateParamsPhase = "http_request_sbfm" RulesetUpdateParamsPhaseHTTPRequestSelectConfiguration RulesetUpdateParamsPhase = "http_request_select_configuration" RulesetUpdateParamsPhaseHTTPRequestTransform RulesetUpdateParamsPhase = "http_request_transform" RulesetUpdateParamsPhaseHTTPResponseCompression RulesetUpdateParamsPhase = "http_response_compression" @@ -2360,7 +1517,7 @@ const ( func (r RulesetUpdateParamsPhase) IsKnown() bool { switch r { - case RulesetUpdateParamsPhaseDDoSL4, RulesetUpdateParamsPhaseDDoSL7, RulesetUpdateParamsPhaseHTTPConfigSettings, RulesetUpdateParamsPhaseHTTPCustomErrors, RulesetUpdateParamsPhaseHTTPLogCustomFields, RulesetUpdateParamsPhaseHTTPRatelimit, RulesetUpdateParamsPhaseHTTPRequestCacheSettings, RulesetUpdateParamsPhaseHTTPRequestDynamicRedirect, RulesetUpdateParamsPhaseHTTPRequestFirewallCustom, RulesetUpdateParamsPhaseHTTPRequestFirewallManaged, RulesetUpdateParamsPhaseHTTPRequestLateTransform, RulesetUpdateParamsPhaseHTTPRequestOrigin, RulesetUpdateParamsPhaseHTTPRequestRedirect, RulesetUpdateParamsPhaseHTTPRequestSanitize, RulesetUpdateParamsPhaseHTTPRequestSbfm, RulesetUpdateParamsPhaseHTTPRequestSelectConfiguration, RulesetUpdateParamsPhaseHTTPRequestTransform, RulesetUpdateParamsPhaseHTTPResponseCompression, RulesetUpdateParamsPhaseHTTPResponseFirewallManaged, RulesetUpdateParamsPhaseHTTPResponseHeadersTransform, RulesetUpdateParamsPhaseMagicTransit, RulesetUpdateParamsPhaseMagicTransitIDsManaged, RulesetUpdateParamsPhaseMagicTransitManaged: + case RulesetUpdateParamsPhaseDDoSL4, RulesetUpdateParamsPhaseDDoSL7, RulesetUpdateParamsPhaseHTTPConfigSettings, RulesetUpdateParamsPhaseHTTPCustomErrors, RulesetUpdateParamsPhaseHTTPLogCustomFields, RulesetUpdateParamsPhaseHTTPRatelimit, RulesetUpdateParamsPhaseHTTPRequestCacheSettings, RulesetUpdateParamsPhaseHTTPRequestDynamicRedirect, RulesetUpdateParamsPhaseHTTPRequestFirewallCustom, RulesetUpdateParamsPhaseHTTPRequestFirewallManaged, RulesetUpdateParamsPhaseHTTPRequestLateTransform, RulesetUpdateParamsPhaseHTTPRequestOrigin, RulesetUpdateParamsPhaseHTTPRequestRedirect, RulesetUpdateParamsPhaseHTTPRequestSanitize, RulesetUpdateParamsPhaseHTTPRequestSBFM, RulesetUpdateParamsPhaseHTTPRequestSelectConfiguration, RulesetUpdateParamsPhaseHTTPRequestTransform, RulesetUpdateParamsPhaseHTTPResponseCompression, RulesetUpdateParamsPhaseHTTPResponseFirewallManaged, RulesetUpdateParamsPhaseHTTPResponseHeadersTransform, RulesetUpdateParamsPhaseMagicTransit, RulesetUpdateParamsPhaseMagicTransitIDsManaged, RulesetUpdateParamsPhaseMagicTransitManaged: return true } return false @@ -2372,8 +1529,8 @@ type RulesetUpdateResponseEnvelope struct { Errors []RulesetUpdateResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []RulesetUpdateResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result RulesetUpdateResponse `json:"result,required"` // Whether the API call was successful. Success RulesetUpdateResponseEnvelopeSuccess `json:"success,required"` JSON rulesetUpdateResponseEnvelopeJSON `json:"-"` @@ -2544,8 +1701,8 @@ type RulesetGetResponseEnvelope struct { Errors []RulesetGetResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []RulesetGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result RulesetGetResponse `json:"result,required"` // Whether the API call was successful. Success RulesetGetResponseEnvelopeSuccess `json:"success,required"` JSON rulesetGetResponseEnvelopeJSON `json:"-"` diff --git a/rulesets/ruleset_test.go b/rulesets/ruleset_test.go index 9e8e0140b0e..56bc36baf44 100644 --- a/rulesets/ruleset_test.go +++ b/rulesets/ruleset_test.go @@ -32,10 +32,10 @@ func TestRulesetNewWithOptionalParams(t *testing.T) { Kind: cloudflare.F(rulesets.RulesetNewParamsKindRoot), Name: cloudflare.F("My ruleset"), Phase: cloudflare.F(rulesets.RulesetNewParamsPhaseHTTPRequestFirewallCustom), - Rules: cloudflare.F([]rulesets.RulesetNewParamsRule{rulesets.RulesetNewParamsRulesRulesetsBlockRule(rulesets.RulesetNewParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ + Rules: cloudflare.F([]rulesets.RulesetNewParamsRuleUnion{rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -45,14 +45,14 @@ func TestRulesetNewWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - }), rulesets.RulesetNewParamsRulesRulesetsBlockRule(rulesets.RulesetNewParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ + }, rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -62,14 +62,14 @@ func TestRulesetNewWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - }), rulesets.RulesetNewParamsRulesRulesetsBlockRule(rulesets.RulesetNewParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ + }, rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -79,11 +79,11 @@ func TestRulesetNewWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - })}), + }}), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), Description: cloudflare.F("My ruleset to execute managed rulesets"), @@ -115,11 +115,10 @@ func TestRulesetUpdateWithOptionalParams(t *testing.T) { context.TODO(), "2f2feab2026849078ba485f918791bdc", rulesets.RulesetUpdateParams{ - ID: cloudflare.F("2f2feab2026849078ba485f918791bdc"), - Rules: cloudflare.F([]rulesets.RulesetUpdateParamsRule{rulesets.RulesetUpdateParamsRulesRulesetsBlockRule(rulesets.RulesetUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Rules: cloudflare.F([]rulesets.RulesetUpdateParamsRuleUnion{rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -129,14 +128,14 @@ func TestRulesetUpdateWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - }), rulesets.RulesetUpdateParamsRulesRulesetsBlockRule(rulesets.RulesetUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + }, rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -146,14 +145,14 @@ func TestRulesetUpdateWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - }), rulesets.RulesetUpdateParamsRulesRulesetsBlockRule(rulesets.RulesetUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + }, rulesets.BlockRuleParam{ + Action: cloudflare.F(rulesets.BlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.BlockRuleActionParametersParam{ + Response: cloudflare.F(rulesets.BlockRuleActionParametersResponseParam{ Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), ContentType: cloudflare.F("application/json"), StatusCode: cloudflare.F(int64(400)), @@ -163,11 +162,11 @@ func TestRulesetUpdateWithOptionalParams(t *testing.T) { Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src ne 1.1.1.1"), ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ + Logging: cloudflare.F(rulesets.LoggingParam{ Enabled: cloudflare.F(true), }), Ref: cloudflare.F("my_ref"), - })}), + }}), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), Description: cloudflare.F("My ruleset to execute managed rulesets"), diff --git a/rulesets/version.go b/rulesets/version.go index 614bf80df8c..f664a61c909 100644 --- a/rulesets/version.go +++ b/rulesets/version.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "net/http" + "reflect" "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" @@ -13,6 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // VersionService contains methods and other services that help with interacting @@ -35,7 +37,7 @@ func NewVersionService(opts ...option.RequestOption) (r *VersionService) { } // Fetches the versions of an account or zone ruleset. -func (r *VersionService) List(ctx context.Context, rulesetID string, query VersionListParams, opts ...option.RequestOption) (res *pagination.SinglePage[VersionListResponse], err error) { +func (r *VersionService) List(ctx context.Context, rulesetID string, query VersionListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Ruleset], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -62,7 +64,7 @@ func (r *VersionService) List(ctx context.Context, rulesetID string, query Versi } // Fetches the versions of an account or zone ruleset. -func (r *VersionService) ListAutoPaging(ctx context.Context, rulesetID string, query VersionListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[VersionListResponse] { +func (r *VersionService) ListAutoPaging(ctx context.Context, rulesetID string, query VersionListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Ruleset] { return pagination.NewSinglePageAutoPager(r.List(ctx, rulesetID, query, opts...)) } @@ -85,7 +87,7 @@ func (r *VersionService) Delete(ctx context.Context, rulesetID string, rulesetVe } // Fetches a specific version of an account or zone ruleset. -func (r *VersionService) Get(ctx context.Context, rulesetID string, rulesetVersion string, query VersionGetParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *VersionService) Get(ctx context.Context, rulesetID string, rulesetVersion string, query VersionGetParams, opts ...option.RequestOption) (res *VersionGetResponse, err error) { opts = append(r.Options[:], opts...) var env VersionGetResponseEnvelope var accountOrZone string @@ -107,96 +109,279 @@ func (r *VersionService) Get(ctx context.Context, rulesetID string, rulesetVersi } // A ruleset object. -type VersionListResponse struct { +type VersionGetResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` // The kind of the ruleset. - Kind VersionListResponseKind `json:"kind,required"` + Kind VersionGetResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` // The human-readable name of the ruleset. Name string `json:"name,required"` // The phase of the ruleset. - Phase VersionListResponsePhase `json:"phase,required"` - // The unique ID of the ruleset. - ID string `json:"id"` - // An informative description of the ruleset. - Description string `json:"description"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated" format:"date-time"` + Phase VersionGetResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []VersionGetResponseRule `json:"rules,required"` // The version of the ruleset. - Version string `json:"version"` - JSON versionListResponseJSON `json:"-"` + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON versionGetResponseJSON `json:"-"` } -// versionListResponseJSON contains the JSON metadata for the struct -// [VersionListResponse] -type versionListResponseJSON struct { +// versionGetResponseJSON contains the JSON metadata for the struct +// [VersionGetResponse] +type versionGetResponseJSON struct { + ID apijson.Field Kind apijson.Field + LastUpdated apijson.Field Name apijson.Field Phase apijson.Field - ID apijson.Field - Description apijson.Field - LastUpdated apijson.Field + Rules apijson.Field Version apijson.Field + Description apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *VersionListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *VersionGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r versionListResponseJSON) RawJSON() string { +func (r versionGetResponseJSON) RawJSON() string { return r.raw } // The kind of the ruleset. -type VersionListResponseKind string +type VersionGetResponseKind string const ( - VersionListResponseKindManaged VersionListResponseKind = "managed" - VersionListResponseKindCustom VersionListResponseKind = "custom" - VersionListResponseKindRoot VersionListResponseKind = "root" - VersionListResponseKindZone VersionListResponseKind = "zone" + VersionGetResponseKindManaged VersionGetResponseKind = "managed" + VersionGetResponseKindCustom VersionGetResponseKind = "custom" + VersionGetResponseKindRoot VersionGetResponseKind = "root" + VersionGetResponseKindZone VersionGetResponseKind = "zone" ) -func (r VersionListResponseKind) IsKnown() bool { +func (r VersionGetResponseKind) IsKnown() bool { switch r { - case VersionListResponseKindManaged, VersionListResponseKindCustom, VersionListResponseKindRoot, VersionListResponseKindZone: + case VersionGetResponseKindManaged, VersionGetResponseKindCustom, VersionGetResponseKindRoot, VersionGetResponseKindZone: return true } return false } // The phase of the ruleset. -type VersionListResponsePhase string +type VersionGetResponsePhase string + +const ( + VersionGetResponsePhaseDDoSL4 VersionGetResponsePhase = "ddos_l4" + VersionGetResponsePhaseDDoSL7 VersionGetResponsePhase = "ddos_l7" + VersionGetResponsePhaseHTTPConfigSettings VersionGetResponsePhase = "http_config_settings" + VersionGetResponsePhaseHTTPCustomErrors VersionGetResponsePhase = "http_custom_errors" + VersionGetResponsePhaseHTTPLogCustomFields VersionGetResponsePhase = "http_log_custom_fields" + VersionGetResponsePhaseHTTPRatelimit VersionGetResponsePhase = "http_ratelimit" + VersionGetResponsePhaseHTTPRequestCacheSettings VersionGetResponsePhase = "http_request_cache_settings" + VersionGetResponsePhaseHTTPRequestDynamicRedirect VersionGetResponsePhase = "http_request_dynamic_redirect" + VersionGetResponsePhaseHTTPRequestFirewallCustom VersionGetResponsePhase = "http_request_firewall_custom" + VersionGetResponsePhaseHTTPRequestFirewallManaged VersionGetResponsePhase = "http_request_firewall_managed" + VersionGetResponsePhaseHTTPRequestLateTransform VersionGetResponsePhase = "http_request_late_transform" + VersionGetResponsePhaseHTTPRequestOrigin VersionGetResponsePhase = "http_request_origin" + VersionGetResponsePhaseHTTPRequestRedirect VersionGetResponsePhase = "http_request_redirect" + VersionGetResponsePhaseHTTPRequestSanitize VersionGetResponsePhase = "http_request_sanitize" + VersionGetResponsePhaseHTTPRequestSBFM VersionGetResponsePhase = "http_request_sbfm" + VersionGetResponsePhaseHTTPRequestSelectConfiguration VersionGetResponsePhase = "http_request_select_configuration" + VersionGetResponsePhaseHTTPRequestTransform VersionGetResponsePhase = "http_request_transform" + VersionGetResponsePhaseHTTPResponseCompression VersionGetResponsePhase = "http_response_compression" + VersionGetResponsePhaseHTTPResponseFirewallManaged VersionGetResponsePhase = "http_response_firewall_managed" + VersionGetResponsePhaseHTTPResponseHeadersTransform VersionGetResponsePhase = "http_response_headers_transform" + VersionGetResponsePhaseMagicTransit VersionGetResponsePhase = "magic_transit" + VersionGetResponsePhaseMagicTransitIDsManaged VersionGetResponsePhase = "magic_transit_ids_managed" + VersionGetResponsePhaseMagicTransitManaged VersionGetResponsePhase = "magic_transit_managed" +) + +func (r VersionGetResponsePhase) IsKnown() bool { + switch r { + case VersionGetResponsePhaseDDoSL4, VersionGetResponsePhaseDDoSL7, VersionGetResponsePhaseHTTPConfigSettings, VersionGetResponsePhaseHTTPCustomErrors, VersionGetResponsePhaseHTTPLogCustomFields, VersionGetResponsePhaseHTTPRatelimit, VersionGetResponsePhaseHTTPRequestCacheSettings, VersionGetResponsePhaseHTTPRequestDynamicRedirect, VersionGetResponsePhaseHTTPRequestFirewallCustom, VersionGetResponsePhaseHTTPRequestFirewallManaged, VersionGetResponsePhaseHTTPRequestLateTransform, VersionGetResponsePhaseHTTPRequestOrigin, VersionGetResponsePhaseHTTPRequestRedirect, VersionGetResponsePhaseHTTPRequestSanitize, VersionGetResponsePhaseHTTPRequestSBFM, VersionGetResponsePhaseHTTPRequestSelectConfiguration, VersionGetResponsePhaseHTTPRequestTransform, VersionGetResponsePhaseHTTPResponseCompression, VersionGetResponsePhaseHTTPResponseFirewallManaged, VersionGetResponsePhaseHTTPResponseHeadersTransform, VersionGetResponsePhaseMagicTransit, VersionGetResponsePhaseMagicTransitIDsManaged, VersionGetResponsePhaseMagicTransitManaged: + return true + } + return false +} + +type VersionGetResponseRule struct { + // The action to perform when the rule matches. + Action VersionGetResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON versionGetResponseRuleJSON `json:"-"` + union VersionGetResponseRulesUnion +} + +// versionGetResponseRuleJSON contains the JSON metadata for the struct +// [VersionGetResponseRule] +type versionGetResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r versionGetResponseRuleJSON) RawJSON() string { + return r.raw +} + +func (r *VersionGetResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r VersionGetResponseRule) AsUnion() VersionGetResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type VersionGetResponseRulesUnion interface { + implementsRulesetsVersionGetResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*VersionGetResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) +} + +// The action to perform when the rule matches. +type VersionGetResponseRulesAction string const ( - VersionListResponsePhaseDDoSL4 VersionListResponsePhase = "ddos_l4" - VersionListResponsePhaseDDoSL7 VersionListResponsePhase = "ddos_l7" - VersionListResponsePhaseHTTPConfigSettings VersionListResponsePhase = "http_config_settings" - VersionListResponsePhaseHTTPCustomErrors VersionListResponsePhase = "http_custom_errors" - VersionListResponsePhaseHTTPLogCustomFields VersionListResponsePhase = "http_log_custom_fields" - VersionListResponsePhaseHTTPRatelimit VersionListResponsePhase = "http_ratelimit" - VersionListResponsePhaseHTTPRequestCacheSettings VersionListResponsePhase = "http_request_cache_settings" - VersionListResponsePhaseHTTPRequestDynamicRedirect VersionListResponsePhase = "http_request_dynamic_redirect" - VersionListResponsePhaseHTTPRequestFirewallCustom VersionListResponsePhase = "http_request_firewall_custom" - VersionListResponsePhaseHTTPRequestFirewallManaged VersionListResponsePhase = "http_request_firewall_managed" - VersionListResponsePhaseHTTPRequestLateTransform VersionListResponsePhase = "http_request_late_transform" - VersionListResponsePhaseHTTPRequestOrigin VersionListResponsePhase = "http_request_origin" - VersionListResponsePhaseHTTPRequestRedirect VersionListResponsePhase = "http_request_redirect" - VersionListResponsePhaseHTTPRequestSanitize VersionListResponsePhase = "http_request_sanitize" - VersionListResponsePhaseHTTPRequestSbfm VersionListResponsePhase = "http_request_sbfm" - VersionListResponsePhaseHTTPRequestSelectConfiguration VersionListResponsePhase = "http_request_select_configuration" - VersionListResponsePhaseHTTPRequestTransform VersionListResponsePhase = "http_request_transform" - VersionListResponsePhaseHTTPResponseCompression VersionListResponsePhase = "http_response_compression" - VersionListResponsePhaseHTTPResponseFirewallManaged VersionListResponsePhase = "http_response_firewall_managed" - VersionListResponsePhaseHTTPResponseHeadersTransform VersionListResponsePhase = "http_response_headers_transform" - VersionListResponsePhaseMagicTransit VersionListResponsePhase = "magic_transit" - VersionListResponsePhaseMagicTransitIDsManaged VersionListResponsePhase = "magic_transit_ids_managed" - VersionListResponsePhaseMagicTransitManaged VersionListResponsePhase = "magic_transit_managed" + VersionGetResponseRulesActionBlock VersionGetResponseRulesAction = "block" + VersionGetResponseRulesActionChallenge VersionGetResponseRulesAction = "challenge" + VersionGetResponseRulesActionCompressResponse VersionGetResponseRulesAction = "compress_response" + VersionGetResponseRulesActionExecute VersionGetResponseRulesAction = "execute" + VersionGetResponseRulesActionJSChallenge VersionGetResponseRulesAction = "js_challenge" + VersionGetResponseRulesActionLog VersionGetResponseRulesAction = "log" + VersionGetResponseRulesActionManagedChallenge VersionGetResponseRulesAction = "managed_challenge" + VersionGetResponseRulesActionRedirect VersionGetResponseRulesAction = "redirect" + VersionGetResponseRulesActionRewrite VersionGetResponseRulesAction = "rewrite" + VersionGetResponseRulesActionRoute VersionGetResponseRulesAction = "route" + VersionGetResponseRulesActionScore VersionGetResponseRulesAction = "score" + VersionGetResponseRulesActionServeError VersionGetResponseRulesAction = "serve_error" + VersionGetResponseRulesActionSetConfig VersionGetResponseRulesAction = "set_config" + VersionGetResponseRulesActionSkip VersionGetResponseRulesAction = "skip" + VersionGetResponseRulesActionSetCacheSettings VersionGetResponseRulesAction = "set_cache_settings" ) -func (r VersionListResponsePhase) IsKnown() bool { +func (r VersionGetResponseRulesAction) IsKnown() bool { switch r { - case VersionListResponsePhaseDDoSL4, VersionListResponsePhaseDDoSL7, VersionListResponsePhaseHTTPConfigSettings, VersionListResponsePhaseHTTPCustomErrors, VersionListResponsePhaseHTTPLogCustomFields, VersionListResponsePhaseHTTPRatelimit, VersionListResponsePhaseHTTPRequestCacheSettings, VersionListResponsePhaseHTTPRequestDynamicRedirect, VersionListResponsePhaseHTTPRequestFirewallCustom, VersionListResponsePhaseHTTPRequestFirewallManaged, VersionListResponsePhaseHTTPRequestLateTransform, VersionListResponsePhaseHTTPRequestOrigin, VersionListResponsePhaseHTTPRequestRedirect, VersionListResponsePhaseHTTPRequestSanitize, VersionListResponsePhaseHTTPRequestSbfm, VersionListResponsePhaseHTTPRequestSelectConfiguration, VersionListResponsePhaseHTTPRequestTransform, VersionListResponsePhaseHTTPResponseCompression, VersionListResponsePhaseHTTPResponseFirewallManaged, VersionListResponsePhaseHTTPResponseHeadersTransform, VersionListResponsePhaseMagicTransit, VersionListResponsePhaseMagicTransitIDsManaged, VersionListResponsePhaseMagicTransitManaged: + case VersionGetResponseRulesActionBlock, VersionGetResponseRulesActionChallenge, VersionGetResponseRulesActionCompressResponse, VersionGetResponseRulesActionExecute, VersionGetResponseRulesActionJSChallenge, VersionGetResponseRulesActionLog, VersionGetResponseRulesActionManagedChallenge, VersionGetResponseRulesActionRedirect, VersionGetResponseRulesActionRewrite, VersionGetResponseRulesActionRoute, VersionGetResponseRulesActionScore, VersionGetResponseRulesActionServeError, VersionGetResponseRulesActionSetConfig, VersionGetResponseRulesActionSkip, VersionGetResponseRulesActionSetCacheSettings: return true } return false @@ -229,8 +414,8 @@ type VersionGetResponseEnvelope struct { Errors []VersionGetResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []VersionGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result VersionGetResponse `json:"result,required"` // Whether the API call was successful. Success VersionGetResponseEnvelopeSuccess `json:"success,required"` JSON versionGetResponseEnvelopeJSON `json:"-"` diff --git a/rulesets/versionbytag.go b/rulesets/versionbytag.go index 2f4335adfd0..6ac3a82af3a 100644 --- a/rulesets/versionbytag.go +++ b/rulesets/versionbytag.go @@ -6,11 +6,14 @@ import ( "context" "fmt" "net/http" + "reflect" + "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // VersionByTagService contains methods and other services that help with @@ -32,7 +35,7 @@ func NewVersionByTagService(opts ...option.RequestOption) (r *VersionByTagServic } // Fetches the rules of a managed account ruleset version for a given tag. -func (r *VersionByTagService) Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query VersionByTagGetParams, opts ...option.RequestOption) (res *Ruleset, err error) { +func (r *VersionByTagService) Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query VersionByTagGetParams, opts ...option.RequestOption) (res *VersionByTagGetResponse, err error) { opts = append(r.Options[:], opts...) var env VersionByTagGetResponseEnvelope path := fmt.Sprintf("accounts/%s/rulesets/%s/versions/%s/by_tag/%s", query.AccountID, rulesetID, rulesetVersion, ruleTag) @@ -44,6 +47,285 @@ func (r *VersionByTagService) Get(ctx context.Context, rulesetID string, ruleset return } +// A ruleset object. +type VersionByTagGetResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind VersionByTagGetResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase VersionByTagGetResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []VersionByTagGetResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON versionByTagGetResponseJSON `json:"-"` +} + +// versionByTagGetResponseJSON contains the JSON metadata for the struct +// [VersionByTagGetResponse] +type versionByTagGetResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionByTagGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionByTagGetResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type VersionByTagGetResponseKind string + +const ( + VersionByTagGetResponseKindManaged VersionByTagGetResponseKind = "managed" + VersionByTagGetResponseKindCustom VersionByTagGetResponseKind = "custom" + VersionByTagGetResponseKindRoot VersionByTagGetResponseKind = "root" + VersionByTagGetResponseKindZone VersionByTagGetResponseKind = "zone" +) + +func (r VersionByTagGetResponseKind) IsKnown() bool { + switch r { + case VersionByTagGetResponseKindManaged, VersionByTagGetResponseKindCustom, VersionByTagGetResponseKindRoot, VersionByTagGetResponseKindZone: + return true + } + return false +} + +// The phase of the ruleset. +type VersionByTagGetResponsePhase string + +const ( + VersionByTagGetResponsePhaseDDoSL4 VersionByTagGetResponsePhase = "ddos_l4" + VersionByTagGetResponsePhaseDDoSL7 VersionByTagGetResponsePhase = "ddos_l7" + VersionByTagGetResponsePhaseHTTPConfigSettings VersionByTagGetResponsePhase = "http_config_settings" + VersionByTagGetResponsePhaseHTTPCustomErrors VersionByTagGetResponsePhase = "http_custom_errors" + VersionByTagGetResponsePhaseHTTPLogCustomFields VersionByTagGetResponsePhase = "http_log_custom_fields" + VersionByTagGetResponsePhaseHTTPRatelimit VersionByTagGetResponsePhase = "http_ratelimit" + VersionByTagGetResponsePhaseHTTPRequestCacheSettings VersionByTagGetResponsePhase = "http_request_cache_settings" + VersionByTagGetResponsePhaseHTTPRequestDynamicRedirect VersionByTagGetResponsePhase = "http_request_dynamic_redirect" + VersionByTagGetResponsePhaseHTTPRequestFirewallCustom VersionByTagGetResponsePhase = "http_request_firewall_custom" + VersionByTagGetResponsePhaseHTTPRequestFirewallManaged VersionByTagGetResponsePhase = "http_request_firewall_managed" + VersionByTagGetResponsePhaseHTTPRequestLateTransform VersionByTagGetResponsePhase = "http_request_late_transform" + VersionByTagGetResponsePhaseHTTPRequestOrigin VersionByTagGetResponsePhase = "http_request_origin" + VersionByTagGetResponsePhaseHTTPRequestRedirect VersionByTagGetResponsePhase = "http_request_redirect" + VersionByTagGetResponsePhaseHTTPRequestSanitize VersionByTagGetResponsePhase = "http_request_sanitize" + VersionByTagGetResponsePhaseHTTPRequestSBFM VersionByTagGetResponsePhase = "http_request_sbfm" + VersionByTagGetResponsePhaseHTTPRequestSelectConfiguration VersionByTagGetResponsePhase = "http_request_select_configuration" + VersionByTagGetResponsePhaseHTTPRequestTransform VersionByTagGetResponsePhase = "http_request_transform" + VersionByTagGetResponsePhaseHTTPResponseCompression VersionByTagGetResponsePhase = "http_response_compression" + VersionByTagGetResponsePhaseHTTPResponseFirewallManaged VersionByTagGetResponsePhase = "http_response_firewall_managed" + VersionByTagGetResponsePhaseHTTPResponseHeadersTransform VersionByTagGetResponsePhase = "http_response_headers_transform" + VersionByTagGetResponsePhaseMagicTransit VersionByTagGetResponsePhase = "magic_transit" + VersionByTagGetResponsePhaseMagicTransitIDsManaged VersionByTagGetResponsePhase = "magic_transit_ids_managed" + VersionByTagGetResponsePhaseMagicTransitManaged VersionByTagGetResponsePhase = "magic_transit_managed" +) + +func (r VersionByTagGetResponsePhase) IsKnown() bool { + switch r { + case VersionByTagGetResponsePhaseDDoSL4, VersionByTagGetResponsePhaseDDoSL7, VersionByTagGetResponsePhaseHTTPConfigSettings, VersionByTagGetResponsePhaseHTTPCustomErrors, VersionByTagGetResponsePhaseHTTPLogCustomFields, VersionByTagGetResponsePhaseHTTPRatelimit, VersionByTagGetResponsePhaseHTTPRequestCacheSettings, VersionByTagGetResponsePhaseHTTPRequestDynamicRedirect, VersionByTagGetResponsePhaseHTTPRequestFirewallCustom, VersionByTagGetResponsePhaseHTTPRequestFirewallManaged, VersionByTagGetResponsePhaseHTTPRequestLateTransform, VersionByTagGetResponsePhaseHTTPRequestOrigin, VersionByTagGetResponsePhaseHTTPRequestRedirect, VersionByTagGetResponsePhaseHTTPRequestSanitize, VersionByTagGetResponsePhaseHTTPRequestSBFM, VersionByTagGetResponsePhaseHTTPRequestSelectConfiguration, VersionByTagGetResponsePhaseHTTPRequestTransform, VersionByTagGetResponsePhaseHTTPResponseCompression, VersionByTagGetResponsePhaseHTTPResponseFirewallManaged, VersionByTagGetResponsePhaseHTTPResponseHeadersTransform, VersionByTagGetResponsePhaseMagicTransit, VersionByTagGetResponsePhaseMagicTransitIDsManaged, VersionByTagGetResponsePhaseMagicTransitManaged: + return true + } + return false +} + +type VersionByTagGetResponseRule struct { + // The action to perform when the rule matches. + Action VersionByTagGetResponseRulesAction `json:"action"` + ActionParameters interface{} `json:"action_parameters,required"` + Categories interface{} `json:"categories,required"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // The unique ID of the rule. + ID string `json:"id"` + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // An object configuring the rule's logging behavior. + Logging Logging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + // The version of the rule. + Version string `json:"version,required"` + JSON versionByTagGetResponseRuleJSON `json:"-"` + union VersionByTagGetResponseRulesUnion +} + +// versionByTagGetResponseRuleJSON contains the JSON metadata for the struct +// [VersionByTagGetResponseRule] +type versionByTagGetResponseRuleJSON struct { + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + ID apijson.Field + LastUpdated apijson.Field + Logging apijson.Field + Ref apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r versionByTagGetResponseRuleJSON) RawJSON() string { + return r.raw +} + +func (r *VersionByTagGetResponseRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r VersionByTagGetResponseRule) AsUnion() VersionByTagGetResponseRulesUnion { + return r.union +} + +// Union satisfied by [rulesets.BlockRule], [rulesets.ChallengeRule], +// [rulesets.CompressResponseRule], [rulesets.ExecuteRule], +// [rulesets.JSChallengeRule], [rulesets.LogRule], [rulesets.ManagedChallengeRule], +// [rulesets.RedirectRule], [rulesets.RewriteRule], [rulesets.RouteRule], +// [rulesets.ScoreRule], [rulesets.ServeErrorRule], [rulesets.SetConfigRule], +// [rulesets.SkipRule] or [rulesets.SetCacheSettingsRule]. +type VersionByTagGetResponseRulesUnion interface { + implementsRulesetsVersionByTagGetResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*VersionByTagGetResponseRulesUnion)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ChallengeRule{}), + DiscriminatorValue: "challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CompressResponseRule{}), + DiscriminatorValue: "compress_response", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JSChallengeRule{}), + DiscriminatorValue: "js_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ManagedChallengeRule{}), + DiscriminatorValue: "managed_challenge", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RedirectRule{}), + DiscriminatorValue: "redirect", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RewriteRule{}), + DiscriminatorValue: "rewrite", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RouteRule{}), + DiscriminatorValue: "route", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScoreRule{}), + DiscriminatorValue: "score", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServeErrorRule{}), + DiscriminatorValue: "serve_error", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetConfigRule{}), + DiscriminatorValue: "set_config", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SkipRule{}), + DiscriminatorValue: "skip", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SetCacheSettingsRule{}), + DiscriminatorValue: "set_cache_settings", + }, + ) +} + +// The action to perform when the rule matches. +type VersionByTagGetResponseRulesAction string + +const ( + VersionByTagGetResponseRulesActionBlock VersionByTagGetResponseRulesAction = "block" + VersionByTagGetResponseRulesActionChallenge VersionByTagGetResponseRulesAction = "challenge" + VersionByTagGetResponseRulesActionCompressResponse VersionByTagGetResponseRulesAction = "compress_response" + VersionByTagGetResponseRulesActionExecute VersionByTagGetResponseRulesAction = "execute" + VersionByTagGetResponseRulesActionJSChallenge VersionByTagGetResponseRulesAction = "js_challenge" + VersionByTagGetResponseRulesActionLog VersionByTagGetResponseRulesAction = "log" + VersionByTagGetResponseRulesActionManagedChallenge VersionByTagGetResponseRulesAction = "managed_challenge" + VersionByTagGetResponseRulesActionRedirect VersionByTagGetResponseRulesAction = "redirect" + VersionByTagGetResponseRulesActionRewrite VersionByTagGetResponseRulesAction = "rewrite" + VersionByTagGetResponseRulesActionRoute VersionByTagGetResponseRulesAction = "route" + VersionByTagGetResponseRulesActionScore VersionByTagGetResponseRulesAction = "score" + VersionByTagGetResponseRulesActionServeError VersionByTagGetResponseRulesAction = "serve_error" + VersionByTagGetResponseRulesActionSetConfig VersionByTagGetResponseRulesAction = "set_config" + VersionByTagGetResponseRulesActionSkip VersionByTagGetResponseRulesAction = "skip" + VersionByTagGetResponseRulesActionSetCacheSettings VersionByTagGetResponseRulesAction = "set_cache_settings" +) + +func (r VersionByTagGetResponseRulesAction) IsKnown() bool { + switch r { + case VersionByTagGetResponseRulesActionBlock, VersionByTagGetResponseRulesActionChallenge, VersionByTagGetResponseRulesActionCompressResponse, VersionByTagGetResponseRulesActionExecute, VersionByTagGetResponseRulesActionJSChallenge, VersionByTagGetResponseRulesActionLog, VersionByTagGetResponseRulesActionManagedChallenge, VersionByTagGetResponseRulesActionRedirect, VersionByTagGetResponseRulesActionRewrite, VersionByTagGetResponseRulesActionRoute, VersionByTagGetResponseRulesActionScore, VersionByTagGetResponseRulesActionServeError, VersionByTagGetResponseRulesActionSetConfig, VersionByTagGetResponseRulesActionSkip, VersionByTagGetResponseRulesActionSetCacheSettings: + return true + } + return false +} + type VersionByTagGetParams struct { // The unique ID of the account. AccountID param.Field[string] `path:"account_id,required"` @@ -55,8 +337,8 @@ type VersionByTagGetResponseEnvelope struct { Errors []VersionByTagGetResponseEnvelopeErrors `json:"errors,required"` // A list of warning messages. Messages []VersionByTagGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result Ruleset `json:"result,required"` + // A ruleset object. + Result VersionByTagGetResponse `json:"result,required"` // Whether the API call was successful. Success VersionByTagGetResponseEnvelopeSuccess `json:"success,required"` JSON versionByTagGetResponseEnvelopeJSON `json:"-"` diff --git a/rum/aliases.go b/rum/aliases.go index f72937278e9..291614971c2 100644 --- a/rum/aliases.go +++ b/rum/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/rum/rule.go b/rum/rule.go index def79fb8450..c23f7b26c23 100644 --- a/rum/rule.go +++ b/rum/rule.go @@ -212,13 +212,19 @@ func (r RuleNewParams) MarshalJSON() (data []byte, err error) { } type RuleNewResponseEnvelope struct { - Result RUMRule `json:"result"` - JSON ruleNewResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result RUMRule `json:"result"` + JSON ruleNewResponseEnvelopeJSON `json:"-"` } // ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct // [RuleNewResponseEnvelope] type ruleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -248,13 +254,19 @@ func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { } type RuleUpdateResponseEnvelope struct { - Result RUMRule `json:"result"` - JSON ruleUpdateResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result RUMRule `json:"result"` + JSON ruleUpdateResponseEnvelopeJSON `json:"-"` } // ruleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct // [RuleUpdateResponseEnvelope] type ruleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -274,13 +286,19 @@ type RuleListParams struct { } type RuleListResponseEnvelope struct { - Result RuleListResponse `json:"result"` - JSON ruleListResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result RuleListResponse `json:"result"` + JSON ruleListResponseEnvelopeJSON `json:"-"` } // ruleListResponseEnvelopeJSON contains the JSON metadata for the struct // [RuleListResponseEnvelope] type ruleListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -300,13 +318,19 @@ type RuleDeleteParams struct { } type RuleDeleteResponseEnvelope struct { - Result RuleDeleteResponse `json:"result"` - JSON ruleDeleteResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result RuleDeleteResponse `json:"result"` + JSON ruleDeleteResponseEnvelopeJSON `json:"-"` } // ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct // [RuleDeleteResponseEnvelope] type ruleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field diff --git a/rum/siteinfo.go b/rum/siteinfo.go index 83a38851858..75f11805110 100644 --- a/rum/siteinfo.go +++ b/rum/siteinfo.go @@ -35,7 +35,7 @@ func NewSiteInfoService(opts ...option.RequestOption) (r *SiteInfoService) { } // Creates a new Web Analytics site. -func (r *SiteInfoService) New(ctx context.Context, params SiteInfoNewParams, opts ...option.RequestOption) (res *RUMSite, err error) { +func (r *SiteInfoService) New(ctx context.Context, params SiteInfoNewParams, opts ...option.RequestOption) (res *Site, err error) { opts = append(r.Options[:], opts...) var env SiteInfoNewResponseEnvelope path := fmt.Sprintf("accounts/%s/rum/site_info", params.AccountID) @@ -48,7 +48,7 @@ func (r *SiteInfoService) New(ctx context.Context, params SiteInfoNewParams, opt } // Updates an existing Web Analytics site. -func (r *SiteInfoService) Update(ctx context.Context, siteID string, params SiteInfoUpdateParams, opts ...option.RequestOption) (res *RUMSite, err error) { +func (r *SiteInfoService) Update(ctx context.Context, siteID string, params SiteInfoUpdateParams, opts ...option.RequestOption) (res *Site, err error) { opts = append(r.Options[:], opts...) var env SiteInfoUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/rum/site_info/%s", params.AccountID, siteID) @@ -61,7 +61,7 @@ func (r *SiteInfoService) Update(ctx context.Context, siteID string, params Site } // Lists all Web Analytics sites of an account. -func (r *SiteInfoService) List(ctx context.Context, params SiteInfoListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[RUMSite], err error) { +func (r *SiteInfoService) List(ctx context.Context, params SiteInfoListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Site], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -79,7 +79,7 @@ func (r *SiteInfoService) List(ctx context.Context, params SiteInfoListParams, o } // Lists all Web Analytics sites of an account. -func (r *SiteInfoService) ListAutoPaging(ctx context.Context, params SiteInfoListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[RUMSite] { +func (r *SiteInfoService) ListAutoPaging(ctx context.Context, params SiteInfoListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Site] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } @@ -97,7 +97,7 @@ func (r *SiteInfoService) Delete(ctx context.Context, siteID string, body SiteIn } // Retrieves a Web Analytics site. -func (r *SiteInfoService) Get(ctx context.Context, siteID string, query SiteInfoGetParams, opts ...option.RequestOption) (res *RUMSite, err error) { +func (r *SiteInfoService) Get(ctx context.Context, siteID string, query SiteInfoGetParams, opts ...option.RequestOption) (res *Site, err error) { opts = append(r.Options[:], opts...) var env SiteInfoGetResponseEnvelope path := fmt.Sprintf("accounts/%s/rum/site_info/%s", query.AccountID, siteID) @@ -109,25 +109,25 @@ func (r *SiteInfoService) Get(ctx context.Context, siteID string, query SiteInfo return } -type RUMSite struct { +type Site struct { // If enabled, the JavaScript snippet is automatically injected for orange-clouded // sites. AutoInstall bool `json:"auto_install"` Created time.Time `json:"created" format:"date-time"` // A list of rules. - Rules []RUMRule `json:"rules"` - Ruleset RUMSiteRuleset `json:"ruleset"` + Rules []RUMRule `json:"rules"` + Ruleset SiteRuleset `json:"ruleset"` // The Web Analytics site identifier. SiteTag string `json:"site_tag"` // The Web Analytics site token. SiteToken string `json:"site_token"` // Encoded JavaScript snippet. - Snippet string `json:"snippet"` - JSON rumSiteJSON `json:"-"` + Snippet string `json:"snippet"` + JSON siteJSON `json:"-"` } -// rumSiteJSON contains the JSON metadata for the struct [RUMSite] -type rumSiteJSON struct { +// siteJSON contains the JSON metadata for the struct [Site] +type siteJSON struct { AutoInstall apijson.Field Created apijson.Field Rules apijson.Field @@ -139,27 +139,27 @@ type rumSiteJSON struct { ExtraFields map[string]apijson.Field } -func (r *RUMSite) UnmarshalJSON(data []byte) (err error) { +func (r *Site) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rumSiteJSON) RawJSON() string { +func (r siteJSON) RawJSON() string { return r.raw } -type RUMSiteRuleset struct { +type SiteRuleset struct { // The Web Analytics ruleset identifier. ID string `json:"id"` // Whether the ruleset is enabled. Enabled bool `json:"enabled"` ZoneName string `json:"zone_name"` // The zone identifier. - ZoneTag string `json:"zone_tag"` - JSON rumSiteRulesetJSON `json:"-"` + ZoneTag string `json:"zone_tag"` + JSON siteRulesetJSON `json:"-"` } -// rumSiteRulesetJSON contains the JSON metadata for the struct [RUMSiteRuleset] -type rumSiteRulesetJSON struct { +// siteRulesetJSON contains the JSON metadata for the struct [SiteRuleset] +type siteRulesetJSON struct { ID apijson.Field Enabled apijson.Field ZoneName apijson.Field @@ -168,11 +168,11 @@ type rumSiteRulesetJSON struct { ExtraFields map[string]apijson.Field } -func (r *RUMSiteRuleset) UnmarshalJSON(data []byte) (err error) { +func (r *SiteRuleset) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rumSiteRulesetJSON) RawJSON() string { +func (r siteRulesetJSON) RawJSON() string { return r.raw } @@ -215,13 +215,19 @@ func (r SiteInfoNewParams) MarshalJSON() (data []byte, err error) { } type SiteInfoNewResponseEnvelope struct { - Result RUMSite `json:"result"` - JSON siteInfoNewResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result Site `json:"result"` + JSON siteInfoNewResponseEnvelopeJSON `json:"-"` } // siteInfoNewResponseEnvelopeJSON contains the JSON metadata for the struct // [SiteInfoNewResponseEnvelope] type siteInfoNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -252,13 +258,19 @@ func (r SiteInfoUpdateParams) MarshalJSON() (data []byte, err error) { } type SiteInfoUpdateResponseEnvelope struct { - Result RUMSite `json:"result"` - JSON siteInfoUpdateResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result Site `json:"result"` + JSON siteInfoUpdateResponseEnvelopeJSON `json:"-"` } // siteInfoUpdateResponseEnvelopeJSON contains the JSON metadata for the struct // [SiteInfoUpdateResponseEnvelope] type siteInfoUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -286,7 +298,7 @@ type SiteInfoListParams struct { // URLQuery serializes [SiteInfoListParams]'s query parameters as `url.Values`. func (r SiteInfoListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -313,13 +325,19 @@ type SiteInfoDeleteParams struct { } type SiteInfoDeleteResponseEnvelope struct { - Result SiteInfoDeleteResponse `json:"result"` - JSON siteInfoDeleteResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result SiteInfoDeleteResponse `json:"result"` + JSON siteInfoDeleteResponseEnvelopeJSON `json:"-"` } // siteInfoDeleteResponseEnvelopeJSON contains the JSON metadata for the struct // [SiteInfoDeleteResponseEnvelope] type siteInfoDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -339,13 +357,19 @@ type SiteInfoGetParams struct { } type SiteInfoGetResponseEnvelope struct { - Result RUMSite `json:"result"` - JSON siteInfoGetResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result Site `json:"result"` + JSON siteInfoGetResponseEnvelopeJSON `json:"-"` } // siteInfoGetResponseEnvelopeJSON contains the JSON metadata for the struct // [SiteInfoGetResponseEnvelope] type siteInfoGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field diff --git a/secondary_dns/acl.go b/secondary_dns/acl.go index 677ccb1984b..cce73998052 100644 --- a/secondary_dns/acl.go +++ b/secondary_dns/acl.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -32,7 +33,7 @@ func NewACLService(opts ...option.RequestOption) (r *ACLService) { } // Create ACL. -func (r *ACLService) New(ctx context.Context, params ACLNewParams, opts ...option.RequestOption) (res *SecondaryDNSACL, err error) { +func (r *ACLService) New(ctx context.Context, params ACLNewParams, opts ...option.RequestOption) (res *ACL, err error) { opts = append(r.Options[:], opts...) var env ACLNewResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/acls", params.AccountID) @@ -45,7 +46,7 @@ func (r *ACLService) New(ctx context.Context, params ACLNewParams, opts ...optio } // Modify ACL. -func (r *ACLService) Update(ctx context.Context, aclID string, params ACLUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSACL, err error) { +func (r *ACLService) Update(ctx context.Context, aclID string, params ACLUpdateParams, opts ...option.RequestOption) (res *ACL, err error) { opts = append(r.Options[:], opts...) var env ACLUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/acls/%s", params.AccountID, aclID) @@ -58,7 +59,7 @@ func (r *ACLService) Update(ctx context.Context, aclID string, params ACLUpdateP } // List ACLs. -func (r *ACLService) List(ctx context.Context, query ACLListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SecondaryDNSACL], err error) { +func (r *ACLService) List(ctx context.Context, query ACLListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ACL], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -76,15 +77,15 @@ func (r *ACLService) List(ctx context.Context, query ACLListParams, opts ...opti } // List ACLs. -func (r *ACLService) ListAutoPaging(ctx context.Context, query ACLListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SecondaryDNSACL] { +func (r *ACLService) ListAutoPaging(ctx context.Context, query ACLListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ACL] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete ACL. -func (r *ACLService) Delete(ctx context.Context, aclID string, body ACLDeleteParams, opts ...option.RequestOption) (res *ACLDeleteResponse, err error) { +func (r *ACLService) Delete(ctx context.Context, aclID string, params ACLDeleteParams, opts ...option.RequestOption) (res *ACLDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env ACLDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/secondary_dns/acls/%s", body.AccountID, aclID) + path := fmt.Sprintf("accounts/%s/secondary_dns/acls/%s", params.AccountID, aclID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -94,7 +95,7 @@ func (r *ACLService) Delete(ctx context.Context, aclID string, body ACLDeletePar } // Get ACL. -func (r *ACLService) Get(ctx context.Context, aclID string, query ACLGetParams, opts ...option.RequestOption) (res *SecondaryDNSACL, err error) { +func (r *ACLService) Get(ctx context.Context, aclID string, query ACLGetParams, opts ...option.RequestOption) (res *ACL, err error) { opts = append(r.Options[:], opts...) var env ACLGetResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/acls/%s", query.AccountID, aclID) @@ -106,7 +107,7 @@ func (r *ACLService) Get(ctx context.Context, aclID string, query ACLGetParams, return } -type SecondaryDNSACL struct { +type ACL struct { ID string `json:"id,required"` // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will // be applied for the entire account. The IP range is used to allow additional @@ -115,12 +116,12 @@ type SecondaryDNSACL struct { // IPv6 respectively. IPRange string `json:"ip_range,required"` // The name of the acl. - Name string `json:"name,required"` - JSON secondaryDnsaclJSON `json:"-"` + Name string `json:"name,required"` + JSON aclJSON `json:"-"` } -// secondaryDnsaclJSON contains the JSON metadata for the struct [SecondaryDNSACL] -type secondaryDnsaclJSON struct { +// aclJSON contains the JSON metadata for the struct [ACL] +type aclJSON struct { ID apijson.Field IPRange apijson.Field Name apijson.Field @@ -128,14 +129,29 @@ type secondaryDnsaclJSON struct { ExtraFields map[string]apijson.Field } -func (r *SecondaryDNSACL) UnmarshalJSON(data []byte) (err error) { +func (r *ACL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r secondaryDnsaclJSON) RawJSON() string { +func (r aclJSON) RawJSON() string { return r.raw } +type ACLParam struct { + // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will + // be applied for the entire account. The IP range is used to allow additional + // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from + // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for + // IPv6 respectively. + IPRange param.Field[string] `json:"ip_range,required"` + // The name of the acl. + Name param.Field[string] `json:"name,required"` +} + +func (r ACLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type ACLDeleteResponse struct { ID string `json:"id"` JSON aclDeleteResponseJSON `json:"-"` @@ -158,8 +174,8 @@ func (r aclDeleteResponseJSON) RawJSON() string { } type ACLNewParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r ACLNewParams) MarshalJSON() (data []byte, err error) { @@ -167,9 +183,9 @@ func (r ACLNewParams) MarshalJSON() (data []byte, err error) { } type ACLNewResponseEnvelope struct { - Errors []ACLNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ACLNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSACL `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ACL `json:"result,required"` // Whether the API call was successful Success ACLNewResponseEnvelopeSuccess `json:"success,required"` JSON aclNewResponseEnvelopeJSON `json:"-"` @@ -194,52 +210,6 @@ func (r aclNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ACLNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// aclNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ACLNewResponseEnvelopeErrors] -type aclNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ACLNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// aclNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ACLNewResponseEnvelopeMessages] -type aclNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ACLNewResponseEnvelopeSuccess bool @@ -257,24 +227,17 @@ func (r ACLNewResponseEnvelopeSuccess) IsKnown() bool { type ACLUpdateParams struct { AccountID param.Field[string] `path:"account_id,required"` - // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will - // be applied for the entire account. The IP range is used to allow additional - // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from - // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for - // IPv6 respectively. - IPRange param.Field[string] `json:"ip_range,required"` - // The name of the acl. - Name param.Field[string] `json:"name,required"` + ACL ACLParam `json:"acl,required"` } func (r ACLUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.ACL) } type ACLUpdateResponseEnvelope struct { - Errors []ACLUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ACLUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSACL `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ACL `json:"result,required"` // Whether the API call was successful Success ACLUpdateResponseEnvelopeSuccess `json:"success,required"` JSON aclUpdateResponseEnvelopeJSON `json:"-"` @@ -299,52 +262,6 @@ func (r aclUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ACLUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// aclUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ACLUpdateResponseEnvelopeErrors] -type aclUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ACLUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// aclUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ACLUpdateResponseEnvelopeMessages] -type aclUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ACLUpdateResponseEnvelopeSuccess bool @@ -366,12 +283,17 @@ type ACLListParams struct { type ACLDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ACLDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ACLDeleteResponseEnvelope struct { - Errors []ACLDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ACLDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ACLDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ACLDeleteResponse `json:"result,required"` // Whether the API call was successful Success ACLDeleteResponseEnvelopeSuccess `json:"success,required"` JSON aclDeleteResponseEnvelopeJSON `json:"-"` @@ -396,52 +318,6 @@ func (r aclDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ACLDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// aclDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ACLDeleteResponseEnvelopeErrors] -type aclDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ACLDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// aclDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ACLDeleteResponseEnvelopeMessages] -type aclDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ACLDeleteResponseEnvelopeSuccess bool @@ -462,9 +338,9 @@ type ACLGetParams struct { } type ACLGetResponseEnvelope struct { - Errors []ACLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ACLGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSACL `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ACL `json:"result,required"` // Whether the API call was successful Success ACLGetResponseEnvelopeSuccess `json:"success,required"` JSON aclGetResponseEnvelopeJSON `json:"-"` @@ -489,52 +365,6 @@ func (r aclGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ACLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// aclGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ACLGetResponseEnvelopeErrors] -type aclGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ACLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON aclGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// aclGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ACLGetResponseEnvelopeMessages] -type aclGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r aclGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ACLGetResponseEnvelopeSuccess bool diff --git a/secondary_dns/acl_test.go b/secondary_dns/acl_test.go index c9537ec02dd..c63989f7f30 100644 --- a/secondary_dns/acl_test.go +++ b/secondary_dns/acl_test.go @@ -30,7 +30,7 @@ func TestACLNew(t *testing.T) { ) _, err := client.SecondaryDNS.ACLs.New(context.TODO(), secondary_dns.ACLNewParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -60,8 +60,10 @@ func TestACLUpdate(t *testing.T) { "23ff594956f20c2a721606e94745a8aa", secondary_dns.ACLUpdateParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - IPRange: cloudflare.F("192.0.2.53/28"), - Name: cloudflare.F("my-acl-1"), + ACL: secondary_dns.ACLParam{ + IPRange: cloudflare.F("192.0.2.53/28"), + Name: cloudflare.F("my-acl-1"), + }, }, ) if err != nil { @@ -118,6 +120,7 @@ func TestACLDelete(t *testing.T) { "23ff594956f20c2a721606e94745a8aa", secondary_dns.ACLDeleteParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/secondary_dns/aliases.go b/secondary_dns/aliases.go index 744bdfed215..b3a2adb1c4a 100644 --- a/secondary_dns/aliases.go +++ b/secondary_dns/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/secondary_dns/forceaxfr.go b/secondary_dns/forceaxfr.go index 081d7c02194..49d3dd13ce4 100644 --- a/secondary_dns/forceaxfr.go +++ b/secondary_dns/forceaxfr.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,10 +32,10 @@ func NewForceAXFRService(opts ...option.RequestOption) (r *ForceAXFRService) { } // Sends AXFR zone transfer request to primary nameserver(s). -func (r *ForceAXFRService) New(ctx context.Context, body ForceAXFRNewParams, opts ...option.RequestOption) (res *SecondaryDNSForce, err error) { +func (r *ForceAXFRService) New(ctx context.Context, params ForceAXFRNewParams, opts ...option.RequestOption) (res *ForceAXFR, err error) { opts = append(r.Options[:], opts...) var env ForceAXFRNewResponseEnvelope - path := fmt.Sprintf("zones/%s/secondary_dns/force_axfr", body.ZoneID) + path := fmt.Sprintf("zones/%s/secondary_dns/force_axfr", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -43,17 +44,22 @@ func (r *ForceAXFRService) New(ctx context.Context, body ForceAXFRNewParams, opt return } -type SecondaryDNSForce = string +type ForceAXFR = string type ForceAXFRNewParams struct { ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ForceAXFRNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ForceAXFRNewResponseEnvelope struct { - Errors []ForceAXFRNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ForceAXFRNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // When force_axfr query parameter is set to true, the response is a simple string - Result SecondaryDNSForce `json:"result,required"` + Result ForceAXFR `json:"result,required"` // Whether the API call was successful Success ForceAXFRNewResponseEnvelopeSuccess `json:"success,required"` JSON forceAXFRNewResponseEnvelopeJSON `json:"-"` @@ -78,52 +84,6 @@ func (r forceAXFRNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ForceAXFRNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON forceAXFRNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// forceAXFRNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ForceAXFRNewResponseEnvelopeErrors] -type forceAXFRNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ForceAXFRNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r forceAXFRNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ForceAXFRNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON forceAXFRNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// forceAXFRNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ForceAXFRNewResponseEnvelopeMessages] -type forceAXFRNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ForceAXFRNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r forceAXFRNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ForceAXFRNewResponseEnvelopeSuccess bool diff --git a/secondary_dns/forceaxfr_test.go b/secondary_dns/forceaxfr_test.go index 2bc8ad0602b..ca75a7e43bc 100644 --- a/secondary_dns/forceaxfr_test.go +++ b/secondary_dns/forceaxfr_test.go @@ -30,6 +30,7 @@ func TestForceAXFRNew(t *testing.T) { ) _, err := client.SecondaryDNS.ForceAXFR.New(context.TODO(), secondary_dns.ForceAXFRNewParams{ ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/secondary_dns/incoming.go b/secondary_dns/incoming.go index 85aa9ab5a51..f7afdfb69ff 100644 --- a/secondary_dns/incoming.go +++ b/secondary_dns/incoming.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -57,10 +58,10 @@ func (r *IncomingService) Update(ctx context.Context, params IncomingUpdateParam } // Delete secondary zone configuration for incoming zone transfers. -func (r *IncomingService) Delete(ctx context.Context, body IncomingDeleteParams, opts ...option.RequestOption) (res *IncomingDeleteResponse, err error) { +func (r *IncomingService) Delete(ctx context.Context, params IncomingDeleteParams, opts ...option.RequestOption) (res *IncomingDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env IncomingDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/secondary_dns/incoming", body.ZoneID) + path := fmt.Sprintf("zones/%s/secondary_dns/incoming", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -248,9 +249,9 @@ func (r IncomingNewParams) MarshalJSON() (data []byte, err error) { } type IncomingNewResponseEnvelope struct { - Errors []IncomingNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IncomingNewResponseEnvelopeMessages `json:"messages,required"` - Result IncomingNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IncomingNewResponse `json:"result,required"` // Whether the API call was successful Success IncomingNewResponseEnvelopeSuccess `json:"success,required"` JSON incomingNewResponseEnvelopeJSON `json:"-"` @@ -275,52 +276,6 @@ func (r incomingNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IncomingNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// incomingNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IncomingNewResponseEnvelopeErrors] -type incomingNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IncomingNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// incomingNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IncomingNewResponseEnvelopeMessages] -type incomingNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IncomingNewResponseEnvelopeSuccess bool @@ -352,9 +307,9 @@ func (r IncomingUpdateParams) MarshalJSON() (data []byte, err error) { } type IncomingUpdateResponseEnvelope struct { - Errors []IncomingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []IncomingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result IncomingUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IncomingUpdateResponse `json:"result,required"` // Whether the API call was successful Success IncomingUpdateResponseEnvelopeSuccess `json:"success,required"` JSON incomingUpdateResponseEnvelopeJSON `json:"-"` @@ -379,52 +334,6 @@ func (r incomingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IncomingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// incomingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IncomingUpdateResponseEnvelopeErrors] -type incomingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IncomingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// incomingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IncomingUpdateResponseEnvelopeMessages] -type incomingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IncomingUpdateResponseEnvelopeSuccess bool @@ -442,12 +351,17 @@ func (r IncomingUpdateResponseEnvelopeSuccess) IsKnown() bool { type IncomingDeleteParams struct { ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r IncomingDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type IncomingDeleteResponseEnvelope struct { - Errors []IncomingDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []IncomingDeleteResponseEnvelopeMessages `json:"messages,required"` - Result IncomingDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IncomingDeleteResponse `json:"result,required"` // Whether the API call was successful Success IncomingDeleteResponseEnvelopeSuccess `json:"success,required"` JSON incomingDeleteResponseEnvelopeJSON `json:"-"` @@ -472,52 +386,6 @@ func (r incomingDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IncomingDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// incomingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IncomingDeleteResponseEnvelopeErrors] -type incomingDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IncomingDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// incomingDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IncomingDeleteResponseEnvelopeMessages] -type incomingDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IncomingDeleteResponseEnvelopeSuccess bool @@ -538,9 +406,9 @@ type IncomingGetParams struct { } type IncomingGetResponseEnvelope struct { - Errors []IncomingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IncomingGetResponseEnvelopeMessages `json:"messages,required"` - Result IncomingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IncomingGetResponse `json:"result,required"` // Whether the API call was successful Success IncomingGetResponseEnvelopeSuccess `json:"success,required"` JSON incomingGetResponseEnvelopeJSON `json:"-"` @@ -565,52 +433,6 @@ func (r incomingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IncomingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// incomingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IncomingGetResponseEnvelopeErrors] -type incomingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IncomingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON incomingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// incomingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IncomingGetResponseEnvelopeMessages] -type incomingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IncomingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r incomingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IncomingGetResponseEnvelopeSuccess bool diff --git a/secondary_dns/incoming_test.go b/secondary_dns/incoming_test.go index 589d132d81c..14759a57c91 100644 --- a/secondary_dns/incoming_test.go +++ b/secondary_dns/incoming_test.go @@ -88,6 +88,7 @@ func TestIncomingDelete(t *testing.T) { ) _, err := client.SecondaryDNS.Incoming.Delete(context.TODO(), secondary_dns.IncomingDeleteParams{ ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/secondary_dns/outgoing.go b/secondary_dns/outgoing.go index 4ba2a60e052..8c8857b2789 100644 --- a/secondary_dns/outgoing.go +++ b/secondary_dns/outgoing.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -59,10 +60,10 @@ func (r *OutgoingService) Update(ctx context.Context, params OutgoingUpdateParam } // Delete primary zone configuration for outgoing zone transfers. -func (r *OutgoingService) Delete(ctx context.Context, body OutgoingDeleteParams, opts ...option.RequestOption) (res *OutgoingDeleteResponse, err error) { +func (r *OutgoingService) Delete(ctx context.Context, params OutgoingDeleteParams, opts ...option.RequestOption) (res *OutgoingDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env OutgoingDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/secondary_dns/outgoing", body.ZoneID) + path := fmt.Sprintf("zones/%s/secondary_dns/outgoing", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -73,10 +74,10 @@ func (r *OutgoingService) Delete(ctx context.Context, body OutgoingDeleteParams, // Disable outgoing zone transfers for primary zone and clears IXFR backlog of // primary zone. -func (r *OutgoingService) Disable(ctx context.Context, body OutgoingDisableParams, opts ...option.RequestOption) (res *SecondaryDNSDisableTransfer, err error) { +func (r *OutgoingService) Disable(ctx context.Context, params OutgoingDisableParams, opts ...option.RequestOption) (res *DisableTransfer, err error) { opts = append(r.Options[:], opts...) var env OutgoingDisableResponseEnvelope - path := fmt.Sprintf("zones/%s/secondary_dns/outgoing/disable", body.ZoneID) + path := fmt.Sprintf("zones/%s/secondary_dns/outgoing/disable", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -86,10 +87,10 @@ func (r *OutgoingService) Disable(ctx context.Context, body OutgoingDisableParam } // Enable outgoing zone transfers for primary zone. -func (r *OutgoingService) Enable(ctx context.Context, body OutgoingEnableParams, opts ...option.RequestOption) (res *SecondaryDNSEnableTransfer, err error) { +func (r *OutgoingService) Enable(ctx context.Context, params OutgoingEnableParams, opts ...option.RequestOption) (res *EnableTransfer, err error) { opts = append(r.Options[:], opts...) var env OutgoingEnableResponseEnvelope - path := fmt.Sprintf("zones/%s/secondary_dns/outgoing/enable", body.ZoneID) + path := fmt.Sprintf("zones/%s/secondary_dns/outgoing/enable", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -99,10 +100,10 @@ func (r *OutgoingService) Enable(ctx context.Context, body OutgoingEnableParams, } // Notifies the secondary nameserver(s) and clears IXFR backlog of primary zone. -func (r *OutgoingService) ForceNotify(ctx context.Context, body OutgoingForceNotifyParams, opts ...option.RequestOption) (res *string, err error) { +func (r *OutgoingService) ForceNotify(ctx context.Context, params OutgoingForceNotifyParams, opts ...option.RequestOption) (res *string, err error) { opts = append(r.Options[:], opts...) var env OutgoingForceNotifyResponseEnvelope - path := fmt.Sprintf("zones/%s/secondary_dns/outgoing/force_notify", body.ZoneID) + path := fmt.Sprintf("zones/%s/secondary_dns/outgoing/force_notify", params.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -124,9 +125,9 @@ func (r *OutgoingService) Get(ctx context.Context, query OutgoingGetParams, opts return } -type SecondaryDNSDisableTransfer = string +type DisableTransfer = string -type SecondaryDNSEnableTransfer = string +type EnableTransfer = string type OutgoingNewResponse struct { ID string `json:"id"` @@ -279,9 +280,9 @@ func (r OutgoingNewParams) MarshalJSON() (data []byte, err error) { } type OutgoingNewResponseEnvelope struct { - Errors []OutgoingNewResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingNewResponseEnvelopeMessages `json:"messages,required"` - Result OutgoingNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OutgoingNewResponse `json:"result,required"` // Whether the API call was successful Success OutgoingNewResponseEnvelopeSuccess `json:"success,required"` JSON outgoingNewResponseEnvelopeJSON `json:"-"` @@ -306,52 +307,6 @@ func (r outgoingNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [OutgoingNewResponseEnvelopeErrors] -type outgoingNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OutgoingNewResponseEnvelopeMessages] -type outgoingNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingNewResponseEnvelopeSuccess bool @@ -380,9 +335,9 @@ func (r OutgoingUpdateParams) MarshalJSON() (data []byte, err error) { } type OutgoingUpdateResponseEnvelope struct { - Errors []OutgoingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result OutgoingUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OutgoingUpdateResponse `json:"result,required"` // Whether the API call was successful Success OutgoingUpdateResponseEnvelopeSuccess `json:"success,required"` JSON outgoingUpdateResponseEnvelopeJSON `json:"-"` @@ -407,52 +362,6 @@ func (r outgoingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OutgoingUpdateResponseEnvelopeErrors] -type outgoingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OutgoingUpdateResponseEnvelopeMessages] -type outgoingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingUpdateResponseEnvelopeSuccess bool @@ -470,12 +379,17 @@ func (r OutgoingUpdateResponseEnvelopeSuccess) IsKnown() bool { type OutgoingDeleteParams struct { ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r OutgoingDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type OutgoingDeleteResponseEnvelope struct { - Errors []OutgoingDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingDeleteResponseEnvelopeMessages `json:"messages,required"` - Result OutgoingDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OutgoingDeleteResponse `json:"result,required"` // Whether the API call was successful Success OutgoingDeleteResponseEnvelopeSuccess `json:"success,required"` JSON outgoingDeleteResponseEnvelopeJSON `json:"-"` @@ -500,52 +414,6 @@ func (r outgoingDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OutgoingDeleteResponseEnvelopeErrors] -type outgoingDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OutgoingDeleteResponseEnvelopeMessages] -type outgoingDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingDeleteResponseEnvelopeSuccess bool @@ -563,13 +431,18 @@ func (r OutgoingDeleteResponseEnvelopeSuccess) IsKnown() bool { type OutgoingDisableParams struct { ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r OutgoingDisableParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type OutgoingDisableResponseEnvelope struct { - Errors []OutgoingDisableResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingDisableResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // The zone transfer status of a primary zone - Result SecondaryDNSDisableTransfer `json:"result,required"` + Result DisableTransfer `json:"result,required"` // Whether the API call was successful Success OutgoingDisableResponseEnvelopeSuccess `json:"success,required"` JSON outgoingDisableResponseEnvelopeJSON `json:"-"` @@ -594,52 +467,6 @@ func (r outgoingDisableResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingDisableResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingDisableResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingDisableResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OutgoingDisableResponseEnvelopeErrors] -type outgoingDisableResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingDisableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingDisableResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingDisableResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingDisableResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingDisableResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OutgoingDisableResponseEnvelopeMessages] -type outgoingDisableResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingDisableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingDisableResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingDisableResponseEnvelopeSuccess bool @@ -657,13 +484,18 @@ func (r OutgoingDisableResponseEnvelopeSuccess) IsKnown() bool { type OutgoingEnableParams struct { ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r OutgoingEnableParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type OutgoingEnableResponseEnvelope struct { - Errors []OutgoingEnableResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingEnableResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // The zone transfer status of a primary zone - Result SecondaryDNSEnableTransfer `json:"result,required"` + Result EnableTransfer `json:"result,required"` // Whether the API call was successful Success OutgoingEnableResponseEnvelopeSuccess `json:"success,required"` JSON outgoingEnableResponseEnvelopeJSON `json:"-"` @@ -688,52 +520,6 @@ func (r outgoingEnableResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingEnableResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingEnableResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingEnableResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OutgoingEnableResponseEnvelopeErrors] -type outgoingEnableResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingEnableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingEnableResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingEnableResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingEnableResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingEnableResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OutgoingEnableResponseEnvelopeMessages] -type outgoingEnableResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingEnableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingEnableResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingEnableResponseEnvelopeSuccess bool @@ -751,11 +537,16 @@ func (r OutgoingEnableResponseEnvelopeSuccess) IsKnown() bool { type OutgoingForceNotifyParams struct { ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r OutgoingForceNotifyParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type OutgoingForceNotifyResponseEnvelope struct { - Errors []OutgoingForceNotifyResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingForceNotifyResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // When force_notify query parameter is set to true, the response is a simple // string Result string `json:"result,required"` @@ -783,52 +574,6 @@ func (r outgoingForceNotifyResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingForceNotifyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingForceNotifyResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingForceNotifyResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OutgoingForceNotifyResponseEnvelopeErrors] -type outgoingForceNotifyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingForceNotifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingForceNotifyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingForceNotifyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingForceNotifyResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingForceNotifyResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [OutgoingForceNotifyResponseEnvelopeMessages] -type outgoingForceNotifyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingForceNotifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingForceNotifyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingForceNotifyResponseEnvelopeSuccess bool @@ -849,9 +594,9 @@ type OutgoingGetParams struct { } type OutgoingGetResponseEnvelope struct { - Errors []OutgoingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingGetResponseEnvelopeMessages `json:"messages,required"` - Result OutgoingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OutgoingGetResponse `json:"result,required"` // Whether the API call was successful Success OutgoingGetResponseEnvelopeSuccess `json:"success,required"` JSON outgoingGetResponseEnvelopeJSON `json:"-"` @@ -876,52 +621,6 @@ func (r outgoingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [OutgoingGetResponseEnvelopeErrors] -type outgoingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OutgoingGetResponseEnvelopeMessages] -type outgoingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingGetResponseEnvelopeSuccess bool diff --git a/secondary_dns/outgoing_test.go b/secondary_dns/outgoing_test.go index 4dd5e1c979d..b8354c90450 100644 --- a/secondary_dns/outgoing_test.go +++ b/secondary_dns/outgoing_test.go @@ -86,6 +86,7 @@ func TestOutgoingDelete(t *testing.T) { ) _, err := client.SecondaryDNS.Outgoing.Delete(context.TODO(), secondary_dns.OutgoingDeleteParams{ ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -112,6 +113,7 @@ func TestOutgoingDisable(t *testing.T) { ) _, err := client.SecondaryDNS.Outgoing.Disable(context.TODO(), secondary_dns.OutgoingDisableParams{ ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -138,6 +140,7 @@ func TestOutgoingEnable(t *testing.T) { ) _, err := client.SecondaryDNS.Outgoing.Enable(context.TODO(), secondary_dns.OutgoingEnableParams{ ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -164,6 +167,7 @@ func TestOutgoingForceNotify(t *testing.T) { ) _, err := client.SecondaryDNS.Outgoing.ForceNotify(context.TODO(), secondary_dns.OutgoingForceNotifyParams{ ZoneID: cloudflare.F("269d8f4853475ca241c4e730be286b20"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/secondary_dns/outgoingstatus.go b/secondary_dns/outgoingstatus.go index 531aa350cba..9325dc10b00 100644 --- a/secondary_dns/outgoingstatus.go +++ b/secondary_dns/outgoingstatus.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewOutgoingStatusService(opts ...option.RequestOption) (r *OutgoingStatusSe } // Get primary zone transfer status. -func (r *OutgoingStatusService) Get(ctx context.Context, query OutgoingStatusGetParams, opts ...option.RequestOption) (res *SecondaryDNSEnableTransfer, err error) { +func (r *OutgoingStatusService) Get(ctx context.Context, query OutgoingStatusGetParams, opts ...option.RequestOption) (res *EnableTransfer, err error) { opts = append(r.Options[:], opts...) var env OutgoingStatusGetResponseEnvelope path := fmt.Sprintf("zones/%s/secondary_dns/outgoing/status", query.ZoneID) @@ -49,10 +50,10 @@ type OutgoingStatusGetParams struct { } type OutgoingStatusGetResponseEnvelope struct { - Errors []OutgoingStatusGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OutgoingStatusGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // The zone transfer status of a primary zone - Result SecondaryDNSEnableTransfer `json:"result,required"` + Result EnableTransfer `json:"result,required"` // Whether the API call was successful Success OutgoingStatusGetResponseEnvelopeSuccess `json:"success,required"` JSON outgoingStatusGetResponseEnvelopeJSON `json:"-"` @@ -77,52 +78,6 @@ func (r outgoingStatusGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OutgoingStatusGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingStatusGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// outgoingStatusGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OutgoingStatusGetResponseEnvelopeErrors] -type outgoingStatusGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingStatusGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingStatusGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OutgoingStatusGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON outgoingStatusGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// outgoingStatusGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OutgoingStatusGetResponseEnvelopeMessages] -type outgoingStatusGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OutgoingStatusGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r outgoingStatusGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OutgoingStatusGetResponseEnvelopeSuccess bool diff --git a/secondary_dns/peer.go b/secondary_dns/peer.go index 8f454f6e5d9..4f17401a1d1 100644 --- a/secondary_dns/peer.go +++ b/secondary_dns/peer.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -32,7 +33,7 @@ func NewPeerService(opts ...option.RequestOption) (r *PeerService) { } // Create Peer. -func (r *PeerService) New(ctx context.Context, params PeerNewParams, opts ...option.RequestOption) (res *SecondaryDNSPeer, err error) { +func (r *PeerService) New(ctx context.Context, params PeerNewParams, opts ...option.RequestOption) (res *Peer, err error) { opts = append(r.Options[:], opts...) var env PeerNewResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/peers", params.AccountID) @@ -45,7 +46,7 @@ func (r *PeerService) New(ctx context.Context, params PeerNewParams, opts ...opt } // Modify Peer. -func (r *PeerService) Update(ctx context.Context, peerID string, params PeerUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSPeer, err error) { +func (r *PeerService) Update(ctx context.Context, peerID string, params PeerUpdateParams, opts ...option.RequestOption) (res *Peer, err error) { opts = append(r.Options[:], opts...) var env PeerUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/peers/%s", params.AccountID, peerID) @@ -58,7 +59,7 @@ func (r *PeerService) Update(ctx context.Context, peerID string, params PeerUpda } // List Peers. -func (r *PeerService) List(ctx context.Context, query PeerListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SecondaryDNSPeer], err error) { +func (r *PeerService) List(ctx context.Context, query PeerListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Peer], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -76,15 +77,15 @@ func (r *PeerService) List(ctx context.Context, query PeerListParams, opts ...op } // List Peers. -func (r *PeerService) ListAutoPaging(ctx context.Context, query PeerListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SecondaryDNSPeer] { +func (r *PeerService) ListAutoPaging(ctx context.Context, query PeerListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Peer] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete Peer. -func (r *PeerService) Delete(ctx context.Context, peerID string, body PeerDeleteParams, opts ...option.RequestOption) (res *PeerDeleteResponse, err error) { +func (r *PeerService) Delete(ctx context.Context, peerID string, params PeerDeleteParams, opts ...option.RequestOption) (res *PeerDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env PeerDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/secondary_dns/peers/%s", body.AccountID, peerID) + path := fmt.Sprintf("accounts/%s/secondary_dns/peers/%s", params.AccountID, peerID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -94,7 +95,7 @@ func (r *PeerService) Delete(ctx context.Context, peerID string, body PeerDelete } // Get Peer. -func (r *PeerService) Get(ctx context.Context, peerID string, query PeerGetParams, opts ...option.RequestOption) (res *SecondaryDNSPeer, err error) { +func (r *PeerService) Get(ctx context.Context, peerID string, query PeerGetParams, opts ...option.RequestOption) (res *Peer, err error) { opts = append(r.Options[:], opts...) var env PeerGetResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/peers/%s", query.AccountID, peerID) @@ -106,7 +107,7 @@ func (r *PeerService) Get(ctx context.Context, peerID string, query PeerGetParam return } -type SecondaryDNSPeer struct { +type Peer struct { ID string `json:"id,required"` // The name of the peer. Name string `json:"name,required"` @@ -123,13 +124,12 @@ type SecondaryDNSPeer struct { // linked to. Port float64 `json:"port"` // TSIG authentication will be used for zone transfer if configured. - TSIGID string `json:"tsig_id"` - JSON secondaryDNSPeerJSON `json:"-"` + TSIGID string `json:"tsig_id"` + JSON peerJSON `json:"-"` } -// secondaryDNSPeerJSON contains the JSON metadata for the struct -// [SecondaryDNSPeer] -type secondaryDNSPeerJSON struct { +// peerJSON contains the JSON metadata for the struct [Peer] +type peerJSON struct { ID apijson.Field Name apijson.Field IP apijson.Field @@ -140,14 +140,37 @@ type secondaryDNSPeerJSON struct { ExtraFields map[string]apijson.Field } -func (r *SecondaryDNSPeer) UnmarshalJSON(data []byte) (err error) { +func (r *Peer) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r secondaryDNSPeerJSON) RawJSON() string { +func (r peerJSON) RawJSON() string { return r.raw } +type PeerParam struct { + // The name of the peer. + Name param.Field[string] `json:"name,required"` + // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone + // this peer is linked to. For primary zones this IP defines the IP of the + // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary + // zones this IP defines the IP of the primary nameserver Cloudflare will send + // AXFR/IXFR requests to. + IP param.Field[string] `json:"ip"` + // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary + // zones. + IxfrEnable param.Field[bool] `json:"ixfr_enable"` + // DNS port of primary or secondary nameserver, depending on what zone this peer is + // linked to. + Port param.Field[float64] `json:"port"` + // TSIG authentication will be used for zone transfer if configured. + TSIGID param.Field[string] `json:"tsig_id"` +} + +func (r PeerParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type PeerDeleteResponse struct { ID string `json:"id"` JSON peerDeleteResponseJSON `json:"-"` @@ -170,8 +193,8 @@ func (r peerDeleteResponseJSON) RawJSON() string { } type PeerNewParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r PeerNewParams) MarshalJSON() (data []byte, err error) { @@ -179,9 +202,9 @@ func (r PeerNewParams) MarshalJSON() (data []byte, err error) { } type PeerNewResponseEnvelope struct { - Errors []PeerNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PeerNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSPeer `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Peer `json:"result,required"` // Whether the API call was successful Success PeerNewResponseEnvelopeSuccess `json:"success,required"` JSON peerNewResponseEnvelopeJSON `json:"-"` @@ -206,52 +229,6 @@ func (r peerNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PeerNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// peerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PeerNewResponseEnvelopeErrors] -type peerNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PeerNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// peerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PeerNewResponseEnvelopeMessages] -type peerNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PeerNewResponseEnvelopeSuccess bool @@ -269,32 +246,17 @@ func (r PeerNewResponseEnvelopeSuccess) IsKnown() bool { type PeerUpdateParams struct { AccountID param.Field[string] `path:"account_id,required"` - // The name of the peer. - Name param.Field[string] `json:"name,required"` - // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone - // this peer is linked to. For primary zones this IP defines the IP of the - // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary - // zones this IP defines the IP of the primary nameserver Cloudflare will send - // AXFR/IXFR requests to. - IP param.Field[string] `json:"ip"` - // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary - // zones. - IxfrEnable param.Field[bool] `json:"ixfr_enable"` - // DNS port of primary or secondary nameserver, depending on what zone this peer is - // linked to. - Port param.Field[float64] `json:"port"` - // TSIG authentication will be used for zone transfer if configured. - TSIGID param.Field[string] `json:"tsig_id"` + Peer PeerParam `json:"peer,required"` } func (r PeerUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Peer) } type PeerUpdateResponseEnvelope struct { - Errors []PeerUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []PeerUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSPeer `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Peer `json:"result,required"` // Whether the API call was successful Success PeerUpdateResponseEnvelopeSuccess `json:"success,required"` JSON peerUpdateResponseEnvelopeJSON `json:"-"` @@ -319,52 +281,6 @@ func (r peerUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PeerUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// peerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PeerUpdateResponseEnvelopeErrors] -type peerUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PeerUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// peerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PeerUpdateResponseEnvelopeMessages] -type peerUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PeerUpdateResponseEnvelopeSuccess bool @@ -386,12 +302,17 @@ type PeerListParams struct { type PeerDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r PeerDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type PeerDeleteResponseEnvelope struct { - Errors []PeerDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []PeerDeleteResponseEnvelopeMessages `json:"messages,required"` - Result PeerDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PeerDeleteResponse `json:"result,required"` // Whether the API call was successful Success PeerDeleteResponseEnvelopeSuccess `json:"success,required"` JSON peerDeleteResponseEnvelopeJSON `json:"-"` @@ -416,52 +337,6 @@ func (r peerDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PeerDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// peerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PeerDeleteResponseEnvelopeErrors] -type peerDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PeerDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// peerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PeerDeleteResponseEnvelopeMessages] -type peerDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PeerDeleteResponseEnvelopeSuccess bool @@ -482,9 +357,9 @@ type PeerGetParams struct { } type PeerGetResponseEnvelope struct { - Errors []PeerGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PeerGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSPeer `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Peer `json:"result,required"` // Whether the API call was successful Success PeerGetResponseEnvelopeSuccess `json:"success,required"` JSON peerGetResponseEnvelopeJSON `json:"-"` @@ -509,52 +384,6 @@ func (r peerGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type PeerGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// peerGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [PeerGetResponseEnvelopeErrors] -type peerGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PeerGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON peerGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// peerGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [PeerGetResponseEnvelopeMessages] -type peerGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PeerGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r peerGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type PeerGetResponseEnvelopeSuccess bool diff --git a/secondary_dns/peer_test.go b/secondary_dns/peer_test.go index 0ac8f69d581..0142a0d7aef 100644 --- a/secondary_dns/peer_test.go +++ b/secondary_dns/peer_test.go @@ -30,7 +30,7 @@ func TestPeerNew(t *testing.T) { ) _, err := client.SecondaryDNS.Peers.New(context.TODO(), secondary_dns.PeerNewParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -59,12 +59,14 @@ func TestPeerUpdateWithOptionalParams(t *testing.T) { context.TODO(), "23ff594956f20c2a721606e94745a8aa", secondary_dns.PeerUpdateParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Name: cloudflare.F("my-peer-1"), - IP: cloudflare.F("192.0.2.53"), - IxfrEnable: cloudflare.F(false), - Port: cloudflare.F(53.000000), - TSIGID: cloudflare.F("69cd1e104af3e6ed3cb344f263fd0d5a"), + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Peer: secondary_dns.PeerParam{ + IP: cloudflare.F("192.0.2.53"), + IxfrEnable: cloudflare.F(false), + Name: cloudflare.F("my-peer-1"), + Port: cloudflare.F(53.000000), + TSIGID: cloudflare.F("69cd1e104af3e6ed3cb344f263fd0d5a"), + }, }, ) if err != nil { @@ -121,6 +123,7 @@ func TestPeerDelete(t *testing.T) { "23ff594956f20c2a721606e94745a8aa", secondary_dns.PeerDeleteParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/secondary_dns/tsig.go b/secondary_dns/tsig.go index bdd588a4163..3ef653747fb 100644 --- a/secondary_dns/tsig.go +++ b/secondary_dns/tsig.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -32,7 +33,7 @@ func NewTSIGService(opts ...option.RequestOption) (r *TSIGService) { } // Create TSIG. -func (r *TSIGService) New(ctx context.Context, params TSIGNewParams, opts ...option.RequestOption) (res *SecondaryDNSTSIG, err error) { +func (r *TSIGService) New(ctx context.Context, params TSIGNewParams, opts ...option.RequestOption) (res *TSIG, err error) { opts = append(r.Options[:], opts...) var env TSIGNewResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/tsigs", params.AccountID) @@ -45,7 +46,7 @@ func (r *TSIGService) New(ctx context.Context, params TSIGNewParams, opts ...opt } // Modify TSIG. -func (r *TSIGService) Update(ctx context.Context, tsigID string, params TSIGUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSTSIG, err error) { +func (r *TSIGService) Update(ctx context.Context, tsigID string, params TSIGUpdateParams, opts ...option.RequestOption) (res *TSIG, err error) { opts = append(r.Options[:], opts...) var env TSIGUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/tsigs/%s", params.AccountID, tsigID) @@ -58,7 +59,7 @@ func (r *TSIGService) Update(ctx context.Context, tsigID string, params TSIGUpda } // List TSIGs. -func (r *TSIGService) List(ctx context.Context, query TSIGListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SecondaryDNSTSIG], err error) { +func (r *TSIGService) List(ctx context.Context, query TSIGListParams, opts ...option.RequestOption) (res *pagination.SinglePage[TSIG], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -76,15 +77,15 @@ func (r *TSIGService) List(ctx context.Context, query TSIGListParams, opts ...op } // List TSIGs. -func (r *TSIGService) ListAutoPaging(ctx context.Context, query TSIGListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SecondaryDNSTSIG] { +func (r *TSIGService) ListAutoPaging(ctx context.Context, query TSIGListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[TSIG] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete TSIG. -func (r *TSIGService) Delete(ctx context.Context, tsigID string, body TSIGDeleteParams, opts ...option.RequestOption) (res *TSIGDeleteResponse, err error) { +func (r *TSIGService) Delete(ctx context.Context, tsigID string, params TSIGDeleteParams, opts ...option.RequestOption) (res *TSIGDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env TSIGDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/secondary_dns/tsigs/%s", body.AccountID, tsigID) + path := fmt.Sprintf("accounts/%s/secondary_dns/tsigs/%s", params.AccountID, tsigID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -94,7 +95,7 @@ func (r *TSIGService) Delete(ctx context.Context, tsigID string, body TSIGDelete } // Get TSIG. -func (r *TSIGService) Get(ctx context.Context, tsigID string, query TSIGGetParams, opts ...option.RequestOption) (res *SecondaryDNSTSIG, err error) { +func (r *TSIGService) Get(ctx context.Context, tsigID string, query TSIGGetParams, opts ...option.RequestOption) (res *TSIG, err error) { opts = append(r.Options[:], opts...) var env TSIGGetResponseEnvelope path := fmt.Sprintf("accounts/%s/secondary_dns/tsigs/%s", query.AccountID, tsigID) @@ -106,20 +107,19 @@ func (r *TSIGService) Get(ctx context.Context, tsigID string, query TSIGGetParam return } -type SecondaryDNSTSIG struct { +type TSIG struct { ID string `json:"id,required"` // TSIG algorithm. Algo string `json:"algo,required"` // TSIG key name. Name string `json:"name,required"` // TSIG secret. - Secret string `json:"secret,required"` - JSON secondaryDnstsigJSON `json:"-"` + Secret string `json:"secret,required"` + JSON tsigJSON `json:"-"` } -// secondaryDnstsigJSON contains the JSON metadata for the struct -// [SecondaryDNSTSIG] -type secondaryDnstsigJSON struct { +// tsigJSON contains the JSON metadata for the struct [TSIG] +type tsigJSON struct { ID apijson.Field Algo apijson.Field Name apijson.Field @@ -128,14 +128,27 @@ type secondaryDnstsigJSON struct { ExtraFields map[string]apijson.Field } -func (r *SecondaryDNSTSIG) UnmarshalJSON(data []byte) (err error) { +func (r *TSIG) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r secondaryDnstsigJSON) RawJSON() string { +func (r tsigJSON) RawJSON() string { return r.raw } +type TSIGParam struct { + // TSIG algorithm. + Algo param.Field[string] `json:"algo,required"` + // TSIG key name. + Name param.Field[string] `json:"name,required"` + // TSIG secret. + Secret param.Field[string] `json:"secret,required"` +} + +func (r TSIGParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type TSIGDeleteResponse struct { ID string `json:"id"` JSON tsigDeleteResponseJSON `json:"-"` @@ -159,22 +172,17 @@ func (r tsigDeleteResponseJSON) RawJSON() string { type TSIGNewParams struct { AccountID param.Field[string] `path:"account_id,required"` - // TSIG algorithm. - Algo param.Field[string] `json:"algo,required"` - // TSIG key name. - Name param.Field[string] `json:"name,required"` - // TSIG secret. - Secret param.Field[string] `json:"secret,required"` + TSIG TSIGParam `json:"tsig,required"` } func (r TSIGNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.TSIG) } type TSIGNewResponseEnvelope struct { - Errors []TSIGNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TSIGNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSTSIG `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TSIG `json:"result,required"` // Whether the API call was successful Success TSIGNewResponseEnvelopeSuccess `json:"success,required"` JSON tsigNewResponseEnvelopeJSON `json:"-"` @@ -199,52 +207,6 @@ func (r tsigNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TSIGNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// tsigNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TSIGNewResponseEnvelopeErrors] -type tsigNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TSIGNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// tsigNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TSIGNewResponseEnvelopeMessages] -type tsigNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TSIGNewResponseEnvelopeSuccess bool @@ -262,22 +224,17 @@ func (r TSIGNewResponseEnvelopeSuccess) IsKnown() bool { type TSIGUpdateParams struct { AccountID param.Field[string] `path:"account_id,required"` - // TSIG algorithm. - Algo param.Field[string] `json:"algo,required"` - // TSIG key name. - Name param.Field[string] `json:"name,required"` - // TSIG secret. - Secret param.Field[string] `json:"secret,required"` + TSIG TSIGParam `json:"tsig,required"` } func (r TSIGUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.TSIG) } type TSIGUpdateResponseEnvelope struct { - Errors []TSIGUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []TSIGUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSTSIG `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TSIG `json:"result,required"` // Whether the API call was successful Success TSIGUpdateResponseEnvelopeSuccess `json:"success,required"` JSON tsigUpdateResponseEnvelopeJSON `json:"-"` @@ -302,52 +259,6 @@ func (r tsigUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TSIGUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// tsigUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TSIGUpdateResponseEnvelopeErrors] -type tsigUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TSIGUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// tsigUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TSIGUpdateResponseEnvelopeMessages] -type tsigUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TSIGUpdateResponseEnvelopeSuccess bool @@ -369,12 +280,17 @@ type TSIGListParams struct { type TSIGDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r TSIGDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type TSIGDeleteResponseEnvelope struct { - Errors []TSIGDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []TSIGDeleteResponseEnvelopeMessages `json:"messages,required"` - Result TSIGDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TSIGDeleteResponse `json:"result,required"` // Whether the API call was successful Success TSIGDeleteResponseEnvelopeSuccess `json:"success,required"` JSON tsigDeleteResponseEnvelopeJSON `json:"-"` @@ -399,52 +315,6 @@ func (r tsigDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TSIGDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// tsigDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TSIGDeleteResponseEnvelopeErrors] -type tsigDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TSIGDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// tsigDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TSIGDeleteResponseEnvelopeMessages] -type tsigDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TSIGDeleteResponseEnvelopeSuccess bool @@ -465,9 +335,9 @@ type TSIGGetParams struct { } type TSIGGetResponseEnvelope struct { - Errors []TSIGGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TSIGGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSTSIG `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TSIG `json:"result,required"` // Whether the API call was successful Success TSIGGetResponseEnvelopeSuccess `json:"success,required"` JSON tsigGetResponseEnvelopeJSON `json:"-"` @@ -492,52 +362,6 @@ func (r tsigGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TSIGGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tsigGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TSIGGetResponseEnvelopeErrors] -type tsigGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TSIGGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tsigGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tsigGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TSIGGetResponseEnvelopeMessages] -type tsigGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TSIGGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tsigGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TSIGGetResponseEnvelopeSuccess bool diff --git a/secondary_dns/tsig_test.go b/secondary_dns/tsig_test.go index dbfd256b427..a3777afb610 100644 --- a/secondary_dns/tsig_test.go +++ b/secondary_dns/tsig_test.go @@ -30,9 +30,11 @@ func TestTSIGNew(t *testing.T) { ) _, err := client.SecondaryDNS.TSIGs.New(context.TODO(), secondary_dns.TSIGNewParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Algo: cloudflare.F("hmac-sha512."), - Name: cloudflare.F("tsig.customer.cf."), - Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), + TSIG: secondary_dns.TSIGParam{ + Algo: cloudflare.F("hmac-sha512."), + Name: cloudflare.F("tsig.customer.cf."), + Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), + }, }) if err != nil { var apierr *cloudflare.Error @@ -62,9 +64,11 @@ func TestTSIGUpdate(t *testing.T) { "69cd1e104af3e6ed3cb344f263fd0d5a", secondary_dns.TSIGUpdateParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Algo: cloudflare.F("hmac-sha512."), - Name: cloudflare.F("tsig.customer.cf."), - Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), + TSIG: secondary_dns.TSIGParam{ + Algo: cloudflare.F("hmac-sha512."), + Name: cloudflare.F("tsig.customer.cf."), + Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), + }, }, ) if err != nil { @@ -121,6 +125,7 @@ func TestTSIGDelete(t *testing.T) { "69cd1e104af3e6ed3cb344f263fd0d5a", secondary_dns.TSIGDeleteParams{ AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/snippets/aliases.go b/snippets/aliases.go index e0864f319a5..2305284a708 100644 --- a/snippets/aliases.go +++ b/snippets/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/snippets/rule.go b/snippets/rule.go index c0186fa162b..49334ec5b96 100644 --- a/snippets/rule.go +++ b/snippets/rule.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -145,8 +146,8 @@ func (r RuleUpdateParamsRule) MarshalJSON() (data []byte, err error) { } type RuleUpdateResponseEnvelope struct { - Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // List of snippet rules Result []RuleUpdateResponse `json:"result,required"` // Whether the API call was successful @@ -173,52 +174,6 @@ func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeErrors] -type ruleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeMessages] -type ruleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleUpdateResponseEnvelopeSuccess bool diff --git a/snippets/snippet.go b/snippets/snippet.go index 7ab723e633e..42096a61468 100644 --- a/snippets/snippet.go +++ b/snippets/snippet.go @@ -75,7 +75,7 @@ func (r *SnippetService) ListAutoPaging(ctx context.Context, zoneIdentifier stri } // Delete Snippet -func (r *SnippetService) Delete(ctx context.Context, zoneIdentifier string, snippetName string, opts ...option.RequestOption) (res *SnippetDeleteResponse, err error) { +func (r *SnippetService) Delete(ctx context.Context, zoneIdentifier string, snippetName string, opts ...option.RequestOption) (res *SnippetDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SnippetDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/snippets/%s", zoneIdentifier, snippetName) @@ -130,13 +130,13 @@ func (r snippetJSON) RawJSON() string { // Union satisfied by [snippets.SnippetDeleteResponseUnknown], // [snippets.SnippetDeleteResponseArray] or [shared.UnionString]. -type SnippetDeleteResponse interface { - ImplementsSnippetsSnippetDeleteResponse() +type SnippetDeleteResponseUnion interface { + ImplementsSnippetsSnippetDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SnippetDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*SnippetDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -151,7 +151,7 @@ func init() { type SnippetDeleteResponseArray []interface{} -func (r SnippetDeleteResponseArray) ImplementsSnippetsSnippetDeleteResponse() {} +func (r SnippetDeleteResponseArray) ImplementsSnippetsSnippetDeleteResponseUnion() {} type SnippetUpdateParams struct { // Content files of uploaded snippet @@ -173,8 +173,8 @@ func (r SnippetUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { } type SnippetUpdateResponseEnvelope struct { - Errors []SnippetUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SnippetUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Snippet Information Result Snippet `json:"result,required"` // Whether the API call was successful @@ -201,52 +201,6 @@ func (r snippetUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SnippetUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// snippetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SnippetUpdateResponseEnvelopeErrors] -type snippetUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SnippetUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// snippetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SnippetUpdateResponseEnvelopeMessages] -type snippetUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SnippetUpdateResponseEnvelopeSuccess bool @@ -263,9 +217,9 @@ func (r SnippetUpdateResponseEnvelopeSuccess) IsKnown() bool { } type SnippetDeleteResponseEnvelope struct { - Errors []SnippetDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SnippetDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SnippetDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SnippetDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success SnippetDeleteResponseEnvelopeSuccess `json:"success,required"` JSON snippetDeleteResponseEnvelopeJSON `json:"-"` @@ -290,52 +244,6 @@ func (r snippetDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SnippetDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// snippetDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SnippetDeleteResponseEnvelopeErrors] -type snippetDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SnippetDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// snippetDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SnippetDeleteResponseEnvelopeMessages] -type snippetDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SnippetDeleteResponseEnvelopeSuccess bool @@ -352,8 +260,8 @@ func (r SnippetDeleteResponseEnvelopeSuccess) IsKnown() bool { } type SnippetGetResponseEnvelope struct { - Errors []SnippetGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SnippetGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Snippet Information Result Snippet `json:"result,required"` // Whether the API call was successful @@ -380,52 +288,6 @@ func (r snippetGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SnippetGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// snippetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SnippetGetResponseEnvelopeErrors] -type snippetGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SnippetGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// snippetGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SnippetGetResponseEnvelopeMessages] -type snippetGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SnippetGetResponseEnvelopeSuccess bool diff --git a/spectrum/aliases.go b/spectrum/aliases.go index d8355ecef04..ed69da0b0de 100644 --- a/spectrum/aliases.go +++ b/spectrum/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/spectrum/analyticsaggregatecurrent.go b/spectrum/analyticsaggregatecurrent.go index b53ef56c306..6672c89eb34 100644 --- a/spectrum/analyticsaggregatecurrent.go +++ b/spectrum/analyticsaggregatecurrent.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -64,15 +65,15 @@ type AnalyticsAggregateCurrentGetParams struct { // `url.Values`. func (r AnalyticsAggregateCurrentGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type AnalyticsAggregateCurrentGetResponseEnvelope struct { - Errors []AnalyticsAggregateCurrentGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyticsAggregateCurrentGetResponseEnvelopeMessages `json:"messages,required"` - Result []AnalyticsAggregateCurrentGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []AnalyticsAggregateCurrentGetResponse `json:"result,required"` // Whether the API call was successful Success AnalyticsAggregateCurrentGetResponseEnvelopeSuccess `json:"success,required"` JSON analyticsAggregateCurrentGetResponseEnvelopeJSON `json:"-"` @@ -97,52 +98,6 @@ func (r analyticsAggregateCurrentGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyticsAggregateCurrentGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AnalyticsAggregateCurrentGetResponseEnvelopeErrors] -type analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsAggregateCurrentGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyticsAggregateCurrentGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AnalyticsAggregateCurrentGetResponseEnvelopeMessages] -type analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsAggregateCurrentGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyticsAggregateCurrentGetResponseEnvelopeSuccess bool diff --git a/spectrum/analyticsevent.go b/spectrum/analyticsevent.go index d9f60ba80e4..e4b2be94c2e 100644 --- a/spectrum/analyticsevent.go +++ b/spectrum/analyticsevent.go @@ -27,3 +27,20 @@ func NewAnalyticsEventService(opts ...option.RequestOption) (r *AnalyticsEventSe r.Summaries = NewAnalyticsEventSummaryService(opts...) return } + +type Dimension string + +const ( + DimensionEvent Dimension = "event" + DimensionAppID Dimension = "appID" + DimensionColoName Dimension = "coloName" + DimensionIPVersion Dimension = "ipVersion" +) + +func (r Dimension) IsKnown() bool { + switch r { + case DimensionEvent, DimensionAppID, DimensionColoName, DimensionIPVersion: + return true + } + return false +} diff --git a/spectrum/analyticseventbytime.go b/spectrum/analyticseventbytime.go index ca8fa9acb65..4edef0db69c 100644 --- a/spectrum/analyticseventbytime.go +++ b/spectrum/analyticseventbytime.go @@ -38,7 +38,7 @@ func NewAnalyticsEventBytimeService(opts ...option.RequestOption) (r *AnalyticsE } // Retrieves a list of aggregate metrics grouped by time interval. -func (r *AnalyticsEventBytimeService) Get(ctx context.Context, zone string, query AnalyticsEventBytimeGetParams, opts ...option.RequestOption) (res *AnalyticsEventBytimeGetResponse, err error) { +func (r *AnalyticsEventBytimeService) Get(ctx context.Context, zone string, query AnalyticsEventBytimeGetParams, opts ...option.RequestOption) (res *AnalyticsEventBytimeGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AnalyticsEventBytimeGetResponseEnvelope path := fmt.Sprintf("zones/%s/spectrum/analytics/events/bytime", zone) @@ -52,13 +52,13 @@ func (r *AnalyticsEventBytimeService) Get(ctx context.Context, zone string, quer // Union satisfied by [spectrum.AnalyticsEventBytimeGetResponseUnknown] or // [shared.UnionString]. -type AnalyticsEventBytimeGetResponse interface { - ImplementsSpectrumAnalyticsEventBytimeGetResponse() +type AnalyticsEventBytimeGetResponseUnion interface { + ImplementsSpectrumAnalyticsEventBytimeGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AnalyticsEventBytimeGetResponse)(nil)).Elem(), + reflect.TypeOf((*AnalyticsEventBytimeGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -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[[]AnalyticsEventBytimeGetParamsDimension] `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. @@ -122,28 +122,11 @@ type AnalyticsEventBytimeGetParams struct { // `url.Values`. func (r AnalyticsEventBytimeGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type AnalyticsEventBytimeGetParamsDimension string - -const ( - AnalyticsEventBytimeGetParamsDimensionEvent AnalyticsEventBytimeGetParamsDimension = "event" - AnalyticsEventBytimeGetParamsDimensionAppID AnalyticsEventBytimeGetParamsDimension = "appID" - AnalyticsEventBytimeGetParamsDimensionColoName AnalyticsEventBytimeGetParamsDimension = "coloName" - AnalyticsEventBytimeGetParamsDimensionIPVersion AnalyticsEventBytimeGetParamsDimension = "ipVersion" -) - -func (r AnalyticsEventBytimeGetParamsDimension) IsKnown() bool { - switch r { - case AnalyticsEventBytimeGetParamsDimensionEvent, AnalyticsEventBytimeGetParamsDimensionAppID, AnalyticsEventBytimeGetParamsDimensionColoName, AnalyticsEventBytimeGetParamsDimensionIPVersion: - return true - } - return false -} - type AnalyticsEventBytimeGetParamsMetric string const ( @@ -187,9 +170,9 @@ func (r AnalyticsEventBytimeGetParamsTimeDelta) IsKnown() bool { } type AnalyticsEventBytimeGetResponseEnvelope struct { - Errors []AnalyticsEventBytimeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyticsEventBytimeGetResponseEnvelopeMessages `json:"messages,required"` - Result AnalyticsEventBytimeGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AnalyticsEventBytimeGetResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AnalyticsEventBytimeGetResponseEnvelopeSuccess `json:"success,required"` JSON analyticsEventBytimeGetResponseEnvelopeJSON `json:"-"` @@ -214,52 +197,6 @@ func (r analyticsEventBytimeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyticsEventBytimeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsEventBytimeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyticsEventBytimeGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AnalyticsEventBytimeGetResponseEnvelopeErrors] -type analyticsEventBytimeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsEventBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsEventBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyticsEventBytimeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsEventBytimeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyticsEventBytimeGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AnalyticsEventBytimeGetResponseEnvelopeMessages] -type analyticsEventBytimeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsEventBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsEventBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyticsEventBytimeGetResponseEnvelopeSuccess bool diff --git a/spectrum/analyticseventbytime_test.go b/spectrum/analyticseventbytime_test.go index e2064ba016c..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.AnalyticsEventBytimeGetParamsDimension{spectrum.AnalyticsEventBytimeGetParamsDimensionEvent, spectrum.AnalyticsEventBytimeGetParamsDimensionAppID}), + 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 eba2d46bb09..ce125d821a5 100644 --- a/spectrum/analyticseventsummary.go +++ b/spectrum/analyticseventsummary.go @@ -38,7 +38,7 @@ func NewAnalyticsEventSummaryService(opts ...option.RequestOption) (r *Analytics } // Retrieves a list of summarised aggregate metrics over a given time period. -func (r *AnalyticsEventSummaryService) Get(ctx context.Context, zone string, query AnalyticsEventSummaryGetParams, opts ...option.RequestOption) (res *AnalyticsEventSummaryGetResponse, err error) { +func (r *AnalyticsEventSummaryService) Get(ctx context.Context, zone string, query AnalyticsEventSummaryGetParams, opts ...option.RequestOption) (res *AnalyticsEventSummaryGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AnalyticsEventSummaryGetResponseEnvelope path := fmt.Sprintf("zones/%s/spectrum/analytics/events/summary", zone) @@ -52,13 +52,13 @@ func (r *AnalyticsEventSummaryService) Get(ctx context.Context, zone string, que // Union satisfied by [spectrum.AnalyticsEventSummaryGetResponseUnknown] or // [shared.UnionString]. -type AnalyticsEventSummaryGetResponse interface { - ImplementsSpectrumAnalyticsEventSummaryGetResponse() +type AnalyticsEventSummaryGetResponseUnion interface { + ImplementsSpectrumAnalyticsEventSummaryGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AnalyticsEventSummaryGetResponse)(nil)).Elem(), + reflect.TypeOf((*AnalyticsEventSummaryGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -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[[]AnalyticsEventSummaryGetParamsDimension] `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. @@ -120,28 +120,11 @@ type AnalyticsEventSummaryGetParams struct { // `url.Values`. func (r AnalyticsEventSummaryGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -type AnalyticsEventSummaryGetParamsDimension string - -const ( - AnalyticsEventSummaryGetParamsDimensionEvent AnalyticsEventSummaryGetParamsDimension = "event" - AnalyticsEventSummaryGetParamsDimensionAppID AnalyticsEventSummaryGetParamsDimension = "appID" - AnalyticsEventSummaryGetParamsDimensionColoName AnalyticsEventSummaryGetParamsDimension = "coloName" - AnalyticsEventSummaryGetParamsDimensionIPVersion AnalyticsEventSummaryGetParamsDimension = "ipVersion" -) - -func (r AnalyticsEventSummaryGetParamsDimension) IsKnown() bool { - switch r { - case AnalyticsEventSummaryGetParamsDimensionEvent, AnalyticsEventSummaryGetParamsDimensionAppID, AnalyticsEventSummaryGetParamsDimensionColoName, AnalyticsEventSummaryGetParamsDimensionIPVersion: - return true - } - return false -} - type AnalyticsEventSummaryGetParamsMetric string const ( @@ -163,9 +146,9 @@ func (r AnalyticsEventSummaryGetParamsMetric) IsKnown() bool { } type AnalyticsEventSummaryGetResponseEnvelope struct { - Errors []AnalyticsEventSummaryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyticsEventSummaryGetResponseEnvelopeMessages `json:"messages,required"` - Result AnalyticsEventSummaryGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AnalyticsEventSummaryGetResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success AnalyticsEventSummaryGetResponseEnvelopeSuccess `json:"success,required"` JSON analyticsEventSummaryGetResponseEnvelopeJSON `json:"-"` @@ -190,52 +173,6 @@ func (r analyticsEventSummaryGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyticsEventSummaryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsEventSummaryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyticsEventSummaryGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AnalyticsEventSummaryGetResponseEnvelopeErrors] -type analyticsEventSummaryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsEventSummaryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsEventSummaryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyticsEventSummaryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsEventSummaryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyticsEventSummaryGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AnalyticsEventSummaryGetResponseEnvelopeMessages] -type analyticsEventSummaryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsEventSummaryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsEventSummaryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyticsEventSummaryGetResponseEnvelopeSuccess bool diff --git a/spectrum/analyticseventsummary_test.go b/spectrum/analyticseventsummary_test.go index a0371c6d0a1..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.AnalyticsEventSummaryGetParamsDimension{spectrum.AnalyticsEventSummaryGetParamsDimensionEvent, spectrum.AnalyticsEventSummaryGetParamsDimensionAppID}), + 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/spectrum/app.go b/spectrum/app.go index 34734a4aab6..7bc29137044 100644 --- a/spectrum/app.go +++ b/spectrum/app.go @@ -89,7 +89,7 @@ func (r *AppService) ListAutoPaging(ctx context.Context, zone string, query AppL } // Deletes a previously existing application. -func (r *AppService) Delete(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *AppDeleteResponse, err error) { +func (r *AppService) Delete(ctx context.Context, zone string, appID string, body AppDeleteParams, opts ...option.RequestOption) (res *AppDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env AppDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) @@ -102,7 +102,7 @@ func (r *AppService) Delete(ctx context.Context, zone string, appID string, opts } // Gets the application configuration of a specific application inside a zone. -func (r *AppService) Get(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *AppGetResponse, err error) { +func (r *AppService) Get(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *AppGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AppGetResponseEnvelope path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) @@ -123,22 +123,22 @@ type AppNewResponse struct { // When the Application was created. CreatedOn time.Time `json:"created_on" format:"date-time"` // The name and type of DNS record for the Spectrum application. - DNS AppNewResponseDNS `json:"dns"` + DNS DNS `json:"dns"` // The anycast edge IP configuration for the hostname of this application. - EdgeIPs AppNewResponseEdgeIPs `json:"edge_ips"` + EdgeIPs EdgeIPs `json:"edge_ips"` // Enables IP Access Rules for this application. Notes: Only available for TCP // applications. IPFirewall bool `json:"ip_firewall"` // When the Application was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // The name and type of DNS record for the Spectrum application. - OriginDNS AppNewResponseOriginDNS `json:"origin_dns"` + OriginDNS OriginDNS `json:"origin_dns"` // The destination port at the origin. Only specified in conjunction with // origin_dns. May use an integer to specify a single origin port, for example // `1000`, or a string to specify a range of origin ports, for example // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the // range must match the number of ports specified in the "protocol" field. - OriginPort AppNewResponseOriginPort `json:"origin_port"` + OriginPort OriginPortUnion `json:"origin_port"` // The port configuration at Cloudflare’s edge. May specify a single port, for // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. Protocol string `json:"protocol"` @@ -185,256 +185,6 @@ func (r appNewResponseJSON) RawJSON() string { return r.raw } -// The name and type of DNS record for the Spectrum application. -type AppNewResponseDNS struct { - // The name of the DNS record associated with the application. - Name string `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type AppNewResponseDNSType `json:"type"` - JSON appNewResponseDNSJSON `json:"-"` -} - -// appNewResponseDNSJSON contains the JSON metadata for the struct -// [AppNewResponseDNS] -type appNewResponseDNSJSON struct { - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppNewResponseDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appNewResponseDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the application. -type AppNewResponseDNSType string - -const ( - AppNewResponseDNSTypeCNAME AppNewResponseDNSType = "CNAME" - AppNewResponseDNSTypeAddress AppNewResponseDNSType = "ADDRESS" -) - -func (r AppNewResponseDNSType) IsKnown() bool { - switch r { - case AppNewResponseDNSTypeCNAME, AppNewResponseDNSTypeAddress: - return true - } - return false -} - -// The anycast edge IP configuration for the hostname of this application. -// -// Union satisfied by [spectrum.AppNewResponseEdgeIPsEyeballIPs] or -// [spectrum.AppNewResponseEdgeIPsCustomerOwnedIPs]. -type AppNewResponseEdgeIPs interface { - implementsSpectrumAppNewResponseEdgeIPs() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AppNewResponseEdgeIPs)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AppNewResponseEdgeIPsEyeballIPs{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AppNewResponseEdgeIPsCustomerOwnedIPs{}), - }, - ) -} - -type AppNewResponseEdgeIPsEyeballIPs struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity AppNewResponseEdgeIPsEyeballIPsConnectivity `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type AppNewResponseEdgeIPsEyeballIPsType `json:"type"` - JSON appNewResponseEdgeIPsEyeballIPsJSON `json:"-"` -} - -// appNewResponseEdgeIPsEyeballIPsJSON contains the JSON metadata for the struct -// [AppNewResponseEdgeIPsEyeballIPs] -type appNewResponseEdgeIPsEyeballIPsJSON struct { - Connectivity apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppNewResponseEdgeIPsEyeballIPs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appNewResponseEdgeIPsEyeballIPsJSON) RawJSON() string { - return r.raw -} - -func (r AppNewResponseEdgeIPsEyeballIPs) implementsSpectrumAppNewResponseEdgeIPs() {} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type AppNewResponseEdgeIPsEyeballIPsConnectivity string - -const ( - AppNewResponseEdgeIPsEyeballIPsConnectivityAll AppNewResponseEdgeIPsEyeballIPsConnectivity = "all" - AppNewResponseEdgeIPsEyeballIPsConnectivityIPV4 AppNewResponseEdgeIPsEyeballIPsConnectivity = "ipv4" - AppNewResponseEdgeIPsEyeballIPsConnectivityIPV6 AppNewResponseEdgeIPsEyeballIPsConnectivity = "ipv6" -) - -func (r AppNewResponseEdgeIPsEyeballIPsConnectivity) IsKnown() bool { - switch r { - case AppNewResponseEdgeIPsEyeballIPsConnectivityAll, AppNewResponseEdgeIPsEyeballIPsConnectivityIPV4, AppNewResponseEdgeIPsEyeballIPsConnectivityIPV6: - return true - } - return false -} - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type AppNewResponseEdgeIPsEyeballIPsType string - -const ( - AppNewResponseEdgeIPsEyeballIPsTypeDynamic AppNewResponseEdgeIPsEyeballIPsType = "dynamic" -) - -func (r AppNewResponseEdgeIPsEyeballIPsType) IsKnown() bool { - switch r { - case AppNewResponseEdgeIPsEyeballIPsTypeDynamic: - return true - } - return false -} - -type AppNewResponseEdgeIPsCustomerOwnedIPs struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs []string `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type AppNewResponseEdgeIPsCustomerOwnedIPsType `json:"type"` - JSON appNewResponseEdgeIPsCustomerOwnedIPsJSON `json:"-"` -} - -// appNewResponseEdgeIPsCustomerOwnedIPsJSON contains the JSON metadata for the -// struct [AppNewResponseEdgeIPsCustomerOwnedIPs] -type appNewResponseEdgeIPsCustomerOwnedIPsJSON struct { - IPs apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppNewResponseEdgeIPsCustomerOwnedIPs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appNewResponseEdgeIPsCustomerOwnedIPsJSON) RawJSON() string { - return r.raw -} - -func (r AppNewResponseEdgeIPsCustomerOwnedIPs) implementsSpectrumAppNewResponseEdgeIPs() {} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type AppNewResponseEdgeIPsCustomerOwnedIPsType string - -const ( - AppNewResponseEdgeIPsCustomerOwnedIPsTypeStatic AppNewResponseEdgeIPsCustomerOwnedIPsType = "static" -) - -func (r AppNewResponseEdgeIPsCustomerOwnedIPsType) IsKnown() bool { - switch r { - case AppNewResponseEdgeIPsCustomerOwnedIPsTypeStatic: - return true - } - return false -} - -// The name and type of DNS record for the Spectrum application. -type AppNewResponseOriginDNS struct { - // The name of the DNS record associated with the origin. - Name string `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL int64 `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type AppNewResponseOriginDNSType `json:"type"` - JSON appNewResponseOriginDNSJSON `json:"-"` -} - -// appNewResponseOriginDNSJSON contains the JSON metadata for the struct -// [AppNewResponseOriginDNS] -type appNewResponseOriginDNSJSON struct { - Name apijson.Field - TTL apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppNewResponseOriginDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appNewResponseOriginDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type AppNewResponseOriginDNSType string - -const ( - AppNewResponseOriginDNSTypeEmpty AppNewResponseOriginDNSType = "" - AppNewResponseOriginDNSTypeA AppNewResponseOriginDNSType = "A" - AppNewResponseOriginDNSTypeAAAA AppNewResponseOriginDNSType = "AAAA" - AppNewResponseOriginDNSTypeSRV AppNewResponseOriginDNSType = "SRV" -) - -func (r AppNewResponseOriginDNSType) IsKnown() bool { - switch r { - case AppNewResponseOriginDNSTypeEmpty, AppNewResponseOriginDNSTypeA, AppNewResponseOriginDNSTypeAAAA, AppNewResponseOriginDNSTypeSRV: - return true - } - return false -} - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Union satisfied by [shared.UnionInt] or [shared.UnionString]. -type AppNewResponseOriginPort interface { - ImplementsSpectrumAppNewResponseOriginPort() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AppNewResponseOriginPort)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionInt(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - // Enables Proxy Protocol to the origin. Refer to // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple @@ -504,22 +254,22 @@ type AppUpdateResponse struct { // When the Application was created. CreatedOn time.Time `json:"created_on" format:"date-time"` // The name and type of DNS record for the Spectrum application. - DNS AppUpdateResponseDNS `json:"dns"` + DNS DNS `json:"dns"` // The anycast edge IP configuration for the hostname of this application. - EdgeIPs AppUpdateResponseEdgeIPs `json:"edge_ips"` + EdgeIPs EdgeIPs `json:"edge_ips"` // Enables IP Access Rules for this application. Notes: Only available for TCP // applications. IPFirewall bool `json:"ip_firewall"` // When the Application was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // The name and type of DNS record for the Spectrum application. - OriginDNS AppUpdateResponseOriginDNS `json:"origin_dns"` + OriginDNS OriginDNS `json:"origin_dns"` // The destination port at the origin. Only specified in conjunction with // origin_dns. May use an integer to specify a single origin port, for example // `1000`, or a string to specify a range of origin ports, for example // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the // range must match the number of ports specified in the "protocol" field. - OriginPort AppUpdateResponseOriginPort `json:"origin_port"` + OriginPort OriginPortUnion `json:"origin_port"` // The port configuration at Cloudflare’s edge. May specify a single port, for // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. Protocol string `json:"protocol"` @@ -567,256 +317,6 @@ func (r appUpdateResponseJSON) RawJSON() string { return r.raw } -// The name and type of DNS record for the Spectrum application. -type AppUpdateResponseDNS struct { - // The name of the DNS record associated with the application. - Name string `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type AppUpdateResponseDNSType `json:"type"` - JSON appUpdateResponseDNSJSON `json:"-"` -} - -// appUpdateResponseDNSJSON contains the JSON metadata for the struct -// [AppUpdateResponseDNS] -type appUpdateResponseDNSJSON struct { - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppUpdateResponseDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appUpdateResponseDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the application. -type AppUpdateResponseDNSType string - -const ( - AppUpdateResponseDNSTypeCNAME AppUpdateResponseDNSType = "CNAME" - AppUpdateResponseDNSTypeAddress AppUpdateResponseDNSType = "ADDRESS" -) - -func (r AppUpdateResponseDNSType) IsKnown() bool { - switch r { - case AppUpdateResponseDNSTypeCNAME, AppUpdateResponseDNSTypeAddress: - return true - } - return false -} - -// The anycast edge IP configuration for the hostname of this application. -// -// Union satisfied by [spectrum.AppUpdateResponseEdgeIPsEyeballIPs] or -// [spectrum.AppUpdateResponseEdgeIPsCustomerOwnedIPs]. -type AppUpdateResponseEdgeIPs interface { - implementsSpectrumAppUpdateResponseEdgeIPs() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AppUpdateResponseEdgeIPs)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AppUpdateResponseEdgeIPsEyeballIPs{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AppUpdateResponseEdgeIPsCustomerOwnedIPs{}), - }, - ) -} - -type AppUpdateResponseEdgeIPsEyeballIPs struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity AppUpdateResponseEdgeIPsEyeballIPsConnectivity `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type AppUpdateResponseEdgeIPsEyeballIPsType `json:"type"` - JSON appUpdateResponseEdgeIPsEyeballIPsJSON `json:"-"` -} - -// appUpdateResponseEdgeIPsEyeballIPsJSON contains the JSON metadata for the struct -// [AppUpdateResponseEdgeIPsEyeballIPs] -type appUpdateResponseEdgeIPsEyeballIPsJSON struct { - Connectivity apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppUpdateResponseEdgeIPsEyeballIPs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appUpdateResponseEdgeIPsEyeballIPsJSON) RawJSON() string { - return r.raw -} - -func (r AppUpdateResponseEdgeIPsEyeballIPs) implementsSpectrumAppUpdateResponseEdgeIPs() {} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type AppUpdateResponseEdgeIPsEyeballIPsConnectivity string - -const ( - AppUpdateResponseEdgeIPsEyeballIPsConnectivityAll AppUpdateResponseEdgeIPsEyeballIPsConnectivity = "all" - AppUpdateResponseEdgeIPsEyeballIPsConnectivityIPV4 AppUpdateResponseEdgeIPsEyeballIPsConnectivity = "ipv4" - AppUpdateResponseEdgeIPsEyeballIPsConnectivityIPV6 AppUpdateResponseEdgeIPsEyeballIPsConnectivity = "ipv6" -) - -func (r AppUpdateResponseEdgeIPsEyeballIPsConnectivity) IsKnown() bool { - switch r { - case AppUpdateResponseEdgeIPsEyeballIPsConnectivityAll, AppUpdateResponseEdgeIPsEyeballIPsConnectivityIPV4, AppUpdateResponseEdgeIPsEyeballIPsConnectivityIPV6: - return true - } - return false -} - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type AppUpdateResponseEdgeIPsEyeballIPsType string - -const ( - AppUpdateResponseEdgeIPsEyeballIPsTypeDynamic AppUpdateResponseEdgeIPsEyeballIPsType = "dynamic" -) - -func (r AppUpdateResponseEdgeIPsEyeballIPsType) IsKnown() bool { - switch r { - case AppUpdateResponseEdgeIPsEyeballIPsTypeDynamic: - return true - } - return false -} - -type AppUpdateResponseEdgeIPsCustomerOwnedIPs struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs []string `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type AppUpdateResponseEdgeIPsCustomerOwnedIPsType `json:"type"` - JSON appUpdateResponseEdgeIPsCustomerOwnedIPsJSON `json:"-"` -} - -// appUpdateResponseEdgeIPsCustomerOwnedIPsJSON contains the JSON metadata for the -// struct [AppUpdateResponseEdgeIPsCustomerOwnedIPs] -type appUpdateResponseEdgeIPsCustomerOwnedIPsJSON struct { - IPs apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppUpdateResponseEdgeIPsCustomerOwnedIPs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appUpdateResponseEdgeIPsCustomerOwnedIPsJSON) RawJSON() string { - return r.raw -} - -func (r AppUpdateResponseEdgeIPsCustomerOwnedIPs) implementsSpectrumAppUpdateResponseEdgeIPs() {} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type AppUpdateResponseEdgeIPsCustomerOwnedIPsType string - -const ( - AppUpdateResponseEdgeIPsCustomerOwnedIPsTypeStatic AppUpdateResponseEdgeIPsCustomerOwnedIPsType = "static" -) - -func (r AppUpdateResponseEdgeIPsCustomerOwnedIPsType) IsKnown() bool { - switch r { - case AppUpdateResponseEdgeIPsCustomerOwnedIPsTypeStatic: - return true - } - return false -} - -// The name and type of DNS record for the Spectrum application. -type AppUpdateResponseOriginDNS struct { - // The name of the DNS record associated with the origin. - Name string `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL int64 `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type AppUpdateResponseOriginDNSType `json:"type"` - JSON appUpdateResponseOriginDNSJSON `json:"-"` -} - -// appUpdateResponseOriginDNSJSON contains the JSON metadata for the struct -// [AppUpdateResponseOriginDNS] -type appUpdateResponseOriginDNSJSON struct { - Name apijson.Field - TTL apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppUpdateResponseOriginDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appUpdateResponseOriginDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type AppUpdateResponseOriginDNSType string - -const ( - AppUpdateResponseOriginDNSTypeEmpty AppUpdateResponseOriginDNSType = "" - AppUpdateResponseOriginDNSTypeA AppUpdateResponseOriginDNSType = "A" - AppUpdateResponseOriginDNSTypeAAAA AppUpdateResponseOriginDNSType = "AAAA" - AppUpdateResponseOriginDNSTypeSRV AppUpdateResponseOriginDNSType = "SRV" -) - -func (r AppUpdateResponseOriginDNSType) IsKnown() bool { - switch r { - case AppUpdateResponseOriginDNSTypeEmpty, AppUpdateResponseOriginDNSTypeA, AppUpdateResponseOriginDNSTypeAAAA, AppUpdateResponseOriginDNSTypeSRV: - return true - } - return false -} - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Union satisfied by [shared.UnionInt] or [shared.UnionString]. -type AppUpdateResponseOriginPort interface { - ImplementsSpectrumAppUpdateResponseOriginPort() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AppUpdateResponseOriginPort)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionInt(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - // Enables Proxy Protocol to the origin. Refer to // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple @@ -902,13 +402,13 @@ func (r appDeleteResponseJSON) RawJSON() string { } // Union satisfied by [spectrum.AppGetResponseUnknown] or [shared.UnionString]. -type AppGetResponse interface { - ImplementsSpectrumAppGetResponse() +type AppGetResponseUnion interface { + ImplementsSpectrumAppGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AppGetResponse)(nil)).Elem(), + reflect.TypeOf((*AppGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -919,15 +419,15 @@ func init() { type AppNewParams struct { // The name and type of DNS record for the Spectrum application. - DNS param.Field[AppNewParamsDNS] `json:"dns,required"` + DNS param.Field[DNSParam] `json:"dns,required"` // The name and type of DNS record for the Spectrum application. - OriginDNS param.Field[AppNewParamsOriginDNS] `json:"origin_dns,required"` + OriginDNS param.Field[OriginDNSParam] `json:"origin_dns,required"` // The destination port at the origin. Only specified in conjunction with // origin_dns. May use an integer to specify a single origin port, for example // `1000`, or a string to specify a range of origin ports, for example // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the // range must match the number of ports specified in the "protocol" field. - OriginPort param.Field[AppNewParamsOriginPort] `json:"origin_port,required"` + OriginPort param.Field[OriginPortUnionParam] `json:"origin_port,required"` // The port configuration at Cloudflare’s edge. May specify a single port, for // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. Protocol param.Field[string] `json:"protocol,required"` @@ -935,7 +435,7 @@ type AppNewParams struct { // applications with traffic_type set to "direct". ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"` // The anycast edge IP configuration for the hostname of this application. - EdgeIPs param.Field[AppNewParamsEdgeIPs] `json:"edge_ips"` + EdgeIPs param.Field[EdgeIPsUnionParam] `json:"edge_ips"` // Enables IP Access Rules for this application. Notes: Only available for TCP // applications. IPFirewall param.Field[bool] `json:"ip_firewall"` @@ -958,169 +458,6 @@ func (r AppNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The name and type of DNS record for the Spectrum application. -type AppNewParamsDNS struct { - // The name of the DNS record associated with the application. - Name param.Field[string] `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type param.Field[AppNewParamsDNSType] `json:"type"` -} - -func (r AppNewParamsDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the application. -type AppNewParamsDNSType string - -const ( - AppNewParamsDNSTypeCNAME AppNewParamsDNSType = "CNAME" - AppNewParamsDNSTypeAddress AppNewParamsDNSType = "ADDRESS" -) - -func (r AppNewParamsDNSType) IsKnown() bool { - switch r { - case AppNewParamsDNSTypeCNAME, AppNewParamsDNSTypeAddress: - return true - } - return false -} - -// The name and type of DNS record for the Spectrum application. -type AppNewParamsOriginDNS struct { - // The name of the DNS record associated with the origin. - Name param.Field[string] `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL param.Field[int64] `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type param.Field[AppNewParamsOriginDNSType] `json:"type"` -} - -func (r AppNewParamsOriginDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type AppNewParamsOriginDNSType string - -const ( - AppNewParamsOriginDNSTypeEmpty AppNewParamsOriginDNSType = "" - AppNewParamsOriginDNSTypeA AppNewParamsOriginDNSType = "A" - AppNewParamsOriginDNSTypeAAAA AppNewParamsOriginDNSType = "AAAA" - AppNewParamsOriginDNSTypeSRV AppNewParamsOriginDNSType = "SRV" -) - -func (r AppNewParamsOriginDNSType) IsKnown() bool { - switch r { - case AppNewParamsOriginDNSTypeEmpty, AppNewParamsOriginDNSTypeA, AppNewParamsOriginDNSTypeAAAA, AppNewParamsOriginDNSTypeSRV: - return true - } - return false -} - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Satisfied by [shared.UnionInt], [shared.UnionString]. -type AppNewParamsOriginPort interface { - ImplementsSpectrumAppNewParamsOriginPort() -} - -// The anycast edge IP configuration for the hostname of this application. -// -// Satisfied by [spectrum.AppNewParamsEdgeIPsEyeballIPs], -// [spectrum.AppNewParamsEdgeIPsCustomerOwnedIPs]. -type AppNewParamsEdgeIPs interface { - implementsSpectrumAppNewParamsEdgeIPs() -} - -type AppNewParamsEdgeIPsEyeballIPs struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity param.Field[AppNewParamsEdgeIPsEyeballIPsConnectivity] `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type param.Field[AppNewParamsEdgeIPsEyeballIPsType] `json:"type"` -} - -func (r AppNewParamsEdgeIPsEyeballIPs) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AppNewParamsEdgeIPsEyeballIPs) implementsSpectrumAppNewParamsEdgeIPs() {} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type AppNewParamsEdgeIPsEyeballIPsConnectivity string - -const ( - AppNewParamsEdgeIPsEyeballIPsConnectivityAll AppNewParamsEdgeIPsEyeballIPsConnectivity = "all" - AppNewParamsEdgeIPsEyeballIPsConnectivityIPV4 AppNewParamsEdgeIPsEyeballIPsConnectivity = "ipv4" - AppNewParamsEdgeIPsEyeballIPsConnectivityIPV6 AppNewParamsEdgeIPsEyeballIPsConnectivity = "ipv6" -) - -func (r AppNewParamsEdgeIPsEyeballIPsConnectivity) IsKnown() bool { - switch r { - case AppNewParamsEdgeIPsEyeballIPsConnectivityAll, AppNewParamsEdgeIPsEyeballIPsConnectivityIPV4, AppNewParamsEdgeIPsEyeballIPsConnectivityIPV6: - return true - } - return false -} - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type AppNewParamsEdgeIPsEyeballIPsType string - -const ( - AppNewParamsEdgeIPsEyeballIPsTypeDynamic AppNewParamsEdgeIPsEyeballIPsType = "dynamic" -) - -func (r AppNewParamsEdgeIPsEyeballIPsType) IsKnown() bool { - switch r { - case AppNewParamsEdgeIPsEyeballIPsTypeDynamic: - return true - } - return false -} - -type AppNewParamsEdgeIPsCustomerOwnedIPs struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs param.Field[[]string] `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type param.Field[AppNewParamsEdgeIPsCustomerOwnedIPsType] `json:"type"` -} - -func (r AppNewParamsEdgeIPsCustomerOwnedIPs) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AppNewParamsEdgeIPsCustomerOwnedIPs) implementsSpectrumAppNewParamsEdgeIPs() {} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type AppNewParamsEdgeIPsCustomerOwnedIPsType string - -const ( - AppNewParamsEdgeIPsCustomerOwnedIPsTypeStatic AppNewParamsEdgeIPsCustomerOwnedIPsType = "static" -) - -func (r AppNewParamsEdgeIPsCustomerOwnedIPsType) IsKnown() bool { - switch r { - case AppNewParamsEdgeIPsCustomerOwnedIPsTypeStatic: - return true - } - return false -} - // Enables Proxy Protocol to the origin. Refer to // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple @@ -1182,9 +519,9 @@ func (r AppNewParamsTrafficType) IsKnown() bool { } type AppNewResponseEnvelope struct { - Errors []AppNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AppNewResponseEnvelopeMessages `json:"messages,required"` - Result AppNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AppNewResponse `json:"result,required,nullable"` // Whether the API call was successful Success AppNewResponseEnvelopeSuccess `json:"success,required"` JSON appNewResponseEnvelopeJSON `json:"-"` @@ -1209,52 +546,6 @@ func (r appNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AppNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// appNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AppNewResponseEnvelopeErrors] -type appNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AppNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// appNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AppNewResponseEnvelopeMessages] -type appNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AppNewResponseEnvelopeSuccess bool @@ -1272,15 +563,15 @@ func (r AppNewResponseEnvelopeSuccess) IsKnown() bool { type AppUpdateParams struct { // The name and type of DNS record for the Spectrum application. - DNS param.Field[AppUpdateParamsDNS] `json:"dns,required"` + DNS param.Field[DNSParam] `json:"dns,required"` // The name and type of DNS record for the Spectrum application. - OriginDNS param.Field[AppUpdateParamsOriginDNS] `json:"origin_dns,required"` + OriginDNS param.Field[OriginDNSParam] `json:"origin_dns,required"` // The destination port at the origin. Only specified in conjunction with // origin_dns. May use an integer to specify a single origin port, for example // `1000`, or a string to specify a range of origin ports, for example // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the // range must match the number of ports specified in the "protocol" field. - OriginPort param.Field[AppUpdateParamsOriginPort] `json:"origin_port,required"` + OriginPort param.Field[OriginPortUnionParam] `json:"origin_port,required"` // The port configuration at Cloudflare’s edge. May specify a single port, for // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. Protocol param.Field[string] `json:"protocol,required"` @@ -1288,7 +579,7 @@ type AppUpdateParams struct { // applications with traffic_type set to "direct". ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"` // The anycast edge IP configuration for the hostname of this application. - EdgeIPs param.Field[AppUpdateParamsEdgeIPs] `json:"edge_ips"` + EdgeIPs param.Field[EdgeIPsUnionParam] `json:"edge_ips"` // Enables IP Access Rules for this application. Notes: Only available for TCP // applications. IPFirewall param.Field[bool] `json:"ip_firewall"` @@ -1311,169 +602,6 @@ func (r AppUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The name and type of DNS record for the Spectrum application. -type AppUpdateParamsDNS struct { - // The name of the DNS record associated with the application. - Name param.Field[string] `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type param.Field[AppUpdateParamsDNSType] `json:"type"` -} - -func (r AppUpdateParamsDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the application. -type AppUpdateParamsDNSType string - -const ( - AppUpdateParamsDNSTypeCNAME AppUpdateParamsDNSType = "CNAME" - AppUpdateParamsDNSTypeAddress AppUpdateParamsDNSType = "ADDRESS" -) - -func (r AppUpdateParamsDNSType) IsKnown() bool { - switch r { - case AppUpdateParamsDNSTypeCNAME, AppUpdateParamsDNSTypeAddress: - return true - } - return false -} - -// The name and type of DNS record for the Spectrum application. -type AppUpdateParamsOriginDNS struct { - // The name of the DNS record associated with the origin. - Name param.Field[string] `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL param.Field[int64] `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type param.Field[AppUpdateParamsOriginDNSType] `json:"type"` -} - -func (r AppUpdateParamsOriginDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type AppUpdateParamsOriginDNSType string - -const ( - AppUpdateParamsOriginDNSTypeEmpty AppUpdateParamsOriginDNSType = "" - AppUpdateParamsOriginDNSTypeA AppUpdateParamsOriginDNSType = "A" - AppUpdateParamsOriginDNSTypeAAAA AppUpdateParamsOriginDNSType = "AAAA" - AppUpdateParamsOriginDNSTypeSRV AppUpdateParamsOriginDNSType = "SRV" -) - -func (r AppUpdateParamsOriginDNSType) IsKnown() bool { - switch r { - case AppUpdateParamsOriginDNSTypeEmpty, AppUpdateParamsOriginDNSTypeA, AppUpdateParamsOriginDNSTypeAAAA, AppUpdateParamsOriginDNSTypeSRV: - return true - } - return false -} - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Satisfied by [shared.UnionInt], [shared.UnionString]. -type AppUpdateParamsOriginPort interface { - ImplementsSpectrumAppUpdateParamsOriginPort() -} - -// The anycast edge IP configuration for the hostname of this application. -// -// Satisfied by [spectrum.AppUpdateParamsEdgeIPsEyeballIPs], -// [spectrum.AppUpdateParamsEdgeIPsCustomerOwnedIPs]. -type AppUpdateParamsEdgeIPs interface { - implementsSpectrumAppUpdateParamsEdgeIPs() -} - -type AppUpdateParamsEdgeIPsEyeballIPs struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity param.Field[AppUpdateParamsEdgeIPsEyeballIPsConnectivity] `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type param.Field[AppUpdateParamsEdgeIPsEyeballIPsType] `json:"type"` -} - -func (r AppUpdateParamsEdgeIPsEyeballIPs) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AppUpdateParamsEdgeIPsEyeballIPs) implementsSpectrumAppUpdateParamsEdgeIPs() {} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type AppUpdateParamsEdgeIPsEyeballIPsConnectivity string - -const ( - AppUpdateParamsEdgeIPsEyeballIPsConnectivityAll AppUpdateParamsEdgeIPsEyeballIPsConnectivity = "all" - AppUpdateParamsEdgeIPsEyeballIPsConnectivityIPV4 AppUpdateParamsEdgeIPsEyeballIPsConnectivity = "ipv4" - AppUpdateParamsEdgeIPsEyeballIPsConnectivityIPV6 AppUpdateParamsEdgeIPsEyeballIPsConnectivity = "ipv6" -) - -func (r AppUpdateParamsEdgeIPsEyeballIPsConnectivity) IsKnown() bool { - switch r { - case AppUpdateParamsEdgeIPsEyeballIPsConnectivityAll, AppUpdateParamsEdgeIPsEyeballIPsConnectivityIPV4, AppUpdateParamsEdgeIPsEyeballIPsConnectivityIPV6: - return true - } - return false -} - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type AppUpdateParamsEdgeIPsEyeballIPsType string - -const ( - AppUpdateParamsEdgeIPsEyeballIPsTypeDynamic AppUpdateParamsEdgeIPsEyeballIPsType = "dynamic" -) - -func (r AppUpdateParamsEdgeIPsEyeballIPsType) IsKnown() bool { - switch r { - case AppUpdateParamsEdgeIPsEyeballIPsTypeDynamic: - return true - } - return false -} - -type AppUpdateParamsEdgeIPsCustomerOwnedIPs struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs param.Field[[]string] `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type param.Field[AppUpdateParamsEdgeIPsCustomerOwnedIPsType] `json:"type"` -} - -func (r AppUpdateParamsEdgeIPsCustomerOwnedIPs) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AppUpdateParamsEdgeIPsCustomerOwnedIPs) implementsSpectrumAppUpdateParamsEdgeIPs() {} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type AppUpdateParamsEdgeIPsCustomerOwnedIPsType string - -const ( - AppUpdateParamsEdgeIPsCustomerOwnedIPsTypeStatic AppUpdateParamsEdgeIPsCustomerOwnedIPsType = "static" -) - -func (r AppUpdateParamsEdgeIPsCustomerOwnedIPsType) IsKnown() bool { - switch r { - case AppUpdateParamsEdgeIPsCustomerOwnedIPsTypeStatic: - return true - } - return false -} - // Enables Proxy Protocol to the origin. Refer to // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple @@ -1535,9 +663,9 @@ func (r AppUpdateParamsTrafficType) IsKnown() bool { } type AppUpdateResponseEnvelope struct { - Errors []AppUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AppUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AppUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AppUpdateResponse `json:"result,required,nullable"` // Whether the API call was successful Success AppUpdateResponseEnvelopeSuccess `json:"success,required"` JSON appUpdateResponseEnvelopeJSON `json:"-"` @@ -1562,52 +690,6 @@ func (r appUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AppUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// appUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AppUpdateResponseEnvelopeErrors] -type appUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AppUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// appUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AppUpdateResponseEnvelopeMessages] -type appUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AppUpdateResponseEnvelopeSuccess bool @@ -1639,7 +721,7 @@ type AppListParams struct { // URLQuery serializes [AppListParams]'s query parameters as `url.Values`. func (r AppListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1679,10 +761,18 @@ func (r AppListParamsOrder) IsKnown() bool { return false } +type AppDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r AppDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type AppDeleteResponseEnvelope struct { - Errors []AppDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AppDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AppDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AppDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success AppDeleteResponseEnvelopeSuccess `json:"success,required"` JSON appDeleteResponseEnvelopeJSON `json:"-"` @@ -1707,52 +797,6 @@ func (r appDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AppDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// appDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AppDeleteResponseEnvelopeErrors] -type appDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AppDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// appDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AppDeleteResponseEnvelopeMessages] -type appDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AppDeleteResponseEnvelopeSuccess bool @@ -1769,9 +813,9 @@ func (r AppDeleteResponseEnvelopeSuccess) IsKnown() bool { } type AppGetResponseEnvelope struct { - Errors []AppGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AppGetResponseEnvelopeMessages `json:"messages,required"` - Result AppGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AppGetResponseUnion `json:"result,required"` // Whether the API call was successful Success AppGetResponseEnvelopeSuccess `json:"success,required"` JSON appGetResponseEnvelopeJSON `json:"-"` @@ -1796,52 +840,6 @@ func (r appGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AppGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// appGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AppGetResponseEnvelopeErrors] -type appGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AppGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON appGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// appGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AppGetResponseEnvelopeMessages] -type appGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AppGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r appGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AppGetResponseEnvelopeSuccess bool diff --git a/spectrum/app_test.go b/spectrum/app_test.go index 0c620e55bee..ed334b07c38 100644 --- a/spectrum/app_test.go +++ b/spectrum/app_test.go @@ -33,22 +33,22 @@ func TestAppNewWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", spectrum.AppNewParams{ - DNS: cloudflare.F(spectrum.AppNewParamsDNS{ + DNS: cloudflare.F(spectrum.DNSParam{ Name: cloudflare.F("ssh.example.com"), - Type: cloudflare.F(spectrum.AppNewParamsDNSTypeCNAME), + Type: cloudflare.F(spectrum.DNSTypeCNAME), }), - OriginDNS: cloudflare.F(spectrum.AppNewParamsOriginDNS{ + OriginDNS: cloudflare.F(spectrum.OriginDNSParam{ Name: cloudflare.F("origin.example.com"), TTL: cloudflare.F(int64(600)), - Type: cloudflare.F(spectrum.AppNewParamsOriginDNSTypeEmpty), + Type: cloudflare.F(spectrum.OriginDNSTypeEmpty), }), - OriginPort: cloudflare.F[spectrum.AppNewParamsOriginPort](shared.UnionInt(int64(22))), + OriginPort: cloudflare.F[spectrum.OriginPortUnionParam](shared.UnionInt(int64(22))), Protocol: cloudflare.F("tcp/22"), ArgoSmartRouting: cloudflare.F(true), - EdgeIPs: cloudflare.F[spectrum.AppNewParamsEdgeIPs](spectrum.AppNewParamsEdgeIPsEyeballIPs(spectrum.AppNewParamsEdgeIPsEyeballIPs{ - Connectivity: cloudflare.F(spectrum.AppNewParamsEdgeIPsEyeballIPsConnectivityAll), - Type: cloudflare.F(spectrum.AppNewParamsEdgeIPsEyeballIPsTypeDynamic), - })), + EdgeIPs: cloudflare.F[spectrum.EdgeIPsUnionParam](spectrum.EdgeIPsObjectParam{ + Connectivity: cloudflare.F(spectrum.EdgeIPsObjectConnectivityAll), + Type: cloudflare.F(spectrum.EdgeIPsObjectTypeDynamic), + }), IPFirewall: cloudflare.F(true), ProxyProtocol: cloudflare.F(spectrum.AppNewParamsProxyProtocolOff), TLS: cloudflare.F(spectrum.AppNewParamsTLSFull), @@ -83,22 +83,22 @@ func TestAppUpdateWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "ea95132c15732412d22c1476fa83f27a", spectrum.AppUpdateParams{ - DNS: cloudflare.F(spectrum.AppUpdateParamsDNS{ + DNS: cloudflare.F(spectrum.DNSParam{ Name: cloudflare.F("ssh.example.com"), - Type: cloudflare.F(spectrum.AppUpdateParamsDNSTypeCNAME), + Type: cloudflare.F(spectrum.DNSTypeCNAME), }), - OriginDNS: cloudflare.F(spectrum.AppUpdateParamsOriginDNS{ + OriginDNS: cloudflare.F(spectrum.OriginDNSParam{ Name: cloudflare.F("origin.example.com"), TTL: cloudflare.F(int64(600)), - Type: cloudflare.F(spectrum.AppUpdateParamsOriginDNSTypeEmpty), + Type: cloudflare.F(spectrum.OriginDNSTypeEmpty), }), - OriginPort: cloudflare.F[spectrum.AppUpdateParamsOriginPort](shared.UnionInt(int64(22))), + OriginPort: cloudflare.F[spectrum.OriginPortUnionParam](shared.UnionInt(int64(22))), Protocol: cloudflare.F("tcp/22"), ArgoSmartRouting: cloudflare.F(true), - EdgeIPs: cloudflare.F[spectrum.AppUpdateParamsEdgeIPs](spectrum.AppUpdateParamsEdgeIPsEyeballIPs(spectrum.AppUpdateParamsEdgeIPsEyeballIPs{ - Connectivity: cloudflare.F(spectrum.AppUpdateParamsEdgeIPsEyeballIPsConnectivityAll), - Type: cloudflare.F(spectrum.AppUpdateParamsEdgeIPsEyeballIPsTypeDynamic), - })), + EdgeIPs: cloudflare.F[spectrum.EdgeIPsUnionParam](spectrum.EdgeIPsObjectParam{ + Connectivity: cloudflare.F(spectrum.EdgeIPsObjectConnectivityAll), + Type: cloudflare.F(spectrum.EdgeIPsObjectTypeDynamic), + }), IPFirewall: cloudflare.F(true), ProxyProtocol: cloudflare.F(spectrum.AppUpdateParamsProxyProtocolOff), TLS: cloudflare.F(spectrum.AppUpdateParamsTLSFull), @@ -165,6 +165,9 @@ func TestAppDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "ea95132c15732412d22c1476fa83f27a", + spectrum.AppDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/spectrum/spectrum.go b/spectrum/spectrum.go index 7f8b7e217b0..05453385604 100644 --- a/spectrum/spectrum.go +++ b/spectrum/spectrum.go @@ -3,7 +3,13 @@ package spectrum import ( + "reflect" + + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // SpectrumService contains methods and other services that help with interacting @@ -26,3 +32,353 @@ func NewSpectrumService(opts ...option.RequestOption) (r *SpectrumService) { r.Apps = NewAppService(opts...) return } + +// The name and type of DNS record for the Spectrum application. +type DNS struct { + // The name of the DNS record associated with the application. + Name string `json:"name" format:"hostname"` + // The type of DNS record associated with the application. + Type DNSType `json:"type"` + JSON dnsJSON `json:"-"` +} + +// dnsJSON contains the JSON metadata for the struct [DNS] +type dnsJSON struct { + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsJSON) RawJSON() string { + return r.raw +} + +// The type of DNS record associated with the application. +type DNSType string + +const ( + DNSTypeCNAME DNSType = "CNAME" + DNSTypeAddress DNSType = "ADDRESS" +) + +func (r DNSType) IsKnown() bool { + switch r { + case DNSTypeCNAME, DNSTypeAddress: + return true + } + return false +} + +// The name and type of DNS record for the Spectrum application. +type DNSParam struct { + // The name of the DNS record associated with the application. + Name param.Field[string] `json:"name" format:"hostname"` + // The type of DNS record associated with the application. + Type param.Field[DNSType] `json:"type"` +} + +func (r DNSParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The anycast edge IP configuration for the hostname of this application. +type EdgeIPs struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity EdgeIPsConnectivity `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type EdgeIPsType `json:"type"` + IPs interface{} `json:"ips,required"` + JSON edgeIPsJSON `json:"-"` + union EdgeIPsUnion +} + +// edgeIPsJSON contains the JSON metadata for the struct [EdgeIPs] +type edgeIPsJSON struct { + Connectivity apijson.Field + Type apijson.Field + IPs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r edgeIPsJSON) RawJSON() string { + return r.raw +} + +func (r *EdgeIPs) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r EdgeIPs) AsUnion() EdgeIPsUnion { + return r.union +} + +// The anycast edge IP configuration for the hostname of this application. +// +// Union satisfied by [spectrum.EdgeIPsObject] or [spectrum.EdgeIPsObject]. +type EdgeIPsUnion interface { + implementsSpectrumEdgeIPs() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*EdgeIPsUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EdgeIPsObject{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EdgeIPsObject{}), + }, + ) +} + +type EdgeIPsObject struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity EdgeIPsObjectConnectivity `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type EdgeIPsObjectType `json:"type"` + JSON edgeIPsObjectJSON `json:"-"` +} + +// edgeIPsObjectJSON contains the JSON metadata for the struct [EdgeIPsObject] +type edgeIPsObjectJSON struct { + Connectivity apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EdgeIPsObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r edgeIPsObjectJSON) RawJSON() string { + return r.raw +} + +func (r EdgeIPsObject) implementsSpectrumEdgeIPs() {} + +// The IP versions supported for inbound connections on Spectrum anycast IPs. +type EdgeIPsObjectConnectivity string + +const ( + EdgeIPsObjectConnectivityAll EdgeIPsObjectConnectivity = "all" + EdgeIPsObjectConnectivityIPV4 EdgeIPsObjectConnectivity = "ipv4" + EdgeIPsObjectConnectivityIPV6 EdgeIPsObjectConnectivity = "ipv6" +) + +func (r EdgeIPsObjectConnectivity) IsKnown() bool { + switch r { + case EdgeIPsObjectConnectivityAll, EdgeIPsObjectConnectivityIPV4, EdgeIPsObjectConnectivityIPV6: + return true + } + return false +} + +// The type of edge IP configuration specified. Dynamically allocated edge IPs use +// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid +// with CNAME DNS names. +type EdgeIPsObjectType string + +const ( + EdgeIPsObjectTypeDynamic EdgeIPsObjectType = "dynamic" +) + +func (r EdgeIPsObjectType) IsKnown() bool { + switch r { + case EdgeIPsObjectTypeDynamic: + return true + } + return false +} + +// The IP versions supported for inbound connections on Spectrum anycast IPs. +type EdgeIPsConnectivity string + +const ( + EdgeIPsConnectivityAll EdgeIPsConnectivity = "all" + EdgeIPsConnectivityIPV4 EdgeIPsConnectivity = "ipv4" + EdgeIPsConnectivityIPV6 EdgeIPsConnectivity = "ipv6" +) + +func (r EdgeIPsConnectivity) IsKnown() bool { + switch r { + case EdgeIPsConnectivityAll, EdgeIPsConnectivityIPV4, EdgeIPsConnectivityIPV6: + return true + } + return false +} + +// The type of edge IP configuration specified. Dynamically allocated edge IPs use +// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid +// with CNAME DNS names. +type EdgeIPsType string + +const ( + EdgeIPsTypeDynamic EdgeIPsType = "dynamic" + EdgeIPsTypeStatic EdgeIPsType = "static" +) + +func (r EdgeIPsType) IsKnown() bool { + switch r { + case EdgeIPsTypeDynamic, EdgeIPsTypeStatic: + return true + } + return false +} + +// The anycast edge IP configuration for the hostname of this application. +type EdgeIPsParam struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity param.Field[EdgeIPsConnectivity] `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type param.Field[EdgeIPsType] `json:"type"` + IPs param.Field[interface{}] `json:"ips,required"` +} + +func (r EdgeIPsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r EdgeIPsParam) implementsSpectrumEdgeIPsUnionParam() {} + +// The anycast edge IP configuration for the hostname of this application. +// +// Satisfied by [spectrum.EdgeIPsObjectParam], [spectrum.EdgeIPsObjectParam], +// [EdgeIPsParam]. +type EdgeIPsUnionParam interface { + implementsSpectrumEdgeIPsUnionParam() +} + +type EdgeIPsObjectParam struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity param.Field[EdgeIPsObjectConnectivity] `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type param.Field[EdgeIPsObjectType] `json:"type"` +} + +func (r EdgeIPsObjectParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r EdgeIPsObjectParam) implementsSpectrumEdgeIPsUnionParam() {} + +// The name and type of DNS record for the Spectrum application. +type OriginDNS struct { + // The name of the DNS record associated with the origin. + Name string `json:"name" format:"hostname"` + // The TTL of our resolution of your DNS record in seconds. + TTL int64 `json:"ttl"` + // The type of DNS record associated with the origin. "" is used to specify a + // combination of A/AAAA records. + Type OriginDNSType `json:"type"` + JSON originDNSJSON `json:"-"` +} + +// originDNSJSON contains the JSON metadata for the struct [OriginDNS] +type originDNSJSON struct { + Name apijson.Field + TTL apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OriginDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r originDNSJSON) RawJSON() string { + return r.raw +} + +// The type of DNS record associated with the origin. "" is used to specify a +// combination of A/AAAA records. +type OriginDNSType string + +const ( + OriginDNSTypeEmpty OriginDNSType = "" + OriginDNSTypeA OriginDNSType = "A" + OriginDNSTypeAAAA OriginDNSType = "AAAA" + OriginDNSTypeSRV OriginDNSType = "SRV" +) + +func (r OriginDNSType) IsKnown() bool { + switch r { + case OriginDNSTypeEmpty, OriginDNSTypeA, OriginDNSTypeAAAA, OriginDNSTypeSRV: + return true + } + return false +} + +// The name and type of DNS record for the Spectrum application. +type OriginDNSParam struct { + // The name of the DNS record associated with the origin. + Name param.Field[string] `json:"name" format:"hostname"` + // The TTL of our resolution of your DNS record in seconds. + TTL param.Field[int64] `json:"ttl"` + // The type of DNS record associated with the origin. "" is used to specify a + // combination of A/AAAA records. + Type param.Field[OriginDNSType] `json:"type"` +} + +func (r OriginDNSParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The destination port at the origin. Only specified in conjunction with +// origin_dns. May use an integer to specify a single origin port, for example +// `1000`, or a string to specify a range of origin ports, for example +// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the +// range must match the number of ports specified in the "protocol" field. +// +// Union satisfied by [shared.UnionInt] or [shared.UnionString]. +type OriginPortUnion interface { + ImplementsSpectrumOriginPortUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*OriginPortUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionInt(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// The destination port at the origin. Only specified in conjunction with +// origin_dns. May use an integer to specify a single origin port, for example +// `1000`, or a string to specify a range of origin ports, for example +// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the +// range must match the number of ports specified in the "protocol" field. +// +// Satisfied by [shared.UnionInt], [shared.UnionString]. +type OriginPortUnionParam interface { + ImplementsSpectrumOriginPortUnionParam() +} diff --git a/speed/aliases.go b/speed/aliases.go index 2f1cd4cec02..35c601fd729 100644 --- a/speed/aliases.go +++ b/speed/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/speed/availability.go b/speed/availability.go index 8d09a6ab01a..d8884c78797 100644 --- a/speed/availability.go +++ b/speed/availability.go @@ -32,7 +32,7 @@ func NewAvailabilityService(opts ...option.RequestOption) (r *AvailabilityServic } // Retrieves quota for all plans, as well as the current zone quota. -func (r *AvailabilityService) List(ctx context.Context, query AvailabilityListParams, opts ...option.RequestOption) (res *ObservatoryAvailabilities, err error) { +func (r *AvailabilityService) List(ctx context.Context, query AvailabilityListParams, opts ...option.RequestOption) (res *Availability, err error) { opts = append(r.Options[:], opts...) var env AvailabilityListResponseEnvelope path := fmt.Sprintf("zones/%s/speed_api/availabilities", query.ZoneID) @@ -44,16 +44,15 @@ func (r *AvailabilityService) List(ctx context.Context, query AvailabilityListPa return } -type ObservatoryAvailabilities struct { - Quota ObservatoryAvailabilitiesQuota `json:"quota"` - Regions []ObservatoryAvailabilitiesRegion `json:"regions"` - RegionsPerPlan interface{} `json:"regionsPerPlan"` - JSON observatoryAvailabilitiesJSON `json:"-"` +type Availability struct { + Quota AvailabilityQuota `json:"quota"` + Regions []LabeledRegion `json:"regions"` + RegionsPerPlan interface{} `json:"regionsPerPlan"` + JSON availabilityJSON `json:"-"` } -// observatoryAvailabilitiesJSON contains the JSON metadata for the struct -// [ObservatoryAvailabilities] -type observatoryAvailabilitiesJSON struct { +// availabilityJSON contains the JSON metadata for the struct [Availability] +type availabilityJSON struct { Quota apijson.Field Regions apijson.Field RegionsPerPlan apijson.Field @@ -61,15 +60,15 @@ type observatoryAvailabilitiesJSON struct { ExtraFields map[string]apijson.Field } -func (r *ObservatoryAvailabilities) UnmarshalJSON(data []byte) (err error) { +func (r *Availability) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r observatoryAvailabilitiesJSON) RawJSON() string { +func (r availabilityJSON) RawJSON() string { return r.raw } -type ObservatoryAvailabilitiesQuota struct { +type AvailabilityQuota struct { // Cloudflare plan. Plan string `json:"plan"` // The number of tests available per plan. @@ -79,13 +78,13 @@ type ObservatoryAvailabilitiesQuota struct { // The number of remaining tests available. RemainingTests float64 `json:"remainingTests"` // The number of schedules available per plan. - ScheduleQuotasPerPlan map[string]float64 `json:"scheduleQuotasPerPlan"` - JSON observatoryAvailabilitiesQuotaJSON `json:"-"` + ScheduleQuotasPerPlan map[string]float64 `json:"scheduleQuotasPerPlan"` + JSON availabilityQuotaJSON `json:"-"` } -// observatoryAvailabilitiesQuotaJSON contains the JSON metadata for the struct -// [ObservatoryAvailabilitiesQuota] -type observatoryAvailabilitiesQuotaJSON struct { +// availabilityQuotaJSON contains the JSON metadata for the struct +// [AvailabilityQuota] +type availabilityQuotaJSON struct { Plan apijson.Field QuotasPerPlan apijson.Field RemainingSchedules apijson.Field @@ -95,87 +94,33 @@ type observatoryAvailabilitiesQuotaJSON struct { ExtraFields map[string]apijson.Field } -func (r *ObservatoryAvailabilitiesQuota) UnmarshalJSON(data []byte) (err error) { +func (r *AvailabilityQuota) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r observatoryAvailabilitiesQuotaJSON) RawJSON() string { +func (r availabilityQuotaJSON) RawJSON() string { return r.raw } -// A test region with a label. -type ObservatoryAvailabilitiesRegion struct { - Label string `json:"label"` - // A test region. - Value ObservatoryAvailabilitiesRegionsValue `json:"value"` - JSON observatoryAvailabilitiesRegionJSON `json:"-"` -} - -// observatoryAvailabilitiesRegionJSON contains the JSON metadata for the struct -// [ObservatoryAvailabilitiesRegion] -type observatoryAvailabilitiesRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ObservatoryAvailabilitiesRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r observatoryAvailabilitiesRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type ObservatoryAvailabilitiesRegionsValue string - -const ( - ObservatoryAvailabilitiesRegionsValueAsiaEast1 ObservatoryAvailabilitiesRegionsValue = "asia-east1" - ObservatoryAvailabilitiesRegionsValueAsiaNortheast1 ObservatoryAvailabilitiesRegionsValue = "asia-northeast1" - ObservatoryAvailabilitiesRegionsValueAsiaNortheast2 ObservatoryAvailabilitiesRegionsValue = "asia-northeast2" - ObservatoryAvailabilitiesRegionsValueAsiaSouth1 ObservatoryAvailabilitiesRegionsValue = "asia-south1" - ObservatoryAvailabilitiesRegionsValueAsiaSoutheast1 ObservatoryAvailabilitiesRegionsValue = "asia-southeast1" - ObservatoryAvailabilitiesRegionsValueAustraliaSoutheast1 ObservatoryAvailabilitiesRegionsValue = "australia-southeast1" - ObservatoryAvailabilitiesRegionsValueEuropeNorth1 ObservatoryAvailabilitiesRegionsValue = "europe-north1" - ObservatoryAvailabilitiesRegionsValueEuropeSouthwest1 ObservatoryAvailabilitiesRegionsValue = "europe-southwest1" - ObservatoryAvailabilitiesRegionsValueEuropeWest1 ObservatoryAvailabilitiesRegionsValue = "europe-west1" - ObservatoryAvailabilitiesRegionsValueEuropeWest2 ObservatoryAvailabilitiesRegionsValue = "europe-west2" - ObservatoryAvailabilitiesRegionsValueEuropeWest3 ObservatoryAvailabilitiesRegionsValue = "europe-west3" - ObservatoryAvailabilitiesRegionsValueEuropeWest4 ObservatoryAvailabilitiesRegionsValue = "europe-west4" - ObservatoryAvailabilitiesRegionsValueEuropeWest8 ObservatoryAvailabilitiesRegionsValue = "europe-west8" - ObservatoryAvailabilitiesRegionsValueEuropeWest9 ObservatoryAvailabilitiesRegionsValue = "europe-west9" - ObservatoryAvailabilitiesRegionsValueMeWest1 ObservatoryAvailabilitiesRegionsValue = "me-west1" - ObservatoryAvailabilitiesRegionsValueSouthamericaEast1 ObservatoryAvailabilitiesRegionsValue = "southamerica-east1" - ObservatoryAvailabilitiesRegionsValueUsCentral1 ObservatoryAvailabilitiesRegionsValue = "us-central1" - ObservatoryAvailabilitiesRegionsValueUsEast1 ObservatoryAvailabilitiesRegionsValue = "us-east1" - ObservatoryAvailabilitiesRegionsValueUsEast4 ObservatoryAvailabilitiesRegionsValue = "us-east4" - ObservatoryAvailabilitiesRegionsValueUsSouth1 ObservatoryAvailabilitiesRegionsValue = "us-south1" - ObservatoryAvailabilitiesRegionsValueUsWest1 ObservatoryAvailabilitiesRegionsValue = "us-west1" -) - -func (r ObservatoryAvailabilitiesRegionsValue) IsKnown() bool { - switch r { - case ObservatoryAvailabilitiesRegionsValueAsiaEast1, ObservatoryAvailabilitiesRegionsValueAsiaNortheast1, ObservatoryAvailabilitiesRegionsValueAsiaNortheast2, ObservatoryAvailabilitiesRegionsValueAsiaSouth1, ObservatoryAvailabilitiesRegionsValueAsiaSoutheast1, ObservatoryAvailabilitiesRegionsValueAustraliaSoutheast1, ObservatoryAvailabilitiesRegionsValueEuropeNorth1, ObservatoryAvailabilitiesRegionsValueEuropeSouthwest1, ObservatoryAvailabilitiesRegionsValueEuropeWest1, ObservatoryAvailabilitiesRegionsValueEuropeWest2, ObservatoryAvailabilitiesRegionsValueEuropeWest3, ObservatoryAvailabilitiesRegionsValueEuropeWest4, ObservatoryAvailabilitiesRegionsValueEuropeWest8, ObservatoryAvailabilitiesRegionsValueEuropeWest9, ObservatoryAvailabilitiesRegionsValueMeWest1, ObservatoryAvailabilitiesRegionsValueSouthamericaEast1, ObservatoryAvailabilitiesRegionsValueUsCentral1, ObservatoryAvailabilitiesRegionsValueUsEast1, ObservatoryAvailabilitiesRegionsValueUsEast4, ObservatoryAvailabilitiesRegionsValueUsSouth1, ObservatoryAvailabilitiesRegionsValueUsWest1: - return true - } - return false -} - type AvailabilityListParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type AvailabilityListResponseEnvelope struct { - Result ObservatoryAvailabilities `json:"result"` - JSON availabilityListResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result Availability `json:"result"` + JSON availabilityListResponseEnvelopeJSON `json:"-"` } // availabilityListResponseEnvelopeJSON contains the JSON metadata for the struct // [AvailabilityListResponseEnvelope] type availabilityListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field diff --git a/speed/page.go b/speed/page.go index d5299ca98f8..e47d8762e9a 100644 --- a/speed/page.go +++ b/speed/page.go @@ -56,10 +56,10 @@ func (r *PageService) ListAutoPaging(ctx context.Context, query PageListParams, type PageListResponse struct { // A test region with a label. - Region PageListResponseRegion `json:"region"` + Region LabeledRegion `json:"region"` // The frequency of the test. ScheduleFrequency PageListResponseScheduleFrequency `json:"scheduleFrequency"` - Tests []ObservatoryPageTest `json:"tests"` + Tests []Test `json:"tests"` // A URL. URL string `json:"url"` JSON pageListResponseJSON `json:"-"` @@ -84,66 +84,6 @@ func (r pageListResponseJSON) RawJSON() string { return r.raw } -// A test region with a label. -type PageListResponseRegion struct { - Label string `json:"label"` - // A test region. - Value PageListResponseRegionValue `json:"value"` - JSON pageListResponseRegionJSON `json:"-"` -} - -// pageListResponseRegionJSON contains the JSON metadata for the struct -// [PageListResponseRegion] -type pageListResponseRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageListResponseRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageListResponseRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type PageListResponseRegionValue string - -const ( - PageListResponseRegionValueAsiaEast1 PageListResponseRegionValue = "asia-east1" - PageListResponseRegionValueAsiaNortheast1 PageListResponseRegionValue = "asia-northeast1" - PageListResponseRegionValueAsiaNortheast2 PageListResponseRegionValue = "asia-northeast2" - PageListResponseRegionValueAsiaSouth1 PageListResponseRegionValue = "asia-south1" - PageListResponseRegionValueAsiaSoutheast1 PageListResponseRegionValue = "asia-southeast1" - PageListResponseRegionValueAustraliaSoutheast1 PageListResponseRegionValue = "australia-southeast1" - PageListResponseRegionValueEuropeNorth1 PageListResponseRegionValue = "europe-north1" - PageListResponseRegionValueEuropeSouthwest1 PageListResponseRegionValue = "europe-southwest1" - PageListResponseRegionValueEuropeWest1 PageListResponseRegionValue = "europe-west1" - PageListResponseRegionValueEuropeWest2 PageListResponseRegionValue = "europe-west2" - PageListResponseRegionValueEuropeWest3 PageListResponseRegionValue = "europe-west3" - PageListResponseRegionValueEuropeWest4 PageListResponseRegionValue = "europe-west4" - PageListResponseRegionValueEuropeWest8 PageListResponseRegionValue = "europe-west8" - PageListResponseRegionValueEuropeWest9 PageListResponseRegionValue = "europe-west9" - PageListResponseRegionValueMeWest1 PageListResponseRegionValue = "me-west1" - PageListResponseRegionValueSouthamericaEast1 PageListResponseRegionValue = "southamerica-east1" - PageListResponseRegionValueUsCentral1 PageListResponseRegionValue = "us-central1" - PageListResponseRegionValueUsEast1 PageListResponseRegionValue = "us-east1" - PageListResponseRegionValueUsEast4 PageListResponseRegionValue = "us-east4" - PageListResponseRegionValueUsSouth1 PageListResponseRegionValue = "us-south1" - PageListResponseRegionValueUsWest1 PageListResponseRegionValue = "us-west1" -) - -func (r PageListResponseRegionValue) IsKnown() bool { - switch r { - case PageListResponseRegionValueAsiaEast1, PageListResponseRegionValueAsiaNortheast1, PageListResponseRegionValueAsiaNortheast2, PageListResponseRegionValueAsiaSouth1, PageListResponseRegionValueAsiaSoutheast1, PageListResponseRegionValueAustraliaSoutheast1, PageListResponseRegionValueEuropeNorth1, PageListResponseRegionValueEuropeSouthwest1, PageListResponseRegionValueEuropeWest1, PageListResponseRegionValueEuropeWest2, PageListResponseRegionValueEuropeWest3, PageListResponseRegionValueEuropeWest4, PageListResponseRegionValueEuropeWest8, PageListResponseRegionValueEuropeWest9, PageListResponseRegionValueMeWest1, PageListResponseRegionValueSouthamericaEast1, PageListResponseRegionValueUsCentral1, PageListResponseRegionValueUsEast1, PageListResponseRegionValueUsEast4, PageListResponseRegionValueUsSouth1, PageListResponseRegionValueUsWest1: - return true - } - return false -} - // The frequency of the test. type PageListResponseScheduleFrequency string diff --git a/speed/schedule.go b/speed/schedule.go index ff14c8d3b03..70641f20311 100644 --- a/speed/schedule.go +++ b/speed/schedule.go @@ -45,10 +45,103 @@ func (r *ScheduleService) New(ctx context.Context, url string, params ScheduleNe return } +// The test schedule. +type Schedule struct { + // The frequency of the test. + Frequency ScheduleFrequency `json:"frequency"` + // A test region. + Region ScheduleRegion `json:"region"` + // A URL. + URL string `json:"url"` + JSON scheduleJSON `json:"-"` +} + +// scheduleJSON contains the JSON metadata for the struct [Schedule] +type scheduleJSON struct { + Frequency apijson.Field + Region apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Schedule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scheduleJSON) RawJSON() string { + return r.raw +} + +// The frequency of the test. +type ScheduleFrequency string + +const ( + ScheduleFrequencyDaily ScheduleFrequency = "DAILY" + ScheduleFrequencyWeekly ScheduleFrequency = "WEEKLY" +) + +func (r ScheduleFrequency) IsKnown() bool { + switch r { + case ScheduleFrequencyDaily, ScheduleFrequencyWeekly: + return true + } + return false +} + +// A test region. +type ScheduleRegion string + +const ( + ScheduleRegionAsiaEast1 ScheduleRegion = "asia-east1" + ScheduleRegionAsiaNortheast1 ScheduleRegion = "asia-northeast1" + ScheduleRegionAsiaNortheast2 ScheduleRegion = "asia-northeast2" + ScheduleRegionAsiaSouth1 ScheduleRegion = "asia-south1" + ScheduleRegionAsiaSoutheast1 ScheduleRegion = "asia-southeast1" + ScheduleRegionAustraliaSoutheast1 ScheduleRegion = "australia-southeast1" + ScheduleRegionEuropeNorth1 ScheduleRegion = "europe-north1" + ScheduleRegionEuropeSouthwest1 ScheduleRegion = "europe-southwest1" + ScheduleRegionEuropeWest1 ScheduleRegion = "europe-west1" + ScheduleRegionEuropeWest2 ScheduleRegion = "europe-west2" + ScheduleRegionEuropeWest3 ScheduleRegion = "europe-west3" + ScheduleRegionEuropeWest4 ScheduleRegion = "europe-west4" + ScheduleRegionEuropeWest8 ScheduleRegion = "europe-west8" + ScheduleRegionEuropeWest9 ScheduleRegion = "europe-west9" + ScheduleRegionMeWest1 ScheduleRegion = "me-west1" + ScheduleRegionSouthamericaEast1 ScheduleRegion = "southamerica-east1" + ScheduleRegionUsCentral1 ScheduleRegion = "us-central1" + ScheduleRegionUsEast1 ScheduleRegion = "us-east1" + ScheduleRegionUsEast4 ScheduleRegion = "us-east4" + ScheduleRegionUsSouth1 ScheduleRegion = "us-south1" + ScheduleRegionUsWest1 ScheduleRegion = "us-west1" +) + +func (r ScheduleRegion) IsKnown() bool { + switch r { + case ScheduleRegionAsiaEast1, ScheduleRegionAsiaNortheast1, ScheduleRegionAsiaNortheast2, ScheduleRegionAsiaSouth1, ScheduleRegionAsiaSoutheast1, ScheduleRegionAustraliaSoutheast1, ScheduleRegionEuropeNorth1, ScheduleRegionEuropeSouthwest1, ScheduleRegionEuropeWest1, ScheduleRegionEuropeWest2, ScheduleRegionEuropeWest3, ScheduleRegionEuropeWest4, ScheduleRegionEuropeWest8, ScheduleRegionEuropeWest9, ScheduleRegionMeWest1, ScheduleRegionSouthamericaEast1, ScheduleRegionUsCentral1, ScheduleRegionUsEast1, ScheduleRegionUsEast4, ScheduleRegionUsSouth1, ScheduleRegionUsWest1: + return true + } + return false +} + +// The test schedule. +type ScheduleParam struct { + // The frequency of the test. + Frequency param.Field[ScheduleFrequency] `json:"frequency"` + // A test region. + Region param.Field[ScheduleRegion] `json:"region"` + // A URL. + URL param.Field[string] `json:"url"` +} + +func (r ScheduleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type ScheduleNewResponse struct { // The test schedule. - Schedule ObservatorySchedule `json:"schedule"` - Test ObservatoryPageTest `json:"test"` + Schedule Schedule `json:"schedule"` + Test Test `json:"test"` JSON scheduleNewResponseJSON `json:"-"` } @@ -79,7 +172,7 @@ type ScheduleNewParams struct { // URLQuery serializes [ScheduleNewParams]'s query parameters as `url.Values`. func (r ScheduleNewParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -120,13 +213,19 @@ func (r ScheduleNewParamsRegion) IsKnown() bool { } type ScheduleNewResponseEnvelope struct { - Result ScheduleNewResponse `json:"result"` - JSON scheduleNewResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result ScheduleNewResponse `json:"result"` + JSON scheduleNewResponseEnvelopeJSON `json:"-"` } // scheduleNewResponseEnvelopeJSON contains the JSON metadata for the struct // [ScheduleNewResponseEnvelope] type scheduleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field diff --git a/speed/speed.go b/speed/speed.go index 4f00e69e5d5..e35127dbe43 100644 --- a/speed/speed.go +++ b/speed/speed.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "net/url" + "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" @@ -54,7 +55,7 @@ func (r *SpeedService) Delete(ctx context.Context, url string, params SpeedDelet } // Retrieves the test schedule for a page in a specific region. -func (r *SpeedService) ScheduleGet(ctx context.Context, url string, params SpeedScheduleGetParams, opts ...option.RequestOption) (res *ObservatorySchedule, err error) { +func (r *SpeedService) ScheduleGet(ctx context.Context, url string, params SpeedScheduleGetParams, opts ...option.RequestOption) (res *Schedule, err error) { opts = append(r.Options[:], opts...) var env SpeedScheduleGetResponseEnvelope path := fmt.Sprintf("zones/%s/speed_api/schedule/%s", params.ZoneID, url) @@ -67,7 +68,7 @@ func (r *SpeedService) ScheduleGet(ctx context.Context, url string, params Speed } // Lists the core web vital metrics trend over time for a specific page. -func (r *SpeedService) TrendsList(ctx context.Context, url string, params SpeedTrendsListParams, opts ...option.RequestOption) (res *ObservatoryTrend, err error) { +func (r *SpeedService) TrendsList(ctx context.Context, url string, params SpeedTrendsListParams, opts ...option.RequestOption) (res *Trend, err error) { opts = append(r.Options[:], opts...) var env SpeedTrendsListResponseEnvelope path := fmt.Sprintf("zones/%s/speed_api/pages/%s/trend", params.ZoneID, url) @@ -79,87 +80,201 @@ func (r *SpeedService) TrendsList(ctx context.Context, url string, params SpeedT return } -// The test schedule. -type ObservatorySchedule struct { - // The frequency of the test. - Frequency ObservatoryScheduleFrequency `json:"frequency"` +// A test region with a label. +type LabeledRegion struct { + Label string `json:"label"` // A test region. - Region ObservatoryScheduleRegion `json:"region"` - // A URL. - URL string `json:"url"` - JSON observatoryScheduleJSON `json:"-"` -} - -// observatoryScheduleJSON contains the JSON metadata for the struct -// [ObservatorySchedule] -type observatoryScheduleJSON struct { - Frequency apijson.Field - Region apijson.Field - URL apijson.Field + Value LabeledRegionValue `json:"value"` + JSON labeledRegionJSON `json:"-"` +} + +// labeledRegionJSON contains the JSON metadata for the struct [LabeledRegion] +type labeledRegionJSON struct { + Label apijson.Field + Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ObservatorySchedule) UnmarshalJSON(data []byte) (err error) { +func (r *LabeledRegion) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r observatoryScheduleJSON) RawJSON() string { +func (r labeledRegionJSON) RawJSON() string { return r.raw } -// The frequency of the test. -type ObservatoryScheduleFrequency string +// A test region. +type LabeledRegionValue string const ( - ObservatoryScheduleFrequencyDaily ObservatoryScheduleFrequency = "DAILY" - ObservatoryScheduleFrequencyWeekly ObservatoryScheduleFrequency = "WEEKLY" + LabeledRegionValueAsiaEast1 LabeledRegionValue = "asia-east1" + LabeledRegionValueAsiaNortheast1 LabeledRegionValue = "asia-northeast1" + LabeledRegionValueAsiaNortheast2 LabeledRegionValue = "asia-northeast2" + LabeledRegionValueAsiaSouth1 LabeledRegionValue = "asia-south1" + LabeledRegionValueAsiaSoutheast1 LabeledRegionValue = "asia-southeast1" + LabeledRegionValueAustraliaSoutheast1 LabeledRegionValue = "australia-southeast1" + LabeledRegionValueEuropeNorth1 LabeledRegionValue = "europe-north1" + LabeledRegionValueEuropeSouthwest1 LabeledRegionValue = "europe-southwest1" + LabeledRegionValueEuropeWest1 LabeledRegionValue = "europe-west1" + LabeledRegionValueEuropeWest2 LabeledRegionValue = "europe-west2" + LabeledRegionValueEuropeWest3 LabeledRegionValue = "europe-west3" + LabeledRegionValueEuropeWest4 LabeledRegionValue = "europe-west4" + LabeledRegionValueEuropeWest8 LabeledRegionValue = "europe-west8" + LabeledRegionValueEuropeWest9 LabeledRegionValue = "europe-west9" + LabeledRegionValueMeWest1 LabeledRegionValue = "me-west1" + LabeledRegionValueSouthamericaEast1 LabeledRegionValue = "southamerica-east1" + LabeledRegionValueUsCentral1 LabeledRegionValue = "us-central1" + LabeledRegionValueUsEast1 LabeledRegionValue = "us-east1" + LabeledRegionValueUsEast4 LabeledRegionValue = "us-east4" + LabeledRegionValueUsSouth1 LabeledRegionValue = "us-south1" + LabeledRegionValueUsWest1 LabeledRegionValue = "us-west1" ) -func (r ObservatoryScheduleFrequency) IsKnown() bool { +func (r LabeledRegionValue) IsKnown() bool { switch r { - case ObservatoryScheduleFrequencyDaily, ObservatoryScheduleFrequencyWeekly: + case LabeledRegionValueAsiaEast1, LabeledRegionValueAsiaNortheast1, LabeledRegionValueAsiaNortheast2, LabeledRegionValueAsiaSouth1, LabeledRegionValueAsiaSoutheast1, LabeledRegionValueAustraliaSoutheast1, LabeledRegionValueEuropeNorth1, LabeledRegionValueEuropeSouthwest1, LabeledRegionValueEuropeWest1, LabeledRegionValueEuropeWest2, LabeledRegionValueEuropeWest3, LabeledRegionValueEuropeWest4, LabeledRegionValueEuropeWest8, LabeledRegionValueEuropeWest9, LabeledRegionValueMeWest1, LabeledRegionValueSouthamericaEast1, LabeledRegionValueUsCentral1, LabeledRegionValueUsEast1, LabeledRegionValueUsEast4, LabeledRegionValueUsSouth1, LabeledRegionValueUsWest1: return true } return false } -// A test region. -type ObservatoryScheduleRegion string +// The Lighthouse report. +type LighthouseReport struct { + // Cumulative Layout Shift. + Cls float64 `json:"cls"` + // The type of device. + DeviceType LighthouseReportDeviceType `json:"deviceType"` + Error LighthouseReportError `json:"error"` + // First Contentful Paint. + Fcp float64 `json:"fcp"` + // The URL to the full Lighthouse JSON report. + JsonReportURL string `json:"jsonReportUrl"` + // Largest Contentful Paint. + Lcp float64 `json:"lcp"` + // The Lighthouse performance score. + PerformanceScore float64 `json:"performanceScore"` + // Speed Index. + Si float64 `json:"si"` + // The state of the Lighthouse report. + State LighthouseReportState `json:"state"` + // Total Blocking Time. + Tbt float64 `json:"tbt"` + // Time To First Byte. + Ttfb float64 `json:"ttfb"` + // Time To Interactive. + Tti float64 `json:"tti"` + JSON lighthouseReportJSON `json:"-"` +} + +// lighthouseReportJSON contains the JSON metadata for the struct +// [LighthouseReport] +type lighthouseReportJSON struct { + Cls apijson.Field + DeviceType apijson.Field + Error apijson.Field + Fcp apijson.Field + JsonReportURL apijson.Field + Lcp apijson.Field + PerformanceScore apijson.Field + Si apijson.Field + State apijson.Field + Tbt apijson.Field + Ttfb apijson.Field + Tti apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LighthouseReport) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lighthouseReportJSON) RawJSON() string { + return r.raw +} + +// The type of device. +type LighthouseReportDeviceType string + +const ( + LighthouseReportDeviceTypeDesktop LighthouseReportDeviceType = "DESKTOP" + LighthouseReportDeviceTypeMobile LighthouseReportDeviceType = "MOBILE" +) + +func (r LighthouseReportDeviceType) IsKnown() bool { + switch r { + case LighthouseReportDeviceTypeDesktop, LighthouseReportDeviceTypeMobile: + return true + } + return false +} + +type LighthouseReportError struct { + // The error code of the Lighthouse result. + Code LighthouseReportErrorCode `json:"code"` + // Detailed error message. + Detail string `json:"detail"` + // The final URL displayed to the user. + FinalDisplayedURL string `json:"finalDisplayedUrl"` + JSON lighthouseReportErrorJSON `json:"-"` +} + +// lighthouseReportErrorJSON contains the JSON metadata for the struct +// [LighthouseReportError] +type lighthouseReportErrorJSON struct { + Code apijson.Field + Detail apijson.Field + FinalDisplayedURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LighthouseReportError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lighthouseReportErrorJSON) RawJSON() string { + return r.raw +} + +// The error code of the Lighthouse result. +type LighthouseReportErrorCode string + +const ( + LighthouseReportErrorCodeNotReachable LighthouseReportErrorCode = "NOT_REACHABLE" + LighthouseReportErrorCodeDNSFailure LighthouseReportErrorCode = "DNS_FAILURE" + LighthouseReportErrorCodeNotHTML LighthouseReportErrorCode = "NOT_HTML" + LighthouseReportErrorCodeLighthouseTimeout LighthouseReportErrorCode = "LIGHTHOUSE_TIMEOUT" + LighthouseReportErrorCodeUnknown LighthouseReportErrorCode = "UNKNOWN" +) + +func (r LighthouseReportErrorCode) IsKnown() bool { + switch r { + case LighthouseReportErrorCodeNotReachable, LighthouseReportErrorCodeDNSFailure, LighthouseReportErrorCodeNotHTML, LighthouseReportErrorCodeLighthouseTimeout, LighthouseReportErrorCodeUnknown: + return true + } + return false +} + +// The state of the Lighthouse report. +type LighthouseReportState string const ( - ObservatoryScheduleRegionAsiaEast1 ObservatoryScheduleRegion = "asia-east1" - ObservatoryScheduleRegionAsiaNortheast1 ObservatoryScheduleRegion = "asia-northeast1" - ObservatoryScheduleRegionAsiaNortheast2 ObservatoryScheduleRegion = "asia-northeast2" - ObservatoryScheduleRegionAsiaSouth1 ObservatoryScheduleRegion = "asia-south1" - ObservatoryScheduleRegionAsiaSoutheast1 ObservatoryScheduleRegion = "asia-southeast1" - ObservatoryScheduleRegionAustraliaSoutheast1 ObservatoryScheduleRegion = "australia-southeast1" - ObservatoryScheduleRegionEuropeNorth1 ObservatoryScheduleRegion = "europe-north1" - ObservatoryScheduleRegionEuropeSouthwest1 ObservatoryScheduleRegion = "europe-southwest1" - ObservatoryScheduleRegionEuropeWest1 ObservatoryScheduleRegion = "europe-west1" - ObservatoryScheduleRegionEuropeWest2 ObservatoryScheduleRegion = "europe-west2" - ObservatoryScheduleRegionEuropeWest3 ObservatoryScheduleRegion = "europe-west3" - ObservatoryScheduleRegionEuropeWest4 ObservatoryScheduleRegion = "europe-west4" - ObservatoryScheduleRegionEuropeWest8 ObservatoryScheduleRegion = "europe-west8" - ObservatoryScheduleRegionEuropeWest9 ObservatoryScheduleRegion = "europe-west9" - ObservatoryScheduleRegionMeWest1 ObservatoryScheduleRegion = "me-west1" - ObservatoryScheduleRegionSouthamericaEast1 ObservatoryScheduleRegion = "southamerica-east1" - ObservatoryScheduleRegionUsCentral1 ObservatoryScheduleRegion = "us-central1" - ObservatoryScheduleRegionUsEast1 ObservatoryScheduleRegion = "us-east1" - ObservatoryScheduleRegionUsEast4 ObservatoryScheduleRegion = "us-east4" - ObservatoryScheduleRegionUsSouth1 ObservatoryScheduleRegion = "us-south1" - ObservatoryScheduleRegionUsWest1 ObservatoryScheduleRegion = "us-west1" + LighthouseReportStateRunning LighthouseReportState = "RUNNING" + LighthouseReportStateComplete LighthouseReportState = "COMPLETE" + LighthouseReportStateFailed LighthouseReportState = "FAILED" ) -func (r ObservatoryScheduleRegion) IsKnown() bool { +func (r LighthouseReportState) IsKnown() bool { switch r { - case ObservatoryScheduleRegionAsiaEast1, ObservatoryScheduleRegionAsiaNortheast1, ObservatoryScheduleRegionAsiaNortheast2, ObservatoryScheduleRegionAsiaSouth1, ObservatoryScheduleRegionAsiaSoutheast1, ObservatoryScheduleRegionAustraliaSoutheast1, ObservatoryScheduleRegionEuropeNorth1, ObservatoryScheduleRegionEuropeSouthwest1, ObservatoryScheduleRegionEuropeWest1, ObservatoryScheduleRegionEuropeWest2, ObservatoryScheduleRegionEuropeWest3, ObservatoryScheduleRegionEuropeWest4, ObservatoryScheduleRegionEuropeWest8, ObservatoryScheduleRegionEuropeWest9, ObservatoryScheduleRegionMeWest1, ObservatoryScheduleRegionSouthamericaEast1, ObservatoryScheduleRegionUsCentral1, ObservatoryScheduleRegionUsEast1, ObservatoryScheduleRegionUsEast4, ObservatoryScheduleRegionUsSouth1, ObservatoryScheduleRegionUsWest1: + case LighthouseReportStateRunning, LighthouseReportStateComplete, LighthouseReportStateFailed: return true } return false } -type ObservatoryTrend struct { +type Trend struct { // Cumulative Layout Shift trend. Cls []float64 `json:"cls"` // First Contentful Paint trend. @@ -175,13 +290,12 @@ type ObservatoryTrend struct { // Time To First Byte trend. Ttfb []float64 `json:"ttfb"` // Time To Interactive trend. - Tti []float64 `json:"tti"` - JSON observatoryTrendJSON `json:"-"` + Tti []float64 `json:"tti"` + JSON trendJSON `json:"-"` } -// observatoryTrendJSON contains the JSON metadata for the struct -// [ObservatoryTrend] -type observatoryTrendJSON struct { +// trendJSON contains the JSON metadata for the struct [Trend] +type trendJSON struct { Cls apijson.Field Fcp apijson.Field Lcp apijson.Field @@ -194,11 +308,11 @@ type observatoryTrendJSON struct { ExtraFields map[string]apijson.Field } -func (r *ObservatoryTrend) UnmarshalJSON(data []byte) (err error) { +func (r *Trend) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r observatoryTrendJSON) RawJSON() string { +func (r trendJSON) RawJSON() string { return r.raw } @@ -234,7 +348,7 @@ type SpeedDeleteParams struct { // URLQuery serializes [SpeedDeleteParams]'s query parameters as `url.Values`. func (r SpeedDeleteParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -275,13 +389,19 @@ func (r SpeedDeleteParamsRegion) IsKnown() bool { } type SpeedDeleteResponseEnvelope struct { - Result SpeedDeleteResponse `json:"result"` - JSON speedDeleteResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result SpeedDeleteResponse `json:"result"` + JSON speedDeleteResponseEnvelopeJSON `json:"-"` } // speedDeleteResponseEnvelopeJSON contains the JSON metadata for the struct // [SpeedDeleteResponseEnvelope] type speedDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -305,7 +425,7 @@ type SpeedScheduleGetParams struct { // URLQuery serializes [SpeedScheduleGetParams]'s query parameters as `url.Values`. func (r SpeedScheduleGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -346,14 +466,20 @@ func (r SpeedScheduleGetParamsRegion) IsKnown() bool { } type SpeedScheduleGetResponseEnvelope struct { + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` // The test schedule. - Result ObservatorySchedule `json:"result"` + Result Schedule `json:"result"` JSON speedScheduleGetResponseEnvelopeJSON `json:"-"` } // speedScheduleGetResponseEnvelopeJSON contains the JSON metadata for the struct // [SpeedScheduleGetResponseEnvelope] type speedScheduleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -376,14 +502,16 @@ type SpeedTrendsListParams struct { Metrics param.Field[string] `query:"metrics,required"` // A test region. Region param.Field[SpeedTrendsListParamsRegion] `query:"region,required"` + Start param.Field[time.Time] `query:"start,required" format:"date-time"` // The timezone of the start and end timestamps. - Tz param.Field[string] `query:"tz,required"` + Tz param.Field[string] `query:"tz,required"` + End param.Field[time.Time] `query:"end" format:"date-time"` } // URLQuery serializes [SpeedTrendsListParams]'s query parameters as `url.Values`. func (r SpeedTrendsListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -440,13 +568,19 @@ func (r SpeedTrendsListParamsRegion) IsKnown() bool { } type SpeedTrendsListResponseEnvelope struct { - Result ObservatoryTrend `json:"result"` - JSON speedTrendsListResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result Trend `json:"result"` + JSON speedTrendsListResponseEnvelopeJSON `json:"-"` } // speedTrendsListResponseEnvelopeJSON contains the JSON metadata for the struct // [SpeedTrendsListResponseEnvelope] type speedTrendsListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field diff --git a/speed/speed_test.go b/speed/speed_test.go index d173629bae9..4aed55eef8a 100644 --- a/speed/speed_test.go +++ b/speed/speed_test.go @@ -7,6 +7,7 @@ import ( "errors" "os" "testing" + "time" "github.com/cloudflare/cloudflare-go/v2" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" @@ -76,7 +77,7 @@ func TestSpeedScheduleGetWithOptionalParams(t *testing.T) { } } -func TestSpeedTrendsList(t *testing.T) { +func TestSpeedTrendsListWithOptionalParams(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 { @@ -98,7 +99,9 @@ func TestSpeedTrendsList(t *testing.T) { DeviceType: cloudflare.F(speed.SpeedTrendsListParamsDeviceTypeDesktop), Metrics: cloudflare.F("performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls"), Region: cloudflare.F(speed.SpeedTrendsListParamsRegionUsCentral1), + Start: cloudflare.F(time.Now()), Tz: cloudflare.F("string"), + End: cloudflare.F(time.Now()), }, ) if err != nil { diff --git a/speed/test.go b/speed/test.go index 709a7a7def4..5b96920fb2c 100644 --- a/speed/test.go +++ b/speed/test.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -34,7 +35,7 @@ func NewTestService(opts ...option.RequestOption) (r *TestService) { } // Starts a test for a specific webpage, in a specific region. -func (r *TestService) New(ctx context.Context, url string, params TestNewParams, opts ...option.RequestOption) (res *ObservatoryPageTest, err error) { +func (r *TestService) New(ctx context.Context, url string, params TestNewParams, opts ...option.RequestOption) (res *Test, err error) { opts = append(r.Options[:], opts...) var env TestNewResponseEnvelope path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests", params.ZoneID, url) @@ -69,7 +70,7 @@ func (r *TestService) Delete(ctx context.Context, url string, params TestDeleteP } // Retrieves the result of a specific test. -func (r *TestService) Get(ctx context.Context, url string, testID string, query TestGetParams, opts ...option.RequestOption) (res *ObservatoryPageTest, err error) { +func (r *TestService) Get(ctx context.Context, url string, testID string, query TestGetParams, opts ...option.RequestOption) (res *Test, err error) { opts = append(r.Options[:], opts...) var env TestGetResponseEnvelope path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests/%s", query.ZoneID, url, testID) @@ -81,26 +82,25 @@ func (r *TestService) Get(ctx context.Context, url string, testID string, query return } -type ObservatoryPageTest struct { +type Test struct { // UUID ID string `json:"id"` Date time.Time `json:"date" format:"date-time"` // The Lighthouse report. - DesktopReport ObservatoryPageTestDesktopReport `json:"desktopReport"` + DesktopReport LighthouseReport `json:"desktopReport"` // The Lighthouse report. - MobileReport ObservatoryPageTestMobileReport `json:"mobileReport"` + MobileReport LighthouseReport `json:"mobileReport"` // A test region with a label. - Region ObservatoryPageTestRegion `json:"region"` + Region LabeledRegion `json:"region"` // The frequency of the test. - ScheduleFrequency ObservatoryPageTestScheduleFrequency `json:"scheduleFrequency"` + ScheduleFrequency TestScheduleFrequency `json:"scheduleFrequency"` // A URL. - URL string `json:"url"` - JSON observatoryPageTestJSON `json:"-"` + URL string `json:"url"` + JSON testJSON `json:"-"` } -// observatoryPageTestJSON contains the JSON metadata for the struct -// [ObservatoryPageTest] -type observatoryPageTestJSON struct { +// testJSON contains the JSON metadata for the struct [Test] +type testJSON struct { ID apijson.Field Date apijson.Field DesktopReport apijson.Field @@ -112,363 +112,33 @@ type observatoryPageTestJSON struct { ExtraFields map[string]apijson.Field } -func (r *ObservatoryPageTest) UnmarshalJSON(data []byte) (err error) { +func (r *Test) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r observatoryPageTestJSON) RawJSON() string { +func (r testJSON) RawJSON() string { return r.raw } -// The Lighthouse report. -type ObservatoryPageTestDesktopReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType ObservatoryPageTestDesktopReportDeviceType `json:"deviceType"` - Error ObservatoryPageTestDesktopReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State ObservatoryPageTestDesktopReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON observatoryPageTestDesktopReportJSON `json:"-"` -} - -// observatoryPageTestDesktopReportJSON contains the JSON metadata for the struct -// [ObservatoryPageTestDesktopReport] -type observatoryPageTestDesktopReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ObservatoryPageTestDesktopReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r observatoryPageTestDesktopReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type ObservatoryPageTestDesktopReportDeviceType string - -const ( - ObservatoryPageTestDesktopReportDeviceTypeDesktop ObservatoryPageTestDesktopReportDeviceType = "DESKTOP" - ObservatoryPageTestDesktopReportDeviceTypeMobile ObservatoryPageTestDesktopReportDeviceType = "MOBILE" -) - -func (r ObservatoryPageTestDesktopReportDeviceType) IsKnown() bool { - switch r { - case ObservatoryPageTestDesktopReportDeviceTypeDesktop, ObservatoryPageTestDesktopReportDeviceTypeMobile: - return true - } - return false -} - -type ObservatoryPageTestDesktopReportError struct { - // The error code of the Lighthouse result. - Code ObservatoryPageTestDesktopReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON observatoryPageTestDesktopReportErrorJSON `json:"-"` -} - -// observatoryPageTestDesktopReportErrorJSON contains the JSON metadata for the -// struct [ObservatoryPageTestDesktopReportError] -type observatoryPageTestDesktopReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ObservatoryPageTestDesktopReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r observatoryPageTestDesktopReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type ObservatoryPageTestDesktopReportErrorCode string - -const ( - ObservatoryPageTestDesktopReportErrorCodeNotReachable ObservatoryPageTestDesktopReportErrorCode = "NOT_REACHABLE" - ObservatoryPageTestDesktopReportErrorCodeDNSFailure ObservatoryPageTestDesktopReportErrorCode = "DNS_FAILURE" - ObservatoryPageTestDesktopReportErrorCodeNotHTML ObservatoryPageTestDesktopReportErrorCode = "NOT_HTML" - ObservatoryPageTestDesktopReportErrorCodeLighthouseTimeout ObservatoryPageTestDesktopReportErrorCode = "LIGHTHOUSE_TIMEOUT" - ObservatoryPageTestDesktopReportErrorCodeUnknown ObservatoryPageTestDesktopReportErrorCode = "UNKNOWN" -) - -func (r ObservatoryPageTestDesktopReportErrorCode) IsKnown() bool { - switch r { - case ObservatoryPageTestDesktopReportErrorCodeNotReachable, ObservatoryPageTestDesktopReportErrorCodeDNSFailure, ObservatoryPageTestDesktopReportErrorCodeNotHTML, ObservatoryPageTestDesktopReportErrorCodeLighthouseTimeout, ObservatoryPageTestDesktopReportErrorCodeUnknown: - return true - } - return false -} - -// The state of the Lighthouse report. -type ObservatoryPageTestDesktopReportState string - -const ( - ObservatoryPageTestDesktopReportStateRunning ObservatoryPageTestDesktopReportState = "RUNNING" - ObservatoryPageTestDesktopReportStateComplete ObservatoryPageTestDesktopReportState = "COMPLETE" - ObservatoryPageTestDesktopReportStateFailed ObservatoryPageTestDesktopReportState = "FAILED" -) - -func (r ObservatoryPageTestDesktopReportState) IsKnown() bool { - switch r { - case ObservatoryPageTestDesktopReportStateRunning, ObservatoryPageTestDesktopReportStateComplete, ObservatoryPageTestDesktopReportStateFailed: - return true - } - return false -} - -// The Lighthouse report. -type ObservatoryPageTestMobileReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType ObservatoryPageTestMobileReportDeviceType `json:"deviceType"` - Error ObservatoryPageTestMobileReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State ObservatoryPageTestMobileReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON observatoryPageTestMobileReportJSON `json:"-"` -} - -// observatoryPageTestMobileReportJSON contains the JSON metadata for the struct -// [ObservatoryPageTestMobileReport] -type observatoryPageTestMobileReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ObservatoryPageTestMobileReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r observatoryPageTestMobileReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type ObservatoryPageTestMobileReportDeviceType string - -const ( - ObservatoryPageTestMobileReportDeviceTypeDesktop ObservatoryPageTestMobileReportDeviceType = "DESKTOP" - ObservatoryPageTestMobileReportDeviceTypeMobile ObservatoryPageTestMobileReportDeviceType = "MOBILE" -) - -func (r ObservatoryPageTestMobileReportDeviceType) IsKnown() bool { - switch r { - case ObservatoryPageTestMobileReportDeviceTypeDesktop, ObservatoryPageTestMobileReportDeviceTypeMobile: - return true - } - return false -} - -type ObservatoryPageTestMobileReportError struct { - // The error code of the Lighthouse result. - Code ObservatoryPageTestMobileReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON observatoryPageTestMobileReportErrorJSON `json:"-"` -} - -// observatoryPageTestMobileReportErrorJSON contains the JSON metadata for the -// struct [ObservatoryPageTestMobileReportError] -type observatoryPageTestMobileReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ObservatoryPageTestMobileReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r observatoryPageTestMobileReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type ObservatoryPageTestMobileReportErrorCode string - -const ( - ObservatoryPageTestMobileReportErrorCodeNotReachable ObservatoryPageTestMobileReportErrorCode = "NOT_REACHABLE" - ObservatoryPageTestMobileReportErrorCodeDNSFailure ObservatoryPageTestMobileReportErrorCode = "DNS_FAILURE" - ObservatoryPageTestMobileReportErrorCodeNotHTML ObservatoryPageTestMobileReportErrorCode = "NOT_HTML" - ObservatoryPageTestMobileReportErrorCodeLighthouseTimeout ObservatoryPageTestMobileReportErrorCode = "LIGHTHOUSE_TIMEOUT" - ObservatoryPageTestMobileReportErrorCodeUnknown ObservatoryPageTestMobileReportErrorCode = "UNKNOWN" -) - -func (r ObservatoryPageTestMobileReportErrorCode) IsKnown() bool { - switch r { - case ObservatoryPageTestMobileReportErrorCodeNotReachable, ObservatoryPageTestMobileReportErrorCodeDNSFailure, ObservatoryPageTestMobileReportErrorCodeNotHTML, ObservatoryPageTestMobileReportErrorCodeLighthouseTimeout, ObservatoryPageTestMobileReportErrorCodeUnknown: - return true - } - return false -} - -// The state of the Lighthouse report. -type ObservatoryPageTestMobileReportState string - -const ( - ObservatoryPageTestMobileReportStateRunning ObservatoryPageTestMobileReportState = "RUNNING" - ObservatoryPageTestMobileReportStateComplete ObservatoryPageTestMobileReportState = "COMPLETE" - ObservatoryPageTestMobileReportStateFailed ObservatoryPageTestMobileReportState = "FAILED" -) - -func (r ObservatoryPageTestMobileReportState) IsKnown() bool { - switch r { - case ObservatoryPageTestMobileReportStateRunning, ObservatoryPageTestMobileReportStateComplete, ObservatoryPageTestMobileReportStateFailed: - return true - } - return false -} - -// A test region with a label. -type ObservatoryPageTestRegion struct { - Label string `json:"label"` - // A test region. - Value ObservatoryPageTestRegionValue `json:"value"` - JSON observatoryPageTestRegionJSON `json:"-"` -} - -// observatoryPageTestRegionJSON contains the JSON metadata for the struct -// [ObservatoryPageTestRegion] -type observatoryPageTestRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ObservatoryPageTestRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r observatoryPageTestRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type ObservatoryPageTestRegionValue string - -const ( - ObservatoryPageTestRegionValueAsiaEast1 ObservatoryPageTestRegionValue = "asia-east1" - ObservatoryPageTestRegionValueAsiaNortheast1 ObservatoryPageTestRegionValue = "asia-northeast1" - ObservatoryPageTestRegionValueAsiaNortheast2 ObservatoryPageTestRegionValue = "asia-northeast2" - ObservatoryPageTestRegionValueAsiaSouth1 ObservatoryPageTestRegionValue = "asia-south1" - ObservatoryPageTestRegionValueAsiaSoutheast1 ObservatoryPageTestRegionValue = "asia-southeast1" - ObservatoryPageTestRegionValueAustraliaSoutheast1 ObservatoryPageTestRegionValue = "australia-southeast1" - ObservatoryPageTestRegionValueEuropeNorth1 ObservatoryPageTestRegionValue = "europe-north1" - ObservatoryPageTestRegionValueEuropeSouthwest1 ObservatoryPageTestRegionValue = "europe-southwest1" - ObservatoryPageTestRegionValueEuropeWest1 ObservatoryPageTestRegionValue = "europe-west1" - ObservatoryPageTestRegionValueEuropeWest2 ObservatoryPageTestRegionValue = "europe-west2" - ObservatoryPageTestRegionValueEuropeWest3 ObservatoryPageTestRegionValue = "europe-west3" - ObservatoryPageTestRegionValueEuropeWest4 ObservatoryPageTestRegionValue = "europe-west4" - ObservatoryPageTestRegionValueEuropeWest8 ObservatoryPageTestRegionValue = "europe-west8" - ObservatoryPageTestRegionValueEuropeWest9 ObservatoryPageTestRegionValue = "europe-west9" - ObservatoryPageTestRegionValueMeWest1 ObservatoryPageTestRegionValue = "me-west1" - ObservatoryPageTestRegionValueSouthamericaEast1 ObservatoryPageTestRegionValue = "southamerica-east1" - ObservatoryPageTestRegionValueUsCentral1 ObservatoryPageTestRegionValue = "us-central1" - ObservatoryPageTestRegionValueUsEast1 ObservatoryPageTestRegionValue = "us-east1" - ObservatoryPageTestRegionValueUsEast4 ObservatoryPageTestRegionValue = "us-east4" - ObservatoryPageTestRegionValueUsSouth1 ObservatoryPageTestRegionValue = "us-south1" - ObservatoryPageTestRegionValueUsWest1 ObservatoryPageTestRegionValue = "us-west1" -) - -func (r ObservatoryPageTestRegionValue) IsKnown() bool { - switch r { - case ObservatoryPageTestRegionValueAsiaEast1, ObservatoryPageTestRegionValueAsiaNortheast1, ObservatoryPageTestRegionValueAsiaNortheast2, ObservatoryPageTestRegionValueAsiaSouth1, ObservatoryPageTestRegionValueAsiaSoutheast1, ObservatoryPageTestRegionValueAustraliaSoutheast1, ObservatoryPageTestRegionValueEuropeNorth1, ObservatoryPageTestRegionValueEuropeSouthwest1, ObservatoryPageTestRegionValueEuropeWest1, ObservatoryPageTestRegionValueEuropeWest2, ObservatoryPageTestRegionValueEuropeWest3, ObservatoryPageTestRegionValueEuropeWest4, ObservatoryPageTestRegionValueEuropeWest8, ObservatoryPageTestRegionValueEuropeWest9, ObservatoryPageTestRegionValueMeWest1, ObservatoryPageTestRegionValueSouthamericaEast1, ObservatoryPageTestRegionValueUsCentral1, ObservatoryPageTestRegionValueUsEast1, ObservatoryPageTestRegionValueUsEast4, ObservatoryPageTestRegionValueUsSouth1, ObservatoryPageTestRegionValueUsWest1: - return true - } - return false -} - // The frequency of the test. -type ObservatoryPageTestScheduleFrequency string +type TestScheduleFrequency string const ( - ObservatoryPageTestScheduleFrequencyDaily ObservatoryPageTestScheduleFrequency = "DAILY" - ObservatoryPageTestScheduleFrequencyWeekly ObservatoryPageTestScheduleFrequency = "WEEKLY" + TestScheduleFrequencyDaily TestScheduleFrequency = "DAILY" + TestScheduleFrequencyWeekly TestScheduleFrequency = "WEEKLY" ) -func (r ObservatoryPageTestScheduleFrequency) IsKnown() bool { +func (r TestScheduleFrequency) IsKnown() bool { switch r { - case ObservatoryPageTestScheduleFrequencyDaily, ObservatoryPageTestScheduleFrequencyWeekly: + case TestScheduleFrequencyDaily, TestScheduleFrequencyWeekly: return true } return false } type TestListResponse struct { - Errors []TestListResponseError `json:"errors,required"` - Messages []TestListResponseMessage `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful. Success bool `json:"success,required"` ResultInfo TestListResponseResultInfo `json:"result_info"` @@ -494,52 +164,6 @@ func (r testListResponseJSON) RawJSON() string { return r.raw } -type TestListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON testListResponseErrorJSON `json:"-"` -} - -// testListResponseErrorJSON contains the JSON metadata for the struct -// [TestListResponseError] -type testListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TestListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r testListResponseErrorJSON) RawJSON() string { - return r.raw -} - -type TestListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON testListResponseMessageJSON `json:"-"` -} - -// testListResponseMessageJSON contains the JSON metadata for the struct -// [TestListResponseMessage] -type testListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TestListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r testListResponseMessageJSON) RawJSON() string { - return r.raw -} - type TestListResponseResultInfo struct { Count int64 `json:"count"` Page int64 `json:"page"` @@ -636,13 +260,19 @@ func (r TestNewParamsRegion) IsKnown() bool { } type TestNewResponseEnvelope struct { - Result ObservatoryPageTest `json:"result"` - JSON testNewResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result Test `json:"result"` + JSON testNewResponseEnvelopeJSON `json:"-"` } // testNewResponseEnvelopeJSON contains the JSON metadata for the struct // [TestNewResponseEnvelope] type testNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -668,7 +298,7 @@ type TestListParams struct { // URLQuery serializes [TestListParams]'s query parameters as `url.Values`. func (r TestListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -718,7 +348,7 @@ type TestDeleteParams struct { // URLQuery serializes [TestDeleteParams]'s query parameters as `url.Values`. func (r TestDeleteParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -759,13 +389,19 @@ func (r TestDeleteParamsRegion) IsKnown() bool { } type TestDeleteResponseEnvelope struct { - Result TestDeleteResponse `json:"result"` - JSON testDeleteResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result TestDeleteResponse `json:"result"` + JSON testDeleteResponseEnvelopeJSON `json:"-"` } // testDeleteResponseEnvelopeJSON contains the JSON metadata for the struct // [TestDeleteResponseEnvelope] type testDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field @@ -785,13 +421,19 @@ type TestGetParams struct { } type TestGetResponseEnvelope struct { - Result ObservatoryPageTest `json:"result"` - JSON testGetResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Success interface{} `json:"success,required"` + Result Test `json:"result"` + JSON testGetResponseEnvelopeJSON `json:"-"` } // testGetResponseEnvelopeJSON contains the JSON metadata for the struct // [TestGetResponseEnvelope] type testGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field Result apijson.Field raw string ExtraFields map[string]apijson.Field diff --git a/ssl/aliases.go b/ssl/aliases.go index b6a1f6ce363..936b9b2f36f 100644 --- a/ssl/aliases.go +++ b/ssl/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/ssl/analyze.go b/ssl/analyze.go index 4e49367edcb..a75c6056413 100644 --- a/ssl/analyze.go +++ b/ssl/analyze.go @@ -8,6 +8,7 @@ import ( "net/http" "reflect" + "github.com/cloudflare/cloudflare-go/v2/custom_hostnames" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" @@ -35,7 +36,7 @@ func NewAnalyzeService(opts ...option.RequestOption) (r *AnalyzeService) { // Returns the set of hostnames, the signature algorithm, and the expiration date // of the certificate. -func (r *AnalyzeService) New(ctx context.Context, params AnalyzeNewParams, opts ...option.RequestOption) (res *AnalyzeNewResponse, err error) { +func (r *AnalyzeService) New(ctx context.Context, params AnalyzeNewParams, opts ...option.RequestOption) (res *AnalyzeNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AnalyzeNewResponseEnvelope path := fmt.Sprintf("zones/%s/ssl/analyze", params.ZoneID) @@ -48,13 +49,13 @@ func (r *AnalyzeService) New(ctx context.Context, params AnalyzeNewParams, opts } // Union satisfied by [ssl.AnalyzeNewResponseUnknown] or [shared.UnionString]. -type AnalyzeNewResponse interface { - ImplementsSSLAnalyzeNewResponse() +type AnalyzeNewResponseUnion interface { + ImplementsSSLAnalyzeNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AnalyzeNewResponse)(nil)).Elem(), + reflect.TypeOf((*AnalyzeNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -70,7 +71,7 @@ type AnalyzeNewParams struct { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod param.Field[AnalyzeNewParamsBundleMethod] `json:"bundle_method"` + BundleMethod param.Field[custom_hostnames.BundleMethod] `json:"bundle_method"` // The zone's SSL certificate or certificate and the intermediate(s). Certificate param.Field[string] `json:"certificate"` } @@ -79,30 +80,10 @@ func (r AnalyzeNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type AnalyzeNewParamsBundleMethod string - -const ( - AnalyzeNewParamsBundleMethodUbiquitous AnalyzeNewParamsBundleMethod = "ubiquitous" - AnalyzeNewParamsBundleMethodOptimal AnalyzeNewParamsBundleMethod = "optimal" - AnalyzeNewParamsBundleMethodForce AnalyzeNewParamsBundleMethod = "force" -) - -func (r AnalyzeNewParamsBundleMethod) IsKnown() bool { - switch r { - case AnalyzeNewParamsBundleMethodUbiquitous, AnalyzeNewParamsBundleMethodOptimal, AnalyzeNewParamsBundleMethodForce: - return true - } - return false -} - type AnalyzeNewResponseEnvelope struct { - Errors []AnalyzeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyzeNewResponseEnvelopeMessages `json:"messages,required"` - Result AnalyzeNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AnalyzeNewResponseUnion `json:"result,required"` // Whether the API call was successful Success AnalyzeNewResponseEnvelopeSuccess `json:"success,required"` JSON analyzeNewResponseEnvelopeJSON `json:"-"` @@ -127,52 +108,6 @@ func (r analyzeNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyzeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyzeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyzeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AnalyzeNewResponseEnvelopeErrors] -type analyzeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyzeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyzeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyzeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyzeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyzeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [AnalyzeNewResponseEnvelopeMessages] -type analyzeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyzeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyzeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyzeNewResponseEnvelopeSuccess bool diff --git a/ssl/analyze_test.go b/ssl/analyze_test.go index b534bd0966b..85029b4549b 100644 --- a/ssl/analyze_test.go +++ b/ssl/analyze_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go/v2" + "github.com/cloudflare/cloudflare-go/v2/custom_hostnames" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" "github.com/cloudflare/cloudflare-go/v2/option" "github.com/cloudflare/cloudflare-go/v2/ssl" @@ -30,7 +31,7 @@ func TestAnalyzeNewWithOptionalParams(t *testing.T) { ) _, err := client.SSL.Analyze.New(context.TODO(), ssl.AnalyzeNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - BundleMethod: cloudflare.F(ssl.AnalyzeNewParamsBundleMethodUbiquitous), + BundleMethod: cloudflare.F(custom_hostnames.BundleMethodUbiquitous), Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), }) if err != nil { diff --git a/ssl/certificatepack.go b/ssl/certificatepack.go index cf07b3bf7df..ce48fca68fc 100644 --- a/ssl/certificatepack.go +++ b/ssl/certificatepack.go @@ -65,10 +65,10 @@ func (r *CertificatePackService) ListAutoPaging(ctx context.Context, params Cert } // For a given zone, delete an advanced certificate pack. -func (r *CertificatePackService) Delete(ctx context.Context, certificatePackID string, body CertificatePackDeleteParams, opts ...option.RequestOption) (res *CertificatePackDeleteResponse, err error) { +func (r *CertificatePackService) Delete(ctx context.Context, certificatePackID string, params CertificatePackDeleteParams, opts ...option.RequestOption) (res *CertificatePackDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env CertificatePackDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", body.ZoneID, certificatePackID) + path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", params.ZoneID, certificatePackID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -80,10 +80,10 @@ func (r *CertificatePackService) Delete(ctx context.Context, certificatePackID s // For a given zone, restart validation for an advanced certificate pack. This is // only a validation operation for a Certificate Pack in a validation_timed_out // status. -func (r *CertificatePackService) Edit(ctx context.Context, certificatePackID string, body CertificatePackEditParams, opts ...option.RequestOption) (res *CertificatePackEditResponse, err error) { +func (r *CertificatePackService) Edit(ctx context.Context, certificatePackID string, params CertificatePackEditParams, opts ...option.RequestOption) (res *CertificatePackEditResponse, err error) { opts = append(r.Options[:], opts...) var env CertificatePackEditResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", body.ZoneID, certificatePackID) + path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", params.ZoneID, certificatePackID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) if err != nil { return @@ -93,7 +93,7 @@ func (r *CertificatePackService) Edit(ctx context.Context, certificatePackID str } // For a given zone, get a certificate pack. -func (r *CertificatePackService) Get(ctx context.Context, certificatePackID string, query CertificatePackGetParams, opts ...option.RequestOption) (res *CertificatePackGetResponse, err error) { +func (r *CertificatePackService) Get(ctx context.Context, certificatePackID string, query CertificatePackGetParams, opts ...option.RequestOption) (res *CertificatePackGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CertificatePackGetResponseEnvelope path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", query.ZoneID, certificatePackID) @@ -105,6 +105,10 @@ func (r *CertificatePackService) Get(ctx context.Context, certificatePackID stri return } +type Host = string + +type HostParam = string + type CertificatePackListResponse = interface{} type CertificatePackDeleteResponse struct { @@ -141,7 +145,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 []string `json:"hosts"` + Hosts []Host `json:"hosts"` // Status of certificate pack. Status CertificatePackEditResponseStatus `json:"status"` // Type of certificate pack. @@ -281,13 +285,13 @@ func (r CertificatePackEditResponseValidityDays) IsKnown() bool { // Union satisfied by [ssl.CertificatePackGetResponseUnknown] or // [shared.UnionString]. -type CertificatePackGetResponse interface { - ImplementsSSLCertificatePackGetResponse() +type CertificatePackGetResponseUnion interface { + ImplementsSSLCertificatePackGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CertificatePackGetResponse)(nil)).Elem(), + reflect.TypeOf((*CertificatePackGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -307,7 +311,7 @@ type CertificatePackListParams struct { // `url.Values`. func (r CertificatePackListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -330,12 +334,17 @@ func (r CertificatePackListParamsStatus) IsKnown() bool { type CertificatePackDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CertificatePackDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CertificatePackDeleteResponseEnvelope struct { - Errors []CertificatePackDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CertificatePackDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CertificatePackDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CertificatePackDeleteResponse `json:"result,required"` // Whether the API call was successful Success CertificatePackDeleteResponseEnvelopeSuccess `json:"success,required"` JSON certificatePackDeleteResponseEnvelopeJSON `json:"-"` @@ -360,52 +369,6 @@ func (r certificatePackDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CertificatePackDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// certificatePackDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CertificatePackDeleteResponseEnvelopeErrors] -type certificatePackDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CertificatePackDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// certificatePackDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CertificatePackDeleteResponseEnvelopeMessages] -type certificatePackDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CertificatePackDeleteResponseEnvelopeSuccess bool @@ -424,12 +387,17 @@ func (r CertificatePackDeleteResponseEnvelopeSuccess) IsKnown() bool { type CertificatePackEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CertificatePackEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CertificatePackEditResponseEnvelope struct { - Errors []CertificatePackEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CertificatePackEditResponseEnvelopeMessages `json:"messages,required"` - Result CertificatePackEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CertificatePackEditResponse `json:"result,required"` // Whether the API call was successful Success CertificatePackEditResponseEnvelopeSuccess `json:"success,required"` JSON certificatePackEditResponseEnvelopeJSON `json:"-"` @@ -454,52 +422,6 @@ func (r certificatePackEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CertificatePackEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// certificatePackEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CertificatePackEditResponseEnvelopeErrors] -type certificatePackEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CertificatePackEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// certificatePackEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CertificatePackEditResponseEnvelopeMessages] -type certificatePackEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CertificatePackEditResponseEnvelopeSuccess bool @@ -521,9 +443,9 @@ type CertificatePackGetParams struct { } type CertificatePackGetResponseEnvelope struct { - Errors []CertificatePackGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CertificatePackGetResponseEnvelopeMessages `json:"messages,required"` - Result CertificatePackGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CertificatePackGetResponseUnion `json:"result,required"` // Whether the API call was successful Success CertificatePackGetResponseEnvelopeSuccess `json:"success,required"` JSON certificatePackGetResponseEnvelopeJSON `json:"-"` @@ -548,52 +470,6 @@ func (r certificatePackGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CertificatePackGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// certificatePackGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CertificatePackGetResponseEnvelopeErrors] -type certificatePackGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CertificatePackGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// certificatePackGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CertificatePackGetResponseEnvelopeMessages] -type certificatePackGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CertificatePackGetResponseEnvelopeSuccess bool diff --git a/ssl/certificatepack_test.go b/ssl/certificatepack_test.go index 85946ef020e..b4b22045431 100644 --- a/ssl/certificatepack_test.go +++ b/ssl/certificatepack_test.go @@ -60,6 +60,7 @@ func TestCertificatePackDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", ssl.CertificatePackDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -90,6 +91,7 @@ func TestCertificatePackEdit(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", ssl.CertificatePackEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/ssl/certificatepackorder.go b/ssl/certificatepackorder.go index 8ecdab9636f..7a2d6c53930 100644 --- a/ssl/certificatepackorder.go +++ b/ssl/certificatepackorder.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -56,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 []string `json:"hosts"` + Hosts []Host `json:"hosts"` // Status of certificate pack. Status CertificatePackOrderNewResponseStatus `json:"status"` // Type of certificate pack. @@ -203,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[[]string] `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. @@ -288,9 +289,9 @@ func (r CertificatePackOrderNewParamsValidityDays) IsKnown() bool { } type CertificatePackOrderNewResponseEnvelope struct { - Errors []CertificatePackOrderNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CertificatePackOrderNewResponseEnvelopeMessages `json:"messages,required"` - Result CertificatePackOrderNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CertificatePackOrderNewResponse `json:"result,required"` // Whether the API call was successful Success CertificatePackOrderNewResponseEnvelopeSuccess `json:"success,required"` JSON certificatePackOrderNewResponseEnvelopeJSON `json:"-"` @@ -315,52 +316,6 @@ func (r certificatePackOrderNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CertificatePackOrderNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackOrderNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// certificatePackOrderNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CertificatePackOrderNewResponseEnvelopeErrors] -type certificatePackOrderNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackOrderNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackOrderNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CertificatePackOrderNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackOrderNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// certificatePackOrderNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CertificatePackOrderNewResponseEnvelopeMessages] -type certificatePackOrderNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackOrderNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackOrderNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CertificatePackOrderNewResponseEnvelopeSuccess bool diff --git a/ssl/certificatepackorder_test.go b/ssl/certificatepackorder_test.go index 5309a9e689a..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([]string{"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/ssl/certificatepackquota.go b/ssl/certificatepackquota.go index 873c747e4b3..3f4f44cc9fc 100644 --- a/ssl/certificatepackquota.go +++ b/ssl/certificatepackquota.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -96,9 +97,9 @@ type CertificatePackQuotaGetParams struct { } type CertificatePackQuotaGetResponseEnvelope struct { - Errors []CertificatePackQuotaGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CertificatePackQuotaGetResponseEnvelopeMessages `json:"messages,required"` - Result CertificatePackQuotaGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CertificatePackQuotaGetResponse `json:"result,required"` // Whether the API call was successful Success CertificatePackQuotaGetResponseEnvelopeSuccess `json:"success,required"` JSON certificatePackQuotaGetResponseEnvelopeJSON `json:"-"` @@ -123,52 +124,6 @@ func (r certificatePackQuotaGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CertificatePackQuotaGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackQuotaGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// certificatePackQuotaGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CertificatePackQuotaGetResponseEnvelopeErrors] -type certificatePackQuotaGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackQuotaGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackQuotaGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CertificatePackQuotaGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificatePackQuotaGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// certificatePackQuotaGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CertificatePackQuotaGetResponseEnvelopeMessages] -type certificatePackQuotaGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificatePackQuotaGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificatePackQuotaGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CertificatePackQuotaGetResponseEnvelopeSuccess bool diff --git a/ssl/recommendation.go b/ssl/recommendation.go index c7b9e802764..9bdbed3b4c4 100644 --- a/ssl/recommendation.go +++ b/ssl/recommendation.go @@ -10,6 +10,7 @@ import ( "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" ) @@ -87,9 +88,9 @@ func (r RecommendationGetResponseValue) IsKnown() bool { } type RecommendationGetResponseEnvelope struct { - Errors []RecommendationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RecommendationGetResponseEnvelopeMessages `json:"messages,required"` - Result RecommendationGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RecommendationGetResponse `json:"result,required,nullable"` // Whether the API call was successful Success RecommendationGetResponseEnvelopeSuccess `json:"success,required"` JSON recommendationGetResponseEnvelopeJSON `json:"-"` @@ -114,52 +115,6 @@ func (r recommendationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RecommendationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recommendationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// recommendationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RecommendationGetResponseEnvelopeErrors] -type recommendationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecommendationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recommendationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RecommendationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON recommendationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// recommendationGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RecommendationGetResponseEnvelopeMessages] -type recommendationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RecommendationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r recommendationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RecommendationGetResponseEnvelopeSuccess bool diff --git a/ssl/universalsetting.go b/ssl/universalsetting.go index 25de2669090..680b55681c8 100644 --- a/ssl/universalsetting.go +++ b/ssl/universalsetting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -103,9 +104,7 @@ func (r universalSSLSettingsJSON) RawJSON() string { return r.raw } -type UniversalSettingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` +type UniversalSSLSettingsParam struct { // Disabling Universal SSL removes any currently active Universal SSL certificates // for your zone from the edge and prevents any future Universal SSL certificates // from being ordered. If there are no advanced certificates or custom certificates @@ -134,14 +133,24 @@ type UniversalSettingEditParams struct { Enabled param.Field[bool] `json:"enabled"` } -func (r UniversalSettingEditParams) MarshalJSON() (data []byte, err error) { +func (r UniversalSSLSettingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +type UniversalSettingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + UniversalSSLSettings UniversalSSLSettingsParam `json:"universal_ssl_settings,required"` +} + +func (r UniversalSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.UniversalSSLSettings) +} + type UniversalSettingEditResponseEnvelope struct { - Errors []UniversalSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []UniversalSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result UniversalSSLSettings `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UniversalSSLSettings `json:"result,required"` // Whether the API call was successful Success UniversalSettingEditResponseEnvelopeSuccess `json:"success,required"` JSON universalSettingEditResponseEnvelopeJSON `json:"-"` @@ -166,52 +175,6 @@ func (r universalSettingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UniversalSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON universalSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// universalSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UniversalSettingEditResponseEnvelopeErrors] -type universalSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UniversalSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r universalSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UniversalSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON universalSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// universalSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UniversalSettingEditResponseEnvelopeMessages] -type universalSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UniversalSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r universalSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UniversalSettingEditResponseEnvelopeSuccess bool @@ -233,9 +196,9 @@ type UniversalSettingGetParams struct { } type UniversalSettingGetResponseEnvelope struct { - Errors []UniversalSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UniversalSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result UniversalSSLSettings `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UniversalSSLSettings `json:"result,required"` // Whether the API call was successful Success UniversalSettingGetResponseEnvelopeSuccess `json:"success,required"` JSON universalSettingGetResponseEnvelopeJSON `json:"-"` @@ -260,52 +223,6 @@ func (r universalSettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UniversalSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON universalSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// universalSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UniversalSettingGetResponseEnvelopeErrors] -type universalSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UniversalSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r universalSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UniversalSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON universalSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// universalSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UniversalSettingGetResponseEnvelopeMessages] -type universalSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UniversalSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r universalSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UniversalSettingGetResponseEnvelopeSuccess bool diff --git a/ssl/universalsetting_test.go b/ssl/universalsetting_test.go index 9497bac7a29..75145922e9d 100644 --- a/ssl/universalsetting_test.go +++ b/ssl/universalsetting_test.go @@ -29,8 +29,10 @@ func TestUniversalSettingEditWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.SSL.Universal.Settings.Edit(context.TODO(), ssl.UniversalSettingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + UniversalSSLSettings: ssl.UniversalSSLSettingsParam{ + Enabled: cloudflare.F(true), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/ssl/verification.go b/ssl/verification.go index 7f0eb046647..26679480537 100644 --- a/ssl/verification.go +++ b/ssl/verification.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -50,7 +51,7 @@ func (r *VerificationService) Edit(ctx context.Context, certificatePackID string } // Get SSL Verification Info for a Zone. -func (r *VerificationService) Get(ctx context.Context, params VerificationGetParams, opts ...option.RequestOption) (res *[]TLSVerificationSetting, err error) { +func (r *VerificationService) Get(ctx context.Context, params VerificationGetParams, opts ...option.RequestOption) (res *[]Verification, err error) { opts = append(r.Options[:], opts...) var env VerificationGetResponseEnvelope path := fmt.Sprintf("zones/%s/ssl/verification", params.ZoneID) @@ -62,30 +63,29 @@ func (r *VerificationService) Get(ctx context.Context, params VerificationGetPar return } -type TLSVerificationSetting struct { +type Verification struct { // Current status of certificate. - CertificateStatus TLSVerificationSettingCertificateStatus `json:"certificate_status,required"` + CertificateStatus VerificationCertificateStatus `json:"certificate_status,required"` // Certificate Authority is manually reviewing the order. BrandCheck bool `json:"brand_check"` // Certificate Pack UUID. CERTPackUUID string `json:"cert_pack_uuid"` // Certificate's signature algorithm. - Signature TLSVerificationSettingSignature `json:"signature"` + Signature VerificationSignature `json:"signature"` // Validation method in use for a certificate pack order. - ValidationMethod TLSVerificationSettingValidationMethod `json:"validation_method"` + ValidationMethod VerificationValidationMethod `json:"validation_method"` // Certificate's required verification information. - VerificationInfo TLSVerificationSettingVerificationInfo `json:"verification_info"` + VerificationInfo VerificationVerificationInfo `json:"verification_info"` // Status of the required verification information, omitted if verification status // is unknown. VerificationStatus bool `json:"verification_status"` // Method of verification. - VerificationType TLSVerificationSettingVerificationType `json:"verification_type"` - JSON tlsVerificationSettingJSON `json:"-"` + VerificationType VerificationVerificationType `json:"verification_type"` + JSON verificationJSON `json:"-"` } -// tlsVerificationSettingJSON contains the JSON metadata for the struct -// [TLSVerificationSetting] -type tlsVerificationSettingJSON struct { +// verificationJSON contains the JSON metadata for the struct [Verification] +type verificationJSON struct { CertificateStatus apijson.Field BrandCheck apijson.Field CERTPackUUID apijson.Field @@ -98,142 +98,142 @@ type tlsVerificationSettingJSON struct { ExtraFields map[string]apijson.Field } -func (r *TLSVerificationSetting) UnmarshalJSON(data []byte) (err error) { +func (r *Verification) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tlsVerificationSettingJSON) RawJSON() string { +func (r verificationJSON) RawJSON() string { return r.raw } // Current status of certificate. -type TLSVerificationSettingCertificateStatus string +type VerificationCertificateStatus string const ( - TLSVerificationSettingCertificateStatusInitializing TLSVerificationSettingCertificateStatus = "initializing" - TLSVerificationSettingCertificateStatusAuthorizing TLSVerificationSettingCertificateStatus = "authorizing" - TLSVerificationSettingCertificateStatusActive TLSVerificationSettingCertificateStatus = "active" - TLSVerificationSettingCertificateStatusExpired TLSVerificationSettingCertificateStatus = "expired" - TLSVerificationSettingCertificateStatusIssuing TLSVerificationSettingCertificateStatus = "issuing" - TLSVerificationSettingCertificateStatusTimingOut TLSVerificationSettingCertificateStatus = "timing_out" - TLSVerificationSettingCertificateStatusPendingDeployment TLSVerificationSettingCertificateStatus = "pending_deployment" + VerificationCertificateStatusInitializing VerificationCertificateStatus = "initializing" + VerificationCertificateStatusAuthorizing VerificationCertificateStatus = "authorizing" + VerificationCertificateStatusActive VerificationCertificateStatus = "active" + VerificationCertificateStatusExpired VerificationCertificateStatus = "expired" + VerificationCertificateStatusIssuing VerificationCertificateStatus = "issuing" + VerificationCertificateStatusTimingOut VerificationCertificateStatus = "timing_out" + VerificationCertificateStatusPendingDeployment VerificationCertificateStatus = "pending_deployment" ) -func (r TLSVerificationSettingCertificateStatus) IsKnown() bool { +func (r VerificationCertificateStatus) IsKnown() bool { switch r { - case TLSVerificationSettingCertificateStatusInitializing, TLSVerificationSettingCertificateStatusAuthorizing, TLSVerificationSettingCertificateStatusActive, TLSVerificationSettingCertificateStatusExpired, TLSVerificationSettingCertificateStatusIssuing, TLSVerificationSettingCertificateStatusTimingOut, TLSVerificationSettingCertificateStatusPendingDeployment: + case VerificationCertificateStatusInitializing, VerificationCertificateStatusAuthorizing, VerificationCertificateStatusActive, VerificationCertificateStatusExpired, VerificationCertificateStatusIssuing, VerificationCertificateStatusTimingOut, VerificationCertificateStatusPendingDeployment: return true } return false } // Certificate's signature algorithm. -type TLSVerificationSettingSignature string +type VerificationSignature string const ( - TLSVerificationSettingSignatureEcdsaWithSha256 TLSVerificationSettingSignature = "ECDSAWithSHA256" - TLSVerificationSettingSignatureSha1WithRsa TLSVerificationSettingSignature = "SHA1WithRSA" - TLSVerificationSettingSignatureSha256WithRsa TLSVerificationSettingSignature = "SHA256WithRSA" + VerificationSignatureEcdsaWithSha256 VerificationSignature = "ECDSAWithSHA256" + VerificationSignatureSha1WithRsa VerificationSignature = "SHA1WithRSA" + VerificationSignatureSha256WithRsa VerificationSignature = "SHA256WithRSA" ) -func (r TLSVerificationSettingSignature) IsKnown() bool { +func (r VerificationSignature) IsKnown() bool { switch r { - case TLSVerificationSettingSignatureEcdsaWithSha256, TLSVerificationSettingSignatureSha1WithRsa, TLSVerificationSettingSignatureSha256WithRsa: + case VerificationSignatureEcdsaWithSha256, VerificationSignatureSha1WithRsa, VerificationSignatureSha256WithRsa: return true } return false } // Validation method in use for a certificate pack order. -type TLSVerificationSettingValidationMethod string +type VerificationValidationMethod string const ( - TLSVerificationSettingValidationMethodHTTP TLSVerificationSettingValidationMethod = "http" - TLSVerificationSettingValidationMethodCNAME TLSVerificationSettingValidationMethod = "cname" - TLSVerificationSettingValidationMethodTXT TLSVerificationSettingValidationMethod = "txt" + VerificationValidationMethodHTTP VerificationValidationMethod = "http" + VerificationValidationMethodCNAME VerificationValidationMethod = "cname" + VerificationValidationMethodTXT VerificationValidationMethod = "txt" ) -func (r TLSVerificationSettingValidationMethod) IsKnown() bool { +func (r VerificationValidationMethod) IsKnown() bool { switch r { - case TLSVerificationSettingValidationMethodHTTP, TLSVerificationSettingValidationMethodCNAME, TLSVerificationSettingValidationMethodTXT: + case VerificationValidationMethodHTTP, VerificationValidationMethodCNAME, VerificationValidationMethodTXT: return true } return false } // Certificate's required verification information. -type TLSVerificationSettingVerificationInfo struct { +type VerificationVerificationInfo struct { // Name of CNAME record. - RecordName TLSVerificationSettingVerificationInfoRecordName `json:"record_name"` + RecordName VerificationVerificationInfoRecordName `json:"record_name"` // Target of CNAME record. - RecordTarget TLSVerificationSettingVerificationInfoRecordTarget `json:"record_target"` - JSON tlsVerificationSettingVerificationInfoJSON `json:"-"` + RecordTarget VerificationVerificationInfoRecordTarget `json:"record_target"` + JSON verificationVerificationInfoJSON `json:"-"` } -// tlsVerificationSettingVerificationInfoJSON contains the JSON metadata for the -// struct [TLSVerificationSettingVerificationInfo] -type tlsVerificationSettingVerificationInfoJSON struct { +// verificationVerificationInfoJSON contains the JSON metadata for the struct +// [VerificationVerificationInfo] +type verificationVerificationInfoJSON struct { RecordName apijson.Field RecordTarget apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *TLSVerificationSettingVerificationInfo) UnmarshalJSON(data []byte) (err error) { +func (r *VerificationVerificationInfo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tlsVerificationSettingVerificationInfoJSON) RawJSON() string { +func (r verificationVerificationInfoJSON) RawJSON() string { return r.raw } // Name of CNAME record. -type TLSVerificationSettingVerificationInfoRecordName string +type VerificationVerificationInfoRecordName string const ( - TLSVerificationSettingVerificationInfoRecordNameRecordName TLSVerificationSettingVerificationInfoRecordName = "record_name" - TLSVerificationSettingVerificationInfoRecordNameHTTPURL TLSVerificationSettingVerificationInfoRecordName = "http_url" - TLSVerificationSettingVerificationInfoRecordNameCNAME TLSVerificationSettingVerificationInfoRecordName = "cname" - TLSVerificationSettingVerificationInfoRecordNameTXTName TLSVerificationSettingVerificationInfoRecordName = "txt_name" + VerificationVerificationInfoRecordNameRecordName VerificationVerificationInfoRecordName = "record_name" + VerificationVerificationInfoRecordNameHTTPURL VerificationVerificationInfoRecordName = "http_url" + VerificationVerificationInfoRecordNameCNAME VerificationVerificationInfoRecordName = "cname" + VerificationVerificationInfoRecordNameTXTName VerificationVerificationInfoRecordName = "txt_name" ) -func (r TLSVerificationSettingVerificationInfoRecordName) IsKnown() bool { +func (r VerificationVerificationInfoRecordName) IsKnown() bool { switch r { - case TLSVerificationSettingVerificationInfoRecordNameRecordName, TLSVerificationSettingVerificationInfoRecordNameHTTPURL, TLSVerificationSettingVerificationInfoRecordNameCNAME, TLSVerificationSettingVerificationInfoRecordNameTXTName: + case VerificationVerificationInfoRecordNameRecordName, VerificationVerificationInfoRecordNameHTTPURL, VerificationVerificationInfoRecordNameCNAME, VerificationVerificationInfoRecordNameTXTName: return true } return false } // Target of CNAME record. -type TLSVerificationSettingVerificationInfoRecordTarget string +type VerificationVerificationInfoRecordTarget string const ( - TLSVerificationSettingVerificationInfoRecordTargetRecordValue TLSVerificationSettingVerificationInfoRecordTarget = "record_value" - TLSVerificationSettingVerificationInfoRecordTargetHTTPBody TLSVerificationSettingVerificationInfoRecordTarget = "http_body" - TLSVerificationSettingVerificationInfoRecordTargetCNAMETarget TLSVerificationSettingVerificationInfoRecordTarget = "cname_target" - TLSVerificationSettingVerificationInfoRecordTargetTXTValue TLSVerificationSettingVerificationInfoRecordTarget = "txt_value" + VerificationVerificationInfoRecordTargetRecordValue VerificationVerificationInfoRecordTarget = "record_value" + VerificationVerificationInfoRecordTargetHTTPBody VerificationVerificationInfoRecordTarget = "http_body" + VerificationVerificationInfoRecordTargetCNAMETarget VerificationVerificationInfoRecordTarget = "cname_target" + VerificationVerificationInfoRecordTargetTXTValue VerificationVerificationInfoRecordTarget = "txt_value" ) -func (r TLSVerificationSettingVerificationInfoRecordTarget) IsKnown() bool { +func (r VerificationVerificationInfoRecordTarget) IsKnown() bool { switch r { - case TLSVerificationSettingVerificationInfoRecordTargetRecordValue, TLSVerificationSettingVerificationInfoRecordTargetHTTPBody, TLSVerificationSettingVerificationInfoRecordTargetCNAMETarget, TLSVerificationSettingVerificationInfoRecordTargetTXTValue: + case VerificationVerificationInfoRecordTargetRecordValue, VerificationVerificationInfoRecordTargetHTTPBody, VerificationVerificationInfoRecordTargetCNAMETarget, VerificationVerificationInfoRecordTargetTXTValue: return true } return false } // Method of verification. -type TLSVerificationSettingVerificationType string +type VerificationVerificationType string const ( - TLSVerificationSettingVerificationTypeCNAME TLSVerificationSettingVerificationType = "cname" - TLSVerificationSettingVerificationTypeMetaTag TLSVerificationSettingVerificationType = "meta tag" + VerificationVerificationTypeCNAME VerificationVerificationType = "cname" + VerificationVerificationTypeMetaTag VerificationVerificationType = "meta tag" ) -func (r TLSVerificationSettingVerificationType) IsKnown() bool { +func (r VerificationVerificationType) IsKnown() bool { switch r { - case TLSVerificationSettingVerificationTypeCNAME, TLSVerificationSettingVerificationTypeMetaTag: + case VerificationVerificationTypeCNAME, VerificationVerificationTypeMetaTag: return true } return false @@ -312,9 +312,9 @@ func (r VerificationEditParamsValidationMethod) IsKnown() bool { } type VerificationEditResponseEnvelope struct { - Errors []VerificationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []VerificationEditResponseEnvelopeMessages `json:"messages,required"` - Result VerificationEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result VerificationEditResponse `json:"result,required"` // Whether the API call was successful Success VerificationEditResponseEnvelopeSuccess `json:"success,required"` JSON verificationEditResponseEnvelopeJSON `json:"-"` @@ -339,52 +339,6 @@ func (r verificationEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type VerificationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON verificationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// verificationEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [VerificationEditResponseEnvelopeErrors] -type verificationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VerificationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r verificationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VerificationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON verificationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// verificationEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [VerificationEditResponseEnvelopeMessages] -type verificationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VerificationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r verificationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type VerificationEditResponseEnvelopeSuccess bool @@ -410,7 +364,7 @@ type VerificationGetParams struct { // URLQuery serializes [VerificationGetParams]'s query parameters as `url.Values`. func (r VerificationGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -431,7 +385,7 @@ func (r VerificationGetParamsRetry) IsKnown() bool { } type VerificationGetResponseEnvelope struct { - Result []TLSVerificationSetting `json:"result"` + Result []Verification `json:"result"` JSON verificationGetResponseEnvelopeJSON `json:"-"` } diff --git a/storage/aliases.go b/storage/aliases.go index 260a2194927..78d52af3864 100644 --- a/storage/aliases.go +++ b/storage/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/storage/analytics.go b/storage/analytics.go index 44bf39dd574..f499ba582ac 100644 --- a/storage/analytics.go +++ b/storage/analytics.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -34,7 +35,7 @@ func NewAnalyticsService(opts ...option.RequestOption) (r *AnalyticsService) { } // Retrieves Workers KV request metrics for the given account. -func (r *AnalyticsService) List(ctx context.Context, params AnalyticsListParams, opts ...option.RequestOption) (res *WorkersKVSchemasResult, err error) { +func (r *AnalyticsService) List(ctx context.Context, params AnalyticsListParams, opts ...option.RequestOption) (res *Schema, err error) { opts = append(r.Options[:], opts...) var env AnalyticsListResponseEnvelope path := fmt.Sprintf("accounts/%s/storage/analytics", params.AccountID) @@ -47,7 +48,7 @@ func (r *AnalyticsService) List(ctx context.Context, params AnalyticsListParams, } // Retrieves Workers KV stored data metrics for the given account. -func (r *AnalyticsService) Stored(ctx context.Context, params AnalyticsStoredParams, opts ...option.RequestOption) (res *WorkersKVComponentsSchemasResult, err error) { +func (r *AnalyticsService) Stored(ctx context.Context, params AnalyticsStoredParams, opts ...option.RequestOption) (res *Components, err error) { opts = append(r.Options[:], opts...) var env AnalyticsStoredResponseEnvelope path := fmt.Sprintf("accounts/%s/storage/analytics/stored", params.AccountID) @@ -60,8 +61,8 @@ func (r *AnalyticsService) Stored(ctx context.Context, params AnalyticsStoredPar } // Metrics on Workers KV requests. -type WorkersKVComponentsSchemasResult struct { - Data []WorkersKVComponentsSchemasResultData `json:"data,required,nullable"` +type Components struct { + Data []ComponentsData `json:"data,required,nullable"` // Number of seconds between current time and last processed event, i.e. how many // seconds of data could be missing. DataLag float64 `json:"data_lag,required"` @@ -70,17 +71,16 @@ type WorkersKVComponentsSchemasResult struct { // Minimum results for each metric. Min interface{} `json:"min,required"` // For specifying result metrics. - Query WorkersKVComponentsSchemasResultQuery `json:"query,required"` + Query ComponentsQuery `json:"query,required"` // Total number of rows in the result. Rows float64 `json:"rows,required"` // Total results for metrics across all data. - Totals interface{} `json:"totals,required"` - JSON workersKVComponentsSchemasResultJSON `json:"-"` + Totals interface{} `json:"totals,required"` + JSON componentsJSON `json:"-"` } -// workersKVComponentsSchemasResultJSON contains the JSON metadata for the struct -// [WorkersKVComponentsSchemasResult] -type workersKVComponentsSchemasResultJSON struct { +// componentsJSON contains the JSON metadata for the struct [Components] +type componentsJSON struct { Data apijson.Field DataLag apijson.Field Max apijson.Field @@ -92,38 +92,37 @@ type workersKVComponentsSchemasResultJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersKVComponentsSchemasResult) UnmarshalJSON(data []byte) (err error) { +func (r *Components) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVComponentsSchemasResultJSON) RawJSON() string { +func (r componentsJSON) RawJSON() string { return r.raw } -type WorkersKVComponentsSchemasResultData struct { +type ComponentsData struct { // List of metrics returned by the query. - Metrics []interface{} `json:"metrics,required"` - JSON workersKVComponentsSchemasResultDataJSON `json:"-"` + Metrics []interface{} `json:"metrics,required"` + JSON componentsDataJSON `json:"-"` } -// workersKVComponentsSchemasResultDataJSON contains the JSON metadata for the -// struct [WorkersKVComponentsSchemasResultData] -type workersKVComponentsSchemasResultDataJSON struct { +// componentsDataJSON contains the JSON metadata for the struct [ComponentsData] +type componentsDataJSON struct { Metrics apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *WorkersKVComponentsSchemasResultData) UnmarshalJSON(data []byte) (err error) { +func (r *ComponentsData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVComponentsSchemasResultDataJSON) RawJSON() string { +func (r componentsDataJSON) RawJSON() string { return r.raw } // For specifying result metrics. -type WorkersKVComponentsSchemasResultQuery struct { +type ComponentsQuery struct { // Can be used to break down the data by given attributes. Dimensions []string `json:"dimensions"` // Used to filter rows by one or more dimensions. Filters can be combined using OR @@ -152,13 +151,12 @@ type WorkersKVComponentsSchemasResultQuery struct { // by - (descending) or + (ascending). Sort []interface{} `json:"sort"` // End of time interval to query, defaults to current time. - Until time.Time `json:"until" format:"date-time"` - JSON workersKVComponentsSchemasResultQueryJSON `json:"-"` + Until time.Time `json:"until" format:"date-time"` + JSON componentsQueryJSON `json:"-"` } -// workersKVComponentsSchemasResultQueryJSON contains the JSON metadata for the -// struct [WorkersKVComponentsSchemasResultQuery] -type workersKVComponentsSchemasResultQueryJSON struct { +// componentsQueryJSON contains the JSON metadata for the struct [ComponentsQuery] +type componentsQueryJSON struct { Dimensions apijson.Field Filters apijson.Field Limit apijson.Field @@ -170,17 +168,17 @@ type workersKVComponentsSchemasResultQueryJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersKVComponentsSchemasResultQuery) UnmarshalJSON(data []byte) (err error) { +func (r *ComponentsQuery) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVComponentsSchemasResultQueryJSON) RawJSON() string { +func (r componentsQueryJSON) RawJSON() string { return r.raw } // Metrics on Workers KV requests. -type WorkersKVSchemasResult struct { - Data []WorkersKVSchemasResultData `json:"data,required,nullable"` +type Schema struct { + Data []SchemaData `json:"data,required,nullable"` // Number of seconds between current time and last processed event, i.e. how many // seconds of data could be missing. DataLag float64 `json:"data_lag,required"` @@ -189,17 +187,16 @@ type WorkersKVSchemasResult struct { // Minimum results for each metric. Min interface{} `json:"min,required"` // For specifying result metrics. - Query WorkersKVSchemasResultQuery `json:"query,required"` + Query SchemaQuery `json:"query,required"` // Total number of rows in the result. Rows float64 `json:"rows,required"` // Total results for metrics across all data. - Totals interface{} `json:"totals,required"` - JSON workersKVSchemasResultJSON `json:"-"` + Totals interface{} `json:"totals,required"` + JSON schemaJSON `json:"-"` } -// workersKVSchemasResultJSON contains the JSON metadata for the struct -// [WorkersKVSchemasResult] -type workersKVSchemasResultJSON struct { +// schemaJSON contains the JSON metadata for the struct [Schema] +type schemaJSON struct { Data apijson.Field DataLag apijson.Field Max apijson.Field @@ -211,38 +208,37 @@ type workersKVSchemasResultJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersKVSchemasResult) UnmarshalJSON(data []byte) (err error) { +func (r *Schema) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVSchemasResultJSON) RawJSON() string { +func (r schemaJSON) RawJSON() string { return r.raw } -type WorkersKVSchemasResultData struct { +type SchemaData struct { // List of metrics returned by the query. - Metrics []interface{} `json:"metrics,required"` - JSON workersKVSchemasResultDataJSON `json:"-"` + Metrics []interface{} `json:"metrics,required"` + JSON schemaDataJSON `json:"-"` } -// workersKVSchemasResultDataJSON contains the JSON metadata for the struct -// [WorkersKVSchemasResultData] -type workersKVSchemasResultDataJSON struct { +// schemaDataJSON contains the JSON metadata for the struct [SchemaData] +type schemaDataJSON struct { Metrics apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *WorkersKVSchemasResultData) UnmarshalJSON(data []byte) (err error) { +func (r *SchemaData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVSchemasResultDataJSON) RawJSON() string { +func (r schemaDataJSON) RawJSON() string { return r.raw } // For specifying result metrics. -type WorkersKVSchemasResultQuery struct { +type SchemaQuery struct { // Can be used to break down the data by given attributes. Dimensions []string `json:"dimensions"` // Used to filter rows by one or more dimensions. Filters can be combined using OR @@ -271,13 +267,12 @@ type WorkersKVSchemasResultQuery struct { // by - (descending) or + (ascending). Sort []interface{} `json:"sort"` // End of time interval to query, defaults to current time. - Until time.Time `json:"until" format:"date-time"` - JSON workersKVSchemasResultQueryJSON `json:"-"` + Until time.Time `json:"until" format:"date-time"` + JSON schemaQueryJSON `json:"-"` } -// workersKVSchemasResultQueryJSON contains the JSON metadata for the struct -// [WorkersKVSchemasResultQuery] -type workersKVSchemasResultQueryJSON struct { +// schemaQueryJSON contains the JSON metadata for the struct [SchemaQuery] +type schemaQueryJSON struct { Dimensions apijson.Field Filters apijson.Field Limit apijson.Field @@ -289,11 +284,11 @@ type workersKVSchemasResultQueryJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersKVSchemasResultQuery) UnmarshalJSON(data []byte) (err error) { +func (r *SchemaQuery) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersKVSchemasResultQueryJSON) RawJSON() string { +func (r schemaQueryJSON) RawJSON() string { return r.raw } @@ -307,7 +302,7 @@ type AnalyticsListParams struct { // URLQuery serializes [AnalyticsListParams]'s query parameters as `url.Values`. func (r AnalyticsListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -349,7 +344,7 @@ type AnalyticsListParamsQuery struct { // `url.Values`. func (r AnalyticsListParamsQuery) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -389,10 +384,10 @@ func (r AnalyticsListParamsQueryMetric) IsKnown() bool { } type AnalyticsListResponseEnvelope struct { - Errors []AnalyticsListResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyticsListResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Metrics on Workers KV requests. - Result WorkersKVSchemasResult `json:"result,required"` + Result Schema `json:"result,required"` // Whether the API call was successful Success AnalyticsListResponseEnvelopeSuccess `json:"success,required"` JSON analyticsListResponseEnvelopeJSON `json:"-"` @@ -417,52 +412,6 @@ func (r analyticsListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyticsListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsListResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyticsListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AnalyticsListResponseEnvelopeErrors] -type analyticsListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyticsListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsListResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyticsListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AnalyticsListResponseEnvelopeMessages] -type analyticsListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyticsListResponseEnvelopeSuccess bool @@ -488,7 +437,7 @@ type AnalyticsStoredParams struct { // URLQuery serializes [AnalyticsStoredParams]'s query parameters as `url.Values`. func (r AnalyticsStoredParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -530,7 +479,7 @@ type AnalyticsStoredParamsQuery struct { // `url.Values`. func (r AnalyticsStoredParamsQuery) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -567,10 +516,10 @@ func (r AnalyticsStoredParamsQueryMetric) IsKnown() bool { } type AnalyticsStoredResponseEnvelope struct { - Errors []AnalyticsStoredResponseEnvelopeErrors `json:"errors,required"` - Messages []AnalyticsStoredResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Metrics on Workers KV requests. - Result WorkersKVComponentsSchemasResult `json:"result,required"` + Result Components `json:"result,required"` // Whether the API call was successful Success AnalyticsStoredResponseEnvelopeSuccess `json:"success,required"` JSON analyticsStoredResponseEnvelopeJSON `json:"-"` @@ -595,52 +544,6 @@ func (r analyticsStoredResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AnalyticsStoredResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsStoredResponseEnvelopeErrorsJSON `json:"-"` -} - -// analyticsStoredResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AnalyticsStoredResponseEnvelopeErrors] -type analyticsStoredResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsStoredResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsStoredResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AnalyticsStoredResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON analyticsStoredResponseEnvelopeMessagesJSON `json:"-"` -} - -// analyticsStoredResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AnalyticsStoredResponseEnvelopeMessages] -type analyticsStoredResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AnalyticsStoredResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsStoredResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AnalyticsStoredResponseEnvelopeSuccess bool diff --git a/stream/aliases.go b/stream/aliases.go index 424f15ba04d..05d08701683 100644 --- a/stream/aliases.go +++ b/stream/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/stream/audiotrack.go b/stream/audiotrack.go index 55fcf5ddd9b..5adfd66e9e0 100644 --- a/stream/audiotrack.go +++ b/stream/audiotrack.go @@ -35,7 +35,7 @@ func NewAudioTrackService(opts ...option.RequestOption) (r *AudioTrackService) { // Deletes additional audio tracks on a video. Deleting a default audio track is // not allowed. You must assign another audio track as default prior to deletion. -func (r *AudioTrackService) Delete(ctx context.Context, identifier string, audioIdentifier string, body AudioTrackDeleteParams, opts ...option.RequestOption) (res *AudioTrackDeleteResponse, err error) { +func (r *AudioTrackService) Delete(ctx context.Context, identifier string, audioIdentifier string, body AudioTrackDeleteParams, opts ...option.RequestOption) (res *AudioTrackDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AudioTrackDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/audio/%s", body.AccountID, identifier, audioIdentifier) @@ -48,7 +48,7 @@ func (r *AudioTrackService) Delete(ctx context.Context, identifier string, audio } // Adds an additional audio track to a video using the provided audio track URL. -func (r *AudioTrackService) Copy(ctx context.Context, identifier string, params AudioTrackCopyParams, opts ...option.RequestOption) (res *StreamAudio, err error) { +func (r *AudioTrackService) Copy(ctx context.Context, identifier string, params AudioTrackCopyParams, opts ...option.RequestOption) (res *Audio, err error) { opts = append(r.Options[:], opts...) var env AudioTrackCopyResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/audio/copy", params.AccountID, identifier) @@ -63,7 +63,7 @@ func (r *AudioTrackService) Copy(ctx context.Context, identifier string, params // Edits additional audio tracks on a video. Editing the default status of an audio // track to `true` will mark all other audio tracks on the video default status to // `false`. -func (r *AudioTrackService) Edit(ctx context.Context, identifier string, audioIdentifier string, params AudioTrackEditParams, opts ...option.RequestOption) (res *StreamAudio, err error) { +func (r *AudioTrackService) Edit(ctx context.Context, identifier string, audioIdentifier string, params AudioTrackEditParams, opts ...option.RequestOption) (res *Audio, err error) { opts = append(r.Options[:], opts...) var env AudioTrackEditResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/audio/%s", params.AccountID, identifier, audioIdentifier) @@ -77,7 +77,7 @@ func (r *AudioTrackService) Edit(ctx context.Context, identifier string, audioId // Lists additional audio tracks on a video. Note this API will not return // information for audio attached to the video upload. -func (r *AudioTrackService) Get(ctx context.Context, identifier string, query AudioTrackGetParams, opts ...option.RequestOption) (res *[]StreamAudio, err error) { +func (r *AudioTrackService) Get(ctx context.Context, identifier string, query AudioTrackGetParams, opts ...option.RequestOption) (res *[]Audio, err error) { opts = append(r.Options[:], opts...) var env AudioTrackGetResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/audio", query.AccountID, identifier) @@ -89,49 +89,49 @@ func (r *AudioTrackService) Get(ctx context.Context, identifier string, query Au return } -type StreamAudio struct { +type Audio struct { // Denotes whether the audio track will be played by default in a player. Default bool `json:"default"` // A string to uniquely identify the track amongst other audio track labels for the // specified video. Label string `json:"label"` // Specifies the processing status of the video. - Status StreamAudioStatus `json:"status"` + Status AudioStatus `json:"status"` // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - JSON streamAudioJSON `json:"-"` + UID string `json:"uid"` + JSON audioJSON `json:"-"` } -// streamAudioJSON contains the JSON metadata for the struct [StreamAudio] -type streamAudioJSON struct { +// audioJSON contains the JSON metadata for the struct [Audio] +type audioJSON struct { Default apijson.Field Label apijson.Field Status apijson.Field - Uid apijson.Field + UID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamAudio) UnmarshalJSON(data []byte) (err error) { +func (r *Audio) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamAudioJSON) RawJSON() string { +func (r audioJSON) RawJSON() string { return r.raw } // Specifies the processing status of the video. -type StreamAudioStatus string +type AudioStatus string const ( - StreamAudioStatusQueued StreamAudioStatus = "queued" - StreamAudioStatusReady StreamAudioStatus = "ready" - StreamAudioStatusError StreamAudioStatus = "error" + AudioStatusQueued AudioStatus = "queued" + AudioStatusReady AudioStatus = "ready" + AudioStatusError AudioStatus = "error" ) -func (r StreamAudioStatus) IsKnown() bool { +func (r AudioStatus) IsKnown() bool { switch r { - case StreamAudioStatusQueued, StreamAudioStatusReady, StreamAudioStatusError: + case AudioStatusQueued, AudioStatusReady, AudioStatusError: return true } return false @@ -139,13 +139,13 @@ func (r StreamAudioStatus) IsKnown() bool { // Union satisfied by [stream.AudioTrackDeleteResponseUnknown] or // [shared.UnionString]. -type AudioTrackDeleteResponse interface { - ImplementsStreamAudioTrackDeleteResponse() +type AudioTrackDeleteResponseUnion interface { + ImplementsStreamAudioTrackDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AudioTrackDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*AudioTrackDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -160,9 +160,9 @@ type AudioTrackDeleteParams struct { } type AudioTrackDeleteResponseEnvelope struct { - Errors []AudioTrackDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AudioTrackDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AudioTrackDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AudioTrackDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success AudioTrackDeleteResponseEnvelopeSuccess `json:"success,required"` JSON audioTrackDeleteResponseEnvelopeJSON `json:"-"` @@ -187,52 +187,6 @@ func (r audioTrackDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AudioTrackDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// audioTrackDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AudioTrackDeleteResponseEnvelopeErrors] -type audioTrackDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AudioTrackDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// audioTrackDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AudioTrackDeleteResponseEnvelopeMessages] -type audioTrackDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AudioTrackDeleteResponseEnvelopeSuccess bool @@ -265,9 +219,9 @@ func (r AudioTrackCopyParams) MarshalJSON() (data []byte, err error) { } type AudioTrackCopyResponseEnvelope struct { - Errors []AudioTrackCopyResponseEnvelopeErrors `json:"errors,required"` - Messages []AudioTrackCopyResponseEnvelopeMessages `json:"messages,required"` - Result StreamAudio `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Audio `json:"result,required"` // Whether the API call was successful Success AudioTrackCopyResponseEnvelopeSuccess `json:"success,required"` JSON audioTrackCopyResponseEnvelopeJSON `json:"-"` @@ -292,52 +246,6 @@ func (r audioTrackCopyResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AudioTrackCopyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackCopyResponseEnvelopeErrorsJSON `json:"-"` -} - -// audioTrackCopyResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AudioTrackCopyResponseEnvelopeErrors] -type audioTrackCopyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackCopyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackCopyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AudioTrackCopyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackCopyResponseEnvelopeMessagesJSON `json:"-"` -} - -// audioTrackCopyResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AudioTrackCopyResponseEnvelopeMessages] -type audioTrackCopyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackCopyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackCopyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AudioTrackCopyResponseEnvelopeSuccess bool @@ -368,9 +276,9 @@ func (r AudioTrackEditParams) MarshalJSON() (data []byte, err error) { } type AudioTrackEditResponseEnvelope struct { - Errors []AudioTrackEditResponseEnvelopeErrors `json:"errors,required"` - Messages []AudioTrackEditResponseEnvelopeMessages `json:"messages,required"` - Result StreamAudio `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Audio `json:"result,required"` // Whether the API call was successful Success AudioTrackEditResponseEnvelopeSuccess `json:"success,required"` JSON audioTrackEditResponseEnvelopeJSON `json:"-"` @@ -395,52 +303,6 @@ func (r audioTrackEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AudioTrackEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// audioTrackEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AudioTrackEditResponseEnvelopeErrors] -type audioTrackEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AudioTrackEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// audioTrackEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AudioTrackEditResponseEnvelopeMessages] -type audioTrackEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AudioTrackEditResponseEnvelopeSuccess bool @@ -462,9 +324,9 @@ type AudioTrackGetParams struct { } type AudioTrackGetResponseEnvelope struct { - Errors []AudioTrackGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AudioTrackGetResponseEnvelopeMessages `json:"messages,required"` - Result []StreamAudio `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Audio `json:"result,required"` // Whether the API call was successful Success AudioTrackGetResponseEnvelopeSuccess `json:"success,required"` JSON audioTrackGetResponseEnvelopeJSON `json:"-"` @@ -489,52 +351,6 @@ func (r audioTrackGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AudioTrackGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// audioTrackGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AudioTrackGetResponseEnvelopeErrors] -type audioTrackGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AudioTrackGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON audioTrackGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// audioTrackGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AudioTrackGetResponseEnvelopeMessages] -type audioTrackGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AudioTrackGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r audioTrackGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AudioTrackGetResponseEnvelopeSuccess bool diff --git a/stream/caption.go b/stream/caption.go index 8d51f5f145f..405ce9d065f 100644 --- a/stream/caption.go +++ b/stream/caption.go @@ -35,7 +35,7 @@ func NewCaptionService(opts ...option.RequestOption) (r *CaptionService) { // Uploads the caption or subtitle file to the endpoint for a specific BCP47 // language. One caption or subtitle file per language is allowed. -func (r *CaptionService) Update(ctx context.Context, identifier string, language string, params CaptionUpdateParams, opts ...option.RequestOption) (res *CaptionUpdateResponse, err error) { +func (r *CaptionService) Update(ctx context.Context, identifier string, language string, params CaptionUpdateParams, opts ...option.RequestOption) (res *CaptionUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CaptionUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/captions/%s", params.AccountID, identifier, language) @@ -48,10 +48,10 @@ func (r *CaptionService) Update(ctx context.Context, identifier string, language } // Removes the captions or subtitles from a video. -func (r *CaptionService) Delete(ctx context.Context, identifier string, language string, body CaptionDeleteParams, opts ...option.RequestOption) (res *CaptionDeleteResponse, err error) { +func (r *CaptionService) Delete(ctx context.Context, identifier string, language string, params CaptionDeleteParams, opts ...option.RequestOption) (res *CaptionDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CaptionDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/captions/%s", body.AccountID, identifier, language) + path := fmt.Sprintf("accounts/%s/stream/%s/captions/%s", params.AccountID, identifier, language) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -61,7 +61,7 @@ func (r *CaptionService) Delete(ctx context.Context, identifier string, language } // Lists the available captions or subtitles for a specific video. -func (r *CaptionService) Get(ctx context.Context, identifier string, query CaptionGetParams, opts ...option.RequestOption) (res *[]StreamCaptions, err error) { +func (r *CaptionService) Get(ctx context.Context, identifier string, query CaptionGetParams, opts ...option.RequestOption) (res *[]Caption, err error) { opts = append(r.Options[:], opts...) var env CaptionGetResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/captions", query.AccountID, identifier) @@ -73,39 +73,39 @@ func (r *CaptionService) Get(ctx context.Context, identifier string, query Capti return } -type StreamCaptions struct { +type Caption struct { // The language label displayed in the native language to users. Label string `json:"label"` // The language tag in BCP 47 format. - Language string `json:"language"` - JSON streamCaptionsJSON `json:"-"` + Language string `json:"language"` + JSON captionJSON `json:"-"` } -// streamCaptionsJSON contains the JSON metadata for the struct [StreamCaptions] -type streamCaptionsJSON struct { +// captionJSON contains the JSON metadata for the struct [Caption] +type captionJSON struct { Label apijson.Field Language apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamCaptions) UnmarshalJSON(data []byte) (err error) { +func (r *Caption) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamCaptionsJSON) RawJSON() string { +func (r captionJSON) RawJSON() string { return r.raw } // Union satisfied by [stream.CaptionUpdateResponseUnknown] or // [shared.UnionString]. -type CaptionUpdateResponse interface { - ImplementsStreamCaptionUpdateResponse() +type CaptionUpdateResponseUnion interface { + ImplementsStreamCaptionUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CaptionUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*CaptionUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -116,13 +116,13 @@ func init() { // Union satisfied by [stream.CaptionDeleteResponseUnknown], // [stream.CaptionDeleteResponseArray] or [shared.UnionString]. -type CaptionDeleteResponse interface { - ImplementsStreamCaptionDeleteResponse() +type CaptionDeleteResponseUnion interface { + ImplementsStreamCaptionDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CaptionDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*CaptionDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -137,7 +137,7 @@ func init() { type CaptionDeleteResponseArray []interface{} -func (r CaptionDeleteResponseArray) ImplementsStreamCaptionDeleteResponse() {} +func (r CaptionDeleteResponseArray) ImplementsStreamCaptionDeleteResponseUnion() {} type CaptionUpdateParams struct { // Identifier @@ -151,9 +151,9 @@ func (r CaptionUpdateParams) MarshalJSON() (data []byte, err error) { } type CaptionUpdateResponseEnvelope struct { - Errors []CaptionUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CaptionUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CaptionUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CaptionUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success CaptionUpdateResponseEnvelopeSuccess `json:"success,required"` JSON captionUpdateResponseEnvelopeJSON `json:"-"` @@ -178,52 +178,6 @@ func (r captionUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CaptionUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON captionUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// captionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CaptionUpdateResponseEnvelopeErrors] -type captionUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CaptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r captionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CaptionUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON captionUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// captionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CaptionUpdateResponseEnvelopeMessages] -type captionUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CaptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r captionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CaptionUpdateResponseEnvelopeSuccess bool @@ -242,12 +196,17 @@ func (r CaptionUpdateResponseEnvelopeSuccess) IsKnown() bool { type CaptionDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r CaptionDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type CaptionDeleteResponseEnvelope struct { - Errors []CaptionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CaptionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CaptionDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CaptionDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success CaptionDeleteResponseEnvelopeSuccess `json:"success,required"` JSON captionDeleteResponseEnvelopeJSON `json:"-"` @@ -272,52 +231,6 @@ func (r captionDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CaptionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON captionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// captionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CaptionDeleteResponseEnvelopeErrors] -type captionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CaptionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r captionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CaptionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON captionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// captionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CaptionDeleteResponseEnvelopeMessages] -type captionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CaptionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r captionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CaptionDeleteResponseEnvelopeSuccess bool @@ -339,9 +252,9 @@ type CaptionGetParams struct { } type CaptionGetResponseEnvelope struct { - Errors []CaptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CaptionGetResponseEnvelopeMessages `json:"messages,required"` - Result []StreamCaptions `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Caption `json:"result,required"` // Whether the API call was successful Success CaptionGetResponseEnvelopeSuccess `json:"success,required"` JSON captionGetResponseEnvelopeJSON `json:"-"` @@ -366,52 +279,6 @@ func (r captionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CaptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON captionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// captionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [CaptionGetResponseEnvelopeErrors] -type captionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CaptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r captionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CaptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON captionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// captionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [CaptionGetResponseEnvelopeMessages] -type captionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CaptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r captionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CaptionGetResponseEnvelopeSuccess bool diff --git a/stream/caption_test.go b/stream/caption_test.go index b6a8068bce0..4d28e941c82 100644 --- a/stream/caption_test.go +++ b/stream/caption_test.go @@ -66,6 +66,7 @@ func TestCaptionDelete(t *testing.T) { "tr", stream.CaptionDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/stream/clip.go b/stream/clip.go index e3d72440c66..c48e3f9fc22 100644 --- a/stream/clip.go +++ b/stream/clip.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewClipService(opts ...option.RequestOption) (r *ClipService) { } // Clips a video based on the specified start and end times provided in seconds. -func (r *ClipService) New(ctx context.Context, params ClipNewParams, opts ...option.RequestOption) (res *StreamClipping, err error) { +func (r *ClipService) New(ctx context.Context, params ClipNewParams, opts ...option.RequestOption) (res *Clip, err error) { opts = append(r.Options[:], opts...) var env ClipNewResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/clip", params.AccountID) @@ -44,13 +45,13 @@ func (r *ClipService) New(ctx context.Context, params ClipNewParams, opts ...opt return } -type StreamClipping struct { +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 []string `json:"allowedOrigins"` + AllowedOrigins []AllowedOrigins `json:"allowedOrigins"` // The unique video identifier (UID). - ClippedFromVideoUid string `json:"clippedFromVideoUID"` + ClippedFromVideoUID string `json:"clippedFromVideoUID"` // The date and time the clip was created. Created time.Time `json:"created" format:"date-time"` // A user-defined identifier for the media creator. @@ -66,8 +67,8 @@ type StreamClipping struct { // managing videos. Meta interface{} `json:"meta"` // The date and time the live input was last modified. - Modified time.Time `json:"modified" format:"date-time"` - Playback StreamClippingPlayback `json:"playback"` + Modified time.Time `json:"modified" format:"date-time"` + Playback ClipPlayback `json:"playback"` // The video's preview page URI. This field is omitted until encoding is complete. Preview string `json:"preview" format:"uri"` // Indicates whether the video can be a accessed using the UID. When set to `true`, @@ -76,20 +77,20 @@ type StreamClipping struct { // Specifies the start time for the video clip in seconds. StartTimeSeconds int64 `json:"startTimeSeconds"` // Specifies the processing status for all quality levels for a video. - Status StreamClippingStatus `json:"status"` + Status ClipStatus `json:"status"` // The timestamp for a thumbnail image calculated as a percentage value of the // video's duration. To convert from a second-wise timestamp to a percentage, // divide the desired timestamp by the total duration of the video. If this value // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` - Watermark StreamClippingWatermark `json:"watermark"` - JSON streamClippingJSON `json:"-"` + ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` + Watermark ClipWatermark `json:"watermark"` + JSON clipJSON `json:"-"` } -// streamClippingJSON contains the JSON metadata for the struct [StreamClipping] -type streamClippingJSON struct { +// clipJSON contains the JSON metadata for the struct [Clip] +type clipJSON struct { AllowedOrigins apijson.Field - ClippedFromVideoUid apijson.Field + ClippedFromVideoUID apijson.Field Created apijson.Field Creator apijson.Field EndTimeSeconds apijson.Field @@ -107,78 +108,76 @@ type streamClippingJSON struct { ExtraFields map[string]apijson.Field } -func (r *StreamClipping) UnmarshalJSON(data []byte) (err error) { +func (r *Clip) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamClippingJSON) RawJSON() string { +func (r clipJSON) RawJSON() string { return r.raw } -type StreamClippingPlayback struct { +type ClipPlayback struct { // DASH Media Presentation Description for the video. Dash string `json:"dash"` // The HLS manifest for the video. - Hls string `json:"hls"` - JSON streamClippingPlaybackJSON `json:"-"` + Hls string `json:"hls"` + JSON clipPlaybackJSON `json:"-"` } -// streamClippingPlaybackJSON contains the JSON metadata for the struct -// [StreamClippingPlayback] -type streamClippingPlaybackJSON struct { +// clipPlaybackJSON contains the JSON metadata for the struct [ClipPlayback] +type clipPlaybackJSON struct { Dash apijson.Field Hls apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamClippingPlayback) UnmarshalJSON(data []byte) (err error) { +func (r *ClipPlayback) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamClippingPlaybackJSON) RawJSON() string { +func (r clipPlaybackJSON) RawJSON() string { return r.raw } // Specifies the processing status for all quality levels for a video. -type StreamClippingStatus string +type ClipStatus string const ( - StreamClippingStatusPendingupload StreamClippingStatus = "pendingupload" - StreamClippingStatusDownloading StreamClippingStatus = "downloading" - StreamClippingStatusQueued StreamClippingStatus = "queued" - StreamClippingStatusInprogress StreamClippingStatus = "inprogress" - StreamClippingStatusReady StreamClippingStatus = "ready" - StreamClippingStatusError StreamClippingStatus = "error" + ClipStatusPendingupload ClipStatus = "pendingupload" + ClipStatusDownloading ClipStatus = "downloading" + ClipStatusQueued ClipStatus = "queued" + ClipStatusInprogress ClipStatus = "inprogress" + ClipStatusReady ClipStatus = "ready" + ClipStatusError ClipStatus = "error" ) -func (r StreamClippingStatus) IsKnown() bool { +func (r ClipStatus) IsKnown() bool { switch r { - case StreamClippingStatusPendingupload, StreamClippingStatusDownloading, StreamClippingStatusQueued, StreamClippingStatusInprogress, StreamClippingStatusReady, StreamClippingStatusError: + case ClipStatusPendingupload, ClipStatusDownloading, ClipStatusQueued, ClipStatusInprogress, ClipStatusReady, ClipStatusError: return true } return false } -type StreamClippingWatermark struct { +type ClipWatermark struct { // The unique identifier for the watermark profile. - Uid string `json:"uid"` - JSON streamClippingWatermarkJSON `json:"-"` + UID string `json:"uid"` + JSON clipWatermarkJSON `json:"-"` } -// streamClippingWatermarkJSON contains the JSON metadata for the struct -// [StreamClippingWatermark] -type streamClippingWatermarkJSON struct { - Uid apijson.Field +// clipWatermarkJSON contains the JSON metadata for the struct [ClipWatermark] +type clipWatermarkJSON struct { + UID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamClippingWatermark) UnmarshalJSON(data []byte) (err error) { +func (r *ClipWatermark) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamClippingWatermarkJSON) RawJSON() string { +func (r clipWatermarkJSON) RawJSON() string { return r.raw } @@ -186,7 +185,7 @@ type ClipNewParams struct { // The account identifier tag. AccountID param.Field[string] `path:"account_id,required"` // The unique video identifier (UID). - ClippedFromVideoUid param.Field[string] `json:"clippedFromVideoUID,required"` + ClippedFromVideoUID param.Field[string] `json:"clippedFromVideoUID,required"` // Specifies the end time for the video clip in seconds. EndTimeSeconds param.Field[int64] `json:"endTimeSeconds,required"` // Specifies the start time for the video clip in seconds. @@ -194,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[[]string] `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 @@ -219,7 +218,7 @@ func (r ClipNewParams) MarshalJSON() (data []byte, err error) { type ClipNewParamsWatermark struct { // The unique identifier for the watermark profile. - Uid param.Field[string] `json:"uid"` + UID param.Field[string] `json:"uid"` } func (r ClipNewParamsWatermark) MarshalJSON() (data []byte, err error) { @@ -227,9 +226,9 @@ func (r ClipNewParamsWatermark) MarshalJSON() (data []byte, err error) { } type ClipNewResponseEnvelope struct { - Errors []ClipNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ClipNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamClipping `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Clip `json:"result,required"` // Whether the API call was successful Success ClipNewResponseEnvelopeSuccess `json:"success,required"` JSON clipNewResponseEnvelopeJSON `json:"-"` @@ -254,52 +253,6 @@ func (r clipNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ClipNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clipNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// clipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ClipNewResponseEnvelopeErrors] -type clipNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clipNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClipNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clipNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// clipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ClipNewResponseEnvelopeMessages] -type clipNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clipNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ClipNewResponseEnvelopeSuccess bool diff --git a/stream/clip_test.go b/stream/clip_test.go index e4728244b39..496ca22b274 100644 --- a/stream/clip_test.go +++ b/stream/clip_test.go @@ -30,16 +30,16 @@ func TestClipNewWithOptionalParams(t *testing.T) { ) _, err := client.Stream.Clip.New(context.TODO(), stream.ClipNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ClippedFromVideoUid: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ClippedFromVideoUID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), EndTimeSeconds: cloudflare.F(int64(0)), StartTimeSeconds: cloudflare.F(int64(0)), - AllowedOrigins: cloudflare.F([]string{"example.com"}), + AllowedOrigins: cloudflare.F([]stream.AllowedOriginsParam{"example.com"}), Creator: cloudflare.F("creator-id_abcde12345"), MaxDurationSeconds: cloudflare.F(int64(1)), RequireSignedURLs: cloudflare.F(true), ThumbnailTimestampPct: cloudflare.F(0.529241), Watermark: cloudflare.F(stream.ClipNewParamsWatermark{ - Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), + UID: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), }), }) if err != nil { diff --git a/stream/copy.go b/stream/copy.go index 93bc8cbfcb9..215e71ff741 100644 --- a/stream/copy.go +++ b/stream/copy.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewCopyService(opts ...option.RequestOption) (r *CopyService) { } // Uploads a video to Stream from a provided URL. -func (r *CopyService) New(ctx context.Context, params CopyNewParams, opts ...option.RequestOption) (res *StreamVideos, err error) { +func (r *CopyService) New(ctx context.Context, params CopyNewParams, opts ...option.RequestOption) (res *Video, err error) { opts = append(r.Options[:], opts...) var env CopyNewResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/copy", params.AccountID) @@ -54,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[[]string] `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 @@ -87,7 +88,7 @@ func (r CopyNewParams) MarshalJSON() (data []byte, err error) { type CopyNewParamsWatermark struct { // The unique identifier for the watermark profile. - Uid param.Field[string] `json:"uid"` + UID param.Field[string] `json:"uid"` } func (r CopyNewParamsWatermark) MarshalJSON() (data []byte, err error) { @@ -95,9 +96,9 @@ func (r CopyNewParamsWatermark) MarshalJSON() (data []byte, err error) { } type CopyNewResponseEnvelope struct { - Errors []CopyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CopyNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamVideos `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Video `json:"result,required"` // Whether the API call was successful Success CopyNewResponseEnvelopeSuccess `json:"success,required"` JSON copyNewResponseEnvelopeJSON `json:"-"` @@ -122,52 +123,6 @@ func (r copyNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CopyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON copyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// copyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [CopyNewResponseEnvelopeErrors] -type copyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CopyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r copyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CopyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON copyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// copyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [CopyNewResponseEnvelopeMessages] -type copyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CopyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r copyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CopyNewResponseEnvelopeSuccess bool diff --git a/stream/copy_test.go b/stream/copy_test.go index 266f5b63044..f2a3a2718c4 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([]string{"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", @@ -41,7 +41,7 @@ func TestCopyNewWithOptionalParams(t *testing.T) { ScheduledDeletion: cloudflare.F(time.Now()), ThumbnailTimestampPct: cloudflare.F(0.529241), Watermark: cloudflare.F(stream.CopyNewParamsWatermark{ - Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), + UID: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), }), UploadCreator: cloudflare.F("creator-id_abcde12345"), UploadMetadata: cloudflare.F("name aGVsbG8gd29ybGQ=, requiresignedurls, allowedorigins ZXhhbXBsZS5jb20sdGVzdC5jb20="), diff --git a/stream/directupload.go b/stream/directupload.go index ada92d9153b..1f36470f23f 100644 --- a/stream/directupload.go +++ b/stream/directupload.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -51,11 +52,11 @@ type DirectUploadNewResponse struct { // scheduled deletion. If specified, must be at least 30 days from upload time. ScheduledDeletion time.Time `json:"scheduledDeletion" format:"date-time"` // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` + UID string `json:"uid"` // The URL an unauthenticated upload can use for a single // `HTTP POST multipart/form-data` request. UploadURL string `json:"uploadURL"` - Watermark StreamWatermarks `json:"watermark"` + Watermark Watermaks `json:"watermark"` JSON directUploadNewResponseJSON `json:"-"` } @@ -63,7 +64,7 @@ type DirectUploadNewResponse struct { // [DirectUploadNewResponse] type directUploadNewResponseJSON struct { ScheduledDeletion apijson.Field - Uid apijson.Field + UID apijson.Field UploadURL apijson.Field Watermark apijson.Field raw string @@ -89,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[[]string] `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. @@ -120,7 +121,7 @@ func (r DirectUploadNewParams) MarshalJSON() (data []byte, err error) { type DirectUploadNewParamsWatermark struct { // The unique identifier for the watermark profile. - Uid param.Field[string] `json:"uid"` + UID param.Field[string] `json:"uid"` } func (r DirectUploadNewParamsWatermark) MarshalJSON() (data []byte, err error) { @@ -128,9 +129,9 @@ func (r DirectUploadNewParamsWatermark) MarshalJSON() (data []byte, err error) { } type DirectUploadNewResponseEnvelope struct { - Errors []DirectUploadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DirectUploadNewResponseEnvelopeMessages `json:"messages,required"` - Result DirectUploadNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DirectUploadNewResponse `json:"result,required"` // Whether the API call was successful Success DirectUploadNewResponseEnvelopeSuccess `json:"success,required"` JSON directUploadNewResponseEnvelopeJSON `json:"-"` @@ -155,52 +156,6 @@ func (r directUploadNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DirectUploadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON directUploadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// directUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DirectUploadNewResponseEnvelopeErrors] -type directUploadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DirectUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r directUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DirectUploadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON directUploadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// directUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DirectUploadNewResponseEnvelopeMessages] -type directUploadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DirectUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r directUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DirectUploadNewResponseEnvelopeSuccess bool diff --git a/stream/directupload_test.go b/stream/directupload_test.go index 7e17964b7e0..3fc1770ce75 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([]string{"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{}{ @@ -42,7 +42,7 @@ func TestDirectUploadNewWithOptionalParams(t *testing.T) { ScheduledDeletion: cloudflare.F(time.Now()), ThumbnailTimestampPct: cloudflare.F(0.529241), Watermark: cloudflare.F(stream.DirectUploadNewParamsWatermark{ - Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), + UID: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), }), UploadCreator: cloudflare.F("creator-id_abcde12345"), }) diff --git a/stream/download.go b/stream/download.go index ef71e6fbfda..52a1f07af4c 100644 --- a/stream/download.go +++ b/stream/download.go @@ -34,10 +34,10 @@ func NewDownloadService(opts ...option.RequestOption) (r *DownloadService) { } // Creates a download for a video when a video is ready to view. -func (r *DownloadService) New(ctx context.Context, identifier string, body DownloadNewParams, opts ...option.RequestOption) (res *DownloadNewResponse, err error) { +func (r *DownloadService) New(ctx context.Context, identifier string, params DownloadNewParams, opts ...option.RequestOption) (res *DownloadNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DownloadNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/downloads", body.AccountID, identifier) + path := fmt.Sprintf("accounts/%s/stream/%s/downloads", params.AccountID, identifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -47,7 +47,7 @@ func (r *DownloadService) New(ctx context.Context, identifier string, body Downl } // Delete the downloads for a video. -func (r *DownloadService) Delete(ctx context.Context, identifier string, body DownloadDeleteParams, opts ...option.RequestOption) (res *DownloadDeleteResponse, err error) { +func (r *DownloadService) Delete(ctx context.Context, identifier string, body DownloadDeleteParams, opts ...option.RequestOption) (res *DownloadDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DownloadDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/downloads", body.AccountID, identifier) @@ -60,7 +60,7 @@ func (r *DownloadService) Delete(ctx context.Context, identifier string, body Do } // Lists the downloads created for a video. -func (r *DownloadService) Get(ctx context.Context, identifier string, query DownloadGetParams, opts ...option.RequestOption) (res *DownloadGetResponse, err error) { +func (r *DownloadService) Get(ctx context.Context, identifier string, query DownloadGetParams, opts ...option.RequestOption) (res *DownloadGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DownloadGetResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s/downloads", query.AccountID, identifier) @@ -73,13 +73,13 @@ func (r *DownloadService) Get(ctx context.Context, identifier string, query Down } // Union satisfied by [stream.DownloadNewResponseUnknown] or [shared.UnionString]. -type DownloadNewResponse interface { - ImplementsStreamDownloadNewResponse() +type DownloadNewResponseUnion interface { + ImplementsStreamDownloadNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DownloadNewResponse)(nil)).Elem(), + reflect.TypeOf((*DownloadNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -90,13 +90,13 @@ func init() { // Union satisfied by [stream.DownloadDeleteResponseUnknown] or // [shared.UnionString]. -type DownloadDeleteResponse interface { - ImplementsStreamDownloadDeleteResponse() +type DownloadDeleteResponseUnion interface { + ImplementsStreamDownloadDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DownloadDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*DownloadDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -106,13 +106,13 @@ func init() { } // Union satisfied by [stream.DownloadGetResponseUnknown] or [shared.UnionString]. -type DownloadGetResponse interface { - ImplementsStreamDownloadGetResponse() +type DownloadGetResponseUnion interface { + ImplementsStreamDownloadGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DownloadGetResponse)(nil)).Elem(), + reflect.TypeOf((*DownloadGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -124,12 +124,17 @@ func init() { type DownloadNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DownloadNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DownloadNewResponseEnvelope struct { - Errors []DownloadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DownloadNewResponseEnvelopeMessages `json:"messages,required"` - Result DownloadNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DownloadNewResponseUnion `json:"result,required"` // Whether the API call was successful Success DownloadNewResponseEnvelopeSuccess `json:"success,required"` JSON downloadNewResponseEnvelopeJSON `json:"-"` @@ -154,52 +159,6 @@ func (r downloadNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DownloadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON downloadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// downloadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DownloadNewResponseEnvelopeErrors] -type downloadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DownloadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r downloadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DownloadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON downloadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// downloadNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DownloadNewResponseEnvelopeMessages] -type downloadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DownloadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r downloadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DownloadNewResponseEnvelopeSuccess bool @@ -221,9 +180,9 @@ type DownloadDeleteParams struct { } type DownloadDeleteResponseEnvelope struct { - Errors []DownloadDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DownloadDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DownloadDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DownloadDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success DownloadDeleteResponseEnvelopeSuccess `json:"success,required"` JSON downloadDeleteResponseEnvelopeJSON `json:"-"` @@ -248,52 +207,6 @@ func (r downloadDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DownloadDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON downloadDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// downloadDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DownloadDeleteResponseEnvelopeErrors] -type downloadDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DownloadDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r downloadDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DownloadDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON downloadDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// downloadDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DownloadDeleteResponseEnvelopeMessages] -type downloadDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DownloadDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r downloadDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DownloadDeleteResponseEnvelopeSuccess bool @@ -315,9 +228,9 @@ type DownloadGetParams struct { } type DownloadGetResponseEnvelope struct { - Errors []DownloadGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DownloadGetResponseEnvelopeMessages `json:"messages,required"` - Result DownloadGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DownloadGetResponseUnion `json:"result,required"` // Whether the API call was successful Success DownloadGetResponseEnvelopeSuccess `json:"success,required"` JSON downloadGetResponseEnvelopeJSON `json:"-"` @@ -342,52 +255,6 @@ func (r downloadGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DownloadGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON downloadGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// downloadGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DownloadGetResponseEnvelopeErrors] -type downloadGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DownloadGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r downloadGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DownloadGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON downloadGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// downloadGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DownloadGetResponseEnvelopeMessages] -type downloadGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DownloadGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r downloadGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DownloadGetResponseEnvelopeSuccess bool diff --git a/stream/download_test.go b/stream/download_test.go index 7c0cadfef29..692636defb4 100644 --- a/stream/download_test.go +++ b/stream/download_test.go @@ -33,6 +33,7 @@ func TestDownloadNew(t *testing.T) { "ea95132c15732412d22c1476fa83f27a", stream.DownloadNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/stream/key.go b/stream/key.go index a3659a2866d..9d102619412 100644 --- a/stream/key.go +++ b/stream/key.go @@ -37,10 +37,10 @@ func NewKeyService(opts ...option.RequestOption) (r *KeyService) { // Creates an RSA private key in PEM and JWK formats. Key files are only displayed // once after creation. Keys are created, used, and deleted independently of // videos, and every key can sign any video. -func (r *KeyService) New(ctx context.Context, body KeyNewParams, opts ...option.RequestOption) (res *StreamKeys, err error) { +func (r *KeyService) New(ctx context.Context, params KeyNewParams, opts ...option.RequestOption) (res *Keys, err error) { opts = append(r.Options[:], opts...) var env KeyNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/keys", body.AccountID) + path := fmt.Sprintf("accounts/%s/stream/keys", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -50,10 +50,10 @@ func (r *KeyService) New(ctx context.Context, body KeyNewParams, opts ...option. } // Deletes signing keys and revokes all signed URLs generated with the key. -func (r *KeyService) Delete(ctx context.Context, identifier string, body KeyDeleteParams, opts ...option.RequestOption) (res *KeyDeleteResponse, err error) { +func (r *KeyService) Delete(ctx context.Context, identifier string, params KeyDeleteParams, opts ...option.RequestOption) (res *KeyDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env KeyDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/keys/%s", body.AccountID, identifier) + path := fmt.Sprintf("accounts/%s/stream/keys/%s", params.AccountID, identifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -75,7 +75,7 @@ func (r *KeyService) Get(ctx context.Context, query KeyGetParams, opts ...option return } -type StreamKeys struct { +type Keys struct { // Identifier ID string `json:"id"` // The date and time a signing key was created. @@ -83,12 +83,12 @@ type StreamKeys struct { // The signing key in JWK format. Jwk string `json:"jwk"` // The signing key in PEM format. - Pem string `json:"pem"` - JSON streamKeysJSON `json:"-"` + Pem string `json:"pem"` + JSON keysJSON `json:"-"` } -// streamKeysJSON contains the JSON metadata for the struct [StreamKeys] -type streamKeysJSON struct { +// keysJSON contains the JSON metadata for the struct [Keys] +type keysJSON struct { ID apijson.Field Created apijson.Field Jwk apijson.Field @@ -97,22 +97,22 @@ type streamKeysJSON struct { ExtraFields map[string]apijson.Field } -func (r *StreamKeys) UnmarshalJSON(data []byte) (err error) { +func (r *Keys) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamKeysJSON) RawJSON() string { +func (r keysJSON) RawJSON() string { return r.raw } // Union satisfied by [stream.KeyDeleteResponseUnknown] or [shared.UnionString]. -type KeyDeleteResponse interface { - ImplementsStreamKeyDeleteResponse() +type KeyDeleteResponseUnion interface { + ImplementsStreamKeyDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*KeyDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*KeyDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -148,12 +148,17 @@ func (r keyGetResponseJSON) RawJSON() string { type KeyNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r KeyNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type KeyNewResponseEnvelope struct { - Errors []KeyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []KeyNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamKeys `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Keys `json:"result,required"` // Whether the API call was successful Success KeyNewResponseEnvelopeSuccess `json:"success,required"` JSON keyNewResponseEnvelopeJSON `json:"-"` @@ -178,52 +183,6 @@ func (r keyNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type KeyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// keyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [KeyNewResponseEnvelopeErrors] -type keyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// keyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [KeyNewResponseEnvelopeMessages] -type keyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type KeyNewResponseEnvelopeSuccess bool @@ -242,12 +201,17 @@ func (r KeyNewResponseEnvelopeSuccess) IsKnown() bool { type KeyDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r KeyDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type KeyDeleteResponseEnvelope struct { - Errors []KeyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []KeyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result KeyDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result KeyDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success KeyDeleteResponseEnvelopeSuccess `json:"success,required"` JSON keyDeleteResponseEnvelopeJSON `json:"-"` @@ -272,52 +236,6 @@ func (r keyDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type KeyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// keyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [KeyDeleteResponseEnvelopeErrors] -type keyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// keyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [KeyDeleteResponseEnvelopeMessages] -type keyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type KeyDeleteResponseEnvelopeSuccess bool @@ -339,9 +257,9 @@ type KeyGetParams struct { } type KeyGetResponseEnvelope struct { - Errors []KeyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []KeyGetResponseEnvelopeMessages `json:"messages,required"` - Result []KeyGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []KeyGetResponse `json:"result,required"` // Whether the API call was successful Success KeyGetResponseEnvelopeSuccess `json:"success,required"` JSON keyGetResponseEnvelopeJSON `json:"-"` @@ -366,52 +284,6 @@ func (r keyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type KeyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// keyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [KeyGetResponseEnvelopeErrors] -type keyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// keyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [KeyGetResponseEnvelopeMessages] -type keyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type KeyGetResponseEnvelopeSuccess bool diff --git a/stream/key_test.go b/stream/key_test.go index 7a47e368b2a..b644d70ddf7 100644 --- a/stream/key_test.go +++ b/stream/key_test.go @@ -30,6 +30,7 @@ func TestKeyNew(t *testing.T) { ) _, err := client.Stream.Keys.New(context.TODO(), stream.KeyNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error @@ -59,6 +60,7 @@ func TestKeyDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", stream.KeyDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/stream/liveinput.go b/stream/liveinput.go index c121a69ec26..ad8d5ae0e6f 100644 --- a/stream/liveinput.go +++ b/stream/liveinput.go @@ -13,6 +13,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -37,7 +38,7 @@ func NewLiveInputService(opts ...option.RequestOption) (r *LiveInputService) { // Creates a live input, and returns credentials that you or your users can use to // stream live video to Cloudflare Stream. -func (r *LiveInputService) New(ctx context.Context, params LiveInputNewParams, opts ...option.RequestOption) (res *StreamLiveInput, err error) { +func (r *LiveInputService) New(ctx context.Context, params LiveInputNewParams, opts ...option.RequestOption) (res *LiveInput, err error) { opts = append(r.Options[:], opts...) var env LiveInputNewResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/live_inputs", params.AccountID) @@ -50,7 +51,7 @@ func (r *LiveInputService) New(ctx context.Context, params LiveInputNewParams, o } // Updates a specified live input. -func (r *LiveInputService) Update(ctx context.Context, liveInputIdentifier string, params LiveInputUpdateParams, opts ...option.RequestOption) (res *StreamLiveInput, err error) { +func (r *LiveInputService) Update(ctx context.Context, liveInputIdentifier string, params LiveInputUpdateParams, opts ...option.RequestOption) (res *LiveInput, err error) { opts = append(r.Options[:], opts...) var env LiveInputUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", params.AccountID, liveInputIdentifier) @@ -78,16 +79,16 @@ func (r *LiveInputService) List(ctx context.Context, params LiveInputListParams, // Prevents a live input from being streamed to and makes the live input // inaccessible to any future API calls. -func (r *LiveInputService) Delete(ctx context.Context, liveInputIdentifier string, body LiveInputDeleteParams, opts ...option.RequestOption) (err error) { +func (r *LiveInputService) Delete(ctx context.Context, liveInputIdentifier string, params LiveInputDeleteParams, opts ...option.RequestOption) (err error) { opts = append(r.Options[:], opts...) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", body.AccountID, liveInputIdentifier) + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", params.AccountID, liveInputIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) return } // Retrieves details of an existing live input. -func (r *LiveInputService) Get(ctx context.Context, liveInputIdentifier string, query LiveInputGetParams, opts ...option.RequestOption) (res *StreamLiveInput, err error) { +func (r *LiveInputService) Get(ctx context.Context, liveInputIdentifier string, query LiveInputGetParams, opts ...option.RequestOption) (res *LiveInput, err error) { opts = append(r.Options[:], opts...) var env LiveInputGetResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", query.AccountID, liveInputIdentifier) @@ -100,7 +101,7 @@ func (r *LiveInputService) Get(ctx context.Context, liveInputIdentifier string, } // Details about a live input. -type StreamLiveInput struct { +type LiveInput struct { // The date and time the live input was created. Created time.Time `json:"created" format:"date-time"` // Indicates the number of days after which the live inputs recordings will be @@ -117,28 +118,28 @@ type StreamLiveInput struct { // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In // most cases, the video will initially be viewable as a live video and transition // to on-demand after a condition is satisfied. - Recording StreamLiveInputRecording `json:"recording"` + Recording LiveInputRecording `json:"recording"` // Details for streaming to an live input using RTMPS. - Rtmps StreamLiveInputRtmps `json:"rtmps"` + Rtmps LiveInputRtmps `json:"rtmps"` // Details for playback from an live input using RTMPS. - RtmpsPlayback StreamLiveInputRtmpsPlayback `json:"rtmpsPlayback"` + RtmpsPlayback LiveInputRtmpsPlayback `json:"rtmpsPlayback"` // Details for streaming to a live input using SRT. - Srt StreamLiveInputSrt `json:"srt"` + Srt LiveInputSrt `json:"srt"` // Details for playback from an live input using SRT. - SrtPlayback StreamLiveInputSrtPlayback `json:"srtPlayback"` + SrtPlayback LiveInputSrtPlayback `json:"srtPlayback"` // The connection status of a live input. - Status StreamLiveInputStatus `json:"status,nullable"` + Status LiveInputStatus `json:"status,nullable"` // A unique identifier for a live input. - Uid string `json:"uid"` + UID string `json:"uid"` // Details for streaming to a live input using WebRTC. - WebRtc StreamLiveInputWebRtc `json:"webRTC"` + WebRtc LiveInputWebRtc `json:"webRTC"` // Details for playback from a live input using WebRTC. - WebRtcPlayback StreamLiveInputWebRtcPlayback `json:"webRTCPlayback"` - JSON streamLiveInputJSON `json:"-"` + WebRtcPlayback LiveInputWebRtcPlayback `json:"webRTCPlayback"` + JSON liveInputJSON `json:"-"` } -// streamLiveInputJSON contains the JSON metadata for the struct [StreamLiveInput] -type streamLiveInputJSON struct { +// liveInputJSON contains the JSON metadata for the struct [LiveInput] +type liveInputJSON struct { Created apijson.Field DeleteRecordingAfterDays apijson.Field Meta apijson.Field @@ -149,25 +150,25 @@ type streamLiveInputJSON struct { Srt apijson.Field SrtPlayback apijson.Field Status apijson.Field - Uid apijson.Field + UID apijson.Field WebRtc apijson.Field WebRtcPlayback apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamLiveInput) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputJSON) RawJSON() string { +func (r liveInputJSON) RawJSON() string { return r.raw } // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In // most cases, the video will initially be viewable as a live video and transition // to on-demand after a condition is satisfied. -type StreamLiveInputRecording struct { +type LiveInputRecording struct { // Lists the origins allowed to display videos created with this input. Enter // allowed origin domains in an array and use `*` for wildcard subdomains. An empty // array allows videos to be viewed on any origin. @@ -175,7 +176,7 @@ type StreamLiveInputRecording struct { // Specifies the recording behavior for the live input. Set this value to `off` to // prevent a recording. Set the value to `automatic` to begin a recording and // transition to on-demand after Stream Live stops receiving input. - Mode StreamLiveInputRecordingMode `json:"mode"` + Mode LiveInputRecordingMode `json:"mode"` // Indicates if a video using the live input has the `requireSignedURLs` property // set. Also enforces access controls on any video recording of the livestream with // the live input. @@ -183,13 +184,13 @@ type StreamLiveInputRecording struct { // Determines the amount of time a live input configured in `automatic` mode should // wait before a recording transitions from live to on-demand. `0` is recommended // for most use cases and indicates the platform default should be used. - TimeoutSeconds int64 `json:"timeoutSeconds"` - JSON streamLiveInputRecordingJSON `json:"-"` + TimeoutSeconds int64 `json:"timeoutSeconds"` + JSON liveInputRecordingJSON `json:"-"` } -// streamLiveInputRecordingJSON contains the JSON metadata for the struct -// [StreamLiveInputRecording] -type streamLiveInputRecordingJSON struct { +// liveInputRecordingJSON contains the JSON metadata for the struct +// [LiveInputRecording] +type liveInputRecordingJSON struct { AllowedOrigins apijson.Field Mode apijson.Field RequireSignedURLs apijson.Field @@ -198,98 +199,96 @@ type streamLiveInputRecordingJSON struct { ExtraFields map[string]apijson.Field } -func (r *StreamLiveInputRecording) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInputRecording) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputRecordingJSON) RawJSON() string { +func (r liveInputRecordingJSON) RawJSON() string { return r.raw } // Specifies the recording behavior for the live input. Set this value to `off` to // prevent a recording. Set the value to `automatic` to begin a recording and // transition to on-demand after Stream Live stops receiving input. -type StreamLiveInputRecordingMode string +type LiveInputRecordingMode string const ( - StreamLiveInputRecordingModeOff StreamLiveInputRecordingMode = "off" - StreamLiveInputRecordingModeAutomatic StreamLiveInputRecordingMode = "automatic" + LiveInputRecordingModeOff LiveInputRecordingMode = "off" + LiveInputRecordingModeAutomatic LiveInputRecordingMode = "automatic" ) -func (r StreamLiveInputRecordingMode) IsKnown() bool { +func (r LiveInputRecordingMode) IsKnown() bool { switch r { - case StreamLiveInputRecordingModeOff, StreamLiveInputRecordingModeAutomatic: + case LiveInputRecordingModeOff, LiveInputRecordingModeAutomatic: return true } return false } // Details for streaming to an live input using RTMPS. -type StreamLiveInputRtmps struct { +type LiveInputRtmps struct { // The secret key to use when streaming via RTMPS to a live input. StreamKey string `json:"streamKey"` // The RTMPS URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputRtmpsJSON `json:"-"` + URL string `json:"url"` + JSON liveInputRtmpsJSON `json:"-"` } -// streamLiveInputRtmpsJSON contains the JSON metadata for the struct -// [StreamLiveInputRtmps] -type streamLiveInputRtmpsJSON struct { +// liveInputRtmpsJSON contains the JSON metadata for the struct [LiveInputRtmps] +type liveInputRtmpsJSON struct { StreamKey apijson.Field URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamLiveInputRtmps) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInputRtmps) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputRtmpsJSON) RawJSON() string { +func (r liveInputRtmpsJSON) RawJSON() string { return r.raw } // Details for playback from an live input using RTMPS. -type StreamLiveInputRtmpsPlayback struct { +type LiveInputRtmpsPlayback struct { // The secret key to use for playback via RTMPS. StreamKey string `json:"streamKey"` // The URL used to play live video over RTMPS. - URL string `json:"url"` - JSON streamLiveInputRtmpsPlaybackJSON `json:"-"` + URL string `json:"url"` + JSON liveInputRtmpsPlaybackJSON `json:"-"` } -// streamLiveInputRtmpsPlaybackJSON contains the JSON metadata for the struct -// [StreamLiveInputRtmpsPlayback] -type streamLiveInputRtmpsPlaybackJSON struct { +// liveInputRtmpsPlaybackJSON contains the JSON metadata for the struct +// [LiveInputRtmpsPlayback] +type liveInputRtmpsPlaybackJSON struct { StreamKey apijson.Field URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamLiveInputRtmpsPlayback) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInputRtmpsPlayback) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputRtmpsPlaybackJSON) RawJSON() string { +func (r liveInputRtmpsPlaybackJSON) RawJSON() string { return r.raw } // Details for streaming to a live input using SRT. -type StreamLiveInputSrt struct { +type LiveInputSrt struct { // The secret key to use when streaming via SRT to a live input. Passphrase string `json:"passphrase"` // The identifier of the live input to use when streaming via SRT. StreamID string `json:"streamId"` // The SRT URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputSrtJSON `json:"-"` + URL string `json:"url"` + JSON liveInputSrtJSON `json:"-"` } -// streamLiveInputSrtJSON contains the JSON metadata for the struct -// [StreamLiveInputSrt] -type streamLiveInputSrtJSON struct { +// liveInputSrtJSON contains the JSON metadata for the struct [LiveInputSrt] +type liveInputSrtJSON struct { Passphrase apijson.Field StreamID apijson.Field URL apijson.Field @@ -297,28 +296,28 @@ type streamLiveInputSrtJSON struct { ExtraFields map[string]apijson.Field } -func (r *StreamLiveInputSrt) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInputSrt) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputSrtJSON) RawJSON() string { +func (r liveInputSrtJSON) RawJSON() string { return r.raw } // Details for playback from an live input using SRT. -type StreamLiveInputSrtPlayback struct { +type LiveInputSrtPlayback struct { // The secret key to use for playback via SRT. Passphrase string `json:"passphrase"` // The identifier of the live input to use for playback via SRT. StreamID string `json:"streamId"` // The URL used to play live video over SRT. - URL string `json:"url"` - JSON streamLiveInputSrtPlaybackJSON `json:"-"` + URL string `json:"url"` + JSON liveInputSrtPlaybackJSON `json:"-"` } -// streamLiveInputSrtPlaybackJSON contains the JSON metadata for the struct -// [StreamLiveInputSrtPlayback] -type streamLiveInputSrtPlaybackJSON struct { +// liveInputSrtPlaybackJSON contains the JSON metadata for the struct +// [LiveInputSrtPlayback] +type liveInputSrtPlaybackJSON struct { Passphrase apijson.Field StreamID apijson.Field URL apijson.Field @@ -326,79 +325,78 @@ type streamLiveInputSrtPlaybackJSON struct { ExtraFields map[string]apijson.Field } -func (r *StreamLiveInputSrtPlayback) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInputSrtPlayback) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputSrtPlaybackJSON) RawJSON() string { +func (r liveInputSrtPlaybackJSON) RawJSON() string { return r.raw } // The connection status of a live input. -type StreamLiveInputStatus string +type LiveInputStatus string const ( - StreamLiveInputStatusConnected StreamLiveInputStatus = "connected" - StreamLiveInputStatusReconnected StreamLiveInputStatus = "reconnected" - StreamLiveInputStatusReconnecting StreamLiveInputStatus = "reconnecting" - StreamLiveInputStatusClientDisconnect StreamLiveInputStatus = "client_disconnect" - StreamLiveInputStatusTTLExceeded StreamLiveInputStatus = "ttl_exceeded" - StreamLiveInputStatusFailedToConnect StreamLiveInputStatus = "failed_to_connect" - StreamLiveInputStatusFailedToReconnect StreamLiveInputStatus = "failed_to_reconnect" - StreamLiveInputStatusNewConfigurationAccepted StreamLiveInputStatus = "new_configuration_accepted" + LiveInputStatusConnected LiveInputStatus = "connected" + LiveInputStatusReconnected LiveInputStatus = "reconnected" + LiveInputStatusReconnecting LiveInputStatus = "reconnecting" + LiveInputStatusClientDisconnect LiveInputStatus = "client_disconnect" + LiveInputStatusTTLExceeded LiveInputStatus = "ttl_exceeded" + LiveInputStatusFailedToConnect LiveInputStatus = "failed_to_connect" + LiveInputStatusFailedToReconnect LiveInputStatus = "failed_to_reconnect" + LiveInputStatusNewConfigurationAccepted LiveInputStatus = "new_configuration_accepted" ) -func (r StreamLiveInputStatus) IsKnown() bool { +func (r LiveInputStatus) IsKnown() bool { switch r { - case StreamLiveInputStatusConnected, StreamLiveInputStatusReconnected, StreamLiveInputStatusReconnecting, StreamLiveInputStatusClientDisconnect, StreamLiveInputStatusTTLExceeded, StreamLiveInputStatusFailedToConnect, StreamLiveInputStatusFailedToReconnect, StreamLiveInputStatusNewConfigurationAccepted: + case LiveInputStatusConnected, LiveInputStatusReconnected, LiveInputStatusReconnecting, LiveInputStatusClientDisconnect, LiveInputStatusTTLExceeded, LiveInputStatusFailedToConnect, LiveInputStatusFailedToReconnect, LiveInputStatusNewConfigurationAccepted: return true } return false } // Details for streaming to a live input using WebRTC. -type StreamLiveInputWebRtc struct { +type LiveInputWebRtc struct { // The WebRTC URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputWebRtcJSON `json:"-"` + URL string `json:"url"` + JSON liveInputWebRtcJSON `json:"-"` } -// streamLiveInputWebRtcJSON contains the JSON metadata for the struct -// [StreamLiveInputWebRtc] -type streamLiveInputWebRtcJSON struct { +// liveInputWebRtcJSON contains the JSON metadata for the struct [LiveInputWebRtc] +type liveInputWebRtcJSON struct { URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamLiveInputWebRtc) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInputWebRtc) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputWebRtcJSON) RawJSON() string { +func (r liveInputWebRtcJSON) RawJSON() string { return r.raw } // Details for playback from a live input using WebRTC. -type StreamLiveInputWebRtcPlayback struct { +type LiveInputWebRtcPlayback struct { // The URL used to play live video over WebRTC. - URL string `json:"url"` - JSON streamLiveInputWebRtcPlaybackJSON `json:"-"` + URL string `json:"url"` + JSON liveInputWebRtcPlaybackJSON `json:"-"` } -// streamLiveInputWebRtcPlaybackJSON contains the JSON metadata for the struct -// [StreamLiveInputWebRtcPlayback] -type streamLiveInputWebRtcPlaybackJSON struct { +// liveInputWebRtcPlaybackJSON contains the JSON metadata for the struct +// [LiveInputWebRtcPlayback] +type liveInputWebRtcPlaybackJSON struct { URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamLiveInputWebRtcPlayback) UnmarshalJSON(data []byte) (err error) { +func (r *LiveInputWebRtcPlayback) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamLiveInputWebRtcPlaybackJSON) RawJSON() string { +func (r liveInputWebRtcPlaybackJSON) RawJSON() string { return r.raw } @@ -444,7 +442,7 @@ type LiveInputListResponseLiveInput struct { // The date and time the live input was last modified. Modified time.Time `json:"modified" format:"date-time"` // A unique identifier for a live input. - Uid string `json:"uid"` + UID string `json:"uid"` JSON liveInputListResponseLiveInputJSON `json:"-"` } @@ -455,7 +453,7 @@ type liveInputListResponseLiveInputJSON struct { DeleteRecordingAfterDays apijson.Field Meta apijson.Field Modified apijson.Field - Uid apijson.Field + UID apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -537,10 +535,10 @@ func (r LiveInputNewParamsRecordingMode) IsKnown() bool { } type LiveInputNewResponseEnvelope struct { - Errors []LiveInputNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LiveInputNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Details about a live input. - Result StreamLiveInput `json:"result,required"` + Result LiveInput `json:"result,required"` // Whether the API call was successful Success LiveInputNewResponseEnvelopeSuccess `json:"success,required"` JSON liveInputNewResponseEnvelopeJSON `json:"-"` @@ -565,52 +563,6 @@ func (r liveInputNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LiveInputNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// liveInputNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [LiveInputNewResponseEnvelopeErrors] -type liveInputNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LiveInputNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// liveInputNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LiveInputNewResponseEnvelopeMessages] -type liveInputNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LiveInputNewResponseEnvelopeSuccess bool @@ -695,10 +647,10 @@ func (r LiveInputUpdateParamsRecordingMode) IsKnown() bool { } type LiveInputUpdateResponseEnvelope struct { - Errors []LiveInputUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LiveInputUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Details about a live input. - Result StreamLiveInput `json:"result,required"` + Result LiveInput `json:"result,required"` // Whether the API call was successful Success LiveInputUpdateResponseEnvelopeSuccess `json:"success,required"` JSON liveInputUpdateResponseEnvelopeJSON `json:"-"` @@ -723,52 +675,6 @@ func (r liveInputUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LiveInputUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// liveInputUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LiveInputUpdateResponseEnvelopeErrors] -type liveInputUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LiveInputUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// liveInputUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LiveInputUpdateResponseEnvelopeMessages] -type liveInputUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LiveInputUpdateResponseEnvelopeSuccess bool @@ -795,15 +701,15 @@ type LiveInputListParams struct { // URLQuery serializes [LiveInputListParams]'s query parameters as `url.Values`. func (r LiveInputListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type LiveInputListResponseEnvelope struct { - Errors []LiveInputListResponseEnvelopeErrors `json:"errors,required"` - Messages []LiveInputListResponseEnvelopeMessages `json:"messages,required"` - Result LiveInputListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LiveInputListResponse `json:"result,required"` // Whether the API call was successful Success LiveInputListResponseEnvelopeSuccess `json:"success,required"` JSON liveInputListResponseEnvelopeJSON `json:"-"` @@ -828,52 +734,6 @@ func (r liveInputListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LiveInputListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputListResponseEnvelopeErrorsJSON `json:"-"` -} - -// liveInputListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LiveInputListResponseEnvelopeErrors] -type liveInputListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LiveInputListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputListResponseEnvelopeMessagesJSON `json:"-"` -} - -// liveInputListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LiveInputListResponseEnvelopeMessages] -type liveInputListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LiveInputListResponseEnvelopeSuccess bool @@ -892,6 +752,11 @@ func (r LiveInputListResponseEnvelopeSuccess) IsKnown() bool { type LiveInputDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r LiveInputDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type LiveInputGetParams struct { @@ -900,10 +765,10 @@ type LiveInputGetParams struct { } type LiveInputGetResponseEnvelope struct { - Errors []LiveInputGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LiveInputGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Details about a live input. - Result StreamLiveInput `json:"result,required"` + Result LiveInput `json:"result,required"` // Whether the API call was successful Success LiveInputGetResponseEnvelopeSuccess `json:"success,required"` JSON liveInputGetResponseEnvelopeJSON `json:"-"` @@ -928,52 +793,6 @@ func (r liveInputGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LiveInputGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// liveInputGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [LiveInputGetResponseEnvelopeErrors] -type liveInputGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LiveInputGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// liveInputGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LiveInputGetResponseEnvelopeMessages] -type liveInputGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LiveInputGetResponseEnvelopeSuccess bool diff --git a/stream/liveinput_test.go b/stream/liveinput_test.go index e34ae982654..60c0c11215a 100644 --- a/stream/liveinput_test.go +++ b/stream/liveinput_test.go @@ -138,6 +138,7 @@ func TestLiveInputDelete(t *testing.T) { "66be4bf738797e01e1fca35a7bdecdcd", stream.LiveInputDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/stream/liveinputoutput.go b/stream/liveinputoutput.go index 1d163725dc0..a3b4ab31e4c 100644 --- a/stream/liveinputoutput.go +++ b/stream/liveinputoutput.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -35,7 +36,7 @@ func NewLiveInputOutputService(opts ...option.RequestOption) (r *LiveInputOutput // Creates a new output that can be used to simulcast or restream live video to // other RTMP or SRT destinations. Outputs are always linked to a specific live // input — one live input can have many outputs. -func (r *LiveInputOutputService) New(ctx context.Context, liveInputIdentifier string, params LiveInputOutputNewParams, opts ...option.RequestOption) (res *StreamOutput, err error) { +func (r *LiveInputOutputService) New(ctx context.Context, liveInputIdentifier string, params LiveInputOutputNewParams, opts ...option.RequestOption) (res *Output, err error) { opts = append(r.Options[:], opts...) var env LiveInputOutputNewResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs", params.AccountID, liveInputIdentifier) @@ -48,7 +49,7 @@ func (r *LiveInputOutputService) New(ctx context.Context, liveInputIdentifier st } // Updates the state of an output. -func (r *LiveInputOutputService) Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params LiveInputOutputUpdateParams, opts ...option.RequestOption) (res *StreamOutput, err error) { +func (r *LiveInputOutputService) Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params LiveInputOutputUpdateParams, opts ...option.RequestOption) (res *Output, err error) { opts = append(r.Options[:], opts...) var env LiveInputOutputUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs/%s", params.AccountID, liveInputIdentifier, outputIdentifier) @@ -61,7 +62,7 @@ func (r *LiveInputOutputService) Update(ctx context.Context, liveInputIdentifier } // Retrieves all outputs associated with a specified live input. -func (r *LiveInputOutputService) List(ctx context.Context, liveInputIdentifier string, query LiveInputOutputListParams, opts ...option.RequestOption) (res *pagination.SinglePage[StreamOutput], err error) { +func (r *LiveInputOutputService) List(ctx context.Context, liveInputIdentifier string, query LiveInputOutputListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Output], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -79,20 +80,20 @@ func (r *LiveInputOutputService) List(ctx context.Context, liveInputIdentifier s } // Retrieves all outputs associated with a specified live input. -func (r *LiveInputOutputService) ListAutoPaging(ctx context.Context, liveInputIdentifier string, query LiveInputOutputListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[StreamOutput] { +func (r *LiveInputOutputService) ListAutoPaging(ctx context.Context, liveInputIdentifier string, query LiveInputOutputListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Output] { return pagination.NewSinglePageAutoPager(r.List(ctx, liveInputIdentifier, query, opts...)) } // Deletes an output and removes it from the associated live input. -func (r *LiveInputOutputService) Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, body LiveInputOutputDeleteParams, opts ...option.RequestOption) (err error) { +func (r *LiveInputOutputService) Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params LiveInputOutputDeleteParams, opts ...option.RequestOption) (err error) { opts = append(r.Options[:], opts...) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs/%s", body.AccountID, liveInputIdentifier, outputIdentifier) + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs/%s", params.AccountID, liveInputIdentifier, outputIdentifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) return } -type StreamOutput struct { +type Output struct { // When enabled, live video streamed to the associated live input will be sent to // the output URL. When disabled, live video will not be sent to the output URL, // even when streaming to the associated live input. Use this to control precisely @@ -102,27 +103,27 @@ type StreamOutput struct { // The streamKey used to authenticate against an output's target. StreamKey string `json:"streamKey"` // A unique identifier for the output. - Uid string `json:"uid"` + UID string `json:"uid"` // The URL an output uses to restream. - URL string `json:"url"` - JSON streamOutputJSON `json:"-"` + URL string `json:"url"` + JSON outputJSON `json:"-"` } -// streamOutputJSON contains the JSON metadata for the struct [StreamOutput] -type streamOutputJSON struct { +// outputJSON contains the JSON metadata for the struct [Output] +type outputJSON struct { Enabled apijson.Field StreamKey apijson.Field - Uid apijson.Field + UID apijson.Field URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamOutput) UnmarshalJSON(data []byte) (err error) { +func (r *Output) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamOutputJSON) RawJSON() string { +func (r outputJSON) RawJSON() string { return r.raw } @@ -146,9 +147,9 @@ func (r LiveInputOutputNewParams) MarshalJSON() (data []byte, err error) { } type LiveInputOutputNewResponseEnvelope struct { - Errors []LiveInputOutputNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LiveInputOutputNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamOutput `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Output `json:"result,required"` // Whether the API call was successful Success LiveInputOutputNewResponseEnvelopeSuccess `json:"success,required"` JSON liveInputOutputNewResponseEnvelopeJSON `json:"-"` @@ -173,52 +174,6 @@ func (r liveInputOutputNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LiveInputOutputNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputOutputNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// liveInputOutputNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LiveInputOutputNewResponseEnvelopeErrors] -type liveInputOutputNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputOutputNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputOutputNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LiveInputOutputNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputOutputNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// liveInputOutputNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LiveInputOutputNewResponseEnvelopeMessages] -type liveInputOutputNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputOutputNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputOutputNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LiveInputOutputNewResponseEnvelopeSuccess bool @@ -250,9 +205,9 @@ func (r LiveInputOutputUpdateParams) MarshalJSON() (data []byte, err error) { } type LiveInputOutputUpdateResponseEnvelope struct { - Errors []LiveInputOutputUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LiveInputOutputUpdateResponseEnvelopeMessages `json:"messages,required"` - Result StreamOutput `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Output `json:"result,required"` // Whether the API call was successful Success LiveInputOutputUpdateResponseEnvelopeSuccess `json:"success,required"` JSON liveInputOutputUpdateResponseEnvelopeJSON `json:"-"` @@ -277,52 +232,6 @@ func (r liveInputOutputUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type LiveInputOutputUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputOutputUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// liveInputOutputUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LiveInputOutputUpdateResponseEnvelopeErrors] -type liveInputOutputUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputOutputUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputOutputUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LiveInputOutputUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON liveInputOutputUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// liveInputOutputUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LiveInputOutputUpdateResponseEnvelopeMessages] -type liveInputOutputUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LiveInputOutputUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r liveInputOutputUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type LiveInputOutputUpdateResponseEnvelopeSuccess bool @@ -346,4 +255,9 @@ type LiveInputOutputListParams struct { type LiveInputOutputDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r LiveInputOutputDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } diff --git a/stream/liveinputoutput_test.go b/stream/liveinputoutput_test.go index 9aa171cb887..91f851fb5ee 100644 --- a/stream/liveinputoutput_test.go +++ b/stream/liveinputoutput_test.go @@ -129,6 +129,7 @@ func TestLiveInputOutputDelete(t *testing.T) { "baea4d9c515887b80289d5c33cf01145", stream.LiveInputOutputDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/stream/stream.go b/stream/stream.go index d3881e1f5ab..7e074ab1f14 100644 --- a/stream/stream.go +++ b/stream/stream.go @@ -14,6 +14,7 @@ import ( "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" ) @@ -74,7 +75,7 @@ func (r *StreamService) New(ctx context.Context, params StreamNewParams, opts .. // Lists up to 1000 videos from a single request. For a specific range, refer to // the optional parameters. -func (r *StreamService) List(ctx context.Context, params StreamListParams, opts ...option.RequestOption) (res *pagination.SinglePage[StreamVideos], err error) { +func (r *StreamService) List(ctx context.Context, params StreamListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Video], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -93,21 +94,21 @@ func (r *StreamService) List(ctx context.Context, params StreamListParams, opts // Lists up to 1000 videos from a single request. For a specific range, refer to // the optional parameters. -func (r *StreamService) ListAutoPaging(ctx context.Context, params StreamListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[StreamVideos] { +func (r *StreamService) ListAutoPaging(ctx context.Context, params StreamListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Video] { return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...)) } // Deletes a video and its copies from Cloudflare Stream. -func (r *StreamService) Delete(ctx context.Context, identifier string, body StreamDeleteParams, opts ...option.RequestOption) (err error) { +func (r *StreamService) Delete(ctx context.Context, identifier string, params StreamDeleteParams, opts ...option.RequestOption) (err error) { opts = append(r.Options[:], opts...) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/stream/%s", body.AccountID, identifier) + path := fmt.Sprintf("accounts/%s/stream/%s", params.AccountID, identifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) return } // Fetches details for a single video. -func (r *StreamService) Get(ctx context.Context, identifier string, query StreamGetParams, opts ...option.RequestOption) (res *StreamVideos, err error) { +func (r *StreamService) Get(ctx context.Context, identifier string, query StreamGetParams, opts ...option.RequestOption) (res *Video, err error) { opts = append(r.Options[:], opts...) var env StreamGetResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/%s", query.AccountID, identifier) @@ -119,11 +120,15 @@ func (r *StreamService) Get(ctx context.Context, identifier string, query Stream return } -type StreamVideos struct { +type AllowedOrigins = 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 []string `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. @@ -131,8 +136,8 @@ type StreamVideos struct { // The duration of the video in seconds. A value of `-1` means the duration is // unknown. The duration becomes available after the upload and before the video is // ready. - Duration float64 `json:"duration"` - Input StreamVideosInput `json:"input"` + Duration float64 `json:"duration"` + Input VideoInput `json:"input"` // The live input ID used to upload a video with Stream Live. LiveInput string `json:"liveInput"` // The maximum duration in seconds for a video upload. Can be set for a video that @@ -144,8 +149,8 @@ type StreamVideos struct { // managing videos. Meta interface{} `json:"meta"` // The date and time the media item was last modified. - Modified time.Time `json:"modified" format:"date-time"` - Playback StreamVideosPlayback `json:"playback"` + Modified time.Time `json:"modified" format:"date-time"` + Playback VideoPlayback `json:"playback"` // The video's preview page URI. This field is omitted until encoding is complete. Preview string `json:"preview" format:"uri"` // Indicates whether the video is playable. The field is empty if the video is not @@ -168,7 +173,7 @@ type StreamVideos struct { // `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the // approximate percent of completion. If the `state` is `error`, `errorReasonCode` // and `errorReasonText` provide additional details. - Status StreamVideosStatus `json:"status"` + Status VideoStatus `json:"status"` // The media item's thumbnail URI. This field is omitted until encoding is // complete. Thumbnail string `json:"thumbnail" format:"uri"` @@ -178,18 +183,18 @@ type StreamVideos struct { // is not set, the default thumbnail image is taken from 0s of the video. ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` + UID string `json:"uid"` // The date and time the media item was uploaded. Uploaded time.Time `json:"uploaded" format:"date-time"` // The date and time when the video upload URL is no longer valid for direct user // uploads. - UploadExpiry time.Time `json:"uploadExpiry" format:"date-time"` - Watermark StreamWatermarks `json:"watermark"` - JSON streamVideosJSON `json:"-"` + UploadExpiry time.Time `json:"uploadExpiry" format:"date-time"` + Watermark Watermaks `json:"watermark"` + JSON videoJSON `json:"-"` } -// streamVideosJSON contains the JSON metadata for the struct [StreamVideos] -type streamVideosJSON struct { +// videoJSON contains the JSON metadata for the struct [Video] +type videoJSON struct { AllowedOrigins apijson.Field Created apijson.Field Creator apijson.Field @@ -209,7 +214,7 @@ type streamVideosJSON struct { Status apijson.Field Thumbnail apijson.Field ThumbnailTimestampPct apijson.Field - Uid apijson.Field + UID apijson.Field Uploaded apijson.Field UploadExpiry apijson.Field Watermark apijson.Field @@ -217,63 +222,61 @@ type streamVideosJSON struct { ExtraFields map[string]apijson.Field } -func (r *StreamVideos) UnmarshalJSON(data []byte) (err error) { +func (r *Video) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamVideosJSON) RawJSON() string { +func (r videoJSON) RawJSON() string { return r.raw } -type StreamVideosInput struct { +type VideoInput struct { // The video height in pixels. A value of `-1` means the height is unknown. The // value becomes available after the upload and before the video is ready. Height int64 `json:"height"` // The video width in pixels. A value of `-1` means the width is unknown. The value // becomes available after the upload and before the video is ready. - Width int64 `json:"width"` - JSON streamVideosInputJSON `json:"-"` + Width int64 `json:"width"` + JSON videoInputJSON `json:"-"` } -// streamVideosInputJSON contains the JSON metadata for the struct -// [StreamVideosInput] -type streamVideosInputJSON struct { +// videoInputJSON contains the JSON metadata for the struct [VideoInput] +type videoInputJSON struct { Height apijson.Field Width apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamVideosInput) UnmarshalJSON(data []byte) (err error) { +func (r *VideoInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamVideosInputJSON) RawJSON() string { +func (r videoInputJSON) RawJSON() string { return r.raw } -type StreamVideosPlayback struct { +type VideoPlayback struct { // DASH Media Presentation Description for the video. Dash string `json:"dash"` // The HLS manifest for the video. - Hls string `json:"hls"` - JSON streamVideosPlaybackJSON `json:"-"` + Hls string `json:"hls"` + JSON videoPlaybackJSON `json:"-"` } -// streamVideosPlaybackJSON contains the JSON metadata for the struct -// [StreamVideosPlayback] -type streamVideosPlaybackJSON struct { +// videoPlaybackJSON contains the JSON metadata for the struct [VideoPlayback] +type videoPlaybackJSON struct { Dash apijson.Field Hls apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamVideosPlayback) UnmarshalJSON(data []byte) (err error) { +func (r *VideoPlayback) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamVideosPlaybackJSON) RawJSON() string { +func (r videoPlaybackJSON) RawJSON() string { return r.raw } @@ -282,7 +285,7 @@ func (r streamVideosPlaybackJSON) RawJSON() string { // `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the // approximate percent of completion. If the `state` is `error`, `errorReasonCode` // and `errorReasonText` provide additional details. -type StreamVideosStatus struct { +type VideoStatus struct { // Specifies why the video failed to encode. This field is empty if the video is // not in an `error` state. Preferred for programmatic use. ErrorReasonCode string `json:"errorReasonCode"` @@ -293,13 +296,12 @@ type StreamVideosStatus struct { // non-negative integer. PctComplete string `json:"pctComplete"` // Specifies the processing status for all quality levels for a video. - State StreamVideosStatusState `json:"state"` - JSON streamVideosStatusJSON `json:"-"` + State VideoStatusState `json:"state"` + JSON videoStatusJSON `json:"-"` } -// streamVideosStatusJSON contains the JSON metadata for the struct -// [StreamVideosStatus] -type streamVideosStatusJSON struct { +// videoStatusJSON contains the JSON metadata for the struct [VideoStatus] +type videoStatusJSON struct { ErrorReasonCode apijson.Field ErrorReasonText apijson.Field PctComplete apijson.Field @@ -308,29 +310,29 @@ type streamVideosStatusJSON struct { ExtraFields map[string]apijson.Field } -func (r *StreamVideosStatus) UnmarshalJSON(data []byte) (err error) { +func (r *VideoStatus) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamVideosStatusJSON) RawJSON() string { +func (r videoStatusJSON) RawJSON() string { return r.raw } // Specifies the processing status for all quality levels for a video. -type StreamVideosStatusState string +type VideoStatusState string const ( - StreamVideosStatusStatePendingupload StreamVideosStatusState = "pendingupload" - StreamVideosStatusStateDownloading StreamVideosStatusState = "downloading" - StreamVideosStatusStateQueued StreamVideosStatusState = "queued" - StreamVideosStatusStateInprogress StreamVideosStatusState = "inprogress" - StreamVideosStatusStateReady StreamVideosStatusState = "ready" - StreamVideosStatusStateError StreamVideosStatusState = "error" + VideoStatusStatePendingupload VideoStatusState = "pendingupload" + VideoStatusStateDownloading VideoStatusState = "downloading" + VideoStatusStateQueued VideoStatusState = "queued" + VideoStatusStateInprogress VideoStatusState = "inprogress" + VideoStatusStateReady VideoStatusState = "ready" + VideoStatusStateError VideoStatusState = "error" ) -func (r StreamVideosStatusState) IsKnown() bool { +func (r VideoStatusState) IsKnown() bool { switch r { - case StreamVideosStatusStatePendingupload, StreamVideosStatusStateDownloading, StreamVideosStatusStateQueued, StreamVideosStatusStateInprogress, StreamVideosStatusStateReady, StreamVideosStatusStateError: + case VideoStatusStatePendingupload, VideoStatusStateDownloading, VideoStatusStateQueued, VideoStatusStateInprogress, VideoStatusStateReady, VideoStatusStateError: return true } return false @@ -339,6 +341,7 @@ func (r StreamVideosStatusState) IsKnown() bool { type StreamNewParams struct { // The account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` // Specifies the TUS protocol version. This value must be included in every upload // request. Notes: The only supported version of TUS protocol is 1.0.0. TusResumable param.Field[StreamNewParamsTusResumable] `header:"Tus-Resumable,required"` @@ -353,6 +356,10 @@ type StreamNewParams struct { UploadMetadata param.Field[string] `header:"Upload-Metadata"` } +func (r StreamNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + // Specifies the TUS protocol version. This value must be included in every upload // request. Notes: The only supported version of TUS protocol is 1.0.0. type StreamNewParamsTusResumable string @@ -395,7 +402,7 @@ type StreamListParams struct { // URLQuery serializes [StreamListParams]'s query parameters as `url.Values`. func (r StreamListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -423,6 +430,11 @@ func (r StreamListParamsStatus) IsKnown() bool { type StreamDeleteParams struct { // The account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r StreamDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type StreamGetParams struct { @@ -431,9 +443,9 @@ type StreamGetParams struct { } type StreamGetResponseEnvelope struct { - Errors []StreamGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamGetResponseEnvelopeMessages `json:"messages,required"` - Result StreamVideos `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Video `json:"result,required"` // Whether the API call was successful Success StreamGetResponseEnvelopeSuccess `json:"success,required"` JSON streamGetResponseEnvelopeJSON `json:"-"` @@ -458,52 +470,6 @@ func (r streamGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type StreamGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [StreamGetResponseEnvelopeErrors] -type streamGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [StreamGetResponseEnvelopeMessages] -type streamGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type StreamGetResponseEnvelopeSuccess bool diff --git a/stream/stream_test.go b/stream/stream_test.go index d51e3c8e703..5cffd011340 100644 --- a/stream/stream_test.go +++ b/stream/stream_test.go @@ -31,6 +31,7 @@ func TestStreamNewWithOptionalParams(t *testing.T) { ) err := client.Stream.New(context.TODO(), stream.StreamNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, TusResumable: cloudflare.F(stream.StreamNewParamsTusResumable1_0_0), UploadLength: cloudflare.F(int64(0)), UploadCreator: cloudflare.F("creator-id_abcde12345"), @@ -98,6 +99,7 @@ func TestStreamDelete(t *testing.T) { "ea95132c15732412d22c1476fa83f27a", stream.StreamDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/stream/token.go b/stream/token.go index 497de50a80c..0b0c65eccfd 100644 --- a/stream/token.go +++ b/stream/token.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -156,9 +157,9 @@ func (r TokenNewParamsAccessRulesType) IsKnown() bool { } type TokenNewResponseEnvelope struct { - Errors []TokenNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TokenNewResponseEnvelopeMessages `json:"messages,required"` - Result TokenNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TokenNewResponse `json:"result,required"` // Whether the API call was successful Success TokenNewResponseEnvelopeSuccess `json:"success,required"` JSON tokenNewResponseEnvelopeJSON `json:"-"` @@ -183,52 +184,6 @@ func (r tokenNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TokenNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// tokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TokenNewResponseEnvelopeErrors] -type tokenNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TokenNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// tokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TokenNewResponseEnvelopeMessages] -type tokenNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TokenNewResponseEnvelopeSuccess bool diff --git a/stream/video.go b/stream/video.go index 30a66691712..21ef9a088e8 100644 --- a/stream/video.go +++ b/stream/video.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -87,15 +88,15 @@ type VideoStorageUsageParams struct { // `url.Values`. func (r VideoStorageUsageParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type VideoStorageUsageResponseEnvelope struct { - Errors []VideoStorageUsageResponseEnvelopeErrors `json:"errors,required"` - Messages []VideoStorageUsageResponseEnvelopeMessages `json:"messages,required"` - Result VideoStorageUsageResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result VideoStorageUsageResponse `json:"result,required"` // Whether the API call was successful Success VideoStorageUsageResponseEnvelopeSuccess `json:"success,required"` JSON videoStorageUsageResponseEnvelopeJSON `json:"-"` @@ -120,52 +121,6 @@ func (r videoStorageUsageResponseEnvelopeJSON) RawJSON() string { return r.raw } -type VideoStorageUsageResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON videoStorageUsageResponseEnvelopeErrorsJSON `json:"-"` -} - -// videoStorageUsageResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [VideoStorageUsageResponseEnvelopeErrors] -type videoStorageUsageResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VideoStorageUsageResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r videoStorageUsageResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VideoStorageUsageResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON videoStorageUsageResponseEnvelopeMessagesJSON `json:"-"` -} - -// videoStorageUsageResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [VideoStorageUsageResponseEnvelopeMessages] -type videoStorageUsageResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VideoStorageUsageResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r videoStorageUsageResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type VideoStorageUsageResponseEnvelopeSuccess bool diff --git a/stream/watermark.go b/stream/watermark.go index 5dbb55c7937..21e7f959007 100644 --- a/stream/watermark.go +++ b/stream/watermark.go @@ -37,7 +37,7 @@ func NewWatermarkService(opts ...option.RequestOption) (r *WatermarkService) { // Creates watermark profiles using a single `HTTP POST multipart/form-data` // request. -func (r *WatermarkService) New(ctx context.Context, params WatermarkNewParams, opts ...option.RequestOption) (res *WatermarkNewResponse, err error) { +func (r *WatermarkService) New(ctx context.Context, params WatermarkNewParams, opts ...option.RequestOption) (res *WatermarkNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WatermarkNewResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/watermarks", params.AccountID) @@ -50,7 +50,7 @@ func (r *WatermarkService) New(ctx context.Context, params WatermarkNewParams, o } // Lists all watermark profiles for an account. -func (r *WatermarkService) List(ctx context.Context, query WatermarkListParams, opts ...option.RequestOption) (res *pagination.SinglePage[StreamWatermarks], err error) { +func (r *WatermarkService) List(ctx context.Context, query WatermarkListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Watermaks], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -68,15 +68,15 @@ func (r *WatermarkService) List(ctx context.Context, query WatermarkListParams, } // Lists all watermark profiles for an account. -func (r *WatermarkService) ListAutoPaging(ctx context.Context, query WatermarkListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[StreamWatermarks] { +func (r *WatermarkService) ListAutoPaging(ctx context.Context, query WatermarkListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Watermaks] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a watermark profile. -func (r *WatermarkService) Delete(ctx context.Context, identifier string, body WatermarkDeleteParams, opts ...option.RequestOption) (res *WatermarkDeleteResponse, err error) { +func (r *WatermarkService) Delete(ctx context.Context, identifier string, params WatermarkDeleteParams, opts ...option.RequestOption) (res *WatermarkDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WatermarkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/watermarks/%s", body.AccountID, identifier) + path := fmt.Sprintf("accounts/%s/stream/watermarks/%s", params.AccountID, identifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -86,7 +86,7 @@ func (r *WatermarkService) Delete(ctx context.Context, identifier string, body W } // Retrieves details for a single watermark profile. -func (r *WatermarkService) Get(ctx context.Context, identifier string, query WatermarkGetParams, opts ...option.RequestOption) (res *WatermarkGetResponse, err error) { +func (r *WatermarkService) Get(ctx context.Context, identifier string, query WatermarkGetParams, opts ...option.RequestOption) (res *WatermarkGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WatermarkGetResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/watermarks/%s", query.AccountID, identifier) @@ -98,7 +98,7 @@ func (r *WatermarkService) Get(ctx context.Context, identifier string, query Wat return } -type StreamWatermarks struct { +type Watermaks struct { // The date and a time a watermark profile was created. Created time.Time `json:"created" format:"date-time"` // The source URL for a downloaded image. If the watermark profile was created via @@ -128,15 +128,14 @@ type StreamWatermarks struct { // The size of the image in bytes. Size float64 `json:"size"` // The unique identifier for a watermark profile. - Uid string `json:"uid"` + UID string `json:"uid"` // The width of the image in pixels. - Width int64 `json:"width"` - JSON streamWatermarksJSON `json:"-"` + Width int64 `json:"width"` + JSON watermaksJSON `json:"-"` } -// streamWatermarksJSON contains the JSON metadata for the struct -// [StreamWatermarks] -type streamWatermarksJSON struct { +// watermaksJSON contains the JSON metadata for the struct [Watermaks] +type watermaksJSON struct { Created apijson.Field DownloadedFrom apijson.Field Height apijson.Field @@ -146,28 +145,28 @@ type streamWatermarksJSON struct { Position apijson.Field Scale apijson.Field Size apijson.Field - Uid apijson.Field + UID apijson.Field Width apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *StreamWatermarks) UnmarshalJSON(data []byte) (err error) { +func (r *Watermaks) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r streamWatermarksJSON) RawJSON() string { +func (r watermaksJSON) RawJSON() string { return r.raw } // Union satisfied by [stream.WatermarkNewResponseUnknown] or [shared.UnionString]. -type WatermarkNewResponse interface { - ImplementsStreamWatermarkNewResponse() +type WatermarkNewResponseUnion interface { + ImplementsStreamWatermarkNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WatermarkNewResponse)(nil)).Elem(), + reflect.TypeOf((*WatermarkNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -178,13 +177,13 @@ func init() { // Union satisfied by [stream.WatermarkDeleteResponseUnknown] or // [shared.UnionString]. -type WatermarkDeleteResponse interface { - ImplementsStreamWatermarkDeleteResponse() +type WatermarkDeleteResponseUnion interface { + ImplementsStreamWatermarkDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WatermarkDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*WatermarkDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -194,13 +193,13 @@ func init() { } // Union satisfied by [stream.WatermarkGetResponseUnknown] or [shared.UnionString]. -type WatermarkGetResponse interface { - ImplementsStreamWatermarkGetResponse() +type WatermarkGetResponseUnion interface { + ImplementsStreamWatermarkGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WatermarkGetResponse)(nil)).Elem(), + reflect.TypeOf((*WatermarkGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -240,9 +239,9 @@ func (r WatermarkNewParams) MarshalJSON() (data []byte, err error) { } type WatermarkNewResponseEnvelope struct { - Errors []WatermarkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WatermarkNewResponseEnvelopeMessages `json:"messages,required"` - Result WatermarkNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WatermarkNewResponseUnion `json:"result,required"` // Whether the API call was successful Success WatermarkNewResponseEnvelopeSuccess `json:"success,required"` JSON watermarkNewResponseEnvelopeJSON `json:"-"` @@ -267,52 +266,6 @@ func (r watermarkNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WatermarkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON watermarkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// watermarkNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WatermarkNewResponseEnvelopeErrors] -type watermarkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WatermarkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r watermarkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WatermarkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON watermarkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// watermarkNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WatermarkNewResponseEnvelopeMessages] -type watermarkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WatermarkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r watermarkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WatermarkNewResponseEnvelopeSuccess bool @@ -336,12 +289,17 @@ type WatermarkListParams struct { type WatermarkDeleteParams struct { // The account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r WatermarkDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type WatermarkDeleteResponseEnvelope struct { - Errors []WatermarkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WatermarkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result WatermarkDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WatermarkDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success WatermarkDeleteResponseEnvelopeSuccess `json:"success,required"` JSON watermarkDeleteResponseEnvelopeJSON `json:"-"` @@ -366,52 +324,6 @@ func (r watermarkDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WatermarkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON watermarkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// watermarkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WatermarkDeleteResponseEnvelopeErrors] -type watermarkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WatermarkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r watermarkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WatermarkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON watermarkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// watermarkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WatermarkDeleteResponseEnvelopeMessages] -type watermarkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WatermarkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r watermarkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WatermarkDeleteResponseEnvelopeSuccess bool @@ -433,9 +345,9 @@ type WatermarkGetParams struct { } type WatermarkGetResponseEnvelope struct { - Errors []WatermarkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WatermarkGetResponseEnvelopeMessages `json:"messages,required"` - Result WatermarkGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WatermarkGetResponseUnion `json:"result,required"` // Whether the API call was successful Success WatermarkGetResponseEnvelopeSuccess `json:"success,required"` JSON watermarkGetResponseEnvelopeJSON `json:"-"` @@ -460,52 +372,6 @@ func (r watermarkGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WatermarkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON watermarkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// watermarkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WatermarkGetResponseEnvelopeErrors] -type watermarkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WatermarkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r watermarkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WatermarkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON watermarkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// watermarkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WatermarkGetResponseEnvelopeMessages] -type watermarkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WatermarkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r watermarkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WatermarkGetResponseEnvelopeSuccess bool diff --git a/stream/watermark_test.go b/stream/watermark_test.go index b09a8b52831..325aa80c310 100644 --- a/stream/watermark_test.go +++ b/stream/watermark_test.go @@ -91,6 +91,7 @@ func TestWatermarkDelete(t *testing.T) { "ea95132c15732412d22c1476fa83f27a", stream.WatermarkDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/stream/webhook.go b/stream/webhook.go index 813aed06ef2..f1b8b55eff5 100644 --- a/stream/webhook.go +++ b/stream/webhook.go @@ -34,7 +34,7 @@ func NewWebhookService(opts ...option.RequestOption) (r *WebhookService) { } // Creates a webhook notification. -func (r *WebhookService) Update(ctx context.Context, params WebhookUpdateParams, opts ...option.RequestOption) (res *WebhookUpdateResponse, err error) { +func (r *WebhookService) Update(ctx context.Context, params WebhookUpdateParams, opts ...option.RequestOption) (res *WebhookUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WebhookUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/webhook", params.AccountID) @@ -47,10 +47,10 @@ func (r *WebhookService) Update(ctx context.Context, params WebhookUpdateParams, } // Deletes a webhook. -func (r *WebhookService) Delete(ctx context.Context, body WebhookDeleteParams, opts ...option.RequestOption) (res *WebhookDeleteResponse, err error) { +func (r *WebhookService) Delete(ctx context.Context, params WebhookDeleteParams, opts ...option.RequestOption) (res *WebhookDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WebhookDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/webhook", body.AccountID) + path := fmt.Sprintf("accounts/%s/stream/webhook", params.AccountID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -60,7 +60,7 @@ func (r *WebhookService) Delete(ctx context.Context, body WebhookDeleteParams, o } // Retrieves a list of webhooks. -func (r *WebhookService) Get(ctx context.Context, query WebhookGetParams, opts ...option.RequestOption) (res *WebhookGetResponse, err error) { +func (r *WebhookService) Get(ctx context.Context, query WebhookGetParams, opts ...option.RequestOption) (res *WebhookGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WebhookGetResponseEnvelope path := fmt.Sprintf("accounts/%s/stream/webhook", query.AccountID) @@ -74,13 +74,13 @@ func (r *WebhookService) Get(ctx context.Context, query WebhookGetParams, opts . // Union satisfied by [stream.WebhookUpdateResponseUnknown] or // [shared.UnionString]. -type WebhookUpdateResponse interface { - ImplementsStreamWebhookUpdateResponse() +type WebhookUpdateResponseUnion interface { + ImplementsStreamWebhookUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WebhookUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*WebhookUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -91,13 +91,13 @@ func init() { // Union satisfied by [stream.WebhookDeleteResponseUnknown] or // [shared.UnionString]. -type WebhookDeleteResponse interface { - ImplementsStreamWebhookDeleteResponse() +type WebhookDeleteResponseUnion interface { + ImplementsStreamWebhookDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WebhookDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*WebhookDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -107,13 +107,13 @@ func init() { } // Union satisfied by [stream.WebhookGetResponseUnknown] or [shared.UnionString]. -type WebhookGetResponse interface { - ImplementsStreamWebhookGetResponse() +type WebhookGetResponseUnion interface { + ImplementsStreamWebhookGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WebhookGetResponse)(nil)).Elem(), + reflect.TypeOf((*WebhookGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -134,9 +134,9 @@ func (r WebhookUpdateParams) MarshalJSON() (data []byte, err error) { } type WebhookUpdateResponseEnvelope struct { - Errors []WebhookUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WebhookUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WebhookUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WebhookUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success WebhookUpdateResponseEnvelopeSuccess `json:"success,required"` JSON webhookUpdateResponseEnvelopeJSON `json:"-"` @@ -161,52 +161,6 @@ func (r webhookUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WebhookUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON webhookUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// webhookUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WebhookUpdateResponseEnvelopeErrors] -type webhookUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WebhookUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r webhookUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WebhookUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON webhookUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// webhookUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WebhookUpdateResponseEnvelopeMessages] -type webhookUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WebhookUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r webhookUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WebhookUpdateResponseEnvelopeSuccess bool @@ -225,12 +179,17 @@ func (r WebhookUpdateResponseEnvelopeSuccess) IsKnown() bool { type WebhookDeleteParams struct { // The account identifier tag. AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r WebhookDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type WebhookDeleteResponseEnvelope struct { - Errors []WebhookDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WebhookDeleteResponseEnvelopeMessages `json:"messages,required"` - Result WebhookDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WebhookDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success WebhookDeleteResponseEnvelopeSuccess `json:"success,required"` JSON webhookDeleteResponseEnvelopeJSON `json:"-"` @@ -255,52 +214,6 @@ func (r webhookDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WebhookDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON webhookDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// webhookDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WebhookDeleteResponseEnvelopeErrors] -type webhookDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WebhookDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r webhookDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WebhookDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON webhookDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// webhookDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WebhookDeleteResponseEnvelopeMessages] -type webhookDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WebhookDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r webhookDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WebhookDeleteResponseEnvelopeSuccess bool @@ -322,9 +235,9 @@ type WebhookGetParams struct { } type WebhookGetResponseEnvelope struct { - Errors []WebhookGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WebhookGetResponseEnvelopeMessages `json:"messages,required"` - Result WebhookGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WebhookGetResponseUnion `json:"result,required"` // Whether the API call was successful Success WebhookGetResponseEnvelopeSuccess `json:"success,required"` JSON webhookGetResponseEnvelopeJSON `json:"-"` @@ -349,52 +262,6 @@ func (r webhookGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WebhookGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON webhookGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// webhookGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WebhookGetResponseEnvelopeErrors] -type webhookGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WebhookGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r webhookGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WebhookGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON webhookGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// webhookGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [WebhookGetResponseEnvelopeMessages] -type webhookGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WebhookGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r webhookGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WebhookGetResponseEnvelopeSuccess bool diff --git a/stream/webhook_test.go b/stream/webhook_test.go index c5af1895401..2f7d92d5bd1 100644 --- a/stream/webhook_test.go +++ b/stream/webhook_test.go @@ -57,6 +57,7 @@ func TestWebhookDelete(t *testing.T) { ) _, err := client.Stream.Webhooks.Delete(context.TODO(), stream.WebhookDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }) if err != nil { var apierr *cloudflare.Error diff --git a/subscriptions/aliases.go b/subscriptions/aliases.go index 863fc22cffd..1fd260119b8 100644 --- a/subscriptions/aliases.go +++ b/subscriptions/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/subscriptions/subscription.go b/subscriptions/subscription.go index c09dbc63c83..ab4eda87083 100644 --- a/subscriptions/subscription.go +++ b/subscriptions/subscription.go @@ -7,14 +7,13 @@ import ( "fmt" "net/http" "reflect" - "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" + "github.com/cloudflare/cloudflare-go/v2/user" "github.com/tidwall/gjson" ) @@ -37,7 +36,7 @@ func NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionServic } // Create a zone subscription, either plan or add-ons. -func (r *SubscriptionService) New(ctx context.Context, identifier string, body SubscriptionNewParams, opts ...option.RequestOption) (res *SubscriptionNewResponse, err error) { +func (r *SubscriptionService) New(ctx context.Context, identifier string, body SubscriptionNewParams, opts ...option.RequestOption) (res *SubscriptionNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SubscriptionNewResponseEnvelope path := fmt.Sprintf("zones/%s/subscription", identifier) @@ -50,7 +49,7 @@ func (r *SubscriptionService) New(ctx context.Context, identifier string, body S } // Updates an account subscription. -func (r *SubscriptionService) Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body SubscriptionUpdateParams, opts ...option.RequestOption) (res *SubscriptionUpdateResponse, err error) { +func (r *SubscriptionService) Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body SubscriptionUpdateParams, opts ...option.RequestOption) (res *SubscriptionUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SubscriptionUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/subscriptions/%s", accountIdentifier, subscriptionIdentifier) @@ -63,7 +62,7 @@ func (r *SubscriptionService) Update(ctx context.Context, accountIdentifier stri } // Lists all of an account's subscriptions. -func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[SubscriptionListResponse], err error) { +func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[user.Subscription], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -81,12 +80,12 @@ func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string } // Lists all of an account's subscriptions. -func (r *SubscriptionService) ListAutoPaging(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SubscriptionListResponse] { +func (r *SubscriptionService) ListAutoPaging(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[user.Subscription] { return pagination.NewSinglePageAutoPager(r.List(ctx, accountIdentifier, opts...)) } // Deletes an account's subscription. -func (r *SubscriptionService) Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, opts ...option.RequestOption) (res *SubscriptionDeleteResponse, err error) { +func (r *SubscriptionService) Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body SubscriptionDeleteParams, opts ...option.RequestOption) (res *SubscriptionDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env SubscriptionDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/subscriptions/%s", accountIdentifier, subscriptionIdentifier) @@ -99,7 +98,7 @@ func (r *SubscriptionService) Delete(ctx context.Context, accountIdentifier stri } // Lists zone subscription details. -func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionGetResponse, err error) { +func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SubscriptionGetResponseEnvelope path := fmt.Sprintf("zones/%s/subscription", identifier) @@ -113,13 +112,13 @@ func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts . // Union satisfied by [subscriptions.SubscriptionNewResponseUnknown] or // [shared.UnionString]. -type SubscriptionNewResponse interface { - ImplementsSubscriptionsSubscriptionNewResponse() +type SubscriptionNewResponseUnion interface { + ImplementsSubscriptionsSubscriptionNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionNewResponse)(nil)).Elem(), + reflect.TypeOf((*SubscriptionNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -130,13 +129,13 @@ func init() { // Union satisfied by [subscriptions.SubscriptionUpdateResponseUnknown] or // [shared.UnionString]. -type SubscriptionUpdateResponse interface { - ImplementsSubscriptionsSubscriptionUpdateResponse() +type SubscriptionUpdateResponseUnion interface { + ImplementsSubscriptionsSubscriptionUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*SubscriptionUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -145,218 +144,6 @@ func init() { ) } -type SubscriptionListResponse struct { - // Subscription identifier tag. - ID string `json:"id"` - App SubscriptionListResponseApp `json:"app"` - // The list of add-ons subscribed to. - ComponentValues []SubscriptionListResponseComponentValue `json:"component_values"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency"` - // The end of the current period and also when the next billing is due. - CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` - // When the current billing period started. May match initial_period_start if this - // is the first period. - CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` - // How often the subscription is renewed automatically. - Frequency SubscriptionListResponseFrequency `json:"frequency"` - // The price of the subscription that will be billed, in US dollars. - Price float64 `json:"price"` - // The rate plan applied to the subscription. - RatePlan SubscriptionListResponseRatePlan `json:"rate_plan"` - // The state that the subscription is in. - State SubscriptionListResponseState `json:"state"` - // A simple zone object. May have null properties if not a zone subscription. - Zone SubscriptionListResponseZone `json:"zone"` - JSON subscriptionListResponseJSON `json:"-"` -} - -// subscriptionListResponseJSON contains the JSON metadata for the struct -// [SubscriptionListResponse] -type subscriptionListResponseJSON struct { - ID apijson.Field - App apijson.Field - ComponentValues apijson.Field - Currency apijson.Field - CurrentPeriodEnd apijson.Field - CurrentPeriodStart apijson.Field - Frequency apijson.Field - Price apijson.Field - RatePlan apijson.Field - State apijson.Field - Zone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseJSON) RawJSON() string { - return r.raw -} - -type SubscriptionListResponseApp struct { - // app install id. - InstallID string `json:"install_id"` - JSON subscriptionListResponseAppJSON `json:"-"` -} - -// subscriptionListResponseAppJSON contains the JSON metadata for the struct -// [SubscriptionListResponseApp] -type subscriptionListResponseAppJSON struct { - InstallID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseAppJSON) RawJSON() string { - return r.raw -} - -// A component value for a subscription. -type SubscriptionListResponseComponentValue struct { - // The default amount assigned. - Default float64 `json:"default"` - // The name of the component value. - Name string `json:"name"` - // The unit price for the component value. - Price float64 `json:"price"` - // The amount of the component value assigned. - Value float64 `json:"value"` - JSON subscriptionListResponseComponentValueJSON `json:"-"` -} - -// subscriptionListResponseComponentValueJSON contains the JSON metadata for the -// struct [SubscriptionListResponseComponentValue] -type subscriptionListResponseComponentValueJSON struct { - Default apijson.Field - Name apijson.Field - Price apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseComponentValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseComponentValueJSON) RawJSON() string { - return r.raw -} - -// How often the subscription is renewed automatically. -type SubscriptionListResponseFrequency string - -const ( - SubscriptionListResponseFrequencyWeekly SubscriptionListResponseFrequency = "weekly" - SubscriptionListResponseFrequencyMonthly SubscriptionListResponseFrequency = "monthly" - SubscriptionListResponseFrequencyQuarterly SubscriptionListResponseFrequency = "quarterly" - SubscriptionListResponseFrequencyYearly SubscriptionListResponseFrequency = "yearly" -) - -func (r SubscriptionListResponseFrequency) IsKnown() bool { - switch r { - case SubscriptionListResponseFrequencyWeekly, SubscriptionListResponseFrequencyMonthly, SubscriptionListResponseFrequencyQuarterly, SubscriptionListResponseFrequencyYearly: - return true - } - return false -} - -// The rate plan applied to the subscription. -type SubscriptionListResponseRatePlan struct { - // The ID of the rate plan. - ID string `json:"id"` - // The currency applied to the rate plan subscription. - Currency string `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged bool `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract bool `json:"is_contract"` - // The full name of the rate plan. - PublicName string `json:"public_name"` - // The scope that this rate plan applies to. - Scope string `json:"scope"` - // The list of sets this rate plan applies to. - Sets []string `json:"sets"` - JSON subscriptionListResponseRatePlanJSON `json:"-"` -} - -// subscriptionListResponseRatePlanJSON contains the JSON metadata for the struct -// [SubscriptionListResponseRatePlan] -type subscriptionListResponseRatePlanJSON struct { - ID apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - IsContract apijson.Field - PublicName apijson.Field - Scope apijson.Field - Sets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseRatePlan) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseRatePlanJSON) RawJSON() string { - return r.raw -} - -// The state that the subscription is in. -type SubscriptionListResponseState string - -const ( - SubscriptionListResponseStateTrial SubscriptionListResponseState = "Trial" - SubscriptionListResponseStateProvisioned SubscriptionListResponseState = "Provisioned" - SubscriptionListResponseStatePaid SubscriptionListResponseState = "Paid" - SubscriptionListResponseStateAwaitingPayment SubscriptionListResponseState = "AwaitingPayment" - SubscriptionListResponseStateCancelled SubscriptionListResponseState = "Cancelled" - SubscriptionListResponseStateFailed SubscriptionListResponseState = "Failed" - SubscriptionListResponseStateExpired SubscriptionListResponseState = "Expired" -) - -func (r SubscriptionListResponseState) IsKnown() bool { - switch r { - case SubscriptionListResponseStateTrial, SubscriptionListResponseStateProvisioned, SubscriptionListResponseStatePaid, SubscriptionListResponseStateAwaitingPayment, SubscriptionListResponseStateCancelled, SubscriptionListResponseStateFailed, SubscriptionListResponseStateExpired: - return true - } - return false -} - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionListResponseZone struct { - // Identifier - ID string `json:"id"` - // The domain name - Name string `json:"name"` - JSON subscriptionListResponseZoneJSON `json:"-"` -} - -// subscriptionListResponseZoneJSON contains the JSON metadata for the struct -// [SubscriptionListResponseZone] -type subscriptionListResponseZoneJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseZone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseZoneJSON) RawJSON() string { - return r.raw -} - type SubscriptionDeleteResponse struct { // Subscription identifier tag. SubscriptionID string `json:"subscription_id"` @@ -381,13 +168,13 @@ func (r subscriptionDeleteResponseJSON) RawJSON() string { // Union satisfied by [subscriptions.SubscriptionGetResponseUnknown] or // [shared.UnionString]. -type SubscriptionGetResponse interface { - ImplementsSubscriptionsSubscriptionGetResponse() +type SubscriptionGetResponseUnion interface { + ImplementsSubscriptionsSubscriptionGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionGetResponse)(nil)).Elem(), + reflect.TypeOf((*SubscriptionGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -397,98 +184,17 @@ func init() { } type SubscriptionNewParams struct { - App param.Field[SubscriptionNewParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]SubscriptionNewParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[SubscriptionNewParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[SubscriptionNewParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[SubscriptionNewParamsZone] `json:"zone"` + Subscription user.SubscriptionParam `json:"subscription,required"` } func (r SubscriptionNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SubscriptionNewParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r SubscriptionNewParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type SubscriptionNewParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r SubscriptionNewParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type SubscriptionNewParamsFrequency string - -const ( - SubscriptionNewParamsFrequencyWeekly SubscriptionNewParamsFrequency = "weekly" - SubscriptionNewParamsFrequencyMonthly SubscriptionNewParamsFrequency = "monthly" - SubscriptionNewParamsFrequencyQuarterly SubscriptionNewParamsFrequency = "quarterly" - SubscriptionNewParamsFrequencyYearly SubscriptionNewParamsFrequency = "yearly" -) - -func (r SubscriptionNewParamsFrequency) IsKnown() bool { - switch r { - case SubscriptionNewParamsFrequencyWeekly, SubscriptionNewParamsFrequencyMonthly, SubscriptionNewParamsFrequencyQuarterly, SubscriptionNewParamsFrequencyYearly: - return true - } - return false -} - -// The rate plan applied to the subscription. -type SubscriptionNewParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[string] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r SubscriptionNewParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionNewParamsZone struct { -} - -func (r SubscriptionNewParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Subscription) } type SubscriptionNewResponseEnvelope struct { - Errors []SubscriptionNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionNewResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionNewResponseUnion `json:"result,required"` // Whether the API call was successful Success SubscriptionNewResponseEnvelopeSuccess `json:"success,required"` JSON subscriptionNewResponseEnvelopeJSON `json:"-"` @@ -513,52 +219,6 @@ func (r subscriptionNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionNewResponseEnvelopeErrors] -type subscriptionNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionNewResponseEnvelopeMessages] -type subscriptionNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionNewResponseEnvelopeSuccess bool @@ -575,98 +235,17 @@ func (r SubscriptionNewResponseEnvelopeSuccess) IsKnown() bool { } type SubscriptionUpdateParams struct { - App param.Field[SubscriptionUpdateParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]SubscriptionUpdateParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[SubscriptionUpdateParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[SubscriptionUpdateParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[SubscriptionUpdateParamsZone] `json:"zone"` + Subscription user.SubscriptionParam `json:"subscription,required"` } func (r SubscriptionUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SubscriptionUpdateParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r SubscriptionUpdateParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type SubscriptionUpdateParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r SubscriptionUpdateParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type SubscriptionUpdateParamsFrequency string - -const ( - SubscriptionUpdateParamsFrequencyWeekly SubscriptionUpdateParamsFrequency = "weekly" - SubscriptionUpdateParamsFrequencyMonthly SubscriptionUpdateParamsFrequency = "monthly" - SubscriptionUpdateParamsFrequencyQuarterly SubscriptionUpdateParamsFrequency = "quarterly" - SubscriptionUpdateParamsFrequencyYearly SubscriptionUpdateParamsFrequency = "yearly" -) - -func (r SubscriptionUpdateParamsFrequency) IsKnown() bool { - switch r { - case SubscriptionUpdateParamsFrequencyWeekly, SubscriptionUpdateParamsFrequencyMonthly, SubscriptionUpdateParamsFrequencyQuarterly, SubscriptionUpdateParamsFrequencyYearly: - return true - } - return false -} - -// The rate plan applied to the subscription. -type SubscriptionUpdateParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[string] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r SubscriptionUpdateParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionUpdateParamsZone struct { -} - -func (r SubscriptionUpdateParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Subscription) } type SubscriptionUpdateResponseEnvelope struct { - Errors []SubscriptionUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success SubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"` JSON subscriptionUpdateResponseEnvelopeJSON `json:"-"` @@ -691,52 +270,6 @@ func (r subscriptionUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionUpdateResponseEnvelopeErrors] -type subscriptionUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SubscriptionUpdateResponseEnvelopeMessages] -type subscriptionUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionUpdateResponseEnvelopeSuccess bool @@ -752,10 +285,18 @@ func (r SubscriptionUpdateResponseEnvelopeSuccess) IsKnown() bool { return false } +type SubscriptionDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r SubscriptionDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type SubscriptionDeleteResponseEnvelope struct { - Errors []SubscriptionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionDeleteResponse `json:"result,required"` // Whether the API call was successful Success SubscriptionDeleteResponseEnvelopeSuccess `json:"success,required"` JSON subscriptionDeleteResponseEnvelopeJSON `json:"-"` @@ -780,52 +321,6 @@ func (r subscriptionDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionDeleteResponseEnvelopeErrors] -type subscriptionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SubscriptionDeleteResponseEnvelopeMessages] -type subscriptionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionDeleteResponseEnvelopeSuccess bool @@ -842,9 +337,9 @@ func (r SubscriptionDeleteResponseEnvelopeSuccess) IsKnown() bool { } type SubscriptionGetResponseEnvelope struct { - Errors []SubscriptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionGetResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionGetResponseUnion `json:"result,required"` // Whether the API call was successful Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"` JSON subscriptionGetResponseEnvelopeJSON `json:"-"` @@ -869,52 +364,6 @@ func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeErrors] -type subscriptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeMessages] -type subscriptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionGetResponseEnvelopeSuccess bool diff --git a/subscriptions/subscription_test.go b/subscriptions/subscription_test.go index f47f40d87e7..13885f10cb1 100644 --- a/subscriptions/subscription_test.go +++ b/subscriptions/subscription_test.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/testutil" "github.com/cloudflare/cloudflare-go/v2/option" "github.com/cloudflare/cloudflare-go/v2/subscriptions" + "github.com/cloudflare/cloudflare-go/v2/user" ) func TestSubscriptionNewWithOptionalParams(t *testing.T) { @@ -32,36 +33,38 @@ func TestSubscriptionNewWithOptionalParams(t *testing.T) { context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2", subscriptions.SubscriptionNewParams{ - App: cloudflare.F(subscriptions.SubscriptionNewParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]subscriptions.SubscriptionNewParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(subscriptions.SubscriptionNewParamsFrequencyMonthly), - RatePlan: cloudflare.F(subscriptions.SubscriptionNewParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(subscriptions.SubscriptionNewParamsZone{}), + Subscription: user.SubscriptionParam{ + App: cloudflare.F(user.SubscriptionAppParam{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]user.SubscriptionComponentParam{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(user.SubscriptionFrequencyMonthly), + RatePlan: cloudflare.F(user.RatePlanParam{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(user.SubscriptionZoneParam{}), + }, }, ) if err != nil { @@ -92,36 +95,38 @@ func TestSubscriptionUpdateWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "506e3185e9c882d175a2d0cb0093d9f2", subscriptions.SubscriptionUpdateParams{ - App: cloudflare.F(subscriptions.SubscriptionUpdateParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]subscriptions.SubscriptionUpdateParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(subscriptions.SubscriptionUpdateParamsFrequencyMonthly), - RatePlan: cloudflare.F(subscriptions.SubscriptionUpdateParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(subscriptions.SubscriptionUpdateParamsZone{}), + Subscription: user.SubscriptionParam{ + App: cloudflare.F(user.SubscriptionAppParam{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]user.SubscriptionComponentParam{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(user.SubscriptionFrequencyMonthly), + RatePlan: cloudflare.F(user.RatePlanParam{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(user.SubscriptionZoneParam{}), + }, }, ) if err != nil { @@ -175,6 +180,9 @@ func TestSubscriptionDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "506e3185e9c882d175a2d0cb0093d9f2", + subscriptions.SubscriptionDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/url_normalization/aliases.go b/url_normalization/aliases.go index b5eff527e25..57b1da720e7 100644 --- a/url_normalization/aliases.go +++ b/url_normalization/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/url_scanner/aliases.go b/url_scanner/aliases.go index 0dfd30d3670..f1f25744793 100644 --- a/url_scanner/aliases.go +++ b/url_scanner/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/url_scanner/scan.go b/url_scanner/scan.go index 24ea8613c1b..2faa9346547 100644 --- a/url_scanner/scan.go +++ b/url_scanner/scan.go @@ -14,6 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/cloudflare/cloudflare-go/v2/radar" ) // ScanService contains methods and other services that help with interacting with @@ -84,6 +85,31 @@ func (r *ScanService) Screenshot(ctx context.Context, accountID string, scanID s return } +type URLScannerDomain struct { + ID int64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID int64 `json:"super_category_id"` + JSON urlScannerDomainJSON `json:"-"` +} + +// urlScannerDomainJSON contains the JSON metadata for the struct +// [URLScannerDomain] +type urlScannerDomainJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *URLScannerDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r urlScannerDomainJSON) RawJSON() string { + return r.raw +} + type ScanNewResponse struct { // Time when url was submitted for scanning. Time time.Time `json:"time,required" format:"date-time"` @@ -277,9 +303,9 @@ func (r scanGetResponseScanMetaProcessorsJSON) RawJSON() string { } type ScanGetResponseScanMetaProcessorsCategories struct { - Content []ScanGetResponseScanMetaProcessorsCategoriesContent `json:"content,required"` - Risks []ScanGetResponseScanMetaProcessorsCategoriesRisk `json:"risks,required"` - JSON scanGetResponseScanMetaProcessorsCategoriesJSON `json:"-"` + Content []URLScannerDomain `json:"content,required"` + Risks []ScanGetResponseScanMetaProcessorsCategoriesRisk `json:"risks,required"` + JSON scanGetResponseScanMetaProcessorsCategoriesJSON `json:"-"` } // scanGetResponseScanMetaProcessorsCategoriesJSON contains the JSON metadata for @@ -299,31 +325,6 @@ func (r scanGetResponseScanMetaProcessorsCategoriesJSON) RawJSON() string { return r.raw } -type ScanGetResponseScanMetaProcessorsCategoriesContent struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON scanGetResponseScanMetaProcessorsCategoriesContentJSON `json:"-"` -} - -// scanGetResponseScanMetaProcessorsCategoriesContentJSON contains the JSON -// metadata for the struct [ScanGetResponseScanMetaProcessorsCategoriesContent] -type scanGetResponseScanMetaProcessorsCategoriesContentJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanGetResponseScanMetaProcessorsCategoriesContent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanGetResponseScanMetaProcessorsCategoriesContentJSON) RawJSON() string { - return r.raw -} - type ScanGetResponseScanMetaProcessorsCategoriesRisk struct { ID int64 `json:"id,required"` Name string `json:"name,required"` @@ -510,9 +511,9 @@ type ScanGetResponseScanPage struct { Country string `json:"country,required"` CountryLocationAlpha2 string `json:"countryLocationAlpha2,required"` Domain string `json:"domain,required"` - Headers []ScanGetResponseScanPageHeader `json:"headers,required"` + Headers []radar.Browser `json:"headers,required"` IP string `json:"ip,required"` - Js ScanGetResponseScanPageJs `json:"js,required"` + JS ScanGetResponseScanPageJS `json:"js,required"` SecurityViolations []ScanGetResponseScanPageSecurityViolation `json:"securityViolations,required"` Status float64 `json:"status,required"` Subdivision1Name string `json:"subdivision1Name,required"` @@ -534,7 +535,7 @@ type scanGetResponseScanPageJSON struct { Domain apijson.Field Headers apijson.Field IP apijson.Field - Js apijson.Field + JS apijson.Field SecurityViolations apijson.Field Status apijson.Field Subdivision1Name apijson.Field @@ -624,70 +625,47 @@ func (r scanGetResponseScanPageCookyJSON) RawJSON() string { return r.raw } -type ScanGetResponseScanPageHeader struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON scanGetResponseScanPageHeaderJSON `json:"-"` -} - -// scanGetResponseScanPageHeaderJSON contains the JSON metadata for the struct -// [ScanGetResponseScanPageHeader] -type scanGetResponseScanPageHeaderJSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanGetResponseScanPageHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanGetResponseScanPageHeaderJSON) RawJSON() string { - return r.raw -} - -type ScanGetResponseScanPageJs struct { - Variables []ScanGetResponseScanPageJsVariable `json:"variables,required"` - JSON scanGetResponseScanPageJsJSON `json:"-"` +type ScanGetResponseScanPageJS struct { + Variables []ScanGetResponseScanPageJSVariable `json:"variables,required"` + JSON scanGetResponseScanPageJSJSON `json:"-"` } -// scanGetResponseScanPageJsJSON contains the JSON metadata for the struct -// [ScanGetResponseScanPageJs] -type scanGetResponseScanPageJsJSON struct { +// scanGetResponseScanPageJSJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPageJS] +type scanGetResponseScanPageJSJSON struct { Variables apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ScanGetResponseScanPageJs) UnmarshalJSON(data []byte) (err error) { +func (r *ScanGetResponseScanPageJS) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r scanGetResponseScanPageJsJSON) RawJSON() string { +func (r scanGetResponseScanPageJSJSON) RawJSON() string { return r.raw } -type ScanGetResponseScanPageJsVariable struct { +type ScanGetResponseScanPageJSVariable struct { Name string `json:"name,required"` Type string `json:"type,required"` - JSON scanGetResponseScanPageJsVariableJSON `json:"-"` + JSON scanGetResponseScanPageJSVariableJSON `json:"-"` } -// scanGetResponseScanPageJsVariableJSON contains the JSON metadata for the struct -// [ScanGetResponseScanPageJsVariable] -type scanGetResponseScanPageJsVariableJSON struct { +// scanGetResponseScanPageJSVariableJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPageJSVariable] +type scanGetResponseScanPageJSVariableJSON struct { Name apijson.Field Type apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ScanGetResponseScanPageJsVariable) UnmarshalJSON(data []byte) (err error) { +func (r *ScanGetResponseScanPageJSVariable) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r scanGetResponseScanPageJsVariableJSON) RawJSON() string { +func (r scanGetResponseScanPageJSVariableJSON) RawJSON() string { return r.raw } @@ -1113,8 +1091,8 @@ func (r scanGetResponseScanDomainsExampleComJSON) RawJSON() string { type ScanGetResponseScanDomainsExampleComCategories struct { Inherited ScanGetResponseScanDomainsExampleComCategoriesInherited `json:"inherited,required"` - Content []ScanGetResponseScanDomainsExampleComCategoriesContent `json:"content"` - Risks []ScanGetResponseScanDomainsExampleComCategoriesRisk `json:"risks"` + Content []URLScannerDomain `json:"content"` + Risks []URLScannerDomain `json:"risks"` JSON scanGetResponseScanDomainsExampleComCategoriesJSON `json:"-"` } @@ -1137,10 +1115,10 @@ func (r scanGetResponseScanDomainsExampleComCategoriesJSON) RawJSON() string { } type ScanGetResponseScanDomainsExampleComCategoriesInherited struct { - Content []ScanGetResponseScanDomainsExampleComCategoriesInheritedContent `json:"content"` - From string `json:"from"` - Risks []ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk `json:"risks"` - JSON scanGetResponseScanDomainsExampleComCategoriesInheritedJSON `json:"-"` + Content []URLScannerDomain `json:"content"` + From string `json:"from"` + Risks []URLScannerDomain `json:"risks"` + JSON scanGetResponseScanDomainsExampleComCategoriesInheritedJSON `json:"-"` } // scanGetResponseScanDomainsExampleComCategoriesInheritedJSON contains the JSON @@ -1162,108 +1140,6 @@ func (r scanGetResponseScanDomainsExampleComCategoriesInheritedJSON) RawJSON() s return r.raw } -type ScanGetResponseScanDomainsExampleComCategoriesInheritedContent struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON `json:"-"` -} - -// scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON contains the -// JSON metadata for the struct -// [ScanGetResponseScanDomainsExampleComCategoriesInheritedContent] -type scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanGetResponseScanDomainsExampleComCategoriesInheritedContent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON) RawJSON() string { - return r.raw -} - -type ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON `json:"-"` -} - -// scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON contains the -// JSON metadata for the struct -// [ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk] -type scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON) RawJSON() string { - return r.raw -} - -type ScanGetResponseScanDomainsExampleComCategoriesContent struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON scanGetResponseScanDomainsExampleComCategoriesContentJSON `json:"-"` -} - -// scanGetResponseScanDomainsExampleComCategoriesContentJSON contains the JSON -// metadata for the struct [ScanGetResponseScanDomainsExampleComCategoriesContent] -type scanGetResponseScanDomainsExampleComCategoriesContentJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanGetResponseScanDomainsExampleComCategoriesContent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanGetResponseScanDomainsExampleComCategoriesContentJSON) RawJSON() string { - return r.raw -} - -type ScanGetResponseScanDomainsExampleComCategoriesRisk struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON scanGetResponseScanDomainsExampleComCategoriesRiskJSON `json:"-"` -} - -// scanGetResponseScanDomainsExampleComCategoriesRiskJSON contains the JSON -// metadata for the struct [ScanGetResponseScanDomainsExampleComCategoriesRisk] -type scanGetResponseScanDomainsExampleComCategoriesRiskJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanGetResponseScanDomainsExampleComCategoriesRisk) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanGetResponseScanDomainsExampleComCategoriesRiskJSON) RawJSON() string { - return r.raw -} - type ScanGetResponseScanDomainsExampleComDNS struct { Address string `json:"address,required"` DNSSECValid bool `json:"dnssec_valid,required"` @@ -1574,13 +1450,13 @@ func (r scanHarResponseHarLogEntryJSON) RawJSON() string { } type ScanHarResponseHarLogEntriesRequest struct { - BodySize float64 `json:"bodySize,required"` - Headers []ScanHarResponseHarLogEntriesRequestHeader `json:"headers,required"` - HeadersSize float64 `json:"headersSize,required"` - HTTPVersion string `json:"httpVersion,required"` - Method string `json:"method,required"` - URL string `json:"url,required"` - JSON scanHarResponseHarLogEntriesRequestJSON `json:"-"` + BodySize float64 `json:"bodySize,required"` + Headers []radar.Browser `json:"headers,required"` + HeadersSize float64 `json:"headersSize,required"` + HTTPVersion string `json:"httpVersion,required"` + Method string `json:"method,required"` + URL string `json:"url,required"` + JSON scanHarResponseHarLogEntriesRequestJSON `json:"-"` } // scanHarResponseHarLogEntriesRequestJSON contains the JSON metadata for the @@ -1604,40 +1480,17 @@ func (r scanHarResponseHarLogEntriesRequestJSON) RawJSON() string { return r.raw } -type ScanHarResponseHarLogEntriesRequestHeader struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON scanHarResponseHarLogEntriesRequestHeaderJSON `json:"-"` -} - -// scanHarResponseHarLogEntriesRequestHeaderJSON contains the JSON metadata for the -// struct [ScanHarResponseHarLogEntriesRequestHeader] -type scanHarResponseHarLogEntriesRequestHeaderJSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanHarResponseHarLogEntriesRequestHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanHarResponseHarLogEntriesRequestHeaderJSON) RawJSON() string { - return r.raw -} - type ScanHarResponseHarLogEntriesResponse struct { - TransferSize float64 `json:"_transferSize,required"` - BodySize float64 `json:"bodySize,required"` - Content ScanHarResponseHarLogEntriesResponseContent `json:"content,required"` - Headers []ScanHarResponseHarLogEntriesResponseHeader `json:"headers,required"` - HeadersSize float64 `json:"headersSize,required"` - HTTPVersion string `json:"httpVersion,required"` - RedirectURL string `json:"redirectURL,required"` - Status float64 `json:"status,required"` - StatusText string `json:"statusText,required"` - JSON scanHarResponseHarLogEntriesResponseJSON `json:"-"` + TransferSize float64 `json:"_transferSize,required"` + BodySize float64 `json:"bodySize,required"` + Content ScanHarResponseHarLogEntriesResponseContent `json:"content,required"` + Headers []radar.Browser `json:"headers,required"` + HeadersSize float64 `json:"headersSize,required"` + HTTPVersion string `json:"httpVersion,required"` + RedirectURL string `json:"redirectURL,required"` + Status float64 `json:"status,required"` + StatusText string `json:"statusText,required"` + JSON scanHarResponseHarLogEntriesResponseJSON `json:"-"` } // scanHarResponseHarLogEntriesResponseJSON contains the JSON metadata for the @@ -1689,29 +1542,6 @@ func (r scanHarResponseHarLogEntriesResponseContentJSON) RawJSON() string { return r.raw } -type ScanHarResponseHarLogEntriesResponseHeader struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON scanHarResponseHarLogEntriesResponseHeaderJSON `json:"-"` -} - -// scanHarResponseHarLogEntriesResponseHeaderJSON contains the JSON metadata for -// the struct [ScanHarResponseHarLogEntriesResponseHeader] -type scanHarResponseHarLogEntriesResponseHeaderJSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScanHarResponseHarLogEntriesResponseHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scanHarResponseHarLogEntriesResponseHeaderJSON) RawJSON() string { - return r.raw -} - type ScanHarResponseHarLogPage struct { ID string `json:"id,required"` PageTimings ScanHarResponseHarLogPagesPageTimings `json:"pageTimings,required"` @@ -2034,7 +1864,7 @@ type ScanScreenshotParams struct { // URLQuery serializes [ScanScreenshotParams]'s query parameters as `url.Values`. func (r ScanScreenshotParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/url_scanner/urlscanner.go b/url_scanner/urlscanner.go index 86bab5fe4e8..793430f5067 100644 --- a/url_scanner/urlscanner.go +++ b/url_scanner/urlscanner.go @@ -154,7 +154,7 @@ type URLScannerScanParams struct { // URLQuery serializes [URLScannerScanParams]'s query parameters as `url.Values`. func (r URLScannerScanParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/user/aliases.go b/user/aliases.go index 00a92c5bf79..da170ec353f 100644 --- a/user/aliases.go +++ b/user/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/user/auditlog.go b/user/auditlog.go index b6a61301fcb..79c3271681d 100644 --- a/user/auditlog.go +++ b/user/auditlog.go @@ -8,11 +8,11 @@ import ( "net/url" "time" - "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" ) @@ -35,7 +35,7 @@ func NewAuditLogService(opts ...option.RequestOption) (r *AuditLogService) { // Gets a list of audit logs for a user account. Can be filtered by who made the // change, on which zone, and the timeframe of the change. -func (r *AuditLogService) List(ctx context.Context, query AuditLogListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[AuditLogListResponse], err error) { +func (r *AuditLogService) List(ctx context.Context, query AuditLogListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[shared.AuditLog], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -54,177 +54,10 @@ func (r *AuditLogService) List(ctx context.Context, query AuditLogListParams, op // Gets a list of audit logs for a user account. Can be filtered by who made the // change, on which zone, and the timeframe of the change. -func (r *AuditLogService) ListAutoPaging(ctx context.Context, query AuditLogListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[AuditLogListResponse] { +func (r *AuditLogService) ListAutoPaging(ctx context.Context, query AuditLogListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[shared.AuditLog] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) } -type AuditLogListResponse struct { - // A string that uniquely identifies the audit log. - ID string `json:"id"` - Action AuditLogListResponseAction `json:"action"` - Actor AuditLogListResponseActor `json:"actor"` - // The source of the event. - Interface string `json:"interface"` - // An object which can lend more context to the action being logged. This is a - // flexible value and varies between different actions. - Metadata interface{} `json:"metadata"` - // The new value of the resource that was modified. - NewValue string `json:"newValue"` - // The value of the resource before it was modified. - OldValue string `json:"oldValue"` - Owner AuditLogListResponseOwner `json:"owner"` - Resource AuditLogListResponseResource `json:"resource"` - // A UTC RFC3339 timestamp that specifies when the action being logged occured. - When time.Time `json:"when" format:"date-time"` - JSON auditLogListResponseJSON `json:"-"` -} - -// auditLogListResponseJSON contains the JSON metadata for the struct -// [AuditLogListResponse] -type auditLogListResponseJSON struct { - ID apijson.Field - Action apijson.Field - Actor apijson.Field - Interface apijson.Field - Metadata apijson.Field - NewValue apijson.Field - OldValue apijson.Field - Owner apijson.Field - Resource apijson.Field - When apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseAction struct { - // A boolean that indicates if the action attempted was successful. - Result bool `json:"result"` - // A short string that describes the action that was performed. - Type string `json:"type"` - JSON auditLogListResponseActionJSON `json:"-"` -} - -// auditLogListResponseActionJSON contains the JSON metadata for the struct -// [AuditLogListResponseAction] -type auditLogListResponseActionJSON struct { - Result apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseActionJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseActor struct { - // The ID of the actor that performed the action. If a user performed the action, - // this will be their User ID. - ID string `json:"id"` - // The email of the user that performed the action. - Email string `json:"email" format:"email"` - // The IP address of the request that performed the action. - IP string `json:"ip"` - // The type of actor, whether a User, Cloudflare Admin, or an Automated System. - Type AuditLogListResponseActorType `json:"type"` - JSON auditLogListResponseActorJSON `json:"-"` -} - -// auditLogListResponseActorJSON contains the JSON metadata for the struct -// [AuditLogListResponseActor] -type auditLogListResponseActorJSON struct { - ID apijson.Field - Email apijson.Field - IP apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseActor) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseActorJSON) RawJSON() string { - return r.raw -} - -// The type of actor, whether a User, Cloudflare Admin, or an Automated System. -type AuditLogListResponseActorType string - -const ( - AuditLogListResponseActorTypeUser AuditLogListResponseActorType = "user" - AuditLogListResponseActorTypeAdmin AuditLogListResponseActorType = "admin" - AuditLogListResponseActorTypeCloudflare AuditLogListResponseActorType = "Cloudflare" -) - -func (r AuditLogListResponseActorType) IsKnown() bool { - switch r { - case AuditLogListResponseActorTypeUser, AuditLogListResponseActorTypeAdmin, AuditLogListResponseActorTypeCloudflare: - return true - } - return false -} - -type AuditLogListResponseOwner struct { - // Identifier - ID string `json:"id"` - JSON auditLogListResponseOwnerJSON `json:"-"` -} - -// auditLogListResponseOwnerJSON contains the JSON metadata for the struct -// [AuditLogListResponseOwner] -type auditLogListResponseOwnerJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseOwner) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseOwnerJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseResource struct { - // An identifier for the resource that was affected by the action. - ID string `json:"id"` - // A short string that describes the resource that was affected by the action. - Type string `json:"type"` - JSON auditLogListResponseResourceJSON `json:"-"` -} - -// auditLogListResponseResourceJSON contains the JSON metadata for the struct -// [AuditLogListResponseResource] -type auditLogListResponseResourceJSON struct { - ID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseResource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseResourceJSON) RawJSON() string { - return r.raw -} - type AuditLogListParams struct { // Finds a specific log by its ID. ID param.Field[string] `query:"id"` @@ -252,7 +85,7 @@ type AuditLogListParams struct { // URLQuery serializes [AuditLogListParams]'s query parameters as `url.Values`. func (r AuditLogListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -266,7 +99,7 @@ type AuditLogListParamsAction struct { // `url.Values`. func (r AuditLogListParamsAction) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -283,7 +116,7 @@ type AuditLogListParamsActor struct { // `url.Values`. func (r AuditLogListParamsActor) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -312,7 +145,7 @@ type AuditLogListParamsZone struct { // URLQuery serializes [AuditLogListParamsZone]'s query parameters as `url.Values`. func (r AuditLogListParamsZone) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/user/billinghistory.go b/user/billinghistory.go index b485501c6e3..2c2f20c9a1e 100644 --- a/user/billinghistory.go +++ b/user/billinghistory.go @@ -10,6 +10,7 @@ import ( "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/option" @@ -34,16 +35,26 @@ func NewBillingHistoryService(opts ...option.RequestOption) (r *BillingHistorySe } // Accesses your billing history object. -func (r *BillingHistoryService) Get(ctx context.Context, query BillingHistoryGetParams, opts ...option.RequestOption) (res *[]BillingHistory, err error) { - opts = append(r.Options[:], opts...) - var env BillingHistoryGetResponseEnvelope +func (r *BillingHistoryService) List(ctx context.Context, query BillingHistoryListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[BillingHistory], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) path := "user/billing/history" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { - return + return nil, err } - res = &env.Result - return + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Accesses your billing history object. +func (r *BillingHistoryService) ListAutoPaging(ctx context.Context, query BillingHistoryListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[BillingHistory] { + return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) } type BillingHistory struct { @@ -108,159 +119,45 @@ func (r billingHistoryZoneJSON) RawJSON() string { return r.raw } -type BillingHistoryGetParams struct { +type BillingHistoryListParams struct { + // The billing item action. + Action param.Field[string] `query:"action"` + // When the billing item was created. + OccuredAt param.Field[time.Time] `query:"occured_at" format:"date-time"` + // When the billing item was created. + OccurredAt param.Field[time.Time] `query:"occurred_at" format:"date-time"` // Field to order billing history by. - Order param.Field[BillingHistoryGetParamsOrder] `query:"order"` + Order param.Field[BillingHistoryListParamsOrder] `query:"order"` // Page number of paginated results. Page param.Field[float64] `query:"page"` // Number of items per page. PerPage param.Field[float64] `query:"per_page"` + // The billing item type. + Type param.Field[string] `query:"type"` } -// URLQuery serializes [BillingHistoryGetParams]'s query parameters as +// URLQuery serializes [BillingHistoryListParams]'s query parameters as // `url.Values`. -func (r BillingHistoryGetParams) URLQuery() (v url.Values) { +func (r BillingHistoryListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } // Field to order billing history by. -type BillingHistoryGetParamsOrder string - -const ( - BillingHistoryGetParamsOrderType BillingHistoryGetParamsOrder = "type" - BillingHistoryGetParamsOrderOccuredAt BillingHistoryGetParamsOrder = "occured_at" - BillingHistoryGetParamsOrderAction BillingHistoryGetParamsOrder = "action" -) - -func (r BillingHistoryGetParamsOrder) IsKnown() bool { - switch r { - case BillingHistoryGetParamsOrderType, BillingHistoryGetParamsOrderOccuredAt, BillingHistoryGetParamsOrderAction: - return true - } - return false -} - -type BillingHistoryGetResponseEnvelope struct { - Errors []BillingHistoryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []BillingHistoryGetResponseEnvelopeMessages `json:"messages,required"` - Result []BillingHistory `json:"result,required,nullable"` - // Whether the API call was successful - Success BillingHistoryGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo BillingHistoryGetResponseEnvelopeResultInfo `json:"result_info"` - JSON billingHistoryGetResponseEnvelopeJSON `json:"-"` -} - -// billingHistoryGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [BillingHistoryGetResponseEnvelope] -type billingHistoryGetResponseEnvelopeJSON 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 *BillingHistoryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r billingHistoryGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type BillingHistoryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON billingHistoryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// billingHistoryGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [BillingHistoryGetResponseEnvelopeErrors] -type billingHistoryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BillingHistoryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r billingHistoryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BillingHistoryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON billingHistoryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// billingHistoryGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [BillingHistoryGetResponseEnvelopeMessages] -type billingHistoryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BillingHistoryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r billingHistoryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type BillingHistoryGetResponseEnvelopeSuccess bool +type BillingHistoryListParamsOrder string const ( - BillingHistoryGetResponseEnvelopeSuccessTrue BillingHistoryGetResponseEnvelopeSuccess = true + BillingHistoryListParamsOrderType BillingHistoryListParamsOrder = "type" + BillingHistoryListParamsOrderOccuredAt BillingHistoryListParamsOrder = "occured_at" + BillingHistoryListParamsOrderAction BillingHistoryListParamsOrder = "action" ) -func (r BillingHistoryGetResponseEnvelopeSuccess) IsKnown() bool { +func (r BillingHistoryListParamsOrder) IsKnown() bool { switch r { - case BillingHistoryGetResponseEnvelopeSuccessTrue: + case BillingHistoryListParamsOrderType, BillingHistoryListParamsOrderOccuredAt, BillingHistoryListParamsOrderAction: return true } return false } - -type BillingHistoryGetResponseEnvelopeResultInfo 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 billingHistoryGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// billingHistoryGetResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [BillingHistoryGetResponseEnvelopeResultInfo] -type billingHistoryGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BillingHistoryGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r billingHistoryGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/user/billinghistory_test.go b/user/billinghistory_test.go index a33466d3f27..bdd4b1dd3fd 100644 --- a/user/billinghistory_test.go +++ b/user/billinghistory_test.go @@ -7,6 +7,7 @@ import ( "errors" "os" "testing" + "time" "github.com/cloudflare/cloudflare-go/v2" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" @@ -14,7 +15,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/user" ) -func TestBillingHistoryGetWithOptionalParams(t *testing.T) { +func TestBillingHistoryListWithOptionalParams(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 { @@ -28,10 +29,14 @@ func TestBillingHistoryGetWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.User.Billing.History.Get(context.TODO(), user.BillingHistoryGetParams{ - Order: cloudflare.F(user.BillingHistoryGetParamsOrderOccuredAt), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), + _, err := client.User.Billing.History.List(context.TODO(), user.BillingHistoryListParams{ + Action: cloudflare.F("subscription"), + OccuredAt: cloudflare.F(time.Now()), + OccurredAt: cloudflare.F(time.Now()), + Order: cloudflare.F(user.BillingHistoryListParamsOrderOccuredAt), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + Type: cloudflare.F("charge"), }) if err != nil { var apierr *cloudflare.Error diff --git a/user/billingprofile.go b/user/billingprofile.go index 2f695310401..c5df0865879 100644 --- a/user/billingprofile.go +++ b/user/billingprofile.go @@ -33,7 +33,7 @@ func NewBillingProfileService(opts ...option.RequestOption) (r *BillingProfileSe } // Accesses your billing profile object. -func (r *BillingProfileService) Get(ctx context.Context, opts ...option.RequestOption) (res *BillingProfileGetResponse, err error) { +func (r *BillingProfileService) Get(ctx context.Context, opts ...option.RequestOption) (res *BillingProfileGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env BillingProfileGetResponseEnvelope path := "user/billing/profile" @@ -47,13 +47,13 @@ func (r *BillingProfileService) Get(ctx context.Context, opts ...option.RequestO // Union satisfied by [user.BillingProfileGetResponseUnknown] or // [shared.UnionString]. -type BillingProfileGetResponse interface { - ImplementsUserBillingProfileGetResponse() +type BillingProfileGetResponseUnion interface { + ImplementsUserBillingProfileGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*BillingProfileGetResponse)(nil)).Elem(), + reflect.TypeOf((*BillingProfileGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -63,9 +63,9 @@ func init() { } type BillingProfileGetResponseEnvelope struct { - Errors []BillingProfileGetResponseEnvelopeErrors `json:"errors,required"` - Messages []BillingProfileGetResponseEnvelopeMessages `json:"messages,required"` - Result BillingProfileGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result BillingProfileGetResponseUnion `json:"result,required"` // Whether the API call was successful Success BillingProfileGetResponseEnvelopeSuccess `json:"success,required"` JSON billingProfileGetResponseEnvelopeJSON `json:"-"` @@ -90,52 +90,6 @@ func (r billingProfileGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type BillingProfileGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON billingProfileGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// billingProfileGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [BillingProfileGetResponseEnvelopeErrors] -type billingProfileGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BillingProfileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r billingProfileGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BillingProfileGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON billingProfileGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// billingProfileGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [BillingProfileGetResponseEnvelopeMessages] -type billingProfileGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BillingProfileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r billingProfileGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type BillingProfileGetResponseEnvelopeSuccess bool 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 0e089b01837..00000000000 --- a/user/firewallaccessrule.go +++ /dev/null @@ -1,1139 +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/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/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, 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. -// -// Union satisfied by [user.FirewallRuleConfigurationLegacyJhsIPConfiguration], -// [user.FirewallRuleConfigurationLegacyJhsIPV6Configuration], -// [user.FirewallRuleConfigurationLegacyJhsCIDRConfiguration], -// [user.FirewallRuleConfigurationLegacyJhsASNConfiguration] or -// [user.FirewallRuleConfigurationLegacyJhsCountryConfiguration]. -type FirewallRuleConfiguration interface { - implementsUserFirewallRuleConfiguration() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleConfiguration)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleConfigurationLegacyJhsIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleConfigurationLegacyJhsIPV6Configuration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleConfigurationLegacyJhsCIDRConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleConfigurationLegacyJhsASNConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleConfigurationLegacyJhsCountryConfiguration{}), - }, - ) -} - -type FirewallRuleConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target FirewallRuleConfigurationLegacyJhsIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON firewallRuleConfigurationLegacyJhsIPConfigurationJSON `json:"-"` -} - -// firewallRuleConfigurationLegacyJhsIPConfigurationJSON contains the JSON metadata -// for the struct [FirewallRuleConfigurationLegacyJhsIPConfiguration] -type firewallRuleConfigurationLegacyJhsIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleConfigurationLegacyJhsIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleConfigurationLegacyJhsIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleConfigurationLegacyJhsIPConfiguration) implementsUserFirewallRuleConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type FirewallRuleConfigurationLegacyJhsIPConfigurationTarget string - -const ( - FirewallRuleConfigurationLegacyJhsIPConfigurationTargetIP FirewallRuleConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -func (r FirewallRuleConfigurationLegacyJhsIPConfigurationTarget) IsKnown() bool { - switch r { - case FirewallRuleConfigurationLegacyJhsIPConfigurationTargetIP: - return true - } - return false -} - -type FirewallRuleConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target FirewallRuleConfigurationLegacyJhsIPV6ConfigurationTarget `json:"target"` - // The IPv6 address to match. - Value string `json:"value"` - JSON firewallRuleConfigurationLegacyJhsIPV6ConfigurationJSON `json:"-"` -} - -// firewallRuleConfigurationLegacyJhsIPV6ConfigurationJSON contains the JSON -// metadata for the struct [FirewallRuleConfigurationLegacyJhsIPV6Configuration] -type firewallRuleConfigurationLegacyJhsIPV6ConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleConfigurationLegacyJhsIPV6Configuration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleConfigurationLegacyJhsIPV6ConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleConfigurationLegacyJhsIPV6Configuration) implementsUserFirewallRuleConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type FirewallRuleConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - FirewallRuleConfigurationLegacyJhsIPV6ConfigurationTargetIp6 FirewallRuleConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -func (r FirewallRuleConfigurationLegacyJhsIPV6ConfigurationTarget) IsKnown() bool { - switch r { - case FirewallRuleConfigurationLegacyJhsIPV6ConfigurationTargetIp6: - return true - } - return false -} - -type FirewallRuleConfigurationLegacyJhsCIDRConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target FirewallRuleConfigurationLegacyJhsCIDRConfigurationTarget `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 firewallRuleConfigurationLegacyJhsCIDRConfigurationJSON `json:"-"` -} - -// firewallRuleConfigurationLegacyJhsCIDRConfigurationJSON contains the JSON -// metadata for the struct [FirewallRuleConfigurationLegacyJhsCIDRConfiguration] -type firewallRuleConfigurationLegacyJhsCIDRConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleConfigurationLegacyJhsCIDRConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleConfigurationLegacyJhsCIDRConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleConfigurationLegacyJhsCIDRConfiguration) implementsUserFirewallRuleConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type FirewallRuleConfigurationLegacyJhsCIDRConfigurationTarget string - -const ( - FirewallRuleConfigurationLegacyJhsCIDRConfigurationTargetIPRange FirewallRuleConfigurationLegacyJhsCIDRConfigurationTarget = "ip_range" -) - -func (r FirewallRuleConfigurationLegacyJhsCIDRConfigurationTarget) IsKnown() bool { - switch r { - case FirewallRuleConfigurationLegacyJhsCIDRConfigurationTargetIPRange: - return true - } - return false -} - -type FirewallRuleConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target FirewallRuleConfigurationLegacyJhsASNConfigurationTarget `json:"target"` - // The AS number to match. - Value string `json:"value"` - JSON firewallRuleConfigurationLegacyJhsASNConfigurationJSON `json:"-"` -} - -// firewallRuleConfigurationLegacyJhsASNConfigurationJSON contains the JSON -// metadata for the struct [FirewallRuleConfigurationLegacyJhsASNConfiguration] -type firewallRuleConfigurationLegacyJhsASNConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleConfigurationLegacyJhsASNConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleConfigurationLegacyJhsASNConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleConfigurationLegacyJhsASNConfiguration) implementsUserFirewallRuleConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type FirewallRuleConfigurationLegacyJhsASNConfigurationTarget string - -const ( - FirewallRuleConfigurationLegacyJhsASNConfigurationTargetASN FirewallRuleConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -func (r FirewallRuleConfigurationLegacyJhsASNConfigurationTarget) IsKnown() bool { - switch r { - case FirewallRuleConfigurationLegacyJhsASNConfigurationTargetASN: - return true - } - return false -} - -type FirewallRuleConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target FirewallRuleConfigurationLegacyJhsCountryConfigurationTarget `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 firewallRuleConfigurationLegacyJhsCountryConfigurationJSON `json:"-"` -} - -// firewallRuleConfigurationLegacyJhsCountryConfigurationJSON contains the JSON -// metadata for the struct [FirewallRuleConfigurationLegacyJhsCountryConfiguration] -type firewallRuleConfigurationLegacyJhsCountryConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleConfigurationLegacyJhsCountryConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleConfigurationLegacyJhsCountryConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleConfigurationLegacyJhsCountryConfiguration) implementsUserFirewallRuleConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type FirewallRuleConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - FirewallRuleConfigurationLegacyJhsCountryConfigurationTargetCountry FirewallRuleConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -func (r FirewallRuleConfigurationLegacyJhsCountryConfigurationTarget) IsKnown() bool { - switch r { - case FirewallRuleConfigurationLegacyJhsCountryConfigurationTargetCountry: - 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[FirewallAccessRuleNewParamsConfiguration] `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. -// -// Satisfied by -// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration], -// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration], -// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration], -// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration], -// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration]. -type FirewallAccessRuleNewParamsConfiguration interface { - implementsUserFirewallAccessRuleNewParamsConfiguration() -} - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget] `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 FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget) IsKnown() bool { - switch r { - case FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP: - return true - } - return false -} - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` - // The IPv6 address to match. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget) IsKnown() bool { - switch r { - case FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6: - return true - } - return false -} - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget] `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 FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTargetIPRange FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget = "ip_range" -) - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTarget) IsKnown() bool { - switch r { - case FirewallAccessRuleNewParamsConfigurationLegacyJhsCIDRConfigurationTargetIPRange: - return true - } - return false -} - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` - // The AS number to match. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget) IsKnown() bool { - switch r { - case FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN: - return true - } - return false -} - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget] `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 FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget) IsKnown() bool { - switch r { - case FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry: - 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 []FirewallAccessRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAccessRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result FirewallRule `json:"result,required,nullable"` - // 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 -} - -type FirewallAccessRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAccessRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallAccessRuleNewResponseEnvelopeErrors] -type firewallAccessRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAccessRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallAccessRuleNewResponseEnvelopeMessages] -type firewallAccessRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleNewResponseEnvelopeMessagesJSON) 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.ArrayQueryFormatComma, - 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.ArrayQueryFormatComma, - 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.ArrayQueryFormatComma, - 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.ArrayQueryFormatComma, - 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 FirewallAccessRuleDeleteResponseEnvelope struct { - Errors []FirewallAccessRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAccessRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FirewallAccessRuleDeleteResponse `json:"result,required,nullable"` - // 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 -} - -type FirewallAccessRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallAccessRuleDeleteResponseEnvelopeErrors] -type firewallAccessRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallAccessRuleDeleteResponseEnvelopeMessages] -type firewallAccessRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseEnvelopeMessagesJSON) 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 []FirewallAccessRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAccessRuleEditResponseEnvelopeMessages `json:"messages,required"` - Result FirewallRule `json:"result,required,nullable"` - // 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 -} - -type FirewallAccessRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAccessRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallAccessRuleEditResponseEnvelopeErrors] -type firewallAccessRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAccessRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallAccessRuleEditResponseEnvelopeMessages] -type firewallAccessRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleEditResponseEnvelopeMessagesJSON) 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 866d6863571..00000000000 --- a/user/firewallaccessrule_test.go +++ /dev/null @@ -1,143 +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 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.FirewallAccessRuleNewParamsConfiguration](user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration(user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration{ - Target: cloudflare.F(user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP), - 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") - 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/invite.go b/user/invite.go index 67f8146e808..2922a20cd05 100644 --- a/user/invite.go +++ b/user/invite.go @@ -9,7 +9,6 @@ import ( "reflect" "time" - "github.com/cloudflare/cloudflare-go/v2/accounts" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" "github.com/cloudflare/cloudflare-go/v2/internal/param" @@ -37,7 +36,7 @@ func NewInviteService(opts ...option.RequestOption) (r *InviteService) { } // Lists all invitations associated with my user. -func (r *InviteService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.SinglePage[InviteListResponse], err error) { +func (r *InviteService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.SinglePage[Invite], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -55,12 +54,12 @@ func (r *InviteService) List(ctx context.Context, opts ...option.RequestOption) } // Lists all invitations associated with my user. -func (r *InviteService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.SinglePageAutoPager[InviteListResponse] { +func (r *InviteService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Invite] { return pagination.NewSinglePageAutoPager(r.List(ctx, opts...)) } // Responds to an invitation. -func (r *InviteService) Edit(ctx context.Context, inviteID string, body InviteEditParams, opts ...option.RequestOption) (res *InviteEditResponse, err error) { +func (r *InviteService) Edit(ctx context.Context, inviteID string, body InviteEditParams, opts ...option.RequestOption) (res *InviteEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env InviteEditResponseEnvelope path := fmt.Sprintf("user/invites/%s", inviteID) @@ -73,7 +72,7 @@ func (r *InviteService) Edit(ctx context.Context, inviteID string, body InviteEd } // Gets the details of an invitation. -func (r *InviteService) Get(ctx context.Context, inviteID string, opts ...option.RequestOption) (res *InviteGetResponse, err error) { +func (r *InviteService) Get(ctx context.Context, inviteID string, opts ...option.RequestOption) (res *InviteGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env InviteGetResponseEnvelope path := fmt.Sprintf("user/invites/%s", inviteID) @@ -85,7 +84,7 @@ func (r *InviteService) Get(ctx context.Context, inviteID string, opts ...option return } -type InviteListResponse struct { +type Invite struct { // ID of the user to add to the organization. InvitedMemberID string `json:"invited_member_id,required,nullable"` // ID of the organization the user will be added to. @@ -103,15 +102,14 @@ type InviteListResponse struct { // Organization name. OrganizationName string `json:"organization_name"` // Roles to be assigned to this user. - Roles []accounts.Role `json:"roles"` + Roles []shared.Role `json:"roles"` // Current status of the invitation. - Status InviteListResponseStatus `json:"status"` - JSON inviteListResponseJSON `json:"-"` + Status InviteStatus `json:"status"` + JSON inviteJSON `json:"-"` } -// inviteListResponseJSON contains the JSON metadata for the struct -// [InviteListResponse] -type inviteListResponseJSON struct { +// inviteJSON contains the JSON metadata for the struct [Invite] +type inviteJSON struct { InvitedMemberID apijson.Field OrganizationID apijson.Field ID apijson.Field @@ -126,40 +124,40 @@ type inviteListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *InviteListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Invite) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r inviteListResponseJSON) RawJSON() string { +func (r inviteJSON) RawJSON() string { return r.raw } // Current status of the invitation. -type InviteListResponseStatus string +type InviteStatus string const ( - InviteListResponseStatusPending InviteListResponseStatus = "pending" - InviteListResponseStatusAccepted InviteListResponseStatus = "accepted" - InviteListResponseStatusRejected InviteListResponseStatus = "rejected" - InviteListResponseStatusExpired InviteListResponseStatus = "expired" + InviteStatusPending InviteStatus = "pending" + InviteStatusAccepted InviteStatus = "accepted" + InviteStatusRejected InviteStatus = "rejected" + InviteStatusExpired InviteStatus = "expired" ) -func (r InviteListResponseStatus) IsKnown() bool { +func (r InviteStatus) IsKnown() bool { switch r { - case InviteListResponseStatusPending, InviteListResponseStatusAccepted, InviteListResponseStatusRejected, InviteListResponseStatusExpired: + case InviteStatusPending, InviteStatusAccepted, InviteStatusRejected, InviteStatusExpired: return true } return false } // Union satisfied by [user.InviteEditResponseUnknown] or [shared.UnionString]. -type InviteEditResponse interface { - ImplementsUserInviteEditResponse() +type InviteEditResponseUnion interface { + ImplementsUserInviteEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*InviteEditResponse)(nil)).Elem(), + reflect.TypeOf((*InviteEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -169,13 +167,13 @@ func init() { } // Union satisfied by [user.InviteGetResponseUnknown] or [shared.UnionString]. -type InviteGetResponse interface { - ImplementsUserInviteGetResponse() +type InviteGetResponseUnion interface { + ImplementsUserInviteGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*InviteGetResponse)(nil)).Elem(), + reflect.TypeOf((*InviteGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -210,9 +208,9 @@ func (r InviteEditParamsStatus) IsKnown() bool { } type InviteEditResponseEnvelope struct { - Errors []InviteEditResponseEnvelopeErrors `json:"errors,required"` - Messages []InviteEditResponseEnvelopeMessages `json:"messages,required"` - Result InviteEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result InviteEditResponseUnion `json:"result,required"` // Whether the API call was successful Success InviteEditResponseEnvelopeSuccess `json:"success,required"` JSON inviteEditResponseEnvelopeJSON `json:"-"` @@ -237,52 +235,6 @@ func (r inviteEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type InviteEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON inviteEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// inviteEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [InviteEditResponseEnvelopeErrors] -type inviteEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InviteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r inviteEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type InviteEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON inviteEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// inviteEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [InviteEditResponseEnvelopeMessages] -type inviteEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InviteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r inviteEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type InviteEditResponseEnvelopeSuccess bool @@ -299,9 +251,9 @@ func (r InviteEditResponseEnvelopeSuccess) IsKnown() bool { } type InviteGetResponseEnvelope struct { - Errors []InviteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []InviteGetResponseEnvelopeMessages `json:"messages,required"` - Result InviteGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result InviteGetResponseUnion `json:"result,required"` // Whether the API call was successful Success InviteGetResponseEnvelopeSuccess `json:"success,required"` JSON inviteGetResponseEnvelopeJSON `json:"-"` @@ -326,52 +278,6 @@ func (r inviteGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type InviteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON inviteGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// inviteGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [InviteGetResponseEnvelopeErrors] -type inviteGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InviteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r inviteGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type InviteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON inviteGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// inviteGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [InviteGetResponseEnvelopeMessages] -type inviteGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InviteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r inviteGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type InviteGetResponseEnvelopeSuccess bool diff --git a/user/loadbalancer.go b/user/loadbalancer.go deleted file mode 100644 index 9781901d7c2..00000000000 --- a/user/loadbalancer.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" -) - -// LoadBalancerService 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 [NewLoadBalancerService] method -// instead. -type LoadBalancerService struct { - Options []option.RequestOption - Monitors *LoadBalancerMonitorService - Pools *LoadBalancerPoolService - Preview *LoadBalancerPreviewService - Analytics *LoadBalancerAnalyticsService -} - -// NewLoadBalancerService 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 NewLoadBalancerService(opts ...option.RequestOption) (r *LoadBalancerService) { - r = &LoadBalancerService{} - r.Options = opts - r.Monitors = NewLoadBalancerMonitorService(opts...) - r.Pools = NewLoadBalancerPoolService(opts...) - r.Preview = NewLoadBalancerPreviewService(opts...) - r.Analytics = NewLoadBalancerAnalyticsService(opts...) - return -} diff --git a/user/loadbalanceranalytics.go b/user/loadbalanceranalytics.go deleted file mode 100644 index a0b0d99c64a..00000000000 --- a/user/loadbalanceranalytics.go +++ /dev/null @@ -1,27 +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" -) - -// LoadBalancerAnalyticsService 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 [NewLoadBalancerAnalyticsService] -// method instead. -type LoadBalancerAnalyticsService struct { - Options []option.RequestOption - Events *LoadBalancerAnalyticsEventService -} - -// NewLoadBalancerAnalyticsService 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 NewLoadBalancerAnalyticsService(opts ...option.RequestOption) (r *LoadBalancerAnalyticsService) { - r = &LoadBalancerAnalyticsService{} - r.Options = opts - r.Events = NewLoadBalancerAnalyticsEventService(opts...) - return -} diff --git a/user/loadbalanceranalyticsevent.go b/user/loadbalanceranalyticsevent.go deleted file mode 100644 index d3528749e20..00000000000 --- a/user/loadbalanceranalyticsevent.go +++ /dev/null @@ -1,112 +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/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/option" -) - -// LoadBalancerAnalyticsEventService 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 -// [NewLoadBalancerAnalyticsEventService] method instead. -type LoadBalancerAnalyticsEventService struct { - Options []option.RequestOption -} - -// NewLoadBalancerAnalyticsEventService 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 NewLoadBalancerAnalyticsEventService(opts ...option.RequestOption) (r *LoadBalancerAnalyticsEventService) { - r = &LoadBalancerAnalyticsEventService{} - r.Options = opts - return -} - -// List origin health changes. -func (r *LoadBalancerAnalyticsEventService) List(ctx context.Context, query LoadBalancerAnalyticsEventListParams, opts ...option.RequestOption) (res *pagination.SinglePage[LoadBalancingAnalytics], 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 *LoadBalancerAnalyticsEventService) ListAutoPaging(ctx context.Context, query LoadBalancerAnalyticsEventListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[LoadBalancingAnalytics] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -type LoadBalancingAnalytics struct { - ID int64 `json:"id"` - Origins []interface{} `json:"origins"` - Pool interface{} `json:"pool"` - Timestamp time.Time `json:"timestamp" format:"date-time"` - JSON loadBalancingAnalyticsJSON `json:"-"` -} - -// loadBalancingAnalyticsJSON contains the JSON metadata for the struct -// [LoadBalancingAnalytics] -type loadBalancingAnalyticsJSON struct { - ID apijson.Field - Origins apijson.Field - Pool apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingAnalytics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingAnalyticsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerAnalyticsEventListParams 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 [LoadBalancerAnalyticsEventListParams]'s query parameters as -// `url.Values`. -func (r LoadBalancerAnalyticsEventListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/user/loadbalanceranalyticsevent_test.go b/user/loadbalanceranalyticsevent_test.go deleted file mode 100644 index 48a7aea2098..00000000000 --- a/user/loadbalanceranalyticsevent_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 TestLoadBalancerAnalyticsEventListWithOptionalParams(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.LoadBalancers.Analytics.Events.List(context.TODO(), user.LoadBalancerAnalyticsEventListParams{ - 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/loadbalancermonitor.go b/user/loadbalancermonitor.go deleted file mode 100644 index 57725dd7619..00000000000 --- a/user/loadbalancermonitor.go +++ /dev/null @@ -1,1314 +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/option" -) - -// LoadBalancerMonitorService 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 [NewLoadBalancerMonitorService] -// method instead. -type LoadBalancerMonitorService struct { - Options []option.RequestOption -} - -// NewLoadBalancerMonitorService 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 NewLoadBalancerMonitorService(opts ...option.RequestOption) (r *LoadBalancerMonitorService) { - r = &LoadBalancerMonitorService{} - r.Options = opts - return -} - -// Create a configured monitor. -func (r *LoadBalancerMonitorService) New(ctx context.Context, body LoadBalancerMonitorNewParams, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorNewResponseEnvelope - 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 *LoadBalancerMonitorService) Update(ctx context.Context, monitorID string, body LoadBalancerMonitorUpdateParams, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorUpdateResponseEnvelope - 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 *LoadBalancerMonitorService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.SinglePage[LoadBalancingMonitor], 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 *LoadBalancerMonitorService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.SinglePageAutoPager[LoadBalancingMonitor] { - return pagination.NewSinglePageAutoPager(r.List(ctx, opts...)) -} - -// Delete a configured monitor. -func (r *LoadBalancerMonitorService) Delete(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *LoadBalancerMonitorDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorDeleteResponseEnvelope - 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 *LoadBalancerMonitorService) Edit(ctx context.Context, monitorID string, body LoadBalancerMonitorEditParams, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorEditResponseEnvelope - 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 *LoadBalancerMonitorService) Get(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorGetResponseEnvelope - 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 *LoadBalancerMonitorService) Preview(ctx context.Context, monitorID string, body LoadBalancerMonitorPreviewParams, opts ...option.RequestOption) (res *LoadBalancerMonitorPreviewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorPreviewResponseEnvelope - 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 *LoadBalancerMonitorService) References(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *[]LoadBalancerMonitorReferencesResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorReferencesResponseEnvelope - 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 LoadBalancingMonitor 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 LoadBalancingMonitorType `json:"type"` - JSON loadBalancingMonitorJSON `json:"-"` -} - -// loadBalancingMonitorJSON contains the JSON metadata for the struct -// [LoadBalancingMonitor] -type loadBalancingMonitorJSON 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 *LoadBalancingMonitor) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorJSON) 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 LoadBalancingMonitorType string - -const ( - LoadBalancingMonitorTypeHTTP LoadBalancingMonitorType = "http" - LoadBalancingMonitorTypeHTTPS LoadBalancingMonitorType = "https" - LoadBalancingMonitorTypeTcp LoadBalancingMonitorType = "tcp" - LoadBalancingMonitorTypeUdpIcmp LoadBalancingMonitorType = "udp_icmp" - LoadBalancingMonitorTypeIcmpPing LoadBalancingMonitorType = "icmp_ping" - LoadBalancingMonitorTypeSmtp LoadBalancingMonitorType = "smtp" -) - -func (r LoadBalancingMonitorType) IsKnown() bool { - switch r { - case LoadBalancingMonitorTypeHTTP, LoadBalancingMonitorTypeHTTPS, LoadBalancingMonitorTypeTcp, LoadBalancingMonitorTypeUdpIcmp, LoadBalancingMonitorTypeIcmpPing, LoadBalancingMonitorTypeSmtp: - return true - } - return false -} - -type LoadBalancerMonitorDeleteResponse struct { - ID string `json:"id"` - JSON loadBalancerMonitorDeleteResponseJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorDeleteResponse] -type loadBalancerMonitorDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorPreviewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON loadBalancerMonitorPreviewResponseJSON `json:"-"` -} - -// loadBalancerMonitorPreviewResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorPreviewResponse] -type loadBalancerMonitorPreviewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorReferencesResponse struct { - ReferenceType LoadBalancerMonitorReferencesResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON loadBalancerMonitorReferencesResponseJSON `json:"-"` -} - -// loadBalancerMonitorReferencesResponseJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorReferencesResponse] -type loadBalancerMonitorReferencesResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferencesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferencesResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorReferencesResponseReferenceType string - -const ( - LoadBalancerMonitorReferencesResponseReferenceTypeStar LoadBalancerMonitorReferencesResponseReferenceType = "*" - LoadBalancerMonitorReferencesResponseReferenceTypeReferral LoadBalancerMonitorReferencesResponseReferenceType = "referral" - LoadBalancerMonitorReferencesResponseReferenceTypeReferrer LoadBalancerMonitorReferencesResponseReferenceType = "referrer" -) - -func (r LoadBalancerMonitorReferencesResponseReferenceType) IsKnown() bool { - switch r { - case LoadBalancerMonitorReferencesResponseReferenceTypeStar, LoadBalancerMonitorReferencesResponseReferenceTypeReferral, LoadBalancerMonitorReferencesResponseReferenceTypeReferrer: - return true - } - return false -} - -type LoadBalancerMonitorNewParams 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[LoadBalancerMonitorNewParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorNewParams) 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 LoadBalancerMonitorNewParamsType string - -const ( - LoadBalancerMonitorNewParamsTypeHTTP LoadBalancerMonitorNewParamsType = "http" - LoadBalancerMonitorNewParamsTypeHTTPS LoadBalancerMonitorNewParamsType = "https" - LoadBalancerMonitorNewParamsTypeTcp LoadBalancerMonitorNewParamsType = "tcp" - LoadBalancerMonitorNewParamsTypeUdpIcmp LoadBalancerMonitorNewParamsType = "udp_icmp" - LoadBalancerMonitorNewParamsTypeIcmpPing LoadBalancerMonitorNewParamsType = "icmp_ping" - LoadBalancerMonitorNewParamsTypeSmtp LoadBalancerMonitorNewParamsType = "smtp" -) - -func (r LoadBalancerMonitorNewParamsType) IsKnown() bool { - switch r { - case LoadBalancerMonitorNewParamsTypeHTTP, LoadBalancerMonitorNewParamsTypeHTTPS, LoadBalancerMonitorNewParamsTypeTcp, LoadBalancerMonitorNewParamsTypeUdpIcmp, LoadBalancerMonitorNewParamsTypeIcmpPing, LoadBalancerMonitorNewParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancerMonitorNewResponseEnvelope struct { - Errors []LoadBalancerMonitorNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingMonitor `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorNewResponseEnvelope] -type loadBalancerMonitorNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorNewResponseEnvelopeErrors] -type loadBalancerMonitorNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorNewResponseEnvelopeMessages] -type loadBalancerMonitorNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorNewResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorNewResponseEnvelopeSuccessTrue LoadBalancerMonitorNewResponseEnvelopeSuccess = true -) - -func (r LoadBalancerMonitorNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerMonitorNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerMonitorUpdateParams 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[LoadBalancerMonitorUpdateParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorUpdateParams) 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 LoadBalancerMonitorUpdateParamsType string - -const ( - LoadBalancerMonitorUpdateParamsTypeHTTP LoadBalancerMonitorUpdateParamsType = "http" - LoadBalancerMonitorUpdateParamsTypeHTTPS LoadBalancerMonitorUpdateParamsType = "https" - LoadBalancerMonitorUpdateParamsTypeTcp LoadBalancerMonitorUpdateParamsType = "tcp" - LoadBalancerMonitorUpdateParamsTypeUdpIcmp LoadBalancerMonitorUpdateParamsType = "udp_icmp" - LoadBalancerMonitorUpdateParamsTypeIcmpPing LoadBalancerMonitorUpdateParamsType = "icmp_ping" - LoadBalancerMonitorUpdateParamsTypeSmtp LoadBalancerMonitorUpdateParamsType = "smtp" -) - -func (r LoadBalancerMonitorUpdateParamsType) IsKnown() bool { - switch r { - case LoadBalancerMonitorUpdateParamsTypeHTTP, LoadBalancerMonitorUpdateParamsTypeHTTPS, LoadBalancerMonitorUpdateParamsTypeTcp, LoadBalancerMonitorUpdateParamsTypeUdpIcmp, LoadBalancerMonitorUpdateParamsTypeIcmpPing, LoadBalancerMonitorUpdateParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancerMonitorUpdateResponseEnvelope struct { - Errors []LoadBalancerMonitorUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingMonitor `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorUpdateResponseEnvelope] -type loadBalancerMonitorUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorUpdateResponseEnvelopeErrors] -type loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorUpdateResponseEnvelopeMessages] -type loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorUpdateResponseEnvelopeSuccessTrue LoadBalancerMonitorUpdateResponseEnvelopeSuccess = true -) - -func (r LoadBalancerMonitorUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerMonitorUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerMonitorDeleteResponseEnvelope struct { - Errors []LoadBalancerMonitorDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorDeleteResponseEnvelope] -type loadBalancerMonitorDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorDeleteResponseEnvelopeErrors] -type loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorDeleteResponseEnvelopeMessages] -type loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorDeleteResponseEnvelopeSuccessTrue LoadBalancerMonitorDeleteResponseEnvelopeSuccess = true -) - -func (r LoadBalancerMonitorDeleteResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerMonitorDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerMonitorEditParams 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[LoadBalancerMonitorEditParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorEditParams) 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 LoadBalancerMonitorEditParamsType string - -const ( - LoadBalancerMonitorEditParamsTypeHTTP LoadBalancerMonitorEditParamsType = "http" - LoadBalancerMonitorEditParamsTypeHTTPS LoadBalancerMonitorEditParamsType = "https" - LoadBalancerMonitorEditParamsTypeTcp LoadBalancerMonitorEditParamsType = "tcp" - LoadBalancerMonitorEditParamsTypeUdpIcmp LoadBalancerMonitorEditParamsType = "udp_icmp" - LoadBalancerMonitorEditParamsTypeIcmpPing LoadBalancerMonitorEditParamsType = "icmp_ping" - LoadBalancerMonitorEditParamsTypeSmtp LoadBalancerMonitorEditParamsType = "smtp" -) - -func (r LoadBalancerMonitorEditParamsType) IsKnown() bool { - switch r { - case LoadBalancerMonitorEditParamsTypeHTTP, LoadBalancerMonitorEditParamsTypeHTTPS, LoadBalancerMonitorEditParamsTypeTcp, LoadBalancerMonitorEditParamsTypeUdpIcmp, LoadBalancerMonitorEditParamsTypeIcmpPing, LoadBalancerMonitorEditParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancerMonitorEditResponseEnvelope struct { - Errors []LoadBalancerMonitorEditResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorEditResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingMonitor `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorEditResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorEditResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorEditResponseEnvelope] -type loadBalancerMonitorEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorEditResponseEnvelopeErrors] -type loadBalancerMonitorEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorEditResponseEnvelopeMessages] -type loadBalancerMonitorEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorEditResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorEditResponseEnvelopeSuccessTrue LoadBalancerMonitorEditResponseEnvelopeSuccess = true -) - -func (r LoadBalancerMonitorEditResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerMonitorEditResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerMonitorGetResponseEnvelope struct { - Errors []LoadBalancerMonitorGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorGetResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingMonitor `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorGetResponseEnvelope] -type loadBalancerMonitorGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorGetResponseEnvelopeErrors] -type loadBalancerMonitorGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorGetResponseEnvelopeMessages] -type loadBalancerMonitorGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorGetResponseEnvelopeSuccessTrue LoadBalancerMonitorGetResponseEnvelopeSuccess = true -) - -func (r LoadBalancerMonitorGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerMonitorGetResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerMonitorPreviewParams 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[LoadBalancerMonitorPreviewParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorPreviewParams) 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 LoadBalancerMonitorPreviewParamsType string - -const ( - LoadBalancerMonitorPreviewParamsTypeHTTP LoadBalancerMonitorPreviewParamsType = "http" - LoadBalancerMonitorPreviewParamsTypeHTTPS LoadBalancerMonitorPreviewParamsType = "https" - LoadBalancerMonitorPreviewParamsTypeTcp LoadBalancerMonitorPreviewParamsType = "tcp" - LoadBalancerMonitorPreviewParamsTypeUdpIcmp LoadBalancerMonitorPreviewParamsType = "udp_icmp" - LoadBalancerMonitorPreviewParamsTypeIcmpPing LoadBalancerMonitorPreviewParamsType = "icmp_ping" - LoadBalancerMonitorPreviewParamsTypeSmtp LoadBalancerMonitorPreviewParamsType = "smtp" -) - -func (r LoadBalancerMonitorPreviewParamsType) IsKnown() bool { - switch r { - case LoadBalancerMonitorPreviewParamsTypeHTTP, LoadBalancerMonitorPreviewParamsTypeHTTPS, LoadBalancerMonitorPreviewParamsTypeTcp, LoadBalancerMonitorPreviewParamsTypeUdpIcmp, LoadBalancerMonitorPreviewParamsTypeIcmpPing, LoadBalancerMonitorPreviewParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancerMonitorPreviewResponseEnvelope struct { - Errors []LoadBalancerMonitorPreviewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorPreviewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorPreviewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorPreviewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorPreviewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorPreviewResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorPreviewResponseEnvelope] -type loadBalancerMonitorPreviewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorPreviewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorPreviewResponseEnvelopeErrors] -type loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorPreviewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LoadBalancerMonitorPreviewResponseEnvelopeMessages] -type loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorPreviewResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorPreviewResponseEnvelopeSuccessTrue LoadBalancerMonitorPreviewResponseEnvelopeSuccess = true -) - -func (r LoadBalancerMonitorPreviewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerMonitorPreviewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerMonitorReferencesResponseEnvelope struct { - Errors []LoadBalancerMonitorReferencesResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorReferencesResponseEnvelopeMessages `json:"messages,required"` - // List of resources that reference a given monitor. - Result []LoadBalancerMonitorReferencesResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerMonitorReferencesResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerMonitorReferencesResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerMonitorReferencesResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorReferencesResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorReferencesResponseEnvelope] -type loadBalancerMonitorReferencesResponseEnvelopeJSON 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 *LoadBalancerMonitorReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferencesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorReferencesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [LoadBalancerMonitorReferencesResponseEnvelopeErrors] -type loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferencesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorReferencesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LoadBalancerMonitorReferencesResponseEnvelopeMessages] -type loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferencesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorReferencesResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorReferencesResponseEnvelopeSuccessTrue LoadBalancerMonitorReferencesResponseEnvelopeSuccess = true -) - -func (r LoadBalancerMonitorReferencesResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerMonitorReferencesResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerMonitorReferencesResponseEnvelopeResultInfo 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 loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [LoadBalancerMonitorReferencesResponseEnvelopeResultInfo] -type loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/user/loadbalancermonitor_test.go b/user/loadbalancermonitor_test.go deleted file mode 100644 index 0e367fd2da2..00000000000 --- a/user/loadbalancermonitor_test.go +++ /dev/null @@ -1,315 +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 TestLoadBalancerMonitorNewWithOptionalParams(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.LoadBalancers.Monitors.New(context.TODO(), user.LoadBalancerMonitorNewParams{ - 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.LoadBalancerMonitorNewParamsTypeHTTPS), - }) - 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 TestLoadBalancerMonitorUpdateWithOptionalParams(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.LoadBalancers.Monitors.Update( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - user.LoadBalancerMonitorUpdateParams{ - 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.LoadBalancerMonitorUpdateParamsTypeHTTPS), - }, - ) - 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 TestLoadBalancerMonitorList(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.LoadBalancers.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 TestLoadBalancerMonitorDelete(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.LoadBalancers.Monitors.Delete(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 TestLoadBalancerMonitorEditWithOptionalParams(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.LoadBalancers.Monitors.Edit( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - user.LoadBalancerMonitorEditParams{ - 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.LoadBalancerMonitorEditParamsTypeHTTPS), - }, - ) - 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 TestLoadBalancerMonitorGet(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.LoadBalancers.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 TestLoadBalancerMonitorPreviewWithOptionalParams(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.LoadBalancers.Monitors.Preview( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - user.LoadBalancerMonitorPreviewParams{ - 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.LoadBalancerMonitorPreviewParamsTypeHTTPS), - }, - ) - 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 TestLoadBalancerMonitorReferences(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.LoadBalancers.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/loadbalancerpool.go b/user/loadbalancerpool.go deleted file mode 100644 index 4ea84f720a1..00000000000 --- a/user/loadbalancerpool.go +++ /dev/null @@ -1,2372 +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/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" -) - -// LoadBalancerPoolService 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 [NewLoadBalancerPoolService] method -// instead. -type LoadBalancerPoolService struct { - Options []option.RequestOption -} - -// NewLoadBalancerPoolService 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 NewLoadBalancerPoolService(opts ...option.RequestOption) (r *LoadBalancerPoolService) { - r = &LoadBalancerPoolService{} - r.Options = opts - return -} - -// Create a new pool. -func (r *LoadBalancerPoolService) New(ctx context.Context, body LoadBalancerPoolNewParams, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolNewResponseEnvelope - 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 *LoadBalancerPoolService) Update(ctx context.Context, poolID string, body LoadBalancerPoolUpdateParams, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolUpdateResponseEnvelope - 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 *LoadBalancerPoolService) List(ctx context.Context, query LoadBalancerPoolListParams, opts ...option.RequestOption) (res *pagination.SinglePage[LoadBalancingPool], 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 *LoadBalancerPoolService) ListAutoPaging(ctx context.Context, query LoadBalancerPoolListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[LoadBalancingPool] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -// Delete a configured pool. -func (r *LoadBalancerPoolService) Delete(ctx context.Context, poolID string, opts ...option.RequestOption) (res *LoadBalancerPoolDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolDeleteResponseEnvelope - 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 *LoadBalancerPoolService) Edit(ctx context.Context, poolID string, body LoadBalancerPoolEditParams, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolEditResponseEnvelope - 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 *LoadBalancerPoolService) Get(ctx context.Context, poolID string, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolGetResponseEnvelope - 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 *LoadBalancerPoolService) Health(ctx context.Context, poolID string, opts ...option.RequestOption) (res *LoadBalancerPoolHealthResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolHealthResponseEnvelope - 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 *LoadBalancerPoolService) Preview(ctx context.Context, poolID string, body LoadBalancerPoolPreviewParams, opts ...option.RequestOption) (res *LoadBalancerPoolPreviewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolPreviewResponseEnvelope - 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 *LoadBalancerPoolService) References(ctx context.Context, poolID string, opts ...option.RequestOption) (res *[]LoadBalancerPoolReferencesResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolReferencesResponseEnvelope - 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 LoadBalancingPool struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []LoadBalancingPoolCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // 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 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 float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding LoadBalancingPoolLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // 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 int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name 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 string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter LoadBalancingPoolNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering LoadBalancingPoolOriginSteering `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 []LoadBalancingPoolOrigin `json:"origins"` - JSON loadBalancingPoolJSON `json:"-"` -} - -// loadBalancingPoolJSON contains the JSON metadata for the struct -// [LoadBalancingPool] -type loadBalancingPoolJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancingPoolCheckRegion string - -const ( - LoadBalancingPoolCheckRegionWnam LoadBalancingPoolCheckRegion = "WNAM" - LoadBalancingPoolCheckRegionEnam LoadBalancingPoolCheckRegion = "ENAM" - LoadBalancingPoolCheckRegionWeu LoadBalancingPoolCheckRegion = "WEU" - LoadBalancingPoolCheckRegionEeu LoadBalancingPoolCheckRegion = "EEU" - LoadBalancingPoolCheckRegionNsam LoadBalancingPoolCheckRegion = "NSAM" - LoadBalancingPoolCheckRegionSsam LoadBalancingPoolCheckRegion = "SSAM" - LoadBalancingPoolCheckRegionOc LoadBalancingPoolCheckRegion = "OC" - LoadBalancingPoolCheckRegionMe LoadBalancingPoolCheckRegion = "ME" - LoadBalancingPoolCheckRegionNaf LoadBalancingPoolCheckRegion = "NAF" - LoadBalancingPoolCheckRegionSaf LoadBalancingPoolCheckRegion = "SAF" - LoadBalancingPoolCheckRegionSas LoadBalancingPoolCheckRegion = "SAS" - LoadBalancingPoolCheckRegionSeas LoadBalancingPoolCheckRegion = "SEAS" - LoadBalancingPoolCheckRegionNeas LoadBalancingPoolCheckRegion = "NEAS" - LoadBalancingPoolCheckRegionAllRegions LoadBalancingPoolCheckRegion = "ALL_REGIONS" -) - -func (r LoadBalancingPoolCheckRegion) IsKnown() bool { - switch r { - case LoadBalancingPoolCheckRegionWnam, LoadBalancingPoolCheckRegionEnam, LoadBalancingPoolCheckRegionWeu, LoadBalancingPoolCheckRegionEeu, LoadBalancingPoolCheckRegionNsam, LoadBalancingPoolCheckRegionSsam, LoadBalancingPoolCheckRegionOc, LoadBalancingPoolCheckRegionMe, LoadBalancingPoolCheckRegionNaf, LoadBalancingPoolCheckRegionSaf, LoadBalancingPoolCheckRegionSas, LoadBalancingPoolCheckRegionSeas, LoadBalancingPoolCheckRegionNeas, LoadBalancingPoolCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type LoadBalancingPoolLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy LoadBalancingPoolLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy LoadBalancingPoolLoadSheddingSessionPolicy `json:"session_policy"` - JSON loadBalancingPoolLoadSheddingJSON `json:"-"` -} - -// loadBalancingPoolLoadSheddingJSON contains the JSON metadata for the struct -// [LoadBalancingPoolLoadShedding] -type loadBalancingPoolLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancingPoolLoadSheddingDefaultPolicy string - -const ( - LoadBalancingPoolLoadSheddingDefaultPolicyRandom LoadBalancingPoolLoadSheddingDefaultPolicy = "random" - LoadBalancingPoolLoadSheddingDefaultPolicyHash LoadBalancingPoolLoadSheddingDefaultPolicy = "hash" -) - -func (r LoadBalancingPoolLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case LoadBalancingPoolLoadSheddingDefaultPolicyRandom, LoadBalancingPoolLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancingPoolLoadSheddingSessionPolicy string - -const ( - LoadBalancingPoolLoadSheddingSessionPolicyHash LoadBalancingPoolLoadSheddingSessionPolicy = "hash" -) - -func (r LoadBalancingPoolLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case LoadBalancingPoolLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancingPoolNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin LoadBalancingPoolNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool LoadBalancingPoolNotificationFilterPool `json:"pool,nullable"` - JSON loadBalancingPoolNotificationFilterJSON `json:"-"` -} - -// loadBalancingPoolNotificationFilterJSON contains the JSON metadata for the -// struct [LoadBalancingPoolNotificationFilter] -type loadBalancingPoolNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancingPoolNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancingPoolNotificationFilterOriginJSON `json:"-"` -} - -// loadBalancingPoolNotificationFilterOriginJSON contains the JSON metadata for the -// struct [LoadBalancingPoolNotificationFilterOrigin] -type loadBalancingPoolNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancingPoolNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancingPoolNotificationFilterPoolJSON `json:"-"` -} - -// loadBalancingPoolNotificationFilterPoolJSON contains the JSON metadata for the -// struct [LoadBalancingPoolNotificationFilterPool] -type loadBalancingPoolNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancingPoolOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy LoadBalancingPoolOriginSteeringPolicy `json:"policy"` - JSON loadBalancingPoolOriginSteeringJSON `json:"-"` -} - -// loadBalancingPoolOriginSteeringJSON contains the JSON metadata for the struct -// [LoadBalancingPoolOriginSteering] -type loadBalancingPoolOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancingPoolOriginSteeringPolicy string - -const ( - LoadBalancingPoolOriginSteeringPolicyRandom LoadBalancingPoolOriginSteeringPolicy = "random" - LoadBalancingPoolOriginSteeringPolicyHash LoadBalancingPoolOriginSteeringPolicy = "hash" - LoadBalancingPoolOriginSteeringPolicyLeastOutstandingRequests LoadBalancingPoolOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancingPoolOriginSteeringPolicyLeastConnections LoadBalancingPoolOriginSteeringPolicy = "least_connections" -) - -func (r LoadBalancingPoolOriginSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancingPoolOriginSteeringPolicyRandom, LoadBalancingPoolOriginSteeringPolicyHash, LoadBalancingPoolOriginSteeringPolicyLeastOutstandingRequests, LoadBalancingPoolOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type LoadBalancingPoolOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header LoadBalancingPoolOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON loadBalancingPoolOriginJSON `json:"-"` -} - -// loadBalancingPoolOriginJSON contains the JSON metadata for the struct -// [LoadBalancingPoolOrigin] -type loadBalancingPoolOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancingPoolOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON loadBalancingPoolOriginsHeaderJSON `json:"-"` -} - -// loadBalancingPoolOriginsHeaderJSON contains the JSON metadata for the struct -// [LoadBalancingPoolOriginsHeader] -type loadBalancingPoolOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolDeleteResponse struct { - ID string `json:"id"` - JSON loadBalancerPoolDeleteResponseJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolDeleteResponse] -type loadBalancerPoolDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseJSON) 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.LoadBalancerPoolHealthResponseUnknown] or -// [shared.UnionString]. -type LoadBalancerPoolHealthResponse interface { - ImplementsUserLoadBalancerPoolHealthResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LoadBalancerPoolHealthResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LoadBalancerPoolPreviewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON loadBalancerPoolPreviewResponseJSON `json:"-"` -} - -// loadBalancerPoolPreviewResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolPreviewResponse] -type loadBalancerPoolPreviewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolPreviewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolPreviewResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolReferencesResponse struct { - ReferenceType LoadBalancerPoolReferencesResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON loadBalancerPoolReferencesResponseJSON `json:"-"` -} - -// loadBalancerPoolReferencesResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolReferencesResponse] -type loadBalancerPoolReferencesResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferencesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferencesResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolReferencesResponseReferenceType string - -const ( - LoadBalancerPoolReferencesResponseReferenceTypeStar LoadBalancerPoolReferencesResponseReferenceType = "*" - LoadBalancerPoolReferencesResponseReferenceTypeReferral LoadBalancerPoolReferencesResponseReferenceType = "referral" - LoadBalancerPoolReferencesResponseReferenceTypeReferrer LoadBalancerPoolReferencesResponseReferenceType = "referrer" -) - -func (r LoadBalancerPoolReferencesResponseReferenceType) IsKnown() bool { - switch r { - case LoadBalancerPoolReferencesResponseReferenceTypeStar, LoadBalancerPoolReferencesResponseReferenceTypeReferral, LoadBalancerPoolReferencesResponseReferenceTypeReferrer: - return true - } - return false -} - -type LoadBalancerPoolNewParams 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[[]LoadBalancerPoolNewParamsOrigin] `json:"origins,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]LoadBalancerPoolNewParamsCheckRegion] `json:"check_regions"` - // 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[LoadBalancerPoolNewParamsLoadShedding] `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[LoadBalancerPoolNewParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolNewParamsOriginSteering] `json:"origin_steering"` -} - -func (r LoadBalancerPoolNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancerPoolNewParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolNewParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolNewParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolNewParamsCheckRegion string - -const ( - LoadBalancerPoolNewParamsCheckRegionWnam LoadBalancerPoolNewParamsCheckRegion = "WNAM" - LoadBalancerPoolNewParamsCheckRegionEnam LoadBalancerPoolNewParamsCheckRegion = "ENAM" - LoadBalancerPoolNewParamsCheckRegionWeu LoadBalancerPoolNewParamsCheckRegion = "WEU" - LoadBalancerPoolNewParamsCheckRegionEeu LoadBalancerPoolNewParamsCheckRegion = "EEU" - LoadBalancerPoolNewParamsCheckRegionNsam LoadBalancerPoolNewParamsCheckRegion = "NSAM" - LoadBalancerPoolNewParamsCheckRegionSsam LoadBalancerPoolNewParamsCheckRegion = "SSAM" - LoadBalancerPoolNewParamsCheckRegionOc LoadBalancerPoolNewParamsCheckRegion = "OC" - LoadBalancerPoolNewParamsCheckRegionMe LoadBalancerPoolNewParamsCheckRegion = "ME" - LoadBalancerPoolNewParamsCheckRegionNaf LoadBalancerPoolNewParamsCheckRegion = "NAF" - LoadBalancerPoolNewParamsCheckRegionSaf LoadBalancerPoolNewParamsCheckRegion = "SAF" - LoadBalancerPoolNewParamsCheckRegionSas LoadBalancerPoolNewParamsCheckRegion = "SAS" - LoadBalancerPoolNewParamsCheckRegionSeas LoadBalancerPoolNewParamsCheckRegion = "SEAS" - LoadBalancerPoolNewParamsCheckRegionNeas LoadBalancerPoolNewParamsCheckRegion = "NEAS" - LoadBalancerPoolNewParamsCheckRegionAllRegions LoadBalancerPoolNewParamsCheckRegion = "ALL_REGIONS" -) - -func (r LoadBalancerPoolNewParamsCheckRegion) IsKnown() bool { - switch r { - case LoadBalancerPoolNewParamsCheckRegionWnam, LoadBalancerPoolNewParamsCheckRegionEnam, LoadBalancerPoolNewParamsCheckRegionWeu, LoadBalancerPoolNewParamsCheckRegionEeu, LoadBalancerPoolNewParamsCheckRegionNsam, LoadBalancerPoolNewParamsCheckRegionSsam, LoadBalancerPoolNewParamsCheckRegionOc, LoadBalancerPoolNewParamsCheckRegionMe, LoadBalancerPoolNewParamsCheckRegionNaf, LoadBalancerPoolNewParamsCheckRegionSaf, LoadBalancerPoolNewParamsCheckRegionSas, LoadBalancerPoolNewParamsCheckRegionSeas, LoadBalancerPoolNewParamsCheckRegionNeas, LoadBalancerPoolNewParamsCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolNewParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom, LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolNewParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash LoadBalancerPoolNewParamsLoadSheddingSessionPolicy = "hash" -) - -func (r LoadBalancerPoolNewParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolNewParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolNewParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolNewParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolNewParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolNewParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolNewParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolNewParamsOriginSteeringPolicyRandom LoadBalancerPoolNewParamsOriginSteeringPolicy = "random" - LoadBalancerPoolNewParamsOriginSteeringPolicyHash LoadBalancerPoolNewParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolNewParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolNewParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_connections" -) - -func (r LoadBalancerPoolNewParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolNewParamsOriginSteeringPolicyRandom, LoadBalancerPoolNewParamsOriginSteeringPolicyHash, LoadBalancerPoolNewParamsOriginSteeringPolicyLeastOutstandingRequests, LoadBalancerPoolNewParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type LoadBalancerPoolNewResponseEnvelope struct { - Errors []LoadBalancerPoolNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingPool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolNewResponseEnvelope] -type loadBalancerPoolNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerPoolNewResponseEnvelopeErrors] -type loadBalancerPoolNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerPoolNewResponseEnvelopeMessages] -type loadBalancerPoolNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolNewResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolNewResponseEnvelopeSuccessTrue LoadBalancerPoolNewResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolUpdateParams 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[[]LoadBalancerPoolUpdateParamsOrigin] `json:"origins,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]LoadBalancerPoolUpdateParamsCheckRegion] `json:"check_regions"` - // 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[LoadBalancerPoolUpdateParamsLoadShedding] `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[LoadBalancerPoolUpdateParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolUpdateParamsOriginSteering] `json:"origin_steering"` -} - -func (r LoadBalancerPoolUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancerPoolUpdateParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolUpdateParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolUpdateParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolUpdateParamsCheckRegion string - -const ( - LoadBalancerPoolUpdateParamsCheckRegionWnam LoadBalancerPoolUpdateParamsCheckRegion = "WNAM" - LoadBalancerPoolUpdateParamsCheckRegionEnam LoadBalancerPoolUpdateParamsCheckRegion = "ENAM" - LoadBalancerPoolUpdateParamsCheckRegionWeu LoadBalancerPoolUpdateParamsCheckRegion = "WEU" - LoadBalancerPoolUpdateParamsCheckRegionEeu LoadBalancerPoolUpdateParamsCheckRegion = "EEU" - LoadBalancerPoolUpdateParamsCheckRegionNsam LoadBalancerPoolUpdateParamsCheckRegion = "NSAM" - LoadBalancerPoolUpdateParamsCheckRegionSsam LoadBalancerPoolUpdateParamsCheckRegion = "SSAM" - LoadBalancerPoolUpdateParamsCheckRegionOc LoadBalancerPoolUpdateParamsCheckRegion = "OC" - LoadBalancerPoolUpdateParamsCheckRegionMe LoadBalancerPoolUpdateParamsCheckRegion = "ME" - LoadBalancerPoolUpdateParamsCheckRegionNaf LoadBalancerPoolUpdateParamsCheckRegion = "NAF" - LoadBalancerPoolUpdateParamsCheckRegionSaf LoadBalancerPoolUpdateParamsCheckRegion = "SAF" - LoadBalancerPoolUpdateParamsCheckRegionSas LoadBalancerPoolUpdateParamsCheckRegion = "SAS" - LoadBalancerPoolUpdateParamsCheckRegionSeas LoadBalancerPoolUpdateParamsCheckRegion = "SEAS" - LoadBalancerPoolUpdateParamsCheckRegionNeas LoadBalancerPoolUpdateParamsCheckRegion = "NEAS" - LoadBalancerPoolUpdateParamsCheckRegionAllRegions LoadBalancerPoolUpdateParamsCheckRegion = "ALL_REGIONS" -) - -func (r LoadBalancerPoolUpdateParamsCheckRegion) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateParamsCheckRegionWnam, LoadBalancerPoolUpdateParamsCheckRegionEnam, LoadBalancerPoolUpdateParamsCheckRegionWeu, LoadBalancerPoolUpdateParamsCheckRegionEeu, LoadBalancerPoolUpdateParamsCheckRegionNsam, LoadBalancerPoolUpdateParamsCheckRegionSsam, LoadBalancerPoolUpdateParamsCheckRegionOc, LoadBalancerPoolUpdateParamsCheckRegionMe, LoadBalancerPoolUpdateParamsCheckRegionNaf, LoadBalancerPoolUpdateParamsCheckRegionSaf, LoadBalancerPoolUpdateParamsCheckRegionSas, LoadBalancerPoolUpdateParamsCheckRegionSeas, LoadBalancerPoolUpdateParamsCheckRegionNeas, LoadBalancerPoolUpdateParamsCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolUpdateParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom, LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy = "hash" -) - -func (r LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolUpdateParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolUpdateParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolUpdateParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolUpdateParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolUpdateParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolUpdateParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "random" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyHash LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_connections" -) - -func (r LoadBalancerPoolUpdateParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom, LoadBalancerPoolUpdateParamsOriginSteeringPolicyHash, LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests, LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type LoadBalancerPoolUpdateResponseEnvelope struct { - Errors []LoadBalancerPoolUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingPool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolUpdateResponseEnvelope] -type loadBalancerPoolUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolUpdateResponseEnvelopeErrors] -type loadBalancerPoolUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolUpdateResponseEnvelopeMessages] -type loadBalancerPoolUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolUpdateResponseEnvelopeSuccessTrue LoadBalancerPoolUpdateResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolListParams 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 [LoadBalancerPoolListParams]'s query parameters as -// `url.Values`. -func (r LoadBalancerPoolListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type LoadBalancerPoolDeleteResponseEnvelope struct { - Errors []LoadBalancerPoolDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolDeleteResponseEnvelope] -type loadBalancerPoolDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolDeleteResponseEnvelopeErrors] -type loadBalancerPoolDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolDeleteResponseEnvelopeMessages] -type loadBalancerPoolDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolDeleteResponseEnvelopeSuccessTrue LoadBalancerPoolDeleteResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolDeleteResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolEditParams struct { - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]LoadBalancerPoolEditParamsCheckRegion] `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[LoadBalancerPoolEditParamsLoadShedding] `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[LoadBalancerPoolEditParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolEditParamsOriginSteering] `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]LoadBalancerPoolEditParamsOrigin] `json:"origins"` -} - -func (r LoadBalancerPoolEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolEditParamsCheckRegion string - -const ( - LoadBalancerPoolEditParamsCheckRegionWnam LoadBalancerPoolEditParamsCheckRegion = "WNAM" - LoadBalancerPoolEditParamsCheckRegionEnam LoadBalancerPoolEditParamsCheckRegion = "ENAM" - LoadBalancerPoolEditParamsCheckRegionWeu LoadBalancerPoolEditParamsCheckRegion = "WEU" - LoadBalancerPoolEditParamsCheckRegionEeu LoadBalancerPoolEditParamsCheckRegion = "EEU" - LoadBalancerPoolEditParamsCheckRegionNsam LoadBalancerPoolEditParamsCheckRegion = "NSAM" - LoadBalancerPoolEditParamsCheckRegionSsam LoadBalancerPoolEditParamsCheckRegion = "SSAM" - LoadBalancerPoolEditParamsCheckRegionOc LoadBalancerPoolEditParamsCheckRegion = "OC" - LoadBalancerPoolEditParamsCheckRegionMe LoadBalancerPoolEditParamsCheckRegion = "ME" - LoadBalancerPoolEditParamsCheckRegionNaf LoadBalancerPoolEditParamsCheckRegion = "NAF" - LoadBalancerPoolEditParamsCheckRegionSaf LoadBalancerPoolEditParamsCheckRegion = "SAF" - LoadBalancerPoolEditParamsCheckRegionSas LoadBalancerPoolEditParamsCheckRegion = "SAS" - LoadBalancerPoolEditParamsCheckRegionSeas LoadBalancerPoolEditParamsCheckRegion = "SEAS" - LoadBalancerPoolEditParamsCheckRegionNeas LoadBalancerPoolEditParamsCheckRegion = "NEAS" - LoadBalancerPoolEditParamsCheckRegionAllRegions LoadBalancerPoolEditParamsCheckRegion = "ALL_REGIONS" -) - -func (r LoadBalancerPoolEditParamsCheckRegion) IsKnown() bool { - switch r { - case LoadBalancerPoolEditParamsCheckRegionWnam, LoadBalancerPoolEditParamsCheckRegionEnam, LoadBalancerPoolEditParamsCheckRegionWeu, LoadBalancerPoolEditParamsCheckRegionEeu, LoadBalancerPoolEditParamsCheckRegionNsam, LoadBalancerPoolEditParamsCheckRegionSsam, LoadBalancerPoolEditParamsCheckRegionOc, LoadBalancerPoolEditParamsCheckRegionMe, LoadBalancerPoolEditParamsCheckRegionNaf, LoadBalancerPoolEditParamsCheckRegionSaf, LoadBalancerPoolEditParamsCheckRegionSas, LoadBalancerPoolEditParamsCheckRegionSeas, LoadBalancerPoolEditParamsCheckRegionNeas, LoadBalancerPoolEditParamsCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolEditParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom, LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolEditParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash LoadBalancerPoolEditParamsLoadSheddingSessionPolicy = "hash" -) - -func (r LoadBalancerPoolEditParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolEditParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolEditParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolEditParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolEditParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolEditParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolEditParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolEditParamsOriginSteeringPolicyRandom LoadBalancerPoolEditParamsOriginSteeringPolicy = "random" - LoadBalancerPoolEditParamsOriginSteeringPolicyHash LoadBalancerPoolEditParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolEditParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolEditParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_connections" -) - -func (r LoadBalancerPoolEditParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolEditParamsOriginSteeringPolicyRandom, LoadBalancerPoolEditParamsOriginSteeringPolicyHash, LoadBalancerPoolEditParamsOriginSteeringPolicyLeastOutstandingRequests, LoadBalancerPoolEditParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type LoadBalancerPoolEditParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolEditParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolEditParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancerPoolEditResponseEnvelope struct { - Errors []LoadBalancerPoolEditResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolEditResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingPool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolEditResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolEditResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolEditResponseEnvelope] -type loadBalancerPoolEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolEditResponseEnvelopeErrors] -type loadBalancerPoolEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerPoolEditResponseEnvelopeMessages] -type loadBalancerPoolEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolEditResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolEditResponseEnvelopeSuccessTrue LoadBalancerPoolEditResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolEditResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolEditResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolGetResponseEnvelope struct { - Errors []LoadBalancerPoolGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolGetResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancingPool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolGetResponseEnvelope] -type loadBalancerPoolGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerPoolGetResponseEnvelopeErrors] -type loadBalancerPoolGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerPoolGetResponseEnvelopeMessages] -type loadBalancerPoolGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolGetResponseEnvelopeSuccessTrue LoadBalancerPoolGetResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolGetResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolHealthResponseEnvelope struct { - Errors []LoadBalancerPoolHealthResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolHealthResponseEnvelopeMessages `json:"messages,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - Result LoadBalancerPoolHealthResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolHealthResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolHealthResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolHealthResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolHealthResponseEnvelope] -type loadBalancerPoolHealthResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolHealthResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolHealthResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolHealthResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolHealthResponseEnvelopeErrors] -type loadBalancerPoolHealthResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolHealthResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolHealthResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolHealthResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolHealthResponseEnvelopeMessages] -type loadBalancerPoolHealthResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolHealthResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolHealthResponseEnvelopeSuccessTrue LoadBalancerPoolHealthResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolHealthResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolHealthResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolPreviewParams 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[LoadBalancerPoolPreviewParamsType] `json:"type"` -} - -func (r LoadBalancerPoolPreviewParams) 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 LoadBalancerPoolPreviewParamsType string - -const ( - LoadBalancerPoolPreviewParamsTypeHTTP LoadBalancerPoolPreviewParamsType = "http" - LoadBalancerPoolPreviewParamsTypeHTTPS LoadBalancerPoolPreviewParamsType = "https" - LoadBalancerPoolPreviewParamsTypeTcp LoadBalancerPoolPreviewParamsType = "tcp" - LoadBalancerPoolPreviewParamsTypeUdpIcmp LoadBalancerPoolPreviewParamsType = "udp_icmp" - LoadBalancerPoolPreviewParamsTypeIcmpPing LoadBalancerPoolPreviewParamsType = "icmp_ping" - LoadBalancerPoolPreviewParamsTypeSmtp LoadBalancerPoolPreviewParamsType = "smtp" -) - -func (r LoadBalancerPoolPreviewParamsType) IsKnown() bool { - switch r { - case LoadBalancerPoolPreviewParamsTypeHTTP, LoadBalancerPoolPreviewParamsTypeHTTPS, LoadBalancerPoolPreviewParamsTypeTcp, LoadBalancerPoolPreviewParamsTypeUdpIcmp, LoadBalancerPoolPreviewParamsTypeIcmpPing, LoadBalancerPoolPreviewParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancerPoolPreviewResponseEnvelope struct { - Errors []LoadBalancerPoolPreviewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolPreviewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolPreviewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolPreviewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolPreviewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolPreviewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolPreviewResponseEnvelope] -type loadBalancerPoolPreviewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolPreviewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolPreviewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolPreviewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolPreviewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolPreviewResponseEnvelopeErrors] -type loadBalancerPoolPreviewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolPreviewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolPreviewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolPreviewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolPreviewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolPreviewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolPreviewResponseEnvelopeMessages] -type loadBalancerPoolPreviewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolPreviewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolPreviewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolPreviewResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolPreviewResponseEnvelopeSuccessTrue LoadBalancerPoolPreviewResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolPreviewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolPreviewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolReferencesResponseEnvelope struct { - Errors []LoadBalancerPoolReferencesResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolReferencesResponseEnvelopeMessages `json:"messages,required"` - // List of resources that reference a given pool. - Result []LoadBalancerPoolReferencesResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerPoolReferencesResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerPoolReferencesResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerPoolReferencesResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolReferencesResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancerPoolReferencesResponseEnvelope] -type loadBalancerPoolReferencesResponseEnvelopeJSON 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 *LoadBalancerPoolReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferencesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolReferencesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolReferencesResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolReferencesResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerPoolReferencesResponseEnvelopeErrors] -type loadBalancerPoolReferencesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferencesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferencesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolReferencesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolReferencesResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolReferencesResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LoadBalancerPoolReferencesResponseEnvelopeMessages] -type loadBalancerPoolReferencesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferencesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferencesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolReferencesResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolReferencesResponseEnvelopeSuccessTrue LoadBalancerPoolReferencesResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPoolReferencesResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPoolReferencesResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancerPoolReferencesResponseEnvelopeResultInfo 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 loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [LoadBalancerPoolReferencesResponseEnvelopeResultInfo] -type loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/user/loadbalancerpool_test.go b/user/loadbalancerpool_test.go deleted file mode 100644 index 433305cb594..00000000000 --- a/user/loadbalancerpool_test.go +++ /dev/null @@ -1,440 +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 TestLoadBalancerPoolNewWithOptionalParams(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.LoadBalancers.Pools.New(context.TODO(), user.LoadBalancerPoolNewParams{ - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]user.LoadBalancerPoolNewParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"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(user.LoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"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(user.LoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"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([]user.LoadBalancerPoolNewParamsCheckRegion{user.LoadBalancerPoolNewParamsCheckRegionWeu, user.LoadBalancerPoolNewParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(user.LoadBalancerPoolNewParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(user.LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(user.LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilter{ - Origin: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(user.LoadBalancerPoolNewParamsOriginSteering{ - Policy: cloudflare.F(user.LoadBalancerPoolNewParamsOriginSteeringPolicyRandom), - }), - }) - 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 TestLoadBalancerPoolUpdateWithOptionalParams(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.LoadBalancers.Pools.Update( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - user.LoadBalancerPoolUpdateParams{ - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]user.LoadBalancerPoolUpdateParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"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(user.LoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"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(user.LoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"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([]user.LoadBalancerPoolUpdateParamsCheckRegion{user.LoadBalancerPoolUpdateParamsCheckRegionWeu, user.LoadBalancerPoolUpdateParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilter{ - Origin: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginSteering{ - Policy: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom), - }), - }, - ) - 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 TestLoadBalancerPoolListWithOptionalParams(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.LoadBalancers.Pools.List(context.TODO(), user.LoadBalancerPoolListParams{ - 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 TestLoadBalancerPoolDelete(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.LoadBalancers.Pools.Delete(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 TestLoadBalancerPoolEditWithOptionalParams(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.LoadBalancers.Pools.Edit( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - user.LoadBalancerPoolEditParams{ - CheckRegions: cloudflare.F([]user.LoadBalancerPoolEditParamsCheckRegion{user.LoadBalancerPoolEditParamsCheckRegionWeu, user.LoadBalancerPoolEditParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(user.LoadBalancerPoolEditParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(user.LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(user.LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - Name: cloudflare.F("primary-dc-1"), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilter{ - Origin: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(user.LoadBalancerPoolEditParamsOriginSteering{ - Policy: cloudflare.F(user.LoadBalancerPoolEditParamsOriginSteeringPolicyRandom), - }), - Origins: cloudflare.F([]user.LoadBalancerPoolEditParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"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(user.LoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"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(user.LoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"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 TestLoadBalancerPoolGet(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.LoadBalancers.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 TestLoadBalancerPoolHealth(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.LoadBalancers.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 TestLoadBalancerPoolPreviewWithOptionalParams(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.LoadBalancers.Pools.Preview( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - user.LoadBalancerPoolPreviewParams{ - 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.LoadBalancerPoolPreviewParamsTypeHTTPS), - }, - ) - 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 TestLoadBalancerPoolReferences(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.LoadBalancers.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/loadbalancerpreview.go b/user/loadbalancerpreview.go deleted file mode 100644 index c52972e684b..00000000000 --- a/user/loadbalancerpreview.go +++ /dev/null @@ -1,187 +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/option" -) - -// LoadBalancerPreviewService 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 [NewLoadBalancerPreviewService] -// method instead. -type LoadBalancerPreviewService struct { - Options []option.RequestOption -} - -// NewLoadBalancerPreviewService 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 NewLoadBalancerPreviewService(opts ...option.RequestOption) (r *LoadBalancerPreviewService) { - r = &LoadBalancerPreviewService{} - r.Options = opts - return -} - -// Get the result of a previous preview operation using the provided preview_id. -func (r *LoadBalancerPreviewService) Get(ctx context.Context, previewID string, opts ...option.RequestOption) (res *LoadBalancingPreview, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPreviewGetResponseEnvelope - 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 LoadBalancingPreview map[string]LoadBalancingPreviewItem - -type LoadBalancingPreviewItem struct { - Healthy bool `json:"healthy"` - Origins []map[string]LoadBalancingPreviewOrigin `json:"origins"` - JSON loadBalancingPreviewItemJSON `json:"-"` -} - -// loadBalancingPreviewItemJSON contains the JSON metadata for the struct -// [LoadBalancingPreviewItem] -type loadBalancingPreviewItemJSON struct { - Healthy apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPreviewItem) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPreviewItemJSON) RawJSON() string { - return r.raw -} - -// The origin ipv4/ipv6 address or domain name mapped to it's health data. -type LoadBalancingPreviewOrigin struct { - FailureReason string `json:"failure_reason"` - Healthy bool `json:"healthy"` - ResponseCode float64 `json:"response_code"` - RTT string `json:"rtt"` - JSON loadBalancingPreviewOriginJSON `json:"-"` -} - -// loadBalancingPreviewOriginJSON contains the JSON metadata for the struct -// [LoadBalancingPreviewOrigin] -type loadBalancingPreviewOriginJSON struct { - FailureReason apijson.Field - Healthy apijson.Field - ResponseCode apijson.Field - RTT apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPreviewOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPreviewOriginJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPreviewGetResponseEnvelope struct { - Errors []LoadBalancerPreviewGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPreviewGetResponseEnvelopeMessages `json:"messages,required"` - // Resulting health data from a preview operation. - Result LoadBalancingPreview `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPreviewGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPreviewGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPreviewGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPreviewGetResponseEnvelope] -type loadBalancerPreviewGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPreviewGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPreviewGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPreviewGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPreviewGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPreviewGetResponseEnvelopeErrors] -type loadBalancerPreviewGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPreviewGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPreviewGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPreviewGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPreviewGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPreviewGetResponseEnvelopeMessages] -type loadBalancerPreviewGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPreviewGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPreviewGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerPreviewGetResponseEnvelopeSuccessTrue LoadBalancerPreviewGetResponseEnvelopeSuccess = true -) - -func (r LoadBalancerPreviewGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancerPreviewGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/user/loadbalancerpreview_test.go b/user/loadbalancerpreview_test.go deleted file mode 100644 index a871b87fb15..00000000000 --- a/user/loadbalancerpreview_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 TestLoadBalancerPreviewGet(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.LoadBalancers.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 71c675df93f..56bcfa54846 100644 --- a/user/organization.go +++ b/user/organization.go @@ -61,7 +61,7 @@ func (r *OrganizationService) ListAutoPaging(ctx context.Context, query Organiza } // Removes association to an organization. -func (r *OrganizationService) Delete(ctx context.Context, organizationID string, opts ...option.RequestOption) (res *OrganizationDeleteResponse, err error) { +func (r *OrganizationService) Delete(ctx context.Context, organizationID string, body OrganizationDeleteParams, opts ...option.RequestOption) (res *OrganizationDeleteResponse, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("user/organizations/%s", organizationID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) @@ -69,7 +69,7 @@ func (r *OrganizationService) Delete(ctx context.Context, organizationID string, } // Gets a specific organization the user is associated with. -func (r *OrganizationService) Get(ctx context.Context, organizationID string, opts ...option.RequestOption) (res *OrganizationGetResponse, err error) { +func (r *OrganizationService) Get(ctx context.Context, organizationID string, opts ...option.RequestOption) (res *OrganizationGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env OrganizationGetResponseEnvelope path := fmt.Sprintf("user/organizations/%s", organizationID) @@ -87,7 +87,7 @@ type Organization struct { // Organization name. Name string `json:"name"` // Access permissions for this User. - Permissions []string `json:"permissions"` + Permissions []shared.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. @@ -154,13 +154,13 @@ func (r organizationDeleteResponseJSON) RawJSON() string { // Union satisfied by [user.OrganizationGetResponseUnknown] or // [shared.UnionString]. -type OrganizationGetResponse interface { - ImplementsUserOrganizationGetResponse() +type OrganizationGetResponseUnion interface { + ImplementsUserOrganizationGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*OrganizationGetResponse)(nil)).Elem(), + reflect.TypeOf((*OrganizationGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -189,7 +189,7 @@ type OrganizationListParams struct { // URLQuery serializes [OrganizationListParams]'s query parameters as `url.Values`. func (r OrganizationListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -259,10 +259,18 @@ func (r OrganizationListParamsStatus) IsKnown() bool { return false } +type OrganizationDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r OrganizationDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type OrganizationGetResponseEnvelope struct { - Errors []OrganizationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OrganizationGetResponseEnvelopeMessages `json:"messages,required"` - Result OrganizationGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result OrganizationGetResponseUnion `json:"result,required"` // Whether the API call was successful Success OrganizationGetResponseEnvelopeSuccess `json:"success,required"` JSON organizationGetResponseEnvelopeJSON `json:"-"` @@ -287,52 +295,6 @@ func (r organizationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OrganizationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// organizationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OrganizationGetResponseEnvelopeErrors] -type organizationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OrganizationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// organizationGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OrganizationGetResponseEnvelopeMessages] -type organizationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OrganizationGetResponseEnvelopeSuccess bool diff --git a/user/organization_test.go b/user/organization_test.go index a4792578a7c..bb3adc45ea2 100644 --- a/user/organization_test.go +++ b/user/organization_test.go @@ -60,7 +60,13 @@ func TestOrganizationDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.User.Organizations.Delete(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + _, err := client.User.Organizations.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + user.OrganizationDeleteParams{ + Body: map[string]interface{}{}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/user/subscription.go b/user/subscription.go index 538f6d7e2d7..7e37ade6c79 100644 --- a/user/subscription.go +++ b/user/subscription.go @@ -36,7 +36,7 @@ func NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionServic } // Updates a user's subscriptions. -func (r *SubscriptionService) Update(ctx context.Context, identifier string, body SubscriptionUpdateParams, opts ...option.RequestOption) (res *SubscriptionUpdateResponse, err error) { +func (r *SubscriptionService) Update(ctx context.Context, identifier string, body SubscriptionUpdateParams, opts ...option.RequestOption) (res *SubscriptionUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SubscriptionUpdateResponseEnvelope path := fmt.Sprintf("user/subscriptions/%s", identifier) @@ -49,7 +49,7 @@ func (r *SubscriptionService) Update(ctx context.Context, identifier string, bod } // Deletes a user's subscription. -func (r *SubscriptionService) Delete(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionDeleteResponse, err error) { +func (r *SubscriptionService) Delete(ctx context.Context, identifier string, body SubscriptionDeleteParams, opts ...option.RequestOption) (res *SubscriptionDeleteResponse, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("user/subscriptions/%s", identifier) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) @@ -57,7 +57,7 @@ func (r *SubscriptionService) Delete(ctx context.Context, identifier string, opt } // Updates zone subscriptions, either plan or add-ons. -func (r *SubscriptionService) Edit(ctx context.Context, identifier string, body SubscriptionEditParams, opts ...option.RequestOption) (res *SubscriptionEditResponse, err error) { +func (r *SubscriptionService) Edit(ctx context.Context, identifier string, body SubscriptionEditParams, opts ...option.RequestOption) (res *SubscriptionEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SubscriptionEditResponseEnvelope path := fmt.Sprintf("zones/%s/subscription", identifier) @@ -70,7 +70,7 @@ func (r *SubscriptionService) Edit(ctx context.Context, identifier string, body } // Lists all of a user's subscriptions. -func (r *SubscriptionService) Get(ctx context.Context, opts ...option.RequestOption) (res *[]SubscriptionGetResponse, err error) { +func (r *SubscriptionService) Get(ctx context.Context, opts ...option.RequestOption) (res *[]Subscription, err error) { opts = append(r.Options[:], opts...) var env SubscriptionGetResponseEnvelope path := "user/subscriptions" @@ -82,68 +82,74 @@ func (r *SubscriptionService) Get(ctx context.Context, opts ...option.RequestOpt return } -// Union satisfied by [user.SubscriptionUpdateResponseUnknown] or -// [shared.UnionString]. -type SubscriptionUpdateResponse interface { - ImplementsUserSubscriptionUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SubscriptionDeleteResponse struct { - // Subscription identifier tag. - SubscriptionID string `json:"subscription_id"` - JSON subscriptionDeleteResponseJSON `json:"-"` +// The rate plan applied to the subscription. +type RatePlan struct { + // The ID of the rate plan. + ID string `json:"id"` + // The currency applied to the rate plan subscription. + Currency string `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged bool `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract bool `json:"is_contract"` + // The full name of the rate plan. + PublicName string `json:"public_name"` + // The scope that this rate plan applies to. + Scope string `json:"scope"` + // The list of sets this rate plan applies to. + Sets []string `json:"sets"` + JSON ratePlanJSON `json:"-"` } -// subscriptionDeleteResponseJSON contains the JSON metadata for the struct -// [SubscriptionDeleteResponse] -type subscriptionDeleteResponseJSON struct { - SubscriptionID apijson.Field - raw string - ExtraFields map[string]apijson.Field +// ratePlanJSON contains the JSON metadata for the struct [RatePlan] +type ratePlanJSON struct { + ID apijson.Field + Currency apijson.Field + ExternallyManaged apijson.Field + IsContract apijson.Field + PublicName apijson.Field + Scope apijson.Field + Sets apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SubscriptionDeleteResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RatePlan) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r subscriptionDeleteResponseJSON) RawJSON() string { +func (r ratePlanJSON) RawJSON() string { return r.raw } -// Union satisfied by [user.SubscriptionEditResponseUnknown] or -// [shared.UnionString]. -type SubscriptionEditResponse interface { - ImplementsUserSubscriptionEditResponse() +// The rate plan applied to the subscription. +type RatePlanParam struct { + // The ID of the rate plan. + ID param.Field[string] `json:"id"` + // The currency applied to the rate plan subscription. + Currency param.Field[string] `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged param.Field[bool] `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract param.Field[bool] `json:"is_contract"` + // The full name of the rate plan. + PublicName param.Field[string] `json:"public_name"` + // The scope that this rate plan applies to. + Scope param.Field[string] `json:"scope"` + // The list of sets this rate plan applies to. + Sets param.Field[[]string] `json:"sets"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) +func (r RatePlanParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type SubscriptionGetResponse struct { +type Subscription struct { // Subscription identifier tag. - ID string `json:"id"` - App SubscriptionGetResponseApp `json:"app"` + ID string `json:"id"` + App SubscriptionApp `json:"app"` // The list of add-ons subscribed to. - ComponentValues []SubscriptionGetResponseComponentValue `json:"component_values"` + ComponentValues []SubscriptionComponent `json:"component_values"` // The monetary unit in which pricing information is displayed. Currency string `json:"currency"` // The end of the current period and also when the next billing is due. @@ -152,21 +158,20 @@ type SubscriptionGetResponse struct { // is the first period. CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` // How often the subscription is renewed automatically. - Frequency SubscriptionGetResponseFrequency `json:"frequency"` + Frequency SubscriptionFrequency `json:"frequency"` // The price of the subscription that will be billed, in US dollars. Price float64 `json:"price"` // The rate plan applied to the subscription. - RatePlan SubscriptionGetResponseRatePlan `json:"rate_plan"` + RatePlan RatePlan `json:"rate_plan"` // The state that the subscription is in. - State SubscriptionGetResponseState `json:"state"` + State SubscriptionState `json:"state"` // A simple zone object. May have null properties if not a zone subscription. - Zone SubscriptionGetResponseZone `json:"zone"` - JSON subscriptionGetResponseJSON `json:"-"` + Zone SubscriptionZone `json:"zone"` + JSON subscriptionJSON `json:"-"` } -// subscriptionGetResponseJSON contains the JSON metadata for the struct -// [SubscriptionGetResponse] -type subscriptionGetResponseJSON struct { +// subscriptionJSON contains the JSON metadata for the struct [Subscription] +type subscriptionJSON struct { ID apijson.Field App apijson.Field ComponentValues apijson.Field @@ -182,445 +187,308 @@ type subscriptionGetResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *SubscriptionGetResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Subscription) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r subscriptionGetResponseJSON) RawJSON() string { +func (r subscriptionJSON) RawJSON() string { return r.raw } -type SubscriptionGetResponseApp struct { +type SubscriptionApp struct { // app install id. - InstallID string `json:"install_id"` - JSON subscriptionGetResponseAppJSON `json:"-"` + InstallID string `json:"install_id"` + JSON subscriptionAppJSON `json:"-"` } -// subscriptionGetResponseAppJSON contains the JSON metadata for the struct -// [SubscriptionGetResponseApp] -type subscriptionGetResponseAppJSON struct { +// subscriptionAppJSON contains the JSON metadata for the struct [SubscriptionApp] +type subscriptionAppJSON struct { InstallID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SubscriptionGetResponseApp) UnmarshalJSON(data []byte) (err error) { +func (r *SubscriptionApp) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r subscriptionGetResponseAppJSON) RawJSON() string { - return r.raw -} - -// A component value for a subscription. -type SubscriptionGetResponseComponentValue struct { - // The default amount assigned. - Default float64 `json:"default"` - // The name of the component value. - Name string `json:"name"` - // The unit price for the component value. - Price float64 `json:"price"` - // The amount of the component value assigned. - Value float64 `json:"value"` - JSON subscriptionGetResponseComponentValueJSON `json:"-"` -} - -// subscriptionGetResponseComponentValueJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseComponentValue] -type subscriptionGetResponseComponentValueJSON struct { - Default apijson.Field - Name apijson.Field - Price apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseComponentValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseComponentValueJSON) RawJSON() string { +func (r subscriptionAppJSON) RawJSON() string { return r.raw } // How often the subscription is renewed automatically. -type SubscriptionGetResponseFrequency string +type SubscriptionFrequency string const ( - SubscriptionGetResponseFrequencyWeekly SubscriptionGetResponseFrequency = "weekly" - SubscriptionGetResponseFrequencyMonthly SubscriptionGetResponseFrequency = "monthly" - SubscriptionGetResponseFrequencyQuarterly SubscriptionGetResponseFrequency = "quarterly" - SubscriptionGetResponseFrequencyYearly SubscriptionGetResponseFrequency = "yearly" + SubscriptionFrequencyWeekly SubscriptionFrequency = "weekly" + SubscriptionFrequencyMonthly SubscriptionFrequency = "monthly" + SubscriptionFrequencyQuarterly SubscriptionFrequency = "quarterly" + SubscriptionFrequencyYearly SubscriptionFrequency = "yearly" ) -func (r SubscriptionGetResponseFrequency) IsKnown() bool { +func (r SubscriptionFrequency) IsKnown() bool { switch r { - case SubscriptionGetResponseFrequencyWeekly, SubscriptionGetResponseFrequencyMonthly, SubscriptionGetResponseFrequencyQuarterly, SubscriptionGetResponseFrequencyYearly: + case SubscriptionFrequencyWeekly, SubscriptionFrequencyMonthly, SubscriptionFrequencyQuarterly, SubscriptionFrequencyYearly: return true } return false } -// The rate plan applied to the subscription. -type SubscriptionGetResponseRatePlan struct { - // The ID of the rate plan. - ID string `json:"id"` - // The currency applied to the rate plan subscription. - Currency string `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged bool `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract bool `json:"is_contract"` - // The full name of the rate plan. - PublicName string `json:"public_name"` - // The scope that this rate plan applies to. - Scope string `json:"scope"` - // The list of sets this rate plan applies to. - Sets []string `json:"sets"` - JSON subscriptionGetResponseRatePlanJSON `json:"-"` -} - -// subscriptionGetResponseRatePlanJSON contains the JSON metadata for the struct -// [SubscriptionGetResponseRatePlan] -type subscriptionGetResponseRatePlanJSON struct { - ID apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - IsContract apijson.Field - PublicName apijson.Field - Scope apijson.Field - Sets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseRatePlan) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseRatePlanJSON) RawJSON() string { - return r.raw -} - // The state that the subscription is in. -type SubscriptionGetResponseState string +type SubscriptionState string const ( - SubscriptionGetResponseStateTrial SubscriptionGetResponseState = "Trial" - SubscriptionGetResponseStateProvisioned SubscriptionGetResponseState = "Provisioned" - SubscriptionGetResponseStatePaid SubscriptionGetResponseState = "Paid" - SubscriptionGetResponseStateAwaitingPayment SubscriptionGetResponseState = "AwaitingPayment" - SubscriptionGetResponseStateCancelled SubscriptionGetResponseState = "Cancelled" - SubscriptionGetResponseStateFailed SubscriptionGetResponseState = "Failed" - SubscriptionGetResponseStateExpired SubscriptionGetResponseState = "Expired" + SubscriptionStateTrial SubscriptionState = "Trial" + SubscriptionStateProvisioned SubscriptionState = "Provisioned" + SubscriptionStatePaid SubscriptionState = "Paid" + SubscriptionStateAwaitingPayment SubscriptionState = "AwaitingPayment" + SubscriptionStateCancelled SubscriptionState = "Cancelled" + SubscriptionStateFailed SubscriptionState = "Failed" + SubscriptionStateExpired SubscriptionState = "Expired" ) -func (r SubscriptionGetResponseState) IsKnown() bool { +func (r SubscriptionState) IsKnown() bool { switch r { - case SubscriptionGetResponseStateTrial, SubscriptionGetResponseStateProvisioned, SubscriptionGetResponseStatePaid, SubscriptionGetResponseStateAwaitingPayment, SubscriptionGetResponseStateCancelled, SubscriptionGetResponseStateFailed, SubscriptionGetResponseStateExpired: + case SubscriptionStateTrial, SubscriptionStateProvisioned, SubscriptionStatePaid, SubscriptionStateAwaitingPayment, SubscriptionStateCancelled, SubscriptionStateFailed, SubscriptionStateExpired: return true } return false } -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionGetResponseZone struct { - // Identifier - ID string `json:"id"` - // The domain name - Name string `json:"name"` - JSON subscriptionGetResponseZoneJSON `json:"-"` -} - -// subscriptionGetResponseZoneJSON contains the JSON metadata for the struct -// [SubscriptionGetResponseZone] -type subscriptionGetResponseZoneJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseZone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseZoneJSON) RawJSON() string { - return r.raw -} - -type SubscriptionUpdateParams struct { - App param.Field[SubscriptionUpdateParamsApp] `json:"app"` +type SubscriptionParam struct { + App param.Field[SubscriptionAppParam] `json:"app"` // The list of add-ons subscribed to. - ComponentValues param.Field[[]SubscriptionUpdateParamsComponentValue] `json:"component_values"` + ComponentValues param.Field[[]SubscriptionComponentParam] `json:"component_values"` // How often the subscription is renewed automatically. - Frequency param.Field[SubscriptionUpdateParamsFrequency] `json:"frequency"` + Frequency param.Field[SubscriptionFrequency] `json:"frequency"` // The rate plan applied to the subscription. - RatePlan param.Field[SubscriptionUpdateParamsRatePlan] `json:"rate_plan"` + RatePlan param.Field[RatePlanParam] `json:"rate_plan"` // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[SubscriptionUpdateParamsZone] `json:"zone"` + Zone param.Field[SubscriptionZoneParam] `json:"zone"` } -func (r SubscriptionUpdateParams) MarshalJSON() (data []byte, err error) { +func (r SubscriptionParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SubscriptionUpdateParamsApp struct { +type SubscriptionAppParam struct { // app install id. InstallID param.Field[string] `json:"install_id"` } -func (r SubscriptionUpdateParamsApp) MarshalJSON() (data []byte, err error) { +func (r SubscriptionAppParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // A component value for a subscription. -type SubscriptionUpdateParamsComponentValue struct { +type SubscriptionComponent struct { // The default amount assigned. - Default param.Field[float64] `json:"default"` + Default float64 `json:"default"` // The name of the component value. - Name param.Field[string] `json:"name"` + Name string `json:"name"` // The unit price for the component value. - Price param.Field[float64] `json:"price"` + Price float64 `json:"price"` // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` + Value float64 `json:"value"` + JSON subscriptionComponentJSON `json:"-"` } -func (r SubscriptionUpdateParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type SubscriptionUpdateParamsFrequency string - -const ( - SubscriptionUpdateParamsFrequencyWeekly SubscriptionUpdateParamsFrequency = "weekly" - SubscriptionUpdateParamsFrequencyMonthly SubscriptionUpdateParamsFrequency = "monthly" - SubscriptionUpdateParamsFrequencyQuarterly SubscriptionUpdateParamsFrequency = "quarterly" - SubscriptionUpdateParamsFrequencyYearly SubscriptionUpdateParamsFrequency = "yearly" -) - -func (r SubscriptionUpdateParamsFrequency) IsKnown() bool { - switch r { - case SubscriptionUpdateParamsFrequencyWeekly, SubscriptionUpdateParamsFrequencyMonthly, SubscriptionUpdateParamsFrequencyQuarterly, SubscriptionUpdateParamsFrequencyYearly: - return true - } - return false +// subscriptionComponentJSON contains the JSON metadata for the struct +// [SubscriptionComponent] +type subscriptionComponentJSON struct { + Default apijson.Field + Name apijson.Field + Price apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The rate plan applied to the subscription. -type SubscriptionUpdateParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[string] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` +func (r *SubscriptionComponent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r SubscriptionUpdateParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r subscriptionComponentJSON) RawJSON() string { + return r.raw } -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionUpdateParamsZone struct { +// A component value for a subscription. +type SubscriptionComponentParam struct { + // The default amount assigned. + Default param.Field[float64] `json:"default"` + // The name of the component value. + Name param.Field[string] `json:"name"` + // The unit price for the component value. + Price param.Field[float64] `json:"price"` + // The amount of the component value assigned. + Value param.Field[float64] `json:"value"` } -func (r SubscriptionUpdateParamsZone) MarshalJSON() (data []byte, err error) { +func (r SubscriptionComponentParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SubscriptionUpdateResponseEnvelope struct { - Errors []SubscriptionUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON subscriptionUpdateResponseEnvelopeJSON `json:"-"` +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionZone struct { + // Identifier + ID string `json:"id"` + // The domain name + Name string `json:"name"` + JSON subscriptionZoneJSON `json:"-"` } -// subscriptionUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [SubscriptionUpdateResponseEnvelope] -type subscriptionUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field +// subscriptionZoneJSON contains the JSON metadata for the struct +// [SubscriptionZone] +type subscriptionZoneJSON struct { + ID apijson.Field + Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *SubscriptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *SubscriptionZone) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r subscriptionUpdateResponseEnvelopeJSON) RawJSON() string { +func (r subscriptionZoneJSON) RawJSON() string { return r.raw } -type SubscriptionUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionUpdateResponseEnvelopeErrorsJSON `json:"-"` +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionZoneParam struct { } -// subscriptionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionUpdateResponseEnvelopeErrors] -type subscriptionUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r SubscriptionZoneParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *SubscriptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [user.SubscriptionUpdateResponseUnknown] or +// [shared.UnionString]. +type SubscriptionUpdateResponseUnion interface { + ImplementsUserSubscriptionUpdateResponseUnion() } -func (r subscriptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionUpdateResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -type SubscriptionUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionUpdateResponseEnvelopeMessagesJSON `json:"-"` +type SubscriptionDeleteResponse struct { + // Subscription identifier tag. + SubscriptionID string `json:"subscription_id"` + JSON subscriptionDeleteResponseJSON `json:"-"` } -// subscriptionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SubscriptionUpdateResponseEnvelopeMessages] -type subscriptionUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +// subscriptionDeleteResponseJSON contains the JSON metadata for the struct +// [SubscriptionDeleteResponse] +type subscriptionDeleteResponseJSON struct { + SubscriptionID apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *SubscriptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *SubscriptionDeleteResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r subscriptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { +func (r subscriptionDeleteResponseJSON) RawJSON() string { return r.raw } -// Whether the API call was successful -type SubscriptionUpdateResponseEnvelopeSuccess bool - -const ( - SubscriptionUpdateResponseEnvelopeSuccessTrue SubscriptionUpdateResponseEnvelopeSuccess = true -) +// Union satisfied by [user.SubscriptionEditResponseUnknown] or +// [shared.UnionString]. +type SubscriptionEditResponseUnion interface { + ImplementsUserSubscriptionEditResponseUnion() +} -func (r SubscriptionUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case SubscriptionUpdateResponseEnvelopeSuccessTrue: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionEditResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -type SubscriptionEditParams struct { - App param.Field[SubscriptionEditParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]SubscriptionEditParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[SubscriptionEditParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[SubscriptionEditParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[SubscriptionEditParamsZone] `json:"zone"` +type SubscriptionUpdateParams struct { + Subscription SubscriptionParam `json:"subscription,required"` } -func (r SubscriptionEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r SubscriptionUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Subscription) } -type SubscriptionEditParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` +type SubscriptionUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionUpdateResponseUnion `json:"result,required"` + // Whether the API call was successful + Success SubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionUpdateResponseEnvelopeJSON `json:"-"` } -func (r SubscriptionEditParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// subscriptionUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionUpdateResponseEnvelope] +type subscriptionUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// A component value for a subscription. -type SubscriptionEditParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` +func (r *SubscriptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r SubscriptionEditParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r subscriptionUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// How often the subscription is renewed automatically. -type SubscriptionEditParamsFrequency string +// Whether the API call was successful +type SubscriptionUpdateResponseEnvelopeSuccess bool const ( - SubscriptionEditParamsFrequencyWeekly SubscriptionEditParamsFrequency = "weekly" - SubscriptionEditParamsFrequencyMonthly SubscriptionEditParamsFrequency = "monthly" - SubscriptionEditParamsFrequencyQuarterly SubscriptionEditParamsFrequency = "quarterly" - SubscriptionEditParamsFrequencyYearly SubscriptionEditParamsFrequency = "yearly" + SubscriptionUpdateResponseEnvelopeSuccessTrue SubscriptionUpdateResponseEnvelopeSuccess = true ) -func (r SubscriptionEditParamsFrequency) IsKnown() bool { +func (r SubscriptionUpdateResponseEnvelopeSuccess) IsKnown() bool { switch r { - case SubscriptionEditParamsFrequencyWeekly, SubscriptionEditParamsFrequencyMonthly, SubscriptionEditParamsFrequencyQuarterly, SubscriptionEditParamsFrequencyYearly: + case SubscriptionUpdateResponseEnvelopeSuccessTrue: return true } return false } -// The rate plan applied to the subscription. -type SubscriptionEditParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[string] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` +type SubscriptionDeleteParams struct { + Body interface{} `json:"body,required"` } -func (r SubscriptionEditParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r SubscriptionDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionEditParamsZone struct { +type SubscriptionEditParams struct { + Subscription SubscriptionParam `json:"subscription,required"` } -func (r SubscriptionEditParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r SubscriptionEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Subscription) } type SubscriptionEditResponseEnvelope struct { - Errors []SubscriptionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionEditResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionEditResponseUnion `json:"result,required"` // Whether the API call was successful Success SubscriptionEditResponseEnvelopeSuccess `json:"success,required"` JSON subscriptionEditResponseEnvelopeJSON `json:"-"` @@ -645,52 +513,6 @@ func (r subscriptionEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionEditResponseEnvelopeErrors] -type subscriptionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionEditResponseEnvelopeMessages] -type subscriptionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionEditResponseEnvelopeSuccess bool @@ -707,9 +529,9 @@ func (r SubscriptionEditResponseEnvelopeSuccess) IsKnown() bool { } type SubscriptionGetResponseEnvelope struct { - Errors []SubscriptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionGetResponseEnvelopeMessages `json:"messages,required"` - Result []SubscriptionGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Subscription `json:"result,required,nullable"` // Whether the API call was successful Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo SubscriptionGetResponseEnvelopeResultInfo `json:"result_info"` @@ -736,52 +558,6 @@ func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeErrors] -type subscriptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeMessages] -type subscriptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionGetResponseEnvelopeSuccess bool diff --git a/user/subscription_test.go b/user/subscription_test.go index be6eeda233c..d4462742dd0 100644 --- a/user/subscription_test.go +++ b/user/subscription_test.go @@ -32,36 +32,38 @@ func TestSubscriptionUpdateWithOptionalParams(t *testing.T) { context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2", user.SubscriptionUpdateParams{ - App: cloudflare.F(user.SubscriptionUpdateParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]user.SubscriptionUpdateParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(user.SubscriptionUpdateParamsFrequencyMonthly), - RatePlan: cloudflare.F(user.SubscriptionUpdateParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(user.SubscriptionUpdateParamsZone{}), + Subscription: user.SubscriptionParam{ + App: cloudflare.F(user.SubscriptionAppParam{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]user.SubscriptionComponentParam{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(user.SubscriptionFrequencyMonthly), + RatePlan: cloudflare.F(user.RatePlanParam{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(user.SubscriptionZoneParam{}), + }, }, ) if err != nil { @@ -87,7 +89,13 @@ func TestSubscriptionDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.User.Subscriptions.Delete(context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2") + _, err := client.User.Subscriptions.Delete( + context.TODO(), + "506e3185e9c882d175a2d0cb0093d9f2", + user.SubscriptionDeleteParams{ + Body: map[string]interface{}{}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -115,36 +123,38 @@ func TestSubscriptionEditWithOptionalParams(t *testing.T) { context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2", user.SubscriptionEditParams{ - App: cloudflare.F(user.SubscriptionEditParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]user.SubscriptionEditParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(user.SubscriptionEditParamsFrequencyMonthly), - RatePlan: cloudflare.F(user.SubscriptionEditParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(user.SubscriptionEditParamsZone{}), + Subscription: user.SubscriptionParam{ + App: cloudflare.F(user.SubscriptionAppParam{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]user.SubscriptionComponentParam{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(user.SubscriptionFrequencyMonthly), + RatePlan: cloudflare.F(user.RatePlanParam{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(user.SubscriptionZoneParam{}), + }, }, ) if err != nil { diff --git a/user/token.go b/user/token.go index 25c99052ac2..0fcec0a4b5e 100644 --- a/user/token.go +++ b/user/token.go @@ -55,7 +55,7 @@ func (r *TokenService) New(ctx context.Context, body TokenNewParams, opts ...opt } // Update an existing token. -func (r *TokenService) Update(ctx context.Context, tokenID interface{}, body TokenUpdateParams, opts ...option.RequestOption) (res *TokenUpdateResponse, err error) { +func (r *TokenService) Update(ctx context.Context, tokenID interface{}, body TokenUpdateParams, opts ...option.RequestOption) (res *TokenUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TokenUpdateResponseEnvelope path := fmt.Sprintf("user/tokens/%v", tokenID) @@ -91,7 +91,7 @@ func (r *TokenService) ListAutoPaging(ctx context.Context, query TokenListParams } // Destroy a token. -func (r *TokenService) Delete(ctx context.Context, tokenID interface{}, opts ...option.RequestOption) (res *TokenDeleteResponse, err error) { +func (r *TokenService) Delete(ctx context.Context, tokenID interface{}, body TokenDeleteParams, opts ...option.RequestOption) (res *TokenDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env TokenDeleteResponseEnvelope path := fmt.Sprintf("user/tokens/%v", tokenID) @@ -104,7 +104,7 @@ func (r *TokenService) Delete(ctx context.Context, tokenID interface{}, opts ... } // Get information about a specific token. -func (r *TokenService) Get(ctx context.Context, tokenID interface{}, opts ...option.RequestOption) (res *TokenGetResponse, err error) { +func (r *TokenService) Get(ctx context.Context, tokenID interface{}, opts ...option.RequestOption) (res *TokenGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TokenGetResponseEnvelope path := fmt.Sprintf("user/tokens/%v", tokenID) @@ -129,9 +129,163 @@ func (r *TokenService) Verify(ctx context.Context, opts ...option.RequestOption) return } +type CIDRListParam = string + +type Policy struct { + // Policy identifier. + ID string `json:"id,required"` + // Allow or deny operations against the resources. + Effect PolicyEffect `json:"effect,required"` + // A set of permission groups that are specified to the policy. + PermissionGroups []PolicyPermissionGroup `json:"permission_groups,required"` + // A list of resource names that the policy applies to. + Resources interface{} `json:"resources,required"` + JSON policyJSON `json:"-"` +} + +// policyJSON contains the JSON metadata for the struct [Policy] +type policyJSON struct { + ID apijson.Field + Effect apijson.Field + PermissionGroups apijson.Field + Resources apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Policy) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r policyJSON) RawJSON() string { + return r.raw +} + +// Allow or deny operations against the resources. +type PolicyEffect string + +const ( + PolicyEffectAllow PolicyEffect = "allow" + PolicyEffectDeny PolicyEffect = "deny" +) + +func (r PolicyEffect) IsKnown() bool { + switch r { + case PolicyEffectAllow, PolicyEffectDeny: + return true + } + return false +} + +// A named group of permissions that map to a group of operations against +// resources. +type PolicyPermissionGroup struct { + // Identifier of the group. + ID string `json:"id,required"` + // Name of the group. + Name string `json:"name"` + JSON policyPermissionGroupJSON `json:"-"` +} + +// policyPermissionGroupJSON contains the JSON metadata for the struct +// [PolicyPermissionGroup] +type policyPermissionGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PolicyPermissionGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r policyPermissionGroupJSON) RawJSON() string { + return r.raw +} + +type PolicyParam struct { + // Allow or deny operations against the resources. + Effect param.Field[PolicyEffect] `json:"effect,required"` + // A set of permission groups that are specified to the policy. + PermissionGroups param.Field[[]PolicyPermissionGroupParam] `json:"permission_groups,required"` + // A list of resource names that the policy applies to. + Resources param.Field[interface{}] `json:"resources,required"` +} + +func (r PolicyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A named group of permissions that map to a group of operations against +// resources. +type PolicyPermissionGroupParam struct { +} + +func (r PolicyPermissionGroupParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TokenParam struct { + // Token name. + Name param.Field[string] `json:"name,required"` + // List of access policies assigned to the token. + Policies param.Field[[]PolicyParam] `json:"policies,required"` + // Status of the token. + Status param.Field[TokenStatus] `json:"status,required"` + Condition param.Field[TokenConditionParam] `json:"condition"` + // The expiration time on or after which the JWT MUST NOT be accepted for + // processing. + ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"` + // The time before which the token MUST NOT be accepted for processing. + NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"` +} + +func (r TokenParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Status of the token. +type TokenStatus string + +const ( + TokenStatusActive TokenStatus = "active" + TokenStatusDisabled TokenStatus = "disabled" + TokenStatusExpired TokenStatus = "expired" +) + +func (r TokenStatus) IsKnown() bool { + switch r { + case TokenStatusActive, TokenStatusDisabled, TokenStatusExpired: + return true + } + return false +} + +type TokenConditionParam struct { + // Client IP restrictions. + RequestIP param.Field[TokenConditionRequestIPParam] `json:"request_ip"` +} + +func (r TokenConditionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Client IP restrictions. +type TokenConditionRequestIPParam struct { + // List of IPv4/IPv6 CIDR addresses. + In param.Field[[]CIDRListParam] `json:"in"` + // List of IPv4/IPv6 CIDR addresses. + NotIn param.Field[[]CIDRListParam] `json:"not_in"` +} + +func (r TokenConditionRequestIPParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type TokenNewResponse struct { // The token value. - Value TokenValue `json:"value"` + Value Value `json:"value"` JSON tokenNewResponseJSON `json:"-"` } @@ -152,13 +306,13 @@ func (r tokenNewResponseJSON) RawJSON() string { } // Union satisfied by [user.TokenUpdateResponseUnknown] or [shared.UnionString]. -type TokenUpdateResponse interface { - ImplementsUserTokenUpdateResponse() +type TokenUpdateResponseUnion interface { + ImplementsUserTokenUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TokenUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*TokenUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -192,13 +346,13 @@ func (r tokenDeleteResponseJSON) RawJSON() string { } // Union satisfied by [user.TokenGetResponseUnknown] or [shared.UnionString]. -type TokenGetResponse interface { - ImplementsUserTokenGetResponse() +type TokenGetResponseUnion interface { + ImplementsUserTokenGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TokenGetResponse)(nil)).Elem(), + reflect.TypeOf((*TokenGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -260,7 +414,7 @@ type TokenNewParams struct { // Token name. Name param.Field[string] `json:"name,required"` // List of access policies assigned to the token. - Policies param.Field[[]TokenNewParamsPolicy] `json:"policies,required"` + Policies param.Field[[]PolicyParam] `json:"policies,required"` Condition param.Field[TokenNewParamsCondition] `json:"condition"` // The expiration time on or after which the JWT MUST NOT be accepted for // processing. @@ -273,44 +427,6 @@ func (r TokenNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type TokenNewParamsPolicy struct { - // Allow or deny operations against the resources. - Effect param.Field[TokenNewParamsPoliciesEffect] `json:"effect,required"` - // A set of permission groups that are specified to the policy. - PermissionGroups param.Field[[]TokenNewParamsPoliciesPermissionGroup] `json:"permission_groups,required"` - // A list of resource names that the policy applies to. - Resources param.Field[interface{}] `json:"resources,required"` -} - -func (r TokenNewParamsPolicy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Allow or deny operations against the resources. -type TokenNewParamsPoliciesEffect string - -const ( - TokenNewParamsPoliciesEffectAllow TokenNewParamsPoliciesEffect = "allow" - TokenNewParamsPoliciesEffectDeny TokenNewParamsPoliciesEffect = "deny" -) - -func (r TokenNewParamsPoliciesEffect) IsKnown() bool { - switch r { - case TokenNewParamsPoliciesEffectAllow, TokenNewParamsPoliciesEffectDeny: - return true - } - return false -} - -// A named group of permissions that map to a group of operations against -// resources. -type TokenNewParamsPoliciesPermissionGroup struct { -} - -func (r TokenNewParamsPoliciesPermissionGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type TokenNewParamsCondition struct { // Client IP restrictions. RequestIP param.Field[TokenNewParamsConditionRequestIP] `json:"request_ip"` @@ -323,9 +439,9 @@ func (r TokenNewParamsCondition) MarshalJSON() (data []byte, err error) { // Client IP restrictions. type TokenNewParamsConditionRequestIP struct { // List of IPv4/IPv6 CIDR addresses. - In param.Field[[]string] `json:"in"` + In param.Field[[]CIDRListParam] `json:"in"` // List of IPv4/IPv6 CIDR addresses. - NotIn param.Field[[]string] `json:"not_in"` + NotIn param.Field[[]CIDRListParam] `json:"not_in"` } func (r TokenNewParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { @@ -333,9 +449,9 @@ func (r TokenNewParamsConditionRequestIP) MarshalJSON() (data []byte, err error) } type TokenNewResponseEnvelope struct { - Errors []TokenNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TokenNewResponseEnvelopeMessages `json:"messages,required"` - Result TokenNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TokenNewResponse `json:"result,required"` // Whether the API call was successful Success TokenNewResponseEnvelopeSuccess `json:"success,required"` JSON tokenNewResponseEnvelopeJSON `json:"-"` @@ -360,52 +476,6 @@ func (r tokenNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TokenNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// tokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TokenNewResponseEnvelopeErrors] -type tokenNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TokenNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// tokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TokenNewResponseEnvelopeMessages] -type tokenNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TokenNewResponseEnvelopeSuccess bool @@ -422,104 +492,17 @@ func (r TokenNewResponseEnvelopeSuccess) IsKnown() bool { } type TokenUpdateParams struct { - // Token name. - Name param.Field[string] `json:"name,required"` - // List of access policies assigned to the token. - Policies param.Field[[]TokenUpdateParamsPolicy] `json:"policies,required"` - // Status of the token. - Status param.Field[TokenUpdateParamsStatus] `json:"status,required"` - Condition param.Field[TokenUpdateParamsCondition] `json:"condition"` - // The expiration time on or after which the JWT MUST NOT be accepted for - // processing. - ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"` - // The time before which the token MUST NOT be accepted for processing. - NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"` + Token TokenParam `json:"token,required"` } func (r TokenUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type TokenUpdateParamsPolicy struct { - // Allow or deny operations against the resources. - Effect param.Field[TokenUpdateParamsPoliciesEffect] `json:"effect,required"` - // A set of permission groups that are specified to the policy. - PermissionGroups param.Field[[]TokenUpdateParamsPoliciesPermissionGroup] `json:"permission_groups,required"` - // A list of resource names that the policy applies to. - Resources param.Field[interface{}] `json:"resources,required"` -} - -func (r TokenUpdateParamsPolicy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Allow or deny operations against the resources. -type TokenUpdateParamsPoliciesEffect string - -const ( - TokenUpdateParamsPoliciesEffectAllow TokenUpdateParamsPoliciesEffect = "allow" - TokenUpdateParamsPoliciesEffectDeny TokenUpdateParamsPoliciesEffect = "deny" -) - -func (r TokenUpdateParamsPoliciesEffect) IsKnown() bool { - switch r { - case TokenUpdateParamsPoliciesEffectAllow, TokenUpdateParamsPoliciesEffectDeny: - return true - } - return false -} - -// A named group of permissions that map to a group of operations against -// resources. -type TokenUpdateParamsPoliciesPermissionGroup struct { -} - -func (r TokenUpdateParamsPoliciesPermissionGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Status of the token. -type TokenUpdateParamsStatus string - -const ( - TokenUpdateParamsStatusActive TokenUpdateParamsStatus = "active" - TokenUpdateParamsStatusDisabled TokenUpdateParamsStatus = "disabled" - TokenUpdateParamsStatusExpired TokenUpdateParamsStatus = "expired" -) - -func (r TokenUpdateParamsStatus) IsKnown() bool { - switch r { - case TokenUpdateParamsStatusActive, TokenUpdateParamsStatusDisabled, TokenUpdateParamsStatusExpired: - return true - } - return false -} - -type TokenUpdateParamsCondition struct { - // Client IP restrictions. - RequestIP param.Field[TokenUpdateParamsConditionRequestIP] `json:"request_ip"` -} - -func (r TokenUpdateParamsCondition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Client IP restrictions. -type TokenUpdateParamsConditionRequestIP struct { - // List of IPv4/IPv6 CIDR addresses. - In param.Field[[]string] `json:"in"` - // List of IPv4/IPv6 CIDR addresses. - NotIn param.Field[[]string] `json:"not_in"` -} - -func (r TokenUpdateParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Token) } type TokenUpdateResponseEnvelope struct { - Errors []TokenUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []TokenUpdateResponseEnvelopeMessages `json:"messages,required"` - Result TokenUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TokenUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success TokenUpdateResponseEnvelopeSuccess `json:"success,required"` JSON tokenUpdateResponseEnvelopeJSON `json:"-"` @@ -544,52 +527,6 @@ func (r tokenUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TokenUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// tokenUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TokenUpdateResponseEnvelopeErrors] -type tokenUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TokenUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// tokenUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TokenUpdateResponseEnvelopeMessages] -type tokenUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TokenUpdateResponseEnvelopeSuccess bool @@ -617,7 +554,7 @@ type TokenListParams struct { // URLQuery serializes [TokenListParams]'s query parameters as `url.Values`. func (r TokenListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -638,10 +575,18 @@ func (r TokenListParamsDirection) IsKnown() bool { return false } +type TokenDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r TokenDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type TokenDeleteResponseEnvelope struct { - Errors []TokenDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []TokenDeleteResponseEnvelopeMessages `json:"messages,required"` - Result TokenDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TokenDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success TokenDeleteResponseEnvelopeSuccess `json:"success,required"` JSON tokenDeleteResponseEnvelopeJSON `json:"-"` @@ -666,52 +611,6 @@ func (r tokenDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TokenDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// tokenDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TokenDeleteResponseEnvelopeErrors] -type tokenDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TokenDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// tokenDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TokenDeleteResponseEnvelopeMessages] -type tokenDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TokenDeleteResponseEnvelopeSuccess bool @@ -728,9 +627,9 @@ func (r TokenDeleteResponseEnvelopeSuccess) IsKnown() bool { } type TokenGetResponseEnvelope struct { - Errors []TokenGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TokenGetResponseEnvelopeMessages `json:"messages,required"` - Result TokenGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TokenGetResponseUnion `json:"result,required"` // Whether the API call was successful Success TokenGetResponseEnvelopeSuccess `json:"success,required"` JSON tokenGetResponseEnvelopeJSON `json:"-"` @@ -755,52 +654,6 @@ func (r tokenGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TokenGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tokenGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TokenGetResponseEnvelopeErrors] -type tokenGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TokenGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tokenGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TokenGetResponseEnvelopeMessages] -type tokenGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TokenGetResponseEnvelopeSuccess bool @@ -817,9 +670,9 @@ func (r TokenGetResponseEnvelopeSuccess) IsKnown() bool { } type TokenVerifyResponseEnvelope struct { - Errors []TokenVerifyResponseEnvelopeErrors `json:"errors,required"` - Messages []TokenVerifyResponseEnvelopeMessages `json:"messages,required"` - Result TokenVerifyResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TokenVerifyResponse `json:"result,required"` // Whether the API call was successful Success TokenVerifyResponseEnvelopeSuccess `json:"success,required"` JSON tokenVerifyResponseEnvelopeJSON `json:"-"` @@ -844,52 +697,6 @@ func (r tokenVerifyResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TokenVerifyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenVerifyResponseEnvelopeErrorsJSON `json:"-"` -} - -// tokenVerifyResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TokenVerifyResponseEnvelopeErrors] -type tokenVerifyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenVerifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenVerifyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TokenVerifyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenVerifyResponseEnvelopeMessagesJSON `json:"-"` -} - -// tokenVerifyResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TokenVerifyResponseEnvelopeMessages] -type tokenVerifyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenVerifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenVerifyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TokenVerifyResponseEnvelopeSuccess bool diff --git a/user/token_test.go b/user/token_test.go index 054eb93928a..39570f78386 100644 --- a/user/token_test.go +++ b/user/token_test.go @@ -31,23 +31,23 @@ func TestTokenNewWithOptionalParams(t *testing.T) { ) _, err := client.User.Tokens.New(context.TODO(), user.TokenNewParams{ Name: cloudflare.F("readonly token"), - Policies: cloudflare.F([]user.TokenNewParamsPolicy{{ - Effect: cloudflare.F(user.TokenNewParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]user.TokenNewParamsPoliciesPermissionGroup{{}, {}}), + Policies: cloudflare.F([]user.PolicyParam{{ + Effect: cloudflare.F(user.PolicyEffectAllow), + PermissionGroups: cloudflare.F([]user.PolicyPermissionGroupParam{{}, {}}), Resources: cloudflare.F[any](map[string]interface{}{ "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", }), }, { - Effect: cloudflare.F(user.TokenNewParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]user.TokenNewParamsPoliciesPermissionGroup{{}, {}}), + Effect: cloudflare.F(user.PolicyEffectAllow), + PermissionGroups: cloudflare.F([]user.PolicyPermissionGroupParam{{}, {}}), Resources: cloudflare.F[any](map[string]interface{}{ "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", }), }, { - Effect: cloudflare.F(user.TokenNewParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]user.TokenNewParamsPoliciesPermissionGroup{{}, {}}), + Effect: cloudflare.F(user.PolicyEffectAllow), + PermissionGroups: cloudflare.F([]user.PolicyPermissionGroupParam{{}, {}}), Resources: cloudflare.F[any](map[string]interface{}{ "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", @@ -55,8 +55,8 @@ func TestTokenNewWithOptionalParams(t *testing.T) { }}), Condition: cloudflare.F(user.TokenNewParamsCondition{ RequestIP: cloudflare.F(user.TokenNewParamsConditionRequestIP{ - In: cloudflare.F([]string{"123.123.123.0/24", "2606:4700::/32"}), - NotIn: cloudflare.F([]string{"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()), @@ -89,38 +89,40 @@ func TestTokenUpdateWithOptionalParams(t *testing.T) { context.TODO(), map[string]interface{}{}, user.TokenUpdateParams{ - Name: cloudflare.F("readonly token"), - Policies: cloudflare.F([]user.TokenUpdateParamsPolicy{{ - Effect: cloudflare.F(user.TokenUpdateParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]user.TokenUpdateParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + Token: user.TokenParam{ + Condition: cloudflare.F(user.TokenConditionParam{ + RequestIP: cloudflare.F(user.TokenConditionRequestIPParam{ + 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"}), + }), }), - }, { - Effect: cloudflare.F(user.TokenUpdateParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]user.TokenUpdateParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }, { - Effect: cloudflare.F(user.TokenUpdateParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]user.TokenUpdateParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }}), - Status: cloudflare.F(user.TokenUpdateParamsStatusActive), - Condition: cloudflare.F(user.TokenUpdateParamsCondition{ - RequestIP: cloudflare.F(user.TokenUpdateParamsConditionRequestIP{ - In: cloudflare.F([]string{"123.123.123.0/24", "2606:4700::/32"}), - NotIn: cloudflare.F([]string{"123.123.123.100/24", "2606:4700:4700::/48"}), - }), - }), - ExpiresOn: cloudflare.F(time.Now()), - NotBefore: cloudflare.F(time.Now()), + ExpiresOn: cloudflare.F(time.Now()), + Name: cloudflare.F("readonly token"), + NotBefore: cloudflare.F(time.Now()), + Policies: cloudflare.F([]user.PolicyParam{{ + Effect: cloudflare.F(user.PolicyEffectAllow), + PermissionGroups: cloudflare.F([]user.PolicyPermissionGroupParam{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }, { + Effect: cloudflare.F(user.PolicyEffectAllow), + PermissionGroups: cloudflare.F([]user.PolicyPermissionGroupParam{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }, { + Effect: cloudflare.F(user.PolicyEffectAllow), + PermissionGroups: cloudflare.F([]user.PolicyPermissionGroupParam{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }}), + Status: cloudflare.F(user.TokenStatusActive), + }, }, ) if err != nil { @@ -174,7 +176,13 @@ func TestTokenDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.User.Tokens.Delete(context.TODO(), map[string]interface{}{}) + _, err := client.User.Tokens.Delete( + context.TODO(), + map[string]interface{}{}, + user.TokenDeleteParams{ + Body: map[string]interface{}{}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/user/tokenvalue.go b/user/tokenvalue.go index 740ec87746a..5b599a4c7e3 100644 --- a/user/tokenvalue.go +++ b/user/tokenvalue.go @@ -8,8 +8,8 @@ import ( "net/http" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "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" ) @@ -31,7 +31,7 @@ func NewTokenValueService(opts ...option.RequestOption) (r *TokenValueService) { } // Roll the token secret. -func (r *TokenValueService) Update(ctx context.Context, tokenID interface{}, body TokenValueUpdateParams, opts ...option.RequestOption) (res *TokenValue, err error) { +func (r *TokenValueService) Update(ctx context.Context, tokenID interface{}, body TokenValueUpdateParams, opts ...option.RequestOption) (res *Value, err error) { opts = append(r.Options[:], opts...) var env TokenValueUpdateResponseEnvelope path := fmt.Sprintf("user/tokens/%v/value", tokenID) @@ -43,10 +43,10 @@ func (r *TokenValueService) Update(ctx context.Context, tokenID interface{}, bod return } -type TokenValue = string +type Value = string type TokenValueUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` + Body interface{} `json:"body,required"` } func (r TokenValueUpdateParams) MarshalJSON() (data []byte, err error) { @@ -54,10 +54,10 @@ func (r TokenValueUpdateParams) MarshalJSON() (data []byte, err error) { } type TokenValueUpdateResponseEnvelope struct { - Errors []TokenValueUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []TokenValueUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // The token value. - Result TokenValue `json:"result,required"` + Result Value `json:"result,required"` // Whether the API call was successful Success TokenValueUpdateResponseEnvelopeSuccess `json:"success,required"` JSON tokenValueUpdateResponseEnvelopeJSON `json:"-"` @@ -82,52 +82,6 @@ func (r tokenValueUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TokenValueUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenValueUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// tokenValueUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TokenValueUpdateResponseEnvelopeErrors] -type tokenValueUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenValueUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenValueUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TokenValueUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tokenValueUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// tokenValueUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TokenValueUpdateResponseEnvelopeMessages] -type tokenValueUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TokenValueUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tokenValueUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TokenValueUpdateResponseEnvelopeSuccess bool diff --git a/user/tokenvalue_test.go b/user/tokenvalue_test.go index 12746b958c0..1aa17c69a0d 100644 --- a/user/tokenvalue_test.go +++ b/user/tokenvalue_test.go @@ -32,7 +32,7 @@ func TestTokenValueUpdate(t *testing.T) { context.TODO(), map[string]interface{}{}, user.TokenValueUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/user/user.go b/user/user.go index 737d45f3e7c..6fdc60fb555 100644 --- a/user/user.go +++ b/user/user.go @@ -23,9 +23,7 @@ type UserService struct { Options []option.RequestOption AuditLogs *AuditLogService Billing *BillingService - Firewall *FirewallService Invites *InviteService - LoadBalancers *LoadBalancerService Organizations *OrganizationService Subscriptions *SubscriptionService Tokens *TokenService @@ -39,9 +37,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.LoadBalancers = NewLoadBalancerService(opts...) r.Organizations = NewOrganizationService(opts...) r.Subscriptions = NewSubscriptionService(opts...) r.Tokens = NewTokenService(opts...) @@ -49,7 +45,7 @@ func NewUserService(opts ...option.RequestOption) (r *UserService) { } // Edit part of your user details. -func (r *UserService) Edit(ctx context.Context, body UserEditParams, opts ...option.RequestOption) (res *UserEditResponse, err error) { +func (r *UserService) Edit(ctx context.Context, body UserEditParams, opts ...option.RequestOption) (res *UserEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env UserEditResponseEnvelope path := "user" @@ -62,7 +58,7 @@ func (r *UserService) Edit(ctx context.Context, body UserEditParams, opts ...opt } // User Details -func (r *UserService) Get(ctx context.Context, opts ...option.RequestOption) (res *UserGetResponse, err error) { +func (r *UserService) Get(ctx context.Context, opts ...option.RequestOption) (res *UserGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env UserGetResponseEnvelope path := "user" @@ -75,13 +71,13 @@ func (r *UserService) Get(ctx context.Context, opts ...option.RequestOption) (re } // Union satisfied by [user.UserEditResponseUnknown] or [shared.UnionString]. -type UserEditResponse interface { - ImplementsUserUserEditResponse() +type UserEditResponseUnion interface { + ImplementsUserUserEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*UserEditResponse)(nil)).Elem(), + reflect.TypeOf((*UserEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -91,13 +87,13 @@ func init() { } // Union satisfied by [user.UserGetResponseUnknown] or [shared.UnionString]. -type UserGetResponse interface { - ImplementsUserUserGetResponse() +type UserGetResponseUnion interface { + ImplementsUserUserGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*UserGetResponse)(nil)).Elem(), + reflect.TypeOf((*UserGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -124,9 +120,9 @@ func (r UserEditParams) MarshalJSON() (data []byte, err error) { } type UserEditResponseEnvelope struct { - Errors []UserEditResponseEnvelopeErrors `json:"errors,required"` - Messages []UserEditResponseEnvelopeMessages `json:"messages,required"` - Result UserEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UserEditResponseUnion `json:"result,required"` // Whether the API call was successful Success UserEditResponseEnvelopeSuccess `json:"success,required"` JSON userEditResponseEnvelopeJSON `json:"-"` @@ -151,52 +147,6 @@ func (r userEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UserEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// userEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UserEditResponseEnvelopeErrors] -type userEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// userEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [UserEditResponseEnvelopeMessages] -type userEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UserEditResponseEnvelopeSuccess bool @@ -213,9 +163,9 @@ func (r UserEditResponseEnvelopeSuccess) IsKnown() bool { } type UserGetResponseEnvelope struct { - Errors []UserGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserGetResponseEnvelopeMessages `json:"messages,required"` - Result UserGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UserGetResponseUnion `json:"result,required"` // Whether the API call was successful Success UserGetResponseEnvelopeSuccess `json:"success,required"` JSON userGetResponseEnvelopeJSON `json:"-"` @@ -240,52 +190,6 @@ func (r userGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type UserGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UserGetResponseEnvelopeErrors] -type userGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [UserGetResponseEnvelopeMessages] -type userGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type UserGetResponseEnvelopeSuccess bool diff --git a/vectorize/aliases.go b/vectorize/aliases.go index 754b6677957..308d00382d4 100644 --- a/vectorize/aliases.go +++ b/vectorize/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/vectorize/index.go b/vectorize/index.go index cfc3119ea65..45990d230e5 100644 --- a/vectorize/index.go +++ b/vectorize/index.go @@ -35,7 +35,7 @@ func NewIndexService(opts ...option.RequestOption) (r *IndexService) { } // Creates and returns a new Vectorize Index. -func (r *IndexService) New(ctx context.Context, accountIdentifier string, body IndexNewParams, opts ...option.RequestOption) (res *VectorizeCreateIndex, err error) { +func (r *IndexService) New(ctx context.Context, accountIdentifier string, body IndexNewParams, opts ...option.RequestOption) (res *CreateIndex, err error) { opts = append(r.Options[:], opts...) var env IndexNewResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes", accountIdentifier) @@ -48,7 +48,7 @@ func (r *IndexService) New(ctx context.Context, accountIdentifier string, body I } // Updates and returns the specified Vectorize Index. -func (r *IndexService) Update(ctx context.Context, accountIdentifier string, indexName string, body IndexUpdateParams, opts ...option.RequestOption) (res *VectorizeCreateIndex, err error) { +func (r *IndexService) Update(ctx context.Context, accountIdentifier string, indexName string, body IndexUpdateParams, opts ...option.RequestOption) (res *CreateIndex, err error) { opts = append(r.Options[:], opts...) var env IndexUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) @@ -61,7 +61,7 @@ func (r *IndexService) Update(ctx context.Context, accountIdentifier string, ind } // Returns a list of Vectorize Indexes -func (r *IndexService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[VectorizeCreateIndex], err error) { +func (r *IndexService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[CreateIndex], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -79,12 +79,12 @@ func (r *IndexService) List(ctx context.Context, accountIdentifier string, opts } // Returns a list of Vectorize Indexes -func (r *IndexService) ListAutoPaging(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[VectorizeCreateIndex] { +func (r *IndexService) ListAutoPaging(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[CreateIndex] { return pagination.NewSinglePageAutoPager(r.List(ctx, accountIdentifier, opts...)) } // Deletes the specified Vectorize Index. -func (r *IndexService) Delete(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *IndexDeleteResponse, err error) { +func (r *IndexService) Delete(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *IndexDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env IndexDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) @@ -97,7 +97,7 @@ func (r *IndexService) Delete(ctx context.Context, accountIdentifier string, ind } // Delete a set of vectors from an index by their vector identifiers. -func (r *IndexService) DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body IndexDeleteByIDsParams, opts ...option.RequestOption) (res *VectorizeIndexDeleteVectorsByID, err error) { +func (r *IndexService) DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body IndexDeleteByIDsParams, opts ...option.RequestOption) (res *IndexDeleteVectorsByID, err error) { opts = append(r.Options[:], opts...) var env IndexDeleteByIDsResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/delete-by-ids", accountIdentifier, indexName) @@ -110,7 +110,7 @@ func (r *IndexService) DeleteByIDs(ctx context.Context, accountIdentifier string } // Returns the specified Vectorize Index. -func (r *IndexService) Get(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeCreateIndex, err error) { +func (r *IndexService) Get(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *CreateIndex, err error) { opts = append(r.Options[:], opts...) var env IndexGetResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) @@ -137,11 +137,11 @@ func (r *IndexService) GetByIDs(ctx context.Context, accountIdentifier string, i // Inserts vectors into the specified index and returns the count of the vectors // successfully inserted. -func (r *IndexService) Insert(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexInsert, err error) { +func (r *IndexService) Insert(ctx context.Context, accountIdentifier string, indexName string, body IndexInsertParams, opts ...option.RequestOption) (res *IndexInsert, err error) { opts = append(r.Options[:], opts...) var env IndexInsertResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/insert", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) if err != nil { return } @@ -150,7 +150,7 @@ func (r *IndexService) Insert(ctx context.Context, accountIdentifier string, ind } // Finds vectors closest to a given vector in an index. -func (r *IndexService) Query(ctx context.Context, accountIdentifier string, indexName string, body IndexQueryParams, opts ...option.RequestOption) (res *VectorizeIndexQuery, err error) { +func (r *IndexService) Query(ctx context.Context, accountIdentifier string, indexName string, body IndexQueryParams, opts ...option.RequestOption) (res *IndexQuery, err error) { opts = append(r.Options[:], opts...) var env IndexQueryResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/query", accountIdentifier, indexName) @@ -164,11 +164,11 @@ func (r *IndexService) Query(ctx context.Context, accountIdentifier string, inde // Upserts vectors into the specified index, creating them if they do not exist and // returns the count of values and ids successfully inserted. -func (r *IndexService) Upsert(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexUpsert, err error) { +func (r *IndexService) Upsert(ctx context.Context, accountIdentifier string, indexName string, body IndexUpsertParams, opts ...option.RequestOption) (res *IndexUpsert, err error) { opts = append(r.Options[:], opts...) var env IndexUpsertResponseEnvelope path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/upsert", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) if err != nil { return } @@ -176,21 +176,20 @@ func (r *IndexService) Upsert(ctx context.Context, accountIdentifier string, ind return } -type VectorizeCreateIndex struct { - Config VectorizeCreateIndexConfig `json:"config"` +type CreateIndex struct { + Config IndexDimensionConfiguration `json:"config"` // Specifies the timestamp the resource was created as an ISO8601 string. CreatedOn string `json:"created_on"` // Specifies the description of the index. Description string `json:"description"` // Specifies the timestamp the resource was modified as an ISO8601 string. - ModifiedOn string `json:"modified_on"` - Name string `json:"name"` - JSON vectorizeCreateIndexJSON `json:"-"` + ModifiedOn string `json:"modified_on"` + Name string `json:"name"` + JSON createIndexJSON `json:"-"` } -// vectorizeCreateIndexJSON contains the JSON metadata for the struct -// [VectorizeCreateIndex] -type vectorizeCreateIndexJSON struct { +// createIndexJSON contains the JSON metadata for the struct [CreateIndex] +type createIndexJSON struct { Config apijson.Field CreatedOn apijson.Field Description apijson.Field @@ -200,145 +199,155 @@ type vectorizeCreateIndexJSON struct { ExtraFields map[string]apijson.Field } -func (r *VectorizeCreateIndex) UnmarshalJSON(data []byte) (err error) { +func (r *CreateIndex) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r createIndexJSON) RawJSON() string { + return r.raw +} + +type IndexDeleteVectorsByID struct { + // The count of the vectors successfully deleted. + Count int64 `json:"count"` + // Array of vector identifiers of the vectors that were successfully processed for + // deletion. + IDs []string `json:"ids"` + JSON indexDeleteVectorsByIDJSON `json:"-"` +} + +// indexDeleteVectorsByIDJSON contains the JSON metadata for the struct +// [IndexDeleteVectorsByID] +type indexDeleteVectorsByIDJSON struct { + Count apijson.Field + IDs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexDeleteVectorsByID) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r vectorizeCreateIndexJSON) RawJSON() string { +func (r indexDeleteVectorsByIDJSON) RawJSON() string { return r.raw } -type VectorizeCreateIndexConfig struct { +type IndexDimensionConfiguration struct { // Specifies the number of dimensions for the index Dimensions int64 `json:"dimensions,required"` // Specifies the type of metric to use calculating distance. - Metric VectorizeCreateIndexConfigMetric `json:"metric,required"` - JSON vectorizeCreateIndexConfigJSON `json:"-"` + Metric IndexDimensionConfigurationMetric `json:"metric,required"` + JSON indexDimensionConfigurationJSON `json:"-"` } -// vectorizeCreateIndexConfigJSON contains the JSON metadata for the struct -// [VectorizeCreateIndexConfig] -type vectorizeCreateIndexConfigJSON struct { +// indexDimensionConfigurationJSON contains the JSON metadata for the struct +// [IndexDimensionConfiguration] +type indexDimensionConfigurationJSON struct { Dimensions apijson.Field Metric apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *VectorizeCreateIndexConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IndexDimensionConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r vectorizeCreateIndexConfigJSON) RawJSON() string { +func (r indexDimensionConfigurationJSON) RawJSON() string { return r.raw } // Specifies the type of metric to use calculating distance. -type VectorizeCreateIndexConfigMetric string +type IndexDimensionConfigurationMetric string const ( - VectorizeCreateIndexConfigMetricCosine VectorizeCreateIndexConfigMetric = "cosine" - VectorizeCreateIndexConfigMetricEuclidean VectorizeCreateIndexConfigMetric = "euclidean" - VectorizeCreateIndexConfigMetricDotProduct VectorizeCreateIndexConfigMetric = "dot-product" + IndexDimensionConfigurationMetricCosine IndexDimensionConfigurationMetric = "cosine" + IndexDimensionConfigurationMetricEuclidean IndexDimensionConfigurationMetric = "euclidean" + IndexDimensionConfigurationMetricDotProduct IndexDimensionConfigurationMetric = "dot-product" ) -func (r VectorizeCreateIndexConfigMetric) IsKnown() bool { +func (r IndexDimensionConfigurationMetric) IsKnown() bool { switch r { - case VectorizeCreateIndexConfigMetricCosine, VectorizeCreateIndexConfigMetricEuclidean, VectorizeCreateIndexConfigMetricDotProduct: + case IndexDimensionConfigurationMetricCosine, IndexDimensionConfigurationMetricEuclidean, IndexDimensionConfigurationMetricDotProduct: return true } return false } -type VectorizeIndexDeleteVectorsByID struct { - // The count of the vectors successfully deleted. - Count int64 `json:"count"` - // Array of vector identifiers of the vectors that were successfully processed for - // deletion. - IDs []string `json:"ids"` - JSON vectorizeIndexDeleteVectorsByIDJSON `json:"-"` +type IndexDimensionConfigurationParam struct { + // Specifies the number of dimensions for the index + Dimensions param.Field[int64] `json:"dimensions,required"` + // Specifies the type of metric to use calculating distance. + Metric param.Field[IndexDimensionConfigurationMetric] `json:"metric,required"` } -// vectorizeIndexDeleteVectorsByIDJSON contains the JSON metadata for the struct -// [VectorizeIndexDeleteVectorsByID] -type vectorizeIndexDeleteVectorsByIDJSON struct { - Count apijson.Field - IDs apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r IndexDimensionConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *VectorizeIndexDeleteVectorsByID) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +func (r IndexDimensionConfigurationParam) implementsVectorizeIndexNewParamsConfigUnion() {} -func (r vectorizeIndexDeleteVectorsByIDJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexInsert struct { +type IndexInsert struct { // Specifies the count of the vectors successfully inserted. Count int64 `json:"count"` // Array of vector identifiers of the vectors successfully inserted. - IDs []string `json:"ids"` - JSON vectorizeIndexInsertJSON `json:"-"` + IDs []string `json:"ids"` + JSON indexInsertJSON `json:"-"` } -// vectorizeIndexInsertJSON contains the JSON metadata for the struct -// [VectorizeIndexInsert] -type vectorizeIndexInsertJSON struct { +// indexInsertJSON contains the JSON metadata for the struct [IndexInsert] +type indexInsertJSON struct { Count apijson.Field IDs apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *VectorizeIndexInsert) UnmarshalJSON(data []byte) (err error) { +func (r *IndexInsert) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r vectorizeIndexInsertJSON) RawJSON() string { +func (r indexInsertJSON) RawJSON() string { return r.raw } -type VectorizeIndexQuery struct { +type IndexQuery struct { // Specifies the count of vectors returned by the search Count int64 `json:"count"` // Array of vectors matched by the search - Matches []VectorizeIndexQueryMatch `json:"matches"` - JSON vectorizeIndexQueryJSON `json:"-"` + Matches []IndexQueryMatch `json:"matches"` + JSON indexQueryJSON `json:"-"` } -// vectorizeIndexQueryJSON contains the JSON metadata for the struct -// [VectorizeIndexQuery] -type vectorizeIndexQueryJSON struct { +// indexQueryJSON contains the JSON metadata for the struct [IndexQuery] +type indexQueryJSON struct { Count apijson.Field Matches apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *VectorizeIndexQuery) UnmarshalJSON(data []byte) (err error) { +func (r *IndexQuery) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r vectorizeIndexQueryJSON) RawJSON() string { +func (r indexQueryJSON) RawJSON() string { return r.raw } -type VectorizeIndexQueryMatch struct { +type IndexQueryMatch struct { // Identifier ID string `json:"id"` Metadata interface{} `json:"metadata"` // The score of the vector according to the index's distance metric - Score float64 `json:"score"` - Values []float64 `json:"values"` - JSON vectorizeIndexQueryMatchJSON `json:"-"` + Score float64 `json:"score"` + Values []float64 `json:"values"` + JSON indexQueryMatchJSON `json:"-"` } -// vectorizeIndexQueryMatchJSON contains the JSON metadata for the struct -// [VectorizeIndexQueryMatch] -type vectorizeIndexQueryMatchJSON struct { +// indexQueryMatchJSON contains the JSON metadata for the struct [IndexQueryMatch] +type indexQueryMatchJSON struct { ID apijson.Field Metadata apijson.Field Score apijson.Field @@ -347,48 +356,47 @@ type vectorizeIndexQueryMatchJSON struct { ExtraFields map[string]apijson.Field } -func (r *VectorizeIndexQueryMatch) UnmarshalJSON(data []byte) (err error) { +func (r *IndexQueryMatch) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r vectorizeIndexQueryMatchJSON) RawJSON() string { +func (r indexQueryMatchJSON) RawJSON() string { return r.raw } -type VectorizeIndexUpsert struct { +type IndexUpsert struct { // Specifies the count of the vectors successfully inserted. Count int64 `json:"count"` // Array of vector identifiers of the vectors successfully inserted. - IDs []string `json:"ids"` - JSON vectorizeIndexUpsertJSON `json:"-"` + IDs []string `json:"ids"` + JSON indexUpsertJSON `json:"-"` } -// vectorizeIndexUpsertJSON contains the JSON metadata for the struct -// [VectorizeIndexUpsert] -type vectorizeIndexUpsertJSON struct { +// indexUpsertJSON contains the JSON metadata for the struct [IndexUpsert] +type indexUpsertJSON struct { Count apijson.Field IDs apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *VectorizeIndexUpsert) UnmarshalJSON(data []byte) (err error) { +func (r *IndexUpsert) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r vectorizeIndexUpsertJSON) RawJSON() string { +func (r indexUpsertJSON) RawJSON() string { return r.raw } // Union satisfied by [vectorize.IndexDeleteResponseUnknown] or // [shared.UnionString]. -type IndexDeleteResponse interface { - ImplementsVectorizeIndexDeleteResponse() +type IndexDeleteResponseUnion interface { + ImplementsVectorizeIndexDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*IndexDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*IndexDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -401,8 +409,8 @@ type IndexGetByIDsResponse = interface{} type IndexNewParams struct { // Specifies the type of configuration to use for the index. - Config param.Field[IndexNewParamsConfig] `json:"config,required"` - Name param.Field[string] `json:"name,required"` + Config param.Field[IndexNewParamsConfigUnion] `json:"config,required"` + Name param.Field[string] `json:"name,required"` // Specifies the description of the index. Description param.Field[string] `json:"description"` } @@ -411,12 +419,28 @@ func (r IndexNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// Specifies the type of configuration to use for the index. +type IndexNewParamsConfig struct { + // Specifies the preset to use for the index. + Preset param.Field[IndexNewParamsConfigPreset] `json:"preset"` + // Specifies the number of dimensions for the index + Dimensions param.Field[int64] `json:"dimensions"` + // Specifies the type of metric to use calculating distance. + Metric param.Field[IndexNewParamsConfigMetric] `json:"metric"` +} + +func (r IndexNewParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r IndexNewParamsConfig) implementsVectorizeIndexNewParamsConfigUnion() {} + // Specifies the type of configuration to use for the index. // // Satisfied by [vectorize.IndexNewParamsConfigVectorizeIndexPresetConfiguration], -// [vectorize.IndexNewParamsConfigVectorizeIndexDimensionConfiguration]. -type IndexNewParamsConfig interface { - implementsVectorizeIndexNewParamsConfig() +// [vectorize.IndexDimensionConfigurationParam], [IndexNewParamsConfig]. +type IndexNewParamsConfigUnion interface { + implementsVectorizeIndexNewParamsConfigUnion() } type IndexNewParamsConfigVectorizeIndexPresetConfiguration struct { @@ -428,7 +452,7 @@ func (r IndexNewParamsConfigVectorizeIndexPresetConfiguration) MarshalJSON() (da return apijson.MarshalRoot(r) } -func (r IndexNewParamsConfigVectorizeIndexPresetConfiguration) implementsVectorizeIndexNewParamsConfig() { +func (r IndexNewParamsConfigVectorizeIndexPresetConfiguration) implementsVectorizeIndexNewParamsConfigUnion() { } // Specifies the preset to use for the index. @@ -450,41 +474,46 @@ func (r IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset) IsKnown() b return false } -type IndexNewParamsConfigVectorizeIndexDimensionConfiguration struct { - // Specifies the number of dimensions for the index - Dimensions param.Field[int64] `json:"dimensions,required"` - // Specifies the type of metric to use calculating distance. - Metric param.Field[IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric] `json:"metric,required"` -} +// Specifies the preset to use for the index. +type IndexNewParamsConfigPreset string -func (r IndexNewParamsConfigVectorizeIndexDimensionConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} +const ( + IndexNewParamsConfigPresetCfBaaiBgeSmallEnV1_5 IndexNewParamsConfigPreset = "@cf/baai/bge-small-en-v1.5" + IndexNewParamsConfigPresetCfBaaiBgeBaseEnV1_5 IndexNewParamsConfigPreset = "@cf/baai/bge-base-en-v1.5" + IndexNewParamsConfigPresetCfBaaiBgeLargeEnV1_5 IndexNewParamsConfigPreset = "@cf/baai/bge-large-en-v1.5" + IndexNewParamsConfigPresetOpenAITextEmbeddingAda002 IndexNewParamsConfigPreset = "openai/text-embedding-ada-002" + IndexNewParamsConfigPresetCohereEmbedMultilingualV2_0 IndexNewParamsConfigPreset = "cohere/embed-multilingual-v2.0" +) -func (r IndexNewParamsConfigVectorizeIndexDimensionConfiguration) implementsVectorizeIndexNewParamsConfig() { +func (r IndexNewParamsConfigPreset) IsKnown() bool { + switch r { + case IndexNewParamsConfigPresetCfBaaiBgeSmallEnV1_5, IndexNewParamsConfigPresetCfBaaiBgeBaseEnV1_5, IndexNewParamsConfigPresetCfBaaiBgeLargeEnV1_5, IndexNewParamsConfigPresetOpenAITextEmbeddingAda002, IndexNewParamsConfigPresetCohereEmbedMultilingualV2_0: + return true + } + return false } // Specifies the type of metric to use calculating distance. -type IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric string +type IndexNewParamsConfigMetric string const ( - IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricCosine IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "cosine" - IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricEuclidean IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "euclidean" - IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricDotProduct IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "dot-product" + IndexNewParamsConfigMetricCosine IndexNewParamsConfigMetric = "cosine" + IndexNewParamsConfigMetricEuclidean IndexNewParamsConfigMetric = "euclidean" + IndexNewParamsConfigMetricDotProduct IndexNewParamsConfigMetric = "dot-product" ) -func (r IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric) IsKnown() bool { +func (r IndexNewParamsConfigMetric) IsKnown() bool { switch r { - case IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricCosine, IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricEuclidean, IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricDotProduct: + case IndexNewParamsConfigMetricCosine, IndexNewParamsConfigMetricEuclidean, IndexNewParamsConfigMetricDotProduct: return true } return false } type IndexNewResponseEnvelope struct { - Errors []IndexNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexNewResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeCreateIndex `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CreateIndex `json:"result,required,nullable"` // Whether the API call was successful Success IndexNewResponseEnvelopeSuccess `json:"success,required"` JSON indexNewResponseEnvelopeJSON `json:"-"` @@ -509,52 +538,6 @@ func (r indexNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IndexNewResponseEnvelopeErrors] -type indexNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IndexNewResponseEnvelopeMessages] -type indexNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexNewResponseEnvelopeSuccess bool @@ -580,9 +563,9 @@ func (r IndexUpdateParams) MarshalJSON() (data []byte, err error) { } type IndexUpdateResponseEnvelope struct { - Errors []IndexUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexUpdateResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeCreateIndex `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CreateIndex `json:"result,required,nullable"` // Whether the API call was successful Success IndexUpdateResponseEnvelopeSuccess `json:"success,required"` JSON indexUpdateResponseEnvelopeJSON `json:"-"` @@ -607,52 +590,6 @@ func (r indexUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IndexUpdateResponseEnvelopeErrors] -type indexUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndexUpdateResponseEnvelopeMessages] -type indexUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexUpdateResponseEnvelopeSuccess bool @@ -669,9 +606,9 @@ func (r IndexUpdateResponseEnvelopeSuccess) IsKnown() bool { } type IndexDeleteResponseEnvelope struct { - Errors []IndexDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexDeleteResponseEnvelopeMessages `json:"messages,required"` - Result IndexDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndexDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success IndexDeleteResponseEnvelopeSuccess `json:"success,required"` JSON indexDeleteResponseEnvelopeJSON `json:"-"` @@ -696,52 +633,6 @@ func (r indexDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IndexDeleteResponseEnvelopeErrors] -type indexDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndexDeleteResponseEnvelopeMessages] -type indexDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexDeleteResponseEnvelopeSuccess bool @@ -767,9 +658,9 @@ func (r IndexDeleteByIDsParams) MarshalJSON() (data []byte, err error) { } type IndexDeleteByIDsResponseEnvelope struct { - Errors []IndexDeleteByIDsResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexDeleteByIDsResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexDeleteVectorsByID `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndexDeleteVectorsByID `json:"result,required,nullable"` // Whether the API call was successful Success IndexDeleteByIDsResponseEnvelopeSuccess `json:"success,required"` JSON indexDeleteByIDsResponseEnvelopeJSON `json:"-"` @@ -794,52 +685,6 @@ func (r indexDeleteByIDsResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexDeleteByIDsResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexDeleteByIDsResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexDeleteByIDsResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IndexDeleteByIDsResponseEnvelopeErrors] -type indexDeleteByIDsResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexDeleteByIDsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexDeleteByIDsResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexDeleteByIDsResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexDeleteByIDsResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexDeleteByIDsResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndexDeleteByIDsResponseEnvelopeMessages] -type indexDeleteByIDsResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexDeleteByIDsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexDeleteByIDsResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexDeleteByIDsResponseEnvelopeSuccess bool @@ -856,9 +701,9 @@ func (r IndexDeleteByIDsResponseEnvelopeSuccess) IsKnown() bool { } type IndexGetResponseEnvelope struct { - Errors []IndexGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexGetResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeCreateIndex `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CreateIndex `json:"result,required,nullable"` // Whether the API call was successful Success IndexGetResponseEnvelopeSuccess `json:"success,required"` JSON indexGetResponseEnvelopeJSON `json:"-"` @@ -883,52 +728,6 @@ func (r indexGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IndexGetResponseEnvelopeErrors] -type indexGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IndexGetResponseEnvelopeMessages] -type indexGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexGetResponseEnvelopeSuccess bool @@ -954,8 +753,8 @@ func (r IndexGetByIDsParams) MarshalJSON() (data []byte, err error) { } type IndexGetByIDsResponseEnvelope struct { - Errors []IndexGetByIDsResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexGetByIDsResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Array of vectors with matching ids. Result IndexGetByIDsResponse `json:"result,required,nullable"` // Whether the API call was successful @@ -982,52 +781,6 @@ func (r indexGetByIDsResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexGetByIDsResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexGetByIDsResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexGetByIDsResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IndexGetByIDsResponseEnvelopeErrors] -type indexGetByIDsResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexGetByIDsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexGetByIDsResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexGetByIDsResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexGetByIDsResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexGetByIDsResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndexGetByIDsResponseEnvelopeMessages] -type indexGetByIDsResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexGetByIDsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexGetByIDsResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexGetByIDsResponseEnvelopeSuccess bool @@ -1043,10 +796,18 @@ func (r IndexGetByIDsResponseEnvelopeSuccess) IsKnown() bool { return false } +type IndexInsertParams struct { + Body interface{} `json:"body,required"` +} + +func (r IndexInsertParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type IndexInsertResponseEnvelope struct { - Errors []IndexInsertResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexInsertResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexInsert `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndexInsert `json:"result,required,nullable"` // Whether the API call was successful Success IndexInsertResponseEnvelopeSuccess `json:"success,required"` JSON indexInsertResponseEnvelopeJSON `json:"-"` @@ -1071,52 +832,6 @@ func (r indexInsertResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexInsertResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexInsertResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexInsertResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IndexInsertResponseEnvelopeErrors] -type indexInsertResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexInsertResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexInsertResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexInsertResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexInsertResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexInsertResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndexInsertResponseEnvelopeMessages] -type indexInsertResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexInsertResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexInsertResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexInsertResponseEnvelopeSuccess bool @@ -1148,9 +863,9 @@ func (r IndexQueryParams) MarshalJSON() (data []byte, err error) { } type IndexQueryResponseEnvelope struct { - Errors []IndexQueryResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexQueryResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexQuery `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndexQuery `json:"result,required,nullable"` // Whether the API call was successful Success IndexQueryResponseEnvelopeSuccess `json:"success,required"` JSON indexQueryResponseEnvelopeJSON `json:"-"` @@ -1175,52 +890,6 @@ func (r indexQueryResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexQueryResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexQueryResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexQueryResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IndexQueryResponseEnvelopeErrors] -type indexQueryResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexQueryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexQueryResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexQueryResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexQueryResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexQueryResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IndexQueryResponseEnvelopeMessages] -type indexQueryResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexQueryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexQueryResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexQueryResponseEnvelopeSuccess bool @@ -1236,10 +905,18 @@ func (r IndexQueryResponseEnvelopeSuccess) IsKnown() bool { return false } +type IndexUpsertParams struct { + Body interface{} `json:"body,required"` +} + +func (r IndexUpsertParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type IndexUpsertResponseEnvelope struct { - Errors []IndexUpsertResponseEnvelopeErrors `json:"errors,required"` - Messages []IndexUpsertResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexUpsert `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IndexUpsert `json:"result,required,nullable"` // Whether the API call was successful Success IndexUpsertResponseEnvelopeSuccess `json:"success,required"` JSON indexUpsertResponseEnvelopeJSON `json:"-"` @@ -1264,52 +941,6 @@ func (r indexUpsertResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IndexUpsertResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexUpsertResponseEnvelopeErrorsJSON `json:"-"` -} - -// indexUpsertResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IndexUpsertResponseEnvelopeErrors] -type indexUpsertResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexUpsertResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexUpsertResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IndexUpsertResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON indexUpsertResponseEnvelopeMessagesJSON `json:"-"` -} - -// indexUpsertResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IndexUpsertResponseEnvelopeMessages] -type indexUpsertResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IndexUpsertResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r indexUpsertResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IndexUpsertResponseEnvelopeSuccess bool diff --git a/vectorize/index_test.go b/vectorize/index_test.go index b5a809bff11..2a47549e5d3 100644 --- a/vectorize/index_test.go +++ b/vectorize/index_test.go @@ -32,9 +32,9 @@ func TestIndexNewWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", vectorize.IndexNewParams{ - Config: cloudflare.F[vectorize.IndexNewParamsConfig](vectorize.IndexNewParamsConfigVectorizeIndexPresetConfiguration(vectorize.IndexNewParamsConfigVectorizeIndexPresetConfiguration{ + Config: cloudflare.F[vectorize.IndexNewParamsConfigUnion](vectorize.IndexNewParamsConfigVectorizeIndexPresetConfiguration{ Preset: cloudflare.F(vectorize.IndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeSmallEnV1_5), - })), + }), Name: cloudflare.F("example-index"), Description: cloudflare.F("This is my example index."), }, @@ -239,6 +239,9 @@ func TestIndexInsert(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "example-index", + vectorize.IndexInsertParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error @@ -301,6 +304,9 @@ func TestIndexUpsert(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "example-index", + vectorize.IndexUpsertParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/waiting_rooms/aliases.go b/waiting_rooms/aliases.go index 085dd0d5f7c..90aca3d8719 100644 --- a/waiting_rooms/aliases.go +++ b/waiting_rooms/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/waiting_rooms/event.go b/waiting_rooms/event.go index 656166af6d4..1faff34ac57 100644 --- a/waiting_rooms/event.go +++ b/waiting_rooms/event.go @@ -6,9 +6,11 @@ import ( "context" "fmt" "net/http" + "net/url" "time" "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" @@ -40,11 +42,11 @@ func NewEventService(opts ...option.RequestOption) (r *EventService) { // some of the properties in the event's configuration may either override or // inherit from the waiting room's configuration. Note that events cannot overlap // with each other, so only one event can be active at a time. -func (r *EventService) New(ctx context.Context, zoneIdentifier string, waitingRoomID string, body EventNewParams, opts ...option.RequestOption) (res *WaitingroomEvent, err error) { +func (r *EventService) New(ctx context.Context, waitingRoomID string, params EventNewParams, opts ...option.RequestOption) (res *Event, err error) { opts = append(r.Options[:], opts...) var env EventNewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events", params.ZoneID, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return } @@ -53,11 +55,11 @@ func (r *EventService) New(ctx context.Context, zoneIdentifier string, waitingRo } // Updates a configured event for a waiting room. -func (r *EventService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string, body EventUpdateParams, opts ...option.RequestOption) (res *WaitingroomEvent, err error) { +func (r *EventService) Update(ctx context.Context, waitingRoomID string, eventID string, params EventUpdateParams, opts ...option.RequestOption) (res *Event, err error) { opts = append(r.Options[:], opts...) var env EventUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", zoneIdentifier, waitingRoomID, eventID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", params.ZoneID, waitingRoomID, eventID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return } @@ -66,12 +68,12 @@ func (r *EventService) Update(ctx context.Context, zoneIdentifier string, waitin } // Lists events for a waiting room. -func (r *EventService) List(ctx context.Context, zoneIdentifier string, waitingRoomID string, opts ...option.RequestOption) (res *pagination.SinglePage[WaitingroomEvent], err error) { +func (r *EventService) List(ctx context.Context, waitingRoomID string, params EventListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Event], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events", zoneIdentifier, waitingRoomID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events", params.ZoneID, waitingRoomID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) if err != nil { return nil, err } @@ -84,15 +86,15 @@ func (r *EventService) List(ctx context.Context, zoneIdentifier string, waitingR } // Lists events for a waiting room. -func (r *EventService) ListAutoPaging(ctx context.Context, zoneIdentifier string, waitingRoomID string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WaitingroomEvent] { - return pagination.NewSinglePageAutoPager(r.List(ctx, zoneIdentifier, waitingRoomID, opts...)) +func (r *EventService) ListAutoPaging(ctx context.Context, waitingRoomID string, params EventListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Event] { + return pagination.NewSinglePageAutoPager(r.List(ctx, waitingRoomID, params, opts...)) } // Deletes an event for a waiting room. -func (r *EventService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string, opts ...option.RequestOption) (res *EventDeleteResponse, err error) { +func (r *EventService) Delete(ctx context.Context, waitingRoomID string, eventID string, params EventDeleteParams, opts ...option.RequestOption) (res *EventDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env EventDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", zoneIdentifier, waitingRoomID, eventID) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", params.ZoneID, waitingRoomID, eventID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -102,11 +104,11 @@ func (r *EventService) Delete(ctx context.Context, zoneIdentifier string, waitin } // Patches a configured event for a waiting room. -func (r *EventService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string, body EventEditParams, opts ...option.RequestOption) (res *WaitingroomEvent, err error) { +func (r *EventService) Edit(ctx context.Context, waitingRoomID string, eventID string, params EventEditParams, opts ...option.RequestOption) (res *Event, err error) { opts = append(r.Options[:], opts...) var env EventEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", zoneIdentifier, waitingRoomID, eventID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", params.ZoneID, waitingRoomID, eventID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) if err != nil { return } @@ -115,10 +117,10 @@ func (r *EventService) Edit(ctx context.Context, zoneIdentifier string, waitingR } // Fetches a single configured event for a waiting room. -func (r *EventService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string, opts ...option.RequestOption) (res *WaitingroomEvent, err error) { +func (r *EventService) Get(ctx context.Context, waitingRoomID string, eventID string, query EventGetParams, opts ...option.RequestOption) (res *Event, err error) { opts = append(r.Options[:], opts...) var env EventGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", zoneIdentifier, waitingRoomID, eventID) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s", query.ZoneID, waitingRoomID, eventID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -127,7 +129,7 @@ func (r *EventService) Get(ctx context.Context, zoneIdentifier string, waitingRo return } -type WaitingroomEvent struct { +type Event struct { ID string `json:"id"` CreatedOn time.Time `json:"created_on" format:"date-time"` // If set, the event will override the waiting room's `custom_page_html` property @@ -175,13 +177,12 @@ type WaitingroomEvent struct { // If set, the event will override the waiting room's `total_active_users` property // while it is active. If null, the event will inherit it. This can only be set if // the event's `new_users_per_minute` property is also set. - TotalActiveUsers int64 `json:"total_active_users,nullable"` - JSON waitingroomEventJSON `json:"-"` + TotalActiveUsers int64 `json:"total_active_users,nullable"` + JSON eventJSON `json:"-"` } -// waitingroomEventJSON contains the JSON metadata for the struct -// [WaitingroomEvent] -type waitingroomEventJSON struct { +// eventJSON contains the JSON metadata for the struct [Event] +type eventJSON struct { ID apijson.Field CreatedOn apijson.Field CustomPageHTML apijson.Field @@ -202,11 +203,11 @@ type waitingroomEventJSON struct { ExtraFields map[string]apijson.Field } -func (r *WaitingroomEvent) UnmarshalJSON(data []byte) (err error) { +func (r *Event) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r waitingroomEventJSON) RawJSON() string { +func (r eventJSON) RawJSON() string { return r.raw } @@ -232,66 +233,30 @@ func (r eventDeleteResponseJSON) RawJSON() string { } type EventNewParams struct { - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime param.Field[string] `json:"event_end_time,required"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime param.Field[string] `json:"event_start_time,required"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // A note that you can use to add more details about the event. - Description param.Field[string] `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod param.Field[string] `json:"queueing_method"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration param.Field[int64] `json:"session_duration"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended param.Field[bool] `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers param.Field[int64] `json:"total_active_users"` + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + EventQuery EventQueryParam `json:"event_query,required"` } func (r EventNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.EventQuery) } type EventNewResponseEnvelope struct { - Result WaitingroomEvent `json:"result,required"` - JSON eventNewResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result Event `json:"result,required"` + Success interface{} `json:"success,required"` + JSON eventNewResponseEnvelopeJSON `json:"-"` } // eventNewResponseEnvelopeJSON contains the JSON metadata for the struct // [EventNewResponseEnvelope] type eventNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -305,66 +270,30 @@ func (r eventNewResponseEnvelopeJSON) RawJSON() string { } type EventUpdateParams struct { - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime param.Field[string] `json:"event_end_time,required"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime param.Field[string] `json:"event_start_time,required"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // A note that you can use to add more details about the event. - Description param.Field[string] `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod param.Field[string] `json:"queueing_method"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration param.Field[int64] `json:"session_duration"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended param.Field[bool] `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers param.Field[int64] `json:"total_active_users"` + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + EventQuery EventQueryParam `json:"event_query,required"` } func (r EventUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.EventQuery) } type EventUpdateResponseEnvelope struct { - Result WaitingroomEvent `json:"result,required"` - JSON eventUpdateResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result Event `json:"result,required"` + Success interface{} `json:"success,required"` + JSON eventUpdateResponseEnvelopeJSON `json:"-"` } // eventUpdateResponseEnvelopeJSON contains the JSON metadata for the struct // [EventUpdateResponseEnvelope] type eventUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -377,15 +306,48 @@ func (r eventUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } +type EventListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Page number of paginated results. + Page param.Field[interface{}] `query:"page"` + // Maximum number of results per page. Must be a multiple of 5. + PerPage param.Field[interface{}] `query:"per_page"` +} + +// URLQuery serializes [EventListParams]'s query parameters as `url.Values`. +func (r EventListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EventDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r EventDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type EventDeleteResponseEnvelope struct { - Result EventDeleteResponse `json:"result,required"` - JSON eventDeleteResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result EventDeleteResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON eventDeleteResponseEnvelopeJSON `json:"-"` } // eventDeleteResponseEnvelopeJSON contains the JSON metadata for the struct // [EventDeleteResponseEnvelope] type eventDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -399,66 +361,30 @@ func (r eventDeleteResponseEnvelopeJSON) RawJSON() string { } type EventEditParams struct { - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime param.Field[string] `json:"event_end_time,required"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime param.Field[string] `json:"event_start_time,required"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // A note that you can use to add more details about the event. - Description param.Field[string] `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod param.Field[string] `json:"queueing_method"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration param.Field[int64] `json:"session_duration"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended param.Field[bool] `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers param.Field[int64] `json:"total_active_users"` + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + EventQuery EventQueryParam `json:"event_query,required"` } func (r EventEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.EventQuery) } type EventEditResponseEnvelope struct { - Result WaitingroomEvent `json:"result,required"` - JSON eventEditResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result Event `json:"result,required"` + Success interface{} `json:"success,required"` + JSON eventEditResponseEnvelopeJSON `json:"-"` } // eventEditResponseEnvelopeJSON contains the JSON metadata for the struct // [EventEditResponseEnvelope] type eventEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -471,15 +397,26 @@ func (r eventEditResponseEnvelopeJSON) RawJSON() string { return r.raw } +type EventGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + type EventGetResponseEnvelope struct { - Result WaitingroomEvent `json:"result,required"` - JSON eventGetResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result Event `json:"result,required"` + Success interface{} `json:"success,required"` + JSON eventGetResponseEnvelopeJSON `json:"-"` } // eventGetResponseEnvelopeJSON contains the JSON metadata for the struct // [EventGetResponseEnvelope] type eventGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/waiting_rooms/event_test.go b/waiting_rooms/event_test.go index 0d47a518639..df298de4efb 100644 --- a/waiting_rooms/event_test.go +++ b/waiting_rooms/event_test.go @@ -30,22 +30,24 @@ func TestEventNewWithOptionalParams(t *testing.T) { ) _, err := client.WaitingRooms.Events.New( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", waiting_rooms.EventNewParams{ - EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), - EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), - Name: cloudflare.F("production_webinar_event"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), - Description: cloudflare.F("Production event - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(true), - NewUsersPerMinute: cloudflare.F(int64(200)), - PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), - QueueingMethod: cloudflare.F("random"), - SessionDuration: cloudflare.F(int64(1)), - ShuffleAtEventStart: cloudflare.F(true), - Suspended: cloudflare.F(true), - TotalActiveUsers: cloudflare.F(int64(200)), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + EventQuery: waiting_rooms.EventQueryParam{ + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), + Description: cloudflare.F("Production event - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(true), + EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), + EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), + Name: cloudflare.F("production_webinar_event"), + NewUsersPerMinute: cloudflare.F(int64(200)), + PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), + QueueingMethod: cloudflare.F("random"), + SessionDuration: cloudflare.F(int64(1)), + ShuffleAtEventStart: cloudflare.F(true), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, }, ) if err != nil { @@ -73,23 +75,25 @@ func TestEventUpdateWithOptionalParams(t *testing.T) { ) _, err := client.WaitingRooms.Events.Update( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", waiting_rooms.EventUpdateParams{ - EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), - EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), - Name: cloudflare.F("production_webinar_event"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), - Description: cloudflare.F("Production event - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(true), - NewUsersPerMinute: cloudflare.F(int64(200)), - PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), - QueueingMethod: cloudflare.F("random"), - SessionDuration: cloudflare.F(int64(1)), - ShuffleAtEventStart: cloudflare.F(true), - Suspended: cloudflare.F(true), - TotalActiveUsers: cloudflare.F(int64(200)), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + EventQuery: waiting_rooms.EventQueryParam{ + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), + Description: cloudflare.F("Production event - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(true), + EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), + EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), + Name: cloudflare.F("production_webinar_event"), + NewUsersPerMinute: cloudflare.F(int64(200)), + PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), + QueueingMethod: cloudflare.F("random"), + SessionDuration: cloudflare.F(int64(1)), + ShuffleAtEventStart: cloudflare.F(true), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, }, ) if err != nil { @@ -101,7 +105,7 @@ func TestEventUpdateWithOptionalParams(t *testing.T) { } } -func TestEventList(t *testing.T) { +func TestEventListWithOptionalParams(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 { @@ -117,8 +121,12 @@ func TestEventList(t *testing.T) { ) _, err := client.WaitingRooms.Events.List( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", + waiting_rooms.EventListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Page: cloudflare.F[any](map[string]interface{}{}), + PerPage: cloudflare.F[any](map[string]interface{}{}), + }, ) if err != nil { var apierr *cloudflare.Error @@ -145,9 +153,12 @@ func TestEventDelete(t *testing.T) { ) _, err := client.WaitingRooms.Events.Delete( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", + waiting_rooms.EventDeleteParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error @@ -174,23 +185,25 @@ func TestEventEditWithOptionalParams(t *testing.T) { ) _, err := client.WaitingRooms.Events.Edit( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", waiting_rooms.EventEditParams{ - EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), - EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), - Name: cloudflare.F("production_webinar_event"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), - Description: cloudflare.F("Production event - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(true), - NewUsersPerMinute: cloudflare.F(int64(200)), - PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), - QueueingMethod: cloudflare.F("random"), - SessionDuration: cloudflare.F(int64(1)), - ShuffleAtEventStart: cloudflare.F(true), - Suspended: cloudflare.F(true), - TotalActiveUsers: cloudflare.F(int64(200)), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + EventQuery: waiting_rooms.EventQueryParam{ + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), + Description: cloudflare.F("Production event - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(true), + EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), + EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), + Name: cloudflare.F("production_webinar_event"), + NewUsersPerMinute: cloudflare.F(int64(200)), + PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), + QueueingMethod: cloudflare.F("random"), + SessionDuration: cloudflare.F(int64(1)), + ShuffleAtEventStart: cloudflare.F(true), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, }, ) if err != nil { @@ -218,9 +231,11 @@ func TestEventGet(t *testing.T) { ) _, err := client.WaitingRooms.Events.Get( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", + waiting_rooms.EventGetParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/waiting_rooms/eventdetail.go b/waiting_rooms/eventdetail.go index afd862003d5..03911c33361 100644 --- a/waiting_rooms/eventdetail.go +++ b/waiting_rooms/eventdetail.go @@ -9,6 +9,7 @@ import ( "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -33,10 +34,10 @@ func NewEventDetailService(opts ...option.RequestOption) (r *EventDetailService) // Previews an event's configuration as if it was active. Inherited fields from the // waiting room will be displayed with their current values. -func (r *EventDetailService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID string, eventID string, opts ...option.RequestOption) (res *WaitingroomEventDetails, err error) { +func (r *EventDetailService) Get(ctx context.Context, waitingRoomID string, eventID string, query EventDetailGetParams, opts ...option.RequestOption) (res *EventDetailGetResponse, err error) { opts = append(r.Options[:], opts...) var env EventDetailGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s/details", zoneIdentifier, waitingRoomID, eventID) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/events/%s/details", query.ZoneID, waitingRoomID, eventID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -45,7 +46,59 @@ func (r *EventDetailService) Get(ctx context.Context, zoneIdentifier string, wai return } -type WaitingroomEventDetails struct { +type EventQueryParam struct { + // An ISO 8601 timestamp that marks the end of the event. + EventEndTime param.Field[string] `json:"event_end_time,required"` + // An ISO 8601 timestamp that marks the start of the event. At this time, queued + // users will be processed with the event's configuration. The start time must be + // at least one minute before `event_end_time`. + EventStartTime param.Field[string] `json:"event_start_time,required"` + // A unique name to identify the event. Only alphanumeric characters, hyphens and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // If set, the event will override the waiting room's `custom_page_html` property + // while it is active. If null, the event will inherit it. + CustomPageHTML param.Field[string] `json:"custom_page_html"` + // A note that you can use to add more details about the event. + Description param.Field[string] `json:"description"` + // If set, the event will override the waiting room's `disable_session_renewal` + // property while it is active. If null, the event will inherit it. + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + // If set, the event will override the waiting room's `new_users_per_minute` + // property while it is active. If null, the event will inherit it. This can only + // be set if the event's `total_active_users` property is also set. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` + // An ISO 8601 timestamp that marks when to begin queueing all users before the + // event starts. The prequeue must start at least five minutes before + // `event_start_time`. + PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` + // If set, the event will override the waiting room's `queueing_method` property + // while it is active. If null, the event will inherit it. + QueueingMethod param.Field[string] `json:"queueing_method"` + // If set, the event will override the waiting room's `session_duration` property + // while it is active. If null, the event will inherit it. + SessionDuration param.Field[int64] `json:"session_duration"` + // If enabled, users in the prequeue will be shuffled randomly at the + // `event_start_time`. Requires that `prequeue_start_time` is not null. This is + // useful for situations when many users will join the event prequeue at the same + // time and you want to shuffle them to ensure fairness. Naturally, it makes the + // most sense to enable this feature when the `queueing_method` during the event + // respects ordering such as **fifo**, or else the shuffling may be unnecessary. + ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` + // Suspends or allows an event. If set to `true`, the event is ignored and traffic + // will be handled based on the waiting room configuration. + Suspended param.Field[bool] `json:"suspended"` + // If set, the event will override the waiting room's `total_active_users` property + // while it is active. If null, the event will inherit it. This can only be set if + // the event's `new_users_per_minute` property is also set. + TotalActiveUsers param.Field[int64] `json:"total_active_users"` +} + +func (r EventQueryParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type EventDetailGetResponse struct { ID string `json:"id"` CreatedOn time.Time `json:"created_on" format:"date-time"` CustomPageHTML string `json:"custom_page_html"` @@ -78,14 +131,14 @@ type WaitingroomEventDetails struct { ShuffleAtEventStart bool `json:"shuffle_at_event_start"` // Suspends or allows an event. If set to `true`, the event is ignored and traffic // will be handled based on the waiting room configuration. - Suspended bool `json:"suspended"` - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingroomEventDetailsJSON `json:"-"` + Suspended bool `json:"suspended"` + TotalActiveUsers int64 `json:"total_active_users"` + JSON eventDetailGetResponseJSON `json:"-"` } -// waitingroomEventDetailsJSON contains the JSON metadata for the struct -// [WaitingroomEventDetails] -type waitingroomEventDetailsJSON struct { +// eventDetailGetResponseJSON contains the JSON metadata for the struct +// [EventDetailGetResponse] +type eventDetailGetResponseJSON struct { ID apijson.Field CreatedOn apijson.Field CustomPageHTML apijson.Field @@ -106,23 +159,34 @@ type waitingroomEventDetailsJSON struct { ExtraFields map[string]apijson.Field } -func (r *WaitingroomEventDetails) UnmarshalJSON(data []byte) (err error) { +func (r *EventDetailGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r waitingroomEventDetailsJSON) RawJSON() string { +func (r eventDetailGetResponseJSON) RawJSON() string { return r.raw } +type EventDetailGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + type EventDetailGetResponseEnvelope struct { - Result WaitingroomEventDetails `json:"result,required"` - JSON eventDetailGetResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result EventDetailGetResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON eventDetailGetResponseEnvelopeJSON `json:"-"` } // eventDetailGetResponseEnvelopeJSON contains the JSON metadata for the struct // [EventDetailGetResponseEnvelope] type eventDetailGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/waiting_rooms/eventdetail_test.go b/waiting_rooms/eventdetail_test.go index 899c642141b..47c7788fa2f 100644 --- a/waiting_rooms/eventdetail_test.go +++ b/waiting_rooms/eventdetail_test.go @@ -11,6 +11,7 @@ import ( "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/waiting_rooms" ) func TestEventDetailGet(t *testing.T) { @@ -29,9 +30,11 @@ func TestEventDetailGet(t *testing.T) { ) _, err := client.WaitingRooms.Events.Details.Get( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", + waiting_rooms.EventDetailGetParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/waiting_rooms/page.go b/waiting_rooms/page.go index 4155812247d..e2b0623a94a 100644 --- a/waiting_rooms/page.go +++ b/waiting_rooms/page.go @@ -66,11 +66,11 @@ func NewPageService(opts ...option.RequestOption) (r *PageService) { // For example, you can make a request to // `http://waitingrooms.dev/preview/?waitTime=50` to configure the estimated // wait time as 50 minutes. -func (r *PageService) Preview(ctx context.Context, zoneIdentifier string, body PagePreviewParams, opts ...option.RequestOption) (res *PagePreviewResponse, err error) { +func (r *PageService) Preview(ctx context.Context, params PagePreviewParams, opts ...option.RequestOption) (res *PagePreviewResponse, err error) { opts = append(r.Options[:], opts...) var env PagePreviewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/preview", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/preview", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return } @@ -101,6 +101,8 @@ func (r pagePreviewResponseJSON) RawJSON() string { } type PagePreviewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` // Only available for the Waiting Room Advanced subscription. This is a template // html file that will be rendered at the edge. If no custom_page_html is provided, // the default waiting room will be used. The template is based on mustache ( @@ -130,14 +132,20 @@ func (r PagePreviewParams) MarshalJSON() (data []byte, err error) { } type PagePreviewResponseEnvelope struct { - Result PagePreviewResponse `json:"result,required"` - JSON pagePreviewResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result PagePreviewResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON pagePreviewResponseEnvelopeJSON `json:"-"` } // pagePreviewResponseEnvelopeJSON contains the JSON metadata for the struct // [PagePreviewResponseEnvelope] type pagePreviewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/waiting_rooms/page_test.go b/waiting_rooms/page_test.go index a9418481ebb..abb0703abbf 100644 --- a/waiting_rooms/page_test.go +++ b/waiting_rooms/page_test.go @@ -28,13 +28,10 @@ func TestPagePreview(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WaitingRooms.Page.Preview( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - waiting_rooms.PagePreviewParams{ - CustomHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), - }, - ) + _, err := client.WaitingRooms.Page.Preview(context.TODO(), waiting_rooms.PagePreviewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + CustomHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/waiting_rooms/rule.go b/waiting_rooms/rule.go index 4293e130773..9e3df896258 100644 --- a/waiting_rooms/rule.go +++ b/waiting_rooms/rule.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -34,11 +35,11 @@ func NewRuleService(opts ...option.RequestOption) (r *RuleService) { // Only available for the Waiting Room Advanced subscription. Creates a rule for a // waiting room. -func (r *RuleService) New(ctx context.Context, zoneIdentifier string, waitingRoomID string, body RuleNewParams, opts ...option.RequestOption) (res *[]WaitingroomRule, err error) { +func (r *RuleService) New(ctx context.Context, waitingRoomID string, params RuleNewParams, opts ...option.RequestOption) (res *[]WaitingRoomRule, err error) { opts = append(r.Options[:], opts...) var env RuleNewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules", params.ZoneID, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return } @@ -48,11 +49,11 @@ func (r *RuleService) New(ctx context.Context, zoneIdentifier string, waitingRoo // Only available for the Waiting Room Advanced subscription. Replaces all rules // for a waiting room. -func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID string, body RuleUpdateParams, opts ...option.RequestOption) (res *[]WaitingroomRule, err error) { +func (r *RuleService) Update(ctx context.Context, waitingRoomID string, params RuleUpdateParams, opts ...option.RequestOption) (res *[]WaitingRoomRule, err error) { opts = append(r.Options[:], opts...) var env RuleUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules", params.ZoneID, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return } @@ -61,12 +62,12 @@ func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, waiting } // Lists rules for a waiting room. -func (r *RuleService) List(ctx context.Context, zoneIdentifier string, waitingRoomID string, opts ...option.RequestOption) (res *pagination.SinglePage[WaitingroomRule], err error) { +func (r *RuleService) List(ctx context.Context, waitingRoomID string, query RuleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[WaitingRoomRule], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules", zoneIdentifier, waitingRoomID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules", query.ZoneID, waitingRoomID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) if err != nil { return nil, err } @@ -79,15 +80,15 @@ func (r *RuleService) List(ctx context.Context, zoneIdentifier string, waitingRo } // Lists rules for a waiting room. -func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, waitingRoomID string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WaitingroomRule] { - return pagination.NewSinglePageAutoPager(r.List(ctx, zoneIdentifier, waitingRoomID, opts...)) +func (r *RuleService) ListAutoPaging(ctx context.Context, waitingRoomID string, query RuleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WaitingRoomRule] { + return pagination.NewSinglePageAutoPager(r.List(ctx, waitingRoomID, query, opts...)) } // Deletes a rule for a waiting room. -func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID string, ruleID string, opts ...option.RequestOption) (res *[]WaitingroomRule, err error) { +func (r *RuleService) Delete(ctx context.Context, waitingRoomID string, ruleID string, params RuleDeleteParams, opts ...option.RequestOption) (res *[]WaitingRoomRule, err error) { opts = append(r.Options[:], opts...) var env RuleDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules/%s", zoneIdentifier, waitingRoomID, ruleID) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules/%s", params.ZoneID, waitingRoomID, ruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -97,11 +98,11 @@ func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, waiting } // Patches a rule for a waiting room. -func (r *RuleService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID string, ruleID string, body RuleEditParams, opts ...option.RequestOption) (res *[]WaitingroomRule, err error) { +func (r *RuleService) Edit(ctx context.Context, waitingRoomID string, ruleID string, params RuleEditParams, opts ...option.RequestOption) (res *[]WaitingRoomRule, err error) { opts = append(r.Options[:], opts...) var env RuleEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules/%s", zoneIdentifier, waitingRoomID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/rules/%s", params.ZoneID, waitingRoomID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) if err != nil { return } @@ -109,11 +110,11 @@ func (r *RuleService) Edit(ctx context.Context, zoneIdentifier string, waitingRo return } -type WaitingroomRule struct { +type WaitingRoomRule struct { // The ID of the rule. ID string `json:"id"` // The action to take when the expression matches. - Action WaitingroomRuleAction `json:"action"` + Action WaitingRoomRuleAction `json:"action"` // The description of the rule. Description string `json:"description"` // When set to true, the rule is enabled. @@ -123,11 +124,11 @@ type WaitingroomRule struct { LastUpdated time.Time `json:"last_updated" format:"date-time"` // The version of the rule. Version string `json:"version"` - JSON waitingroomRuleJSON `json:"-"` + JSON waitingRoomRuleJSON `json:"-"` } -// waitingroomRuleJSON contains the JSON metadata for the struct [WaitingroomRule] -type waitingroomRuleJSON struct { +// waitingRoomRuleJSON contains the JSON metadata for the struct [WaitingRoomRule] +type waitingRoomRuleJSON struct { ID apijson.Field Action apijson.Field Description apijson.Field @@ -139,30 +140,32 @@ type waitingroomRuleJSON struct { ExtraFields map[string]apijson.Field } -func (r *WaitingroomRule) UnmarshalJSON(data []byte) (err error) { +func (r *WaitingRoomRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r waitingroomRuleJSON) RawJSON() string { +func (r waitingRoomRuleJSON) RawJSON() string { return r.raw } // The action to take when the expression matches. -type WaitingroomRuleAction string +type WaitingRoomRuleAction string const ( - WaitingroomRuleActionBypassWaitingRoom WaitingroomRuleAction = "bypass_waiting_room" + WaitingRoomRuleActionBypassWaitingRoom WaitingRoomRuleAction = "bypass_waiting_room" ) -func (r WaitingroomRuleAction) IsKnown() bool { +func (r WaitingRoomRuleAction) IsKnown() bool { switch r { - case WaitingroomRuleActionBypassWaitingRoom: + case WaitingRoomRuleActionBypassWaitingRoom: return true } return false } type RuleNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` // The action to take when the expression matches. Action param.Field[RuleNewParamsAction] `json:"action,required"` // Criteria defining when there is a match for the current rule. @@ -193,9 +196,9 @@ func (r RuleNewParamsAction) IsKnown() bool { } type RuleNewResponseEnvelope struct { - Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingroomRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []WaitingRoomRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo RuleNewResponseEnvelopeResultInfo `json:"result_info"` @@ -222,52 +225,6 @@ func (r ruleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeErrors] -type ruleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleNewResponseEnvelopeMessages] -type ruleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleNewResponseEnvelopeSuccess bool @@ -315,7 +272,9 @@ func (r ruleNewResponseEnvelopeResultInfoJSON) RawJSON() string { } type RuleUpdateParams struct { - Body param.Field[[]RuleUpdateParamsBody] `json:"body,required"` + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Body []RuleUpdateParamsBody `json:"body,required"` } func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { @@ -353,9 +312,9 @@ func (r RuleUpdateParamsBodyAction) IsKnown() bool { } type RuleUpdateResponseEnvelope struct { - Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingroomRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []WaitingRoomRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo RuleUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -382,52 +341,6 @@ func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeErrors] -type ruleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleUpdateResponseEnvelopeMessages] -type ruleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleUpdateResponseEnvelopeSuccess bool @@ -474,10 +387,25 @@ func (r ruleUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { return r.raw } +type RuleListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RuleDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` +} + +func (r RuleDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type RuleDeleteResponseEnvelope struct { - Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingroomRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []WaitingRoomRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo RuleDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -504,52 +432,6 @@ func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeErrors] -type ruleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleDeleteResponseEnvelopeMessages] -type ruleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleDeleteResponseEnvelopeSuccess bool @@ -597,6 +479,8 @@ func (r ruleDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { } type RuleEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` // The action to take when the expression matches. Action param.Field[RuleEditParamsAction] `json:"action,required"` // Criteria defining when there is a match for the current rule. @@ -606,7 +490,7 @@ type RuleEditParams struct { // When set to true, the rule is enabled. Enabled param.Field[bool] `json:"enabled"` // Reorder the position of a rule - Position param.Field[RuleEditParamsPosition] `json:"position"` + Position param.Field[RuleEditParamsPositionUnion] `json:"position"` } func (r RuleEditParams) MarshalJSON() (data []byte, err error) { @@ -628,13 +512,34 @@ func (r RuleEditParamsAction) IsKnown() bool { return false } +// Reorder the position of a rule +type RuleEditParamsPosition struct { + // Places the rule in the exact position specified by the integer number + // . Position numbers start with 1. Existing rules in the ruleset + // from the specified position number onward are shifted one position (no rule is + // overwritten). + Index param.Field[int64] `json:"index"` + // Places the rule before rule . Use this argument with an empty rule ID + // value ("") to set the rule as the first rule in the ruleset. + Before param.Field[string] `json:"before"` + // Places the rule after rule . Use this argument with an empty rule ID + // value ("") to set the rule as the last rule in the ruleset. + After param.Field[string] `json:"after"` +} + +func (r RuleEditParamsPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleEditParamsPosition) implementsWaitingRoomsRuleEditParamsPositionUnion() {} + // Reorder the position of a rule // // Satisfied by [waiting_rooms.RuleEditParamsPositionObject], // [waiting_rooms.RuleEditParamsPositionObject], -// [waiting_rooms.RuleEditParamsPositionObject]. -type RuleEditParamsPosition interface { - implementsWaitingRoomsRuleEditParamsPosition() +// [waiting_rooms.RuleEditParamsPositionObject], [RuleEditParamsPosition]. +type RuleEditParamsPositionUnion interface { + implementsWaitingRoomsRuleEditParamsPositionUnion() } type RuleEditParamsPositionObject struct { @@ -649,12 +554,12 @@ func (r RuleEditParamsPositionObject) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r RuleEditParamsPositionObject) implementsWaitingRoomsRuleEditParamsPosition() {} +func (r RuleEditParamsPositionObject) implementsWaitingRoomsRuleEditParamsPositionUnion() {} type RuleEditResponseEnvelope struct { - Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingroomRule `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []WaitingRoomRule `json:"result,required,nullable"` // Whether the API call was successful Success RuleEditResponseEnvelopeSuccess `json:"success,required"` ResultInfo RuleEditResponseEnvelopeResultInfo `json:"result_info"` @@ -681,52 +586,6 @@ func (r ruleEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type RuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleEditResponseEnvelopeErrors] -type ruleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RuleEditResponseEnvelopeMessages] -type ruleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type RuleEditResponseEnvelopeSuccess bool diff --git a/waiting_rooms/rule_test.go b/waiting_rooms/rule_test.go index e9285daf797..5535ce64dfd 100644 --- a/waiting_rooms/rule_test.go +++ b/waiting_rooms/rule_test.go @@ -30,9 +30,9 @@ func TestRuleNewWithOptionalParams(t *testing.T) { ) _, err := client.WaitingRooms.Rules.New( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", waiting_rooms.RuleNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Action: cloudflare.F(waiting_rooms.RuleNewParamsActionBypassWaitingRoom), Expression: cloudflare.F("ip.src in {10.20.30.40}"), Description: cloudflare.F("allow all traffic from 10.20.30.40"), @@ -64,10 +64,10 @@ func TestRuleUpdate(t *testing.T) { ) _, err := client.WaitingRooms.Rules.Update( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", waiting_rooms.RuleUpdateParams{ - Body: cloudflare.F([]waiting_rooms.RuleUpdateParamsBody{{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: []waiting_rooms.RuleUpdateParamsBody{{ Action: cloudflare.F(waiting_rooms.RuleUpdateParamsBodyActionBypassWaitingRoom), Description: cloudflare.F("allow all traffic from 10.20.30.40"), Enabled: cloudflare.F(true), @@ -82,7 +82,7 @@ func TestRuleUpdate(t *testing.T) { Description: cloudflare.F("allow all traffic from 10.20.30.40"), Enabled: cloudflare.F(true), Expression: cloudflare.F("ip.src in {10.20.30.40}"), - }}), + }}, }, ) if err != nil { @@ -110,8 +110,10 @@ func TestRuleList(t *testing.T) { ) _, err := client.WaitingRooms.Rules.List( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", + waiting_rooms.RuleListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, ) if err != nil { var apierr *cloudflare.Error @@ -138,9 +140,12 @@ func TestRuleDelete(t *testing.T) { ) _, err := client.WaitingRooms.Rules.Delete( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", + waiting_rooms.RuleDeleteParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error @@ -167,17 +172,17 @@ func TestRuleEditWithOptionalParams(t *testing.T) { ) _, err := client.WaitingRooms.Rules.Edit( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", "25756b2dfe6e378a06b033b670413757", waiting_rooms.RuleEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Action: cloudflare.F(waiting_rooms.RuleEditParamsActionBypassWaitingRoom), Expression: cloudflare.F("ip.src in {10.20.30.40}"), Description: cloudflare.F("allow all traffic from 10.20.30.40"), Enabled: cloudflare.F(true), - Position: cloudflare.F[waiting_rooms.RuleEditParamsPosition](waiting_rooms.RuleEditParamsPositionObject(waiting_rooms.RuleEditParamsPositionObject{ + Position: cloudflare.F[waiting_rooms.RuleEditParamsPositionUnion](waiting_rooms.RuleEditParamsPositionObject{ Index: cloudflare.F(int64(0)), - })), + }), }, ) if err != nil { diff --git a/waiting_rooms/setting.go b/waiting_rooms/setting.go index 088e7122567..9f48d707406 100644 --- a/waiting_rooms/setting.go +++ b/waiting_rooms/setting.go @@ -31,11 +31,11 @@ func NewSettingService(opts ...option.RequestOption) (r *SettingService) { } // Update zone-level Waiting Room settings -func (r *SettingService) Update(ctx context.Context, zoneIdentifier string, body SettingUpdateParams, opts ...option.RequestOption) (res *SettingUpdateResponse, err error) { +func (r *SettingService) Update(ctx context.Context, params SettingUpdateParams, opts ...option.RequestOption) (res *SettingUpdateResponse, err error) { opts = append(r.Options[:], opts...) var env SettingUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/settings", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return } @@ -44,11 +44,11 @@ func (r *SettingService) Update(ctx context.Context, zoneIdentifier string, body } // Patch zone-level Waiting Room settings -func (r *SettingService) Edit(ctx context.Context, zoneIdentifier string, body SettingEditParams, opts ...option.RequestOption) (res *SettingEditResponse, err error) { +func (r *SettingService) Edit(ctx context.Context, params SettingEditParams, opts ...option.RequestOption) (res *SettingEditResponse, err error) { opts = append(r.Options[:], opts...) var env SettingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/settings", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) if err != nil { return } @@ -57,10 +57,10 @@ func (r *SettingService) Edit(ctx context.Context, zoneIdentifier string, body S } // Get zone-level Waiting Room settings -func (r *SettingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *SettingGetResponse, err error) { +func (r *SettingService) Get(ctx context.Context, query SettingGetParams, opts ...option.RequestOption) (res *SettingGetResponse, err error) { opts = append(r.Options[:], opts...) var env SettingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) + path := fmt.Sprintf("zones/%s/waiting_rooms/settings", query.ZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -69,6 +69,29 @@ func (r *SettingService) Get(ctx context.Context, zoneIdentifier string, opts .. return } +type Setting struct { + // Whether to allow verified search engine crawlers to bypass all waiting rooms on + // this zone. Verified search engine crawlers will not be tracked or counted by the + // waiting room system, and will not appear in waiting room analytics. + SearchEngineCrawlerBypass bool `json:"search_engine_crawler_bypass,required"` + JSON settingJSON `json:"-"` +} + +// settingJSON contains the JSON metadata for the struct [Setting] +type settingJSON struct { + SearchEngineCrawlerBypass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Setting) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingJSON) RawJSON() string { + return r.raw +} + type SettingUpdateResponse struct { // Whether to allow verified search engine crawlers to bypass all waiting rooms on // this zone. Verified search engine crawlers will not be tracked or counted by the @@ -142,6 +165,8 @@ func (r settingGetResponseJSON) RawJSON() string { } type SettingUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` // Whether to allow verified search engine crawlers to bypass all waiting rooms on // this zone. Verified search engine crawlers will not be tracked or counted by the // waiting room system, and will not appear in waiting room analytics. @@ -153,14 +178,20 @@ func (r SettingUpdateParams) MarshalJSON() (data []byte, err error) { } type SettingUpdateResponseEnvelope struct { - Result SettingUpdateResponse `json:"result,required"` - JSON settingUpdateResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result SettingUpdateResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON settingUpdateResponseEnvelopeJSON `json:"-"` } // settingUpdateResponseEnvelopeJSON contains the JSON metadata for the struct // [SettingUpdateResponseEnvelope] type settingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -174,6 +205,8 @@ func (r settingUpdateResponseEnvelopeJSON) RawJSON() string { } type SettingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` // Whether to allow verified search engine crawlers to bypass all waiting rooms on // this zone. Verified search engine crawlers will not be tracked or counted by the // waiting room system, and will not appear in waiting room analytics. @@ -185,14 +218,20 @@ func (r SettingEditParams) MarshalJSON() (data []byte, err error) { } type SettingEditResponseEnvelope struct { - Result SettingEditResponse `json:"result,required"` - JSON settingEditResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result SettingEditResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON settingEditResponseEnvelopeJSON `json:"-"` } // settingEditResponseEnvelopeJSON contains the JSON metadata for the struct // [SettingEditResponseEnvelope] type settingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -205,15 +244,26 @@ func (r settingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } +type SettingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + type SettingGetResponseEnvelope struct { - Result SettingGetResponse `json:"result,required"` - JSON settingGetResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result SettingGetResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON settingGetResponseEnvelopeJSON `json:"-"` } // settingGetResponseEnvelopeJSON contains the JSON metadata for the struct // [SettingGetResponseEnvelope] type settingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/waiting_rooms/setting_test.go b/waiting_rooms/setting_test.go index 863bd50b000..08788935bdb 100644 --- a/waiting_rooms/setting_test.go +++ b/waiting_rooms/setting_test.go @@ -28,13 +28,10 @@ func TestSettingUpdateWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WaitingRooms.Settings.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - waiting_rooms.SettingUpdateParams{ - SearchEngineCrawlerBypass: cloudflare.F(true), - }, - ) + _, err := client.WaitingRooms.Settings.Update(context.TODO(), waiting_rooms.SettingUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + SearchEngineCrawlerBypass: cloudflare.F(true), + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -58,13 +55,10 @@ func TestSettingEditWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WaitingRooms.Settings.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - waiting_rooms.SettingEditParams{ - SearchEngineCrawlerBypass: cloudflare.F(true), - }, - ) + _, err := client.WaitingRooms.Settings.Edit(context.TODO(), waiting_rooms.SettingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + SearchEngineCrawlerBypass: cloudflare.F(true), + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -88,7 +82,9 @@ func TestSettingGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WaitingRooms.Settings.Get(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + _, err := client.WaitingRooms.Settings.Get(context.TODO(), waiting_rooms.SettingGetParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/waiting_rooms/status.go b/waiting_rooms/status.go index a008a3bb0c6..f16460b1566 100644 --- a/waiting_rooms/status.go +++ b/waiting_rooms/status.go @@ -8,6 +8,7 @@ import ( "net/http" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -47,10 +48,10 @@ func NewStatusService(opts ...option.RequestOption) (r *StatusService) { // currently active on the origin. // 5. `max_estimated_time_minutes`: Integer of the maximum estimated time currently // presented to the users. -func (r *StatusService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID string, opts ...option.RequestOption) (res *StatusGetResponse, err error) { +func (r *StatusService) Get(ctx context.Context, waitingRoomID string, query StatusGetParams, opts ...option.RequestOption) (res *StatusGetResponse, err error) { opts = append(r.Options[:], opts...) var env StatusGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s/status", zoneIdentifier, waitingRoomID) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s/status", query.ZoneID, waitingRoomID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -104,15 +105,26 @@ func (r StatusGetResponseStatus) IsKnown() bool { return false } +type StatusGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + type StatusGetResponseEnvelope struct { - Result StatusGetResponse `json:"result,required"` - JSON statusGetResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result StatusGetResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON statusGetResponseEnvelopeJSON `json:"-"` } // statusGetResponseEnvelopeJSON contains the JSON metadata for the struct // [StatusGetResponseEnvelope] type statusGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/waiting_rooms/status_test.go b/waiting_rooms/status_test.go index ea498bc5815..5bb98a83189 100644 --- a/waiting_rooms/status_test.go +++ b/waiting_rooms/status_test.go @@ -11,6 +11,7 @@ import ( "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/waiting_rooms" ) func TestStatusGet(t *testing.T) { @@ -29,8 +30,10 @@ func TestStatusGet(t *testing.T) { ) _, err := client.WaitingRooms.Statuses.Get( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", + waiting_rooms.StatusGetParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/waiting_rooms/waitingroom.go b/waiting_rooms/waitingroom.go index a594229800c..164249c28af 100644 --- a/waiting_rooms/waitingroom.go +++ b/waiting_rooms/waitingroom.go @@ -6,9 +6,11 @@ import ( "context" "fmt" "net/http" + "net/url" "time" "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" @@ -44,11 +46,11 @@ func NewWaitingRoomService(opts ...option.RequestOption) (r *WaitingRoomService) } // Creates a new waiting room. -func (r *WaitingRoomService) New(ctx context.Context, zoneIdentifier string, body WaitingRoomNewParams, opts ...option.RequestOption) (res *WaitingRoom, err error) { +func (r *WaitingRoomService) New(ctx context.Context, params WaitingRoomNewParams, opts ...option.RequestOption) (res *WaitingRoom, err error) { opts = append(r.Options[:], opts...) var env WaitingRoomNewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return } @@ -57,11 +59,11 @@ func (r *WaitingRoomService) New(ctx context.Context, zoneIdentifier string, bod } // Updates a configured waiting room. -func (r *WaitingRoomService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID string, body WaitingRoomUpdateParams, opts ...option.RequestOption) (res *WaitingRoom, err error) { +func (r *WaitingRoomService) Update(ctx context.Context, waitingRoomID string, params WaitingRoomUpdateParams, opts ...option.RequestOption) (res *WaitingRoom, err error) { opts = append(r.Options[:], opts...) var env WaitingRoomUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s", params.ZoneID, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return } @@ -70,12 +72,12 @@ func (r *WaitingRoomService) Update(ctx context.Context, zoneIdentifier string, } // Lists waiting rooms. -func (r *WaitingRoomService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[WaitingRoom], err error) { +func (r *WaitingRoomService) List(ctx context.Context, params WaitingRoomListParams, opts ...option.RequestOption) (res *pagination.SinglePage[WaitingRoom], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/waiting_rooms", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms", params.ZoneID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) if err != nil { return nil, err } @@ -88,15 +90,15 @@ func (r *WaitingRoomService) List(ctx context.Context, zoneIdentifier string, op } // Lists waiting rooms. -func (r *WaitingRoomService) ListAutoPaging(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WaitingRoom] { - return pagination.NewSinglePageAutoPager(r.List(ctx, zoneIdentifier, opts...)) +func (r *WaitingRoomService) ListAutoPaging(ctx context.Context, params WaitingRoomListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WaitingRoom] { + return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...)) } // Deletes a waiting room. -func (r *WaitingRoomService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID string, opts ...option.RequestOption) (res *WaitingRoomDeleteResponse, err error) { +func (r *WaitingRoomService) Delete(ctx context.Context, waitingRoomID string, params WaitingRoomDeleteParams, opts ...option.RequestOption) (res *WaitingRoomDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env WaitingRoomDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s", zoneIdentifier, waitingRoomID) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s", params.ZoneID, waitingRoomID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -106,11 +108,11 @@ func (r *WaitingRoomService) Delete(ctx context.Context, zoneIdentifier string, } // Patches a configured waiting room. -func (r *WaitingRoomService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID string, body WaitingRoomEditParams, opts ...option.RequestOption) (res *WaitingRoom, err error) { +func (r *WaitingRoomService) Edit(ctx context.Context, waitingRoomID string, params WaitingRoomEditParams, opts ...option.RequestOption) (res *WaitingRoom, err error) { opts = append(r.Options[:], opts...) var env WaitingRoomEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s", params.ZoneID, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) if err != nil { return } @@ -119,10 +121,10 @@ func (r *WaitingRoomService) Edit(ctx context.Context, zoneIdentifier string, wa } // Fetches a single configured waiting room. -func (r *WaitingRoomService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID string, opts ...option.RequestOption) (res *WaitingRoom, err error) { +func (r *WaitingRoomService) Get(ctx context.Context, waitingRoomID string, query WaitingRoomGetParams, opts ...option.RequestOption) (res *WaitingRoom, err error) { opts = append(r.Options[:], opts...) var env WaitingRoomGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%s", zoneIdentifier, waitingRoomID) + path := fmt.Sprintf("zones/%s/waiting_rooms/%s", query.ZoneID, waitingRoomID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -131,21 +133,177 @@ func (r *WaitingRoomService) Get(ctx context.Context, zoneIdentifier string, wai return } -type WaitingRoom struct { - ID string `json:"id"` +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://). + Host string `json:"host"` + // Sets the path within the host to enable the waiting room on. The waiting room + // 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 additionalRoutesJSON `json:"-"` +} + +// 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 *AdditionalRoutes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r additionalRoutesJSON) RawJSON() string { + return r.raw +} + +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://). + Host param.Field[string] `json:"host"` + // Sets the path within the host to enable the waiting room on. The waiting room + // 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 param.Field[string] `json:"path"` +} + +func (r AdditionalRoutesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures cookie attributes for the waiting room cookie. This encrypted cookie +// stores a user's status in the waiting room, such as queue position. +type CookieAttributes struct { + // Configures the SameSite attribute on the waiting room cookie. Value `auto` will + // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. + // Note that when using value `none`, the secure attribute cannot be set to + // `never`. + Samesite CookieAttributesSamesite `json:"samesite"` + // Configures the Secure attribute on the waiting room cookie. Value `always` + // indicates that the Secure attribute will be set in the Set-Cookie header, + // `never` indicates that the Secure attribute will not be set, and `auto` will set + // the Secure attribute depending if **Always Use HTTPS** is enabled. + Secure CookieAttributesSecure `json:"secure"` + JSON cookieAttributesJSON `json:"-"` +} + +// cookieAttributesJSON contains the JSON metadata for the struct +// [CookieAttributes] +type cookieAttributesJSON struct { + Samesite apijson.Field + Secure apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CookieAttributes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cookieAttributesJSON) RawJSON() string { + return r.raw +} + +// Configures the SameSite attribute on the waiting room cookie. Value `auto` will +// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. +// Note that when using value `none`, the secure attribute cannot be set to +// `never`. +type CookieAttributesSamesite string + +const ( + CookieAttributesSamesiteAuto CookieAttributesSamesite = "auto" + CookieAttributesSamesiteLax CookieAttributesSamesite = "lax" + CookieAttributesSamesiteNone CookieAttributesSamesite = "none" + CookieAttributesSamesiteStrict CookieAttributesSamesite = "strict" +) + +func (r CookieAttributesSamesite) IsKnown() bool { + switch r { + case CookieAttributesSamesiteAuto, CookieAttributesSamesiteLax, CookieAttributesSamesiteNone, CookieAttributesSamesiteStrict: + return true + } + return false +} + +// Configures the Secure attribute on the waiting room cookie. Value `always` +// indicates that the Secure attribute will be set in the Set-Cookie header, +// `never` indicates that the Secure attribute will not be set, and `auto` will set +// the Secure attribute depending if **Always Use HTTPS** is enabled. +type CookieAttributesSecure string + +const ( + CookieAttributesSecureAuto CookieAttributesSecure = "auto" + CookieAttributesSecureAlways CookieAttributesSecure = "always" + CookieAttributesSecureNever CookieAttributesSecure = "never" +) + +func (r CookieAttributesSecure) IsKnown() bool { + switch r { + case CookieAttributesSecureAuto, CookieAttributesSecureAlways, CookieAttributesSecureNever: + return true + } + return false +} + +// Configures cookie attributes for the waiting room cookie. This encrypted cookie +// stores a user's status in the waiting room, such as queue position. +type CookieAttributesParam struct { + // Configures the SameSite attribute on the waiting room cookie. Value `auto` will + // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. + // Note that when using value `none`, the secure attribute cannot be set to + // `never`. + Samesite param.Field[CookieAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on the waiting room cookie. Value `always` + // indicates that the Secure attribute will be set in the Set-Cookie header, + // `never` indicates that the Secure attribute will not be set, and `auto` will set + // the Secure attribute depending if **Always Use HTTPS** is enabled. + Secure param.Field[CookieAttributesSecure] `json:"secure"` +} + +func (r CookieAttributesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type QueryParam struct { + // The host name to which the waiting room will be applied (no wildcards). Please + // do not include the scheme (http:// or https://). The host and path combination + // must be unique. + Host param.Field[string] `json:"host,required"` + // A unique name to identify the waiting room. Only alphanumeric characters, + // hyphens and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // Sets the number of new users that will be let into the route every minute. This + // value is used as baseline for the number of users that are let in per minute. So + // it is possible that there is a little more or little less traffic coming to the + // route based on the traffic patterns at that time around the world. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` + // Sets the total number of active user sessions on the route at a point in time. A + // route is a combination of host and path on which a waiting room is available. + // This value is used as a baseline for the total number of active user sessions on + // the route. It is possible to have a situation where there are more or less + // active users sessions on the route based on the traffic patterns at that time + // around the world. + TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` // Only available for the Waiting Room Advanced subscription. Additional hostname // 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 []WaitingRoomAdditionalRoute `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 WaitingRoomCookieAttributes `json:"cookie_attributes"` + CookieAttributes param.Field[CookieAttributesParam] `json:"cookie_attributes"` // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix string `json:"cookie_suffix"` - CreatedOn time.Time `json:"created_on" format:"date-time"` + CookieSuffix param.Field[string] `json:"cookie_suffix"` // Only available for the Waiting Room Advanced subscription. This is a template // html file that will be rendered at the edge. If no custom_page_html is provided, // the default waiting room will be used. The template is based on mustache ( @@ -167,22 +325,18 @@ type WaitingRoom struct { // // To view the full list of variables, look at the `cfWaitingRoom` object described // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML string `json:"custom_page_html"` + CustomPageHTML param.Field[string] `json:"custom_page_html"` // The language of the default page template. If no default_template_language is // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage WaitingRoomDefaultTemplateLanguage `json:"default_template_language"` + DefaultTemplateLanguage param.Field[QueryDefaultTemplateLanguage] `json:"default_template_language"` // A note that you can use to add more details about the waiting room. - Description string `json:"description"` + Description param.Field[string] `json:"description"` // Only available for the Waiting Room Advanced subscription. Disables automatic // renewal of session cookies. If `true`, an accepted user will have // session_duration minutes to browse the site. After that, they will have to go // through the waiting room again. If `false`, a user's session cookie will be // automatically renewed on every request. - DisableSessionRenewal bool `json:"disable_session_renewal"` - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host string `json:"host"` + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` // Only available for the Waiting Room Advanced subscription. If `true`, requests // to the waiting room with the header `Accept: application/json` will receive a // JSON response object with information on the user's status in the waiting room @@ -328,29 +482,16 @@ type WaitingRoom struct { // "shuffleAtEventStart": true // } // }. - JsonResponseEnabled bool `json:"json_response_enabled"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name string `json:"name"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute int64 `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when the next event will begin queueing. - NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` - // An ISO 8601 timestamp that marks when the next event will start. - NextEventStartTime string `json:"next_event_start_time,nullable"` + JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` // Sets the path within the host to enable the waiting room on. The waiting room // 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"` + Path param.Field[string] `json:"path"` // If queue_all is `true`, all the traffic that is coming to a route will be sent // to the waiting room. No new traffic can get to the route once this field is set // and estimated time will become unavailable. - QueueAll bool `json:"queue_all"` + QueueAll param.Field[bool] `json:"queue_all"` // Sets the queueing method used by the waiting room. Changing this parameter from // the **default** queueing method is only available for the Waiting Room Advanced // subscription. Regardless of the queueing method, if `queue_all` is enabled or an @@ -378,313 +519,130 @@ type WaitingRoom struct { // events override this with `fifo`, `random`, or `passthrough`. When this // queueing method is enabled and neither `queueAll` is enabled nor an event is // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod WaitingRoomQueueingMethod `json:"queueing_method"` + QueueingMethod param.Field[QueryQueueingMethod] `json:"queueing_method"` // HTTP status code returned to a user while in the queue. - QueueingStatusCode WaitingRoomQueueingStatusCode `json:"queueing_status_code"` + QueueingStatusCode param.Field[QueryQueueingStatusCode] `json:"queueing_status_code"` // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to // the route. If a user is not seen by Cloudflare again in that time period, they // will be treated as a new user that visits the route. - SessionDuration int64 `json:"session_duration"` + SessionDuration param.Field[int64] `json:"session_duration"` // Suspends or allows traffic going to the waiting room. If set to `true`, the // traffic will not go to the waiting room. - Suspended bool `json:"suspended"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingRoomJSON `json:"-"` -} - -// waitingRoomJSON contains the JSON metadata for the struct [WaitingRoom] -type waitingRoomJSON struct { - ID apijson.Field - AdditionalRoutes apijson.Field - CookieAttributes apijson.Field - CookieSuffix apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - DefaultTemplateLanguage apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - Host apijson.Field - JsonResponseEnabled apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - NextEventPrequeueStartTime apijson.Field - NextEventStartTime apijson.Field - Path apijson.Field - QueueAll apijson.Field - QueueingMethod apijson.Field - QueueingStatusCode apijson.Field - SessionDuration apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field + Suspended param.Field[bool] `json:"suspended"` } -func (r *WaitingRoom) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r QueryParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r waitingRoomJSON) RawJSON() string { - return r.raw -} +// The language of the default page template. If no default_template_language is +// provided, then `en-US` (English) will be used. +type QueryDefaultTemplateLanguage string -type WaitingRoomAdditionalRoute 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://). - Host string `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // 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 waitingRoomAdditionalRouteJSON `json:"-"` -} +const ( + QueryDefaultTemplateLanguageEnUs QueryDefaultTemplateLanguage = "en-US" + QueryDefaultTemplateLanguageEsEs QueryDefaultTemplateLanguage = "es-ES" + QueryDefaultTemplateLanguageDeDe QueryDefaultTemplateLanguage = "de-DE" + QueryDefaultTemplateLanguageFrFr QueryDefaultTemplateLanguage = "fr-FR" + QueryDefaultTemplateLanguageItIt QueryDefaultTemplateLanguage = "it-IT" + QueryDefaultTemplateLanguageJaJp QueryDefaultTemplateLanguage = "ja-JP" + QueryDefaultTemplateLanguageKoKr QueryDefaultTemplateLanguage = "ko-KR" + QueryDefaultTemplateLanguagePtBr QueryDefaultTemplateLanguage = "pt-BR" + QueryDefaultTemplateLanguageZhCn QueryDefaultTemplateLanguage = "zh-CN" + QueryDefaultTemplateLanguageZhTw QueryDefaultTemplateLanguage = "zh-TW" + QueryDefaultTemplateLanguageNlNl QueryDefaultTemplateLanguage = "nl-NL" + QueryDefaultTemplateLanguagePlPl QueryDefaultTemplateLanguage = "pl-PL" + QueryDefaultTemplateLanguageIDID QueryDefaultTemplateLanguage = "id-ID" + QueryDefaultTemplateLanguageTrTr QueryDefaultTemplateLanguage = "tr-TR" + QueryDefaultTemplateLanguageArEg QueryDefaultTemplateLanguage = "ar-EG" + QueryDefaultTemplateLanguageRuRu QueryDefaultTemplateLanguage = "ru-RU" + QueryDefaultTemplateLanguageFaIr QueryDefaultTemplateLanguage = "fa-IR" +) -// waitingRoomAdditionalRouteJSON contains the JSON metadata for the struct -// [WaitingRoomAdditionalRoute] -type waitingRoomAdditionalRouteJSON struct { - Host apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r QueryDefaultTemplateLanguage) IsKnown() bool { + switch r { + case QueryDefaultTemplateLanguageEnUs, QueryDefaultTemplateLanguageEsEs, QueryDefaultTemplateLanguageDeDe, QueryDefaultTemplateLanguageFrFr, QueryDefaultTemplateLanguageItIt, QueryDefaultTemplateLanguageJaJp, QueryDefaultTemplateLanguageKoKr, QueryDefaultTemplateLanguagePtBr, QueryDefaultTemplateLanguageZhCn, QueryDefaultTemplateLanguageZhTw, QueryDefaultTemplateLanguageNlNl, QueryDefaultTemplateLanguagePlPl, QueryDefaultTemplateLanguageIDID, QueryDefaultTemplateLanguageTrTr, QueryDefaultTemplateLanguageArEg, QueryDefaultTemplateLanguageRuRu, QueryDefaultTemplateLanguageFaIr: + return true + } + return false } -func (r *WaitingRoomAdditionalRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomAdditionalRouteJSON) RawJSON() string { - return r.raw -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite WaitingRoomCookieAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure WaitingRoomCookieAttributesSecure `json:"secure"` - JSON waitingRoomCookieAttributesJSON `json:"-"` -} - -// waitingRoomCookieAttributesJSON contains the JSON metadata for the struct -// [WaitingRoomCookieAttributes] -type waitingRoomCookieAttributesJSON struct { - Samesite apijson.Field - Secure apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomCookieAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomCookieAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomCookieAttributesSamesite string - -const ( - WaitingRoomCookieAttributesSamesiteAuto WaitingRoomCookieAttributesSamesite = "auto" - WaitingRoomCookieAttributesSamesiteLax WaitingRoomCookieAttributesSamesite = "lax" - WaitingRoomCookieAttributesSamesiteNone WaitingRoomCookieAttributesSamesite = "none" - WaitingRoomCookieAttributesSamesiteStrict WaitingRoomCookieAttributesSamesite = "strict" -) - -func (r WaitingRoomCookieAttributesSamesite) IsKnown() bool { - switch r { - case WaitingRoomCookieAttributesSamesiteAuto, WaitingRoomCookieAttributesSamesiteLax, WaitingRoomCookieAttributesSamesiteNone, WaitingRoomCookieAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomCookieAttributesSecure string - -const ( - WaitingRoomCookieAttributesSecureAuto WaitingRoomCookieAttributesSecure = "auto" - WaitingRoomCookieAttributesSecureAlways WaitingRoomCookieAttributesSecure = "always" - WaitingRoomCookieAttributesSecureNever WaitingRoomCookieAttributesSecure = "never" -) - -func (r WaitingRoomCookieAttributesSecure) IsKnown() bool { - switch r { - case WaitingRoomCookieAttributesSecureAuto, WaitingRoomCookieAttributesSecureAlways, WaitingRoomCookieAttributesSecureNever: - return true - } - return false -} - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomDefaultTemplateLanguage string - -const ( - WaitingRoomDefaultTemplateLanguageEnUs WaitingRoomDefaultTemplateLanguage = "en-US" - WaitingRoomDefaultTemplateLanguageEsEs WaitingRoomDefaultTemplateLanguage = "es-ES" - WaitingRoomDefaultTemplateLanguageDeDe WaitingRoomDefaultTemplateLanguage = "de-DE" - WaitingRoomDefaultTemplateLanguageFrFr WaitingRoomDefaultTemplateLanguage = "fr-FR" - WaitingRoomDefaultTemplateLanguageItIt WaitingRoomDefaultTemplateLanguage = "it-IT" - WaitingRoomDefaultTemplateLanguageJaJp WaitingRoomDefaultTemplateLanguage = "ja-JP" - WaitingRoomDefaultTemplateLanguageKoKr WaitingRoomDefaultTemplateLanguage = "ko-KR" - WaitingRoomDefaultTemplateLanguagePtBr WaitingRoomDefaultTemplateLanguage = "pt-BR" - WaitingRoomDefaultTemplateLanguageZhCn WaitingRoomDefaultTemplateLanguage = "zh-CN" - WaitingRoomDefaultTemplateLanguageZhTw WaitingRoomDefaultTemplateLanguage = "zh-TW" - WaitingRoomDefaultTemplateLanguageNlNl WaitingRoomDefaultTemplateLanguage = "nl-NL" - WaitingRoomDefaultTemplateLanguagePlPl WaitingRoomDefaultTemplateLanguage = "pl-PL" - WaitingRoomDefaultTemplateLanguageIDID WaitingRoomDefaultTemplateLanguage = "id-ID" - WaitingRoomDefaultTemplateLanguageTrTr WaitingRoomDefaultTemplateLanguage = "tr-TR" - WaitingRoomDefaultTemplateLanguageArEg WaitingRoomDefaultTemplateLanguage = "ar-EG" - WaitingRoomDefaultTemplateLanguageRuRu WaitingRoomDefaultTemplateLanguage = "ru-RU" - WaitingRoomDefaultTemplateLanguageFaIr WaitingRoomDefaultTemplateLanguage = "fa-IR" -) - -func (r WaitingRoomDefaultTemplateLanguage) IsKnown() bool { - switch r { - case WaitingRoomDefaultTemplateLanguageEnUs, WaitingRoomDefaultTemplateLanguageEsEs, WaitingRoomDefaultTemplateLanguageDeDe, WaitingRoomDefaultTemplateLanguageFrFr, WaitingRoomDefaultTemplateLanguageItIt, WaitingRoomDefaultTemplateLanguageJaJp, WaitingRoomDefaultTemplateLanguageKoKr, WaitingRoomDefaultTemplateLanguagePtBr, WaitingRoomDefaultTemplateLanguageZhCn, WaitingRoomDefaultTemplateLanguageZhTw, WaitingRoomDefaultTemplateLanguageNlNl, WaitingRoomDefaultTemplateLanguagePlPl, WaitingRoomDefaultTemplateLanguageIDID, WaitingRoomDefaultTemplateLanguageTrTr, WaitingRoomDefaultTemplateLanguageArEg, WaitingRoomDefaultTemplateLanguageRuRu, WaitingRoomDefaultTemplateLanguageFaIr: - return true - } - return false -} - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomQueueingMethod string +// Sets the queueing method used by the waiting room. Changing this parameter from +// the **default** queueing method is only available for the Waiting Room Advanced +// subscription. Regardless of the queueing method, if `queue_all` is enabled or an +// event is prequeueing, users in the waiting room will not be accepted to the +// origin. These users will always see a waiting room page that refreshes +// automatically. The valid queueing methods are: +// +// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in +// the order they arrived. +// 2. `random`: Random queue where customers gain access randomly, regardless of +// arrival time. +// 3. `passthrough`: Users will pass directly through the waiting room and into the +// origin website. As a result, any configured limits will not be respected +// while this is enabled. This method can be used as an alternative to disabling +// a waiting room (with `suspended`) so that analytics are still reported. This +// can be used if you wish to allow all traffic normally, but want to restrict +// traffic during a waiting room event, or vice versa. +// 4. `reject`: Users will be immediately rejected from the waiting room. As a +// result, no users will reach the origin website while this is enabled. This +// can be used if you wish to reject all traffic while performing maintenance, +// block traffic during a specified period of time (an event), or block traffic +// while events are not occurring. Consider a waiting room used for vaccine +// distribution that only allows traffic during sign-up events, and otherwise +// blocks all traffic. For this case, the waiting room uses `reject`, and its +// events override this with `fifo`, `random`, or `passthrough`. When this +// queueing method is enabled and neither `queueAll` is enabled nor an event is +// prequeueing, the waiting room page **will not refresh automatically**. +type QueryQueueingMethod string const ( - WaitingRoomQueueingMethodFifo WaitingRoomQueueingMethod = "fifo" - WaitingRoomQueueingMethodRandom WaitingRoomQueueingMethod = "random" - WaitingRoomQueueingMethodPassthrough WaitingRoomQueueingMethod = "passthrough" - WaitingRoomQueueingMethodReject WaitingRoomQueueingMethod = "reject" + QueryQueueingMethodFifo QueryQueueingMethod = "fifo" + QueryQueueingMethodRandom QueryQueueingMethod = "random" + QueryQueueingMethodPassthrough QueryQueueingMethod = "passthrough" + QueryQueueingMethodReject QueryQueueingMethod = "reject" ) -func (r WaitingRoomQueueingMethod) IsKnown() bool { +func (r QueryQueueingMethod) IsKnown() bool { switch r { - case WaitingRoomQueueingMethodFifo, WaitingRoomQueueingMethodRandom, WaitingRoomQueueingMethodPassthrough, WaitingRoomQueueingMethodReject: + case QueryQueueingMethodFifo, QueryQueueingMethodRandom, QueryQueueingMethodPassthrough, QueryQueueingMethodReject: return true } return false } // HTTP status code returned to a user while in the queue. -type WaitingRoomQueueingStatusCode int64 +type QueryQueueingStatusCode int64 const ( - WaitingRoomQueueingStatusCode200 WaitingRoomQueueingStatusCode = 200 - WaitingRoomQueueingStatusCode202 WaitingRoomQueueingStatusCode = 202 - WaitingRoomQueueingStatusCode429 WaitingRoomQueueingStatusCode = 429 + QueryQueueingStatusCode200 QueryQueueingStatusCode = 200 + QueryQueueingStatusCode202 QueryQueueingStatusCode = 202 + QueryQueueingStatusCode429 QueryQueueingStatusCode = 429 ) -func (r WaitingRoomQueueingStatusCode) IsKnown() bool { +func (r QueryQueueingStatusCode) IsKnown() bool { switch r { - case WaitingRoomQueueingStatusCode200, WaitingRoomQueueingStatusCode202, WaitingRoomQueueingStatusCode429: + case QueryQueueingStatusCode200, QueryQueueingStatusCode202, QueryQueueingStatusCode429: return true } return false } -type WaitingRoomDeleteResponse struct { - ID string `json:"id"` - JSON waitingRoomDeleteResponseJSON `json:"-"` -} - -// waitingRoomDeleteResponseJSON contains the JSON metadata for the struct -// [WaitingRoomDeleteResponse] -type waitingRoomDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomNewParams struct { - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host param.Field[string] `json:"host,required"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` +type WaitingRoom struct { + ID string `json:"id"` // Only available for the Waiting Room Advanced subscription. Additional hostname // 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[[]WaitingRoomNewParamsAdditionalRoute] `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 param.Field[WaitingRoomNewParamsCookieAttributes] `json:"cookie_attributes"` + CookieAttributes CookieAttributes `json:"cookie_attributes"` // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix param.Field[string] `json:"cookie_suffix"` + CookieSuffix string `json:"cookie_suffix"` + CreatedOn time.Time `json:"created_on" format:"date-time"` // Only available for the Waiting Room Advanced subscription. This is a template // html file that will be rendered at the edge. If no custom_page_html is provided, // the default waiting room will be used. The template is based on mustache ( @@ -706,18 +664,22 @@ type WaitingRoomNewParams struct { // // To view the full list of variables, look at the `cfWaitingRoom` object described // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML param.Field[string] `json:"custom_page_html"` + CustomPageHTML string `json:"custom_page_html"` // The language of the default page template. If no default_template_language is // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage param.Field[WaitingRoomNewParamsDefaultTemplateLanguage] `json:"default_template_language"` + DefaultTemplateLanguage WaitingRoomDefaultTemplateLanguage `json:"default_template_language"` // A note that you can use to add more details about the waiting room. - Description param.Field[string] `json:"description"` + Description string `json:"description"` // Only available for the Waiting Room Advanced subscription. Disables automatic // renewal of session cookies. If `true`, an accepted user will have // session_duration minutes to browse the site. After that, they will have to go // through the waiting room again. If `false`, a user's session cookie will be // automatically renewed on every request. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + DisableSessionRenewal bool `json:"disable_session_renewal"` + // The host name to which the waiting room will be applied (no wildcards). Please + // do not include the scheme (http:// or https://). The host and path combination + // must be unique. + Host string `json:"host"` // Only available for the Waiting Room Advanced subscription. If `true`, requests // to the waiting room with the header `Accept: application/json` will receive a // JSON response object with information on the user's status in the waiting room @@ -863,16 +825,29 @@ type WaitingRoomNewParams struct { // "shuffleAtEventStart": true // } // }. - JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` + JsonResponseEnabled bool `json:"json_response_enabled"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // A unique name to identify the waiting room. Only alphanumeric characters, + // hyphens and underscores are allowed. + Name string `json:"name"` + // Sets the number of new users that will be let into the route every minute. This + // value is used as baseline for the number of users that are let in per minute. So + // it is possible that there is a little more or little less traffic coming to the + // route based on the traffic patterns at that time around the world. + NewUsersPerMinute int64 `json:"new_users_per_minute"` + // An ISO 8601 timestamp that marks when the next event will begin queueing. + NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` + // An ISO 8601 timestamp that marks when the next event will start. + NextEventStartTime string `json:"next_event_start_time,nullable"` // Sets the path within the host to enable the waiting room on. The waiting room // 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 param.Field[string] `json:"path"` + Path string `json:"path"` // If queue_all is `true`, all the traffic that is coming to a route will be sent // to the waiting room. No new traffic can get to the route once this field is set // and estimated time will become unavailable. - QueueAll param.Field[bool] `json:"queue_all"` + QueueAll bool `json:"queue_all"` // Sets the queueing method used by the waiting room. Changing this parameter from // the **default** queueing method is only available for the Waiting Room Advanced // subscription. Regardless of the queueing method, if `queue_all` is enabled or an @@ -900,125 +875,90 @@ type WaitingRoomNewParams struct { // events override this with `fifo`, `random`, or `passthrough`. When this // queueing method is enabled and neither `queueAll` is enabled nor an event is // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod param.Field[WaitingRoomNewParamsQueueingMethod] `json:"queueing_method"` + QueueingMethod WaitingRoomQueueingMethod `json:"queueing_method"` // HTTP status code returned to a user while in the queue. - QueueingStatusCode param.Field[WaitingRoomNewParamsQueueingStatusCode] `json:"queueing_status_code"` + QueueingStatusCode WaitingRoomQueueingStatusCode `json:"queueing_status_code"` // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to // the route. If a user is not seen by Cloudflare again in that time period, they // will be treated as a new user that visits the route. - SessionDuration param.Field[int64] `json:"session_duration"` + SessionDuration int64 `json:"session_duration"` // Suspends or allows traffic going to the waiting room. If set to `true`, the // traffic will not go to the waiting room. - Suspended param.Field[bool] `json:"suspended"` + Suspended bool `json:"suspended"` + // Sets the total number of active user sessions on the route at a point in time. A + // route is a combination of host and path on which a waiting room is available. + // This value is used as a baseline for the total number of active user sessions on + // the route. It is possible to have a situation where there are more or less + // active users sessions on the route based on the traffic patterns at that time + // around the world. + TotalActiveUsers int64 `json:"total_active_users"` + JSON waitingRoomJSON `json:"-"` } -func (r WaitingRoomNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// waitingRoomJSON contains the JSON metadata for the struct [WaitingRoom] +type waitingRoomJSON struct { + ID apijson.Field + AdditionalRoutes apijson.Field + CookieAttributes apijson.Field + CookieSuffix apijson.Field + CreatedOn apijson.Field + CustomPageHTML apijson.Field + DefaultTemplateLanguage apijson.Field + Description apijson.Field + DisableSessionRenewal apijson.Field + Host apijson.Field + JsonResponseEnabled apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + NewUsersPerMinute apijson.Field + NextEventPrequeueStartTime apijson.Field + NextEventStartTime apijson.Field + Path apijson.Field + QueueAll apijson.Field + QueueingMethod apijson.Field + QueueingStatusCode apijson.Field + SessionDuration apijson.Field + Suspended apijson.Field + TotalActiveUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type WaitingRoomNewParamsAdditionalRoute 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://). - Host param.Field[string] `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // 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 param.Field[string] `json:"path"` -} - -func (r WaitingRoomNewParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomNewParamsCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite param.Field[WaitingRoomNewParamsCookieAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure param.Field[WaitingRoomNewParamsCookieAttributesSecure] `json:"secure"` -} - -func (r WaitingRoomNewParamsCookieAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomNewParamsCookieAttributesSamesite string - -const ( - WaitingRoomNewParamsCookieAttributesSamesiteAuto WaitingRoomNewParamsCookieAttributesSamesite = "auto" - WaitingRoomNewParamsCookieAttributesSamesiteLax WaitingRoomNewParamsCookieAttributesSamesite = "lax" - WaitingRoomNewParamsCookieAttributesSamesiteNone WaitingRoomNewParamsCookieAttributesSamesite = "none" - WaitingRoomNewParamsCookieAttributesSamesiteStrict WaitingRoomNewParamsCookieAttributesSamesite = "strict" -) - -func (r WaitingRoomNewParamsCookieAttributesSamesite) IsKnown() bool { - switch r { - case WaitingRoomNewParamsCookieAttributesSamesiteAuto, WaitingRoomNewParamsCookieAttributesSamesiteLax, WaitingRoomNewParamsCookieAttributesSamesiteNone, WaitingRoomNewParamsCookieAttributesSamesiteStrict: - return true - } - return false +func (r *WaitingRoom) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomNewParamsCookieAttributesSecure string - -const ( - WaitingRoomNewParamsCookieAttributesSecureAuto WaitingRoomNewParamsCookieAttributesSecure = "auto" - WaitingRoomNewParamsCookieAttributesSecureAlways WaitingRoomNewParamsCookieAttributesSecure = "always" - WaitingRoomNewParamsCookieAttributesSecureNever WaitingRoomNewParamsCookieAttributesSecure = "never" -) - -func (r WaitingRoomNewParamsCookieAttributesSecure) IsKnown() bool { - switch r { - case WaitingRoomNewParamsCookieAttributesSecureAuto, WaitingRoomNewParamsCookieAttributesSecureAlways, WaitingRoomNewParamsCookieAttributesSecureNever: - return true - } - return false +func (r waitingRoomJSON) RawJSON() string { + return r.raw } // The language of the default page template. If no default_template_language is // provided, then `en-US` (English) will be used. -type WaitingRoomNewParamsDefaultTemplateLanguage string +type WaitingRoomDefaultTemplateLanguage string const ( - WaitingRoomNewParamsDefaultTemplateLanguageEnUs WaitingRoomNewParamsDefaultTemplateLanguage = "en-US" - WaitingRoomNewParamsDefaultTemplateLanguageEsEs WaitingRoomNewParamsDefaultTemplateLanguage = "es-ES" - WaitingRoomNewParamsDefaultTemplateLanguageDeDe WaitingRoomNewParamsDefaultTemplateLanguage = "de-DE" - WaitingRoomNewParamsDefaultTemplateLanguageFrFr WaitingRoomNewParamsDefaultTemplateLanguage = "fr-FR" - WaitingRoomNewParamsDefaultTemplateLanguageItIt WaitingRoomNewParamsDefaultTemplateLanguage = "it-IT" - WaitingRoomNewParamsDefaultTemplateLanguageJaJp WaitingRoomNewParamsDefaultTemplateLanguage = "ja-JP" - WaitingRoomNewParamsDefaultTemplateLanguageKoKr WaitingRoomNewParamsDefaultTemplateLanguage = "ko-KR" - WaitingRoomNewParamsDefaultTemplateLanguagePtBr WaitingRoomNewParamsDefaultTemplateLanguage = "pt-BR" - WaitingRoomNewParamsDefaultTemplateLanguageZhCn WaitingRoomNewParamsDefaultTemplateLanguage = "zh-CN" - WaitingRoomNewParamsDefaultTemplateLanguageZhTw WaitingRoomNewParamsDefaultTemplateLanguage = "zh-TW" - WaitingRoomNewParamsDefaultTemplateLanguageNlNl WaitingRoomNewParamsDefaultTemplateLanguage = "nl-NL" - WaitingRoomNewParamsDefaultTemplateLanguagePlPl WaitingRoomNewParamsDefaultTemplateLanguage = "pl-PL" - WaitingRoomNewParamsDefaultTemplateLanguageIDID WaitingRoomNewParamsDefaultTemplateLanguage = "id-ID" - WaitingRoomNewParamsDefaultTemplateLanguageTrTr WaitingRoomNewParamsDefaultTemplateLanguage = "tr-TR" - WaitingRoomNewParamsDefaultTemplateLanguageArEg WaitingRoomNewParamsDefaultTemplateLanguage = "ar-EG" - WaitingRoomNewParamsDefaultTemplateLanguageRuRu WaitingRoomNewParamsDefaultTemplateLanguage = "ru-RU" - WaitingRoomNewParamsDefaultTemplateLanguageFaIr WaitingRoomNewParamsDefaultTemplateLanguage = "fa-IR" + WaitingRoomDefaultTemplateLanguageEnUs WaitingRoomDefaultTemplateLanguage = "en-US" + WaitingRoomDefaultTemplateLanguageEsEs WaitingRoomDefaultTemplateLanguage = "es-ES" + WaitingRoomDefaultTemplateLanguageDeDe WaitingRoomDefaultTemplateLanguage = "de-DE" + WaitingRoomDefaultTemplateLanguageFrFr WaitingRoomDefaultTemplateLanguage = "fr-FR" + WaitingRoomDefaultTemplateLanguageItIt WaitingRoomDefaultTemplateLanguage = "it-IT" + WaitingRoomDefaultTemplateLanguageJaJp WaitingRoomDefaultTemplateLanguage = "ja-JP" + WaitingRoomDefaultTemplateLanguageKoKr WaitingRoomDefaultTemplateLanguage = "ko-KR" + WaitingRoomDefaultTemplateLanguagePtBr WaitingRoomDefaultTemplateLanguage = "pt-BR" + WaitingRoomDefaultTemplateLanguageZhCn WaitingRoomDefaultTemplateLanguage = "zh-CN" + WaitingRoomDefaultTemplateLanguageZhTw WaitingRoomDefaultTemplateLanguage = "zh-TW" + WaitingRoomDefaultTemplateLanguageNlNl WaitingRoomDefaultTemplateLanguage = "nl-NL" + WaitingRoomDefaultTemplateLanguagePlPl WaitingRoomDefaultTemplateLanguage = "pl-PL" + WaitingRoomDefaultTemplateLanguageIDID WaitingRoomDefaultTemplateLanguage = "id-ID" + WaitingRoomDefaultTemplateLanguageTrTr WaitingRoomDefaultTemplateLanguage = "tr-TR" + WaitingRoomDefaultTemplateLanguageArEg WaitingRoomDefaultTemplateLanguage = "ar-EG" + WaitingRoomDefaultTemplateLanguageRuRu WaitingRoomDefaultTemplateLanguage = "ru-RU" + WaitingRoomDefaultTemplateLanguageFaIr WaitingRoomDefaultTemplateLanguage = "fa-IR" ) -func (r WaitingRoomNewParamsDefaultTemplateLanguage) IsKnown() bool { +func (r WaitingRoomDefaultTemplateLanguage) IsKnown() bool { switch r { - case WaitingRoomNewParamsDefaultTemplateLanguageEnUs, WaitingRoomNewParamsDefaultTemplateLanguageEsEs, WaitingRoomNewParamsDefaultTemplateLanguageDeDe, WaitingRoomNewParamsDefaultTemplateLanguageFrFr, WaitingRoomNewParamsDefaultTemplateLanguageItIt, WaitingRoomNewParamsDefaultTemplateLanguageJaJp, WaitingRoomNewParamsDefaultTemplateLanguageKoKr, WaitingRoomNewParamsDefaultTemplateLanguagePtBr, WaitingRoomNewParamsDefaultTemplateLanguageZhCn, WaitingRoomNewParamsDefaultTemplateLanguageZhTw, WaitingRoomNewParamsDefaultTemplateLanguageNlNl, WaitingRoomNewParamsDefaultTemplateLanguagePlPl, WaitingRoomNewParamsDefaultTemplateLanguageIDID, WaitingRoomNewParamsDefaultTemplateLanguageTrTr, WaitingRoomNewParamsDefaultTemplateLanguageArEg, WaitingRoomNewParamsDefaultTemplateLanguageRuRu, WaitingRoomNewParamsDefaultTemplateLanguageFaIr: + case WaitingRoomDefaultTemplateLanguageEnUs, WaitingRoomDefaultTemplateLanguageEsEs, WaitingRoomDefaultTemplateLanguageDeDe, WaitingRoomDefaultTemplateLanguageFrFr, WaitingRoomDefaultTemplateLanguageItIt, WaitingRoomDefaultTemplateLanguageJaJp, WaitingRoomDefaultTemplateLanguageKoKr, WaitingRoomDefaultTemplateLanguagePtBr, WaitingRoomDefaultTemplateLanguageZhCn, WaitingRoomDefaultTemplateLanguageZhTw, WaitingRoomDefaultTemplateLanguageNlNl, WaitingRoomDefaultTemplateLanguagePlPl, WaitingRoomDefaultTemplateLanguageIDID, WaitingRoomDefaultTemplateLanguageTrTr, WaitingRoomDefaultTemplateLanguageArEg, WaitingRoomDefaultTemplateLanguageRuRu, WaitingRoomDefaultTemplateLanguageFaIr: return true } return false @@ -1051,49 +991,86 @@ func (r WaitingRoomNewParamsDefaultTemplateLanguage) IsKnown() bool { // events override this with `fifo`, `random`, or `passthrough`. When this // queueing method is enabled and neither `queueAll` is enabled nor an event is // prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomNewParamsQueueingMethod string +type WaitingRoomQueueingMethod string const ( - WaitingRoomNewParamsQueueingMethodFifo WaitingRoomNewParamsQueueingMethod = "fifo" - WaitingRoomNewParamsQueueingMethodRandom WaitingRoomNewParamsQueueingMethod = "random" - WaitingRoomNewParamsQueueingMethodPassthrough WaitingRoomNewParamsQueueingMethod = "passthrough" - WaitingRoomNewParamsQueueingMethodReject WaitingRoomNewParamsQueueingMethod = "reject" + WaitingRoomQueueingMethodFifo WaitingRoomQueueingMethod = "fifo" + WaitingRoomQueueingMethodRandom WaitingRoomQueueingMethod = "random" + WaitingRoomQueueingMethodPassthrough WaitingRoomQueueingMethod = "passthrough" + WaitingRoomQueueingMethodReject WaitingRoomQueueingMethod = "reject" ) -func (r WaitingRoomNewParamsQueueingMethod) IsKnown() bool { +func (r WaitingRoomQueueingMethod) IsKnown() bool { switch r { - case WaitingRoomNewParamsQueueingMethodFifo, WaitingRoomNewParamsQueueingMethodRandom, WaitingRoomNewParamsQueueingMethodPassthrough, WaitingRoomNewParamsQueueingMethodReject: + case WaitingRoomQueueingMethodFifo, WaitingRoomQueueingMethodRandom, WaitingRoomQueueingMethodPassthrough, WaitingRoomQueueingMethodReject: return true } return false } // HTTP status code returned to a user while in the queue. -type WaitingRoomNewParamsQueueingStatusCode int64 +type WaitingRoomQueueingStatusCode int64 const ( - WaitingRoomNewParamsQueueingStatusCode200 WaitingRoomNewParamsQueueingStatusCode = 200 - WaitingRoomNewParamsQueueingStatusCode202 WaitingRoomNewParamsQueueingStatusCode = 202 - WaitingRoomNewParamsQueueingStatusCode429 WaitingRoomNewParamsQueueingStatusCode = 429 + WaitingRoomQueueingStatusCode200 WaitingRoomQueueingStatusCode = 200 + WaitingRoomQueueingStatusCode202 WaitingRoomQueueingStatusCode = 202 + WaitingRoomQueueingStatusCode429 WaitingRoomQueueingStatusCode = 429 ) -func (r WaitingRoomNewParamsQueueingStatusCode) IsKnown() bool { +func (r WaitingRoomQueueingStatusCode) IsKnown() bool { switch r { - case WaitingRoomNewParamsQueueingStatusCode200, WaitingRoomNewParamsQueueingStatusCode202, WaitingRoomNewParamsQueueingStatusCode429: + case WaitingRoomQueueingStatusCode200, WaitingRoomQueueingStatusCode202, WaitingRoomQueueingStatusCode429: return true } return false } +type WaitingRoomDeleteResponse struct { + ID string `json:"id"` + JSON waitingRoomDeleteResponseJSON `json:"-"` +} + +// waitingRoomDeleteResponseJSON contains the JSON metadata for the struct +// [WaitingRoomDeleteResponse] +type waitingRoomDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Query QueryParam `json:"query,required"` +} + +func (r WaitingRoomNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Query) +} + type WaitingRoomNewResponseEnvelope struct { - Result WaitingRoom `json:"result,required"` - JSON waitingRoomNewResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result WaitingRoom `json:"result,required"` + Success interface{} `json:"success,required"` + JSON waitingRoomNewResponseEnvelopeJSON `json:"-"` } // waitingRoomNewResponseEnvelopeJSON contains the JSON metadata for the struct // [WaitingRoomNewResponseEnvelope] type waitingRoomNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1107,941 +1084,153 @@ func (r waitingRoomNewResponseEnvelopeJSON) RawJSON() string { } type WaitingRoomUpdateParams struct { - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host param.Field[string] `json:"host,required"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // 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[[]WaitingRoomUpdateParamsAdditionalRoute] `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[WaitingRoomUpdateParamsCookieAttributes] `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix param.Field[string] `json:"cookie_suffix"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage param.Field[WaitingRoomUpdateParamsDefaultTemplateLanguage] `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description param.Field[string] `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` - // Sets the path within the host to enable the waiting room on. The waiting room - // 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 param.Field[string] `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll param.Field[bool] `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod param.Field[WaitingRoomUpdateParamsQueueingMethod] `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode param.Field[WaitingRoomUpdateParamsQueueingStatusCode] `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration param.Field[int64] `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended param.Field[bool] `json:"suspended"` + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Query QueryParam `json:"query,required"` } func (r WaitingRoomUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomUpdateParamsAdditionalRoute 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://). - Host param.Field[string] `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // 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 param.Field[string] `json:"path"` + return apijson.MarshalRoot(r.Query) } -func (r WaitingRoomUpdateParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type WaitingRoomUpdateResponseEnvelope struct { + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result WaitingRoom `json:"result,required"` + Success interface{} `json:"success,required"` + JSON waitingRoomUpdateResponseEnvelopeJSON `json:"-"` } -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomUpdateParamsCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite param.Field[WaitingRoomUpdateParamsCookieAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure param.Field[WaitingRoomUpdateParamsCookieAttributesSecure] `json:"secure"` +// waitingRoomUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomUpdateResponseEnvelope] +type waitingRoomUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r WaitingRoomUpdateParamsCookieAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *WaitingRoomUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomUpdateParamsCookieAttributesSamesite string - -const ( - WaitingRoomUpdateParamsCookieAttributesSamesiteAuto WaitingRoomUpdateParamsCookieAttributesSamesite = "auto" - WaitingRoomUpdateParamsCookieAttributesSamesiteLax WaitingRoomUpdateParamsCookieAttributesSamesite = "lax" - WaitingRoomUpdateParamsCookieAttributesSamesiteNone WaitingRoomUpdateParamsCookieAttributesSamesite = "none" - WaitingRoomUpdateParamsCookieAttributesSamesiteStrict WaitingRoomUpdateParamsCookieAttributesSamesite = "strict" -) - -func (r WaitingRoomUpdateParamsCookieAttributesSamesite) IsKnown() bool { - switch r { - case WaitingRoomUpdateParamsCookieAttributesSamesiteAuto, WaitingRoomUpdateParamsCookieAttributesSamesiteLax, WaitingRoomUpdateParamsCookieAttributesSamesiteNone, WaitingRoomUpdateParamsCookieAttributesSamesiteStrict: - return true - } - return false +func (r waitingRoomUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomUpdateParamsCookieAttributesSecure string - -const ( - WaitingRoomUpdateParamsCookieAttributesSecureAuto WaitingRoomUpdateParamsCookieAttributesSecure = "auto" - WaitingRoomUpdateParamsCookieAttributesSecureAlways WaitingRoomUpdateParamsCookieAttributesSecure = "always" - WaitingRoomUpdateParamsCookieAttributesSecureNever WaitingRoomUpdateParamsCookieAttributesSecure = "never" -) - -func (r WaitingRoomUpdateParamsCookieAttributesSecure) IsKnown() bool { - switch r { - case WaitingRoomUpdateParamsCookieAttributesSecureAuto, WaitingRoomUpdateParamsCookieAttributesSecureAlways, WaitingRoomUpdateParamsCookieAttributesSecureNever: - return true - } - return false +type WaitingRoomListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Page number of paginated results. + Page param.Field[interface{}] `query:"page"` + // Maximum number of results per page. Must be a multiple of 5. + PerPage param.Field[interface{}] `query:"per_page"` } -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomUpdateParamsDefaultTemplateLanguage string - -const ( - WaitingRoomUpdateParamsDefaultTemplateLanguageEnUs WaitingRoomUpdateParamsDefaultTemplateLanguage = "en-US" - WaitingRoomUpdateParamsDefaultTemplateLanguageEsEs WaitingRoomUpdateParamsDefaultTemplateLanguage = "es-ES" - WaitingRoomUpdateParamsDefaultTemplateLanguageDeDe WaitingRoomUpdateParamsDefaultTemplateLanguage = "de-DE" - WaitingRoomUpdateParamsDefaultTemplateLanguageFrFr WaitingRoomUpdateParamsDefaultTemplateLanguage = "fr-FR" - WaitingRoomUpdateParamsDefaultTemplateLanguageItIt WaitingRoomUpdateParamsDefaultTemplateLanguage = "it-IT" - WaitingRoomUpdateParamsDefaultTemplateLanguageJaJp WaitingRoomUpdateParamsDefaultTemplateLanguage = "ja-JP" - WaitingRoomUpdateParamsDefaultTemplateLanguageKoKr WaitingRoomUpdateParamsDefaultTemplateLanguage = "ko-KR" - WaitingRoomUpdateParamsDefaultTemplateLanguagePtBr WaitingRoomUpdateParamsDefaultTemplateLanguage = "pt-BR" - WaitingRoomUpdateParamsDefaultTemplateLanguageZhCn WaitingRoomUpdateParamsDefaultTemplateLanguage = "zh-CN" - WaitingRoomUpdateParamsDefaultTemplateLanguageZhTw WaitingRoomUpdateParamsDefaultTemplateLanguage = "zh-TW" - WaitingRoomUpdateParamsDefaultTemplateLanguageNlNl WaitingRoomUpdateParamsDefaultTemplateLanguage = "nl-NL" - WaitingRoomUpdateParamsDefaultTemplateLanguagePlPl WaitingRoomUpdateParamsDefaultTemplateLanguage = "pl-PL" - WaitingRoomUpdateParamsDefaultTemplateLanguageIDID WaitingRoomUpdateParamsDefaultTemplateLanguage = "id-ID" - WaitingRoomUpdateParamsDefaultTemplateLanguageTrTr WaitingRoomUpdateParamsDefaultTemplateLanguage = "tr-TR" - WaitingRoomUpdateParamsDefaultTemplateLanguageArEg WaitingRoomUpdateParamsDefaultTemplateLanguage = "ar-EG" - WaitingRoomUpdateParamsDefaultTemplateLanguageRuRu WaitingRoomUpdateParamsDefaultTemplateLanguage = "ru-RU" - WaitingRoomUpdateParamsDefaultTemplateLanguageFaIr WaitingRoomUpdateParamsDefaultTemplateLanguage = "fa-IR" -) - -func (r WaitingRoomUpdateParamsDefaultTemplateLanguage) IsKnown() bool { - switch r { - case WaitingRoomUpdateParamsDefaultTemplateLanguageEnUs, WaitingRoomUpdateParamsDefaultTemplateLanguageEsEs, WaitingRoomUpdateParamsDefaultTemplateLanguageDeDe, WaitingRoomUpdateParamsDefaultTemplateLanguageFrFr, WaitingRoomUpdateParamsDefaultTemplateLanguageItIt, WaitingRoomUpdateParamsDefaultTemplateLanguageJaJp, WaitingRoomUpdateParamsDefaultTemplateLanguageKoKr, WaitingRoomUpdateParamsDefaultTemplateLanguagePtBr, WaitingRoomUpdateParamsDefaultTemplateLanguageZhCn, WaitingRoomUpdateParamsDefaultTemplateLanguageZhTw, WaitingRoomUpdateParamsDefaultTemplateLanguageNlNl, WaitingRoomUpdateParamsDefaultTemplateLanguagePlPl, WaitingRoomUpdateParamsDefaultTemplateLanguageIDID, WaitingRoomUpdateParamsDefaultTemplateLanguageTrTr, WaitingRoomUpdateParamsDefaultTemplateLanguageArEg, WaitingRoomUpdateParamsDefaultTemplateLanguageRuRu, WaitingRoomUpdateParamsDefaultTemplateLanguageFaIr: - return true - } - return false +// URLQuery serializes [WaitingRoomListParams]'s query parameters as `url.Values`. +func (r WaitingRoomListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) } -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomUpdateParamsQueueingMethod string - -const ( - WaitingRoomUpdateParamsQueueingMethodFifo WaitingRoomUpdateParamsQueueingMethod = "fifo" - WaitingRoomUpdateParamsQueueingMethodRandom WaitingRoomUpdateParamsQueueingMethod = "random" - WaitingRoomUpdateParamsQueueingMethodPassthrough WaitingRoomUpdateParamsQueueingMethod = "passthrough" - WaitingRoomUpdateParamsQueueingMethodReject WaitingRoomUpdateParamsQueueingMethod = "reject" -) - -func (r WaitingRoomUpdateParamsQueueingMethod) IsKnown() bool { - switch r { - case WaitingRoomUpdateParamsQueueingMethodFifo, WaitingRoomUpdateParamsQueueingMethodRandom, WaitingRoomUpdateParamsQueueingMethodPassthrough, WaitingRoomUpdateParamsQueueingMethodReject: - return true - } - return false +type WaitingRoomDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Body interface{} `json:"body,required"` } -// HTTP status code returned to a user while in the queue. -type WaitingRoomUpdateParamsQueueingStatusCode int64 - -const ( - WaitingRoomUpdateParamsQueueingStatusCode200 WaitingRoomUpdateParamsQueueingStatusCode = 200 - WaitingRoomUpdateParamsQueueingStatusCode202 WaitingRoomUpdateParamsQueueingStatusCode = 202 - WaitingRoomUpdateParamsQueueingStatusCode429 WaitingRoomUpdateParamsQueueingStatusCode = 429 -) - -func (r WaitingRoomUpdateParamsQueueingStatusCode) IsKnown() bool { - switch r { - case WaitingRoomUpdateParamsQueueingStatusCode200, WaitingRoomUpdateParamsQueueingStatusCode202, WaitingRoomUpdateParamsQueueingStatusCode429: - return true - } - return false +func (r WaitingRoomDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -type WaitingRoomUpdateResponseEnvelope struct { - Result WaitingRoom `json:"result,required"` - JSON waitingRoomUpdateResponseEnvelopeJSON `json:"-"` +type WaitingRoomDeleteResponseEnvelope struct { + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result WaitingRoomDeleteResponse `json:"result,required"` + Success interface{} `json:"success,required"` + JSON waitingRoomDeleteResponseEnvelopeJSON `json:"-"` } -// waitingRoomUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomUpdateResponseEnvelope] -type waitingRoomUpdateResponseEnvelopeJSON struct { +// waitingRoomDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomDeleteResponseEnvelope] +type waitingRoomDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *WaitingRoomUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *WaitingRoomDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r waitingRoomUpdateResponseEnvelopeJSON) RawJSON() string { +func (r waitingRoomDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WaitingRoomDeleteResponseEnvelope struct { - Result WaitingRoomDeleteResponse `json:"result,required"` - JSON waitingRoomDeleteResponseEnvelopeJSON `json:"-"` +type WaitingRoomEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Query QueryParam `json:"query,required"` } -// waitingRoomDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomDeleteResponseEnvelope] -type waitingRoomDeleteResponseEnvelopeJSON struct { +func (r WaitingRoomEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Query) +} + +type WaitingRoomEditResponseEnvelope struct { + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result WaitingRoom `json:"result,required"` + Success interface{} `json:"success,required"` + JSON waitingRoomEditResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomEditResponseEnvelope] +type waitingRoomEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *WaitingRoomDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *WaitingRoomEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r waitingRoomDeleteResponseEnvelopeJSON) RawJSON() string { +func (r waitingRoomEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WaitingRoomEditParams struct { - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host param.Field[string] `json:"host,required"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // 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[[]WaitingRoomEditParamsAdditionalRoute] `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[WaitingRoomEditParamsCookieAttributes] `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix param.Field[string] `json:"cookie_suffix"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage param.Field[WaitingRoomEditParamsDefaultTemplateLanguage] `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description param.Field[string] `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` - // Sets the path within the host to enable the waiting room on. The waiting room - // 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 param.Field[string] `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll param.Field[bool] `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod param.Field[WaitingRoomEditParamsQueueingMethod] `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode param.Field[WaitingRoomEditParamsQueueingStatusCode] `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration param.Field[int64] `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended param.Field[bool] `json:"suspended"` -} - -func (r WaitingRoomEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomEditParamsAdditionalRoute 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://). - Host param.Field[string] `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // 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 param.Field[string] `json:"path"` -} - -func (r WaitingRoomEditParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomEditParamsCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite param.Field[WaitingRoomEditParamsCookieAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure param.Field[WaitingRoomEditParamsCookieAttributesSecure] `json:"secure"` -} - -func (r WaitingRoomEditParamsCookieAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomEditParamsCookieAttributesSamesite string - -const ( - WaitingRoomEditParamsCookieAttributesSamesiteAuto WaitingRoomEditParamsCookieAttributesSamesite = "auto" - WaitingRoomEditParamsCookieAttributesSamesiteLax WaitingRoomEditParamsCookieAttributesSamesite = "lax" - WaitingRoomEditParamsCookieAttributesSamesiteNone WaitingRoomEditParamsCookieAttributesSamesite = "none" - WaitingRoomEditParamsCookieAttributesSamesiteStrict WaitingRoomEditParamsCookieAttributesSamesite = "strict" -) - -func (r WaitingRoomEditParamsCookieAttributesSamesite) IsKnown() bool { - switch r { - case WaitingRoomEditParamsCookieAttributesSamesiteAuto, WaitingRoomEditParamsCookieAttributesSamesiteLax, WaitingRoomEditParamsCookieAttributesSamesiteNone, WaitingRoomEditParamsCookieAttributesSamesiteStrict: - return true - } - return false -} - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomEditParamsCookieAttributesSecure string - -const ( - WaitingRoomEditParamsCookieAttributesSecureAuto WaitingRoomEditParamsCookieAttributesSecure = "auto" - WaitingRoomEditParamsCookieAttributesSecureAlways WaitingRoomEditParamsCookieAttributesSecure = "always" - WaitingRoomEditParamsCookieAttributesSecureNever WaitingRoomEditParamsCookieAttributesSecure = "never" -) - -func (r WaitingRoomEditParamsCookieAttributesSecure) IsKnown() bool { - switch r { - case WaitingRoomEditParamsCookieAttributesSecureAuto, WaitingRoomEditParamsCookieAttributesSecureAlways, WaitingRoomEditParamsCookieAttributesSecureNever: - return true - } - return false -} - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomEditParamsDefaultTemplateLanguage string - -const ( - WaitingRoomEditParamsDefaultTemplateLanguageEnUs WaitingRoomEditParamsDefaultTemplateLanguage = "en-US" - WaitingRoomEditParamsDefaultTemplateLanguageEsEs WaitingRoomEditParamsDefaultTemplateLanguage = "es-ES" - WaitingRoomEditParamsDefaultTemplateLanguageDeDe WaitingRoomEditParamsDefaultTemplateLanguage = "de-DE" - WaitingRoomEditParamsDefaultTemplateLanguageFrFr WaitingRoomEditParamsDefaultTemplateLanguage = "fr-FR" - WaitingRoomEditParamsDefaultTemplateLanguageItIt WaitingRoomEditParamsDefaultTemplateLanguage = "it-IT" - WaitingRoomEditParamsDefaultTemplateLanguageJaJp WaitingRoomEditParamsDefaultTemplateLanguage = "ja-JP" - WaitingRoomEditParamsDefaultTemplateLanguageKoKr WaitingRoomEditParamsDefaultTemplateLanguage = "ko-KR" - WaitingRoomEditParamsDefaultTemplateLanguagePtBr WaitingRoomEditParamsDefaultTemplateLanguage = "pt-BR" - WaitingRoomEditParamsDefaultTemplateLanguageZhCn WaitingRoomEditParamsDefaultTemplateLanguage = "zh-CN" - WaitingRoomEditParamsDefaultTemplateLanguageZhTw WaitingRoomEditParamsDefaultTemplateLanguage = "zh-TW" - WaitingRoomEditParamsDefaultTemplateLanguageNlNl WaitingRoomEditParamsDefaultTemplateLanguage = "nl-NL" - WaitingRoomEditParamsDefaultTemplateLanguagePlPl WaitingRoomEditParamsDefaultTemplateLanguage = "pl-PL" - WaitingRoomEditParamsDefaultTemplateLanguageIDID WaitingRoomEditParamsDefaultTemplateLanguage = "id-ID" - WaitingRoomEditParamsDefaultTemplateLanguageTrTr WaitingRoomEditParamsDefaultTemplateLanguage = "tr-TR" - WaitingRoomEditParamsDefaultTemplateLanguageArEg WaitingRoomEditParamsDefaultTemplateLanguage = "ar-EG" - WaitingRoomEditParamsDefaultTemplateLanguageRuRu WaitingRoomEditParamsDefaultTemplateLanguage = "ru-RU" - WaitingRoomEditParamsDefaultTemplateLanguageFaIr WaitingRoomEditParamsDefaultTemplateLanguage = "fa-IR" -) - -func (r WaitingRoomEditParamsDefaultTemplateLanguage) IsKnown() bool { - switch r { - case WaitingRoomEditParamsDefaultTemplateLanguageEnUs, WaitingRoomEditParamsDefaultTemplateLanguageEsEs, WaitingRoomEditParamsDefaultTemplateLanguageDeDe, WaitingRoomEditParamsDefaultTemplateLanguageFrFr, WaitingRoomEditParamsDefaultTemplateLanguageItIt, WaitingRoomEditParamsDefaultTemplateLanguageJaJp, WaitingRoomEditParamsDefaultTemplateLanguageKoKr, WaitingRoomEditParamsDefaultTemplateLanguagePtBr, WaitingRoomEditParamsDefaultTemplateLanguageZhCn, WaitingRoomEditParamsDefaultTemplateLanguageZhTw, WaitingRoomEditParamsDefaultTemplateLanguageNlNl, WaitingRoomEditParamsDefaultTemplateLanguagePlPl, WaitingRoomEditParamsDefaultTemplateLanguageIDID, WaitingRoomEditParamsDefaultTemplateLanguageTrTr, WaitingRoomEditParamsDefaultTemplateLanguageArEg, WaitingRoomEditParamsDefaultTemplateLanguageRuRu, WaitingRoomEditParamsDefaultTemplateLanguageFaIr: - return true - } - return false -} - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomEditParamsQueueingMethod string - -const ( - WaitingRoomEditParamsQueueingMethodFifo WaitingRoomEditParamsQueueingMethod = "fifo" - WaitingRoomEditParamsQueueingMethodRandom WaitingRoomEditParamsQueueingMethod = "random" - WaitingRoomEditParamsQueueingMethodPassthrough WaitingRoomEditParamsQueueingMethod = "passthrough" - WaitingRoomEditParamsQueueingMethodReject WaitingRoomEditParamsQueueingMethod = "reject" -) - -func (r WaitingRoomEditParamsQueueingMethod) IsKnown() bool { - switch r { - case WaitingRoomEditParamsQueueingMethodFifo, WaitingRoomEditParamsQueueingMethodRandom, WaitingRoomEditParamsQueueingMethodPassthrough, WaitingRoomEditParamsQueueingMethodReject: - return true - } - return false -} - -// HTTP status code returned to a user while in the queue. -type WaitingRoomEditParamsQueueingStatusCode int64 - -const ( - WaitingRoomEditParamsQueueingStatusCode200 WaitingRoomEditParamsQueueingStatusCode = 200 - WaitingRoomEditParamsQueueingStatusCode202 WaitingRoomEditParamsQueueingStatusCode = 202 - WaitingRoomEditParamsQueueingStatusCode429 WaitingRoomEditParamsQueueingStatusCode = 429 -) - -func (r WaitingRoomEditParamsQueueingStatusCode) IsKnown() bool { - switch r { - case WaitingRoomEditParamsQueueingStatusCode200, WaitingRoomEditParamsQueueingStatusCode202, WaitingRoomEditParamsQueueingStatusCode429: - return true - } - return false -} - -type WaitingRoomEditResponseEnvelope struct { - Result WaitingRoom `json:"result,required"` - JSON waitingRoomEditResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomEditResponseEnvelope] -type waitingRoomEditResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEditResponseEnvelopeJSON) RawJSON() string { - return r.raw +type WaitingRoomGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` } type WaitingRoomGetResponseEnvelope struct { - Result WaitingRoom `json:"result,required"` - JSON waitingRoomGetResponseEnvelopeJSON `json:"-"` + Errors interface{} `json:"errors,required"` + Messages interface{} `json:"messages,required"` + Result WaitingRoom `json:"result,required"` + Success interface{} `json:"success,required"` + JSON waitingRoomGetResponseEnvelopeJSON `json:"-"` } // waitingRoomGetResponseEnvelopeJSON contains the JSON metadata for the struct // [WaitingRoomGetResponseEnvelope] type waitingRoomGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/waiting_rooms/waitingroom_test.go b/waiting_rooms/waitingroom_test.go index 0f6c9849c24..c67d532b914 100644 --- a/waiting_rooms/waitingroom_test.go +++ b/waiting_rooms/waitingroom_test.go @@ -28,15 +28,10 @@ func TestWaitingRoomNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WaitingRooms.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - waiting_rooms.WaitingRoomNewParams{ - Host: cloudflare.F("shop.example.com"), - Name: cloudflare.F("production_webinar"), - NewUsersPerMinute: cloudflare.F(int64(200)), - TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]waiting_rooms.WaitingRoomNewParamsAdditionalRoute{{ + _, err := client.WaitingRooms.New(context.TODO(), waiting_rooms.WaitingRoomNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Query: waiting_rooms.QueryParam{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesParam{{ Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }, { @@ -46,24 +41,28 @@ func TestWaitingRoomNewWithOptionalParams(t *testing.T) { Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }}), - CookieAttributes: cloudflare.F(waiting_rooms.WaitingRoomNewParamsCookieAttributes{ - Samesite: cloudflare.F(waiting_rooms.WaitingRoomNewParamsCookieAttributesSamesiteAuto), - Secure: cloudflare.F(waiting_rooms.WaitingRoomNewParamsCookieAttributesSecureAuto), + CookieAttributes: cloudflare.F(waiting_rooms.CookieAttributesParam{ + Samesite: cloudflare.F(waiting_rooms.CookieAttributesSamesiteAuto), + Secure: cloudflare.F(waiting_rooms.CookieAttributesSecureAuto), }), CookieSuffix: cloudflare.F("abcd"), CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), - DefaultTemplateLanguage: cloudflare.F(waiting_rooms.WaitingRoomNewParamsDefaultTemplateLanguageEsEs), + DefaultTemplateLanguage: cloudflare.F(waiting_rooms.QueryDefaultTemplateLanguageEsEs), Description: cloudflare.F("Production - DO NOT MODIFY"), DisableSessionRenewal: cloudflare.F(false), + Host: cloudflare.F("shop.example.com"), JsonResponseEnabled: cloudflare.F(false), + Name: cloudflare.F("production_webinar"), + NewUsersPerMinute: cloudflare.F(int64(200)), Path: cloudflare.F("/shop/checkout"), QueueAll: cloudflare.F(true), - QueueingMethod: cloudflare.F(waiting_rooms.WaitingRoomNewParamsQueueingMethodFifo), - QueueingStatusCode: cloudflare.F(waiting_rooms.WaitingRoomNewParamsQueueingStatusCode202), + QueueingMethod: cloudflare.F(waiting_rooms.QueryQueueingMethodFifo), + QueueingStatusCode: cloudflare.F(waiting_rooms.QueryQueueingStatusCode202), SessionDuration: cloudflare.F(int64(1)), Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), }, - ) + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -89,39 +88,41 @@ func TestWaitingRoomUpdateWithOptionalParams(t *testing.T) { ) _, err := client.WaitingRooms.Update( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", waiting_rooms.WaitingRoomUpdateParams{ - Host: cloudflare.F("shop.example.com"), - Name: cloudflare.F("production_webinar"), - NewUsersPerMinute: cloudflare.F(int64(200)), - TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]waiting_rooms.WaitingRoomUpdateParamsAdditionalRoute{{ - Host: cloudflare.F("shop2.example.com"), - Path: cloudflare.F("/shop2/checkout"), - }, { - Host: cloudflare.F("shop2.example.com"), - Path: cloudflare.F("/shop2/checkout"), - }, { - Host: cloudflare.F("shop2.example.com"), - Path: cloudflare.F("/shop2/checkout"), - }}), - CookieAttributes: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsCookieAttributes{ - Samesite: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsCookieAttributesSamesiteAuto), - Secure: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsCookieAttributesSecureAuto), - }), - CookieSuffix: cloudflare.F("abcd"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), - DefaultTemplateLanguage: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsDefaultTemplateLanguageEsEs), - Description: cloudflare.F("Production - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(false), - JsonResponseEnabled: cloudflare.F(false), - Path: cloudflare.F("/shop/checkout"), - QueueAll: cloudflare.F(true), - QueueingMethod: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsQueueingMethodFifo), - QueueingStatusCode: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsQueueingStatusCode202), - SessionDuration: cloudflare.F(int64(1)), - Suspended: cloudflare.F(true), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Query: waiting_rooms.QueryParam{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesParam{{ + Host: cloudflare.F("shop2.example.com"), + Path: cloudflare.F("/shop2/checkout"), + }, { + Host: cloudflare.F("shop2.example.com"), + Path: cloudflare.F("/shop2/checkout"), + }, { + Host: cloudflare.F("shop2.example.com"), + Path: cloudflare.F("/shop2/checkout"), + }}), + CookieAttributes: cloudflare.F(waiting_rooms.CookieAttributesParam{ + Samesite: cloudflare.F(waiting_rooms.CookieAttributesSamesiteAuto), + Secure: cloudflare.F(waiting_rooms.CookieAttributesSecureAuto), + }), + CookieSuffix: cloudflare.F("abcd"), + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), + DefaultTemplateLanguage: cloudflare.F(waiting_rooms.QueryDefaultTemplateLanguageEsEs), + Description: cloudflare.F("Production - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(false), + Host: cloudflare.F("shop.example.com"), + JsonResponseEnabled: cloudflare.F(false), + Name: cloudflare.F("production_webinar"), + NewUsersPerMinute: cloudflare.F(int64(200)), + Path: cloudflare.F("/shop/checkout"), + QueueAll: cloudflare.F(true), + QueueingMethod: cloudflare.F(waiting_rooms.QueryQueueingMethodFifo), + QueueingStatusCode: cloudflare.F(waiting_rooms.QueryQueueingStatusCode202), + SessionDuration: cloudflare.F(int64(1)), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, }, ) if err != nil { @@ -133,7 +134,7 @@ func TestWaitingRoomUpdateWithOptionalParams(t *testing.T) { } } -func TestWaitingRoomList(t *testing.T) { +func TestWaitingRoomListWithOptionalParams(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 { @@ -147,7 +148,11 @@ func TestWaitingRoomList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WaitingRooms.List(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + _, err := client.WaitingRooms.List(context.TODO(), waiting_rooms.WaitingRoomListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Page: cloudflare.F[any](map[string]interface{}{}), + PerPage: cloudflare.F[any](map[string]interface{}{}), + }) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -173,8 +178,11 @@ func TestWaitingRoomDelete(t *testing.T) { ) _, err := client.WaitingRooms.Delete( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", + waiting_rooms.WaitingRoomDeleteParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error @@ -201,39 +209,41 @@ func TestWaitingRoomEditWithOptionalParams(t *testing.T) { ) _, err := client.WaitingRooms.Edit( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", waiting_rooms.WaitingRoomEditParams{ - Host: cloudflare.F("shop.example.com"), - Name: cloudflare.F("production_webinar"), - NewUsersPerMinute: cloudflare.F(int64(200)), - TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]waiting_rooms.WaitingRoomEditParamsAdditionalRoute{{ - Host: cloudflare.F("shop2.example.com"), - Path: cloudflare.F("/shop2/checkout"), - }, { - Host: cloudflare.F("shop2.example.com"), - Path: cloudflare.F("/shop2/checkout"), - }, { - Host: cloudflare.F("shop2.example.com"), - Path: cloudflare.F("/shop2/checkout"), - }}), - CookieAttributes: cloudflare.F(waiting_rooms.WaitingRoomEditParamsCookieAttributes{ - Samesite: cloudflare.F(waiting_rooms.WaitingRoomEditParamsCookieAttributesSamesiteAuto), - Secure: cloudflare.F(waiting_rooms.WaitingRoomEditParamsCookieAttributesSecureAuto), - }), - CookieSuffix: cloudflare.F("abcd"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), - DefaultTemplateLanguage: cloudflare.F(waiting_rooms.WaitingRoomEditParamsDefaultTemplateLanguageEsEs), - Description: cloudflare.F("Production - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(false), - JsonResponseEnabled: cloudflare.F(false), - Path: cloudflare.F("/shop/checkout"), - QueueAll: cloudflare.F(true), - QueueingMethod: cloudflare.F(waiting_rooms.WaitingRoomEditParamsQueueingMethodFifo), - QueueingStatusCode: cloudflare.F(waiting_rooms.WaitingRoomEditParamsQueueingStatusCode202), - SessionDuration: cloudflare.F(int64(1)), - Suspended: cloudflare.F(true), + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Query: waiting_rooms.QueryParam{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesParam{{ + Host: cloudflare.F("shop2.example.com"), + Path: cloudflare.F("/shop2/checkout"), + }, { + Host: cloudflare.F("shop2.example.com"), + Path: cloudflare.F("/shop2/checkout"), + }, { + Host: cloudflare.F("shop2.example.com"), + Path: cloudflare.F("/shop2/checkout"), + }}), + CookieAttributes: cloudflare.F(waiting_rooms.CookieAttributesParam{ + Samesite: cloudflare.F(waiting_rooms.CookieAttributesSamesiteAuto), + Secure: cloudflare.F(waiting_rooms.CookieAttributesSecureAuto), + }), + CookieSuffix: cloudflare.F("abcd"), + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), + DefaultTemplateLanguage: cloudflare.F(waiting_rooms.QueryDefaultTemplateLanguageEsEs), + Description: cloudflare.F("Production - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(false), + Host: cloudflare.F("shop.example.com"), + JsonResponseEnabled: cloudflare.F(false), + Name: cloudflare.F("production_webinar"), + NewUsersPerMinute: cloudflare.F(int64(200)), + Path: cloudflare.F("/shop/checkout"), + QueueAll: cloudflare.F(true), + QueueingMethod: cloudflare.F(waiting_rooms.QueryQueueingMethodFifo), + QueueingStatusCode: cloudflare.F(waiting_rooms.QueryQueueingStatusCode202), + SessionDuration: cloudflare.F(int64(1)), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, }, ) if err != nil { @@ -261,8 +271,10 @@ func TestWaitingRoomGet(t *testing.T) { ) _, err := client.WaitingRooms.Get( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", + waiting_rooms.WaitingRoomGetParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/warp_connector/aliases.go b/warp_connector/aliases.go index fbdaf9d3e00..074163df9bd 100644 --- a/warp_connector/aliases.go +++ b/warp_connector/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/warp_connector/warpconnector.go b/warp_connector/warpconnector.go index e675a9301b1..caf5464dfef 100644 --- a/warp_connector/warpconnector.go +++ b/warp_connector/warpconnector.go @@ -115,7 +115,7 @@ func (r *WARPConnectorService) Get(ctx context.Context, tunnelID string, query W // Gets the token used to associate warp device with a specific Warp Connector // tunnel. -func (r *WARPConnectorService) Token(ctx context.Context, tunnelID string, query WARPConnectorTokenParams, opts ...option.RequestOption) (res *WARPConnectorTokenResponse, err error) { +func (r *WARPConnectorService) Token(ctx context.Context, tunnelID string, query WARPConnectorTokenParams, opts ...option.RequestOption) (res *WARPConnectorTokenResponseUnion, err error) { opts = append(r.Options[:], opts...) var env WARPConnectorTokenResponseEnvelope path := fmt.Sprintf("accounts/%s/warp_connector/%s/token", query.AccountID, tunnelID) @@ -128,36 +128,10 @@ func (r *WARPConnectorService) Token(ctx context.Context, tunnelID string, query } // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [warp_connector.WARPConnectorNewResponseTunnelCfdTunnel] or -// [warp_connector.WARPConnectorNewResponseTunnelWARPConnectorTunnel]. -type WARPConnectorNewResponse interface { - implementsWARPConnectorWARPConnectorNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WARPConnectorNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorNewResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorNewResponseTunnelWARPConnectorTunnel{}), - }, - ) -} - -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type WARPConnectorNewResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` +type WARPConnectorNewResponse struct { // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []WARPConnectorNewResponseTunnelCfdTunnelConnection `json:"connections"` + AccountTag string `json:"account_tag"` + Connections interface{} `json:"connections,required"` // Timestamp of when the tunnel established at least one connection to Cloudflare's // edge. If `null`, the tunnel is inactive. ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` @@ -169,8 +143,9 @@ type WARPConnectorNewResponseTunnelCfdTunnel struct { // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been // deleted. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` + // UUID of the tunnel. + ID string `json:"id"` + Metadata interface{} `json:"metadata,required"` // A user-friendly name for the tunnel. Name string `json:"name"` // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. @@ -182,20 +157,21 @@ type WARPConnectorNewResponseTunnelCfdTunnel struct { // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). Status string `json:"status"` // The type of tunnel. - TunType WARPConnectorNewResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON warpConnectorNewResponseTunnelCfdTunnelJSON `json:"-"` + TunType WARPConnectorNewResponseTunType `json:"tun_type"` + JSON warpConnectorNewResponseJSON `json:"-"` + union WARPConnectorNewResponseUnion } -// warpConnectorNewResponseTunnelCfdTunnelJSON contains the JSON metadata for the -// struct [WARPConnectorNewResponseTunnelCfdTunnel] -type warpConnectorNewResponseTunnelCfdTunnelJSON struct { - ID apijson.Field +// warpConnectorNewResponseJSON contains the JSON metadata for the struct +// [WARPConnectorNewResponse] +type warpConnectorNewResponseJSON struct { AccountTag apijson.Field Connections apijson.Field ConnsActiveAt apijson.Field ConnsInactiveAt apijson.Field CreatedAt apijson.Field DeletedAt apijson.Field + ID apijson.Field Metadata apijson.Field Name apijson.Field RemoteConfig apijson.Field @@ -205,79 +181,43 @@ type warpConnectorNewResponseTunnelCfdTunnelJSON struct { ExtraFields map[string]apijson.Field } -func (r *WARPConnectorNewResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorNewResponseTunnelCfdTunnelJSON) RawJSON() string { +func (r warpConnectorNewResponseJSON) RawJSON() string { return r.raw } -func (r WARPConnectorNewResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorNewResponse() {} - -type WARPConnectorNewResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON warpConnectorNewResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// warpConnectorNewResponseTunnelCfdTunnelConnectionJSON contains the JSON metadata -// for the struct [WARPConnectorNewResponseTunnelCfdTunnelConnection] -type warpConnectorNewResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r *WARPConnectorNewResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r *WARPConnectorNewResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r WARPConnectorNewResponse) AsUnion() WARPConnectorNewResponseUnion { + return r.union } -func (r warpConnectorNewResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [shared.CloudflareTunnel] or +// [warp_connector.WARPConnectorNewResponseTunnelWARPConnectorTunnel]. +type WARPConnectorNewResponseUnion interface { + ImplementsWARPConnectorWARPConnectorNewResponse() } -// The type of tunnel. -type WARPConnectorNewResponseTunnelCfdTunnelTunType string - -const ( - WARPConnectorNewResponseTunnelCfdTunnelTunTypeCfdTunnel WARPConnectorNewResponseTunnelCfdTunnelTunType = "cfd_tunnel" - WARPConnectorNewResponseTunnelCfdTunnelTunTypeWARPConnector WARPConnectorNewResponseTunnelCfdTunnelTunType = "warp_connector" - WARPConnectorNewResponseTunnelCfdTunnelTunTypeIPSec WARPConnectorNewResponseTunnelCfdTunnelTunType = "ip_sec" - WARPConnectorNewResponseTunnelCfdTunnelTunTypeGRE WARPConnectorNewResponseTunnelCfdTunnelTunType = "gre" - WARPConnectorNewResponseTunnelCfdTunnelTunTypeCni WARPConnectorNewResponseTunnelCfdTunnelTunType = "cni" -) - -func (r WARPConnectorNewResponseTunnelCfdTunnelTunType) IsKnown() bool { - switch r { - case WARPConnectorNewResponseTunnelCfdTunnelTunTypeCfdTunnel, WARPConnectorNewResponseTunnelCfdTunnelTunTypeWARPConnector, WARPConnectorNewResponseTunnelCfdTunnelTunTypeIPSec, WARPConnectorNewResponseTunnelCfdTunnelTunTypeGRE, WARPConnectorNewResponseTunnelCfdTunnelTunTypeCni: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WARPConnectorNewResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.CloudflareTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WARPConnectorNewResponseTunnelWARPConnectorTunnel{}), + }, + ) } // A Warp Connector Tunnel that connects your origin to Cloudflare's edge. @@ -339,7 +279,7 @@ func (r warpConnectorNewResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorNewResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorNewResponse() { +func (r WARPConnectorNewResponseTunnelWARPConnectorTunnel) ImplementsWARPConnectorWARPConnectorNewResponse() { } type WARPConnectorNewResponseTunnelWARPConnectorTunnelConnection struct { @@ -397,48 +337,41 @@ const ( WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeWARPConnector WARPConnectorNewResponseTunnelWARPConnectorTunnelTunType = "warp_connector" WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeIPSec WARPConnectorNewResponseTunnelWARPConnectorTunnelTunType = "ip_sec" WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeGRE WARPConnectorNewResponseTunnelWARPConnectorTunnelTunType = "gre" - WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeCni WARPConnectorNewResponseTunnelWARPConnectorTunnelTunType = "cni" + WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeCNI WARPConnectorNewResponseTunnelWARPConnectorTunnelTunType = "cni" ) func (r WARPConnectorNewResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool { switch r { - case WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeCni: + case WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorNewResponseTunnelWARPConnectorTunnelTunTypeCNI: return true } return false } -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [warp_connector.WARPConnectorListResponseTunnelCfdTunnel] or -// [warp_connector.WARPConnectorListResponseTunnelWARPConnectorTunnel]. -type WARPConnectorListResponse interface { - implementsWARPConnectorWARPConnectorListResponse() -} +// The type of tunnel. +type WARPConnectorNewResponseTunType string -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WARPConnectorListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorListResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorListResponseTunnelWARPConnectorTunnel{}), - }, - ) +const ( + WARPConnectorNewResponseTunTypeCfdTunnel WARPConnectorNewResponseTunType = "cfd_tunnel" + WARPConnectorNewResponseTunTypeWARPConnector WARPConnectorNewResponseTunType = "warp_connector" + WARPConnectorNewResponseTunTypeIPSec WARPConnectorNewResponseTunType = "ip_sec" + WARPConnectorNewResponseTunTypeGRE WARPConnectorNewResponseTunType = "gre" + WARPConnectorNewResponseTunTypeCNI WARPConnectorNewResponseTunType = "cni" +) + +func (r WARPConnectorNewResponseTunType) IsKnown() bool { + switch r { + case WARPConnectorNewResponseTunTypeCfdTunnel, WARPConnectorNewResponseTunTypeWARPConnector, WARPConnectorNewResponseTunTypeIPSec, WARPConnectorNewResponseTunTypeGRE, WARPConnectorNewResponseTunTypeCNI: + return true + } + return false } // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type WARPConnectorListResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` +type WARPConnectorListResponse struct { // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []WARPConnectorListResponseTunnelCfdTunnelConnection `json:"connections"` + AccountTag string `json:"account_tag"` + Connections interface{} `json:"connections,required"` // Timestamp of when the tunnel established at least one connection to Cloudflare's // edge. If `null`, the tunnel is inactive. ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` @@ -450,8 +383,9 @@ type WARPConnectorListResponseTunnelCfdTunnel struct { // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been // deleted. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` + // UUID of the tunnel. + ID string `json:"id"` + Metadata interface{} `json:"metadata,required"` // A user-friendly name for the tunnel. Name string `json:"name"` // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. @@ -463,20 +397,21 @@ type WARPConnectorListResponseTunnelCfdTunnel struct { // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). Status string `json:"status"` // The type of tunnel. - TunType WARPConnectorListResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON warpConnectorListResponseTunnelCfdTunnelJSON `json:"-"` + TunType WARPConnectorListResponseTunType `json:"tun_type"` + JSON warpConnectorListResponseJSON `json:"-"` + union WARPConnectorListResponseUnion } -// warpConnectorListResponseTunnelCfdTunnelJSON contains the JSON metadata for the -// struct [WARPConnectorListResponseTunnelCfdTunnel] -type warpConnectorListResponseTunnelCfdTunnelJSON struct { - ID apijson.Field +// warpConnectorListResponseJSON contains the JSON metadata for the struct +// [WARPConnectorListResponse] +type warpConnectorListResponseJSON struct { AccountTag apijson.Field Connections apijson.Field ConnsActiveAt apijson.Field ConnsInactiveAt apijson.Field CreatedAt apijson.Field DeletedAt apijson.Field + ID apijson.Field Metadata apijson.Field Name apijson.Field RemoteConfig apijson.Field @@ -486,80 +421,43 @@ type warpConnectorListResponseTunnelCfdTunnelJSON struct { ExtraFields map[string]apijson.Field } -func (r *WARPConnectorListResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorListResponseTunnelCfdTunnelJSON) RawJSON() string { +func (r warpConnectorListResponseJSON) RawJSON() string { return r.raw } -func (r WARPConnectorListResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorListResponse() { -} - -type WARPConnectorListResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON warpConnectorListResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// warpConnectorListResponseTunnelCfdTunnelConnectionJSON contains the JSON -// metadata for the struct [WARPConnectorListResponseTunnelCfdTunnelConnection] -type warpConnectorListResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r *WARPConnectorListResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r *WARPConnectorListResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r WARPConnectorListResponse) AsUnion() WARPConnectorListResponseUnion { + return r.union } -func (r warpConnectorListResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [shared.CloudflareTunnel] or +// [warp_connector.WARPConnectorListResponseTunnelWARPConnectorTunnel]. +type WARPConnectorListResponseUnion interface { + ImplementsWARPConnectorWARPConnectorListResponse() } -// The type of tunnel. -type WARPConnectorListResponseTunnelCfdTunnelTunType string - -const ( - WARPConnectorListResponseTunnelCfdTunnelTunTypeCfdTunnel WARPConnectorListResponseTunnelCfdTunnelTunType = "cfd_tunnel" - WARPConnectorListResponseTunnelCfdTunnelTunTypeWARPConnector WARPConnectorListResponseTunnelCfdTunnelTunType = "warp_connector" - WARPConnectorListResponseTunnelCfdTunnelTunTypeIPSec WARPConnectorListResponseTunnelCfdTunnelTunType = "ip_sec" - WARPConnectorListResponseTunnelCfdTunnelTunTypeGRE WARPConnectorListResponseTunnelCfdTunnelTunType = "gre" - WARPConnectorListResponseTunnelCfdTunnelTunTypeCni WARPConnectorListResponseTunnelCfdTunnelTunType = "cni" -) - -func (r WARPConnectorListResponseTunnelCfdTunnelTunType) IsKnown() bool { - switch r { - case WARPConnectorListResponseTunnelCfdTunnelTunTypeCfdTunnel, WARPConnectorListResponseTunnelCfdTunnelTunTypeWARPConnector, WARPConnectorListResponseTunnelCfdTunnelTunTypeIPSec, WARPConnectorListResponseTunnelCfdTunnelTunTypeGRE, WARPConnectorListResponseTunnelCfdTunnelTunTypeCni: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WARPConnectorListResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.CloudflareTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WARPConnectorListResponseTunnelWARPConnectorTunnel{}), + }, + ) } // A Warp Connector Tunnel that connects your origin to Cloudflare's edge. @@ -621,7 +519,7 @@ func (r warpConnectorListResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorListResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorListResponse() { +func (r WARPConnectorListResponseTunnelWARPConnectorTunnel) ImplementsWARPConnectorWARPConnectorListResponse() { } type WARPConnectorListResponseTunnelWARPConnectorTunnelConnection struct { @@ -679,48 +577,41 @@ const ( WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector WARPConnectorListResponseTunnelWARPConnectorTunnelTunType = "warp_connector" WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeIPSec WARPConnectorListResponseTunnelWARPConnectorTunnelTunType = "ip_sec" WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeGRE WARPConnectorListResponseTunnelWARPConnectorTunnelTunType = "gre" - WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeCni WARPConnectorListResponseTunnelWARPConnectorTunnelTunType = "cni" + WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeCNI WARPConnectorListResponseTunnelWARPConnectorTunnelTunType = "cni" ) func (r WARPConnectorListResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool { switch r { - case WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeCni: + case WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorListResponseTunnelWARPConnectorTunnelTunTypeCNI: return true } return false } -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [warp_connector.WARPConnectorDeleteResponseTunnelCfdTunnel] -// or [warp_connector.WARPConnectorDeleteResponseTunnelWARPConnectorTunnel]. -type WARPConnectorDeleteResponse interface { - implementsWARPConnectorWARPConnectorDeleteResponse() -} +// The type of tunnel. +type WARPConnectorListResponseTunType string -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WARPConnectorDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorDeleteResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorDeleteResponseTunnelWARPConnectorTunnel{}), - }, - ) +const ( + WARPConnectorListResponseTunTypeCfdTunnel WARPConnectorListResponseTunType = "cfd_tunnel" + WARPConnectorListResponseTunTypeWARPConnector WARPConnectorListResponseTunType = "warp_connector" + WARPConnectorListResponseTunTypeIPSec WARPConnectorListResponseTunType = "ip_sec" + WARPConnectorListResponseTunTypeGRE WARPConnectorListResponseTunType = "gre" + WARPConnectorListResponseTunTypeCNI WARPConnectorListResponseTunType = "cni" +) + +func (r WARPConnectorListResponseTunType) IsKnown() bool { + switch r { + case WARPConnectorListResponseTunTypeCfdTunnel, WARPConnectorListResponseTunTypeWARPConnector, WARPConnectorListResponseTunTypeIPSec, WARPConnectorListResponseTunTypeGRE, WARPConnectorListResponseTunTypeCNI: + return true + } + return false } // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type WARPConnectorDeleteResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` +type WARPConnectorDeleteResponse struct { // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []WARPConnectorDeleteResponseTunnelCfdTunnelConnection `json:"connections"` + AccountTag string `json:"account_tag"` + Connections interface{} `json:"connections,required"` // Timestamp of when the tunnel established at least one connection to Cloudflare's // edge. If `null`, the tunnel is inactive. ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` @@ -732,8 +623,9 @@ type WARPConnectorDeleteResponseTunnelCfdTunnel struct { // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been // deleted. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` + // UUID of the tunnel. + ID string `json:"id"` + Metadata interface{} `json:"metadata,required"` // A user-friendly name for the tunnel. Name string `json:"name"` // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. @@ -745,20 +637,21 @@ type WARPConnectorDeleteResponseTunnelCfdTunnel struct { // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). Status string `json:"status"` // The type of tunnel. - TunType WARPConnectorDeleteResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON warpConnectorDeleteResponseTunnelCfdTunnelJSON `json:"-"` + TunType WARPConnectorDeleteResponseTunType `json:"tun_type"` + JSON warpConnectorDeleteResponseJSON `json:"-"` + union WARPConnectorDeleteResponseUnion } -// warpConnectorDeleteResponseTunnelCfdTunnelJSON contains the JSON metadata for -// the struct [WARPConnectorDeleteResponseTunnelCfdTunnel] -type warpConnectorDeleteResponseTunnelCfdTunnelJSON struct { - ID apijson.Field +// warpConnectorDeleteResponseJSON contains the JSON metadata for the struct +// [WARPConnectorDeleteResponse] +type warpConnectorDeleteResponseJSON struct { AccountTag apijson.Field Connections apijson.Field ConnsActiveAt apijson.Field ConnsInactiveAt apijson.Field CreatedAt apijson.Field DeletedAt apijson.Field + ID apijson.Field Metadata apijson.Field Name apijson.Field RemoteConfig apijson.Field @@ -768,80 +661,43 @@ type warpConnectorDeleteResponseTunnelCfdTunnelJSON struct { ExtraFields map[string]apijson.Field } -func (r *WARPConnectorDeleteResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorDeleteResponseTunnelCfdTunnelJSON) RawJSON() string { +func (r warpConnectorDeleteResponseJSON) RawJSON() string { return r.raw } -func (r WARPConnectorDeleteResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorDeleteResponse() { -} - -type WARPConnectorDeleteResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON warpConnectorDeleteResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// warpConnectorDeleteResponseTunnelCfdTunnelConnectionJSON contains the JSON -// metadata for the struct [WARPConnectorDeleteResponseTunnelCfdTunnelConnection] -type warpConnectorDeleteResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r *WARPConnectorDeleteResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r *WARPConnectorDeleteResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r WARPConnectorDeleteResponse) AsUnion() WARPConnectorDeleteResponseUnion { + return r.union } -func (r warpConnectorDeleteResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [shared.CloudflareTunnel] or +// [warp_connector.WARPConnectorDeleteResponseTunnelWARPConnectorTunnel]. +type WARPConnectorDeleteResponseUnion interface { + ImplementsWARPConnectorWARPConnectorDeleteResponse() } -// The type of tunnel. -type WARPConnectorDeleteResponseTunnelCfdTunnelTunType string - -const ( - WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeCfdTunnel WARPConnectorDeleteResponseTunnelCfdTunnelTunType = "cfd_tunnel" - WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeWARPConnector WARPConnectorDeleteResponseTunnelCfdTunnelTunType = "warp_connector" - WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeIPSec WARPConnectorDeleteResponseTunnelCfdTunnelTunType = "ip_sec" - WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeGRE WARPConnectorDeleteResponseTunnelCfdTunnelTunType = "gre" - WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeCni WARPConnectorDeleteResponseTunnelCfdTunnelTunType = "cni" -) - -func (r WARPConnectorDeleteResponseTunnelCfdTunnelTunType) IsKnown() bool { - switch r { - case WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeCfdTunnel, WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeWARPConnector, WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeIPSec, WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeGRE, WARPConnectorDeleteResponseTunnelCfdTunnelTunTypeCni: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WARPConnectorDeleteResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.CloudflareTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WARPConnectorDeleteResponseTunnelWARPConnectorTunnel{}), + }, + ) } // A Warp Connector Tunnel that connects your origin to Cloudflare's edge. @@ -903,7 +759,7 @@ func (r warpConnectorDeleteResponseTunnelWARPConnectorTunnelJSON) RawJSON() stri return r.raw } -func (r WARPConnectorDeleteResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorDeleteResponse() { +func (r WARPConnectorDeleteResponseTunnelWARPConnectorTunnel) ImplementsWARPConnectorWARPConnectorDeleteResponse() { } type WARPConnectorDeleteResponseTunnelWARPConnectorTunnelConnection struct { @@ -961,48 +817,41 @@ const ( WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeWARPConnector WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunType = "warp_connector" WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeIPSec WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunType = "ip_sec" WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeGRE WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunType = "gre" - WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeCni WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunType = "cni" + WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeCNI WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunType = "cni" ) func (r WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool { switch r { - case WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeCni: + case WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorDeleteResponseTunnelWARPConnectorTunnelTunTypeCNI: return true } return false } -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [warp_connector.WARPConnectorEditResponseTunnelCfdTunnel] or -// [warp_connector.WARPConnectorEditResponseTunnelWARPConnectorTunnel]. -type WARPConnectorEditResponse interface { - implementsWARPConnectorWARPConnectorEditResponse() -} +// The type of tunnel. +type WARPConnectorDeleteResponseTunType string -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WARPConnectorEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorEditResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorEditResponseTunnelWARPConnectorTunnel{}), - }, - ) +const ( + WARPConnectorDeleteResponseTunTypeCfdTunnel WARPConnectorDeleteResponseTunType = "cfd_tunnel" + WARPConnectorDeleteResponseTunTypeWARPConnector WARPConnectorDeleteResponseTunType = "warp_connector" + WARPConnectorDeleteResponseTunTypeIPSec WARPConnectorDeleteResponseTunType = "ip_sec" + WARPConnectorDeleteResponseTunTypeGRE WARPConnectorDeleteResponseTunType = "gre" + WARPConnectorDeleteResponseTunTypeCNI WARPConnectorDeleteResponseTunType = "cni" +) + +func (r WARPConnectorDeleteResponseTunType) IsKnown() bool { + switch r { + case WARPConnectorDeleteResponseTunTypeCfdTunnel, WARPConnectorDeleteResponseTunTypeWARPConnector, WARPConnectorDeleteResponseTunTypeIPSec, WARPConnectorDeleteResponseTunTypeGRE, WARPConnectorDeleteResponseTunTypeCNI: + return true + } + return false } // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type WARPConnectorEditResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` +type WARPConnectorEditResponse struct { // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []WARPConnectorEditResponseTunnelCfdTunnelConnection `json:"connections"` + AccountTag string `json:"account_tag"` + Connections interface{} `json:"connections,required"` // Timestamp of when the tunnel established at least one connection to Cloudflare's // edge. If `null`, the tunnel is inactive. ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` @@ -1014,8 +863,9 @@ type WARPConnectorEditResponseTunnelCfdTunnel struct { // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been // deleted. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` + // UUID of the tunnel. + ID string `json:"id"` + Metadata interface{} `json:"metadata,required"` // A user-friendly name for the tunnel. Name string `json:"name"` // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. @@ -1027,103 +877,67 @@ type WARPConnectorEditResponseTunnelCfdTunnel struct { // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). Status string `json:"status"` // The type of tunnel. - TunType WARPConnectorEditResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON warpConnectorEditResponseTunnelCfdTunnelJSON `json:"-"` + TunType WARPConnectorEditResponseTunType `json:"tun_type"` + JSON warpConnectorEditResponseJSON `json:"-"` + union WARPConnectorEditResponseUnion } -// warpConnectorEditResponseTunnelCfdTunnelJSON contains the JSON metadata for the -// struct [WARPConnectorEditResponseTunnelCfdTunnel] -type warpConnectorEditResponseTunnelCfdTunnelJSON struct { - ID apijson.Field +// warpConnectorEditResponseJSON contains the JSON metadata for the struct +// [WARPConnectorEditResponse] +type warpConnectorEditResponseJSON struct { AccountTag apijson.Field Connections apijson.Field ConnsActiveAt apijson.Field ConnsInactiveAt apijson.Field CreatedAt apijson.Field DeletedAt apijson.Field + ID apijson.Field Metadata apijson.Field Name apijson.Field RemoteConfig apijson.Field Status apijson.Field TunType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorEditResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorEditResponseTunnelCfdTunnelJSON) RawJSON() string { - return r.raw -} - -func (r WARPConnectorEditResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorEditResponse() { -} - -type WARPConnectorEditResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON warpConnectorEditResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// warpConnectorEditResponseTunnelCfdTunnelConnectionJSON contains the JSON -// metadata for the struct [WARPConnectorEditResponseTunnelCfdTunnelConnection] -type warpConnectorEditResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *WARPConnectorEditResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r warpConnectorEditResponseJSON) RawJSON() string { + return r.raw } -func (r warpConnectorEditResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw +func (r *WARPConnectorEditResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -// The type of tunnel. -type WARPConnectorEditResponseTunnelCfdTunnelTunType string +func (r WARPConnectorEditResponse) AsUnion() WARPConnectorEditResponseUnion { + return r.union +} -const ( - WARPConnectorEditResponseTunnelCfdTunnelTunTypeCfdTunnel WARPConnectorEditResponseTunnelCfdTunnelTunType = "cfd_tunnel" - WARPConnectorEditResponseTunnelCfdTunnelTunTypeWARPConnector WARPConnectorEditResponseTunnelCfdTunnelTunType = "warp_connector" - WARPConnectorEditResponseTunnelCfdTunnelTunTypeIPSec WARPConnectorEditResponseTunnelCfdTunnelTunType = "ip_sec" - WARPConnectorEditResponseTunnelCfdTunnelTunTypeGRE WARPConnectorEditResponseTunnelCfdTunnelTunType = "gre" - WARPConnectorEditResponseTunnelCfdTunnelTunTypeCni WARPConnectorEditResponseTunnelCfdTunnelTunType = "cni" -) +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [shared.CloudflareTunnel] or +// [warp_connector.WARPConnectorEditResponseTunnelWARPConnectorTunnel]. +type WARPConnectorEditResponseUnion interface { + ImplementsWARPConnectorWARPConnectorEditResponse() +} -func (r WARPConnectorEditResponseTunnelCfdTunnelTunType) IsKnown() bool { - switch r { - case WARPConnectorEditResponseTunnelCfdTunnelTunTypeCfdTunnel, WARPConnectorEditResponseTunnelCfdTunnelTunTypeWARPConnector, WARPConnectorEditResponseTunnelCfdTunnelTunTypeIPSec, WARPConnectorEditResponseTunnelCfdTunnelTunTypeGRE, WARPConnectorEditResponseTunnelCfdTunnelTunTypeCni: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WARPConnectorEditResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.CloudflareTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WARPConnectorEditResponseTunnelWARPConnectorTunnel{}), + }, + ) } // A Warp Connector Tunnel that connects your origin to Cloudflare's edge. @@ -1185,7 +999,7 @@ func (r warpConnectorEditResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorEditResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorEditResponse() { +func (r WARPConnectorEditResponseTunnelWARPConnectorTunnel) ImplementsWARPConnectorWARPConnectorEditResponse() { } type WARPConnectorEditResponseTunnelWARPConnectorTunnelConnection struct { @@ -1243,48 +1057,41 @@ const ( WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector WARPConnectorEditResponseTunnelWARPConnectorTunnelTunType = "warp_connector" WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeIPSec WARPConnectorEditResponseTunnelWARPConnectorTunnelTunType = "ip_sec" WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeGRE WARPConnectorEditResponseTunnelWARPConnectorTunnelTunType = "gre" - WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeCni WARPConnectorEditResponseTunnelWARPConnectorTunnelTunType = "cni" + WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeCNI WARPConnectorEditResponseTunnelWARPConnectorTunnelTunType = "cni" ) func (r WARPConnectorEditResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool { switch r { - case WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeCni: + case WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorEditResponseTunnelWARPConnectorTunnelTunTypeCNI: return true } return false } -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [warp_connector.WARPConnectorGetResponseTunnelCfdTunnel] or -// [warp_connector.WARPConnectorGetResponseTunnelWARPConnectorTunnel]. -type WARPConnectorGetResponse interface { - implementsWARPConnectorWARPConnectorGetResponse() -} +// The type of tunnel. +type WARPConnectorEditResponseTunType string -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WARPConnectorGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorGetResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WARPConnectorGetResponseTunnelWARPConnectorTunnel{}), - }, - ) +const ( + WARPConnectorEditResponseTunTypeCfdTunnel WARPConnectorEditResponseTunType = "cfd_tunnel" + WARPConnectorEditResponseTunTypeWARPConnector WARPConnectorEditResponseTunType = "warp_connector" + WARPConnectorEditResponseTunTypeIPSec WARPConnectorEditResponseTunType = "ip_sec" + WARPConnectorEditResponseTunTypeGRE WARPConnectorEditResponseTunType = "gre" + WARPConnectorEditResponseTunTypeCNI WARPConnectorEditResponseTunType = "cni" +) + +func (r WARPConnectorEditResponseTunType) IsKnown() bool { + switch r { + case WARPConnectorEditResponseTunTypeCfdTunnel, WARPConnectorEditResponseTunTypeWARPConnector, WARPConnectorEditResponseTunTypeIPSec, WARPConnectorEditResponseTunTypeGRE, WARPConnectorEditResponseTunTypeCNI: + return true + } + return false } // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type WARPConnectorGetResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` +type WARPConnectorGetResponse struct { // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []WARPConnectorGetResponseTunnelCfdTunnelConnection `json:"connections"` + AccountTag string `json:"account_tag"` + Connections interface{} `json:"connections,required"` // Timestamp of when the tunnel established at least one connection to Cloudflare's // edge. If `null`, the tunnel is inactive. ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` @@ -1296,8 +1103,9 @@ type WARPConnectorGetResponseTunnelCfdTunnel struct { // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been // deleted. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` + // UUID of the tunnel. + ID string `json:"id"` + Metadata interface{} `json:"metadata,required"` // A user-friendly name for the tunnel. Name string `json:"name"` // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. @@ -1309,20 +1117,21 @@ type WARPConnectorGetResponseTunnelCfdTunnel struct { // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). Status string `json:"status"` // The type of tunnel. - TunType WARPConnectorGetResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON warpConnectorGetResponseTunnelCfdTunnelJSON `json:"-"` + TunType WARPConnectorGetResponseTunType `json:"tun_type"` + JSON warpConnectorGetResponseJSON `json:"-"` + union WARPConnectorGetResponseUnion } -// warpConnectorGetResponseTunnelCfdTunnelJSON contains the JSON metadata for the -// struct [WARPConnectorGetResponseTunnelCfdTunnel] -type warpConnectorGetResponseTunnelCfdTunnelJSON struct { - ID apijson.Field +// warpConnectorGetResponseJSON contains the JSON metadata for the struct +// [WARPConnectorGetResponse] +type warpConnectorGetResponseJSON struct { AccountTag apijson.Field Connections apijson.Field ConnsActiveAt apijson.Field ConnsInactiveAt apijson.Field CreatedAt apijson.Field DeletedAt apijson.Field + ID apijson.Field Metadata apijson.Field Name apijson.Field RemoteConfig apijson.Field @@ -1332,79 +1141,43 @@ type warpConnectorGetResponseTunnelCfdTunnelJSON struct { ExtraFields map[string]apijson.Field } -func (r *WARPConnectorGetResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorGetResponseTunnelCfdTunnelJSON) RawJSON() string { +func (r warpConnectorGetResponseJSON) RawJSON() string { return r.raw } -func (r WARPConnectorGetResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorGetResponse() {} - -type WARPConnectorGetResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON warpConnectorGetResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// warpConnectorGetResponseTunnelCfdTunnelConnectionJSON contains the JSON metadata -// for the struct [WARPConnectorGetResponseTunnelCfdTunnelConnection] -type warpConnectorGetResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r *WARPConnectorGetResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r *WARPConnectorGetResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r WARPConnectorGetResponse) AsUnion() WARPConnectorGetResponseUnion { + return r.union } -func (r warpConnectorGetResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [shared.CloudflareTunnel] or +// [warp_connector.WARPConnectorGetResponseTunnelWARPConnectorTunnel]. +type WARPConnectorGetResponseUnion interface { + ImplementsWARPConnectorWARPConnectorGetResponse() } -// The type of tunnel. -type WARPConnectorGetResponseTunnelCfdTunnelTunType string - -const ( - WARPConnectorGetResponseTunnelCfdTunnelTunTypeCfdTunnel WARPConnectorGetResponseTunnelCfdTunnelTunType = "cfd_tunnel" - WARPConnectorGetResponseTunnelCfdTunnelTunTypeWARPConnector WARPConnectorGetResponseTunnelCfdTunnelTunType = "warp_connector" - WARPConnectorGetResponseTunnelCfdTunnelTunTypeIPSec WARPConnectorGetResponseTunnelCfdTunnelTunType = "ip_sec" - WARPConnectorGetResponseTunnelCfdTunnelTunTypeGRE WARPConnectorGetResponseTunnelCfdTunnelTunType = "gre" - WARPConnectorGetResponseTunnelCfdTunnelTunTypeCni WARPConnectorGetResponseTunnelCfdTunnelTunType = "cni" -) - -func (r WARPConnectorGetResponseTunnelCfdTunnelTunType) IsKnown() bool { - switch r { - case WARPConnectorGetResponseTunnelCfdTunnelTunTypeCfdTunnel, WARPConnectorGetResponseTunnelCfdTunnelTunTypeWARPConnector, WARPConnectorGetResponseTunnelCfdTunnelTunTypeIPSec, WARPConnectorGetResponseTunnelCfdTunnelTunTypeGRE, WARPConnectorGetResponseTunnelCfdTunnelTunTypeCni: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WARPConnectorGetResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.CloudflareTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WARPConnectorGetResponseTunnelWARPConnectorTunnel{}), + }, + ) } // A Warp Connector Tunnel that connects your origin to Cloudflare's edge. @@ -1466,7 +1239,7 @@ func (r warpConnectorGetResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorGetResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorGetResponse() { +func (r WARPConnectorGetResponseTunnelWARPConnectorTunnel) ImplementsWARPConnectorWARPConnectorGetResponse() { } type WARPConnectorGetResponseTunnelWARPConnectorTunnelConnection struct { @@ -1524,12 +1297,31 @@ const ( WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeWARPConnector WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType = "warp_connector" WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeIPSec WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType = "ip_sec" WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeGRE WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType = "gre" - WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeCni WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType = "cni" + WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeCNI WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType = "cni" ) func (r WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool { switch r { - case WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeCni: + case WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeIPSec, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeGRE, WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeCNI: + return true + } + return false +} + +// The type of tunnel. +type WARPConnectorGetResponseTunType string + +const ( + WARPConnectorGetResponseTunTypeCfdTunnel WARPConnectorGetResponseTunType = "cfd_tunnel" + WARPConnectorGetResponseTunTypeWARPConnector WARPConnectorGetResponseTunType = "warp_connector" + WARPConnectorGetResponseTunTypeIPSec WARPConnectorGetResponseTunType = "ip_sec" + WARPConnectorGetResponseTunTypeGRE WARPConnectorGetResponseTunType = "gre" + WARPConnectorGetResponseTunTypeCNI WARPConnectorGetResponseTunType = "cni" +) + +func (r WARPConnectorGetResponseTunType) IsKnown() bool { + switch r { + case WARPConnectorGetResponseTunTypeCfdTunnel, WARPConnectorGetResponseTunTypeWARPConnector, WARPConnectorGetResponseTunTypeIPSec, WARPConnectorGetResponseTunTypeGRE, WARPConnectorGetResponseTunTypeCNI: return true } return false @@ -1537,13 +1329,13 @@ func (r WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool // Union satisfied by [warp_connector.WARPConnectorTokenResponseUnknown], // [warp_connector.WARPConnectorTokenResponseArray] or [shared.UnionString]. -type WARPConnectorTokenResponse interface { - ImplementsWARPConnectorWARPConnectorTokenResponse() +type WARPConnectorTokenResponseUnion interface { + ImplementsWARPConnectorWARPConnectorTokenResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*WARPConnectorTokenResponse)(nil)).Elem(), + reflect.TypeOf((*WARPConnectorTokenResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -1558,7 +1350,7 @@ func init() { type WARPConnectorTokenResponseArray []interface{} -func (r WARPConnectorTokenResponseArray) ImplementsWARPConnectorWARPConnectorTokenResponse() {} +func (r WARPConnectorTokenResponseArray) ImplementsWARPConnectorWARPConnectorTokenResponseUnion() {} type WARPConnectorNewParams struct { // Cloudflare account ID @@ -1572,8 +1364,8 @@ func (r WARPConnectorNewParams) MarshalJSON() (data []byte, err error) { } type WARPConnectorNewResponseEnvelope struct { - Errors []WARPConnectorNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WARPConnectorNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. Result WARPConnectorNewResponse `json:"result,required"` // Whether the API call was successful @@ -1600,52 +1392,6 @@ func (r warpConnectorNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WARPConnectorNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// warpConnectorNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WARPConnectorNewResponseEnvelopeErrors] -type warpConnectorNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WARPConnectorNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// warpConnectorNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WARPConnectorNewResponseEnvelopeMessages] -type warpConnectorNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WARPConnectorNewResponseEnvelopeSuccess bool @@ -1677,7 +1423,9 @@ type WARPConnectorListParams struct { // Page number of paginated results. Page param.Field[float64] `query:"page"` // Number of results to display. - PerPage param.Field[float64] `query:"per_page"` + PerPage param.Field[float64] `query:"per_page"` + // UUID of the tunnel. + UUID param.Field[string] `query:"uuid"` WasActiveAt param.Field[time.Time] `query:"was_active_at" format:"date-time"` WasInactiveAt param.Field[time.Time] `query:"was_inactive_at" format:"date-time"` } @@ -1686,15 +1434,15 @@ type WARPConnectorListParams struct { // `url.Values`. func (r WARPConnectorListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type WARPConnectorDeleteParams struct { // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r WARPConnectorDeleteParams) MarshalJSON() (data []byte, err error) { @@ -1702,8 +1450,8 @@ func (r WARPConnectorDeleteParams) MarshalJSON() (data []byte, err error) { } type WARPConnectorDeleteResponseEnvelope struct { - Errors []WARPConnectorDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WARPConnectorDeleteResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. Result WARPConnectorDeleteResponse `json:"result,required"` // Whether the API call was successful @@ -1730,52 +1478,6 @@ func (r warpConnectorDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WARPConnectorDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// warpConnectorDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WARPConnectorDeleteResponseEnvelopeErrors] -type warpConnectorDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WARPConnectorDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// warpConnectorDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WARPConnectorDeleteResponseEnvelopeMessages] -type warpConnectorDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WARPConnectorDeleteResponseEnvelopeSuccess bool @@ -1806,8 +1508,8 @@ func (r WARPConnectorEditParams) MarshalJSON() (data []byte, err error) { } type WARPConnectorEditResponseEnvelope struct { - Errors []WARPConnectorEditResponseEnvelopeErrors `json:"errors,required"` - Messages []WARPConnectorEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. Result WARPConnectorEditResponse `json:"result,required"` // Whether the API call was successful @@ -1834,52 +1536,6 @@ func (r warpConnectorEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WARPConnectorEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// warpConnectorEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WARPConnectorEditResponseEnvelopeErrors] -type warpConnectorEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WARPConnectorEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// warpConnectorEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WARPConnectorEditResponseEnvelopeMessages] -type warpConnectorEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WARPConnectorEditResponseEnvelopeSuccess bool @@ -1901,8 +1557,8 @@ type WARPConnectorGetParams struct { } type WARPConnectorGetResponseEnvelope struct { - Errors []WARPConnectorGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WARPConnectorGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. Result WARPConnectorGetResponse `json:"result,required"` // Whether the API call was successful @@ -1929,52 +1585,6 @@ func (r warpConnectorGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WARPConnectorGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// warpConnectorGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WARPConnectorGetResponseEnvelopeErrors] -type warpConnectorGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WARPConnectorGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// warpConnectorGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WARPConnectorGetResponseEnvelopeMessages] -type warpConnectorGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WARPConnectorGetResponseEnvelopeSuccess bool @@ -1996,9 +1606,9 @@ type WARPConnectorTokenParams struct { } type WARPConnectorTokenResponseEnvelope struct { - Errors []WARPConnectorTokenResponseEnvelopeErrors `json:"errors,required"` - Messages []WARPConnectorTokenResponseEnvelopeMessages `json:"messages,required"` - Result WARPConnectorTokenResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result WARPConnectorTokenResponseUnion `json:"result,required"` // Whether the API call was successful Success WARPConnectorTokenResponseEnvelopeSuccess `json:"success,required"` JSON warpConnectorTokenResponseEnvelopeJSON `json:"-"` @@ -2023,52 +1633,6 @@ func (r warpConnectorTokenResponseEnvelopeJSON) RawJSON() string { return r.raw } -type WARPConnectorTokenResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorTokenResponseEnvelopeErrorsJSON `json:"-"` -} - -// warpConnectorTokenResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WARPConnectorTokenResponseEnvelopeErrors] -type warpConnectorTokenResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorTokenResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorTokenResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WARPConnectorTokenResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON warpConnectorTokenResponseEnvelopeMessagesJSON `json:"-"` -} - -// warpConnectorTokenResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WARPConnectorTokenResponseEnvelopeMessages] -type warpConnectorTokenResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WARPConnectorTokenResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r warpConnectorTokenResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type WARPConnectorTokenResponseEnvelopeSuccess bool diff --git a/warp_connector/warpconnector_test.go b/warp_connector/warpconnector_test.go index cd22f48844e..4a52ce9e494 100644 --- a/warp_connector/warpconnector_test.go +++ b/warp_connector/warpconnector_test.go @@ -65,6 +65,7 @@ func TestWARPConnectorListWithOptionalParams(t *testing.T) { Name: cloudflare.F("blog"), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(1.000000), + UUID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), WasActiveAt: cloudflare.F(time.Now()), WasInactiveAt: cloudflare.F(time.Now()), }) @@ -96,7 +97,7 @@ func TestWARPConnectorDelete(t *testing.T) { "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", warp_connector.WARPConnectorDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/web3/aliases.go b/web3/aliases.go index 64b46f2c8ab..83fdb7aa08c 100644 --- a/web3/aliases.go +++ b/web3/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/web3/hostname.go b/web3/hostname.go index 715ad7c6398..6258eb9b789 100644 --- a/web3/hostname.go +++ b/web3/hostname.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -35,7 +36,7 @@ func NewHostnameService(opts ...option.RequestOption) (r *HostnameService) { } // Create Web3 Hostname -func (r *HostnameService) New(ctx context.Context, zoneIdentifier string, body HostnameNewParams, opts ...option.RequestOption) (res *DistributedWebHostname, err error) { +func (r *HostnameService) New(ctx context.Context, zoneIdentifier string, body HostnameNewParams, opts ...option.RequestOption) (res *Hostname, err error) { opts = append(r.Options[:], opts...) var env HostnameNewResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames", zoneIdentifier) @@ -48,7 +49,7 @@ func (r *HostnameService) New(ctx context.Context, zoneIdentifier string, body H } // List Web3 Hostnames -func (r *HostnameService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[DistributedWebHostname], err error) { +func (r *HostnameService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[Hostname], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -66,12 +67,12 @@ func (r *HostnameService) List(ctx context.Context, zoneIdentifier string, opts } // List Web3 Hostnames -func (r *HostnameService) ListAutoPaging(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DistributedWebHostname] { +func (r *HostnameService) ListAutoPaging(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Hostname] { return pagination.NewSinglePageAutoPager(r.List(ctx, zoneIdentifier, opts...)) } // Delete Web3 Hostname -func (r *HostnameService) Delete(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HostnameDeleteResponse, err error) { +func (r *HostnameService) Delete(ctx context.Context, zoneIdentifier string, identifier string, body HostnameDeleteParams, opts ...option.RequestOption) (res *HostnameDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env HostnameDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) @@ -84,7 +85,7 @@ func (r *HostnameService) Delete(ctx context.Context, zoneIdentifier string, ide } // Edit Web3 Hostname -func (r *HostnameService) Edit(ctx context.Context, zoneIdentifier string, identifier string, body HostnameEditParams, opts ...option.RequestOption) (res *DistributedWebHostname, err error) { +func (r *HostnameService) Edit(ctx context.Context, zoneIdentifier string, identifier string, body HostnameEditParams, opts ...option.RequestOption) (res *Hostname, err error) { opts = append(r.Options[:], opts...) var env HostnameEditResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) @@ -97,7 +98,7 @@ func (r *HostnameService) Edit(ctx context.Context, zoneIdentifier string, ident } // Web3 Hostname Details -func (r *HostnameService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *DistributedWebHostname, err error) { +func (r *HostnameService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *Hostname, err error) { opts = append(r.Options[:], opts...) var env HostnameGetResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) @@ -109,7 +110,7 @@ func (r *HostnameService) Get(ctx context.Context, zoneIdentifier string, identi return } -type DistributedWebHostname struct { +type Hostname struct { // Identifier ID string `json:"id"` CreatedOn time.Time `json:"created_on" format:"date-time"` @@ -121,15 +122,14 @@ type DistributedWebHostname struct { // The hostname that will point to the target gateway via CNAME. Name string `json:"name"` // Status of the hostname's activation. - Status DistributedWebHostnameStatus `json:"status"` + Status HostnameStatus `json:"status"` // Target gateway of the hostname. - Target DistributedWebHostnameTarget `json:"target"` - JSON distributedWebHostnameJSON `json:"-"` + Target HostnameTarget `json:"target"` + JSON hostnameJSON `json:"-"` } -// distributedWebHostnameJSON contains the JSON metadata for the struct -// [DistributedWebHostname] -type distributedWebHostnameJSON struct { +// hostnameJSON contains the JSON metadata for the struct [Hostname] +type hostnameJSON struct { ID apijson.Field CreatedOn apijson.Field Description apijson.Field @@ -142,49 +142,64 @@ type distributedWebHostnameJSON struct { ExtraFields map[string]apijson.Field } -func (r *DistributedWebHostname) UnmarshalJSON(data []byte) (err error) { +func (r *Hostname) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r distributedWebHostnameJSON) RawJSON() string { +func (r hostnameJSON) RawJSON() string { return r.raw } +func (r Hostname) ImplementsRulesListItemGetResponseUnion() {} + // Status of the hostname's activation. -type DistributedWebHostnameStatus string +type HostnameStatus string const ( - DistributedWebHostnameStatusActive DistributedWebHostnameStatus = "active" - DistributedWebHostnameStatusPending DistributedWebHostnameStatus = "pending" - DistributedWebHostnameStatusDeleting DistributedWebHostnameStatus = "deleting" - DistributedWebHostnameStatusError DistributedWebHostnameStatus = "error" + HostnameStatusActive HostnameStatus = "active" + HostnameStatusPending HostnameStatus = "pending" + HostnameStatusDeleting HostnameStatus = "deleting" + HostnameStatusError HostnameStatus = "error" ) -func (r DistributedWebHostnameStatus) IsKnown() bool { +func (r HostnameStatus) IsKnown() bool { switch r { - case DistributedWebHostnameStatusActive, DistributedWebHostnameStatusPending, DistributedWebHostnameStatusDeleting, DistributedWebHostnameStatusError: + case HostnameStatusActive, HostnameStatusPending, HostnameStatusDeleting, HostnameStatusError: return true } return false } // Target gateway of the hostname. -type DistributedWebHostnameTarget string +type HostnameTarget string const ( - DistributedWebHostnameTargetEthereum DistributedWebHostnameTarget = "ethereum" - DistributedWebHostnameTargetIPFS DistributedWebHostnameTarget = "ipfs" - DistributedWebHostnameTargetIPFSUniversalPath DistributedWebHostnameTarget = "ipfs_universal_path" + HostnameTargetEthereum HostnameTarget = "ethereum" + HostnameTargetIPFS HostnameTarget = "ipfs" + HostnameTargetIPFSUniversalPath HostnameTarget = "ipfs_universal_path" ) -func (r DistributedWebHostnameTarget) IsKnown() bool { +func (r HostnameTarget) IsKnown() bool { switch r { - case DistributedWebHostnameTargetEthereum, DistributedWebHostnameTargetIPFS, DistributedWebHostnameTargetIPFSUniversalPath: + case HostnameTargetEthereum, HostnameTargetIPFS, HostnameTargetIPFSUniversalPath: return true } return false } +type HostnameParam struct { + // An optional description of the hostname. + Description param.Field[string] `json:"description"` + // DNSLink value used if the target is ipfs. + Dnslink param.Field[string] `json:"dnslink"` + // Target gateway of the hostname. + Target param.Field[HostnameTarget] `json:"target"` +} + +func (r HostnameParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type HostnameDeleteResponse struct { // Identifier ID string `json:"id,required"` @@ -238,9 +253,9 @@ func (r HostnameNewParamsTarget) IsKnown() bool { } type HostnameNewResponseEnvelope struct { - Errors []HostnameNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameNewResponseEnvelopeMessages `json:"messages,required"` - Result DistributedWebHostname `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Hostname `json:"result,required"` // Whether the API call was successful Success HostnameNewResponseEnvelopeSuccess `json:"success,required"` JSON hostnameNewResponseEnvelopeJSON `json:"-"` @@ -265,52 +280,6 @@ func (r hostnameNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [HostnameNewResponseEnvelopeErrors] -type hostnameNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HostnameNewResponseEnvelopeMessages] -type hostnameNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameNewResponseEnvelopeSuccess bool @@ -326,10 +295,18 @@ func (r HostnameNewResponseEnvelopeSuccess) IsKnown() bool { return false } +type HostnameDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r HostnameDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type HostnameDeleteResponseEnvelope struct { - Errors []HostnameDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HostnameDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success HostnameDeleteResponseEnvelopeSuccess `json:"success,required"` JSON hostnameDeleteResponseEnvelopeJSON `json:"-"` @@ -354,52 +331,6 @@ func (r hostnameDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HostnameDeleteResponseEnvelopeErrors] -type hostnameDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HostnameDeleteResponseEnvelopeMessages] -type hostnameDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameDeleteResponseEnvelopeSuccess bool @@ -427,9 +358,9 @@ func (r HostnameEditParams) MarshalJSON() (data []byte, err error) { } type HostnameEditResponseEnvelope struct { - Errors []HostnameEditResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameEditResponseEnvelopeMessages `json:"messages,required"` - Result DistributedWebHostname `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Hostname `json:"result,required"` // Whether the API call was successful Success HostnameEditResponseEnvelopeSuccess `json:"success,required"` JSON hostnameEditResponseEnvelopeJSON `json:"-"` @@ -454,52 +385,6 @@ func (r hostnameEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [HostnameEditResponseEnvelopeErrors] -type hostnameEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HostnameEditResponseEnvelopeMessages] -type hostnameEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameEditResponseEnvelopeSuccess bool @@ -516,9 +401,9 @@ func (r HostnameEditResponseEnvelopeSuccess) IsKnown() bool { } type HostnameGetResponseEnvelope struct { - Errors []HostnameGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameGetResponseEnvelopeMessages `json:"messages,required"` - Result DistributedWebHostname `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Hostname `json:"result,required"` // Whether the API call was successful Success HostnameGetResponseEnvelopeSuccess `json:"success,required"` JSON hostnameGetResponseEnvelopeJSON `json:"-"` @@ -543,52 +428,6 @@ func (r hostnameGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HostnameGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [HostnameGetResponseEnvelopeErrors] -type hostnameGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HostnameGetResponseEnvelopeMessages] -type hostnameGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameGetResponseEnvelopeSuccess bool diff --git a/web3/hostname_test.go b/web3/hostname_test.go index e91b06efcf6..f8881dd8584 100644 --- a/web3/hostname_test.go +++ b/web3/hostname_test.go @@ -88,6 +88,9 @@ func TestHostnameDelete(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", + web3.HostnameDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/web3/hostnameipfsuniversalpathcontentlist.go b/web3/hostnameipfsuniversalpathcontentlist.go index fe57f76162b..dfb3add0f6f 100644 --- a/web3/hostnameipfsuniversalpathcontentlist.go +++ b/web3/hostnameipfsuniversalpathcontentlist.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewHostnameIPFSUniversalPathContentListService(opts ...option.RequestOption } // Update IPFS Universal Path Gateway Content List -func (r *HostnameIPFSUniversalPathContentListService) Update(ctx context.Context, zoneIdentifier string, identifier string, body HostnameIPFSUniversalPathContentListUpdateParams, opts ...option.RequestOption) (res *DistributedWebConfigContentList, err error) { +func (r *HostnameIPFSUniversalPathContentListService) Update(ctx context.Context, zoneIdentifier string, identifier string, body HostnameIPFSUniversalPathContentListUpdateParams, opts ...option.RequestOption) (res *ContentList, err error) { opts = append(r.Options[:], opts...) var env HostnameIPFSUniversalPathContentListUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list", zoneIdentifier, identifier) @@ -48,7 +49,7 @@ func (r *HostnameIPFSUniversalPathContentListService) Update(ctx context.Context } // IPFS Universal Path Gateway Content List Details -func (r *HostnameIPFSUniversalPathContentListService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *DistributedWebConfigContentList, err error) { +func (r *HostnameIPFSUniversalPathContentListService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *ContentList, err error) { opts = append(r.Options[:], opts...) var env HostnameIPFSUniversalPathContentListGetResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list", zoneIdentifier, identifier) @@ -60,38 +61,37 @@ func (r *HostnameIPFSUniversalPathContentListService) Get(ctx context.Context, z return } -type DistributedWebConfigContentList struct { +type ContentList struct { // Behavior of the content list. - Action DistributedWebConfigContentListAction `json:"action"` - JSON distributedWebConfigContentListJSON `json:"-"` + Action ContentListAction `json:"action"` + JSON contentListJSON `json:"-"` } -// distributedWebConfigContentListJSON contains the JSON metadata for the struct -// [DistributedWebConfigContentList] -type distributedWebConfigContentListJSON struct { +// contentListJSON contains the JSON metadata for the struct [ContentList] +type contentListJSON struct { Action apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DistributedWebConfigContentList) UnmarshalJSON(data []byte) (err error) { +func (r *ContentList) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r distributedWebConfigContentListJSON) RawJSON() string { +func (r contentListJSON) RawJSON() string { return r.raw } // Behavior of the content list. -type DistributedWebConfigContentListAction string +type ContentListAction string const ( - DistributedWebConfigContentListActionBlock DistributedWebConfigContentListAction = "block" + ContentListActionBlock ContentListAction = "block" ) -func (r DistributedWebConfigContentListAction) IsKnown() bool { +func (r ContentListAction) IsKnown() bool { switch r { - case DistributedWebConfigContentListActionBlock: + case ContentListActionBlock: return true } return false @@ -101,7 +101,7 @@ type HostnameIPFSUniversalPathContentListUpdateParams struct { // Behavior of the content list. Action param.Field[HostnameIPFSUniversalPathContentListUpdateParamsAction] `json:"action,required"` // Content list entries. - Entries param.Field[[]DistributedWebConfigContentListEntryParam] `json:"entries,required"` + Entries param.Field[[]HostnameIPFSUniversalPathContentListUpdateParamsEntry] `json:"entries,required"` } func (r HostnameIPFSUniversalPathContentListUpdateParams) MarshalJSON() (data []byte, err error) { @@ -123,10 +123,40 @@ func (r HostnameIPFSUniversalPathContentListUpdateParamsAction) IsKnown() bool { return false } +// Content list entry to be blocked. +type HostnameIPFSUniversalPathContentListUpdateParamsEntry 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[HostnameIPFSUniversalPathContentListUpdateParamsEntriesType] `json:"type"` +} + +func (r HostnameIPFSUniversalPathContentListUpdateParamsEntry) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of content list entry to block. +type HostnameIPFSUniversalPathContentListUpdateParamsEntriesType string + +const ( + HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid HostnameIPFSUniversalPathContentListUpdateParamsEntriesType = "cid" + HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeContentPath HostnameIPFSUniversalPathContentListUpdateParamsEntriesType = "content_path" +) + +func (r HostnameIPFSUniversalPathContentListUpdateParamsEntriesType) IsKnown() bool { + switch r { + case HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid, HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeContentPath: + return true + } + return false +} + type HostnameIPFSUniversalPathContentListUpdateResponseEnvelope struct { - Errors []HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DistributedWebConfigContentList `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ContentList `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON `json:"-"` @@ -152,54 +182,6 @@ func (r hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON) RawJSON( return r.raw } -type HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors] -type hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages] -type hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess bool @@ -216,9 +198,9 @@ func (r HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess) IsKno } type HostnameIPFSUniversalPathContentListGetResponseEnvelope struct { - Errors []HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages `json:"messages,required"` - Result DistributedWebConfigContentList `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ContentList `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON `json:"-"` @@ -244,54 +226,6 @@ func (r hostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON) RawJSON() s return r.raw } -type HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors] -type hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages] -type hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess bool diff --git a/web3/hostnameipfsuniversalpathcontentlist_test.go b/web3/hostnameipfsuniversalpathcontentlist_test.go index 99784cb4fed..f04882f17d1 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.DistributedWebConfigContentListEntryParam{{ + Entries: cloudflare.F([]web3.HostnameIPFSUniversalPathContentListUpdateParamsEntry{{ Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(web3.DistributedWebConfigContentListEntryTypeCid), + Type: cloudflare.F(web3.HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid), }, { Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(web3.DistributedWebConfigContentListEntryTypeCid), + Type: cloudflare.F(web3.HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid), }, { Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(web3.DistributedWebConfigContentListEntryTypeCid), + Type: cloudflare.F(web3.HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid), }}), }, ) diff --git a/web3/hostnameipfsuniversalpathcontentlistentry.go b/web3/hostnameipfsuniversalpathcontentlistentry.go index ba1f35ec6ec..b47006fe67c 100644 --- a/web3/hostnameipfsuniversalpathcontentlistentry.go +++ b/web3/hostnameipfsuniversalpathcontentlistentry.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,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 *DistributedWebConfigContentListEntry, err error) { +func (r *HostnameIPFSUniversalPathContentListEntryService) New(ctx context.Context, zoneIdentifier string, identifier string, body HostnameIPFSUniversalPathContentListEntryNewParams, opts ...option.RequestOption) (res *HostnameIPFSUniversalPathContentListEntryNewResponse, 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) @@ -47,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 *DistributedWebConfigContentListEntry, err error) { +func (r *HostnameIPFSUniversalPathContentListEntryService) Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body HostnameIPFSUniversalPathContentListEntryUpdateParams, opts ...option.RequestOption) (res *HostnameIPFSUniversalPathContentListEntryUpdateResponse, 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) @@ -73,7 +74,7 @@ func (r *HostnameIPFSUniversalPathContentListEntryService) List(ctx context.Cont } // Delete IPFS Universal Path Gateway Content List Entry -func (r *HostnameIPFSUniversalPathContentListEntryService) Delete(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *HostnameIPFSUniversalPathContentListEntryDeleteResponse, err error) { +func (r *HostnameIPFSUniversalPathContentListEntryService) Delete(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body HostnameIPFSUniversalPathContentListEntryDeleteParams, opts ...option.RequestOption) (res *HostnameIPFSUniversalPathContentListEntryDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) @@ -86,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 *DistributedWebConfigContentListEntry, err error) { +func (r *HostnameIPFSUniversalPathContentListEntryService) Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *HostnameIPFSUniversalPathContentListEntryGetResponse, 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) @@ -99,7 +100,7 @@ func (r *HostnameIPFSUniversalPathContentListEntryService) Get(ctx context.Conte } // Content list entry to be blocked. -type DistributedWebConfigContentListEntry struct { +type HostnameIPFSUniversalPathContentListEntryNewResponse struct { // Identifier ID string `json:"id"` // CID or content path of content to block. @@ -109,13 +110,13 @@ type DistributedWebConfigContentListEntry struct { Description string `json:"description"` ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Type of content list entry to block. - Type DistributedWebConfigContentListEntryType `json:"type"` - JSON distributedWebConfigContentListEntryJSON `json:"-"` + Type HostnameIPFSUniversalPathContentListEntryNewResponseType `json:"type"` + JSON hostnameIPFSUniversalPathContentListEntryNewResponseJSON `json:"-"` } -// distributedWebConfigContentListEntryJSON contains the JSON metadata for the -// struct [DistributedWebConfigContentListEntry] -type distributedWebConfigContentListEntryJSON struct { +// hostnameIPFSUniversalPathContentListEntryNewResponseJSON contains the JSON +// metadata for the struct [HostnameIPFSUniversalPathContentListEntryNewResponse] +type hostnameIPFSUniversalPathContentListEntryNewResponseJSON struct { ID apijson.Field Content apijson.Field CreatedOn apijson.Field @@ -126,48 +127,87 @@ type distributedWebConfigContentListEntryJSON struct { ExtraFields map[string]apijson.Field } -func (r *DistributedWebConfigContentListEntry) UnmarshalJSON(data []byte) (err error) { +func (r *HostnameIPFSUniversalPathContentListEntryNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r distributedWebConfigContentListEntryJSON) RawJSON() string { +func (r hostnameIPFSUniversalPathContentListEntryNewResponseJSON) RawJSON() string { return r.raw } // Type of content list entry to block. -type DistributedWebConfigContentListEntryType string +type HostnameIPFSUniversalPathContentListEntryNewResponseType string const ( - DistributedWebConfigContentListEntryTypeCid DistributedWebConfigContentListEntryType = "cid" - DistributedWebConfigContentListEntryTypeContentPath DistributedWebConfigContentListEntryType = "content_path" + HostnameIPFSUniversalPathContentListEntryNewResponseTypeCid HostnameIPFSUniversalPathContentListEntryNewResponseType = "cid" + HostnameIPFSUniversalPathContentListEntryNewResponseTypeContentPath HostnameIPFSUniversalPathContentListEntryNewResponseType = "content_path" ) -func (r DistributedWebConfigContentListEntryType) IsKnown() bool { +func (r HostnameIPFSUniversalPathContentListEntryNewResponseType) IsKnown() bool { switch r { - case DistributedWebConfigContentListEntryTypeCid, DistributedWebConfigContentListEntryTypeContentPath: + case HostnameIPFSUniversalPathContentListEntryNewResponseTypeCid, HostnameIPFSUniversalPathContentListEntryNewResponseTypeContentPath: return true } return false } // Content list entry to be blocked. -type DistributedWebConfigContentListEntryParam struct { +type HostnameIPFSUniversalPathContentListEntryUpdateResponse struct { + // Identifier + ID string `json:"id"` // CID or content path of content to block. - Content param.Field[string] `json:"content"` + Content string `json:"content"` + CreatedOn time.Time `json:"created_on" format:"date-time"` // An optional description of the content list entry. - Description param.Field[string] `json:"description"` + Description string `json:"description"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Type of content list entry to block. - Type param.Field[DistributedWebConfigContentListEntryType] `json:"type"` + Type HostnameIPFSUniversalPathContentListEntryUpdateResponseType `json:"type"` + JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseJSON `json:"-"` } -func (r DistributedWebConfigContentListEntryParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// hostnameIPFSUniversalPathContentListEntryUpdateResponseJSON contains the JSON +// metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryUpdateResponse] +type hostnameIPFSUniversalPathContentListEntryUpdateResponseJSON struct { + ID apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// Type of content list entry to block. +type HostnameIPFSUniversalPathContentListEntryUpdateResponseType string + +const ( + HostnameIPFSUniversalPathContentListEntryUpdateResponseTypeCid HostnameIPFSUniversalPathContentListEntryUpdateResponseType = "cid" + HostnameIPFSUniversalPathContentListEntryUpdateResponseTypeContentPath HostnameIPFSUniversalPathContentListEntryUpdateResponseType = "content_path" +) + +func (r HostnameIPFSUniversalPathContentListEntryUpdateResponseType) IsKnown() bool { + switch r { + case HostnameIPFSUniversalPathContentListEntryUpdateResponseTypeCid, HostnameIPFSUniversalPathContentListEntryUpdateResponseTypeContentPath: + return true + } + return false } type HostnameIPFSUniversalPathContentListEntryListResponse struct { // Content list entries. - Entries []DistributedWebConfigContentListEntry `json:"entries"` - JSON hostnameIPFSUniversalPathContentListEntryListResponseJSON `json:"-"` + Entries []HostnameIPFSUniversalPathContentListEntryListResponseEntry `json:"entries"` + JSON hostnameIPFSUniversalPathContentListEntryListResponseJSON `json:"-"` } // hostnameIPFSUniversalPathContentListEntryListResponseJSON contains the JSON @@ -186,6 +226,59 @@ func (r hostnameIPFSUniversalPathContentListEntryListResponseJSON) RawJSON() str return r.raw } +// Content list entry to be blocked. +type HostnameIPFSUniversalPathContentListEntryListResponseEntry struct { + // Identifier + ID string `json:"id"` + // CID or content path of content to block. + Content string `json:"content"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional description of the content list entry. + Description string `json:"description"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Type of content list entry to block. + Type HostnameIPFSUniversalPathContentListEntryListResponseEntriesType `json:"type"` + JSON hostnameIPFSUniversalPathContentListEntryListResponseEntryJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryListResponseEntryJSON contains the JSON +// metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryListResponseEntry] +type hostnameIPFSUniversalPathContentListEntryListResponseEntryJSON struct { + ID apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryListResponseEntry) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryListResponseEntryJSON) RawJSON() string { + return r.raw +} + +// Type of content list entry to block. +type HostnameIPFSUniversalPathContentListEntryListResponseEntriesType string + +const ( + HostnameIPFSUniversalPathContentListEntryListResponseEntriesTypeCid HostnameIPFSUniversalPathContentListEntryListResponseEntriesType = "cid" + HostnameIPFSUniversalPathContentListEntryListResponseEntriesTypeContentPath HostnameIPFSUniversalPathContentListEntryListResponseEntriesType = "content_path" +) + +func (r HostnameIPFSUniversalPathContentListEntryListResponseEntriesType) IsKnown() bool { + switch r { + case HostnameIPFSUniversalPathContentListEntryListResponseEntriesTypeCid, HostnameIPFSUniversalPathContentListEntryListResponseEntriesTypeContentPath: + return true + } + return false +} + type HostnameIPFSUniversalPathContentListEntryDeleteResponse struct { // Identifier ID string `json:"id,required"` @@ -209,6 +302,58 @@ func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseJSON) RawJSON() s return r.raw } +// Content list entry to be blocked. +type HostnameIPFSUniversalPathContentListEntryGetResponse struct { + // Identifier + ID string `json:"id"` + // CID or content path of content to block. + Content string `json:"content"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional description of the content list entry. + Description string `json:"description"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Type of content list entry to block. + Type HostnameIPFSUniversalPathContentListEntryGetResponseType `json:"type"` + JSON hostnameIPFSUniversalPathContentListEntryGetResponseJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryGetResponseJSON contains the JSON +// metadata for the struct [HostnameIPFSUniversalPathContentListEntryGetResponse] +type hostnameIPFSUniversalPathContentListEntryGetResponseJSON struct { + ID apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryGetResponseJSON) RawJSON() string { + return r.raw +} + +// Type of content list entry to block. +type HostnameIPFSUniversalPathContentListEntryGetResponseType string + +const ( + HostnameIPFSUniversalPathContentListEntryGetResponseTypeCid HostnameIPFSUniversalPathContentListEntryGetResponseType = "cid" + HostnameIPFSUniversalPathContentListEntryGetResponseTypeContentPath HostnameIPFSUniversalPathContentListEntryGetResponseType = "content_path" +) + +func (r HostnameIPFSUniversalPathContentListEntryGetResponseType) IsKnown() bool { + switch r { + case HostnameIPFSUniversalPathContentListEntryGetResponseTypeCid, HostnameIPFSUniversalPathContentListEntryGetResponseTypeContentPath: + return true + } + return false +} + type HostnameIPFSUniversalPathContentListEntryNewParams struct { // CID or content path of content to block. Content param.Field[string] `json:"content,required"` @@ -239,10 +384,10 @@ func (r HostnameIPFSUniversalPathContentListEntryNewParamsType) IsKnown() bool { } type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope struct { - Errors []HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Content list entry to be blocked. - Result DistributedWebConfigContentListEntry `json:"result,required"` + Result HostnameIPFSUniversalPathContentListEntryNewResponse `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON `json:"-"` @@ -268,54 +413,6 @@ func (r hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON) RawJSO return r.raw } -type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors] -type hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages] -type hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess bool @@ -361,10 +458,10 @@ func (r HostnameIPFSUniversalPathContentListEntryUpdateParamsType) IsKnown() boo } type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope struct { - Errors []HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Content list entry to be blocked. - Result DistributedWebConfigContentListEntry `json:"result,required"` + Result HostnameIPFSUniversalPathContentListEntryUpdateResponse `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON `json:"-"` @@ -390,54 +487,6 @@ func (r hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON) Raw return r.raw } -type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors] -type hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages] -type hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess bool @@ -454,9 +503,9 @@ func (r HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess) } type HostnameIPFSUniversalPathContentListEntryListResponseEnvelope struct { - Errors []HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages `json:"messages,required"` - Result HostnameIPFSUniversalPathContentListEntryListResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameIPFSUniversalPathContentListEntryListResponse `json:"result,required,nullable"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess `json:"success,required"` ResultInfo HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo `json:"result_info"` @@ -484,54 +533,6 @@ func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON) RawJS return r.raw } -type HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors] -type hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages] -type hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess bool @@ -579,10 +580,18 @@ func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJ return r.raw } +type HostnameIPFSUniversalPathContentListEntryDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r HostnameIPFSUniversalPathContentListEntryDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope struct { - Errors []HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HostnameIPFSUniversalPathContentListEntryDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HostnameIPFSUniversalPathContentListEntryDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON `json:"-"` @@ -608,54 +617,6 @@ func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON) Raw return r.raw } -type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors] -type hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages] -type hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess bool @@ -672,10 +633,10 @@ func (r HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess) } type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope struct { - Errors []HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Content list entry to be blocked. - Result DistributedWebConfigContentListEntry `json:"result,required"` + Result HostnameIPFSUniversalPathContentListEntryGetResponse `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON `json:"-"` @@ -701,54 +662,6 @@ func (r hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON) RawJSO return r.raw } -type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors] -type hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages] -type hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess bool diff --git a/web3/hostnameipfsuniversalpathcontentlistentry_test.go b/web3/hostnameipfsuniversalpathcontentlistentry_test.go index 486cd5d7681..be6989fa6d6 100644 --- a/web3/hostnameipfsuniversalpathcontentlistentry_test.go +++ b/web3/hostnameipfsuniversalpathcontentlistentry_test.go @@ -128,6 +128,9 @@ func TestHostnameIPFSUniversalPathContentListEntryDelete(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", + web3.HostnameIPFSUniversalPathContentListEntryDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/workers/accountsetting.go b/workers/accountsetting.go index c9ad27f1c3c..9caf4c2d516 100644 --- a/workers/accountsetting.go +++ b/workers/accountsetting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -106,7 +107,7 @@ func (r accountSettingGetResponseJSON) RawJSON() string { type AccountSettingUpdateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[string] `json:"body,required"` + Body string `json:"body,required"` } func (r AccountSettingUpdateParams) MarshalJSON() (data []byte, err error) { @@ -114,9 +115,9 @@ func (r AccountSettingUpdateParams) MarshalJSON() (data []byte, err error) { } type AccountSettingUpdateResponseEnvelope struct { - Errors []AccountSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AccountSettingUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccountSettingUpdateResponse `json:"result,required"` // Whether the API call was successful Success AccountSettingUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accountSettingUpdateResponseEnvelopeJSON `json:"-"` @@ -141,52 +142,6 @@ func (r accountSettingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccountSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountSettingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccountSettingUpdateResponseEnvelopeErrors] -type accountSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountSettingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccountSettingUpdateResponseEnvelopeMessages] -type accountSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccountSettingUpdateResponseEnvelopeSuccess bool @@ -208,9 +163,9 @@ type AccountSettingGetParams struct { } type AccountSettingGetResponseEnvelope struct { - Errors []AccountSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result AccountSettingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccountSettingGetResponse `json:"result,required"` // Whether the API call was successful Success AccountSettingGetResponseEnvelopeSuccess `json:"success,required"` JSON accountSettingGetResponseEnvelopeJSON `json:"-"` @@ -235,52 +190,6 @@ func (r accountSettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccountSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountSettingGetResponseEnvelopeErrors] -type accountSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccountSettingGetResponseEnvelopeMessages] -type accountSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccountSettingGetResponseEnvelopeSuccess bool diff --git a/workers/accountsetting_test.go b/workers/accountsetting_test.go index bb74eaa7425..08d436c142a 100644 --- a/workers/accountsetting_test.go +++ b/workers/accountsetting_test.go @@ -30,7 +30,7 @@ func TestAccountSettingUpdate(t *testing.T) { ) _, err := client.Workers.AccountSettings.Update(context.TODO(), workers.AccountSettingUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F("{'default_usage_model': 'unbound'}"), + Body: "{'default_usage_model': 'unbound'}", }) if err != nil { var apierr *cloudflare.Error diff --git a/workers/ai.go b/workers/ai.go index c277df22b37..f578d1c2426 100644 --- a/workers/ai.go +++ b/workers/ai.go @@ -42,10 +42,10 @@ func NewAIService(opts ...option.RequestOption) (r *AIService) { // // Model specific inputs available in // [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). -func (r *AIService) Run(ctx context.Context, modelName string, params AIRunParams, opts ...option.RequestOption) (res *AIRunResponse, err error) { +func (r *AIService) Run(ctx context.Context, modelName string, params AIRunParams, opts ...option.RequestOption) (res *AIRunResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AIRunResponseEnvelope - path := fmt.Sprintf("accounts/%s/ai/run/%s", params.getAccountID(), modelName) + path := fmt.Sprintf("accounts/%s/ai/run/%s", params.AccountID, modelName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return @@ -61,13 +61,13 @@ func (r *AIService) Run(ctx context.Context, modelName string, params AIRunParam // [workers.AIRunResponseObjectDetection], [workers.AIRunResponseObject], // [shared.UnionString], [workers.AIRunResponseTranslation], // [workers.AIRunResponseSummarization] or [workers.AIRunResponseImageToText]. -type AIRunResponse interface { - ImplementsWorkersAIRunResponse() +type AIRunResponseUnion interface { + ImplementsWorkersAIRunResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AIRunResponse)(nil)).Elem(), + reflect.TypeOf((*AIRunResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -122,11 +122,11 @@ func init() { type AIRunResponseTextClassification []AIRunResponseTextClassification -func (r AIRunResponseTextClassification) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseTextClassification) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseSentenceSimilarity []float64 -func (r AIRunResponseSentenceSimilarity) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseSentenceSimilarity) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseTextEmbeddings struct { Data [][]float64 `json:"data"` @@ -151,7 +151,7 @@ func (r aiRunResponseTextEmbeddingsJSON) RawJSON() string { return r.raw } -func (r AIRunResponseTextEmbeddings) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseTextEmbeddings) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseSpeechRecognition struct { Text string `json:"text,required"` @@ -180,7 +180,7 @@ func (r aiRunResponseSpeechRecognitionJSON) RawJSON() string { return r.raw } -func (r AIRunResponseSpeechRecognition) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseSpeechRecognition) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseSpeechRecognitionWord struct { End float64 `json:"end"` @@ -209,11 +209,11 @@ func (r aiRunResponseSpeechRecognitionWordJSON) RawJSON() string { type AIRunResponseImageClassification []AIRunResponseImageClassification -func (r AIRunResponseImageClassification) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseImageClassification) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseObjectDetection []AIRunResponseObjectDetection -func (r AIRunResponseObjectDetection) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseObjectDetection) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseObject struct { Response string `json:"response"` @@ -236,7 +236,7 @@ func (r aiRunResponseObjectJSON) RawJSON() string { return r.raw } -func (r AIRunResponseObject) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseObject) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseTranslation struct { TranslatedText string `json:"translated_text"` @@ -259,7 +259,7 @@ func (r aiRunResponseTranslationJSON) RawJSON() string { return r.raw } -func (r AIRunResponseTranslation) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseTranslation) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseSummarization struct { Summary string `json:"summary"` @@ -282,7 +282,7 @@ func (r aiRunResponseSummarizationJSON) RawJSON() string { return r.raw } -func (r AIRunResponseSummarization) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseSummarization) ImplementsWorkersAIRunResponseUnion() {} type AIRunResponseImageToText struct { Description string `json:"description"` @@ -305,243 +305,207 @@ func (r aiRunResponseImageToTextJSON) RawJSON() string { return r.raw } -func (r AIRunResponseImageToText) ImplementsWorkersAIRunResponse() {} +func (r AIRunResponseImageToText) ImplementsWorkersAIRunResponseUnion() {} -// This interface is a union satisfied by one of the following: -// [AIRunParamsTextClassification], [AIRunParamsTextToImage], -// [AIRunParamsSentenceSimilarity], [AIRunParamsTextEmbeddings], -// [AIRunParamsSpeechRecognition], [AIRunParamsImageClassification], -// [AIRunParamsObjectDetection], [AIRunParamsTextGeneration], -// [AIRunParamsTranslation], [AIRunParamsSummarization], [AIRunParamsImageToText]. -type AIRunParams interface { - ImplementsAIRunParams() - - getAccountID() param.Field[string] +type AIRunParams struct { + AccountID param.Field[string] `path:"account_id,required"` + Body AIRunParamsBodyUnion `json:"body,required"` } -type AIRunParamsTextClassification struct { - AccountID param.Field[string] `path:"account_id,required"` - Text param.Field[string] `json:"text,required"` +func (r AIRunParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } -func (r AIRunParamsTextClassification) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type AIRunParamsBody struct { + Text param.Field[interface{}] `json:"text,required"` + Guidance param.Field[float64] `json:"guidance"` + Image param.Field[interface{}] `json:"image,required"` + Mask param.Field[interface{}] `json:"mask,required"` + NumSteps param.Field[int64] `json:"num_steps"` + Prompt param.Field[string] `json:"prompt"` + Strength param.Field[float64] `json:"strength"` + Sentences param.Field[interface{}] `json:"sentences,required"` + Source param.Field[string] `json:"source"` + Audio param.Field[interface{}] `json:"audio,required"` + Lora param.Field[string] `json:"lora"` + MaxTokens param.Field[int64] `json:"max_tokens"` + Raw param.Field[bool] `json:"raw"` + Stream param.Field[bool] `json:"stream"` + Messages param.Field[interface{}] `json:"messages,required"` + SourceLang param.Field[string] `json:"source_lang"` + TargetLang param.Field[string] `json:"target_lang"` + InputText param.Field[string] `json:"input_text"` + MaxLength param.Field[int64] `json:"max_length"` } -func (r AIRunParamsTextClassification) getAccountID() param.Field[string] { - return r.AccountID +func (r AIRunParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (AIRunParamsTextClassification) ImplementsAIRunParams() { +func (r AIRunParamsBody) implementsWorkersAIRunParamsBodyUnion() {} +// Satisfied by [workers.AIRunParamsBodyTextClassification], +// [workers.AIRunParamsBodyTextToImage], +// [workers.AIRunParamsBodySentenceSimilarity], +// [workers.AIRunParamsBodyTextEmbeddings], +// [workers.AIRunParamsBodySpeechRecognition], +// [workers.AIRunParamsBodyImageClassification], +// [workers.AIRunParamsBodyObjectDetection], +// [workers.AIRunParamsBodyTextGeneration], [workers.AIRunParamsBodyTranslation], +// [workers.AIRunParamsBodySummarization], [workers.AIRunParamsBodyImageToText], +// [AIRunParamsBody]. +type AIRunParamsBodyUnion interface { + implementsWorkersAIRunParamsBodyUnion() } -type AIRunParamsTextToImage struct { - AccountID param.Field[string] `path:"account_id,required"` - Prompt param.Field[string] `json:"prompt,required"` - Guidance param.Field[float64] `json:"guidance"` - Image param.Field[[]float64] `json:"image"` - Mask param.Field[[]float64] `json:"mask"` - NumSteps param.Field[int64] `json:"num_steps"` - Strength param.Field[float64] `json:"strength"` +type AIRunParamsBodyTextClassification struct { + Text param.Field[string] `json:"text,required"` } -func (r AIRunParamsTextToImage) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyTextClassification) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsTextToImage) getAccountID() param.Field[string] { - return r.AccountID -} +func (r AIRunParamsBodyTextClassification) implementsWorkersAIRunParamsBodyUnion() {} -func (AIRunParamsTextToImage) ImplementsAIRunParams() { +type AIRunParamsBodyTextToImage struct { + Prompt param.Field[string] `json:"prompt,required"` + Guidance param.Field[float64] `json:"guidance"` + Image param.Field[[]float64] `json:"image"` + Mask param.Field[[]float64] `json:"mask"` + NumSteps param.Field[int64] `json:"num_steps"` + Strength param.Field[float64] `json:"strength"` +} +func (r AIRunParamsBodyTextToImage) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type AIRunParamsSentenceSimilarity struct { - AccountID param.Field[string] `path:"account_id,required"` +func (r AIRunParamsBodyTextToImage) implementsWorkersAIRunParamsBodyUnion() {} + +type AIRunParamsBodySentenceSimilarity struct { Sentences param.Field[[]string] `json:"sentences,required"` Source param.Field[string] `json:"source,required"` } -func (r AIRunParamsSentenceSimilarity) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodySentenceSimilarity) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsSentenceSimilarity) getAccountID() param.Field[string] { - return r.AccountID -} - -func (AIRunParamsSentenceSimilarity) ImplementsAIRunParams() { - -} +func (r AIRunParamsBodySentenceSimilarity) implementsWorkersAIRunParamsBodyUnion() {} -type AIRunParamsTextEmbeddings struct { - AccountID param.Field[string] `path:"account_id,required"` - Text param.Field[AIRunParamsTextEmbeddingsText] `json:"text,required"` +type AIRunParamsBodyTextEmbeddings struct { + Text param.Field[AIRunParamsBodyTextEmbeddingsTextUnion] `json:"text,required"` } -func (r AIRunParamsTextEmbeddings) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyTextEmbeddings) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsTextEmbeddings) getAccountID() param.Field[string] { - return r.AccountID -} - -func (AIRunParamsTextEmbeddings) ImplementsAIRunParams() { - -} +func (r AIRunParamsBodyTextEmbeddings) implementsWorkersAIRunParamsBodyUnion() {} -// Satisfied by [shared.UnionString], [workers.AIRunParamsTextEmbeddingsTextArray]. -type AIRunParamsTextEmbeddingsText interface { - ImplementsWorkersAIRunParamsTextEmbeddingsText() +// Satisfied by [shared.UnionString], +// [workers.AIRunParamsBodyTextEmbeddingsTextArray]. +type AIRunParamsBodyTextEmbeddingsTextUnion interface { + ImplementsWorkersAIRunParamsBodyTextEmbeddingsTextUnion() } -type AIRunParamsTextEmbeddingsTextArray []string - -func (r AIRunParamsTextEmbeddingsTextArray) ImplementsWorkersAIRunParamsTextEmbeddingsText() {} +type AIRunParamsBodyTextEmbeddingsTextArray []string -type AIRunParamsSpeechRecognition struct { - AccountID param.Field[string] `path:"account_id,required"` - Audio param.Field[[]float64] `json:"audio"` +func (r AIRunParamsBodyTextEmbeddingsTextArray) ImplementsWorkersAIRunParamsBodyTextEmbeddingsTextUnion() { } -func (r AIRunParamsSpeechRecognition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type AIRunParamsBodySpeechRecognition struct { + Audio param.Field[[]float64] `json:"audio"` } -func (r AIRunParamsSpeechRecognition) getAccountID() param.Field[string] { - return r.AccountID +func (r AIRunParamsBodySpeechRecognition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (AIRunParamsSpeechRecognition) ImplementsAIRunParams() { - -} +func (r AIRunParamsBodySpeechRecognition) implementsWorkersAIRunParamsBodyUnion() {} -type AIRunParamsImageClassification struct { - AccountID param.Field[string] `path:"account_id,required"` - Image param.Field[[]float64] `json:"image"` +type AIRunParamsBodyImageClassification struct { + Image param.Field[[]float64] `json:"image"` } -func (r AIRunParamsImageClassification) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyImageClassification) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsImageClassification) getAccountID() param.Field[string] { - return r.AccountID -} - -func (AIRunParamsImageClassification) ImplementsAIRunParams() { +func (r AIRunParamsBodyImageClassification) implementsWorkersAIRunParamsBodyUnion() {} +type AIRunParamsBodyObjectDetection struct { + Image param.Field[[]float64] `json:"image"` } -type AIRunParamsObjectDetection struct { - AccountID param.Field[string] `path:"account_id,required"` - Image param.Field[[]float64] `json:"image"` -} - -func (r AIRunParamsObjectDetection) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyObjectDetection) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsObjectDetection) getAccountID() param.Field[string] { - return r.AccountID -} - -func (AIRunParamsObjectDetection) ImplementsAIRunParams() { - -} +func (r AIRunParamsBodyObjectDetection) implementsWorkersAIRunParamsBodyUnion() {} -type AIRunParamsTextGeneration struct { - AccountID param.Field[string] `path:"account_id,required"` - Lora param.Field[string] `json:"lora"` - MaxTokens param.Field[int64] `json:"max_tokens"` - Messages param.Field[[]AIRunParamsTextGenerationMessage] `json:"messages"` - Prompt param.Field[string] `json:"prompt"` - Raw param.Field[bool] `json:"raw"` - Stream param.Field[bool] `json:"stream"` +type AIRunParamsBodyTextGeneration struct { + Lora param.Field[string] `json:"lora"` + MaxTokens param.Field[int64] `json:"max_tokens"` + Messages param.Field[[]AIRunParamsBodyTextGenerationMessage] `json:"messages"` + Prompt param.Field[string] `json:"prompt"` + Raw param.Field[bool] `json:"raw"` + Stream param.Field[bool] `json:"stream"` } -func (r AIRunParamsTextGeneration) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyTextGeneration) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsTextGeneration) getAccountID() param.Field[string] { - return r.AccountID -} - -func (AIRunParamsTextGeneration) ImplementsAIRunParams() { +func (r AIRunParamsBodyTextGeneration) implementsWorkersAIRunParamsBodyUnion() {} -} - -type AIRunParamsTextGenerationMessage struct { +type AIRunParamsBodyTextGenerationMessage struct { Content param.Field[string] `json:"content,required"` Role param.Field[string] `json:"role,required"` } -func (r AIRunParamsTextGenerationMessage) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyTextGenerationMessage) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type AIRunParamsTranslation struct { - AccountID param.Field[string] `path:"account_id,required"` +type AIRunParamsBodyTranslation struct { TargetLang param.Field[string] `json:"target_lang,required"` Text param.Field[string] `json:"text,required"` SourceLang param.Field[string] `json:"source_lang"` } -func (r AIRunParamsTranslation) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyTranslation) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsTranslation) getAccountID() param.Field[string] { - return r.AccountID -} +func (r AIRunParamsBodyTranslation) implementsWorkersAIRunParamsBodyUnion() {} -func (AIRunParamsTranslation) ImplementsAIRunParams() { - -} - -type AIRunParamsSummarization struct { - AccountID param.Field[string] `path:"account_id,required"` +type AIRunParamsBodySummarization struct { InputText param.Field[string] `json:"input_text,required"` MaxLength param.Field[int64] `json:"max_length"` } -func (r AIRunParamsSummarization) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodySummarization) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsSummarization) getAccountID() param.Field[string] { - return r.AccountID -} - -func (AIRunParamsSummarization) ImplementsAIRunParams() { +func (r AIRunParamsBodySummarization) implementsWorkersAIRunParamsBodyUnion() {} -} - -type AIRunParamsImageToText struct { - AccountID param.Field[string] `path:"account_id,required"` +type AIRunParamsBodyImageToText struct { Image param.Field[[]float64] `json:"image"` MaxTokens param.Field[int64] `json:"max_tokens"` Prompt param.Field[string] `json:"prompt"` } -func (r AIRunParamsImageToText) MarshalJSON() (data []byte, err error) { +func (r AIRunParamsBodyImageToText) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AIRunParamsImageToText) getAccountID() param.Field[string] { - return r.AccountID -} - -func (AIRunParamsImageToText) ImplementsAIRunParams() { - -} +func (r AIRunParamsBodyImageToText) implementsWorkersAIRunParamsBodyUnion() {} type AIRunResponseEnvelope struct { - Result AIRunResponse `json:"result" format:"binary"` + Result AIRunResponseUnion `json:"result" format:"binary"` JSON aiRunResponseEnvelopeJSON `json:"-"` } diff --git a/workers/ai_test.go b/workers/ai_test.go index a2f9ffb448c..ece41338400 100644 --- a/workers/ai_test.go +++ b/workers/ai_test.go @@ -31,9 +31,11 @@ func TestAIRunWithOptionalParams(t *testing.T) { _, err := client.Workers.AI.Run( context.TODO(), "string", - workers.AIRunParamsTextClassification{ + workers.AIRunParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Text: cloudflare.F("x"), + Body: workers.AIRunParamsBodyTextClassification{ + Text: cloudflare.F("x"), + }, }, ) if err != nil { diff --git a/workers/aliases.go b/workers/aliases.go index acc46d15e9c..2a465ca1fe2 100644 --- a/workers/aliases.go +++ b/workers/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/workers/deployment.go b/workers/deployment.go deleted file mode 100644 index ef8bd4fb215..00000000000 --- a/workers/deployment.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// DeploymentService 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 [NewDeploymentService] method instead. -type DeploymentService struct { - Options []option.RequestOption - ByScripts *DeploymentByScriptService -} - -// NewDeploymentService 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 NewDeploymentService(opts ...option.RequestOption) (r *DeploymentService) { - r = &DeploymentService{} - r.Options = opts - r.ByScripts = NewDeploymentByScriptService(opts...) - return -} diff --git a/workers/deploymentbyscript.go b/workers/deploymentbyscript.go deleted file mode 100644 index d8634421b98..00000000000 --- a/workers/deploymentbyscript.go +++ /dev/null @@ -1,164 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// DeploymentByScriptService 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 [NewDeploymentByScriptService] method -// instead. -type DeploymentByScriptService struct { - Options []option.RequestOption - Details *DeploymentByScriptDetailService -} - -// NewDeploymentByScriptService 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 NewDeploymentByScriptService(opts ...option.RequestOption) (r *DeploymentByScriptService) { - r = &DeploymentByScriptService{} - r.Options = opts - r.Details = NewDeploymentByScriptDetailService(opts...) - return -} - -// List Deployments -func (r *DeploymentByScriptService) Get(ctx context.Context, scriptID string, query DeploymentByScriptGetParams, opts ...option.RequestOption) (res *DeploymentByScriptGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DeploymentByScriptGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/deployments/by-script/%s", query.AccountID, scriptID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DeploymentByScriptGetResponse struct { - Items []interface{} `json:"items"` - Latest interface{} `json:"latest"` - JSON deploymentByScriptGetResponseJSON `json:"-"` -} - -// deploymentByScriptGetResponseJSON contains the JSON metadata for the struct -// [DeploymentByScriptGetResponse] -type deploymentByScriptGetResponseJSON struct { - Items apijson.Field - Latest apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptGetResponseJSON) RawJSON() string { - return r.raw -} - -type DeploymentByScriptGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type DeploymentByScriptGetResponseEnvelope struct { - Errors []DeploymentByScriptGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DeploymentByScriptGetResponseEnvelopeMessages `json:"messages,required"` - Result DeploymentByScriptGetResponse `json:"result,required"` - // Whether the API call was successful - Success DeploymentByScriptGetResponseEnvelopeSuccess `json:"success,required"` - JSON deploymentByScriptGetResponseEnvelopeJSON `json:"-"` -} - -// deploymentByScriptGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [DeploymentByScriptGetResponseEnvelope] -type deploymentByScriptGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DeploymentByScriptGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deploymentByScriptGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// deploymentByScriptGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DeploymentByScriptGetResponseEnvelopeErrors] -type deploymentByScriptGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeploymentByScriptGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deploymentByScriptGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// deploymentByScriptGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DeploymentByScriptGetResponseEnvelopeMessages] -type deploymentByScriptGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DeploymentByScriptGetResponseEnvelopeSuccess bool - -const ( - DeploymentByScriptGetResponseEnvelopeSuccessTrue DeploymentByScriptGetResponseEnvelopeSuccess = true -) - -func (r DeploymentByScriptGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case DeploymentByScriptGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/workers/deploymentbyscript_test.go b/workers/deploymentbyscript_test.go deleted file mode 100644 index 7615d9f5744..00000000000 --- a/workers/deploymentbyscript_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers_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/workers" -) - -func TestDeploymentByScriptGet(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.Workers.Deployments.ByScripts.Get( - context.TODO(), - "8ee82b3a2c0f42928b8f14dae4a97121", - workers.DeploymentByScriptGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) - 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/workers/deploymentbyscriptdetail.go b/workers/deploymentbyscriptdetail.go deleted file mode 100644 index eb78bdec859..00000000000 --- a/workers/deploymentbyscriptdetail.go +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// DeploymentByScriptDetailService 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 -// [NewDeploymentByScriptDetailService] method instead. -type DeploymentByScriptDetailService struct { - Options []option.RequestOption -} - -// NewDeploymentByScriptDetailService 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 NewDeploymentByScriptDetailService(opts ...option.RequestOption) (r *DeploymentByScriptDetailService) { - r = &DeploymentByScriptDetailService{} - r.Options = opts - return -} - -// Get Deployment Detail -func (r *DeploymentByScriptDetailService) Get(ctx context.Context, scriptID string, deploymentID string, query DeploymentByScriptDetailGetParams, opts ...option.RequestOption) (res *DeploymentByScriptDetailGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DeploymentByScriptDetailGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/deployments/by-script/%s/detail/%s", query.AccountID, scriptID, deploymentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DeploymentByScriptDetailGetResponse struct { - ID string `json:"id"` - Metadata interface{} `json:"metadata"` - Number float64 `json:"number"` - Resources interface{} `json:"resources"` - JSON deploymentByScriptDetailGetResponseJSON `json:"-"` -} - -// deploymentByScriptDetailGetResponseJSON contains the JSON metadata for the -// struct [DeploymentByScriptDetailGetResponse] -type deploymentByScriptDetailGetResponseJSON struct { - ID apijson.Field - Metadata apijson.Field - Number apijson.Field - Resources apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptDetailGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptDetailGetResponseJSON) RawJSON() string { - return r.raw -} - -type DeploymentByScriptDetailGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type DeploymentByScriptDetailGetResponseEnvelope struct { - Errors []DeploymentByScriptDetailGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DeploymentByScriptDetailGetResponseEnvelopeMessages `json:"messages,required"` - Result DeploymentByScriptDetailGetResponse `json:"result,required"` - // Whether the API call was successful - Success DeploymentByScriptDetailGetResponseEnvelopeSuccess `json:"success,required"` - JSON deploymentByScriptDetailGetResponseEnvelopeJSON `json:"-"` -} - -// deploymentByScriptDetailGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [DeploymentByScriptDetailGetResponseEnvelope] -type deploymentByScriptDetailGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptDetailGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptDetailGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DeploymentByScriptDetailGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deploymentByScriptDetailGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// deploymentByScriptDetailGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DeploymentByScriptDetailGetResponseEnvelopeErrors] -type deploymentByScriptDetailGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptDetailGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptDetailGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeploymentByScriptDetailGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deploymentByScriptDetailGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// deploymentByScriptDetailGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DeploymentByScriptDetailGetResponseEnvelopeMessages] -type deploymentByScriptDetailGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeploymentByScriptDetailGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deploymentByScriptDetailGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DeploymentByScriptDetailGetResponseEnvelopeSuccess bool - -const ( - DeploymentByScriptDetailGetResponseEnvelopeSuccessTrue DeploymentByScriptDetailGetResponseEnvelopeSuccess = true -) - -func (r DeploymentByScriptDetailGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case DeploymentByScriptDetailGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/workers/deploymentbyscriptdetail_test.go b/workers/deploymentbyscriptdetail_test.go deleted file mode 100644 index 412b34c9c6e..00000000000 --- a/workers/deploymentbyscriptdetail_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers_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/workers" -) - -func TestDeploymentByScriptDetailGet(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.Workers.Deployments.ByScripts.Details.Get( - context.TODO(), - "8ee82b3a2c0f42928b8f14dae4a97121", - "bcf48806-b317-4351-9ee7-36e7d557d4de", - workers.DeploymentByScriptDetailGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) - 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/workers/domain.go b/workers/domain.go index 938bfe342f5..dcbcfce9401 100644 --- a/workers/domain.go +++ b/workers/domain.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -34,7 +35,7 @@ func NewDomainService(opts ...option.RequestOption) (r *DomainService) { } // Attaches a Worker to a zone and hostname. -func (r *DomainService) Update(ctx context.Context, params DomainUpdateParams, opts ...option.RequestOption) (res *WorkersDomain, err error) { +func (r *DomainService) Update(ctx context.Context, params DomainUpdateParams, opts ...option.RequestOption) (res *Domain, err error) { opts = append(r.Options[:], opts...) var env DomainUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/domains", params.AccountID) @@ -47,7 +48,7 @@ func (r *DomainService) Update(ctx context.Context, params DomainUpdateParams, o } // Lists all Worker Domains for an account. -func (r *DomainService) List(ctx context.Context, params DomainListParams, opts ...option.RequestOption) (res *pagination.SinglePage[WorkersDomain], err error) { +func (r *DomainService) List(ctx context.Context, params DomainListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Domain], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -65,21 +66,21 @@ func (r *DomainService) List(ctx context.Context, params DomainListParams, opts } // Lists all Worker Domains for an account. -func (r *DomainService) ListAutoPaging(ctx context.Context, params DomainListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WorkersDomain] { +func (r *DomainService) ListAutoPaging(ctx context.Context, params DomainListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Domain] { return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...)) } // Detaches a Worker from a zone and hostname. -func (r *DomainService) Delete(ctx context.Context, domainID string, body DomainDeleteParams, opts ...option.RequestOption) (err error) { +func (r *DomainService) Delete(ctx context.Context, domainID string, params DomainDeleteParams, opts ...option.RequestOption) (err error) { opts = append(r.Options[:], opts...) opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/domains/%s", body.AccountID, domainID) + path := fmt.Sprintf("accounts/%s/workers/domains/%s", params.AccountID, domainID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) return } // Gets a Worker domain. -func (r *DomainService) Get(ctx context.Context, domainID string, query DomainGetParams, opts ...option.RequestOption) (res *WorkersDomain, err error) { +func (r *DomainService) Get(ctx context.Context, domainID string, query DomainGetParams, opts ...option.RequestOption) (res *Domain, err error) { opts = append(r.Options[:], opts...) var env DomainGetResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/domains/%s", query.AccountID, domainID) @@ -91,7 +92,7 @@ func (r *DomainService) Get(ctx context.Context, domainID string, query DomainGe return } -type WorkersDomain struct { +type Domain struct { // Identifer of the Worker Domain. ID string `json:"id"` // Worker environment associated with the zone and hostname. @@ -103,12 +104,12 @@ type WorkersDomain struct { // Identifier of the zone. ZoneID string `json:"zone_id"` // Name of the zone. - ZoneName string `json:"zone_name"` - JSON workersDomainJSON `json:"-"` + ZoneName string `json:"zone_name"` + JSON domainJSON `json:"-"` } -// workersDomainJSON contains the JSON metadata for the struct [WorkersDomain] -type workersDomainJSON struct { +// domainJSON contains the JSON metadata for the struct [Domain] +type domainJSON struct { ID apijson.Field Environment apijson.Field Hostname apijson.Field @@ -119,11 +120,11 @@ type workersDomainJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersDomain) UnmarshalJSON(data []byte) (err error) { +func (r *Domain) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersDomainJSON) RawJSON() string { +func (r domainJSON) RawJSON() string { return r.raw } @@ -144,9 +145,9 @@ func (r DomainUpdateParams) MarshalJSON() (data []byte, err error) { } type DomainUpdateResponseEnvelope struct { - Errors []DomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersDomain `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Domain `json:"result,required"` // Whether the API call was successful Success DomainUpdateResponseEnvelopeSuccess `json:"success,required"` JSON domainUpdateResponseEnvelopeJSON `json:"-"` @@ -171,52 +172,6 @@ func (r domainUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// domainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DomainUpdateResponseEnvelopeErrors] -type domainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// domainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DomainUpdateResponseEnvelopeMessages] -type domainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DomainUpdateResponseEnvelopeSuccess bool @@ -249,13 +204,18 @@ type DomainListParams struct { // URLQuery serializes [DomainListParams]'s query parameters as `url.Values`. func (r DomainListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DomainDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DomainDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DomainGetParams struct { @@ -263,9 +223,9 @@ type DomainGetParams struct { } type DomainGetResponseEnvelope struct { - Errors []DomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DomainGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkersDomain `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Domain `json:"result,required"` // Whether the API call was successful Success DomainGetResponseEnvelopeSuccess `json:"success,required"` JSON domainGetResponseEnvelopeJSON `json:"-"` @@ -290,52 +250,6 @@ func (r domainGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// domainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DomainGetResponseEnvelopeErrors] -type domainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON domainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// domainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DomainGetResponseEnvelopeMessages] -type domainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r domainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DomainGetResponseEnvelopeSuccess bool diff --git a/workers/domain_test.go b/workers/domain_test.go index 6f04843c1f5..a2a6e5ba3c8 100644 --- a/workers/domain_test.go +++ b/workers/domain_test.go @@ -94,6 +94,7 @@ func TestDomainDelete(t *testing.T) { "dbe10b4bc17c295377eabd600e1787fd", workers.DomainDeleteParams{ AccountID: cloudflare.F("9a7806061c88ada191ed06f989cc3dac"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/workers/filter.go b/workers/filter.go deleted file mode 100644 index a641eef2ff9..00000000000 --- a/workers/filter.go +++ /dev/null @@ -1,462 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - - "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" -) - -// FilterService 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 [NewFilterService] method instead. -type FilterService struct { - Options []option.RequestOption -} - -// NewFilterService 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 NewFilterService(opts ...option.RequestOption) (r *FilterService) { - r = &FilterService{} - r.Options = opts - return -} - -// Create Filter -func (r *FilterService) New(ctx context.Context, params FilterNewParams, opts ...option.RequestOption) (res *FilterNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env FilterNewResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/filters", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update Filter -func (r *FilterService) Update(ctx context.Context, filterID string, params FilterUpdateParams, opts ...option.RequestOption) (res *WorkersFilter, err error) { - opts = append(r.Options[:], opts...) - var env FilterUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/filters/%s", params.ZoneID, filterID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Filters -func (r *FilterService) List(ctx context.Context, query FilterListParams, opts ...option.RequestOption) (res *pagination.SinglePage[WorkersFilter], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/workers/filters", query.ZoneID) - 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 Filters -func (r *FilterService) ListAutoPaging(ctx context.Context, query FilterListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WorkersFilter] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -// Delete Filter -func (r *FilterService) Delete(ctx context.Context, filterID string, body FilterDeleteParams, opts ...option.RequestOption) (res *FilterDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FilterDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/filters/%s", body.ZoneID, filterID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkersFilter struct { - // Identifier - ID string `json:"id,required"` - Enabled bool `json:"enabled,required"` - Pattern string `json:"pattern,required"` - JSON workersFilterJSON `json:"-"` -} - -// workersFilterJSON contains the JSON metadata for the struct [WorkersFilter] -type workersFilterJSON struct { - ID apijson.Field - Enabled apijson.Field - Pattern apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersFilterJSON) RawJSON() string { - return r.raw -} - -type FilterNewResponse struct { - // Identifier - ID string `json:"id,required"` - JSON filterNewResponseJSON `json:"-"` -} - -// filterNewResponseJSON contains the JSON metadata for the struct -// [FilterNewResponse] -type filterNewResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseJSON) RawJSON() string { - return r.raw -} - -type FilterDeleteResponse struct { - // Identifier - ID string `json:"id,required"` - JSON filterDeleteResponseJSON `json:"-"` -} - -// filterDeleteResponseJSON contains the JSON metadata for the struct -// [FilterDeleteResponse] -type filterDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type FilterNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Enabled param.Field[bool] `json:"enabled,required"` - Pattern param.Field[string] `json:"pattern,required"` -} - -func (r FilterNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type FilterNewResponseEnvelope struct { - Errors []FilterNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterNewResponseEnvelopeMessages `json:"messages,required"` - Result FilterNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FilterNewResponseEnvelopeSuccess `json:"success,required"` - JSON filterNewResponseEnvelopeJSON `json:"-"` -} - -// filterNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelope] -type filterNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FilterNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelopeErrors] -type filterNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelopeMessages] -type filterNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FilterNewResponseEnvelopeSuccess bool - -const ( - FilterNewResponseEnvelopeSuccessTrue FilterNewResponseEnvelopeSuccess = true -) - -func (r FilterNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case FilterNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type FilterUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Enabled param.Field[bool] `json:"enabled,required"` - Pattern param.Field[string] `json:"pattern,required"` -} - -func (r FilterUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type FilterUpdateResponseEnvelope struct { - Errors []FilterUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersFilter `json:"result,required"` - // Whether the API call was successful - Success FilterUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON filterUpdateResponseEnvelopeJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [FilterUpdateResponseEnvelope] -type filterUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FilterUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterUpdateResponseEnvelopeErrors] -type filterUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FilterUpdateResponseEnvelopeMessages] -type filterUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FilterUpdateResponseEnvelopeSuccess bool - -const ( - FilterUpdateResponseEnvelopeSuccessTrue FilterUpdateResponseEnvelopeSuccess = true -) - -func (r FilterUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case FilterUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type FilterListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type FilterDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type FilterDeleteResponseEnvelope struct { - Errors []FilterDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FilterDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FilterDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON filterDeleteResponseEnvelopeJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [FilterDeleteResponseEnvelope] -type filterDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FilterDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterDeleteResponseEnvelopeErrors] -type filterDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FilterDeleteResponseEnvelopeMessages] -type filterDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FilterDeleteResponseEnvelopeSuccess bool - -const ( - FilterDeleteResponseEnvelopeSuccessTrue FilterDeleteResponseEnvelopeSuccess = true -) - -func (r FilterDeleteResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case FilterDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/workers/route.go b/workers/route.go deleted file mode 100644 index 044993ec115..00000000000 --- a/workers/route.go +++ /dev/null @@ -1,563 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "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" - "github.com/tidwall/gjson" -) - -// RouteService 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 [NewRouteService] method instead. -type RouteService struct { - Options []option.RequestOption -} - -// NewRouteService 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 NewRouteService(opts ...option.RequestOption) (r *RouteService) { - r = &RouteService{} - r.Options = opts - return -} - -// Creates a route that maps a URL pattern to a Worker. -func (r *RouteService) New(ctx context.Context, params RouteNewParams, opts ...option.RequestOption) (res *RouteNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RouteNewResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates the URL pattern or Worker associated with a route. -func (r *RouteService) Update(ctx context.Context, routeID string, params RouteUpdateParams, opts ...option.RequestOption) (res *WorkersRoute, err error) { - opts = append(r.Options[:], opts...) - var env RouteUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes/%s", params.ZoneID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns routes for a zone. -func (r *RouteService) List(ctx context.Context, query RouteListParams, opts ...option.RequestOption) (res *pagination.SinglePage[WorkersRoute], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/workers/routes", query.ZoneID) - 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 -} - -// Returns routes for a zone. -func (r *RouteService) ListAutoPaging(ctx context.Context, query RouteListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WorkersRoute] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -// Deletes a route. -func (r *RouteService) Delete(ctx context.Context, routeID string, body RouteDeleteParams, opts ...option.RequestOption) (res *RouteDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env RouteDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes/%s", body.ZoneID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns information about a route, including URL pattern and Worker. -func (r *RouteService) Get(ctx context.Context, routeID string, query RouteGetParams, opts ...option.RequestOption) (res *WorkersRoute, err error) { - opts = append(r.Options[:], opts...) - var env RouteGetResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes/%s", query.ZoneID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkersRoute struct { - // Identifier - ID string `json:"id,required"` - Pattern string `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script string `json:"script,required"` - JSON workersRouteJSON `json:"-"` -} - -// workersRouteJSON contains the JSON metadata for the struct [WorkersRoute] -type workersRouteJSON struct { - ID apijson.Field - Pattern apijson.Field - Script apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersRouteJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [workers.RouteNewResponseUnknown] or [shared.UnionString]. -type RouteNewResponse interface { - ImplementsWorkersRouteNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RouteNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [workers.RouteDeleteResponseUnknown] or [shared.UnionString]. -type RouteDeleteResponse interface { - ImplementsWorkersRouteDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RouteDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type RouteNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Pattern param.Field[string] `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script param.Field[string] `json:"script"` -} - -func (r RouteNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RouteNewResponseEnvelope struct { - Errors []RouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteNewResponseEnvelopeMessages `json:"messages,required"` - Result RouteNewResponse `json:"result,required"` - // Whether the API call was successful - Success RouteNewResponseEnvelopeSuccess `json:"success,required"` - JSON routeNewResponseEnvelopeJSON `json:"-"` -} - -// routeNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RouteNewResponseEnvelope] -type routeNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteNewResponseEnvelopeErrors] -type routeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RouteNewResponseEnvelopeMessages] -type routeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RouteNewResponseEnvelopeSuccess bool - -const ( - RouteNewResponseEnvelopeSuccessTrue RouteNewResponseEnvelopeSuccess = true -) - -func (r RouteNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case RouteNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type RouteUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Pattern param.Field[string] `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script param.Field[string] `json:"script"` -} - -func (r RouteUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RouteUpdateResponseEnvelope struct { - Errors []RouteUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersRoute `json:"result,required"` - // Whether the API call was successful - Success RouteUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON routeUpdateResponseEnvelopeJSON `json:"-"` -} - -// routeUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [RouteUpdateResponseEnvelope] -type routeUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RouteUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteUpdateResponseEnvelopeErrors] -type routeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RouteUpdateResponseEnvelopeMessages] -type routeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RouteUpdateResponseEnvelopeSuccess bool - -const ( - RouteUpdateResponseEnvelopeSuccessTrue RouteUpdateResponseEnvelopeSuccess = true -) - -func (r RouteUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case RouteUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type RouteListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type RouteDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type RouteDeleteResponseEnvelope struct { - Errors []RouteDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteDeleteResponseEnvelopeMessages `json:"messages,required"` - Result RouteDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success RouteDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON routeDeleteResponseEnvelopeJSON `json:"-"` -} - -// routeDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [RouteDeleteResponseEnvelope] -type routeDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RouteDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteDeleteResponseEnvelopeErrors] -type routeDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RouteDeleteResponseEnvelopeMessages] -type routeDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RouteDeleteResponseEnvelopeSuccess bool - -const ( - RouteDeleteResponseEnvelopeSuccessTrue RouteDeleteResponseEnvelopeSuccess = true -) - -func (r RouteDeleteResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case RouteDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type RouteGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type RouteGetResponseEnvelope struct { - Errors []RouteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RouteGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkersRoute `json:"result,required"` - // Whether the API call was successful - Success RouteGetResponseEnvelopeSuccess `json:"success,required"` - JSON routeGetResponseEnvelopeJSON `json:"-"` -} - -// routeGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RouteGetResponseEnvelope] -type routeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RouteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// routeGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RouteGetResponseEnvelopeErrors] -type routeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RouteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON routeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// routeGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RouteGetResponseEnvelopeMessages] -type routeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RouteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r routeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RouteGetResponseEnvelopeSuccess bool - -const ( - RouteGetResponseEnvelopeSuccessTrue RouteGetResponseEnvelopeSuccess = true -) - -func (r RouteGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case RouteGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/workers/route_test.go b/workers/route_test.go deleted file mode 100644 index a6f503cf1c7..00000000000 --- a/workers/route_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers_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/workers" -) - -func TestRouteNewWithOptionalParams(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.Workers.Routes.New(context.TODO(), workers.RouteNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Pattern: cloudflare.F("example.net/*"), - Script: cloudflare.F("this-is_my_script-01"), - }) - 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 TestRouteUpdateWithOptionalParams(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.Workers.Routes.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - workers.RouteUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Pattern: cloudflare.F("example.net/*"), - Script: cloudflare.F("this-is_my_script-01"), - }, - ) - 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 TestRouteList(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.Workers.Routes.List(context.TODO(), workers.RouteListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }) - 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 TestRouteDelete(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.Workers.Routes.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - workers.RouteDeleteParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) - 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 TestRouteGet(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.Workers.Routes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - workers.RouteGetParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) - 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/workers/script.go b/workers/script.go index d45f6457770..d263f62be8c 100644 --- a/workers/script.go +++ b/workers/script.go @@ -18,6 +18,7 @@ import ( "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" ) @@ -26,14 +27,13 @@ import ( // variables from the environment automatically. You should not instantiate this // service directly, and instead use the [NewScriptService] method instead. type ScriptService struct { - Options []option.RequestOption - Bindings *ScriptBindingService - Schedules *ScriptScheduleService - Tail *ScriptTailService - UsageModel *ScriptUsageModelService - Content *ScriptContentService - ContentV2 *ScriptContentV2Service - Settings *ScriptSettingService + Options []option.RequestOption + Schedules *ScriptScheduleService + Tail *ScriptTailService + Content *ScriptContentService + Settings *ScriptSettingService + Deployments *ScriptDeploymentService + Versions *ScriptVersionService } // NewScriptService generates a new service that applies the given options to each @@ -42,21 +42,20 @@ type ScriptService struct { func NewScriptService(opts ...option.RequestOption) (r *ScriptService) { r = &ScriptService{} r.Options = opts - r.Bindings = NewScriptBindingService(opts...) r.Schedules = NewScriptScheduleService(opts...) r.Tail = NewScriptTailService(opts...) - r.UsageModel = NewScriptUsageModelService(opts...) r.Content = NewScriptContentService(opts...) - r.ContentV2 = NewScriptContentV2Service(opts...) r.Settings = NewScriptSettingService(opts...) + r.Deployments = NewScriptDeploymentService(opts...) + r.Versions = NewScriptVersionService(opts...) return } // Upload a worker module. -func (r *ScriptService) Update(ctx context.Context, scriptName string, params ScriptUpdateParams, opts ...option.RequestOption) (res *WorkersScript, err error) { +func (r *ScriptService) Update(ctx context.Context, scriptName string, params ScriptUpdateParams, opts ...option.RequestOption) (res *Script, err error) { opts = append(r.Options[:], opts...) var env ScriptUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s", params.getAccountID(), scriptName) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s", params.AccountID, scriptName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return @@ -66,7 +65,7 @@ func (r *ScriptService) Update(ctx context.Context, scriptName string, params Sc } // Fetch a list of uploaded workers. -func (r *ScriptService) List(ctx context.Context, query ScriptListParams, opts ...option.RequestOption) (res *pagination.SinglePage[WorkersScript], err error) { +func (r *ScriptService) List(ctx context.Context, query ScriptListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Script], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -84,7 +83,7 @@ func (r *ScriptService) List(ctx context.Context, query ScriptListParams, opts . } // Fetch a list of uploaded workers. -func (r *ScriptService) ListAutoPaging(ctx context.Context, query ScriptListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[WorkersScript] { +func (r *ScriptService) ListAutoPaging(ctx context.Context, query ScriptListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Script] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -107,7 +106,7 @@ func (r *ScriptService) Get(ctx context.Context, scriptName string, query Script return } -type WorkersScript struct { +type Script struct { // The id of the script in the Workers system. Usually the script name. ID string `json:"id"` // When the script was created. @@ -118,25 +117,22 @@ type WorkersScript struct { Logpush bool `json:"logpush"` // When the script was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` // 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 []WorkersScriptTailConsumer `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 workersScriptJSON `json:"-"` + UsageModel string `json:"usage_model"` + JSON scriptJSON `json:"-"` } -// workersScriptJSON contains the JSON metadata for the struct [WorkersScript] -type workersScriptJSON struct { +// scriptJSON contains the JSON metadata for the struct [Script] +type scriptJSON struct { ID apijson.Field CreatedOn apijson.Field Etag apijson.Field Logpush apijson.Field ModifiedOn apijson.Field - PipelineHash apijson.Field PlacementMode apijson.Field TailConsumers apijson.Field UsageModel apijson.Field @@ -144,67 +140,60 @@ type workersScriptJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersScript) UnmarshalJSON(data []byte) (err error) { +func (r *Script) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersScriptJSON) RawJSON() string { +func (r scriptJSON) RawJSON() string { return r.raw } -// A reference to a script that will consume logs from the attached Worker. -type WorkersScriptTailConsumer 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 workersScriptTailConsumerJSON `json:"-"` +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 []ConsumerScript `json:"tail_consumers"` + JSON scriptSettingJSON `json:"-"` } -// workersScriptTailConsumerJSON contains the JSON metadata for the struct -// [WorkersScriptTailConsumer] -type workersScriptTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field +// scriptSettingJSON contains the JSON metadata for the struct [ScriptSetting] +type scriptSettingJSON struct { + Logpush apijson.Field + TailConsumers apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *WorkersScriptTailConsumer) UnmarshalJSON(data []byte) (err error) { +func (r *ScriptSetting) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersScriptTailConsumerJSON) RawJSON() string { +func (r scriptSettingJSON) RawJSON() string { return r.raw } -// This interface is a union satisfied by one of the following: -// [ScriptUpdateParamsVariant0], [ScriptUpdateParamsVariant1]. -type ScriptUpdateParams interface { - ImplementsScriptUpdateParams() +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[[]ConsumerScriptParam] `json:"tail_consumers"` +} - getAccountID() param.Field[string] +func (r ScriptSettingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type ScriptUpdateParamsVariant0 struct { +type ScriptUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body ScriptUpdateParamsBodyUnion `json:"body,required"` // Rollback to provided deployment based on deployment ID. Request body will only // parse a "message" part. You can learn more about deployments // [here](https://developers.cloudflare.com/workers/platform/deployments/). RollbackTo param.Field[string] `query:"rollback_to"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be present - // and referenced in the metadata as `main_module` or `body_part` by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[ScriptUpdateParamsVariant0Metadata] `json:"metadata"` } -func (r ScriptUpdateParamsVariant0) MarshalMultipart() (data []byte, contentType string, err error) { +func (r ScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { buf := bytes.NewBuffer(nil) writer := multipart.NewWriter(buf) err = apiform.MarshalRoot(r, writer) @@ -219,25 +208,53 @@ func (r ScriptUpdateParamsVariant0) MarshalMultipart() (data []byte, contentType return buf.Bytes(), writer.FormDataContentType(), nil } -// URLQuery serializes [ScriptUpdateParamsVariant0]'s query parameters as -// `url.Values`. -func (r ScriptUpdateParamsVariant0) URLQuery() (v url.Values) { +// URLQuery serializes [ScriptUpdateParams]'s query parameters as `url.Values`. +func (r ScriptUpdateParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } -func (r ScriptUpdateParamsVariant0) getAccountID() param.Field[string] { - return r.AccountID +type ScriptUpdateParamsBody struct { + AnyPartName param.Field[interface{}] `json:",required"` + Metadata param.Field[interface{}] `json:"metadata,required"` + // Rollback message to be associated with this deployment. Only parsed when query + // param `"rollback_to"` is present. + Message param.Field[string] `json:"message"` +} + +func (r ScriptUpdateParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptUpdateParamsBody) implementsWorkersScriptUpdateParamsBodyUnion() {} + +// Satisfied by [workers.ScriptUpdateParamsBodyObject], +// [workers.ScriptUpdateParamsBodyObject], [ScriptUpdateParamsBody]. +type ScriptUpdateParamsBodyUnion interface { + implementsWorkersScriptUpdateParamsBodyUnion() } -func (ScriptUpdateParamsVariant0) ImplementsScriptUpdateParams() { +type ScriptUpdateParamsBodyObject struct { + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be present + // and referenced in the metadata as `main_module` or `body_part` by part name. + // Source maps may also be included using the `application/source-map` content + // type. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[ScriptUpdateParamsBodyObjectMetadata] `json:"metadata"` +} +func (r ScriptUpdateParamsBodyObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } +func (r ScriptUpdateParamsBodyObject) implementsWorkersScriptUpdateParamsBodyUnion() {} + // JSON encoded metadata about the uploaded parts and Worker configuration. -type ScriptUpdateParamsVariant0Metadata struct { +type ScriptUpdateParamsBodyObjectMetadata struct { // List of bindings available to the worker. Bindings param.Field[[]interface{}] `json:"bindings"` // Name of the part in the multipart request that contains the script (e.g. the @@ -259,222 +276,72 @@ type ScriptUpdateParamsVariant0Metadata struct { // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. MainModule param.Field[string] `json:"main_module"` // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[ScriptUpdateParamsVariant0MetadataMigrations] `json:"migrations"` - Placement param.Field[ScriptUpdateParamsVariant0MetadataPlacement] `json:"placement"` + Migrations param.Field[ScriptUpdateParamsBodyObjectMetadataMigrationsUnion] `json:"migrations"` + Placement param.Field[PlacementConfigurationParam] `json:"placement"` // 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[[]ScriptUpdateParamsVariant0MetadataTailConsumer] `json:"tail_consumers"` + TailConsumers param.Field[[]ConsumerScriptParam] `json:"tail_consumers"` // Usage model to apply to invocations. - UsageModel param.Field[ScriptUpdateParamsVariant0MetadataUsageModel] `json:"usage_model"` + UsageModel param.Field[ScriptUpdateParamsBodyObjectMetadataUsageModel] `json:"usage_model"` // Key-value pairs to use as tags for this version of this Worker VersionTags param.Field[interface{}] `json:"version_tags"` } -func (r ScriptUpdateParamsVariant0Metadata) MarshalJSON() (data []byte, err error) { +func (r ScriptUpdateParamsBodyObjectMetadata) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations], -// [workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations]. -type ScriptUpdateParamsVariant0MetadataMigrations interface { - implementsWorkersScriptUpdateParamsVariant0MetadataMigrations() -} - -// A single set of migrations to apply. -type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations) implementsWorkersScriptUpdateParamsVariant0MetadataMigrations() { -} - -type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations struct { +type ScriptUpdateParamsBodyObjectMetadataMigrations struct { // Tag to set as the latest migration tag. NewTag param.Field[string] `json:"new_tag"` // Tag used to verify against the latest migration tag for this Worker. If they // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations) implementsWorkersScriptUpdateParamsVariant0MetadataMigrations() { -} - -type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` + OldTag param.Field[string] `json:"old_tag"` + DeletedClasses param.Field[interface{}] `json:"deleted_classes,required"` + NewClasses param.Field[interface{}] `json:"new_classes,required"` + RenamedClasses param.Field[interface{}] `json:"renamed_classes,required"` + TransferredClasses param.Field[interface{}] `json:"transferred_classes,required"` + Steps param.Field[interface{}] `json:"steps,required"` } -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { +func (r ScriptUpdateParamsBodyObjectMetadataMigrations) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` +func (r ScriptUpdateParamsBodyObjectMetadataMigrations) implementsWorkersScriptUpdateParamsBodyObjectMetadataMigrationsUnion() { } -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r ScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptUpdateParamsVariant0MetadataPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[ScriptUpdateParamsVariant0MetadataPlacementMode] `json:"mode"` -} - -func (r ScriptUpdateParamsVariant0MetadataPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type ScriptUpdateParamsVariant0MetadataPlacementMode string - -const ( - ScriptUpdateParamsVariant0MetadataPlacementModeSmart ScriptUpdateParamsVariant0MetadataPlacementMode = "smart" -) - -func (r ScriptUpdateParamsVariant0MetadataPlacementMode) IsKnown() bool { - switch r { - case ScriptUpdateParamsVariant0MetadataPlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type ScriptUpdateParamsVariant0MetadataTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r ScriptUpdateParamsVariant0MetadataTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by [workers.SingleStepMigrationParam], +// [workers.SteppedMigrationParam], +// [ScriptUpdateParamsBodyObjectMetadataMigrations]. +type ScriptUpdateParamsBodyObjectMetadataMigrationsUnion interface { + implementsWorkersScriptUpdateParamsBodyObjectMetadataMigrationsUnion() } // Usage model to apply to invocations. -type ScriptUpdateParamsVariant0MetadataUsageModel string +type ScriptUpdateParamsBodyObjectMetadataUsageModel string const ( - ScriptUpdateParamsVariant0MetadataUsageModelBundled ScriptUpdateParamsVariant0MetadataUsageModel = "bundled" - ScriptUpdateParamsVariant0MetadataUsageModelUnbound ScriptUpdateParamsVariant0MetadataUsageModel = "unbound" + ScriptUpdateParamsBodyObjectMetadataUsageModelBundled ScriptUpdateParamsBodyObjectMetadataUsageModel = "bundled" + ScriptUpdateParamsBodyObjectMetadataUsageModelUnbound ScriptUpdateParamsBodyObjectMetadataUsageModel = "unbound" ) -func (r ScriptUpdateParamsVariant0MetadataUsageModel) IsKnown() bool { +func (r ScriptUpdateParamsBodyObjectMetadataUsageModel) IsKnown() bool { switch r { - case ScriptUpdateParamsVariant0MetadataUsageModelBundled, ScriptUpdateParamsVariant0MetadataUsageModelUnbound: + case ScriptUpdateParamsBodyObjectMetadataUsageModelBundled, ScriptUpdateParamsBodyObjectMetadataUsageModelUnbound: return true } return false } -type ScriptUpdateParamsVariant1 struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Rollback to provided deployment based on deployment ID. Request body will only - // parse a "message" part. You can learn more about deployments - // [here](https://developers.cloudflare.com/workers/platform/deployments/). - RollbackTo param.Field[string] `query:"rollback_to"` - // Rollback message to be associated with this deployment. Only parsed when query - // param `"rollback_to"` is present. - Message param.Field[string] `json:"message"` -} - -func (r ScriptUpdateParamsVariant1) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// URLQuery serializes [ScriptUpdateParamsVariant1]'s query parameters as -// `url.Values`. -func (r ScriptUpdateParamsVariant1) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -func (r ScriptUpdateParamsVariant1) getAccountID() param.Field[string] { - return r.AccountID -} - -func (ScriptUpdateParamsVariant1) ImplementsScriptUpdateParams() { - -} - type ScriptUpdateResponseEnvelope struct { - Errors []ScriptUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersScript `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Script `json:"result,required"` // Whether the API call was successful Success ScriptUpdateResponseEnvelopeSuccess `json:"success,required"` JSON scriptUpdateResponseEnvelopeJSON `json:"-"` @@ -499,52 +366,6 @@ func (r scriptUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ScriptUpdateResponseEnvelopeErrors] -type scriptUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptUpdateResponseEnvelopeMessages] -type scriptUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptUpdateResponseEnvelopeSuccess bool @@ -568,16 +389,21 @@ type ScriptListParams struct { type ScriptDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` // If set to true, delete will not be stopped by associated service binding, // durable object, or other binding. Any of these associated bindings/durable // objects will be deleted along with the script. Force param.Field[bool] `query:"force"` } +func (r ScriptDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + // URLQuery serializes [ScriptDeleteParams]'s query parameters as `url.Values`. func (r ScriptDeleteParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/workers/script_test.go b/workers/script_test.go index d3d22c9a430..95c8c9fd2d6 100644 --- a/workers/script_test.go +++ b/workers/script_test.go @@ -35,71 +35,73 @@ func TestScriptUpdateWithOptionalParams(t *testing.T) { _, err := client.Workers.Scripts.Update( context.TODO(), "this-is_my_script-01", - workers.ScriptUpdateParamsVariant0{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - RollbackTo: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(workers.ScriptUpdateParamsVariant0Metadata{ - Bindings: cloudflare.F([]interface{}{map[string]interface{}{ - "name": "MY_ENV_VAR", - "text": "my_data", - "type": "plain_text", - }}), - BodyPart: cloudflare.F("worker.js"), - CompatibilityDate: cloudflare.F("2023-07-25"), - CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), - KeepBindings: cloudflare.F([]string{"string", "string", "string"}), - Logpush: cloudflare.F(false), - MainModule: cloudflare.F("worker.js"), - Migrations: cloudflare.F[workers.ScriptUpdateParamsVariant0MetadataMigrations](workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations(workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), + workers.ScriptUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: workers.ScriptUpdateParamsBodyObject{ + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Metadata: cloudflare.F(workers.ScriptUpdateParamsBodyObjectMetadata{ + Bindings: cloudflare.F([]interface{}{map[string]interface{}{ + "name": "MY_ENV_VAR", + "text": "my_data", + "type": "plain_text", }}), - TransferredClasses: cloudflare.F([]workers.ScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), + BodyPart: cloudflare.F("worker.js"), + CompatibilityDate: cloudflare.F("2023-07-25"), + CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), + KeepBindings: cloudflare.F([]string{"string", "string", "string"}), + Logpush: cloudflare.F(false), + MainModule: cloudflare.F("worker.js"), + Migrations: cloudflare.F[workers.ScriptUpdateParamsBodyObjectMetadataMigrationsUnion](workers.SingleStepMigrationParam{ + NewTag: cloudflare.F("v2"), + OldTag: cloudflare.F("v1"), + DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), + NewClasses: cloudflare.F([]string{"string", "string", "string"}), + RenamedClasses: cloudflare.F([]workers.SingleStepMigrationRenamedClassParam{{ + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + TransferredClasses: cloudflare.F([]workers.SingleStepMigrationTransferredClassParam{{ + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + }), + Placement: cloudflare.F(workers.PlacementConfigurationParam{ + Mode: cloudflare.F(workers.PlacementConfigurationModeSmart), + }), + Tags: cloudflare.F([]string{"string", "string", "string"}), + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }}), - })), - Placement: cloudflare.F(workers.ScriptUpdateParamsVariant0MetadataPlacement{ - Mode: cloudflare.F(workers.ScriptUpdateParamsVariant0MetadataPlacementModeSmart), + UsageModel: cloudflare.F(workers.ScriptUpdateParamsBodyObjectMetadataUsageModelBundled), + VersionTags: cloudflare.F[any](map[string]interface{}{}), }), - Tags: cloudflare.F([]string{"string", "string", "string"}), - TailConsumers: cloudflare.F([]workers.ScriptUpdateParamsVariant0MetadataTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F(workers.ScriptUpdateParamsVariant0MetadataUsageModelBundled), - VersionTags: cloudflare.F[any](map[string]interface{}{}), - }), + }, + RollbackTo: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, ) if err != nil { @@ -156,6 +158,7 @@ func TestScriptDeleteWithOptionalParams(t *testing.T) { "this-is_my_script-01", workers.ScriptDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, Force: cloudflare.F(true), }, ) diff --git a/workers/scriptbinding.go b/workers/scriptbinding.go deleted file mode 100644 index 8b39ec0daf4..00000000000 --- a/workers/scriptbinding.go +++ /dev/null @@ -1,249 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/tidwall/gjson" -) - -// ScriptBindingService 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 [NewScriptBindingService] method -// instead. -type ScriptBindingService struct { - Options []option.RequestOption -} - -// NewScriptBindingService 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 NewScriptBindingService(opts ...option.RequestOption) (r *ScriptBindingService) { - r = &ScriptBindingService{} - r.Options = opts - return -} - -// List the bindings for a Workers script. -func (r *ScriptBindingService) Get(ctx context.Context, query ScriptBindingGetParams, opts ...option.RequestOption) (res *[]WorkersBinding, err error) { - opts = append(r.Options[:], opts...) - var env ScriptBindingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/script/bindings", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [workers.WorkersBindingWorkersKVNamespaceBinding] or -// [workers.WorkersBindingWorkersWasmModuleBinding]. -type WorkersBinding interface { - implementsWorkersWorkersBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkersBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersBindingWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersBindingWorkersWasmModuleBinding{}), - }, - ) -} - -type WorkersBindingWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkersBindingWorkersKVNamespaceBindingType `json:"type,required"` - JSON workersBindingWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workersBindingWorkersKVNamespaceBindingJSON contains the JSON metadata for the -// struct [WorkersBindingWorkersKVNamespaceBinding] -type workersBindingWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersBindingWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersBindingWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersBindingWorkersKVNamespaceBinding) implementsWorkersWorkersBinding() {} - -// The class of resource that the binding provides. -type WorkersBindingWorkersKVNamespaceBindingType string - -const ( - WorkersBindingWorkersKVNamespaceBindingTypeKVNamespace WorkersBindingWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r WorkersBindingWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case WorkersBindingWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type WorkersBindingWorkersWasmModuleBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersBindingWorkersWasmModuleBindingType `json:"type,required"` - JSON workersBindingWorkersWasmModuleBindingJSON `json:"-"` -} - -// workersBindingWorkersWasmModuleBindingJSON contains the JSON metadata for the -// struct [WorkersBindingWorkersWasmModuleBinding] -type workersBindingWorkersWasmModuleBindingJSON struct { - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersBindingWorkersWasmModuleBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersBindingWorkersWasmModuleBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersBindingWorkersWasmModuleBinding) implementsWorkersWorkersBinding() {} - -// The class of resource that the binding provides. -type WorkersBindingWorkersWasmModuleBindingType string - -const ( - WorkersBindingWorkersWasmModuleBindingTypeWasmModule WorkersBindingWorkersWasmModuleBindingType = "wasm_module" -) - -func (r WorkersBindingWorkersWasmModuleBindingType) IsKnown() bool { - switch r { - case WorkersBindingWorkersWasmModuleBindingTypeWasmModule: - return true - } - return false -} - -type ScriptBindingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ScriptBindingGetResponseEnvelope struct { - Errors []ScriptBindingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptBindingGetResponseEnvelopeMessages `json:"messages,required"` - Result []WorkersBinding `json:"result,required"` - // Whether the API call was successful - Success ScriptBindingGetResponseEnvelopeSuccess `json:"success,required"` - JSON scriptBindingGetResponseEnvelopeJSON `json:"-"` -} - -// scriptBindingGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ScriptBindingGetResponseEnvelope] -type scriptBindingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptBindingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptBindingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ScriptBindingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptBindingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptBindingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptBindingGetResponseEnvelopeErrors] -type scriptBindingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptBindingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptBindingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptBindingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptBindingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptBindingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptBindingGetResponseEnvelopeMessages] -type scriptBindingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptBindingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptBindingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ScriptBindingGetResponseEnvelopeSuccess bool - -const ( - ScriptBindingGetResponseEnvelopeSuccessTrue ScriptBindingGetResponseEnvelopeSuccess = true -) - -func (r ScriptBindingGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case ScriptBindingGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/workers/scriptbinding_test.go b/workers/scriptbinding_test.go deleted file mode 100644 index d8a843ba01a..00000000000 --- a/workers/scriptbinding_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers_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/workers" -) - -func TestScriptBindingGet(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.Workers.Scripts.Bindings.Get(context.TODO(), workers.ScriptBindingGetParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }) - 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/workers/scriptcontent.go b/workers/scriptcontent.go index 6a4255a6e15..84ee7e1f33d 100644 --- a/workers/scriptcontent.go +++ b/workers/scriptcontent.go @@ -14,6 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewScriptContentService(opts ...option.RequestOption) (r *ScriptContentServ } // Put script content without touching config or metadata -func (r *ScriptContentService) Update(ctx context.Context, scriptName string, params ScriptContentUpdateParams, opts ...option.RequestOption) (res *WorkersScript, err error) { +func (r *ScriptContentService) Update(ctx context.Context, scriptName string, params ScriptContentUpdateParams, opts ...option.RequestOption) (res *Script, err error) { opts = append(r.Options[:], opts...) var env ScriptContentUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/scripts/%s/content", params.AccountID, scriptName) @@ -48,6 +49,15 @@ func (r *ScriptContentService) Update(ctx context.Context, scriptName string, pa return } +// Fetch script content only +func (r *ScriptContentService) Get(ctx context.Context, scriptName string, query ScriptContentGetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/content/v2", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + type ScriptContentUpdateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -55,12 +65,13 @@ type ScriptContentUpdateParams struct { // may be provided as separate named parts, but at least one module must be // present. This should be referenced either in the metadata as `main_module` // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` - // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. + // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. Source maps may also + // be included using the `application/source-map` content type. AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[ScriptContentUpdateParamsMetadata] `json:"metadata"` - CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` - CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` + Metadata param.Field[WorkerMetadataParam] `json:"metadata"` + CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` + CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` } func (r ScriptContentUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { @@ -78,25 +89,10 @@ func (r ScriptContentUpdateParams) MarshalMultipart() (data []byte, contentType return buf.Bytes(), writer.FormDataContentType(), nil } -// JSON encoded metadata about the uploaded parts and Worker configuration. -type ScriptContentUpdateParamsMetadata struct { - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` -} - -func (r ScriptContentUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type ScriptContentUpdateResponseEnvelope struct { - Errors []ScriptContentUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptContentUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersScript `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Script `json:"result,required"` // Whether the API call was successful Success ScriptContentUpdateResponseEnvelopeSuccess `json:"success,required"` JSON scriptContentUpdateResponseEnvelopeJSON `json:"-"` @@ -121,52 +117,6 @@ func (r scriptContentUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptContentUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptContentUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptContentUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptContentUpdateResponseEnvelopeErrors] -type scriptContentUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptContentUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptContentUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptContentUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptContentUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptContentUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ScriptContentUpdateResponseEnvelopeMessages] -type scriptContentUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptContentUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptContentUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptContentUpdateResponseEnvelopeSuccess bool @@ -181,3 +131,8 @@ func (r ScriptContentUpdateResponseEnvelopeSuccess) IsKnown() bool { } return false } + +type ScriptContentGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/workers/scriptcontent_test.go b/workers/scriptcontent_test.go index 744d305beab..ec7fd6f6802 100644 --- a/workers/scriptcontent_test.go +++ b/workers/scriptcontent_test.go @@ -7,6 +7,8 @@ import ( "context" "errors" "io" + "net/http" + "net/http/httptest" "os" "testing" @@ -36,7 +38,7 @@ func TestScriptContentUpdateWithOptionalParams(t *testing.T) { workers.ScriptContentUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(workers.ScriptContentUpdateParamsMetadata{ + Metadata: cloudflare.F(workers.WorkerMetadataParam{ BodyPart: cloudflare.F("worker.js"), MainModule: cloudflare.F("worker.js"), }), @@ -52,3 +54,45 @@ func TestScriptContentUpdateWithOptionalParams(t *testing.T) { t.Fatalf("err should be nil: %s", err.Error()) } } + +func TestScriptContentGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.Workers.Scripts.Content.Get( + context.TODO(), + "this-is_my_script-01", + workers.ScriptContentGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, + ) + 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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/workers/scriptcontentv2.go b/workers/scriptcontentv2.go deleted file mode 100644 index 15729bd9291..00000000000 --- a/workers/scriptcontentv2.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// ScriptContentV2Service 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 [NewScriptContentV2Service] method -// instead. -type ScriptContentV2Service struct { - Options []option.RequestOption -} - -// NewScriptContentV2Service 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 NewScriptContentV2Service(opts ...option.RequestOption) (r *ScriptContentV2Service) { - r = &ScriptContentV2Service{} - r.Options = opts - return -} - -// Fetch script content only -func (r *ScriptContentV2Service) Get(ctx context.Context, scriptName string, query ScriptContentV2GetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/content/v2", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -type ScriptContentV2GetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workers/scriptcontentv2_test.go b/workers/scriptcontentv2_test.go deleted file mode 100644 index 284d164689d..00000000000 --- a/workers/scriptcontentv2_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "testing" - - "github.com/cloudflare/cloudflare-go/v2" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/cloudflare/cloudflare-go/v2/workers" -) - -func TestScriptContentV2Get(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Workers.Scripts.ContentV2.Get( - context.TODO(), - "this-is_my_script-01", - workers.ScriptContentV2GetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) - 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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/workers/scriptdeployment.go b/workers/scriptdeployment.go new file mode 100644 index 00000000000..265fb5fdd1c --- /dev/null +++ b/workers/scriptdeployment.go @@ -0,0 +1,278 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "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" +) + +// ScriptDeploymentService 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 [NewScriptDeploymentService] method +// instead. +type ScriptDeploymentService struct { + Options []option.RequestOption +} + +// NewScriptDeploymentService 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 NewScriptDeploymentService(opts ...option.RequestOption) (r *ScriptDeploymentService) { + r = &ScriptDeploymentService{} + r.Options = opts + return +} + +// Deployments configure how +// [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions) +// are deployed to traffic. A deployment can consist of one or two versions of a +// Worker. +func (r *ScriptDeploymentService) New(ctx context.Context, scriptName string, params ScriptDeploymentNewParams, opts ...option.RequestOption) (res *ScriptDeploymentNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptDeploymentNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/deployments", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List of Worker Deployments. The first deployment in the list is the latest +// deployment actively serving traffic. +func (r *ScriptDeploymentService) Get(ctx context.Context, scriptName string, query ScriptDeploymentGetParams, opts ...option.RequestOption) (res *ScriptDeploymentGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptDeploymentGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/deployments", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type Deployment struct { + // Human-readable message about the deployment. + WorkersMessage string `json:"workers/message"` + JSON deploymentJSON `json:"-"` +} + +// deploymentJSON contains the JSON metadata for the struct [Deployment] +type deploymentJSON struct { + WorkersMessage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Deployment) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentJSON) RawJSON() string { + return r.raw +} + +type DeploymentParam struct { + // Human-readable message about the deployment. + WorkersMessage param.Field[string] `json:"workers/message"` +} + +func (r DeploymentParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptDeploymentNewResponse struct { + ID string `json:"id"` + Annotations Deployment `json:"annotations"` + AuthorEmail string `json:"author_email"` + CreatedOn string `json:"created_on"` + Source string `json:"source"` + Strategy string `json:"strategy"` + JSON scriptDeploymentNewResponseJSON `json:"-"` +} + +// scriptDeploymentNewResponseJSON contains the JSON metadata for the struct +// [ScriptDeploymentNewResponse] +type scriptDeploymentNewResponseJSON struct { + ID apijson.Field + Annotations apijson.Field + AuthorEmail apijson.Field + CreatedOn apijson.Field + Source apijson.Field + Strategy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptDeploymentNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptDeploymentNewResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptDeploymentGetResponse struct { + Deployments []ScriptDeploymentGetResponseDeployment `json:"deployments"` + JSON scriptDeploymentGetResponseJSON `json:"-"` +} + +// scriptDeploymentGetResponseJSON contains the JSON metadata for the struct +// [ScriptDeploymentGetResponse] +type scriptDeploymentGetResponseJSON struct { + Deployments apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptDeploymentGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptDeploymentGetResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptDeploymentGetResponseDeployment struct { + ID string `json:"id"` + Annotations Deployment `json:"annotations"` + AuthorEmail string `json:"author_email"` + CreatedOn string `json:"created_on"` + Source string `json:"source"` + Strategy string `json:"strategy"` + JSON scriptDeploymentGetResponseDeploymentJSON `json:"-"` +} + +// scriptDeploymentGetResponseDeploymentJSON contains the JSON metadata for the +// struct [ScriptDeploymentGetResponseDeployment] +type scriptDeploymentGetResponseDeploymentJSON struct { + ID apijson.Field + Annotations apijson.Field + AuthorEmail apijson.Field + CreatedOn apijson.Field + Source apijson.Field + Strategy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptDeploymentGetResponseDeployment) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptDeploymentGetResponseDeploymentJSON) RawJSON() string { + return r.raw +} + +type ScriptDeploymentNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Annotations param.Field[DeploymentParam] `json:"annotations"` + Strategy param.Field[string] `json:"strategy"` +} + +func (r ScriptDeploymentNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptDeploymentNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptDeploymentNewResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptDeploymentNewResponseEnvelopeSuccess `json:"success,required"` + JSON scriptDeploymentNewResponseEnvelopeJSON `json:"-"` +} + +// scriptDeploymentNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [ScriptDeploymentNewResponseEnvelope] +type scriptDeploymentNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptDeploymentNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptDeploymentNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptDeploymentNewResponseEnvelopeSuccess bool + +const ( + ScriptDeploymentNewResponseEnvelopeSuccessTrue ScriptDeploymentNewResponseEnvelopeSuccess = true +) + +func (r ScriptDeploymentNewResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case ScriptDeploymentNewResponseEnvelopeSuccessTrue: + return true + } + return false +} + +type ScriptDeploymentGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptDeploymentGetResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptDeploymentGetResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptDeploymentGetResponseEnvelopeSuccess `json:"success,required"` + JSON scriptDeploymentGetResponseEnvelopeJSON `json:"-"` +} + +// scriptDeploymentGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ScriptDeploymentGetResponseEnvelope] +type scriptDeploymentGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptDeploymentGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptDeploymentGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptDeploymentGetResponseEnvelopeSuccess bool + +const ( + ScriptDeploymentGetResponseEnvelopeSuccessTrue ScriptDeploymentGetResponseEnvelopeSuccess = true +) + +func (r ScriptDeploymentGetResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case ScriptDeploymentGetResponseEnvelopeSuccessTrue: + return true + } + return false +} diff --git a/workers/scriptusagemodel_test.go b/workers/scriptdeployment_test.go similarity index 80% rename from workers/scriptusagemodel_test.go rename to workers/scriptdeployment_test.go index 0546a32685d..bd146259bbf 100644 --- a/workers/scriptusagemodel_test.go +++ b/workers/scriptdeployment_test.go @@ -14,7 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/workers" ) -func TestScriptUsageModelUpdate(t *testing.T) { +func TestScriptDeploymentNewWithOptionalParams(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 { @@ -28,12 +28,15 @@ func TestScriptUsageModelUpdate(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Workers.Scripts.UsageModel.Update( + _, err := client.Workers.Scripts.Deployments.New( context.TODO(), "this-is_my_script-01", - workers.ScriptUsageModelUpdateParams{ + workers.ScriptDeploymentNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F("{'usage_model': 'unbound'}"), + Annotations: cloudflare.F(workers.DeploymentParam{ + WorkersMessage: cloudflare.F("Deploy bug fix."), + }), + Strategy: cloudflare.F("string"), }, ) if err != nil { @@ -45,7 +48,7 @@ func TestScriptUsageModelUpdate(t *testing.T) { } } -func TestScriptUsageModelGet(t *testing.T) { +func TestScriptDeploymentGet(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 { @@ -59,10 +62,10 @@ func TestScriptUsageModelGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Workers.Scripts.UsageModel.Get( + _, err := client.Workers.Scripts.Deployments.Get( context.TODO(), "this-is_my_script-01", - workers.ScriptUsageModelGetParams{ + workers.ScriptDeploymentGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/workers/scriptschedule.go b/workers/scriptschedule.go index d055c13d2e8..57655387c80 100644 --- a/workers/scriptschedule.go +++ b/workers/scriptschedule.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -57,55 +58,61 @@ func (r *ScriptScheduleService) Get(ctx context.Context, scriptName string, quer return } -type ScriptScheduleUpdateResponse struct { - Schedules []ScriptScheduleUpdateResponseSchedule `json:"schedules"` - JSON scriptScheduleUpdateResponseJSON `json:"-"` +type Schedule struct { + CreatedOn interface{} `json:"created_on"` + Cron interface{} `json:"cron"` + ModifiedOn interface{} `json:"modified_on"` + JSON scheduleJSON `json:"-"` } -// scriptScheduleUpdateResponseJSON contains the JSON metadata for the struct -// [ScriptScheduleUpdateResponse] -type scriptScheduleUpdateResponseJSON struct { - Schedules apijson.Field +// scheduleJSON contains the JSON metadata for the struct [Schedule] +type scheduleJSON struct { + CreatedOn apijson.Field + Cron apijson.Field + ModifiedOn apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ScriptScheduleUpdateResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Schedule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r scriptScheduleUpdateResponseJSON) RawJSON() string { +func (r scheduleJSON) RawJSON() string { return r.raw } -type ScriptScheduleUpdateResponseSchedule struct { - CreatedOn interface{} `json:"created_on"` - Cron interface{} `json:"cron"` - ModifiedOn interface{} `json:"modified_on"` - JSON scriptScheduleUpdateResponseScheduleJSON `json:"-"` +type ScheduleParam struct { } -// scriptScheduleUpdateResponseScheduleJSON contains the JSON metadata for the -// struct [ScriptScheduleUpdateResponseSchedule] -type scriptScheduleUpdateResponseScheduleJSON struct { - CreatedOn apijson.Field - Cron apijson.Field - ModifiedOn apijson.Field +func (r ScheduleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptScheduleUpdateResponse struct { + Schedules []Schedule `json:"schedules"` + JSON scriptScheduleUpdateResponseJSON `json:"-"` +} + +// scriptScheduleUpdateResponseJSON contains the JSON metadata for the struct +// [ScriptScheduleUpdateResponse] +type scriptScheduleUpdateResponseJSON struct { + Schedules apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ScriptScheduleUpdateResponseSchedule) UnmarshalJSON(data []byte) (err error) { +func (r *ScriptScheduleUpdateResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r scriptScheduleUpdateResponseScheduleJSON) RawJSON() string { +func (r scriptScheduleUpdateResponseJSON) RawJSON() string { return r.raw } type ScriptScheduleGetResponse struct { - Schedules []ScriptScheduleGetResponseSchedule `json:"schedules"` - JSON scriptScheduleGetResponseJSON `json:"-"` + Schedules []Schedule `json:"schedules"` + JSON scriptScheduleGetResponseJSON `json:"-"` } // scriptScheduleGetResponseJSON contains the JSON metadata for the struct @@ -124,35 +131,10 @@ func (r scriptScheduleGetResponseJSON) RawJSON() string { return r.raw } -type ScriptScheduleGetResponseSchedule struct { - CreatedOn interface{} `json:"created_on"` - Cron interface{} `json:"cron"` - ModifiedOn interface{} `json:"modified_on"` - JSON scriptScheduleGetResponseScheduleJSON `json:"-"` -} - -// scriptScheduleGetResponseScheduleJSON contains the JSON metadata for the struct -// [ScriptScheduleGetResponseSchedule] -type scriptScheduleGetResponseScheduleJSON struct { - CreatedOn apijson.Field - Cron apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptScheduleGetResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptScheduleGetResponseScheduleJSON) RawJSON() string { - return r.raw -} - type ScriptScheduleUpdateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[string] `json:"body,required"` + Body string `json:"body,required"` } func (r ScriptScheduleUpdateParams) MarshalJSON() (data []byte, err error) { @@ -160,9 +142,9 @@ func (r ScriptScheduleUpdateParams) MarshalJSON() (data []byte, err error) { } type ScriptScheduleUpdateResponseEnvelope struct { - Errors []ScriptScheduleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptScheduleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ScriptScheduleUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptScheduleUpdateResponse `json:"result,required"` // Whether the API call was successful Success ScriptScheduleUpdateResponseEnvelopeSuccess `json:"success,required"` JSON scriptScheduleUpdateResponseEnvelopeJSON `json:"-"` @@ -187,52 +169,6 @@ func (r scriptScheduleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptScheduleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptScheduleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptScheduleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ScriptScheduleUpdateResponseEnvelopeErrors] -type scriptScheduleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptScheduleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptScheduleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptScheduleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptScheduleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptScheduleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ScriptScheduleUpdateResponseEnvelopeMessages] -type scriptScheduleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptScheduleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptScheduleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptScheduleUpdateResponseEnvelopeSuccess bool @@ -254,9 +190,9 @@ type ScriptScheduleGetParams struct { } type ScriptScheduleGetResponseEnvelope struct { - Errors []ScriptScheduleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptScheduleGetResponseEnvelopeMessages `json:"messages,required"` - Result ScriptScheduleGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptScheduleGetResponse `json:"result,required"` // Whether the API call was successful Success ScriptScheduleGetResponseEnvelopeSuccess `json:"success,required"` JSON scriptScheduleGetResponseEnvelopeJSON `json:"-"` @@ -281,52 +217,6 @@ func (r scriptScheduleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptScheduleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptScheduleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptScheduleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptScheduleGetResponseEnvelopeErrors] -type scriptScheduleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptScheduleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptScheduleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptScheduleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptScheduleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptScheduleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptScheduleGetResponseEnvelopeMessages] -type scriptScheduleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptScheduleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptScheduleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptScheduleGetResponseEnvelopeSuccess bool diff --git a/workers/scriptschedule_test.go b/workers/scriptschedule_test.go index 27590d0e6bd..a14d50ae951 100644 --- a/workers/scriptschedule_test.go +++ b/workers/scriptschedule_test.go @@ -33,7 +33,7 @@ func TestScriptScheduleUpdate(t *testing.T) { "this-is_my_script-01", workers.ScriptScheduleUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F("[{'cron': '*/30 * * * *'}]"), + Body: "[{'cron': '*/30 * * * *'}]", }, ) if err != nil { diff --git a/workers/scriptsetting.go b/workers/scriptsetting.go index bcae9a384d8..ed8c14427bd 100644 --- a/workers/scriptsetting.go +++ b/workers/scriptsetting.go @@ -6,13 +6,12 @@ import ( "context" "fmt" "net/http" - "reflect" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) // ScriptSettingService contains methods and other services that help with @@ -33,11 +32,13 @@ func NewScriptSettingService(opts ...option.RequestOption) (r *ScriptSettingServ return } -// Patch script metadata or config, such as bindings or usage model -func (r *ScriptSettingService) Edit(ctx context.Context, scriptName string, params ScriptSettingEditParams, opts ...option.RequestOption) (res *ScriptSettingEditResponse, err error) { +// Patch script-level settings when using +// [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions). +// Includes Logpush and Tail Consumers. +func (r *ScriptSettingService) Edit(ctx context.Context, scriptName string, params ScriptSettingEditParams, opts ...option.RequestOption) (res *ScriptSetting, err error) { opts = append(r.Options[:], opts...) var env ScriptSettingEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/settings", params.AccountID, scriptName) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/script-settings", params.AccountID, scriptName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) if err != nil { return @@ -46,11 +47,13 @@ func (r *ScriptSettingService) Edit(ctx context.Context, scriptName string, para return } -// Get script metadata and config, such as bindings or usage model -func (r *ScriptSettingService) Get(ctx context.Context, scriptName string, query ScriptSettingGetParams, opts ...option.RequestOption) (res *ScriptSettingGetResponse, err error) { +// Get script-level settings when using +// [Worker Versions](https://developers.cloudflare.com/api/operations/worker-versions-list-versions). +// Includes Logpush and Tail Consumers. +func (r *ScriptSettingService) Get(ctx context.Context, scriptName string, query ScriptSettingGetParams, opts ...option.RequestOption) (res *ScriptSetting, err error) { opts = append(r.Options[:], opts...) var env ScriptSettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/settings", query.AccountID, scriptName) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/script-settings", query.AccountID, scriptName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -59,2209 +62,20 @@ func (r *ScriptSettingService) Get(ctx context.Context, scriptName string, query return } -type ScriptSettingEditResponse struct { - // List of bindings attached to this Worker - Bindings []ScriptSettingEditResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations ScriptSettingEditResponseMigrations `json:"migrations"` - Placement ScriptSettingEditResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []ScriptSettingEditResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON scriptSettingEditResponseJSON `json:"-"` -} - -// scriptSettingEditResponseJSON contains the JSON metadata for the struct -// [ScriptSettingEditResponse] -type scriptSettingEditResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [workers.ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding], -// [workers.ScriptSettingEditResponseBindingsWorkersServiceBinding], -// [workers.ScriptSettingEditResponseBindingsWorkersDoBinding], -// [workers.ScriptSettingEditResponseBindingsWorkersR2Binding], -// [workers.ScriptSettingEditResponseBindingsWorkersQueueBinding], -// [workers.ScriptSettingEditResponseBindingsWorkersD1Binding], -// [workers.ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] or -// [workers.ScriptSettingEditResponseBindingsWorkersMTLSCERTBinding]. -type ScriptSettingEditResponseBinding interface { - implementsWorkersScriptSettingEditResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ScriptSettingEditResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersMTLSCERTBinding{}), - }, - ) -} - -type ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON contains the JSON -// metadata for the struct -// [ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding] -type scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type ScriptSettingEditResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON scriptSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersServiceBindingJSON contains the JSON -// metadata for the struct [ScriptSettingEditResponseBindingsWorkersServiceBinding] -type scriptSettingEditResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersServiceBinding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersServiceBindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersServiceBindingTypeService ScriptSettingEditResponseBindingsWorkersServiceBindingType = "service" -) - -func (r ScriptSettingEditResponseBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type ScriptSettingEditResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON scriptSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersDoBindingJSON contains the JSON metadata -// for the struct [ScriptSettingEditResponseBindingsWorkersDoBinding] -type scriptSettingEditResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersDoBinding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersDoBindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ScriptSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r ScriptSettingEditResponseBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type ScriptSettingEditResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON scriptSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersR2BindingJSON contains the JSON metadata -// for the struct [ScriptSettingEditResponseBindingsWorkersR2Binding] -type scriptSettingEditResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersR2Binding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersR2BindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket ScriptSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r ScriptSettingEditResponseBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type ScriptSettingEditResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON scriptSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersQueueBindingJSON contains the JSON -// metadata for the struct [ScriptSettingEditResponseBindingsWorkersQueueBinding] -type scriptSettingEditResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersQueueBinding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersQueueBindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersQueueBindingTypeQueue ScriptSettingEditResponseBindingsWorkersQueueBindingType = "queue" -) - -func (r ScriptSettingEditResponseBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type ScriptSettingEditResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON scriptSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersD1BindingJSON contains the JSON metadata -// for the struct [ScriptSettingEditResponseBindingsWorkersD1Binding] -type scriptSettingEditResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersD1Binding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersD1BindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersD1BindingTypeD1 ScriptSettingEditResponseBindingsWorkersD1BindingType = "d1" -) - -func (r ScriptSettingEditResponseBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON contains -// the JSON metadata for the struct -// [ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -type scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditResponseBindingsWorkersMTLSCERTBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON scriptSettingEditResponseBindingsWorkersMtlscertBindingJSON `json:"-"` -} - -// scriptSettingEditResponseBindingsWorkersMtlscertBindingJSON contains the JSON -// metadata for the struct -// [ScriptSettingEditResponseBindingsWorkersMTLSCERTBinding] -type scriptSettingEditResponseBindingsWorkersMtlscertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseBindingsWorkersMTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseBindingsWorkersMtlscertBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseBindingsWorkersMTLSCERTBinding) implementsWorkersScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType string - -const ( - ScriptSettingEditResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate ScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r ScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [workers.ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] or -// [workers.ScriptSettingEditResponseMigrationsWorkersSteppedMigrations]. -type ScriptSettingEditResponseMigrations interface { - implementsWorkersScriptSettingEditResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ScriptSettingEditResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingEditResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON contains the -// JSON metadata for the struct -// [ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] -type scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkersScriptSettingEditResponseMigrations() { -} - -type ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON contains the -// JSON metadata for the struct -// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrations] -type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkersScriptSettingEditResponseMigrations() { -} - -type ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON contains the -// JSON metadata for the struct -// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep] -type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode ScriptSettingEditResponsePlacementMode `json:"mode"` - JSON scriptSettingEditResponsePlacementJSON `json:"-"` -} - -// scriptSettingEditResponsePlacementJSON contains the JSON metadata for the struct -// [ScriptSettingEditResponsePlacement] -type scriptSettingEditResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type ScriptSettingEditResponsePlacementMode string - -const ( - ScriptSettingEditResponsePlacementModeSmart ScriptSettingEditResponsePlacementMode = "smart" -) - -func (r ScriptSettingEditResponsePlacementMode) IsKnown() bool { - switch r { - case ScriptSettingEditResponsePlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type ScriptSettingEditResponseTailConsumer 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 scriptSettingEditResponseTailConsumerJSON `json:"-"` -} - -// scriptSettingEditResponseTailConsumerJSON contains the JSON metadata for the -// struct [ScriptSettingEditResponseTailConsumer] -type scriptSettingEditResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponse struct { - // List of bindings attached to this Worker - Bindings []ScriptSettingGetResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations ScriptSettingGetResponseMigrations `json:"migrations"` - Placement ScriptSettingGetResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []ScriptSettingGetResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON scriptSettingGetResponseJSON `json:"-"` -} - -// scriptSettingGetResponseJSON contains the JSON metadata for the struct -// [ScriptSettingGetResponse] -type scriptSettingGetResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [workers.ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding], -// [workers.ScriptSettingGetResponseBindingsWorkersServiceBinding], -// [workers.ScriptSettingGetResponseBindingsWorkersDoBinding], -// [workers.ScriptSettingGetResponseBindingsWorkersR2Binding], -// [workers.ScriptSettingGetResponseBindingsWorkersQueueBinding], -// [workers.ScriptSettingGetResponseBindingsWorkersD1Binding], -// [workers.ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] or -// [workers.ScriptSettingGetResponseBindingsWorkersMTLSCERTBinding]. -type ScriptSettingGetResponseBinding interface { - implementsWorkersScriptSettingGetResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ScriptSettingGetResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersMTLSCERTBinding{}), - }, - ) -} - -type ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON contains the JSON -// metadata for the struct -// [ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding] -type scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type ScriptSettingGetResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON scriptSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersServiceBindingJSON contains the JSON -// metadata for the struct [ScriptSettingGetResponseBindingsWorkersServiceBinding] -type scriptSettingGetResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersServiceBinding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersServiceBindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersServiceBindingTypeService ScriptSettingGetResponseBindingsWorkersServiceBindingType = "service" -) - -func (r ScriptSettingGetResponseBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type ScriptSettingGetResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON scriptSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersDoBindingJSON contains the JSON metadata -// for the struct [ScriptSettingGetResponseBindingsWorkersDoBinding] -type scriptSettingGetResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersDoBinding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersDoBindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ScriptSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r ScriptSettingGetResponseBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type ScriptSettingGetResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON scriptSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersR2BindingJSON contains the JSON metadata -// for the struct [ScriptSettingGetResponseBindingsWorkersR2Binding] -type scriptSettingGetResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersR2Binding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersR2BindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket ScriptSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r ScriptSettingGetResponseBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type ScriptSettingGetResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON scriptSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersQueueBindingJSON contains the JSON -// metadata for the struct [ScriptSettingGetResponseBindingsWorkersQueueBinding] -type scriptSettingGetResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersQueueBinding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersQueueBindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersQueueBindingTypeQueue ScriptSettingGetResponseBindingsWorkersQueueBindingType = "queue" -) - -func (r ScriptSettingGetResponseBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type ScriptSettingGetResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON scriptSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersD1BindingJSON contains the JSON metadata -// for the struct [ScriptSettingGetResponseBindingsWorkersD1Binding] -type scriptSettingGetResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersD1Binding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersD1BindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersD1BindingTypeD1 ScriptSettingGetResponseBindingsWorkersD1BindingType = "d1" -) - -func (r ScriptSettingGetResponseBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON contains the -// JSON metadata for the struct -// [ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -type scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponseBindingsWorkersMTLSCERTBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON scriptSettingGetResponseBindingsWorkersMtlscertBindingJSON `json:"-"` -} - -// scriptSettingGetResponseBindingsWorkersMtlscertBindingJSON contains the JSON -// metadata for the struct [ScriptSettingGetResponseBindingsWorkersMTLSCERTBinding] -type scriptSettingGetResponseBindingsWorkersMtlscertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseBindingsWorkersMTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseBindingsWorkersMtlscertBindingJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseBindingsWorkersMTLSCERTBinding) implementsWorkersScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType string - -const ( - ScriptSettingGetResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate ScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r ScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case ScriptSettingGetResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [workers.ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] or -// [workers.ScriptSettingGetResponseMigrationsWorkersSteppedMigrations]. -type ScriptSettingGetResponseMigrations interface { - implementsWorkersScriptSettingGetResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ScriptSettingGetResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ScriptSettingGetResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON contains the -// JSON metadata for the struct -// [ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] -type scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkersScriptSettingGetResponseMigrations() { -} - -type ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON contains the JSON -// metadata for the struct -// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrations] -type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ScriptSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkersScriptSettingGetResponseMigrations() { -} - -type ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON contains the -// JSON metadata for the struct -// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep] -type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode ScriptSettingGetResponsePlacementMode `json:"mode"` - JSON scriptSettingGetResponsePlacementJSON `json:"-"` -} - -// scriptSettingGetResponsePlacementJSON contains the JSON metadata for the struct -// [ScriptSettingGetResponsePlacement] -type scriptSettingGetResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type ScriptSettingGetResponsePlacementMode string - -const ( - ScriptSettingGetResponsePlacementModeSmart ScriptSettingGetResponsePlacementMode = "smart" -) - -func (r ScriptSettingGetResponsePlacementMode) IsKnown() bool { - switch r { - case ScriptSettingGetResponsePlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type ScriptSettingGetResponseTailConsumer 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 scriptSettingGetResponseTailConsumerJSON `json:"-"` -} - -// scriptSettingGetResponseTailConsumerJSON contains the JSON metadata for the -// struct [ScriptSettingGetResponseTailConsumer] -type scriptSettingGetResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Settings param.Field[ScriptSettingEditParamsSettings] `json:"settings"` -} - -func (r ScriptSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettings struct { - Errors param.Field[[]ScriptSettingEditParamsSettingsError] `json:"errors,required"` - Messages param.Field[[]ScriptSettingEditParamsSettingsMessage] `json:"messages,required"` - Result param.Field[ScriptSettingEditParamsSettingsResult] `json:"result,required"` - // Whether the API call was successful - Success param.Field[ScriptSettingEditParamsSettingsSuccess] `json:"success,required"` -} - -func (r ScriptSettingEditParamsSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsError struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r ScriptSettingEditParamsSettingsError) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsMessage struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r ScriptSettingEditParamsSettingsMessage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsResult struct { - // List of bindings attached to this Worker - Bindings param.Field[[]ScriptSettingEditParamsSettingsResultBinding] `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[ScriptSettingEditParamsSettingsResultMigrations] `json:"migrations"` - Placement param.Field[ScriptSettingEditParamsSettingsResultPlacement] `json:"placement"` - // Tags to help you manage your Workers - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]ScriptSettingEditParamsSettingsResultTailConsumer] `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel param.Field[string] `json:"usage_model"` -} - -func (r ScriptSettingEditParamsSettingsResult) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A binding to allow the Worker to communicate with resources -// -// Satisfied by -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding], -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding], -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding], -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding], -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding], -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding], -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding], -// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBinding]. -type ScriptSettingEditParamsSettingsResultBinding interface { - implementsWorkersScriptSettingEditParamsSettingsResultBinding() -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding struct { - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment,required"` - // Name of Worker to bind to - Service param.Field[string] `json:"service,required"` - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType] `json:"type,required"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingTypeService ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType = "service" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName param.Field[string] `json:"class_name,required"` - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType] `json:"type,required"` - // The environment of the script_name to bind to - Environment param.Field[string] `json:"environment"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName param.Field[string] `json:"script_name"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingTypeDurableObjectNamespace ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName param.Field[string] `json:"bucket_name,required"` - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType] `json:"type,required"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingTypeR2Bucket ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding struct { - // Name of the Queue to bind to - QueueName param.Field[string] `json:"queue_name,required"` - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType] `json:"type,required"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingTypeQueue ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType = "queue" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID param.Field[string] `json:"id,required"` - // The name of the D1 database associated with the 'id' provided. - Name param.Field[string] `json:"name,required"` - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType] `json:"type,required"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingTypeD1 ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType = "d1" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding struct { - // Namespace to bind to - Namespace param.Field[string] `json:"namespace,required"` - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` - // Outbound worker - Outbound param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params param.Field[[]string] `json:"params"` - // Outbound worker - Worker param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Outbound worker -type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment param.Field[string] `json:"environment"` - // Name of the outbound worker - Service param.Field[string] `json:"service"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBinding struct { - // The class of resource that the binding provides. - Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBindingType] `json:"type,required"` - // ID of the certificate to bind to - CertificateID param.Field[string] `json:"certificate_id"` -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBindingType string - -const ( - ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBindingTypeMTLSCertificate ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations], -// [workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations]. -type ScriptSettingEditParamsSettingsResultMigrations interface { - implementsWorkersScriptSettingEditParamsSettingsResultMigrations() -} - -// A single set of migrations to apply. -type ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations) implementsWorkersScriptSettingEditParamsSettingsResultMigrations() { -} - -type ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations) implementsWorkersScriptSettingEditParamsSettingsResultMigrations() { -} - -type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ScriptSettingEditParamsSettingsResultPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[ScriptSettingEditParamsSettingsResultPlacementMode] `json:"mode"` -} - -func (r ScriptSettingEditParamsSettingsResultPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type ScriptSettingEditParamsSettingsResultPlacementMode string - -const ( - ScriptSettingEditParamsSettingsResultPlacementModeSmart ScriptSettingEditParamsSettingsResultPlacementMode = "smart" -) - -func (r ScriptSettingEditParamsSettingsResultPlacementMode) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsResultPlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type ScriptSettingEditParamsSettingsResultTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r ScriptSettingEditParamsSettingsResultTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type ScriptSettingEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + ScriptSetting ScriptSettingParam `json:"script_setting,required"` } -// Whether the API call was successful -type ScriptSettingEditParamsSettingsSuccess bool - -const ( - ScriptSettingEditParamsSettingsSuccessTrue ScriptSettingEditParamsSettingsSuccess = true -) - -func (r ScriptSettingEditParamsSettingsSuccess) IsKnown() bool { - switch r { - case ScriptSettingEditParamsSettingsSuccessTrue: - return true - } - return false +func (r ScriptSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.ScriptSetting) } type ScriptSettingEditResponseEnvelope struct { - Errors []ScriptSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result ScriptSettingEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptSetting `json:"result,required"` // Whether the API call was successful Success ScriptSettingEditResponseEnvelopeSuccess `json:"success,required"` JSON scriptSettingEditResponseEnvelopeJSON `json:"-"` @@ -2286,52 +100,6 @@ func (r scriptSettingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptSettingEditResponseEnvelopeErrors] -type scriptSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptSettingEditResponseEnvelopeMessages] -type scriptSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptSettingEditResponseEnvelopeSuccess bool @@ -2353,9 +121,9 @@ type ScriptSettingGetParams struct { } type ScriptSettingGetResponseEnvelope struct { - Errors []ScriptSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result ScriptSettingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptSetting `json:"result,required"` // Whether the API call was successful Success ScriptSettingGetResponseEnvelopeSuccess `json:"success,required"` JSON scriptSettingGetResponseEnvelopeJSON `json:"-"` @@ -2380,52 +148,6 @@ func (r scriptSettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptSettingGetResponseEnvelopeErrors] -type scriptSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptSettingGetResponseEnvelopeMessages] -type scriptSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptSettingGetResponseEnvelopeSuccess bool diff --git a/workers/scriptsetting_test.go b/workers/scriptsetting_test.go index bef872bc01b..939837760f9 100644 --- a/workers/scriptsetting_test.go +++ b/workers/scriptsetting_test.go @@ -33,88 +33,22 @@ func TestScriptSettingEditWithOptionalParams(t *testing.T) { "this-is_my_script-01", workers.ScriptSettingEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Settings: cloudflare.F(workers.ScriptSettingEditParamsSettings{ - Errors: cloudflare.F([]workers.ScriptSettingEditParamsSettingsError{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), + ScriptSetting: workers.ScriptSettingParam{ + Logpush: cloudflare.F(false), + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }}), - Messages: cloudflare.F([]workers.ScriptSettingEditParamsSettingsMessage{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Result: cloudflare.F(workers.ScriptSettingEditParamsSettingsResult{ - Bindings: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultBinding{workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - })}), - CompatibilityDate: cloudflare.F("2022-04-05"), - CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), - Logpush: cloudflare.F(false), - Migrations: cloudflare.F[workers.ScriptSettingEditParamsSettingsResultMigrations](workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations(workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - TransferredClasses: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - })), - Placement: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultPlacement{ - Mode: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultPlacementModeSmart), - }), - Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), - TailConsumers: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F("unbound"), - }), - Success: cloudflare.F(workers.ScriptSettingEditParamsSettingsSuccessTrue), - }), + }, }, ) if err != nil { diff --git a/workers/scripttail.go b/workers/scripttail.go index 2d83824d647..2824704d2f1 100644 --- a/workers/scripttail.go +++ b/workers/scripttail.go @@ -34,10 +34,10 @@ func NewScriptTailService(opts ...option.RequestOption) (r *ScriptTailService) { } // Starts a tail that receives logs and exception from a Worker. -func (r *ScriptTailService) New(ctx context.Context, scriptName string, body ScriptTailNewParams, opts ...option.RequestOption) (res *ScriptTailNewResponse, err error) { +func (r *ScriptTailService) New(ctx context.Context, scriptName string, params ScriptTailNewParams, opts ...option.RequestOption) (res *ScriptTailNewResponse, err error) { opts = append(r.Options[:], opts...) var env ScriptTailNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails", body.AccountID, scriptName) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails", params.AccountID, scriptName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) if err != nil { return @@ -47,10 +47,10 @@ func (r *ScriptTailService) New(ctx context.Context, scriptName string, body Scr } // Deletes a tail from a Worker. -func (r *ScriptTailService) Delete(ctx context.Context, scriptName string, id string, body ScriptTailDeleteParams, opts ...option.RequestOption) (res *ScriptTailDeleteResponse, err error) { +func (r *ScriptTailService) Delete(ctx context.Context, scriptName string, id string, params ScriptTailDeleteParams, opts ...option.RequestOption) (res *ScriptTailDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env ScriptTailDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails/%s", body.AccountID, scriptName, id) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails/%s", params.AccountID, scriptName, id) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -72,6 +72,48 @@ func (r *ScriptTailService) Get(ctx context.Context, scriptName string, query Sc return } +// A reference to a script that will consume logs from the attached Worker. +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 consumerScriptJSON `json:"-"` +} + +// consumerScriptJSON contains the JSON metadata for the struct [ConsumerScript] +type consumerScriptJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerScript) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerScriptJSON) RawJSON() string { + return r.raw +} + +// A reference to a script that will consume logs from the attached Worker. +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. + Environment param.Field[string] `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace param.Field[string] `json:"namespace"` +} + +func (r ConsumerScriptParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type ScriptTailNewResponse struct { ID interface{} `json:"id"` ExpiresAt interface{} `json:"expires_at"` @@ -99,13 +141,13 @@ func (r scriptTailNewResponseJSON) RawJSON() string { // Union satisfied by [workers.ScriptTailDeleteResponseUnknown], // [workers.ScriptTailDeleteResponseArray] or [shared.UnionString]. -type ScriptTailDeleteResponse interface { - ImplementsWorkersScriptTailDeleteResponse() +type ScriptTailDeleteResponseUnion interface { + ImplementsWorkersScriptTailDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ScriptTailDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*ScriptTailDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -120,7 +162,7 @@ func init() { type ScriptTailDeleteResponseArray []interface{} -func (r ScriptTailDeleteResponseArray) ImplementsWorkersScriptTailDeleteResponse() {} +func (r ScriptTailDeleteResponseArray) ImplementsWorkersScriptTailDeleteResponseUnion() {} type ScriptTailGetResponse struct { ID interface{} `json:"id"` @@ -150,12 +192,17 @@ func (r scriptTailGetResponseJSON) RawJSON() string { type ScriptTailNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ScriptTailNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ScriptTailNewResponseEnvelope struct { - Errors []ScriptTailNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptTailNewResponseEnvelopeMessages `json:"messages,required"` - Result ScriptTailNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptTailNewResponse `json:"result,required"` // Whether the API call was successful Success ScriptTailNewResponseEnvelopeSuccess `json:"success,required"` JSON scriptTailNewResponseEnvelopeJSON `json:"-"` @@ -180,52 +227,6 @@ func (r scriptTailNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptTailNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptTailNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptTailNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptTailNewResponseEnvelopeErrors] -type scriptTailNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptTailNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptTailNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptTailNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptTailNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptTailNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptTailNewResponseEnvelopeMessages] -type scriptTailNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptTailNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptTailNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptTailNewResponseEnvelopeSuccess bool @@ -244,12 +245,17 @@ func (r ScriptTailNewResponseEnvelopeSuccess) IsKnown() bool { type ScriptTailDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r ScriptTailDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type ScriptTailDeleteResponseEnvelope struct { - Errors []ScriptTailDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptTailDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ScriptTailDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptTailDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success ScriptTailDeleteResponseEnvelopeSuccess `json:"success,required"` JSON scriptTailDeleteResponseEnvelopeJSON `json:"-"` @@ -274,52 +280,6 @@ func (r scriptTailDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptTailDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptTailDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptTailDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptTailDeleteResponseEnvelopeErrors] -type scriptTailDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptTailDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptTailDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptTailDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptTailDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptTailDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptTailDeleteResponseEnvelopeMessages] -type scriptTailDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptTailDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptTailDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptTailDeleteResponseEnvelopeSuccess bool @@ -341,9 +301,9 @@ type ScriptTailGetParams struct { } type ScriptTailGetResponseEnvelope struct { - Errors []ScriptTailGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptTailGetResponseEnvelopeMessages `json:"messages,required"` - Result ScriptTailGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptTailGetResponse `json:"result,required"` // Whether the API call was successful Success ScriptTailGetResponseEnvelopeSuccess `json:"success,required"` JSON scriptTailGetResponseEnvelopeJSON `json:"-"` @@ -368,52 +328,6 @@ func (r scriptTailGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ScriptTailGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptTailGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptTailGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptTailGetResponseEnvelopeErrors] -type scriptTailGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptTailGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptTailGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptTailGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptTailGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptTailGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ScriptTailGetResponseEnvelopeMessages] -type scriptTailGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptTailGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptTailGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ScriptTailGetResponseEnvelopeSuccess bool diff --git a/workers/scripttail_test.go b/workers/scripttail_test.go index 2484832c133..42b6671626b 100644 --- a/workers/scripttail_test.go +++ b/workers/scripttail_test.go @@ -33,6 +33,7 @@ func TestScriptTailNew(t *testing.T) { "this-is_my_script-01", workers.ScriptTailNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -64,6 +65,7 @@ func TestScriptTailDelete(t *testing.T) { "03dc9f77817b488fb26c5861ec18f791", workers.ScriptTailDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/workers/scriptusagemodel.go b/workers/scriptusagemodel.go deleted file mode 100644 index da43d4930c9..00000000000 --- a/workers/scriptusagemodel.go +++ /dev/null @@ -1,294 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// ScriptUsageModelService 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 [NewScriptUsageModelService] method -// instead. -type ScriptUsageModelService struct { - Options []option.RequestOption -} - -// NewScriptUsageModelService 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 NewScriptUsageModelService(opts ...option.RequestOption) (r *ScriptUsageModelService) { - r = &ScriptUsageModelService{} - r.Options = opts - return -} - -// Updates the Usage Model for a given Worker. Requires a Workers Paid -// subscription. -func (r *ScriptUsageModelService) Update(ctx context.Context, scriptName string, params ScriptUsageModelUpdateParams, opts ...option.RequestOption) (res *ScriptUsageModelUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ScriptUsageModelUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/usage-model", params.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the Usage Model for a given Worker. -func (r *ScriptUsageModelService) Get(ctx context.Context, scriptName string, query ScriptUsageModelGetParams, opts ...option.RequestOption) (res *ScriptUsageModelGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ScriptUsageModelGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/usage-model", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ScriptUsageModelUpdateResponse struct { - UsageModel interface{} `json:"usage_model"` - JSON scriptUsageModelUpdateResponseJSON `json:"-"` -} - -// scriptUsageModelUpdateResponseJSON contains the JSON metadata for the struct -// [ScriptUsageModelUpdateResponse] -type scriptUsageModelUpdateResponseJSON struct { - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ScriptUsageModelGetResponse struct { - UsageModel interface{} `json:"usage_model"` - JSON scriptUsageModelGetResponseJSON `json:"-"` -} - -// scriptUsageModelGetResponseJSON contains the JSON metadata for the struct -// [ScriptUsageModelGetResponse] -type scriptUsageModelGetResponseJSON struct { - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelGetResponseJSON) RawJSON() string { - return r.raw -} - -type ScriptUsageModelUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[string] `json:"body,required"` -} - -func (r ScriptUsageModelUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ScriptUsageModelUpdateResponseEnvelope struct { - Errors []ScriptUsageModelUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptUsageModelUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ScriptUsageModelUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ScriptUsageModelUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON scriptUsageModelUpdateResponseEnvelopeJSON `json:"-"` -} - -// scriptUsageModelUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [ScriptUsageModelUpdateResponseEnvelope] -type scriptUsageModelUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ScriptUsageModelUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptUsageModelUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptUsageModelUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ScriptUsageModelUpdateResponseEnvelopeErrors] -type scriptUsageModelUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptUsageModelUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptUsageModelUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptUsageModelUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ScriptUsageModelUpdateResponseEnvelopeMessages] -type scriptUsageModelUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ScriptUsageModelUpdateResponseEnvelopeSuccess bool - -const ( - ScriptUsageModelUpdateResponseEnvelopeSuccessTrue ScriptUsageModelUpdateResponseEnvelopeSuccess = true -) - -func (r ScriptUsageModelUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case ScriptUsageModelUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type ScriptUsageModelGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ScriptUsageModelGetResponseEnvelope struct { - Errors []ScriptUsageModelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ScriptUsageModelGetResponseEnvelopeMessages `json:"messages,required"` - Result ScriptUsageModelGetResponse `json:"result,required"` - // Whether the API call was successful - Success ScriptUsageModelGetResponseEnvelopeSuccess `json:"success,required"` - JSON scriptUsageModelGetResponseEnvelopeJSON `json:"-"` -} - -// scriptUsageModelGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ScriptUsageModelGetResponseEnvelope] -type scriptUsageModelGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ScriptUsageModelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptUsageModelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// scriptUsageModelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ScriptUsageModelGetResponseEnvelopeErrors] -type scriptUsageModelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ScriptUsageModelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON scriptUsageModelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// scriptUsageModelGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ScriptUsageModelGetResponseEnvelopeMessages] -type scriptUsageModelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ScriptUsageModelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r scriptUsageModelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ScriptUsageModelGetResponseEnvelopeSuccess bool - -const ( - ScriptUsageModelGetResponseEnvelopeSuccessTrue ScriptUsageModelGetResponseEnvelopeSuccess = true -) - -func (r ScriptUsageModelGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case ScriptUsageModelGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/workers/scriptversion.go b/workers/scriptversion.go new file mode 100644 index 00000000000..88c5434fd2d --- /dev/null +++ b/workers/scriptversion.go @@ -0,0 +1,392 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package workers + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + + "github.com/cloudflare/cloudflare-go/v2/internal/apiform" + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "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" +) + +// ScriptVersionService 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 [NewScriptVersionService] method +// instead. +type ScriptVersionService struct { + Options []option.RequestOption +} + +// NewScriptVersionService 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 NewScriptVersionService(opts ...option.RequestOption) (r *ScriptVersionService) { + r = &ScriptVersionService{} + r.Options = opts + return +} + +// Upload a Worker Version without deploying to Cloudflare's network. +func (r *ScriptVersionService) New(ctx context.Context, scriptName string, params ScriptVersionNewParams, opts ...option.RequestOption) (res *ScriptVersionNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptVersionNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/versions", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List of Worker Versions. The first version in the list is the latest version. +func (r *ScriptVersionService) List(ctx context.Context, scriptName string, query ScriptVersionListParams, opts ...option.RequestOption) (res *ScriptVersionListResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptVersionListResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/versions", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Version Detail +func (r *ScriptVersionService) Get(ctx context.Context, scriptName string, versionID string, query ScriptVersionGetParams, opts ...option.RequestOption) (res *ScriptVersionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptVersionGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/versions/%s", query.AccountID, scriptName, versionID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ScriptVersionNewResponse struct { + Resources interface{} `json:"resources,required"` + ID string `json:"id"` + Metadata interface{} `json:"metadata"` + Number float64 `json:"number"` + JSON scriptVersionNewResponseJSON `json:"-"` +} + +// scriptVersionNewResponseJSON contains the JSON metadata for the struct +// [ScriptVersionNewResponse] +type scriptVersionNewResponseJSON struct { + Resources apijson.Field + ID apijson.Field + Metadata apijson.Field + Number apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptVersionNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptVersionNewResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptVersionListResponse struct { + Items []ScriptVersionListResponseItem `json:"items"` + JSON scriptVersionListResponseJSON `json:"-"` +} + +// scriptVersionListResponseJSON contains the JSON metadata for the struct +// [ScriptVersionListResponse] +type scriptVersionListResponseJSON struct { + Items apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptVersionListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptVersionListResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptVersionListResponseItem struct { + ID string `json:"id"` + Metadata interface{} `json:"metadata"` + Number float64 `json:"number"` + JSON scriptVersionListResponseItemJSON `json:"-"` +} + +// scriptVersionListResponseItemJSON contains the JSON metadata for the struct +// [ScriptVersionListResponseItem] +type scriptVersionListResponseItemJSON struct { + ID apijson.Field + Metadata apijson.Field + Number apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptVersionListResponseItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptVersionListResponseItemJSON) RawJSON() string { + return r.raw +} + +type ScriptVersionGetResponse struct { + Resources interface{} `json:"resources,required"` + ID string `json:"id"` + Metadata interface{} `json:"metadata"` + Number float64 `json:"number"` + JSON scriptVersionGetResponseJSON `json:"-"` +} + +// scriptVersionGetResponseJSON contains the JSON metadata for the struct +// [ScriptVersionGetResponse] +type scriptVersionGetResponseJSON struct { + Resources apijson.Field + ID apijson.Field + Metadata apijson.Field + Number apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptVersionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptVersionGetResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptVersionNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be present + // and referenced in the metadata as `main_module`. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[ScriptVersionNewParamsMetadata] `json:"metadata"` +} + +func (r ScriptVersionNewParams) MarshalMultipart() (data []byte, contentType string, err error) { + buf := bytes.NewBuffer(nil) + writer := multipart.NewWriter(buf) + err = apiform.MarshalRoot(r, writer) + if err != nil { + writer.Close() + return nil, "", err + } + err = writer.Close() + if err != nil { + return nil, "", err + } + return buf.Bytes(), writer.FormDataContentType(), nil +} + +// JSON encoded metadata about the uploaded parts and Worker configuration. +type ScriptVersionNewParamsMetadata struct { + Annotations param.Field[ScriptVersionNewParamsMetadataAnnotations] `json:"annotations"` + // List of bindings available to the worker. + Bindings param.Field[[]interface{}] `json:"bindings"` + // Date indicating targeted support in the Workers runtime. Backwards incompatible + // fixes to the runtime following this date will not affect this Worker. + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Flags that enable or disable certain features in the Workers runtime. Used to + // enable upcoming features or opt in or out of specific changes not included in a + // `compatibility_date`. + CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` + // List of binding types to keep from previous_upload. + KeepBindings param.Field[[]string] `json:"keep_bindings"` + // Name of the part in the multipart request that contains the main module (e.g. + // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. + MainModule param.Field[string] `json:"main_module"` + // Usage model to apply to invocations. + UsageModel param.Field[ScriptVersionNewParamsMetadataUsageModel] `json:"usage_model"` +} + +func (r ScriptVersionNewParamsMetadata) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptVersionNewParamsMetadataAnnotations struct { + // Human-readable message about the version. + WorkersMessage param.Field[string] `json:"workers/message"` + // User-provided identifier for the version. + WorkersTag param.Field[string] `json:"workers/tag"` +} + +func (r ScriptVersionNewParamsMetadataAnnotations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Usage model to apply to invocations. +type ScriptVersionNewParamsMetadataUsageModel string + +const ( + ScriptVersionNewParamsMetadataUsageModelStandard ScriptVersionNewParamsMetadataUsageModel = "standard" +) + +func (r ScriptVersionNewParamsMetadataUsageModel) IsKnown() bool { + switch r { + case ScriptVersionNewParamsMetadataUsageModelStandard: + return true + } + return false +} + +type ScriptVersionNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptVersionNewResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptVersionNewResponseEnvelopeSuccess `json:"success,required"` + JSON scriptVersionNewResponseEnvelopeJSON `json:"-"` +} + +// scriptVersionNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptVersionNewResponseEnvelope] +type scriptVersionNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptVersionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptVersionNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptVersionNewResponseEnvelopeSuccess bool + +const ( + ScriptVersionNewResponseEnvelopeSuccessTrue ScriptVersionNewResponseEnvelopeSuccess = true +) + +func (r ScriptVersionNewResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case ScriptVersionNewResponseEnvelopeSuccessTrue: + return true + } + return false +} + +type ScriptVersionListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptVersionListResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptVersionListResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptVersionListResponseEnvelopeSuccess `json:"success,required"` + JSON scriptVersionListResponseEnvelopeJSON `json:"-"` +} + +// scriptVersionListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptVersionListResponseEnvelope] +type scriptVersionListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptVersionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptVersionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptVersionListResponseEnvelopeSuccess bool + +const ( + ScriptVersionListResponseEnvelopeSuccessTrue ScriptVersionListResponseEnvelopeSuccess = true +) + +func (r ScriptVersionListResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case ScriptVersionListResponseEnvelopeSuccessTrue: + return true + } + return false +} + +type ScriptVersionGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptVersionGetResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ScriptVersionGetResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptVersionGetResponseEnvelopeSuccess `json:"success,required"` + JSON scriptVersionGetResponseEnvelopeJSON `json:"-"` +} + +// scriptVersionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptVersionGetResponseEnvelope] +type scriptVersionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptVersionGetResponseEnvelopeSuccess bool + +const ( + ScriptVersionGetResponseEnvelopeSuccessTrue ScriptVersionGetResponseEnvelopeSuccess = true +) + +func (r ScriptVersionGetResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case ScriptVersionGetResponseEnvelopeSuccessTrue: + return true + } + return false +} diff --git a/workers/filter_test.go b/workers/scriptversion_test.go similarity index 55% rename from workers/filter_test.go rename to workers/scriptversion_test.go index 85a31159c91..1e3f64d3e07 100644 --- a/workers/filter_test.go +++ b/workers/scriptversion_test.go @@ -3,8 +3,10 @@ package workers_test import ( + "bytes" "context" "errors" + "io" "os" "testing" @@ -14,7 +16,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/workers" ) -func TestFilterNew(t *testing.T) { +func TestScriptVersionNewWithOptionalParams(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 { @@ -28,41 +30,28 @@ func TestFilterNew(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Workers.Filters.New(context.TODO(), workers.FilterNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - Pattern: cloudflare.F("example.net/*"), - }) - 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 TestFilterUpdate(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.Workers.Filters.Update( + _, err := client.Workers.Scripts.Versions.New( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - workers.FilterUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - Pattern: cloudflare.F("example.net/*"), + "this-is_my_script-01", + workers.ScriptVersionNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Metadata: cloudflare.F(workers.ScriptVersionNewParamsMetadata{ + Annotations: cloudflare.F(workers.ScriptVersionNewParamsMetadataAnnotations{ + WorkersMessage: cloudflare.F("Fixed worker code."), + WorkersTag: cloudflare.F("string"), + }), + Bindings: cloudflare.F([]interface{}{map[string]interface{}{ + "name": "MY_ENV_VAR", + "text": "my_data", + "type": "plain_text", + }}), + CompatibilityDate: cloudflare.F("2023-07-25"), + CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), + KeepBindings: cloudflare.F([]string{"string", "string", "string"}), + MainModule: cloudflare.F("worker.js"), + UsageModel: cloudflare.F(workers.ScriptVersionNewParamsMetadataUsageModelStandard), + }), }, ) if err != nil { @@ -74,7 +63,7 @@ func TestFilterUpdate(t *testing.T) { } } -func TestFilterList(t *testing.T) { +func TestScriptVersionList(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 { @@ -88,9 +77,13 @@ func TestFilterList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Workers.Filters.List(context.TODO(), workers.FilterListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }) + _, err := client.Workers.Scripts.Versions.List( + context.TODO(), + "this-is_my_script-01", + workers.ScriptVersionListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -100,7 +93,7 @@ func TestFilterList(t *testing.T) { } } -func TestFilterDelete(t *testing.T) { +func TestScriptVersionGet(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 { @@ -114,11 +107,12 @@ func TestFilterDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Workers.Filters.Delete( + _, err := client.Workers.Scripts.Versions.Get( context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - workers.FilterDeleteParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + "this-is_my_script-01", + "bcf48806-b317-4351-9ee7-36e7d557d4de", + workers.ScriptVersionGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { diff --git a/workers/service.go b/workers/service.go deleted file mode 100644 index aa3aad35b58..00000000000 --- a/workers/service.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// ServiceService 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 [NewServiceService] method instead. -type ServiceService struct { - Options []option.RequestOption - Environments *ServiceEnvironmentService -} - -// NewServiceService 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 NewServiceService(opts ...option.RequestOption) (r *ServiceService) { - r = &ServiceService{} - r.Options = opts - r.Environments = NewServiceEnvironmentService(opts...) - return -} diff --git a/workers/serviceenvironment.go b/workers/serviceenvironment.go deleted file mode 100644 index 7dbef3c0421..00000000000 --- a/workers/serviceenvironment.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// ServiceEnvironmentService 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 [NewServiceEnvironmentService] method -// instead. -type ServiceEnvironmentService struct { - Options []option.RequestOption - Content *ServiceEnvironmentContentService - Settings *ServiceEnvironmentSettingService -} - -// NewServiceEnvironmentService 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 NewServiceEnvironmentService(opts ...option.RequestOption) (r *ServiceEnvironmentService) { - r = &ServiceEnvironmentService{} - r.Options = opts - r.Content = NewServiceEnvironmentContentService(opts...) - r.Settings = NewServiceEnvironmentSettingService(opts...) - return -} diff --git a/workers/serviceenvironmentcontent.go b/workers/serviceenvironmentcontent.go deleted file mode 100644 index 7cdbd348d32..00000000000 --- a/workers/serviceenvironmentcontent.go +++ /dev/null @@ -1,198 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "bytes" - "context" - "fmt" - "io" - "mime/multipart" - "net/http" - - "github.com/cloudflare/cloudflare-go/v2/internal/apiform" - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// ServiceEnvironmentContentService 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 -// [NewServiceEnvironmentContentService] method instead. -type ServiceEnvironmentContentService struct { - Options []option.RequestOption -} - -// NewServiceEnvironmentContentService 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 NewServiceEnvironmentContentService(opts ...option.RequestOption) (r *ServiceEnvironmentContentService) { - r = &ServiceEnvironmentContentService{} - r.Options = opts - return -} - -// Put script content from a worker with an environment -func (r *ServiceEnvironmentContentService) Update(ctx context.Context, serviceName string, environmentName string, params ServiceEnvironmentContentUpdateParams, opts ...option.RequestOption) (res *WorkersScript, err error) { - opts = append(r.Options[:], opts...) - var env ServiceEnvironmentContentUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/content", params.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get script content from a worker with an environment -func (r *ServiceEnvironmentContentService) Get(ctx context.Context, serviceName string, environmentName string, query ServiceEnvironmentContentGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/content", query.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -type ServiceEnvironmentContentUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be - // present. This should be referenced either in the metadata as `main_module` - // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` - // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[ServiceEnvironmentContentUpdateParamsMetadata] `json:"metadata"` - CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` - CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` -} - -func (r ServiceEnvironmentContentUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { - buf := bytes.NewBuffer(nil) - writer := multipart.NewWriter(buf) - err = apiform.MarshalRoot(r, writer) - if err != nil { - writer.Close() - return nil, "", err - } - err = writer.Close() - if err != nil { - return nil, "", err - } - return buf.Bytes(), writer.FormDataContentType(), nil -} - -// JSON encoded metadata about the uploaded parts and Worker configuration. -type ServiceEnvironmentContentUpdateParamsMetadata struct { - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` -} - -func (r ServiceEnvironmentContentUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentContentUpdateResponseEnvelope struct { - Errors []ServiceEnvironmentContentUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ServiceEnvironmentContentUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersScript `json:"result,required"` - // Whether the API call was successful - Success ServiceEnvironmentContentUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON serviceEnvironmentContentUpdateResponseEnvelopeJSON `json:"-"` -} - -// serviceEnvironmentContentUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ServiceEnvironmentContentUpdateResponseEnvelope] -type serviceEnvironmentContentUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentContentUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentContentUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentContentUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ServiceEnvironmentContentUpdateResponseEnvelopeErrors] -type serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentContentUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentContentUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ServiceEnvironmentContentUpdateResponseEnvelopeMessages] -type serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentContentUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ServiceEnvironmentContentUpdateResponseEnvelopeSuccess bool - -const ( - ServiceEnvironmentContentUpdateResponseEnvelopeSuccessTrue ServiceEnvironmentContentUpdateResponseEnvelopeSuccess = true -) - -func (r ServiceEnvironmentContentUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case ServiceEnvironmentContentUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type ServiceEnvironmentContentGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workers/serviceenvironmentcontent_test.go b/workers/serviceenvironmentcontent_test.go deleted file mode 100644 index 932618eac22..00000000000 --- a/workers/serviceenvironmentcontent_test.go +++ /dev/null @@ -1,100 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "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/workers" -) - -func TestServiceEnvironmentContentUpdateWithOptionalParams(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.Workers.Services.Environments.Content.Update( - context.TODO(), - "my-worker", - "production", - workers.ServiceEnvironmentContentUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(workers.ServiceEnvironmentContentUpdateParamsMetadata{ - BodyPart: cloudflare.F("worker.js"), - MainModule: cloudflare.F("worker.js"), - }), - CfWorkerBodyPart: cloudflare.F("string"), - CfWorkerMainModulePart: cloudflare.F("string"), - }, - ) - 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 TestServiceEnvironmentContentGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Workers.Services.Environments.Content.Get( - context.TODO(), - "my-worker", - "production", - workers.ServiceEnvironmentContentGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) - 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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/workers/serviceenvironmentsetting.go b/workers/serviceenvironmentsetting.go deleted file mode 100644 index 5add7e94f15..00000000000 --- a/workers/serviceenvironmentsetting.go +++ /dev/null @@ -1,2448 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/tidwall/gjson" -) - -// ServiceEnvironmentSettingService 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 -// [NewServiceEnvironmentSettingService] method instead. -type ServiceEnvironmentSettingService struct { - Options []option.RequestOption -} - -// NewServiceEnvironmentSettingService 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 NewServiceEnvironmentSettingService(opts ...option.RequestOption) (r *ServiceEnvironmentSettingService) { - r = &ServiceEnvironmentSettingService{} - r.Options = opts - return -} - -// Patch script metadata, such as bindings -func (r *ServiceEnvironmentSettingService) Edit(ctx context.Context, serviceName string, environmentName string, params ServiceEnvironmentSettingEditParams, opts ...option.RequestOption) (res *ServiceEnvironmentSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ServiceEnvironmentSettingEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/settings", params.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get script settings from a worker with an environment -func (r *ServiceEnvironmentSettingService) Get(ctx context.Context, serviceName string, environmentName string, query ServiceEnvironmentSettingGetParams, opts ...option.RequestOption) (res *ServiceEnvironmentSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ServiceEnvironmentSettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/settings", query.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ServiceEnvironmentSettingEditResponse struct { - // List of bindings attached to this Worker - Bindings []ServiceEnvironmentSettingEditResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations ServiceEnvironmentSettingEditResponseMigrations `json:"migrations"` - Placement ServiceEnvironmentSettingEditResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []ServiceEnvironmentSettingEditResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON serviceEnvironmentSettingEditResponseJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseJSON contains the JSON metadata for the -// struct [ServiceEnvironmentSettingEditResponse] -type serviceEnvironmentSettingEditResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding], -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding], -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding], -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding], -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding], -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding], -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -// or -// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBinding]. -type ServiceEnvironmentSettingEditResponseBinding interface { - implementsWorkersServiceEnvironmentSettingEditResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ServiceEnvironmentSettingEditResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBinding{}), - }, - ) -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding] -type serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON contains -// the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding] -type serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingTypeService ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType = "service" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON contains the -// JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding] -type serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON contains the -// JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding] -type serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON contains -// the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding] -type serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingTypeQueue ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType = "queue" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON contains the -// JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding] -type serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingTypeD1 ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType = "d1" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -type serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON serviceEnvironmentSettingEditResponseBindingsWorkersMtlscertBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseBindingsWorkersMtlscertBindingJSON contains -// the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBinding] -type serviceEnvironmentSettingEditResponseBindingsWorkersMtlscertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseBindingsWorkersMtlscertBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBindingType string - -const ( - ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [workers.ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations] -// or -// [workers.ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations]. -type ServiceEnvironmentSettingEditResponseMigrations interface { - implementsWorkersServiceEnvironmentSettingEditResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ServiceEnvironmentSettingEditResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations] -type serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkersServiceEnvironmentSettingEditResponseMigrations() { -} - -type ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations] -type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkersServiceEnvironmentSettingEditResponseMigrations() { -} - -type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep] -type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode ServiceEnvironmentSettingEditResponsePlacementMode `json:"mode"` - JSON serviceEnvironmentSettingEditResponsePlacementJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponsePlacementJSON contains the JSON metadata -// for the struct [ServiceEnvironmentSettingEditResponsePlacement] -type serviceEnvironmentSettingEditResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type ServiceEnvironmentSettingEditResponsePlacementMode string - -const ( - ServiceEnvironmentSettingEditResponsePlacementModeSmart ServiceEnvironmentSettingEditResponsePlacementMode = "smart" -) - -func (r ServiceEnvironmentSettingEditResponsePlacementMode) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponsePlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type ServiceEnvironmentSettingEditResponseTailConsumer 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 serviceEnvironmentSettingEditResponseTailConsumerJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseTailConsumerJSON contains the JSON metadata -// for the struct [ServiceEnvironmentSettingEditResponseTailConsumer] -type serviceEnvironmentSettingEditResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponse struct { - // List of bindings attached to this Worker - Bindings []ServiceEnvironmentSettingGetResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations ServiceEnvironmentSettingGetResponseMigrations `json:"migrations"` - Placement ServiceEnvironmentSettingGetResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []ServiceEnvironmentSettingGetResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON serviceEnvironmentSettingGetResponseJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseJSON contains the JSON metadata for the -// struct [ServiceEnvironmentSettingGetResponse] -type serviceEnvironmentSettingGetResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding], -// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding], -// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding], -// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding], -// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding], -// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding], -// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -// or [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBinding]. -type ServiceEnvironmentSettingGetResponseBinding interface { - implementsWorkersServiceEnvironmentSettingGetResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ServiceEnvironmentSettingGetResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBinding{}), - }, - ) -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding] -type serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON contains -// the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding] -type serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingTypeService ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType = "service" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON contains the -// JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding] -type serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON contains the -// JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding] -type serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON contains the -// JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding] -type serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingTypeQueue ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType = "queue" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON contains the -// JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding] -type serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingTypeD1 ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType = "d1" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -type serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON serviceEnvironmentSettingGetResponseBindingsWorkersMtlscertBindingJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseBindingsWorkersMtlscertBindingJSON contains -// the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBinding] -type serviceEnvironmentSettingGetResponseBindingsWorkersMtlscertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseBindingsWorkersMtlscertBindingJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBindingType string - -const ( - ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [workers.ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations] -// or -// [workers.ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations]. -type ServiceEnvironmentSettingGetResponseMigrations interface { - implementsWorkersServiceEnvironmentSettingGetResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ServiceEnvironmentSettingGetResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations] -type serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkersServiceEnvironmentSettingGetResponseMigrations() { -} - -type ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations] -type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkersServiceEnvironmentSettingGetResponseMigrations() { -} - -type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep] -type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode ServiceEnvironmentSettingGetResponsePlacementMode `json:"mode"` - JSON serviceEnvironmentSettingGetResponsePlacementJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponsePlacementJSON contains the JSON metadata for -// the struct [ServiceEnvironmentSettingGetResponsePlacement] -type serviceEnvironmentSettingGetResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type ServiceEnvironmentSettingGetResponsePlacementMode string - -const ( - ServiceEnvironmentSettingGetResponsePlacementModeSmart ServiceEnvironmentSettingGetResponsePlacementMode = "smart" -) - -func (r ServiceEnvironmentSettingGetResponsePlacementMode) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponsePlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type ServiceEnvironmentSettingGetResponseTailConsumer 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 serviceEnvironmentSettingGetResponseTailConsumerJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseTailConsumerJSON contains the JSON metadata -// for the struct [ServiceEnvironmentSettingGetResponseTailConsumer] -type serviceEnvironmentSettingGetResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Errors param.Field[[]ServiceEnvironmentSettingEditParamsError] `json:"errors,required"` - Messages param.Field[[]ServiceEnvironmentSettingEditParamsMessage] `json:"messages,required"` - Result param.Field[ServiceEnvironmentSettingEditParamsResult] `json:"result,required"` - // Whether the API call was successful - Success param.Field[ServiceEnvironmentSettingEditParamsSuccess] `json:"success,required"` -} - -func (r ServiceEnvironmentSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsError struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r ServiceEnvironmentSettingEditParamsError) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsMessage struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r ServiceEnvironmentSettingEditParamsMessage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsResult struct { - // List of bindings attached to this Worker - Bindings param.Field[[]ServiceEnvironmentSettingEditParamsResultBinding] `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[ServiceEnvironmentSettingEditParamsResultMigrations] `json:"migrations"` - Placement param.Field[ServiceEnvironmentSettingEditParamsResultPlacement] `json:"placement"` - // Tags to help you manage your Workers - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]ServiceEnvironmentSettingEditParamsResultTailConsumer] `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel param.Field[string] `json:"usage_model"` -} - -func (r ServiceEnvironmentSettingEditParamsResult) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A binding to allow the Worker to communicate with resources -// -// Satisfied by -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding], -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding], -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding], -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding], -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding], -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding], -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding], -// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBinding]. -type ServiceEnvironmentSettingEditParamsResultBinding interface { - implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding struct { - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment,required"` - // Name of Worker to bind to - Service param.Field[string] `json:"service,required"` - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType] `json:"type,required"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingTypeService ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType = "service" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName param.Field[string] `json:"class_name,required"` - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType] `json:"type,required"` - // The environment of the script_name to bind to - Environment param.Field[string] `json:"environment"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName param.Field[string] `json:"script_name"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName param.Field[string] `json:"bucket_name,required"` - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType] `json:"type,required"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding struct { - // Name of the Queue to bind to - QueueName param.Field[string] `json:"queue_name,required"` - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType] `json:"type,required"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType = "queue" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID param.Field[string] `json:"id,required"` - // The name of the D1 database associated with the 'id' provided. - Name param.Field[string] `json:"name,required"` - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType] `json:"type,required"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingTypeD1 ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType = "d1" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding struct { - // Namespace to bind to - Namespace param.Field[string] `json:"namespace,required"` - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` - // Outbound worker - Outbound param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params param.Field[[]string] `json:"params"` - // Outbound worker - Worker param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Outbound worker -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment param.Field[string] `json:"environment"` - // Name of the outbound worker - Service param.Field[string] `json:"service"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBinding struct { - // The class of resource that the binding provides. - Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBindingType] `json:"type,required"` - // ID of the certificate to bind to - CertificateID param.Field[string] `json:"certificate_id"` -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBindingType string - -const ( - ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBindingTypeMTLSCertificate ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations], -// [workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations]. -type ServiceEnvironmentSettingEditParamsResultMigrations interface { - implementsWorkersServiceEnvironmentSettingEditParamsResultMigrations() -} - -// A single set of migrations to apply. -type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) implementsWorkersServiceEnvironmentSettingEditParamsResultMigrations() { -} - -type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations) implementsWorkersServiceEnvironmentSettingEditParamsResultMigrations() { -} - -type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ServiceEnvironmentSettingEditParamsResultPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[ServiceEnvironmentSettingEditParamsResultPlacementMode] `json:"mode"` -} - -func (r ServiceEnvironmentSettingEditParamsResultPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type ServiceEnvironmentSettingEditParamsResultPlacementMode string - -const ( - ServiceEnvironmentSettingEditParamsResultPlacementModeSmart ServiceEnvironmentSettingEditParamsResultPlacementMode = "smart" -) - -func (r ServiceEnvironmentSettingEditParamsResultPlacementMode) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsResultPlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type ServiceEnvironmentSettingEditParamsResultTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r ServiceEnvironmentSettingEditParamsResultTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether the API call was successful -type ServiceEnvironmentSettingEditParamsSuccess bool - -const ( - ServiceEnvironmentSettingEditParamsSuccessTrue ServiceEnvironmentSettingEditParamsSuccess = true -) - -func (r ServiceEnvironmentSettingEditParamsSuccess) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditParamsSuccessTrue: - return true - } - return false -} - -type ServiceEnvironmentSettingEditResponseEnvelope struct { - Errors []ServiceEnvironmentSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ServiceEnvironmentSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result ServiceEnvironmentSettingEditResponse `json:"result,required"` - // Whether the API call was successful - Success ServiceEnvironmentSettingEditResponseEnvelopeSuccess `json:"success,required"` - JSON serviceEnvironmentSettingEditResponseEnvelopeJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ServiceEnvironmentSettingEditResponseEnvelope] -type serviceEnvironmentSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ServiceEnvironmentSettingEditResponseEnvelopeErrors] -type serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ServiceEnvironmentSettingEditResponseEnvelopeMessages] -type serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ServiceEnvironmentSettingEditResponseEnvelopeSuccess bool - -const ( - ServiceEnvironmentSettingEditResponseEnvelopeSuccessTrue ServiceEnvironmentSettingEditResponseEnvelopeSuccess = true -) - -func (r ServiceEnvironmentSettingEditResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingEditResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type ServiceEnvironmentSettingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ServiceEnvironmentSettingGetResponseEnvelope struct { - Errors []ServiceEnvironmentSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ServiceEnvironmentSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result ServiceEnvironmentSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success ServiceEnvironmentSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON serviceEnvironmentSettingGetResponseEnvelopeJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ServiceEnvironmentSettingGetResponseEnvelope] -type serviceEnvironmentSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ServiceEnvironmentSettingGetResponseEnvelopeErrors] -type serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ServiceEnvironmentSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ServiceEnvironmentSettingGetResponseEnvelopeMessages] -type serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ServiceEnvironmentSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ServiceEnvironmentSettingGetResponseEnvelopeSuccess bool - -const ( - ServiceEnvironmentSettingGetResponseEnvelopeSuccessTrue ServiceEnvironmentSettingGetResponseEnvelopeSuccess = true -) - -func (r ServiceEnvironmentSettingGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case ServiceEnvironmentSettingGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/workers/serviceenvironmentsetting_test.go b/workers/serviceenvironmentsetting_test.go deleted file mode 100644 index e111dc1e03f..00000000000 --- a/workers/serviceenvironmentsetting_test.go +++ /dev/null @@ -1,157 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package workers_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/workers" -) - -func TestServiceEnvironmentSettingEditWithOptionalParams(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.Workers.Services.Environments.Settings.Edit( - context.TODO(), - "my-worker", - "production", - workers.ServiceEnvironmentSettingEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Errors: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsError{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Messages: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsMessage{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Result: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResult{ - Bindings: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultBinding{workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - })}), - CompatibilityDate: cloudflare.F("2022-04-05"), - CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), - Logpush: cloudflare.F(false), - Migrations: cloudflare.F[workers.ServiceEnvironmentSettingEditParamsResultMigrations](workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations(workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - TransferredClasses: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - })), - Placement: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultPlacement{ - Mode: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultPlacementModeSmart), - }), - Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), - TailConsumers: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F("unbound"), - }), - Success: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsSuccessTrue), - }, - ) - 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 TestServiceEnvironmentSettingGet(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.Workers.Services.Environments.Settings.Get( - context.TODO(), - "my-worker", - "production", - workers.ServiceEnvironmentSettingGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) - 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/workers/subdomain.go b/workers/subdomain.go index fd3302e5749..947137a3ea2 100644 --- a/workers/subdomain.go +++ b/workers/subdomain.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -101,7 +102,7 @@ func (r subdomainGetResponseJSON) RawJSON() string { type SubdomainUpdateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[string] `json:"body,required"` + Body string `json:"body,required"` } func (r SubdomainUpdateParams) MarshalJSON() (data []byte, err error) { @@ -109,9 +110,9 @@ func (r SubdomainUpdateParams) MarshalJSON() (data []byte, err error) { } type SubdomainUpdateResponseEnvelope struct { - Errors []SubdomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SubdomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SubdomainUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubdomainUpdateResponse `json:"result,required"` // Whether the API call was successful Success SubdomainUpdateResponseEnvelopeSuccess `json:"success,required"` JSON subdomainUpdateResponseEnvelopeJSON `json:"-"` @@ -136,52 +137,6 @@ func (r subdomainUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubdomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subdomainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// subdomainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubdomainUpdateResponseEnvelopeErrors] -type subdomainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubdomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subdomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubdomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subdomainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// subdomainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubdomainUpdateResponseEnvelopeMessages] -type subdomainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubdomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subdomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubdomainUpdateResponseEnvelopeSuccess bool @@ -203,9 +158,9 @@ type SubdomainGetParams struct { } type SubdomainGetResponseEnvelope struct { - Errors []SubdomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SubdomainGetResponseEnvelopeMessages `json:"messages,required"` - Result SubdomainGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubdomainGetResponse `json:"result,required"` // Whether the API call was successful Success SubdomainGetResponseEnvelopeSuccess `json:"success,required"` JSON subdomainGetResponseEnvelopeJSON `json:"-"` @@ -230,52 +185,6 @@ func (r subdomainGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubdomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subdomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// subdomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SubdomainGetResponseEnvelopeErrors] -type subdomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubdomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subdomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubdomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subdomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// subdomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubdomainGetResponseEnvelopeMessages] -type subdomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubdomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subdomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubdomainGetResponseEnvelopeSuccess bool diff --git a/workers/subdomain_test.go b/workers/subdomain_test.go index f11d0f91c79..f659c744ed5 100644 --- a/workers/subdomain_test.go +++ b/workers/subdomain_test.go @@ -30,7 +30,7 @@ func TestSubdomainUpdate(t *testing.T) { ) _, err := client.Workers.Subdomains.Update(context.TODO(), workers.SubdomainUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F("{'subdomain': 'example-subdomain'}"), + Body: "{'subdomain': 'example-subdomain'}", }) if err != nil { var apierr *cloudflare.Error diff --git a/workers/worker.go b/workers/worker.go index 34ec8ec37f4..23688ec140e 100644 --- a/workers/worker.go +++ b/workers/worker.go @@ -3,7 +3,12 @@ package workers import ( + "reflect" + + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // WorkerService contains methods and other services that help with interacting @@ -14,13 +19,9 @@ type WorkerService struct { Options []option.RequestOption AI *AIService Scripts *ScriptService - Filters *FilterService - Routes *RouteService AccountSettings *AccountSettingService - Deployments *DeploymentService Domains *DomainService Subdomains *SubdomainService - Services *ServiceService } // NewWorkerService generates a new service that applies the given options to each @@ -31,12 +32,1143 @@ func NewWorkerService(opts ...option.RequestOption) (r *WorkerService) { r.Options = opts r.AI = NewAIService(opts...) r.Scripts = NewScriptService(opts...) - r.Filters = NewFilterService(opts...) - r.Routes = NewRouteService(opts...) r.AccountSettings = NewAccountSettingService(opts...) - r.Deployments = NewDeploymentService(opts...) r.Domains = NewDomainService(opts...) r.Subdomains = NewSubdomainService(opts...) - r.Services = NewServiceService(opts...) return } + +// A binding to allow the Worker to communicate with resources +type Binding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The class of resource that the binding provides. + Type BindingType `json:"type,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Name of Worker to bind to + Service string `json:"service"` + // The exported class name of the Durable Object + ClassName string `json:"class_name"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + // R2 bucket to bind to + BucketName string `json:"bucket_name"` + // Name of the Queue to bind to + QueueName string `json:"queue_name"` + // A JavaScript variable name for the binding. + Binding string `json:"binding"` + // ID of the D1 database to bind to + ID string `json:"id"` + // Namespace to bind to + Namespace string `json:"namespace"` + Outbound interface{} `json:"outbound,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + Certificate interface{} `json:"certificate,required"` + JSON bindingJSON `json:"-"` + union BindingUnion +} + +// bindingJSON contains the JSON metadata for the struct [Binding] +type bindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + Environment apijson.Field + Service apijson.Field + ClassName apijson.Field + ScriptName apijson.Field + BucketName apijson.Field + QueueName apijson.Field + Binding apijson.Field + ID apijson.Field + Namespace apijson.Field + Outbound apijson.Field + CertificateID apijson.Field + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r bindingJSON) RawJSON() string { + return r.raw +} + +func (r *Binding) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r Binding) AsUnion() BindingUnion { + return r.union +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by [workers.KVNamespaceBinding], [workers.ServiceBinding], +// [workers.DurableObjectBinding], [workers.R2Binding], +// [workers.BindingWorkersQueueBinding], [workers.D1Binding], +// [workers.DispatchNamespaceBinding] or [workers.MTLSCERTBinding]. +type BindingUnion interface { + implementsWorkersBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*BindingUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(KVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DurableObjectBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(R2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BindingWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(D1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(MTLSCERTBinding{}), + }, + ) +} + +type BindingWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type BindingWorkersQueueBindingType `json:"type,required"` + JSON bindingWorkersQueueBindingJSON `json:"-"` +} + +// bindingWorkersQueueBindingJSON contains the JSON metadata for the struct +// [BindingWorkersQueueBinding] +type bindingWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BindingWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bindingWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r BindingWorkersQueueBinding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type BindingWorkersQueueBindingType string + +const ( + BindingWorkersQueueBindingTypeQueue BindingWorkersQueueBindingType = "queue" +) + +func (r BindingWorkersQueueBindingType) IsKnown() bool { + switch r { + case BindingWorkersQueueBindingTypeQueue: + return true + } + return false +} + +// The class of resource that the binding provides. +type BindingType string + +const ( + BindingTypeKVNamespace BindingType = "kv_namespace" + BindingTypeService BindingType = "service" + BindingTypeDurableObjectNamespace BindingType = "durable_object_namespace" + BindingTypeR2Bucket BindingType = "r2_bucket" + BindingTypeQueue BindingType = "queue" + BindingTypeD1 BindingType = "d1" + BindingTypeDispatchNamespace BindingType = "dispatch_namespace" + BindingTypeMTLSCertificate BindingType = "mtls_certificate" +) + +func (r BindingType) IsKnown() bool { + switch r { + case BindingTypeKVNamespace, BindingTypeService, BindingTypeDurableObjectNamespace, BindingTypeR2Bucket, BindingTypeQueue, BindingTypeD1, BindingTypeDispatchNamespace, BindingTypeMTLSCertificate: + return true + } + return false +} + +// A binding to allow the Worker to communicate with resources +type BindingParam struct { + // The class of resource that the binding provides. + Type param.Field[BindingType] `json:"type,required"` + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment"` + // Name of Worker to bind to + Service param.Field[string] `json:"service"` + // The exported class name of the Durable Object + ClassName param.Field[string] `json:"class_name"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName param.Field[string] `json:"script_name"` + // R2 bucket to bind to + BucketName param.Field[string] `json:"bucket_name"` + // Name of the Queue to bind to + QueueName param.Field[string] `json:"queue_name"` + // ID of the D1 database to bind to + ID param.Field[string] `json:"id"` + // Namespace to bind to + Namespace param.Field[string] `json:"namespace"` + Outbound param.Field[interface{}] `json:"outbound,required"` + // ID of the certificate to bind to + CertificateID param.Field[string] `json:"certificate_id"` + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r BindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r BindingParam) implementsWorkersBindingUnionParam() {} + +// A binding to allow the Worker to communicate with resources +// +// Satisfied by [workers.KVNamespaceBindingParam], [workers.ServiceBindingParam], +// [workers.DurableObjectBindingParam], [workers.R2BindingParam], +// [workers.BindingWorkersQueueBindingParam], [workers.D1BindingParam], +// [workers.DispatchNamespaceBindingParam], [workers.MTLSCERTBindingParam], +// [BindingParam]. +type BindingUnionParam interface { + implementsWorkersBindingUnionParam() +} + +type BindingWorkersQueueBindingParam struct { + // Name of the Queue to bind to + QueueName param.Field[string] `json:"queue_name,required"` + // The class of resource that the binding provides. + Type param.Field[BindingWorkersQueueBindingType] `json:"type,required"` +} + +func (r BindingWorkersQueueBindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r BindingWorkersQueueBindingParam) implementsWorkersBindingUnionParam() {} + +type D1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type D1BindingType `json:"type,required"` + JSON d1BindingJSON `json:"-"` +} + +// d1BindingJSON contains the JSON metadata for the struct [D1Binding] +type d1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *D1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r d1BindingJSON) RawJSON() string { + return r.raw +} + +func (r D1Binding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type D1BindingType string + +const ( + D1BindingTypeD1 D1BindingType = "d1" +) + +func (r D1BindingType) IsKnown() bool { + switch r { + case D1BindingTypeD1: + return true + } + return false +} + +type D1BindingParam struct { + // ID of the D1 database to bind to + ID param.Field[string] `json:"id,required"` + // The name of the D1 database associated with the 'id' provided. + Name param.Field[string] `json:"name,required"` + // The class of resource that the binding provides. + Type param.Field[D1BindingType] `json:"type,required"` +} + +func (r D1BindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r D1BindingParam) implementsWorkersBindingUnionParam() {} + +type DispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound DispatchNamespaceBindingOutbound `json:"outbound"` + JSON dispatchNamespaceBindingJSON `json:"-"` +} + +// dispatchNamespaceBindingJSON contains the JSON metadata for the struct +// [DispatchNamespaceBinding] +type dispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceBinding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type DispatchNamespaceBindingType string + +const ( + DispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceBindingType = "dispatch_namespace" +) + +func (r DispatchNamespaceBindingType) IsKnown() bool { + switch r { + case DispatchNamespaceBindingTypeDispatchNamespace: + return true + } + return false +} + +// Outbound worker +type DispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker DispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON dispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// dispatchNamespaceBindingOutboundJSON contains the JSON metadata for the struct +// [DispatchNamespaceBindingOutbound] +type dispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type DispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON dispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// dispatchNamespaceBindingOutboundWorkerJSON contains the JSON metadata for the +// struct [DispatchNamespaceBindingOutboundWorker] +type dispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceBindingParam struct { + // Namespace to bind to + Namespace param.Field[string] `json:"namespace,required"` + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceBindingType] `json:"type,required"` + // Outbound worker + Outbound param.Field[DispatchNamespaceBindingOutboundParam] `json:"outbound"` +} + +func (r DispatchNamespaceBindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceBindingParam) implementsWorkersBindingUnionParam() {} + +// Outbound worker +type DispatchNamespaceBindingOutboundParam struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params param.Field[[]string] `json:"params"` + // Outbound worker + Worker param.Field[DispatchNamespaceBindingOutboundWorkerParam] `json:"worker"` +} + +func (r DispatchNamespaceBindingOutboundParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Outbound worker +type DispatchNamespaceBindingOutboundWorkerParam struct { + // Environment of the outbound worker + Environment param.Field[string] `json:"environment"` + // Name of the outbound worker + Service param.Field[string] `json:"service"` +} + +func (r DispatchNamespaceBindingOutboundWorkerParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DurableObjectBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DurableObjectBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON durableObjectBindingJSON `json:"-"` +} + +// durableObjectBindingJSON contains the JSON metadata for the struct +// [DurableObjectBinding] +type durableObjectBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DurableObjectBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r durableObjectBindingJSON) RawJSON() string { + return r.raw +} + +func (r DurableObjectBinding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type DurableObjectBindingType string + +const ( + DurableObjectBindingTypeDurableObjectNamespace DurableObjectBindingType = "durable_object_namespace" +) + +func (r DurableObjectBindingType) IsKnown() bool { + switch r { + case DurableObjectBindingTypeDurableObjectNamespace: + return true + } + return false +} + +type DurableObjectBindingParam struct { + // The exported class name of the Durable Object + ClassName param.Field[string] `json:"class_name,required"` + // The class of resource that the binding provides. + Type param.Field[DurableObjectBindingType] `json:"type,required"` + // The environment of the script_name to bind to + Environment param.Field[string] `json:"environment"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName param.Field[string] `json:"script_name"` +} + +func (r DurableObjectBindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DurableObjectBindingParam) implementsWorkersBindingUnionParam() {} + +type KVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type KVNamespaceBindingType `json:"type,required"` + JSON kvNamespaceBindingJSON `json:"-"` +} + +// kvNamespaceBindingJSON contains the JSON metadata for the struct +// [KVNamespaceBinding] +type kvNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r kvNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r KVNamespaceBinding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type KVNamespaceBindingType string + +const ( + KVNamespaceBindingTypeKVNamespace KVNamespaceBindingType = "kv_namespace" +) + +func (r KVNamespaceBindingType) IsKnown() bool { + switch r { + case KVNamespaceBindingTypeKVNamespace: + return true + } + return false +} + +type KVNamespaceBindingParam struct { + // The class of resource that the binding provides. + Type param.Field[KVNamespaceBindingType] `json:"type,required"` +} + +func (r KVNamespaceBindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r KVNamespaceBindingParam) implementsWorkersBindingUnionParam() {} + +type MigrationStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []MigrationStepRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []MigrationStepTransferredClass `json:"transferred_classes"` + JSON migrationStepJSON `json:"-"` +} + +// migrationStepJSON contains the JSON metadata for the struct [MigrationStep] +type migrationStepJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MigrationStep) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r migrationStepJSON) RawJSON() string { + return r.raw +} + +type MigrationStepRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON migrationStepRenamedClassJSON `json:"-"` +} + +// migrationStepRenamedClassJSON contains the JSON metadata for the struct +// [MigrationStepRenamedClass] +type migrationStepRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MigrationStepRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r migrationStepRenamedClassJSON) RawJSON() string { + return r.raw +} + +type MigrationStepTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON migrationStepTransferredClassJSON `json:"-"` +} + +// migrationStepTransferredClassJSON contains the JSON metadata for the struct +// [MigrationStepTransferredClass] +type migrationStepTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MigrationStepTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r migrationStepTransferredClassJSON) RawJSON() string { + return r.raw +} + +type MigrationStepParam struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]MigrationStepRenamedClassParam] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]MigrationStepTransferredClassParam] `json:"transferred_classes"` +} + +func (r MigrationStepParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MigrationStepRenamedClassParam struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r MigrationStepRenamedClassParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MigrationStepTransferredClassParam struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r MigrationStepTransferredClassParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MTLSCERTBinding struct { + Certificate interface{} `json:"certificate,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type MTLSCERTBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON mtlscertBindingJSON `json:"-"` +} + +// mtlscertBindingJSON contains the JSON metadata for the struct [MTLSCERTBinding] +type mtlscertBindingJSON struct { + Certificate apijson.Field + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r mtlscertBindingJSON) RawJSON() string { + return r.raw +} + +func (r MTLSCERTBinding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type MTLSCERTBindingType string + +const ( + MTLSCERTBindingTypeMTLSCertificate MTLSCERTBindingType = "mtls_certificate" +) + +func (r MTLSCERTBindingType) IsKnown() bool { + switch r { + case MTLSCERTBindingTypeMTLSCertificate: + return true + } + return false +} + +type MTLSCERTBindingParam struct { + Certificate param.Field[interface{}] `json:"certificate,required"` + // The class of resource that the binding provides. + Type param.Field[MTLSCERTBindingType] `json:"type,required"` + // ID of the certificate to bind to + CertificateID param.Field[string] `json:"certificate_id"` +} + +func (r MTLSCERTBindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r MTLSCERTBindingParam) implementsWorkersBindingUnionParam() {} + +type PlacementConfiguration struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode PlacementConfigurationMode `json:"mode"` + JSON placementConfigurationJSON `json:"-"` +} + +// placementConfigurationJSON contains the JSON metadata for the struct +// [PlacementConfiguration] +type placementConfigurationJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PlacementConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r placementConfigurationJSON) RawJSON() string { + return r.raw +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type PlacementConfigurationMode string + +const ( + PlacementConfigurationModeSmart PlacementConfigurationMode = "smart" +) + +func (r PlacementConfigurationMode) IsKnown() bool { + switch r { + case PlacementConfigurationModeSmart: + return true + } + return false +} + +type PlacementConfigurationParam struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode param.Field[PlacementConfigurationMode] `json:"mode"` +} + +func (r PlacementConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type R2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type R2BindingType `json:"type,required"` + JSON r2BindingJSON `json:"-"` +} + +// r2BindingJSON contains the JSON metadata for the struct [R2Binding] +type r2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2BindingJSON) RawJSON() string { + return r.raw +} + +func (r R2Binding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type R2BindingType string + +const ( + R2BindingTypeR2Bucket R2BindingType = "r2_bucket" +) + +func (r R2BindingType) IsKnown() bool { + switch r { + case R2BindingTypeR2Bucket: + return true + } + return false +} + +type R2BindingParam struct { + // R2 bucket to bind to + BucketName param.Field[string] `json:"bucket_name,required"` + // The class of resource that the binding provides. + Type param.Field[R2BindingType] `json:"type,required"` +} + +func (r R2BindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r R2BindingParam) implementsWorkersBindingUnionParam() {} + +type ServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type ServiceBindingType `json:"type,required"` + JSON serviceBindingJSON `json:"-"` +} + +// serviceBindingJSON contains the JSON metadata for the struct [ServiceBinding] +type serviceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceBinding) implementsWorkersBinding() {} + +// The class of resource that the binding provides. +type ServiceBindingType string + +const ( + ServiceBindingTypeService ServiceBindingType = "service" +) + +func (r ServiceBindingType) IsKnown() bool { + switch r { + case ServiceBindingTypeService: + return true + } + return false +} + +type ServiceBindingParam struct { + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment,required"` + // Name of Worker to bind to + Service param.Field[string] `json:"service,required"` + // The class of resource that the binding provides. + Type param.Field[ServiceBindingType] `json:"type,required"` +} + +func (r ServiceBindingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceBindingParam) implementsWorkersBindingUnionParam() {} + +// A single set of migrations to apply. +type SingleStepMigration struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []SingleStepMigrationRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []SingleStepMigrationTransferredClass `json:"transferred_classes"` + JSON singleStepMigrationJSON `json:"-"` +} + +// singleStepMigrationJSON contains the JSON metadata for the struct +// [SingleStepMigration] +type singleStepMigrationJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + NewTag apijson.Field + OldTag apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SingleStepMigration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r singleStepMigrationJSON) RawJSON() string { + return r.raw +} + +func (r SingleStepMigration) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseMigrations() { +} + +func (r SingleStepMigration) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseMigrations() { +} + +type SingleStepMigrationRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON singleStepMigrationRenamedClassJSON `json:"-"` +} + +// singleStepMigrationRenamedClassJSON contains the JSON metadata for the struct +// [SingleStepMigrationRenamedClass] +type singleStepMigrationRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SingleStepMigrationRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r singleStepMigrationRenamedClassJSON) RawJSON() string { + return r.raw +} + +type SingleStepMigrationTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON singleStepMigrationTransferredClassJSON `json:"-"` +} + +// singleStepMigrationTransferredClassJSON contains the JSON metadata for the +// struct [SingleStepMigrationTransferredClass] +type singleStepMigrationTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SingleStepMigrationTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r singleStepMigrationTransferredClassJSON) RawJSON() string { + return r.raw +} + +// A single set of migrations to apply. +type SingleStepMigrationParam struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]SingleStepMigrationRenamedClassParam] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]SingleStepMigrationTransferredClassParam] `json:"transferred_classes"` +} + +func (r SingleStepMigrationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SingleStepMigrationParam) implementsWorkersScriptUpdateParamsBodyObjectMetadataMigrationsUnion() { +} + +func (r SingleStepMigrationParam) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrationsUnion() { +} + +func (r SingleStepMigrationParam) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsSettingsMigrationsUnion() { +} + +type SingleStepMigrationRenamedClassParam struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r SingleStepMigrationRenamedClassParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SingleStepMigrationTransferredClassParam struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r SingleStepMigrationTransferredClassParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SteppedMigration struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // Migrations to apply in order. + Steps []MigrationStep `json:"steps"` + JSON steppedMigrationJSON `json:"-"` +} + +// steppedMigrationJSON contains the JSON metadata for the struct +// [SteppedMigration] +type steppedMigrationJSON struct { + NewTag apijson.Field + OldTag apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SteppedMigration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r steppedMigrationJSON) RawJSON() string { + return r.raw +} + +func (r SteppedMigration) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseMigrations() { +} + +func (r SteppedMigration) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseMigrations() { +} + +type SteppedMigrationParam struct { + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // Migrations to apply in order. + Steps param.Field[[]MigrationStepParam] `json:"steps"` +} + +func (r SteppedMigrationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SteppedMigrationParam) implementsWorkersScriptUpdateParamsBodyObjectMetadataMigrationsUnion() { +} + +func (r SteppedMigrationParam) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrationsUnion() { +} + +func (r SteppedMigrationParam) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsSettingsMigrationsUnion() { +} + +// JSON encoded metadata about the uploaded parts and Worker configuration. +type WorkerMetadataParam struct { + // Name of the part in the multipart request that contains the script (e.g. the + // file adding a listener to the `fetch` event). Indicates a + // `service worker syntax` Worker. + BodyPart param.Field[string] `json:"body_part"` + // Name of the part in the multipart request that contains the main module (e.g. + // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. + MainModule param.Field[string] `json:"main_module"` +} + +func (r WorkerMetadataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} diff --git a/workers_for_platforms/aliases.go b/workers_for_platforms/aliases.go index 25b4efbdd43..ffdf71b240b 100644 --- a/workers_for_platforms/aliases.go +++ b/workers_for_platforms/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/workers_for_platforms/dispatchnamespace.go b/workers_for_platforms/dispatchnamespace.go index 4e07c18c6d3..70cd3343add 100644 --- a/workers_for_platforms/dispatchnamespace.go +++ b/workers_for_platforms/dispatchnamespace.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -84,7 +85,7 @@ func (r *DispatchNamespaceService) Delete(ctx context.Context, dispatchNamespace return } -// Fetch a Workers for Platforms namespace. +// Get a Workers for Platforms namespace. func (r *DispatchNamespaceService) Get(ctx context.Context, dispatchNamespace string, query DispatchNamespaceGetParams, opts ...option.RequestOption) (res *DispatchNamespaceGetResponse, err error) { opts = append(r.Options[:], opts...) var env DispatchNamespaceGetResponseEnvelope @@ -231,9 +232,9 @@ func (r DispatchNamespaceNewParams) MarshalJSON() (data []byte, err error) { } type DispatchNamespaceNewResponseEnvelope struct { - Errors []DispatchNamespaceNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceNewResponseEnvelopeMessages `json:"messages,required"` - Result DispatchNamespaceNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DispatchNamespaceNewResponse `json:"result,required"` // Whether the API call was successful Success DispatchNamespaceNewResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceNewResponseEnvelopeJSON `json:"-"` @@ -258,52 +259,6 @@ func (r dispatchNamespaceNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DispatchNamespaceNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DispatchNamespaceNewResponseEnvelopeErrors] -type dispatchNamespaceNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DispatchNamespaceNewResponseEnvelopeMessages] -type dispatchNamespaceNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceNewResponseEnvelopeSuccess bool @@ -330,9 +285,9 @@ type DispatchNamespaceDeleteParams struct { } type DispatchNamespaceDeleteResponseEnvelope struct { - Errors []DispatchNamespaceDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DispatchNamespaceDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DispatchNamespaceDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful Success DispatchNamespaceDeleteResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceDeleteResponseEnvelopeJSON `json:"-"` @@ -357,52 +312,6 @@ func (r dispatchNamespaceDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DispatchNamespaceDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DispatchNamespaceDeleteResponseEnvelopeErrors] -type dispatchNamespaceDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DispatchNamespaceDeleteResponseEnvelopeMessages] -type dispatchNamespaceDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceDeleteResponseEnvelopeSuccess bool @@ -424,9 +333,9 @@ type DispatchNamespaceGetParams struct { } type DispatchNamespaceGetResponseEnvelope struct { - Errors []DispatchNamespaceGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceGetResponseEnvelopeMessages `json:"messages,required"` - Result DispatchNamespaceGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DispatchNamespaceGetResponse `json:"result,required"` // Whether the API call was successful Success DispatchNamespaceGetResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceGetResponseEnvelopeJSON `json:"-"` @@ -451,52 +360,6 @@ func (r dispatchNamespaceGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DispatchNamespaceGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DispatchNamespaceGetResponseEnvelopeErrors] -type dispatchNamespaceGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DispatchNamespaceGetResponseEnvelopeMessages] -type dispatchNamespaceGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceGetResponseEnvelopeSuccess bool diff --git a/workers_for_platforms/dispatchnamespacescript.go b/workers_for_platforms/dispatchnamespacescript.go index fea031d6efa..d80c3ada18c 100644 --- a/workers_for_platforms/dispatchnamespacescript.go +++ b/workers_for_platforms/dispatchnamespacescript.go @@ -17,6 +17,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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/cloudflare/cloudflare-go/v2/workers" ) @@ -31,6 +32,8 @@ type DispatchNamespaceScriptService struct { Content *DispatchNamespaceScriptContentService Settings *DispatchNamespaceScriptSettingService Bindings *DispatchNamespaceScriptBindingService + Secrets *DispatchNamespaceScriptSecretService + Tags *DispatchNamespaceScriptTagService } // NewDispatchNamespaceScriptService generates a new service that applies the given @@ -42,14 +45,18 @@ func NewDispatchNamespaceScriptService(opts ...option.RequestOption) (r *Dispatc r.Content = NewDispatchNamespaceScriptContentService(opts...) r.Settings = NewDispatchNamespaceScriptSettingService(opts...) r.Bindings = NewDispatchNamespaceScriptBindingService(opts...) + r.Secrets = NewDispatchNamespaceScriptSecretService(opts...) + r.Tags = NewDispatchNamespaceScriptTagService(opts...) return } -// Upload a worker module to a Workers for Platforms namespace. -func (r *DispatchNamespaceScriptService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptUpdateParams, opts ...option.RequestOption) (res *workers.WorkersScript, err error) { +// Upload a worker module to a Workers for Platforms namespace. You can find an +// example of the metadata on our docs: +// https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/reference/metadata/ +func (r *DispatchNamespaceScriptService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptUpdateParams, opts ...option.RequestOption) (res *workers.Script, err error) { opts = append(r.Options[:], opts...) var env DispatchNamespaceScriptUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", params.getAccountID(), dispatchNamespace, scriptName) + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", params.AccountID, dispatchNamespace, scriptName) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) if err != nil { return @@ -69,7 +76,7 @@ func (r *DispatchNamespaceScriptService) Delete(ctx context.Context, dispatchNam } // Fetch information about a script uploaded to a Workers for Platforms namespace. -func (r *DispatchNamespaceScriptService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptGetParams, opts ...option.RequestOption) (res *WorkersForPlatformsNamespaceScript, err error) { +func (r *DispatchNamespaceScriptService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptGetParams, opts ...option.RequestOption) (res *Script, err error) { opts = append(r.Options[:], opts...) var env DispatchNamespaceScriptGetResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", query.AccountID, dispatchNamespace, scriptName) @@ -82,20 +89,19 @@ func (r *DispatchNamespaceScriptService) Get(ctx context.Context, dispatchNamesp } // Details about a worker uploaded to a Workers for Platforms namespace. -type WorkersForPlatformsNamespaceScript struct { +type Script struct { // When the script was created. CreatedOn time.Time `json:"created_on" format:"date-time"` // Name of the Workers for Platforms dispatch namespace. DispatchNamespace string `json:"dispatch_namespace"` // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - Script workers.WorkersScript `json:"script"` - JSON workersForPlatformsNamespaceScriptJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + Script workers.Script `json:"script"` + JSON scriptJSON `json:"-"` } -// workersForPlatformsNamespaceScriptJSON contains the JSON metadata for the struct -// [WorkersForPlatformsNamespaceScript] -type workersForPlatformsNamespaceScriptJSON struct { +// scriptJSON contains the JSON metadata for the struct [Script] +type scriptJSON struct { CreatedOn apijson.Field DispatchNamespace apijson.Field ModifiedOn apijson.Field @@ -104,35 +110,21 @@ type workersForPlatformsNamespaceScriptJSON struct { ExtraFields map[string]apijson.Field } -func (r *WorkersForPlatformsNamespaceScript) UnmarshalJSON(data []byte) (err error) { +func (r *Script) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r workersForPlatformsNamespaceScriptJSON) RawJSON() string { +func (r scriptJSON) RawJSON() string { return r.raw } -// This interface is a union satisfied by one of the following: -// [DispatchNamespaceScriptUpdateParamsVariant0], -// [DispatchNamespaceScriptUpdateParamsVariant1]. -type DispatchNamespaceScriptUpdateParams interface { - ImplementsDispatchNamespaceScriptUpdateParams() - - getAccountID() param.Field[string] -} - -type DispatchNamespaceScriptUpdateParamsVariant0 struct { +type DispatchNamespaceScriptUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be present - // and referenced in the metadata as `main_module` or `body_part` by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[DispatchNamespaceScriptUpdateParamsVariant0Metadata] `json:"metadata"` + AccountID param.Field[string] `path:"account_id,required"` + Body DispatchNamespaceScriptUpdateParamsBodyUnion `json:"body,required"` } -func (r DispatchNamespaceScriptUpdateParamsVariant0) MarshalMultipart() (data []byte, contentType string, err error) { +func (r DispatchNamespaceScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { buf := bytes.NewBuffer(nil) writer := multipart.NewWriter(buf) err = apiform.MarshalRoot(r, writer) @@ -147,16 +139,49 @@ func (r DispatchNamespaceScriptUpdateParamsVariant0) MarshalMultipart() (data [] return buf.Bytes(), writer.FormDataContentType(), nil } -func (r DispatchNamespaceScriptUpdateParamsVariant0) getAccountID() param.Field[string] { - return r.AccountID +type DispatchNamespaceScriptUpdateParamsBody struct { + AnyPartName param.Field[interface{}] `json:",required"` + Metadata param.Field[interface{}] `json:"metadata,required"` + // Rollback message to be associated with this deployment. Only parsed when query + // param `"rollback_to"` is present. + Message param.Field[string] `json:"message"` +} + +func (r DispatchNamespaceScriptUpdateParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (DispatchNamespaceScriptUpdateParamsVariant0) ImplementsDispatchNamespaceScriptUpdateParams() { +func (r DispatchNamespaceScriptUpdateParamsBody) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsBodyUnion() { +} +// Satisfied by +// [workers_for_platforms.DispatchNamespaceScriptUpdateParamsBodyObject], +// [workers_for_platforms.DispatchNamespaceScriptUpdateParamsBodyObject], +// [DispatchNamespaceScriptUpdateParamsBody]. +type DispatchNamespaceScriptUpdateParamsBodyUnion interface { + implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsBodyUnion() +} + +type DispatchNamespaceScriptUpdateParamsBodyObject struct { + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be present + // and referenced in the metadata as `main_module` or `body_part` by part name. + // Source maps may also be included using the `application/source-map` content + // type. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[DispatchNamespaceScriptUpdateParamsBodyObjectMetadata] `json:"metadata"` +} + +func (r DispatchNamespaceScriptUpdateParamsBodyObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptUpdateParamsBodyObject) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsBodyUnion() { } // JSON encoded metadata about the uploaded parts and Worker configuration. -type DispatchNamespaceScriptUpdateParamsVariant0Metadata struct { +type DispatchNamespaceScriptUpdateParamsBodyObjectMetadata struct { // List of bindings available to the worker. Bindings param.Field[[]interface{}] `json:"bindings"` // Name of the part in the multipart request that contains the script (e.g. the @@ -178,209 +203,72 @@ type DispatchNamespaceScriptUpdateParamsVariant0Metadata struct { // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. MainModule param.Field[string] `json:"main_module"` // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrations] `json:"migrations"` - Placement param.Field[DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacement] `json:"placement"` + Migrations param.Field[DispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrationsUnion] `json:"migrations"` + Placement param.Field[workers.PlacementConfigurationParam] `json:"placement"` // 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[[]DispatchNamespaceScriptUpdateParamsVariant0MetadataTailConsumer] `json:"tail_consumers"` + TailConsumers param.Field[[]workers.ConsumerScriptParam] `json:"tail_consumers"` // Usage model to apply to invocations. - UsageModel param.Field[DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModel] `json:"usage_model"` + UsageModel param.Field[DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModel] `json:"usage_model"` // Key-value pairs to use as tags for this version of this Worker VersionTags param.Field[interface{}] `json:"version_tags"` } -func (r DispatchNamespaceScriptUpdateParamsVariant0Metadata) MarshalJSON() (data []byte, err error) { +func (r DispatchNamespaceScriptUpdateParamsBodyObjectMetadata) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations], -// [workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations]. -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrations interface { - implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsVariant0MetadataMigrations() -} - -// A single set of migrations to apply. -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` +type DispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrations struct { // Tag to set as the latest migration tag. NewTag param.Field[string] `json:"new_tag"` // Tag used to verify against the latest migration tag for this Worker. If they // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsVariant0MetadataMigrations() { -} - -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` + OldTag param.Field[string] `json:"old_tag"` + DeletedClasses param.Field[interface{}] `json:"deleted_classes,required"` + NewClasses param.Field[interface{}] `json:"new_classes,required"` + RenamedClasses param.Field[interface{}] `json:"renamed_classes,required"` + TransferredClasses param.Field[interface{}] `json:"transferred_classes,required"` + Steps param.Field[interface{}] `json:"steps,required"` } -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { +func (r DispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrations) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` +func (r DispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrationsUnion() { } -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsVariant0MetadataMigrations() { -} - -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacementMode] `json:"mode"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacementMode string - -const ( - DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacementModeSmart DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacementMode = "smart" -) - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacementMode) IsKnown() bool { - switch r { - case DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type DispatchNamespaceScriptUpdateParamsVariant0MetadataTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by [workers.SingleStepMigrationParam], +// [workers.SteppedMigrationParam], +// [DispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrations]. +type DispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrationsUnion interface { + implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrationsUnion() } // Usage model to apply to invocations. -type DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModel string +type DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModel string const ( - DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModelBundled DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModel = "bundled" - DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModelUnbound DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModel = "unbound" + DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModelBundled DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModel = "bundled" + DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModelUnbound DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModel = "unbound" ) -func (r DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModel) IsKnown() bool { +func (r DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModel) IsKnown() bool { switch r { - case DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModelBundled, DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModelUnbound: + case DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModelBundled, DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModelUnbound: return true } return false } -type DispatchNamespaceScriptUpdateParamsVariant1 struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Rollback message to be associated with this deployment. Only parsed when query - // param `"rollback_to"` is present. - Message param.Field[string] `json:"message"` -} - -func (r DispatchNamespaceScriptUpdateParamsVariant1) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptUpdateParamsVariant1) getAccountID() param.Field[string] { - return r.AccountID -} - -func (DispatchNamespaceScriptUpdateParamsVariant1) ImplementsDispatchNamespaceScriptUpdateParams() { - -} - type DispatchNamespaceScriptUpdateResponseEnvelope struct { - Errors []DispatchNamespaceScriptUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceScriptUpdateResponseEnvelopeMessages `json:"messages,required"` - Result workers.WorkersScript `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result workers.Script `json:"result,required"` // Whether the API call was successful Success DispatchNamespaceScriptUpdateResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceScriptUpdateResponseEnvelopeJSON `json:"-"` @@ -405,52 +293,6 @@ func (r dispatchNamespaceScriptUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DispatchNamespaceScriptUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DispatchNamespaceScriptUpdateResponseEnvelopeErrors] -type dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DispatchNamespaceScriptUpdateResponseEnvelopeMessages] -type dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceScriptUpdateResponseEnvelopeSuccess bool @@ -469,17 +311,22 @@ func (r DispatchNamespaceScriptUpdateResponseEnvelopeSuccess) IsKnown() bool { type DispatchNamespaceScriptDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` // If set to true, delete will not be stopped by associated service binding, // durable object, or other binding. Any of these associated bindings/durable // objects will be deleted along with the script. Force param.Field[bool] `query:"force"` } +func (r DispatchNamespaceScriptDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + // URLQuery serializes [DispatchNamespaceScriptDeleteParams]'s query parameters as // `url.Values`. func (r DispatchNamespaceScriptDeleteParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -490,10 +337,10 @@ type DispatchNamespaceScriptGetParams struct { } type DispatchNamespaceScriptGetResponseEnvelope struct { - Errors []DispatchNamespaceScriptGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceScriptGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Details about a worker uploaded to a Workers for Platforms namespace. - Result WorkersForPlatformsNamespaceScript `json:"result,required"` + Result Script `json:"result,required"` // Whether the API call was successful Success DispatchNamespaceScriptGetResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceScriptGetResponseEnvelopeJSON `json:"-"` @@ -518,52 +365,6 @@ func (r dispatchNamespaceScriptGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DispatchNamespaceScriptGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DispatchNamespaceScriptGetResponseEnvelopeErrors] -type dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DispatchNamespaceScriptGetResponseEnvelopeMessages] -type dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceScriptGetResponseEnvelopeSuccess bool diff --git a/workers_for_platforms/dispatchnamespacescript_test.go b/workers_for_platforms/dispatchnamespacescript_test.go index a176d7f71f4..5d77cc1d499 100644 --- a/workers_for_platforms/dispatchnamespacescript_test.go +++ b/workers_for_platforms/dispatchnamespacescript_test.go @@ -13,6 +13,7 @@ import ( "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/workers" "github.com/cloudflare/cloudflare-go/v2/workers_for_platforms" ) @@ -34,70 +35,72 @@ func TestDispatchNamespaceScriptUpdateWithOptionalParams(t *testing.T) { context.TODO(), "my-dispatch-namespace", "this-is_my_script-01", - workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0Metadata{ - Bindings: cloudflare.F([]interface{}{map[string]interface{}{ - "name": "MY_ENV_VAR", - "text": "my_data", - "type": "plain_text", - }}), - BodyPart: cloudflare.F("worker.js"), - CompatibilityDate: cloudflare.F("2023-07-25"), - CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), - KeepBindings: cloudflare.F([]string{"string", "string", "string"}), - Logpush: cloudflare.F(false), - MainModule: cloudflare.F("worker.js"), - Migrations: cloudflare.F[workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrations](workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations(workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), + workers_for_platforms.DispatchNamespaceScriptUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: workers_for_platforms.DispatchNamespaceScriptUpdateParamsBodyObject{ + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Metadata: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsBodyObjectMetadata{ + Bindings: cloudflare.F([]interface{}{map[string]interface{}{ + "name": "MY_ENV_VAR", + "text": "my_data", + "type": "plain_text", }}), - TransferredClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), + BodyPart: cloudflare.F("worker.js"), + CompatibilityDate: cloudflare.F("2023-07-25"), + CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), + KeepBindings: cloudflare.F([]string{"string", "string", "string"}), + Logpush: cloudflare.F(false), + MainModule: cloudflare.F("worker.js"), + Migrations: cloudflare.F[workers_for_platforms.DispatchNamespaceScriptUpdateParamsBodyObjectMetadataMigrationsUnion](workers.SingleStepMigrationParam{ + NewTag: cloudflare.F("v2"), + OldTag: cloudflare.F("v1"), + DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), + NewClasses: cloudflare.F([]string{"string", "string", "string"}), + RenamedClasses: cloudflare.F([]workers.SingleStepMigrationRenamedClassParam{{ + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + TransferredClasses: cloudflare.F([]workers.SingleStepMigrationTransferredClassParam{{ + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + }), + Placement: cloudflare.F(workers.PlacementConfigurationParam{ + Mode: cloudflare.F(workers.PlacementConfigurationModeSmart), + }), + Tags: cloudflare.F([]string{"string", "string", "string"}), + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), }}), - })), - Placement: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacement{ - Mode: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataPlacementModeSmart), + UsageModel: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsBodyObjectMetadataUsageModelBundled), + VersionTags: cloudflare.F[any](map[string]interface{}{}), }), - Tags: cloudflare.F([]string{"string", "string", "string"}), - TailConsumers: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModelBundled), - VersionTags: cloudflare.F[any](map[string]interface{}{}), - }), + }, }, ) if err != nil { @@ -129,6 +132,7 @@ func TestDispatchNamespaceScriptDeleteWithOptionalParams(t *testing.T) { "this-is_my_script-01", workers_for_platforms.DispatchNamespaceScriptDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, Force: cloudflare.F(true), }, ) diff --git a/workers_for_platforms/dispatchnamespacescriptbinding.go b/workers_for_platforms/dispatchnamespacescriptbinding.go index a008ba63850..b8613a0cacb 100644 --- a/workers_for_platforms/dispatchnamespacescriptbinding.go +++ b/workers_for_platforms/dispatchnamespacescriptbinding.go @@ -6,13 +6,13 @@ import ( "context" "fmt" "net/http" - "reflect" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" + "github.com/cloudflare/cloudflare-go/v2/workers" ) // DispatchNamespaceScriptBindingService contains methods and other services that @@ -35,518 +35,63 @@ func NewDispatchNamespaceScriptBindingService(opts ...option.RequestOption) (r * // Fetch script bindings from a script uploaded to a Workers for Platforms // namespace. -func (r *DispatchNamespaceScriptBindingService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptBindingGetParams, opts ...option.RequestOption) (res *DispatchNamespaceScriptBindingGetResponse, err error) { +func (r *DispatchNamespaceScriptBindingService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptBindingGetParams, opts ...option.RequestOption) (res *[]workers.Binding, err error) { opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptBindingGetResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/bindings", query.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBinding], -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersServiceBinding], -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersDoBinding], -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersR2Binding], -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersQueueBinding], -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersD1Binding], -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBinding] -// or -// [workers_for_platforms.DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBinding]. -type DispatchNamespaceScriptBindingGetResponse interface { - implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DispatchNamespaceScriptBindingGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBinding{}), - }, - ) -} - -type DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingType `json:"type,required"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingJSON contains -// the JSON metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBinding] -type dispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingType string - -const ( - DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptBindingGetResponseWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersServiceBindingType `json:"type,required"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersServiceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersServiceBindingJSON contains the -// JSON metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersServiceBinding] -type dispatchNamespaceScriptBindingGetResponseWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersServiceBindingType string - -const ( - DispatchNamespaceScriptBindingGetResponseWorkersServiceBindingTypeService DispatchNamespaceScriptBindingGetResponseWorkersServiceBindingType = "service" -) - -func (r DispatchNamespaceScriptBindingGetResponseWorkersServiceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersServiceBindingTypeService: - return true + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return } - return false -} - -type DispatchNamespaceScriptBindingGetResponseWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersDoBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersDoBindingJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersDoBinding] -type dispatchNamespaceScriptBindingGetResponseWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersDoBindingType string - -const ( - DispatchNamespaceScriptBindingGetResponseWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptBindingGetResponseWorkersDoBindingType = "durable_object_namespace" -) - -func (r DispatchNamespaceScriptBindingGetResponseWorkersDoBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptBindingGetResponseWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersR2BindingType `json:"type,required"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersR2BindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersR2BindingJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersR2Binding] -type dispatchNamespaceScriptBindingGetResponseWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersR2BindingType string - -const ( - DispatchNamespaceScriptBindingGetResponseWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptBindingGetResponseWorkersR2BindingType = "r2_bucket" -) - -func (r DispatchNamespaceScriptBindingGetResponseWorkersR2BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type DispatchNamespaceScriptBindingGetResponseWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersQueueBindingType `json:"type,required"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersQueueBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersQueueBindingJSON contains the -// JSON metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersQueueBinding] -type dispatchNamespaceScriptBindingGetResponseWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersQueueBindingType string - -const ( - DispatchNamespaceScriptBindingGetResponseWorkersQueueBindingTypeQueue DispatchNamespaceScriptBindingGetResponseWorkersQueueBindingType = "queue" -) - -func (r DispatchNamespaceScriptBindingGetResponseWorkersQueueBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type DispatchNamespaceScriptBindingGetResponseWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersD1BindingType `json:"type,required"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersD1BindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersD1BindingJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersD1Binding] -type dispatchNamespaceScriptBindingGetResponseWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersD1BindingType string - -const ( - DispatchNamespaceScriptBindingGetResponseWorkersD1BindingTypeD1 DispatchNamespaceScriptBindingGetResponseWorkersD1BindingType = "d1" -) - -func (r DispatchNamespaceScriptBindingGetResponseWorkersD1BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersD1BindingTypeD1: - return true - } - return false -} - -type DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBinding] -type dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingType string - -const ( - DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutbound] -type dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + res = &env.Result + return } -func (r dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw +type DispatchNamespaceScriptBindingGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` } -// Outbound worker -type DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +type DispatchNamespaceScriptBindingGetResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + // List of bindings attached to this Worker + Result []workers.Binding `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptBindingGetResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptBindingGetResponseEnvelopeJSON `json:"-"` } -// dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker] -type dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field +// dispatchNamespaceScriptBindingGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptBindingGetResponseEnvelope] +type dispatchNamespaceScriptBindingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { +func (r *DispatchNamespaceScriptBindingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dispatchNamespaceScriptBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { +func (r dispatchNamespaceScriptBindingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON dispatchNamespaceScriptBindingGetResponseWorkersMtlscertBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptBindingGetResponseWorkersMtlscertBindingJSON contains the -// JSON metadata for the struct -// [DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBinding] -type dispatchNamespaceScriptBindingGetResponseWorkersMtlscertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptBindingGetResponseWorkersMtlscertBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBinding) implementsWorkersForPlatformsDispatchNamespaceScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBindingType string +// Whether the API call was successful +type DispatchNamespaceScriptBindingGetResponseEnvelopeSuccess bool const ( - DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBindingTypeMTLSCertificate DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBindingType = "mtls_certificate" + DispatchNamespaceScriptBindingGetResponseEnvelopeSuccessTrue DispatchNamespaceScriptBindingGetResponseEnvelopeSuccess = true ) -func (r DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBindingType) IsKnown() bool { +func (r DispatchNamespaceScriptBindingGetResponseEnvelopeSuccess) IsKnown() bool { switch r { - case DispatchNamespaceScriptBindingGetResponseWorkersMTLSCERTBindingTypeMTLSCertificate: + case DispatchNamespaceScriptBindingGetResponseEnvelopeSuccessTrue: return true } return false } - -type DispatchNamespaceScriptBindingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workers_for_platforms/dispatchnamespacescriptcontent.go b/workers_for_platforms/dispatchnamespacescriptcontent.go index c0fcc253f60..cc786b80ce5 100644 --- a/workers_for_platforms/dispatchnamespacescriptcontent.go +++ b/workers_for_platforms/dispatchnamespacescriptcontent.go @@ -14,6 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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/cloudflare/cloudflare-go/v2/workers" ) @@ -37,7 +38,7 @@ func NewDispatchNamespaceScriptContentService(opts ...option.RequestOption) (r * } // Put script content for a script uploaded to a Workers for Platforms namespace. -func (r *DispatchNamespaceScriptContentService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptContentUpdateParams, opts ...option.RequestOption) (res *workers.WorkersScript, err error) { +func (r *DispatchNamespaceScriptContentService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptContentUpdateParams, opts ...option.RequestOption) (res *workers.Script, err error) { opts = append(r.Options[:], opts...) var env DispatchNamespaceScriptContentUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/content", params.AccountID, dispatchNamespace, scriptName) @@ -66,12 +67,13 @@ type DispatchNamespaceScriptContentUpdateParams struct { // may be provided as separate named parts, but at least one module must be // present. This should be referenced either in the metadata as `main_module` // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` - // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. + // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. Source maps may also + // be included using the `application/source-map` content type. AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[DispatchNamespaceScriptContentUpdateParamsMetadata] `json:"metadata"` - CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` - CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` + Metadata param.Field[workers.WorkerMetadataParam] `json:"metadata"` + CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` + CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` } func (r DispatchNamespaceScriptContentUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { @@ -89,25 +91,10 @@ func (r DispatchNamespaceScriptContentUpdateParams) MarshalMultipart() (data []b return buf.Bytes(), writer.FormDataContentType(), nil } -// JSON encoded metadata about the uploaded parts and Worker configuration. -type DispatchNamespaceScriptContentUpdateParamsMetadata struct { - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` -} - -func (r DispatchNamespaceScriptContentUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type DispatchNamespaceScriptContentUpdateResponseEnvelope struct { - Errors []DispatchNamespaceScriptContentUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceScriptContentUpdateResponseEnvelopeMessages `json:"messages,required"` - Result workers.WorkersScript `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result workers.Script `json:"result,required"` // Whether the API call was successful Success DispatchNamespaceScriptContentUpdateResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceScriptContentUpdateResponseEnvelopeJSON `json:"-"` @@ -132,54 +119,6 @@ func (r dispatchNamespaceScriptContentUpdateResponseEnvelopeJSON) RawJSON() stri return r.raw } -type DispatchNamespaceScriptContentUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptContentUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceScriptContentUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptContentUpdateResponseEnvelopeErrors] -type dispatchNamespaceScriptContentUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptContentUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptContentUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptContentUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptContentUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceScriptContentUpdateResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [DispatchNamespaceScriptContentUpdateResponseEnvelopeMessages] -type dispatchNamespaceScriptContentUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptContentUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptContentUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceScriptContentUpdateResponseEnvelopeSuccess bool diff --git a/workers_for_platforms/dispatchnamespacescriptcontent_test.go b/workers_for_platforms/dispatchnamespacescriptcontent_test.go index db11955c93d..3393d0a1e6e 100644 --- a/workers_for_platforms/dispatchnamespacescriptcontent_test.go +++ b/workers_for_platforms/dispatchnamespacescriptcontent_test.go @@ -15,6 +15,7 @@ import ( "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/workers" "github.com/cloudflare/cloudflare-go/v2/workers_for_platforms" ) @@ -39,7 +40,7 @@ func TestDispatchNamespaceScriptContentUpdateWithOptionalParams(t *testing.T) { workers_for_platforms.DispatchNamespaceScriptContentUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentUpdateParamsMetadata{ + Metadata: cloudflare.F(workers.WorkerMetadataParam{ BodyPart: cloudflare.F("worker.js"), MainModule: cloudflare.F("worker.js"), }), diff --git a/workers_for_platforms/dispatchnamespacescriptsecret.go b/workers_for_platforms/dispatchnamespacescriptsecret.go new file mode 100644 index 00000000000..d46fb698f18 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptsecret.go @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package workers_for_platforms + +import ( + "context" + "fmt" + "net/http" + + "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" +) + +// DispatchNamespaceScriptSecretService 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 +// [NewDispatchNamespaceScriptSecretService] method instead. +type DispatchNamespaceScriptSecretService struct { + Options []option.RequestOption +} + +// NewDispatchNamespaceScriptSecretService 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 NewDispatchNamespaceScriptSecretService(opts ...option.RequestOption) (r *DispatchNamespaceScriptSecretService) { + r = &DispatchNamespaceScriptSecretService{} + r.Options = opts + return +} + +// Put secrets to a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptSecretService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptSecretUpdateParams, opts ...option.RequestOption) (res *DispatchNamespaceScriptSecretUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptSecretUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/secrets", params.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch secrets from a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptSecretService) List(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptSecretListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DispatchNamespaceScriptSecretListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/secrets", query.AccountID, dispatchNamespace, scriptName) + 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 +} + +// Fetch secrets from a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptSecretService) ListAutoPaging(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptSecretListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DispatchNamespaceScriptSecretListResponse] { + return pagination.NewSinglePageAutoPager(r.List(ctx, dispatchNamespace, scriptName, query, opts...)) +} + +type DispatchNamespaceScriptSecretUpdateResponse struct { + // The name of this secret, this is what will be to access it inside the Worker. + Name string `json:"name"` + // The type of secret to put. + Type DispatchNamespaceScriptSecretUpdateResponseType `json:"type"` + JSON dispatchNamespaceScriptSecretUpdateResponseJSON `json:"-"` +} + +// dispatchNamespaceScriptSecretUpdateResponseJSON contains the JSON metadata for +// the struct [DispatchNamespaceScriptSecretUpdateResponse] +type dispatchNamespaceScriptSecretUpdateResponseJSON struct { + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptSecretUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptSecretUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// The type of secret to put. +type DispatchNamespaceScriptSecretUpdateResponseType string + +const ( + DispatchNamespaceScriptSecretUpdateResponseTypeSecretText DispatchNamespaceScriptSecretUpdateResponseType = "secret_text" +) + +func (r DispatchNamespaceScriptSecretUpdateResponseType) IsKnown() bool { + switch r { + case DispatchNamespaceScriptSecretUpdateResponseTypeSecretText: + return true + } + return false +} + +type DispatchNamespaceScriptSecretListResponse struct { + // The name of this secret, this is what will be to access it inside the Worker. + Name string `json:"name"` + // The type of secret to put. + Type DispatchNamespaceScriptSecretListResponseType `json:"type"` + JSON dispatchNamespaceScriptSecretListResponseJSON `json:"-"` +} + +// dispatchNamespaceScriptSecretListResponseJSON contains the JSON metadata for the +// struct [DispatchNamespaceScriptSecretListResponse] +type dispatchNamespaceScriptSecretListResponseJSON struct { + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptSecretListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptSecretListResponseJSON) RawJSON() string { + return r.raw +} + +// The type of secret to put. +type DispatchNamespaceScriptSecretListResponseType string + +const ( + DispatchNamespaceScriptSecretListResponseTypeSecretText DispatchNamespaceScriptSecretListResponseType = "secret_text" +) + +func (r DispatchNamespaceScriptSecretListResponseType) IsKnown() bool { + switch r { + case DispatchNamespaceScriptSecretListResponseTypeSecretText: + return true + } + return false +} + +type DispatchNamespaceScriptSecretUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The name of this secret, this is what will be to access it inside the Worker. + Name param.Field[string] `json:"name"` + // The value of the secret. + Text param.Field[string] `json:"text"` + // The type of secret to put. + Type param.Field[DispatchNamespaceScriptSecretUpdateParamsType] `json:"type"` +} + +func (r DispatchNamespaceScriptSecretUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of secret to put. +type DispatchNamespaceScriptSecretUpdateParamsType string + +const ( + DispatchNamespaceScriptSecretUpdateParamsTypeSecretText DispatchNamespaceScriptSecretUpdateParamsType = "secret_text" +) + +func (r DispatchNamespaceScriptSecretUpdateParamsType) IsKnown() bool { + switch r { + case DispatchNamespaceScriptSecretUpdateParamsTypeSecretText: + return true + } + return false +} + +type DispatchNamespaceScriptSecretUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DispatchNamespaceScriptSecretUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptSecretUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptSecretUpdateResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptSecretUpdateResponseEnvelopeJSON contains the JSON +// metadata for the struct [DispatchNamespaceScriptSecretUpdateResponseEnvelope] +type dispatchNamespaceScriptSecretUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptSecretUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptSecretUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptSecretUpdateResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptSecretUpdateResponseEnvelopeSuccessTrue DispatchNamespaceScriptSecretUpdateResponseEnvelopeSuccess = true +) + +func (r DispatchNamespaceScriptSecretUpdateResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case DispatchNamespaceScriptSecretUpdateResponseEnvelopeSuccessTrue: + return true + } + return false +} + +type DispatchNamespaceScriptSecretListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/zones/setting_test.go b/workers_for_platforms/dispatchnamespacescriptsecret_test.go similarity index 54% rename from zones/setting_test.go rename to workers_for_platforms/dispatchnamespacescriptsecret_test.go index 33c845c5550..2ee9139e1c1 100644 --- a/zones/setting_test.go +++ b/workers_for_platforms/dispatchnamespacescriptsecret_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package zones_test +package workers_for_platforms_test import ( "context" @@ -11,11 +11,11 @@ import ( "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/zones" + "github.com/cloudflare/cloudflare-go/v2/workers_for_platforms" ) -func TestSettingEdit(t *testing.T) { - t.Skip("oneOf doesnt match") +func TestDispatchNamespaceScriptSecretUpdateWithOptionalParams(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 @@ -28,19 +28,17 @@ func TestSettingEdit(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.Settings.Edit(context.TODO(), zones.SettingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Items: cloudflare.F([]zones.SettingEditParamsItem{zones.ZoneSettingAlwaysOnlineParam(zones.ZoneSettingAlwaysOnlineParam{ - ID: cloudflare.F(zones.ZoneSettingAlwaysOnlineIDAlwaysOnline), - Value: cloudflare.F(zones.ZoneSettingAlwaysOnlineValueOn), - }), zones.ZoneSettingBrowserCacheTTLParam(zones.ZoneSettingBrowserCacheTTLParam{ - ID: cloudflare.F(zones.ZoneSettingBrowserCacheTTLIDBrowserCacheTTL), - Value: cloudflare.F(zones.ZoneSettingBrowserCacheTTLValue18000), - }), zones.ZoneSettingIPGeolocationParam(zones.ZoneSettingIPGeolocationParam{ - ID: cloudflare.F(zones.ZoneSettingIPGeolocationIDIPGeolocation), - Value: cloudflare.F(zones.ZoneSettingIPGeolocationValueOff), - })}), - }) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Secrets.Update( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptSecretUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("MY_SECRET"), + Text: cloudflare.F("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"), + Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSecretUpdateParamsTypeSecretText), + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -50,7 +48,7 @@ func TestSettingEdit(t *testing.T) { } } -func TestSettingGet(t *testing.T) { +func TestDispatchNamespaceScriptSecretList(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 { @@ -64,9 +62,14 @@ func TestSettingGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.Settings.Get(context.TODO(), zones.SettingGetParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Secrets.List( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptSecretListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/workers_for_platforms/dispatchnamespacescriptsetting.go b/workers_for_platforms/dispatchnamespacescriptsetting.go index ee7589403d4..9d1a43c4fa4 100644 --- a/workers_for_platforms/dispatchnamespacescriptsetting.go +++ b/workers_for_platforms/dispatchnamespacescriptsetting.go @@ -11,7 +11,9 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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/cloudflare/cloudflare-go/v2/workers" "github.com/tidwall/gjson" ) @@ -61,20 +63,22 @@ func (r *DispatchNamespaceScriptSettingService) Get(ctx context.Context, dispatc type DispatchNamespaceScriptSettingEditResponse struct { // List of bindings attached to this Worker - Bindings []DispatchNamespaceScriptSettingEditResponseBinding `json:"bindings"` + Bindings []workers.Binding `json:"bindings"` // Opt your Worker into changes after this date CompatibilityDate string `json:"compatibility_date"` // Opt your Worker into specific changes CompatibilityFlags []string `json:"compatibility_flags"` + // Limits to apply for this Worker. + Limits DispatchNamespaceScriptSettingEditResponseLimits `json:"limits"` // Whether Logpush is turned on for the Worker. Logpush bool `json:"logpush"` // Migrations to apply for Durable Objects associated with this Worker. Migrations DispatchNamespaceScriptSettingEditResponseMigrations `json:"migrations"` - Placement DispatchNamespaceScriptSettingEditResponsePlacement `json:"placement"` + Placement workers.PlacementConfiguration `json:"placement"` // Tags to help you manage your Workers Tags []string `json:"tags"` // List of Workers that will consume logs from the attached Worker. - TailConsumers []DispatchNamespaceScriptSettingEditResponseTailConsumer `json:"tail_consumers"` + TailConsumers []workers.ConsumerScript `json:"tail_consumers"` // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). UsageModel string `json:"usage_model"` JSON dispatchNamespaceScriptSettingEditResponseJSON `json:"-"` @@ -86,6 +90,7 @@ type dispatchNamespaceScriptSettingEditResponseJSON struct { Bindings apijson.Field CompatibilityDate apijson.Field CompatibilityFlags apijson.Field + Limits apijson.Field Logpush apijson.Field Migrations apijson.Field Placement apijson.Field @@ -104,2171 +109,316 @@ func (r dispatchNamespaceScriptSettingEditResponseJSON) RawJSON() string { return r.raw } -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2Binding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1Binding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -// or -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBinding]. -type DispatchNamespaceScriptSettingEditResponseBinding interface { - implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DispatchNamespaceScriptSettingEditResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBinding{}), - }, - ) -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBinding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBinding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingTypeService DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingType = "service" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingJSON contains -// the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBinding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingJSON contains -// the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2Binding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBinding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingTypeQueue DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingType = "queue" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingJSON contains -// the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1Binding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingTypeD1 DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingType = "d1" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON dispatchNamespaceScriptSettingEditResponseBindingsWorkersMtlscertBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseBindingsWorkersMtlscertBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBinding] -type dispatchNamespaceScriptSettingEditResponseBindingsWorkersMtlscertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseBindingsWorkersMtlscertBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType string - -const ( - DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] -// or -// [workers_for_platforms.DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrations]. -type DispatchNamespaceScriptSettingEditResponseMigrations interface { - implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DispatchNamespaceScriptSettingEditResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] -type dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseMigrations() { -} - -type DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrations] -type dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseMigrations() { -} - -type DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep] -type dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode DispatchNamespaceScriptSettingEditResponsePlacementMode `json:"mode"` - JSON dispatchNamespaceScriptSettingEditResponsePlacementJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponsePlacementJSON contains the JSON -// metadata for the struct [DispatchNamespaceScriptSettingEditResponsePlacement] -type dispatchNamespaceScriptSettingEditResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type DispatchNamespaceScriptSettingEditResponsePlacementMode string - -const ( - DispatchNamespaceScriptSettingEditResponsePlacementModeSmart DispatchNamespaceScriptSettingEditResponsePlacementMode = "smart" -) - -func (r DispatchNamespaceScriptSettingEditResponsePlacementMode) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditResponsePlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type DispatchNamespaceScriptSettingEditResponseTailConsumer 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 dispatchNamespaceScriptSettingEditResponseTailConsumerJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseTailConsumerJSON contains the JSON -// metadata for the struct [DispatchNamespaceScriptSettingEditResponseTailConsumer] -type dispatchNamespaceScriptSettingEditResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponse struct { - // List of bindings attached to this Worker - Bindings []DispatchNamespaceScriptSettingGetResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations DispatchNamespaceScriptSettingGetResponseMigrations `json:"migrations"` - Placement DispatchNamespaceScriptSettingGetResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []DispatchNamespaceScriptSettingGetResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON dispatchNamespaceScriptSettingGetResponseJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseJSON contains the JSON metadata for the -// struct [DispatchNamespaceScriptSettingGetResponse] -type dispatchNamespaceScriptSettingGetResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2Binding], -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1Binding], -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -// or -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBinding]. -type DispatchNamespaceScriptSettingGetResponseBinding interface { - implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DispatchNamespaceScriptSettingGetResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBinding{}), - }, - ) -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBinding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBinding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingTypeService DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingType = "service" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingJSON contains -// the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBinding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingJSON contains -// the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2Binding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBinding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingTypeQueue DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingType = "queue" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersQueueBindingTypeQueue: - return true - } - return false -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingJSON contains -// the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1Binding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingTypeD1 DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingType = "d1" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersD1BindingTypeD1: - return true - } - return false -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false -} - -// Outbound worker -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON dispatchNamespaceScriptSettingGetResponseBindingsWorkersMtlscertBindingJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseBindingsWorkersMtlscertBindingJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBinding] -type dispatchNamespaceScriptSettingGetResponseBindingsWorkersMtlscertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseBindingsWorkersMtlscertBindingJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType string - -const ( - DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponseBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] -// or -// [workers_for_platforms.DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrations]. -type DispatchNamespaceScriptSettingGetResponseMigrations interface { - implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DispatchNamespaceScriptSettingGetResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] -type dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseMigrations() { -} - -type DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrations] -type dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseMigrations() { -} - -type DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep] -type dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode DispatchNamespaceScriptSettingGetResponsePlacementMode `json:"mode"` - JSON dispatchNamespaceScriptSettingGetResponsePlacementJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponsePlacementJSON contains the JSON -// metadata for the struct [DispatchNamespaceScriptSettingGetResponsePlacement] -type dispatchNamespaceScriptSettingGetResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type DispatchNamespaceScriptSettingGetResponsePlacementMode string - -const ( - DispatchNamespaceScriptSettingGetResponsePlacementModeSmart DispatchNamespaceScriptSettingGetResponsePlacementMode = "smart" -) - -func (r DispatchNamespaceScriptSettingGetResponsePlacementMode) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingGetResponsePlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type DispatchNamespaceScriptSettingGetResponseTailConsumer 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 dispatchNamespaceScriptSettingGetResponseTailConsumerJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseTailConsumerJSON contains the JSON -// metadata for the struct [DispatchNamespaceScriptSettingGetResponseTailConsumer] -type dispatchNamespaceScriptSettingGetResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Errors param.Field[[]DispatchNamespaceScriptSettingEditParamsError] `json:"errors,required"` - Messages param.Field[[]DispatchNamespaceScriptSettingEditParamsMessage] `json:"messages,required"` - Result param.Field[DispatchNamespaceScriptSettingEditParamsResult] `json:"result,required"` - // Whether the API call was successful - Success param.Field[DispatchNamespaceScriptSettingEditParamsSuccess] `json:"success,required"` -} - -func (r DispatchNamespaceScriptSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DispatchNamespaceScriptSettingEditParamsError struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r DispatchNamespaceScriptSettingEditParamsError) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DispatchNamespaceScriptSettingEditParamsMessage struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r DispatchNamespaceScriptSettingEditParamsMessage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DispatchNamespaceScriptSettingEditParamsResult struct { - // List of bindings attached to this Worker - Bindings param.Field[[]DispatchNamespaceScriptSettingEditParamsResultBinding] `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[DispatchNamespaceScriptSettingEditParamsResultMigrations] `json:"migrations"` - Placement param.Field[DispatchNamespaceScriptSettingEditParamsResultPlacement] `json:"placement"` - // Tags to help you manage your Workers - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]DispatchNamespaceScriptSettingEditParamsResultTailConsumer] `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel param.Field[string] `json:"usage_model"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResult) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A binding to allow the Worker to communicate with resources -// -// Satisfied by -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2Binding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1Binding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBinding]. -type DispatchNamespaceScriptSettingEditParamsResultBinding interface { - implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() -} - -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding struct { - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment,required"` - // Name of Worker to bind to - Service param.Field[string] `json:"service,required"` - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBindingType] `json:"type,required"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBindingTypeService DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBindingType = "service" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersServiceBindingTypeService: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName param.Field[string] `json:"class_name,required"` - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBindingType] `json:"type,required"` - // The environment of the script_name to bind to - Environment param.Field[string] `json:"environment"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName param.Field[string] `json:"script_name"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBindingType = "durable_object_namespace" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName param.Field[string] `json:"bucket_name,required"` - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2BindingType] `json:"type,required"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2BindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2BindingType = "r2_bucket" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket: - return true - } - return false -} - -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBinding struct { - // Name of the Queue to bind to - QueueName param.Field[string] `json:"queue_name,required"` - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBindingType] `json:"type,required"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// Limits to apply for this Worker. +type DispatchNamespaceScriptSettingEditResponseLimits struct { + // The amount of CPU time this Worker can use in milliseconds. + CPUMs int64 `json:"cpu_ms"` + JSON dispatchNamespaceScriptSettingEditResponseLimitsJSON `json:"-"` } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { +// dispatchNamespaceScriptSettingEditResponseLimitsJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptSettingEditResponseLimits] +type dispatchNamespaceScriptSettingEditResponseLimitsJSON struct { + CPUMs apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBindingType = "queue" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue: - return true - } - return false +func (r *DispatchNamespaceScriptSettingEditResponseLimits) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID param.Field[string] `json:"id,required"` - // The name of the D1 database associated with the 'id' provided. - Name param.Field[string] `json:"name,required"` - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1BindingType] `json:"type,required"` +func (r dispatchNamespaceScriptSettingEditResponseLimitsJSON) RawJSON() string { + return r.raw } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// Migrations to apply for Durable Objects associated with this Worker. +type DispatchNamespaceScriptSettingEditResponseMigrations struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + DeletedClasses interface{} `json:"deleted_classes,required"` + NewClasses interface{} `json:"new_classes,required"` + RenamedClasses interface{} `json:"renamed_classes,required"` + TransferredClasses interface{} `json:"transferred_classes,required"` + Steps interface{} `json:"steps,required"` + JSON dispatchNamespaceScriptSettingEditResponseMigrationsJSON `json:"-"` + union DispatchNamespaceScriptSettingEditResponseMigrationsUnion +} + +// dispatchNamespaceScriptSettingEditResponseMigrationsJSON contains the JSON +// metadata for the struct [DispatchNamespaceScriptSettingEditResponseMigrations] +type dispatchNamespaceScriptSettingEditResponseMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { +func (r dispatchNamespaceScriptSettingEditResponseMigrationsJSON) RawJSON() string { + return r.raw } -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1BindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1BindingTypeD1 DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1BindingType = "d1" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1BindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersD1BindingTypeD1: - return true +func (r *DispatchNamespaceScriptSettingEditResponseMigrations) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err } - return false -} - -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding struct { - // Namespace to bind to - Namespace param.Field[string] `json:"namespace,required"` - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` - // Outbound worker - Outbound param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` + return apijson.Port(r.union, &r) } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r DispatchNamespaceScriptSettingEditResponseMigrations) AsUnion() DispatchNamespaceScriptSettingEditResponseMigrationsUnion { + return r.union } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by [workers.SingleStepMigration] or [workers.SteppedMigration]. +type DispatchNamespaceScriptSettingEditResponseMigrationsUnion interface { + implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditResponseMigrations() } -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DispatchNamespaceScriptSettingEditResponseMigrationsUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(workers.SingleStepMigration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(workers.SteppedMigration{}), + }, + ) } -// Outbound worker -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params param.Field[[]string] `json:"params"` - // Outbound worker - Worker param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` +type DispatchNamespaceScriptSettingGetResponse struct { + // List of bindings attached to this Worker + Bindings []workers.Binding `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate string `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags []string `json:"compatibility_flags"` + // Limits to apply for this Worker. + Limits DispatchNamespaceScriptSettingGetResponseLimits `json:"limits"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations DispatchNamespaceScriptSettingGetResponseMigrations `json:"migrations"` + Placement workers.PlacementConfiguration `json:"placement"` + // Tags to help you manage your Workers + Tags []string `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []workers.ConsumerScript `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON dispatchNamespaceScriptSettingGetResponseJSON `json:"-"` } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// dispatchNamespaceScriptSettingGetResponseJSON contains the JSON metadata for the +// struct [DispatchNamespaceScriptSettingGetResponse] +type dispatchNamespaceScriptSettingGetResponseJSON struct { + Bindings apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + Limits apijson.Field + Logpush apijson.Field + Migrations apijson.Field + Placement apijson.Field + Tags apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Outbound worker -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment param.Field[string] `json:"environment"` - // Name of the outbound worker - Service param.Field[string] `json:"service"` +func (r *DispatchNamespaceScriptSettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r dispatchNamespaceScriptSettingGetResponseJSON) RawJSON() string { + return r.raw } -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBinding struct { - // The class of resource that the binding provides. - Type param.Field[DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBindingType] `json:"type,required"` - // ID of the certificate to bind to - CertificateID param.Field[string] `json:"certificate_id"` +// Limits to apply for this Worker. +type DispatchNamespaceScriptSettingGetResponseLimits struct { + // The amount of CPU time this Worker can use in milliseconds. + CPUMs int64 `json:"cpu_ms"` + JSON dispatchNamespaceScriptSettingGetResponseLimitsJSON `json:"-"` } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// dispatchNamespaceScriptSettingGetResponseLimitsJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptSettingGetResponseLimits] +type dispatchNamespaceScriptSettingGetResponseLimitsJSON struct { + CPUMs apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBinding) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultBinding() { +func (r *DispatchNamespaceScriptSettingGetResponseLimits) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The class of resource that the binding provides. -type DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBindingType string - -const ( - DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBindingTypeMTLSCertificate DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBindingType = "mtls_certificate" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBindingType) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersMTLSCERTBindingTypeMTLSCertificate: - return true - } - return false +func (r dispatchNamespaceScriptSettingGetResponseLimitsJSON) RawJSON() string { + return r.raw } // Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrations], -// [workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrations]. -type DispatchNamespaceScriptSettingEditParamsResultMigrations interface { - implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultMigrations() -} - -// A single set of migrations to apply. -type DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` +type DispatchNamespaceScriptSettingGetResponseMigrations struct { // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` + NewTag string `json:"new_tag"` // Tag used to verify against the latest migration tag for this Worker. If they // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultMigrations() { -} - -type DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + OldTag string `json:"old_tag"` + DeletedClasses interface{} `json:"deleted_classes,required"` + NewClasses interface{} `json:"new_classes,required"` + RenamedClasses interface{} `json:"renamed_classes,required"` + TransferredClasses interface{} `json:"transferred_classes,required"` + Steps interface{} `json:"steps,required"` + JSON dispatchNamespaceScriptSettingGetResponseMigrationsJSON `json:"-"` + union DispatchNamespaceScriptSettingGetResponseMigrationsUnion +} + +// dispatchNamespaceScriptSettingGetResponseMigrationsJSON contains the JSON +// metadata for the struct [DispatchNamespaceScriptSettingGetResponseMigrations] +type dispatchNamespaceScriptSettingGetResponseMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` +func (r dispatchNamespaceScriptSettingGetResponseMigrationsJSON) RawJSON() string { + return r.raw } -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *DispatchNamespaceScriptSettingGetResponseMigrations) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -type DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` +func (r DispatchNamespaceScriptSettingGetResponseMigrations) AsUnion() DispatchNamespaceScriptSettingGetResponseMigrationsUnion { + return r.union } -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by [workers.SingleStepMigration] or [workers.SteppedMigration]. +type DispatchNamespaceScriptSettingGetResponseMigrationsUnion interface { + implementsWorkersForPlatformsDispatchNamespaceScriptSettingGetResponseMigrations() } -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsResultMigrations() { +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DispatchNamespaceScriptSettingGetResponseMigrationsUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(workers.SingleStepMigration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(workers.SteppedMigration{}), + }, + ) } -type DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` +type DispatchNamespaceScriptSettingEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Settings param.Field[DispatchNamespaceScriptSettingEditParamsSettings] `json:"settings"` } -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { +func (r DispatchNamespaceScriptSettingEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` +type DispatchNamespaceScriptSettingEditParamsSettings struct { + // List of bindings attached to this Worker + Bindings param.Field[[]workers.BindingUnionParam] `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` + // Limits to apply for this Worker. + Limits param.Field[DispatchNamespaceScriptSettingEditParamsSettingsLimits] `json:"limits"` + // Whether Logpush is turned on for the Worker. + Logpush param.Field[bool] `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations param.Field[DispatchNamespaceScriptSettingEditParamsSettingsMigrationsUnion] `json:"migrations"` + Placement param.Field[workers.PlacementConfigurationParam] `json:"placement"` + // Tags to help you manage your Workers + Tags param.Field[[]string] `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers param.Field[[]workers.ConsumerScriptParam] `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel param.Field[string] `json:"usage_model"` } -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { +func (r DispatchNamespaceScriptSettingEditParamsSettings) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` +// Limits to apply for this Worker. +type DispatchNamespaceScriptSettingEditParamsSettingsLimits struct { + // The amount of CPU time this Worker can use in milliseconds. + CPUMs param.Field[int64] `json:"cpu_ms"` } -func (r DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { +func (r DispatchNamespaceScriptSettingEditParamsSettingsLimits) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type DispatchNamespaceScriptSettingEditParamsResultPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[DispatchNamespaceScriptSettingEditParamsResultPlacementMode] `json:"mode"` +// Migrations to apply for Durable Objects associated with this Worker. +type DispatchNamespaceScriptSettingEditParamsSettingsMigrations struct { + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + DeletedClasses param.Field[interface{}] `json:"deleted_classes,required"` + NewClasses param.Field[interface{}] `json:"new_classes,required"` + RenamedClasses param.Field[interface{}] `json:"renamed_classes,required"` + TransferredClasses param.Field[interface{}] `json:"transferred_classes,required"` + Steps param.Field[interface{}] `json:"steps,required"` } -func (r DispatchNamespaceScriptSettingEditParamsResultPlacement) MarshalJSON() (data []byte, err error) { +func (r DispatchNamespaceScriptSettingEditParamsSettingsMigrations) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type DispatchNamespaceScriptSettingEditParamsResultPlacementMode string - -const ( - DispatchNamespaceScriptSettingEditParamsResultPlacementModeSmart DispatchNamespaceScriptSettingEditParamsResultPlacementMode = "smart" -) - -func (r DispatchNamespaceScriptSettingEditParamsResultPlacementMode) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsResultPlacementModeSmart: - return true - } - return false -} - -// A reference to a script that will consume logs from the attached Worker. -type DispatchNamespaceScriptSettingEditParamsResultTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r DispatchNamespaceScriptSettingEditParamsResultTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r DispatchNamespaceScriptSettingEditParamsSettingsMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsSettingsMigrationsUnion() { } -// Whether the API call was successful -type DispatchNamespaceScriptSettingEditParamsSuccess bool - -const ( - DispatchNamespaceScriptSettingEditParamsSuccessTrue DispatchNamespaceScriptSettingEditParamsSuccess = true -) - -func (r DispatchNamespaceScriptSettingEditParamsSuccess) IsKnown() bool { - switch r { - case DispatchNamespaceScriptSettingEditParamsSuccessTrue: - return true - } - return false +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by [workers.SingleStepMigrationParam], +// [workers.SteppedMigrationParam], +// [DispatchNamespaceScriptSettingEditParamsSettingsMigrations]. +type DispatchNamespaceScriptSettingEditParamsSettingsMigrationsUnion interface { + implementsWorkersForPlatformsDispatchNamespaceScriptSettingEditParamsSettingsMigrationsUnion() } type DispatchNamespaceScriptSettingEditResponseEnvelope struct { - Errors []DispatchNamespaceScriptSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceScriptSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result DispatchNamespaceScriptSettingEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DispatchNamespaceScriptSettingEditResponse `json:"result,required"` // Whether the API call was successful Success DispatchNamespaceScriptSettingEditResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceScriptSettingEditResponseEnvelopeJSON `json:"-"` @@ -2293,54 +443,6 @@ func (r dispatchNamespaceScriptSettingEditResponseEnvelopeJSON) RawJSON() string return r.raw } -type DispatchNamespaceScriptSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseEnvelopeErrors] -type dispatchNamespaceScriptSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptSettingEditResponseEnvelopeMessages] -type dispatchNamespaceScriptSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceScriptSettingEditResponseEnvelopeSuccess bool @@ -2362,9 +464,9 @@ type DispatchNamespaceScriptSettingGetParams struct { } type DispatchNamespaceScriptSettingGetResponseEnvelope struct { - Errors []DispatchNamespaceScriptSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DispatchNamespaceScriptSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result DispatchNamespaceScriptSettingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DispatchNamespaceScriptSettingGetResponse `json:"result,required"` // Whether the API call was successful Success DispatchNamespaceScriptSettingGetResponseEnvelopeSuccess `json:"success,required"` JSON dispatchNamespaceScriptSettingGetResponseEnvelopeJSON `json:"-"` @@ -2389,54 +491,6 @@ func (r dispatchNamespaceScriptSettingGetResponseEnvelopeJSON) RawJSON() string return r.raw } -type DispatchNamespaceScriptSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseEnvelopeErrors] -type dispatchNamespaceScriptSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DispatchNamespaceScriptSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dispatchNamespaceScriptSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dispatchNamespaceScriptSettingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [DispatchNamespaceScriptSettingGetResponseEnvelopeMessages] -type dispatchNamespaceScriptSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DispatchNamespaceScriptSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dispatchNamespaceScriptSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DispatchNamespaceScriptSettingGetResponseEnvelopeSuccess bool diff --git a/workers_for_platforms/dispatchnamespacescriptsetting_test.go b/workers_for_platforms/dispatchnamespacescriptsetting_test.go index 619a2c24e78..d77c9b9088e 100644 --- a/workers_for_platforms/dispatchnamespacescriptsetting_test.go +++ b/workers_for_platforms/dispatchnamespacescriptsetting_test.go @@ -11,6 +11,7 @@ import ( "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/workers" "github.com/cloudflare/cloudflare-go/v2/workers_for_platforms" ) @@ -34,43 +35,26 @@ func TestDispatchNamespaceScriptSettingEditWithOptionalParams(t *testing.T) { "this-is_my_script-01", workers_for_platforms.DispatchNamespaceScriptSettingEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Errors: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptSettingEditParamsError{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Messages: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptSettingEditParamsMessage{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Result: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResult{ - Bindings: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBinding{workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - })}), + Settings: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsSettings{ + Bindings: cloudflare.F([]workers.BindingUnionParam{workers.KVNamespaceBindingParam{ + Type: cloudflare.F(workers.KVNamespaceBindingTypeKVNamespace), + }, workers.KVNamespaceBindingParam{ + Type: cloudflare.F(workers.KVNamespaceBindingTypeKVNamespace), + }, workers.KVNamespaceBindingParam{ + Type: cloudflare.F(workers.KVNamespaceBindingTypeKVNamespace), + }}), CompatibilityDate: cloudflare.F("2022-04-05"), CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), - Logpush: cloudflare.F(false), - Migrations: cloudflare.F[workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultMigrations](workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrations(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrations{ + Limits: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsSettingsLimits{ + CPUMs: cloudflare.F(int64(50)), + }), + Logpush: cloudflare.F(false), + Migrations: cloudflare.F[workers_for_platforms.DispatchNamespaceScriptSettingEditParamsSettingsMigrationsUnion](workers.SingleStepMigrationParam{ NewTag: cloudflare.F("v2"), OldTag: cloudflare.F("v1"), DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ + RenamedClasses: cloudflare.F([]workers.SingleStepMigrationRenamedClassParam{{ From: cloudflare.F("string"), To: cloudflare.F("string"), }, { @@ -80,7 +64,7 @@ func TestDispatchNamespaceScriptSettingEditWithOptionalParams(t *testing.T) { From: cloudflare.F("string"), To: cloudflare.F("string"), }}), - TransferredClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ + TransferredClasses: cloudflare.F([]workers.SingleStepMigrationTransferredClassParam{{ From: cloudflare.F("string"), FromScript: cloudflare.F("string"), To: cloudflare.F("string"), @@ -93,12 +77,12 @@ func TestDispatchNamespaceScriptSettingEditWithOptionalParams(t *testing.T) { FromScript: cloudflare.F("string"), To: cloudflare.F("string"), }}), - })), - Placement: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultPlacement{ - Mode: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultPlacementModeSmart), + }), + Placement: cloudflare.F(workers.PlacementConfigurationParam{ + Mode: cloudflare.F(workers.PlacementConfigurationModeSmart), }), Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), - TailConsumers: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptSettingEditParamsResultTailConsumer{{ + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ Environment: cloudflare.F("production"), Namespace: cloudflare.F("my-namespace"), Service: cloudflare.F("my-log-consumer"), @@ -113,7 +97,6 @@ func TestDispatchNamespaceScriptSettingEditWithOptionalParams(t *testing.T) { }}), UsageModel: cloudflare.F("unbound"), }), - Success: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSettingEditParamsSuccessTrue), }, ) if err != nil { diff --git a/workers_for_platforms/dispatchnamespacescripttag.go b/workers_for_platforms/dispatchnamespacescripttag.go new file mode 100644 index 00000000000..b3c0772fec6 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescripttag.go @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package workers_for_platforms + +import ( + "context" + "fmt" + "net/http" + + "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" +) + +// DispatchNamespaceScriptTagService 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 +// [NewDispatchNamespaceScriptTagService] method instead. +type DispatchNamespaceScriptTagService struct { + Options []option.RequestOption +} + +// NewDispatchNamespaceScriptTagService 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 NewDispatchNamespaceScriptTagService(opts ...option.RequestOption) (r *DispatchNamespaceScriptTagService) { + r = &DispatchNamespaceScriptTagService{} + r.Options = opts + return +} + +// Put script tags for a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptTagService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptTagUpdateParams, opts ...option.RequestOption) (res *[]string, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptTagUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/tags", params.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch tags from a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptTagService) List(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptTagListParams, opts ...option.RequestOption) (res *pagination.SinglePage[string], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/tags", query.AccountID, dispatchNamespace, scriptName) + 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 +} + +// Fetch tags from a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptTagService) ListAutoPaging(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptTagListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[string] { + return pagination.NewSinglePageAutoPager(r.List(ctx, dispatchNamespace, scriptName, query, opts...)) +} + +// Delete script tag for a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptTagService) Delete(ctx context.Context, dispatchNamespace string, scriptName string, tag string, body DispatchNamespaceScriptTagDeleteParams, opts ...option.RequestOption) (res *DispatchNamespaceScriptTagDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptTagDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/tags/%s", body.AccountID, dispatchNamespace, scriptName, tag) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DispatchNamespaceScriptTagDeleteResponse = interface{} + +type DispatchNamespaceScriptTagUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Tags to help you manage your Workers + Body []string `json:"body,required"` +} + +func (r DispatchNamespaceScriptTagUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type DispatchNamespaceScriptTagUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []string `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptTagUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptTagUpdateResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptTagUpdateResponseEnvelopeJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptTagUpdateResponseEnvelope] +type dispatchNamespaceScriptTagUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptTagUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptTagUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptTagUpdateResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptTagUpdateResponseEnvelopeSuccessTrue DispatchNamespaceScriptTagUpdateResponseEnvelopeSuccess = true +) + +func (r DispatchNamespaceScriptTagUpdateResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case DispatchNamespaceScriptTagUpdateResponseEnvelopeSuccessTrue: + return true + } + return false +} + +type DispatchNamespaceScriptTagListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DispatchNamespaceScriptTagDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DispatchNamespaceScriptTagDeleteResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DispatchNamespaceScriptTagDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success DispatchNamespaceScriptTagDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptTagDeleteResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptTagDeleteResponseEnvelopeJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptTagDeleteResponseEnvelope] +type dispatchNamespaceScriptTagDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptTagDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptTagDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptTagDeleteResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptTagDeleteResponseEnvelopeSuccessTrue DispatchNamespaceScriptTagDeleteResponseEnvelopeSuccess = true +) + +func (r DispatchNamespaceScriptTagDeleteResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case DispatchNamespaceScriptTagDeleteResponseEnvelopeSuccessTrue: + return true + } + return false +} diff --git a/zones/workerscript_test.go b/workers_for_platforms/dispatchnamespacescripttag_test.go similarity index 57% rename from zones/workerscript_test.go rename to workers_for_platforms/dispatchnamespacescripttag_test.go index afdfb6681cf..8e608129604 100644 --- a/zones/workerscript_test.go +++ b/workers_for_platforms/dispatchnamespacescripttag_test.go @@ -1,24 +1,20 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package zones_test +package workers_for_platforms_test import ( - "bytes" "context" "errors" - "io" - "net/http" - "net/http/httptest" "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/zones" + "github.com/cloudflare/cloudflare-go/v2/workers_for_platforms" ) -func TestWorkerScriptUpdate(t *testing.T) { +func TestDispatchNamespaceScriptTagUpdate(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 { @@ -32,9 +28,15 @@ func TestWorkerScriptUpdate(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.Workers.Script.Update(context.TODO(), zones.WorkerScriptUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Tags.Update( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptTagUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: []string{"my-tag", "my-tag", "my-tag"}, + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -44,7 +46,7 @@ func TestWorkerScriptUpdate(t *testing.T) { } } -func TestWorkerScriptDelete(t *testing.T) { +func TestDispatchNamespaceScriptTagList(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 { @@ -58,9 +60,14 @@ func TestWorkerScriptDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - err := client.Zones.Workers.Script.Delete(context.TODO(), zones.WorkerScriptDeleteParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Tags.List( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptTagListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -70,32 +77,29 @@ func TestWorkerScriptDelete(t *testing.T) { } } -func TestWorkerScriptGet(t *testing.T) { +func TestDispatchNamespaceScriptTagDelete(t *testing.T) { t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL + 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"), ) - resp, err := client.Zones.Workers.Script.Get(context.TODO(), zones.WorkerScriptGetParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }) - 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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Tags.Delete( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + "my-tag", + workers_for_platforms.DispatchNamespaceScriptTagDeleteParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + }, + ) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { @@ -103,7 +107,4 @@ func TestWorkerScriptGet(t *testing.T) { } t.Fatalf("err should be nil: %s", err.Error()) } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } } diff --git a/zero_trust/access.go b/zero_trust/access.go index e6c9c9bc83c..7e88457de56 100644 --- a/zero_trust/access.go +++ b/zero_trust/access.go @@ -3,7 +3,12 @@ package zero_trust import ( + "reflect" + + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" + "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/tidwall/gjson" ) // AccessService contains methods and other services that help with interacting @@ -42,3 +47,1395 @@ func NewAccessService(opts ...option.RequestOption) (r *AccessService) { r.Tags = NewAccessTagService(opts...) return } + +// Enforces a device posture rule has run successfully +type AccessDevicePostureRule struct { + DevicePosture AccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessDevicePostureRuleJSON `json:"-"` +} + +// accessDevicePostureRuleJSON contains the JSON metadata for the struct +// [AccessDevicePostureRule] +type accessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessDevicePostureRule) implementsZeroTrustAccessRule() {} + +type AccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUID string `json:"integration_uid,required"` + JSON accessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessDevicePostureRuleDevicePostureJSON contains the JSON metadata for the +// struct [AccessDevicePostureRuleDevicePosture] +type accessDevicePostureRuleDevicePostureJSON struct { + IntegrationUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessDevicePostureRuleParam struct { + DevicePosture param.Field[AccessDevicePostureRuleDevicePostureParam] `json:"device_posture,required"` +} + +func (r AccessDevicePostureRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessDevicePostureRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type AccessDevicePostureRuleDevicePostureParam struct { + // The ID of a device posture integration. + IntegrationUID param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessDevicePostureRuleDevicePostureParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +type AccessRule struct { + Email interface{} `json:"email,required"` + EmailList interface{} `json:"email_list,required"` + EmailDomain interface{} `json:"email_domain,required"` + Everyone interface{} `json:"everyone,required"` + IP interface{} `json:"ip,required"` + IPList interface{} `json:"ip_list,required"` + Certificate interface{} `json:"certificate,required"` + Group interface{} `json:"group,required"` + AzureAD interface{} `json:"azureAD,required"` + GitHubOrganization interface{} `json:"github-organization,required"` + GSuite interface{} `json:"gsuite,required"` + Okta interface{} `json:"okta,required"` + SAML interface{} `json:"saml,required"` + ServiceToken interface{} `json:"service_token,required"` + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + ExternalEvaluation interface{} `json:"external_evaluation,required"` + Geo interface{} `json:"geo,required"` + AuthMethod interface{} `json:"auth_method,required"` + DevicePosture interface{} `json:"device_posture,required"` + JSON accessRuleJSON `json:"-"` + union AccessRuleUnion +} + +// accessRuleJSON contains the JSON metadata for the struct [AccessRule] +type accessRuleJSON struct { + Email apijson.Field + EmailList apijson.Field + EmailDomain apijson.Field + Everyone apijson.Field + IP apijson.Field + IPList apijson.Field + Certificate apijson.Field + Group apijson.Field + AzureAD apijson.Field + GitHubOrganization apijson.Field + GSuite apijson.Field + Okta apijson.Field + SAML apijson.Field + ServiceToken apijson.Field + AnyValidServiceToken apijson.Field + ExternalEvaluation apijson.Field + Geo apijson.Field + AuthMethod apijson.Field + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r accessRuleJSON) RawJSON() string { + return r.raw +} + +func (r *AccessRule) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r AccessRule) AsUnion() AccessRuleUnion { + return r.union +} + +// Matches a specific email. +// +// Union satisfied by [zero_trust.EmailRule], [zero_trust.EmailListRule], +// [zero_trust.DomainRule], [zero_trust.EveryoneRule], [zero_trust.IPRule], +// [zero_trust.IPListRule], [zero_trust.CertificateRule], [zero_trust.GroupRule], +// [zero_trust.AzureGroupRule], [zero_trust.GitHubOrganizationRule], +// [zero_trust.GSuiteGroupRule], [zero_trust.OktaGroupRule], +// [zero_trust.SAMLGroupRule], [zero_trust.ServiceTokenRule], +// [zero_trust.AnyValidServiceTokenRule], [zero_trust.ExternalEvaluationRule], +// [zero_trust.CountryRule], [zero_trust.AuthenticationMethodRule] or +// [zero_trust.AccessDevicePostureRule]. +type AccessRuleUnion interface { + implementsZeroTrustAccessRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessRuleUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(GroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(GitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(GSuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(OktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SAMLGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessRuleParam struct { + Email param.Field[interface{}] `json:"email,required"` + EmailList param.Field[interface{}] `json:"email_list,required"` + EmailDomain param.Field[interface{}] `json:"email_domain,required"` + Everyone param.Field[interface{}] `json:"everyone,required"` + IP param.Field[interface{}] `json:"ip,required"` + IPList param.Field[interface{}] `json:"ip_list,required"` + Certificate param.Field[interface{}] `json:"certificate,required"` + Group param.Field[interface{}] `json:"group,required"` + AzureAD param.Field[interface{}] `json:"azureAD,required"` + GitHubOrganization param.Field[interface{}] `json:"github-organization,required"` + GSuite param.Field[interface{}] `json:"gsuite,required"` + Okta param.Field[interface{}] `json:"okta,required"` + SAML param.Field[interface{}] `json:"saml,required"` + ServiceToken param.Field[interface{}] `json:"service_token,required"` + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` + ExternalEvaluation param.Field[interface{}] `json:"external_evaluation,required"` + Geo param.Field[interface{}] `json:"geo,required"` + AuthMethod param.Field[interface{}] `json:"auth_method,required"` + DevicePosture param.Field[interface{}] `json:"device_posture,required"` +} + +func (r AccessRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +// Matches a specific email. +// +// Satisfied by [zero_trust.EmailRuleParam], [zero_trust.EmailListRuleParam], +// [zero_trust.DomainRuleParam], [zero_trust.EveryoneRuleParam], +// [zero_trust.IPRuleParam], [zero_trust.IPListRuleParam], +// [zero_trust.CertificateRuleParam], [zero_trust.GroupRuleParam], +// [zero_trust.AzureGroupRuleParam], [zero_trust.GitHubOrganizationRuleParam], +// [zero_trust.GSuiteGroupRuleParam], [zero_trust.OktaGroupRuleParam], +// [zero_trust.SAMLGroupRuleParam], [zero_trust.ServiceTokenRuleParam], +// [zero_trust.AnyValidServiceTokenRuleParam], +// [zero_trust.ExternalEvaluationRuleParam], [zero_trust.CountryRuleParam], +// [zero_trust.AuthenticationMethodRuleParam], +// [zero_trust.AccessDevicePostureRuleParam], [AccessRuleParam]. +type AccessRuleUnionParam interface { + implementsZeroTrustAccessRuleUnionParam() +} + +// Matches any valid Access Service Token +type AnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON anyValidServiceTokenRuleJSON `json:"-"` +} + +// anyValidServiceTokenRuleJSON contains the JSON metadata for the struct +// [AnyValidServiceTokenRule] +type anyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r anyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AnyValidServiceTokenRule) implementsZeroTrustAccessRule() {} + +// Matches any valid Access Service Token +type AnyValidServiceTokenRuleParam struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AnyValidServiceTokenRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AnyValidServiceTokenRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +// Enforce different MFA options +type AuthenticationMethodRule struct { + AuthMethod AuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON authenticationMethodRuleJSON `json:"-"` +} + +// authenticationMethodRuleJSON contains the JSON metadata for the struct +// [AuthenticationMethodRule] +type authenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r authenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AuthenticationMethodRule) implementsZeroTrustAccessRule() {} + +type AuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON authenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// authenticationMethodRuleAuthMethodJSON contains the JSON metadata for the struct +// [AuthenticationMethodRuleAuthMethod] +type authenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r authenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AuthenticationMethodRuleParam struct { + AuthMethod param.Field[AuthenticationMethodRuleAuthMethodParam] `json:"auth_method,required"` +} + +func (r AuthenticationMethodRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AuthenticationMethodRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type AuthenticationMethodRuleAuthMethodParam struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AuthenticationMethodRuleAuthMethodParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AzureGroupRule struct { + AzureAD AzureGroupRuleAzureAD `json:"azureAD,required"` + JSON azureGroupRuleJSON `json:"-"` +} + +// azureGroupRuleJSON contains the JSON metadata for the struct [AzureGroupRule] +type azureGroupRuleJSON struct { + AzureAD apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r azureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AzureGroupRule) implementsZeroTrustAccessRule() {} + +type AzureGroupRuleAzureAD struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON azureGroupRuleAzureADJSON `json:"-"` +} + +// azureGroupRuleAzureADJSON contains the JSON metadata for the struct +// [AzureGroupRuleAzureAD] +type azureGroupRuleAzureADJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AzureGroupRuleAzureAD) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r azureGroupRuleAzureADJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AzureGroupRuleParam struct { + AzureAD param.Field[AzureGroupRuleAzureADParam] `json:"azureAD,required"` +} + +func (r AzureGroupRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AzureGroupRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type AzureGroupRuleAzureADParam struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AzureGroupRuleAzureADParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type CertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON certificateRuleJSON `json:"-"` +} + +// certificateRuleJSON contains the JSON metadata for the struct [CertificateRule] +type certificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r CertificateRule) implementsZeroTrustAccessRule() {} + +// Matches any valid client certificate. +type CertificateRuleParam struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r CertificateRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r CertificateRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +// Matches a specific country +type CountryRule struct { + Geo CountryRuleGeo `json:"geo,required"` + JSON countryRuleJSON `json:"-"` +} + +// countryRuleJSON contains the JSON metadata for the struct [CountryRule] +type countryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r countryRuleJSON) RawJSON() string { + return r.raw +} + +func (r CountryRule) implementsZeroTrustAccessRule() {} + +type CountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON countryRuleGeoJSON `json:"-"` +} + +// countryRuleGeoJSON contains the JSON metadata for the struct [CountryRuleGeo] +type countryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r countryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type CountryRuleParam struct { + Geo param.Field[CountryRuleGeoParam] `json:"geo,required"` +} + +func (r CountryRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r CountryRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type CountryRuleGeoParam struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r CountryRuleGeoParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type DomainRule struct { + EmailDomain DomainRuleEmailDomain `json:"email_domain,required"` + JSON domainRuleJSON `json:"-"` +} + +// domainRuleJSON contains the JSON metadata for the struct [DomainRule] +type domainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainRuleJSON) RawJSON() string { + return r.raw +} + +func (r DomainRule) implementsZeroTrustAccessRule() {} + +type DomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON domainRuleEmailDomainJSON `json:"-"` +} + +// domainRuleEmailDomainJSON contains the JSON metadata for the struct +// [DomainRuleEmailDomain] +type domainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type DomainRuleParam struct { + EmailDomain param.Field[DomainRuleEmailDomainParam] `json:"email_domain,required"` +} + +func (r DomainRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DomainRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type DomainRuleEmailDomainParam struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r DomainRuleEmailDomainParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type EmailListRule struct { + EmailList EmailListRuleEmailList `json:"email_list,required"` + JSON emailListRuleJSON `json:"-"` +} + +// emailListRuleJSON contains the JSON metadata for the struct [EmailListRule] +type emailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r EmailListRule) implementsZeroTrustAccessRule() {} + +type EmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON emailListRuleEmailListJSON `json:"-"` +} + +// emailListRuleEmailListJSON contains the JSON metadata for the struct +// [EmailListRuleEmailList] +type emailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type EmailListRuleParam struct { + EmailList param.Field[EmailListRuleEmailListParam] `json:"email_list,required"` +} + +func (r EmailListRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r EmailListRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type EmailListRuleEmailListParam struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r EmailListRuleEmailListParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +type EmailRule struct { + Email EmailRuleEmail `json:"email,required"` + JSON emailRuleJSON `json:"-"` +} + +// emailRuleJSON contains the JSON metadata for the struct [EmailRule] +type emailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRuleJSON) RawJSON() string { + return r.raw +} + +func (r EmailRule) implementsZeroTrustAccessRule() {} + +type EmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON emailRuleEmailJSON `json:"-"` +} + +// emailRuleEmailJSON contains the JSON metadata for the struct [EmailRuleEmail] +type emailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches a specific email. +type EmailRuleParam struct { + Email param.Field[EmailRuleEmailParam] `json:"email,required"` +} + +func (r EmailRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r EmailRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type EmailRuleEmailParam struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r EmailRuleEmailParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type EveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON everyoneRuleJSON `json:"-"` +} + +// everyoneRuleJSON contains the JSON metadata for the struct [EveryoneRule] +type everyoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r everyoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r EveryoneRule) implementsZeroTrustAccessRule() {} + +// Matches everyone. +type EveryoneRuleParam struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r EveryoneRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r EveryoneRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type ExternalEvaluationRule struct { + ExternalEvaluation ExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON externalEvaluationRuleJSON `json:"-"` +} + +// externalEvaluationRuleJSON contains the JSON metadata for the struct +// [ExternalEvaluationRule] +type externalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r externalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r ExternalEvaluationRule) implementsZeroTrustAccessRule() {} + +type ExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON externalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// externalEvaluationRuleExternalEvaluationJSON contains the JSON metadata for the +// struct [ExternalEvaluationRuleExternalEvaluation] +type externalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r externalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type ExternalEvaluationRuleParam struct { + ExternalEvaluation param.Field[ExternalEvaluationRuleExternalEvaluationParam] `json:"external_evaluation,required"` +} + +func (r ExternalEvaluationRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ExternalEvaluationRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type ExternalEvaluationRuleExternalEvaluationParam struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r ExternalEvaluationRuleExternalEvaluationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type GitHubOrganizationRule struct { + GitHubOrganization GitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON githubOrganizationRuleJSON `json:"-"` +} + +// githubOrganizationRuleJSON contains the JSON metadata for the struct +// [GitHubOrganizationRule] +type githubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r githubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r GitHubOrganizationRule) implementsZeroTrustAccessRule() {} + +type GitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON githubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// githubOrganizationRuleGitHubOrganizationJSON contains the JSON metadata for the +// struct [GitHubOrganizationRuleGitHubOrganization] +type githubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r githubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type GitHubOrganizationRuleParam struct { + GitHubOrganization param.Field[GitHubOrganizationRuleGitHubOrganizationParam] `json:"github-organization,required"` +} + +func (r GitHubOrganizationRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r GitHubOrganizationRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type GitHubOrganizationRuleGitHubOrganizationParam struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r GitHubOrganizationRuleGitHubOrganizationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Access group. +type GroupRule struct { + Group GroupRuleGroup `json:"group,required"` + JSON groupRuleJSON `json:"-"` +} + +// groupRuleJSON contains the JSON metadata for the struct [GroupRule] +type groupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r groupRuleJSON) RawJSON() string { + return r.raw +} + +func (r GroupRule) implementsZeroTrustAccessRule() {} + +type GroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON groupRuleGroupJSON `json:"-"` +} + +// groupRuleGroupJSON contains the JSON metadata for the struct [GroupRuleGroup] +type groupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r groupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Access group. +type GroupRuleParam struct { + Group param.Field[GroupRuleGroupParam] `json:"group,required"` +} + +func (r GroupRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r GroupRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type GroupRuleGroupParam struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r GroupRuleGroupParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type GSuiteGroupRule struct { + GSuite GSuiteGroupRuleGSuite `json:"gsuite,required"` + JSON GSuiteGroupRuleJSON `json:"-"` +} + +// GSuiteGroupRuleJSON contains the JSON metadata for the struct [GSuiteGroupRule] +type GSuiteGroupRuleJSON struct { + GSuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GSuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r GSuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r GSuiteGroupRule) implementsZeroTrustAccessRule() {} + +type GSuiteGroupRuleGSuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON GSuiteGroupRuleGSuiteJSON `json:"-"` +} + +// GSuiteGroupRuleGSuiteJSON contains the JSON metadata for the struct +// [GSuiteGroupRuleGSuite] +type GSuiteGroupRuleGSuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GSuiteGroupRuleGSuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r GSuiteGroupRuleGSuiteJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type GSuiteGroupRuleParam struct { + GSuite param.Field[GSuiteGroupRuleGSuiteParam] `json:"gsuite,required"` +} + +func (r GSuiteGroupRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r GSuiteGroupRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type GSuiteGroupRuleGSuiteParam struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r GSuiteGroupRuleGSuiteParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type IPListRule struct { + IPList IPListRuleIPList `json:"ip_list,required"` + JSON ipListRuleJSON `json:"-"` +} + +// ipListRuleJSON contains the JSON metadata for the struct [IPListRule] +type ipListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListRuleJSON) RawJSON() string { + return r.raw +} + +func (r IPListRule) implementsZeroTrustAccessRule() {} + +type IPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON ipListRuleIPListJSON `json:"-"` +} + +// ipListRuleIPListJSON contains the JSON metadata for the struct +// [IPListRuleIPList] +type ipListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type IPListRuleParam struct { + IPList param.Field[IPListRuleIPListParam] `json:"ip_list,required"` +} + +func (r IPListRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r IPListRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type IPListRuleIPListParam struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r IPListRuleIPListParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address block. +type IPRule struct { + IP IPRuleIP `json:"ip,required"` + JSON ipRuleJSON `json:"-"` +} + +// ipRuleJSON contains the JSON metadata for the struct [IPRule] +type ipRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipRuleJSON) RawJSON() string { + return r.raw +} + +func (r IPRule) implementsZeroTrustAccessRule() {} + +type IPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON ipRuleIPJSON `json:"-"` +} + +// ipRuleIPJSON contains the JSON metadata for the struct [IPRuleIP] +type ipRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address block. +type IPRuleParam struct { + IP param.Field[IPRuleIPParam] `json:"ip,required"` +} + +func (r IPRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r IPRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type IPRuleIPParam struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r IPRuleIPParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type OktaGroupRule struct { + Okta OktaGroupRuleOkta `json:"okta,required"` + JSON oktaGroupRuleJSON `json:"-"` +} + +// oktaGroupRuleJSON contains the JSON metadata for the struct [OktaGroupRule] +type oktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r oktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r OktaGroupRule) implementsZeroTrustAccessRule() {} + +type OktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON oktaGroupRuleOktaJSON `json:"-"` +} + +// oktaGroupRuleOktaJSON contains the JSON metadata for the struct +// [OktaGroupRuleOkta] +type oktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r oktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type OktaGroupRuleParam struct { + Okta param.Field[OktaGroupRuleOktaParam] `json:"okta,required"` +} + +func (r OktaGroupRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r OktaGroupRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type OktaGroupRuleOktaParam struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r OktaGroupRuleOktaParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type SAMLGroupRule struct { + SAML SAMLGroupRuleSAML `json:"saml,required"` + JSON samlGroupRuleJSON `json:"-"` +} + +// samlGroupRuleJSON contains the JSON metadata for the struct [SAMLGroupRule] +type samlGroupRuleJSON struct { + SAML apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SAMLGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r samlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r SAMLGroupRule) implementsZeroTrustAccessRule() {} + +type SAMLGroupRuleSAML struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON samlGroupRuleSAMLJSON `json:"-"` +} + +// samlGroupRuleSAMLJSON contains the JSON metadata for the struct +// [SAMLGroupRuleSAML] +type samlGroupRuleSAMLJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SAMLGroupRuleSAML) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r samlGroupRuleSAMLJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type SAMLGroupRuleParam struct { + SAML param.Field[SAMLGroupRuleSAMLParam] `json:"saml,required"` +} + +func (r SAMLGroupRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SAMLGroupRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type SAMLGroupRuleSAMLParam struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r SAMLGroupRuleSAMLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type ServiceTokenRule struct { + ServiceToken ServiceTokenRuleServiceToken `json:"service_token,required"` + JSON serviceTokenRuleJSON `json:"-"` +} + +// serviceTokenRuleJSON contains the JSON metadata for the struct +// [ServiceTokenRule] +type serviceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r ServiceTokenRule) implementsZeroTrustAccessRule() {} + +type ServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON serviceTokenRuleServiceTokenJSON `json:"-"` +} + +// serviceTokenRuleServiceTokenJSON contains the JSON metadata for the struct +// [ServiceTokenRuleServiceToken] +type serviceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type ServiceTokenRuleParam struct { + ServiceToken param.Field[ServiceTokenRuleServiceTokenParam] `json:"service_token,required"` +} + +func (r ServiceTokenRuleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceTokenRuleParam) implementsZeroTrustAccessRuleUnionParam() {} + +type ServiceTokenRuleServiceTokenParam struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r ServiceTokenRuleServiceTokenParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} diff --git a/zero_trust/accessapplication.go b/zero_trust/accessapplication.go index bc568a844e7..bc9149da9b5 100644 --- a/zero_trust/accessapplication.go +++ b/zero_trust/accessapplication.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -42,17 +43,17 @@ func NewAccessApplicationService(opts ...option.RequestOption) (r *AccessApplica } // Adds a new application to Access. -func (r *AccessApplicationService) New(ctx context.Context, params AccessApplicationNewParams, opts ...option.RequestOption) (res *ZeroTrustApps, err error) { +func (r *AccessApplicationService) New(ctx context.Context, params AccessApplicationNewParams, opts ...option.RequestOption) (res *Application, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationNewResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if params.getAccountID().Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = params.getAccountID() + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = params.getZoneID() + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/access/apps", accountOrZone, accountOrZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) @@ -64,17 +65,17 @@ func (r *AccessApplicationService) New(ctx context.Context, params AccessApplica } // Updates an Access application. -func (r *AccessApplicationService) Update(ctx context.Context, appID AccessApplicationUpdateParamsSelfHostedApplicationAppID, params AccessApplicationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustApps, err error) { +func (r *AccessApplicationService) Update(ctx context.Context, appID AppIDUnionParam, params AccessApplicationUpdateParams, opts ...option.RequestOption) (res *Application, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationUpdateResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if params.getAccountID().Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = params.getAccountID() + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = params.getZoneID() + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/access/apps/%v", accountOrZone, accountOrZoneID, appID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) @@ -86,7 +87,7 @@ func (r *AccessApplicationService) Update(ctx context.Context, appID AccessAppli } // Lists all Access applications in an account or zone. -func (r *AccessApplicationService) List(ctx context.Context, query AccessApplicationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustApps], err error) { +func (r *AccessApplicationService) List(ctx context.Context, query AccessApplicationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Application], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -113,12 +114,12 @@ func (r *AccessApplicationService) List(ctx context.Context, query AccessApplica } // Lists all Access applications in an account or zone. -func (r *AccessApplicationService) ListAutoPaging(ctx context.Context, query AccessApplicationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustApps] { +func (r *AccessApplicationService) ListAutoPaging(ctx context.Context, query AccessApplicationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Application] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes an application from Access. -func (r *AccessApplicationService) Delete(ctx context.Context, appID AccessApplicationDeleteParamsAppID, body AccessApplicationDeleteParams, opts ...option.RequestOption) (res *AccessApplicationDeleteResponse, err error) { +func (r *AccessApplicationService) Delete(ctx context.Context, appID AppIDUnionParam, body AccessApplicationDeleteParams, opts ...option.RequestOption) (res *AccessApplicationDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationDeleteResponseEnvelope var accountOrZone string @@ -140,7 +141,7 @@ func (r *AccessApplicationService) Delete(ctx context.Context, appID AccessAppli } // Fetches information about an Access application. -func (r *AccessApplicationService) Get(ctx context.Context, appID AccessApplicationGetParamsAppID, query AccessApplicationGetParams, opts ...option.RequestOption) (res *ZeroTrustApps, err error) { +func (r *AccessApplicationService) Get(ctx context.Context, appID AppIDUnionParam, query AccessApplicationGetParams, opts ...option.RequestOption) (res *Application, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationGetResponseEnvelope var accountOrZone string @@ -162,7 +163,7 @@ func (r *AccessApplicationService) Get(ctx context.Context, appID AccessApplicat } // Revokes all tokens issued for an application. -func (r *AccessApplicationService) RevokeTokens(ctx context.Context, appID AccessApplicationRevokeTokensParamsAppID, body AccessApplicationRevokeTokensParams, opts ...option.RequestOption) (res *AccessApplicationRevokeTokensResponse, err error) { +func (r *AccessApplicationService) RevokeTokens(ctx context.Context, appID AppIDUnionParam, body AccessApplicationRevokeTokensParams, opts ...option.RequestOption) (res *AccessApplicationRevokeTokensResponse, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationRevokeTokensResponseEnvelope var accountOrZone string @@ -183,58 +184,213 @@ func (r *AccessApplicationService) RevokeTokens(ctx context.Context, appID Acces return } -// Union satisfied by [zero_trust.ZeroTrustAppsSelfHostedApplication], -// [zero_trust.ZeroTrustAppsSaaSApplication], -// [zero_trust.ZeroTrustAppsBrowserSSHApplication], -// [zero_trust.ZeroTrustAppsBrowserVncApplication], -// [zero_trust.ZeroTrustAppsAppLauncherApplication], -// [zero_trust.ZeroTrustAppsDeviceEnrollmentPermissionsApplication], -// [zero_trust.ZeroTrustAppsBrowserIsolationPermissionsApplication] or -// [zero_trust.ZeroTrustAppsBookmarkApplication]. -type ZeroTrustApps interface { - implementsZeroTrustZeroTrustApps() +type AllowedHeadersh = string + +type AllowedHeadershParam = string + +type AllowedIdpsh = string + +type AllowedIdpshParam = string + +type AllowedMethodsh string + +const ( + AllowedMethodshGet AllowedMethodsh = "GET" + AllowedMethodshPost AllowedMethodsh = "POST" + AllowedMethodshHead AllowedMethodsh = "HEAD" + AllowedMethodshPut AllowedMethodsh = "PUT" + AllowedMethodshDelete AllowedMethodsh = "DELETE" + AllowedMethodshConnect AllowedMethodsh = "CONNECT" + AllowedMethodshOptions AllowedMethodsh = "OPTIONS" + AllowedMethodshTrace AllowedMethodsh = "TRACE" + AllowedMethodshPatch AllowedMethodsh = "PATCH" +) + +func (r AllowedMethodsh) IsKnown() bool { + switch r { + case AllowedMethodshGet, AllowedMethodshPost, AllowedMethodshHead, AllowedMethodshPut, AllowedMethodshDelete, AllowedMethodshConnect, AllowedMethodshOptions, AllowedMethodshTrace, AllowedMethodshPatch: + return true + } + return false +} + +type AllowedOriginsh = string + +type AllowedOriginshParam = string + +// Identifier +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type AppIDUnionParam interface { + ImplementsZeroTrustAppIDUnionParam() +} + +type Application struct { + // Audience tag. + Aud string `json:"aud"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // UUID + ID string `json:"id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. + AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` + AllowedIDPs interface{} `json:"allowed_idps,required"` + // Displays the application in the App Launcher. + AppLauncherVisible bool `json:"app_launcher_visible"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CorsHeaders CorsHeaders `json:"cors_headers"` + // The custom error message shown to a user when they are denied access to the + // application. + CustomDenyMessage string `json:"custom_deny_message"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing identity-based rules. + CustomDenyURL string `json:"custom_deny_url"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing non-identity rules. + CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` + CustomPages interface{} `json:"custom_pages,required"` + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain"` + // Enables the binding cookie, which increases security against compromised + // authorization tokens and CSRF attacks. + EnableBindingCookie bool `json:"enable_binding_cookie"` + // Enables the HttpOnly cookie attribute, which increases security against XSS + // attacks. + HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL string `json:"logo_url"` + // The name of the application. + Name string `json:"name"` + // Enables cookie paths to scope an application's JWT to the application path. If + // disabled, the JWT will scope to the hostname by default + PathCookieAttribute bool `json:"path_cookie_attribute"` + // Sets the SameSite cookie setting, which provides increased security against CSRF + // attacks. + SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` + SelfHostedDomains interface{} `json:"self_hosted_domains,required"` + // Returns a 401 status code when the request is blocked by a Service Auth policy. + ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration string `json:"session_duration"` + // Enables automatic authentication through cloudflared. + SkipInterstitial bool `json:"skip_interstitial"` + Tags interface{} `json:"tags,required"` + // The application type. + Type string `json:"type"` + SaasApp interface{} `json:"saas_app,required"` + JSON applicationJSON `json:"-"` + union ApplicationUnion +} + +// applicationJSON contains the JSON metadata for the struct [Application] +type applicationJSON struct { + Aud apijson.Field + CreatedAt apijson.Field + ID apijson.Field + UpdatedAt apijson.Field + AllowAuthenticateViaWARP apijson.Field + AllowedIDPs apijson.Field + AppLauncherVisible apijson.Field + AutoRedirectToIdentity apijson.Field + CorsHeaders apijson.Field + CustomDenyMessage apijson.Field + CustomDenyURL apijson.Field + CustomNonIdentityDenyURL apijson.Field + CustomPages apijson.Field + Domain apijson.Field + EnableBindingCookie apijson.Field + HTTPOnlyCookieAttribute apijson.Field + LogoURL apijson.Field + Name apijson.Field + PathCookieAttribute apijson.Field + SameSiteCookieAttribute apijson.Field + SelfHostedDomains apijson.Field + ServiceAuth401Redirect apijson.Field + SessionDuration apijson.Field + SkipInterstitial apijson.Field + Tags apijson.Field + Type apijson.Field + SaasApp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r applicationJSON) RawJSON() string { + return r.raw +} + +func (r *Application) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r Application) AsUnion() ApplicationUnion { + return r.union +} + +// Union satisfied by [zero_trust.ApplicationSelfHostedApplication], +// [zero_trust.ApplicationSaaSApplication], +// [zero_trust.ApplicationBrowserSSHApplication], +// [zero_trust.ApplicationBrowserVncApplication], +// [zero_trust.ApplicationAppLauncherApplication], +// [zero_trust.ApplicationDeviceEnrollmentPermissionsApplication], +// [zero_trust.ApplicationBrowserIsolationPermissionsApplication] or +// [zero_trust.ApplicationBookmarkApplication]. +type ApplicationUnion interface { + implementsZeroTrustApplication() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustApps)(nil)).Elem(), + reflect.TypeOf((*ApplicationUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsSelfHostedApplication{}), + Type: reflect.TypeOf(ApplicationSelfHostedApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsSaaSApplication{}), + Type: reflect.TypeOf(ApplicationSaaSApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsBrowserSSHApplication{}), + Type: reflect.TypeOf(ApplicationBrowserSSHApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsBrowserVncApplication{}), + Type: reflect.TypeOf(ApplicationBrowserVncApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsAppLauncherApplication{}), + Type: reflect.TypeOf(ApplicationAppLauncherApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsDeviceEnrollmentPermissionsApplication{}), + Type: reflect.TypeOf(ApplicationDeviceEnrollmentPermissionsApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsBrowserIsolationPermissionsApplication{}), + Type: reflect.TypeOf(ApplicationBrowserIsolationPermissionsApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsBookmarkApplication{}), + Type: reflect.TypeOf(ApplicationBookmarkApplication{}), }, ) } -type ZeroTrustAppsSelfHostedApplication struct { +type ApplicationSelfHostedApplication struct { // The primary hostname and path that Access will secure. If the app is visible in // the App Launcher dashboard, this is the domain that will be displayed. Domain string `json:"domain,required"` @@ -249,16 +405,16 @@ type ZeroTrustAppsSelfHostedApplication struct { AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs []string `json:"allowed_idps"` + AllowedIDPs []AllowedIdpsh `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible bool `json:"app_launcher_visible"` // Audience tag. Aud string `json:"aud"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAppsSelfHostedApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CorsHeaders CorsHeaders `json:"cors_headers"` + CreatedAt time.Time `json:"created_at" format:"date-time"` // The custom error message shown to a user when they are denied access to the // application. CustomDenyMessage string `json:"custom_deny_message"` @@ -269,7 +425,7 @@ type ZeroTrustAppsSelfHostedApplication struct { // application when failing non-identity rules. CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` + CustomPages []CustomPagesh `json:"custom_pages"` // Enables the binding cookie, which increases security against compromised // authorization tokens and CSRF attacks. EnableBindingCookie bool `json:"enable_binding_cookie"` @@ -287,7 +443,7 @@ type ZeroTrustAppsSelfHostedApplication struct { // attacks. SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` + SelfHostedDomains []SelfHostedDomainsh `json:"self_hosted_domains"` // Returns a 401 status code when the request is blocked by a Service Auth policy. ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` // The amount of time that tokens issued for this application will be valid. Must @@ -298,14 +454,14 @@ type ZeroTrustAppsSelfHostedApplication struct { SkipInterstitial bool `json:"skip_interstitial"` // The tags you want assigned to an application. Tags are used to filter // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsSelfHostedApplicationJSON `json:"-"` + Tags []string `json:"tags"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationSelfHostedApplicationJSON `json:"-"` } -// zeroTrustAppsSelfHostedApplicationJSON contains the JSON metadata for the struct -// [ZeroTrustAppsSelfHostedApplication] -type zeroTrustAppsSelfHostedApplicationJSON struct { +// applicationSelfHostedApplicationJSON contains the JSON metadata for the struct +// [ApplicationSelfHostedApplication] +type applicationSelfHostedApplicationJSON struct { Domain apijson.Field Type apijson.Field ID apijson.Field @@ -336,88 +492,22 @@ type zeroTrustAppsSelfHostedApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsSelfHostedApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAppsSelfHostedApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAppsSelfHostedApplication) implementsZeroTrustZeroTrustApps() {} - -type ZeroTrustAppsSelfHostedApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []string `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []string `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAppsSelfHostedApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAppsSelfHostedApplicationCorsHeadersJSON contains the JSON metadata for -// the struct [ZeroTrustAppsSelfHostedApplicationCorsHeaders] -type zeroTrustAppsSelfHostedApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAppsSelfHostedApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationSelfHostedApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsSelfHostedApplicationCorsHeadersJSON) RawJSON() string { +func (r applicationSelfHostedApplicationJSON) RawJSON() string { return r.raw } -type ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodGet ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodPost ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodHead ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodPut ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodDelete ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodConnect ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodOptions ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodTrace ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodPatch ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodGet, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodPost, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodHead, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodPut, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodDelete, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodConnect, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodOptions, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodTrace, ZeroTrustAppsSelfHostedApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} +func (r ApplicationSelfHostedApplication) implementsZeroTrustApplication() {} -type ZeroTrustAppsSaaSApplication struct { +type ApplicationSaaSApplication struct { // UUID ID string `json:"id"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs []string `json:"allowed_idps"` + AllowedIDPs []AllowedIdpsh `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible bool `json:"app_launcher_visible"` // Audience tag. @@ -427,24 +517,24 @@ type ZeroTrustAppsSaaSApplication struct { AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` CreatedAt time.Time `json:"created_at" format:"date-time"` // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` + CustomPages []CustomPagesh `json:"custom_pages"` // The image URL for the logo shown in the App Launcher dashboard. LogoURL string `json:"logo_url"` // The name of the application. - Name string `json:"name"` - SaasApp ZeroTrustAppsSaaSApplicationSaasApp `json:"saas_app"` + Name string `json:"name"` + SaasApp ApplicationSaaSApplicationSaasApp `json:"saas_app"` // The tags you want assigned to an application. Tags are used to filter // applications in the App Launcher dashboard. Tags []string `json:"tags"` // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsSaaSApplicationJSON `json:"-"` + Type string `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationSaaSApplicationJSON `json:"-"` } -// zeroTrustAppsSaaSApplicationJSON contains the JSON metadata for the struct -// [ZeroTrustAppsSaaSApplication] -type zeroTrustAppsSaaSApplicationJSON struct { +// applicationSaaSApplicationJSON contains the JSON metadata for the struct +// [ApplicationSaaSApplication] +type applicationSaaSApplicationJSON struct { ID apijson.Field AllowedIDPs apijson.Field AppLauncherVisible apijson.Field @@ -462,54 +552,32 @@ type zeroTrustAppsSaaSApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsSaaSApplication) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationSaaSApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsSaaSApplicationJSON) RawJSON() string { +func (r applicationSaaSApplicationJSON) RawJSON() string { return r.raw } -func (r ZeroTrustAppsSaaSApplication) implementsZeroTrustZeroTrustApps() {} - -// Union satisfied by -// [zero_trust.ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasApp] or -// [zero_trust.ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasApp]. -type ZeroTrustAppsSaaSApplicationSaasApp interface { - implementsZeroTrustZeroTrustAppsSaaSApplicationSaasApp() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAppsSaaSApplicationSaasApp)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasApp{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasApp{}), - }, - ) -} +func (r ApplicationSaaSApplication) implementsZeroTrustApplication() {} -type ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasApp struct { +type ApplicationSaaSApplicationSaasApp struct { // Optional identifier indicating the authentication protocol used for the saas // app. Required for OIDC. Default if unset is "saml" - AuthType ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType `json:"auth_type"` + AuthType ApplicationSaaSApplicationSaasAppAuthType `json:"auth_type"` // The service provider's endpoint that is responsible for receiving and parsing a // SAML assertion. - ConsumerServiceURL string `json:"consumer_service_url"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomAttributes ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes `json:"custom_attributes"` + ConsumerServiceURL string `json:"consumer_service_url"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + CustomAttributes interface{} `json:"custom_attributes,required"` // The URL that the user will be redirected to after a successful login for IDP // initiated logins. DefaultRelayState string `json:"default_relay_state"` // The unique identifier for your SaaS application. IDPEntityID string `json:"idp_entity_id"` // The format of the name identifier sent to the SaaS application. - NameIDFormat ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat `json:"name_id_format"` + NameIDFormat SaasAppNameIDFormat `json:"name_id_format"` // A [JSONata](https://jsonata.org/) expression that transforms an application's // user identities into a NameID value for its SAML assertion. This expression // should evaluate to a singular string. The output of this expression can override @@ -522,18 +590,30 @@ type ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasApp struct { // can transform id, email, name, and groups values. It can also transform fields // listed in the saml_attributes or oidc_fields of the identity provider used to // authenticate. The output of this expression must be a JSON object. - SamlAttributeTransformJsonata string `json:"saml_attribute_transform_jsonata"` + SAMLAttributeTransformJsonata string `json:"saml_attribute_transform_jsonata"` // A globally unique name for an identity or service provider. SpEntityID string `json:"sp_entity_id"` // The endpoint where your SaaS application will send login requests. - SSOEndpoint string `json:"sso_endpoint"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON `json:"-"` + SSOEndpoint string `json:"sso_endpoint"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + // The URL where this applications tile redirects users + AppLauncherURL string `json:"app_launcher_url"` + // The application client id + ClientID string `json:"client_id"` + // The application client secret, only returned on POST request. + ClientSecret string `json:"client_secret"` + GrantTypes interface{} `json:"grant_types,required"` + // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint + GroupFilterRegex string `json:"group_filter_regex"` + RedirectURIs interface{} `json:"redirect_uris,required"` + Scopes interface{} `json:"scopes,required"` + JSON applicationSaaSApplicationSaasAppJSON `json:"-"` + union ApplicationSaaSApplicationSaasAppUnion } -// zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON contains the JSON -// metadata for the struct [ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasApp] -type zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON struct { +// applicationSaaSApplicationSaasAppJSON contains the JSON metadata for the struct +// [ApplicationSaaSApplicationSaasApp] +type applicationSaaSApplicationSaasAppJSON struct { AuthType apijson.Field ConsumerServiceURL apijson.Field CreatedAt apijson.Field @@ -543,139 +623,71 @@ type zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON struct { NameIDFormat apijson.Field NameIDTransformJsonata apijson.Field PublicKey apijson.Field - SamlAttributeTransformJsonata apijson.Field + SAMLAttributeTransformJsonata apijson.Field SpEntityID apijson.Field SSOEndpoint apijson.Field UpdatedAt apijson.Field + AppLauncherURL apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + GrantTypes apijson.Field + GroupFilterRegex apijson.Field + RedirectURIs apijson.Field + Scopes apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustZeroTrustAppsSaaSApplicationSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType string - -const ( - ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" - ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType) IsKnown() bool { - switch r { - case ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml, ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc: - return true - } - return false -} - -type ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name string `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat `json:"name_format"` - Source ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource `json:"source"` - JSON zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON `json:"-"` -} - -// zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON -// contains the JSON metadata for the struct -// [ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] -type zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON struct { - Name apijson.Field - NameFormat apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON) RawJSON() string { +func (r applicationSaaSApplicationSaasAppJSON) RawJSON() string { return r.raw } -// A globally unique name for an identity or service provider. -type ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat) IsKnown() bool { - switch r { - case ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified, ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic, ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI: - return true +func (r *ApplicationSaaSApplicationSaasApp) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err } - return false -} - -type ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name string `json:"name"` - JSON zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON `json:"-"` -} - -// zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON -// contains the JSON metadata for the struct -// [ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] -type zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field + return apijson.Port(r.union, &r) } -func (r *ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r ApplicationSaaSApplicationSaasApp) AsUnion() ApplicationSaaSApplicationSaasAppUnion { + return r.union } -func (r zeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON) RawJSON() string { - return r.raw +// Union satisfied by [zero_trust.SAMLSaasApp] or +// [zero_trust.ApplicationSaaSApplicationSaasAppAccessOIDCSaasApp]. +type ApplicationSaaSApplicationSaasAppUnion interface { + implementsZeroTrustApplicationSaaSApplicationSaasApp() } -// The format of the name identifier sent to the SaaS application. -type ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" - ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat) IsKnown() bool { - switch r { - case ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID, ZeroTrustAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ApplicationSaaSApplicationSaasAppUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SAMLSaasApp{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ApplicationSaaSApplicationSaasAppAccessOIDCSaasApp{}), + }, + ) } -type ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasApp struct { +type ApplicationSaaSApplicationSaasAppAccessOIDCSaasApp struct { // The URL where this applications tile redirects users AppLauncherURL string `json:"app_launcher_url"` // Identifier of the authentication protocol used for the saas app. Required for // OIDC. - AuthType ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType `json:"auth_type"` + AuthType ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthType `json:"auth_type"` // The application client id ClientID string `json:"client_id"` // The application client secret, only returned on POST request. ClientSecret string `json:"client_secret"` CreatedAt time.Time `json:"created_at" format:"date-time"` // The OIDC flows supported by this application - GrantTypes []ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType `json:"grant_types"` + GrantTypes []ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantType `json:"grant_types"` // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint GroupFilterRegex string `json:"group_filter_regex"` // The Access public certificate that will be used to verify your identity. @@ -684,14 +696,14 @@ type ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasApp struct { // tokens RedirectURIs []string `json:"redirect_uris"` // Define the user information shared with access - Scopes []ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScope `json:"scopes"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON `json:"-"` + Scopes []ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope `json:"scopes"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationSaaSApplicationSaasAppAccessOIDCSaasAppJSON `json:"-"` } -// zeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON contains the JSON -// metadata for the struct [ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasApp] -type zeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON struct { +// applicationSaaSApplicationSaasAppAccessOIDCSaasAppJSON contains the JSON +// metadata for the struct [ApplicationSaaSApplicationSaasAppAccessOIDCSaasApp] +type applicationSaaSApplicationSaasAppAccessOIDCSaasAppJSON struct { AppLauncherURL apijson.Field AuthType apijson.Field ClientID apijson.Field @@ -707,91 +719,108 @@ type zeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasApp) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationSaaSApplicationSaasAppAccessOIDCSaasApp) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON) RawJSON() string { +func (r applicationSaaSApplicationSaasAppAccessOIDCSaasAppJSON) RawJSON() string { return r.raw } -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustZeroTrustAppsSaaSApplicationSaasApp() { +func (r ApplicationSaaSApplicationSaasAppAccessOIDCSaasApp) implementsZeroTrustApplicationSaaSApplicationSaasApp() { } // Identifier of the authentication protocol used for the saas app. Required for // OIDC. -type ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType string +type ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthType string const ( - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthTypeSAML ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthType = "saml" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthTypeOIDC ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthType = "oidc" ) -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType) IsKnown() bool { +func (r ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthType) IsKnown() bool { switch r { - case ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml, ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc: + case ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthTypeSAML, ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthTypeOIDC: return true } return false } -type ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType string +type ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantType string const ( - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantTypeAuthorizationCode ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantType = "authorization_code" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantTypeAuthorizationCodeWithPkce ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantType = "authorization_code_with_pkce" ) -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType) IsKnown() bool { +func (r ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantType) IsKnown() bool { switch r { - case ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode, ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce: + case ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantTypeAuthorizationCode, ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantTypeAuthorizationCodeWithPkce: return true } return false } -type ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScope string +type ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope string const ( - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" - ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeOpenid ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope = "openid" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeGroups ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope = "groups" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeEmail ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope = "email" + ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeProfile ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope = "profile" ) -func (r ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScope) IsKnown() bool { +func (r ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope) IsKnown() bool { switch r { - case ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid, ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups, ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail, ZeroTrustAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile: + case ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeOpenid, ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeGroups, ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeEmail, ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScopeProfile: return true } return false } -type ZeroTrustAppsBrowserSSHApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. +// Optional identifier indicating the authentication protocol used for the saas +// app. Required for OIDC. Default if unset is "saml" +type ApplicationSaaSApplicationSaasAppAuthType string + +const ( + ApplicationSaaSApplicationSaasAppAuthTypeSAML ApplicationSaaSApplicationSaasAppAuthType = "saml" + ApplicationSaaSApplicationSaasAppAuthTypeOIDC ApplicationSaaSApplicationSaasAppAuthType = "oidc" +) + +func (r ApplicationSaaSApplicationSaasAppAuthType) IsKnown() bool { + switch r { + case ApplicationSaaSApplicationSaasAppAuthTypeSAML, ApplicationSaaSApplicationSaasAppAuthTypeOIDC: + return true + } + return false +} + +type ApplicationBrowserSSHApplication struct { + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain,required"` + // The application type. + Type string `json:"type,required"` + // UUID + ID string `json:"id"` + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs []string `json:"allowed_idps"` + AllowedIDPs []AllowedIdpsh `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible bool `json:"app_launcher_visible"` // Audience tag. Aud string `json:"aud"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAppsBrowserSSHApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CorsHeaders CorsHeaders `json:"cors_headers"` + CreatedAt time.Time `json:"created_at" format:"date-time"` // The custom error message shown to a user when they are denied access to the // application. CustomDenyMessage string `json:"custom_deny_message"` @@ -802,7 +831,7 @@ type ZeroTrustAppsBrowserSSHApplication struct { // application when failing non-identity rules. CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` + CustomPages []CustomPagesh `json:"custom_pages"` // Enables the binding cookie, which increases security against compromised // authorization tokens and CSRF attacks. EnableBindingCookie bool `json:"enable_binding_cookie"` @@ -820,7 +849,7 @@ type ZeroTrustAppsBrowserSSHApplication struct { // attacks. SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` + SelfHostedDomains []SelfHostedDomainsh `json:"self_hosted_domains"` // Returns a 401 status code when the request is blocked by a Service Auth policy. ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` // The amount of time that tokens issued for this application will be valid. Must @@ -831,14 +860,14 @@ type ZeroTrustAppsBrowserSSHApplication struct { SkipInterstitial bool `json:"skip_interstitial"` // The tags you want assigned to an application. Tags are used to filter // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsBrowserSSHApplicationJSON `json:"-"` + Tags []string `json:"tags"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationBrowserSSHApplicationJSON `json:"-"` } -// zeroTrustAppsBrowserSSHApplicationJSON contains the JSON metadata for the struct -// [ZeroTrustAppsBrowserSSHApplication] -type zeroTrustAppsBrowserSSHApplicationJSON struct { +// applicationBrowserSSHApplicationJSON contains the JSON metadata for the struct +// [ApplicationBrowserSSHApplication] +type applicationBrowserSSHApplicationJSON struct { Domain apijson.Field Type apijson.Field ID apijson.Field @@ -869,83 +898,17 @@ type zeroTrustAppsBrowserSSHApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsBrowserSSHApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAppsBrowserSSHApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAppsBrowserSSHApplication) implementsZeroTrustZeroTrustApps() {} - -type ZeroTrustAppsBrowserSSHApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []string `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []string `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAppsBrowserSSHApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAppsBrowserSSHApplicationCorsHeadersJSON contains the JSON metadata for -// the struct [ZeroTrustAppsBrowserSSHApplicationCorsHeaders] -type zeroTrustAppsBrowserSSHApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAppsBrowserSSHApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationBrowserSSHApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsBrowserSSHApplicationCorsHeadersJSON) RawJSON() string { +func (r applicationBrowserSSHApplicationJSON) RawJSON() string { return r.raw } -type ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodGet ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodPost ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodHead ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodPut ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodDelete ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodConnect ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodOptions ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodTrace ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodPatch ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodGet, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodPost, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodHead, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodPut, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodDelete, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodConnect, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodOptions, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodTrace, ZeroTrustAppsBrowserSSHApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} +func (r ApplicationBrowserSSHApplication) implementsZeroTrustApplication() {} -type ZeroTrustAppsBrowserVncApplication struct { +type ApplicationBrowserVncApplication struct { // The primary hostname and path that Access will secure. If the app is visible in // the App Launcher dashboard, this is the domain that will be displayed. Domain string `json:"domain,required"` @@ -960,16 +923,16 @@ type ZeroTrustAppsBrowserVncApplication struct { AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs []string `json:"allowed_idps"` + AllowedIDPs []AllowedIdpsh `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible bool `json:"app_launcher_visible"` // Audience tag. Aud string `json:"aud"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAppsBrowserVncApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CorsHeaders CorsHeaders `json:"cors_headers"` + CreatedAt time.Time `json:"created_at" format:"date-time"` // The custom error message shown to a user when they are denied access to the // application. CustomDenyMessage string `json:"custom_deny_message"` @@ -980,7 +943,7 @@ type ZeroTrustAppsBrowserVncApplication struct { // application when failing non-identity rules. CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` + CustomPages []CustomPagesh `json:"custom_pages"` // Enables the binding cookie, which increases security against compromised // authorization tokens and CSRF attacks. EnableBindingCookie bool `json:"enable_binding_cookie"` @@ -998,7 +961,7 @@ type ZeroTrustAppsBrowserVncApplication struct { // attacks. SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` + SelfHostedDomains []SelfHostedDomainsh `json:"self_hosted_domains"` // Returns a 401 status code when the request is blocked by a Service Auth policy. ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` // The amount of time that tokens issued for this application will be valid. Must @@ -1009,14 +972,14 @@ type ZeroTrustAppsBrowserVncApplication struct { SkipInterstitial bool `json:"skip_interstitial"` // The tags you want assigned to an application. Tags are used to filter // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsBrowserVncApplicationJSON `json:"-"` + Tags []string `json:"tags"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationBrowserVncApplicationJSON `json:"-"` } -// zeroTrustAppsBrowserVncApplicationJSON contains the JSON metadata for the struct -// [ZeroTrustAppsBrowserVncApplication] -type zeroTrustAppsBrowserVncApplicationJSON struct { +// applicationBrowserVncApplicationJSON contains the JSON metadata for the struct +// [ApplicationBrowserVncApplication] +type applicationBrowserVncApplicationJSON struct { Domain apijson.Field Type apijson.Field ID apijson.Field @@ -1047,90 +1010,24 @@ type zeroTrustAppsBrowserVncApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsBrowserVncApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAppsBrowserVncApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAppsBrowserVncApplication) implementsZeroTrustZeroTrustApps() {} - -type ZeroTrustAppsBrowserVncApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []string `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []string `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAppsBrowserVncApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAppsBrowserVncApplicationCorsHeadersJSON contains the JSON metadata for -// the struct [ZeroTrustAppsBrowserVncApplicationCorsHeaders] -type zeroTrustAppsBrowserVncApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAppsBrowserVncApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationBrowserVncApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsBrowserVncApplicationCorsHeadersJSON) RawJSON() string { +func (r applicationBrowserVncApplicationJSON) RawJSON() string { return r.raw } -type ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodGet ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodPost ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodHead ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodPut ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodDelete ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodConnect ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodOptions ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodTrace ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodPatch ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodGet, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodPost, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodHead, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodPut, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodDelete, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodConnect, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodOptions, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodTrace, ZeroTrustAppsBrowserVncApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} +func (r ApplicationBrowserVncApplication) implementsZeroTrustApplication() {} -type ZeroTrustAppsAppLauncherApplication struct { +type ApplicationAppLauncherApplication struct { // The application type. - Type ZeroTrustAppsAppLauncherApplicationType `json:"type,required"` + Type ApplicationAppLauncherApplicationType `json:"type,required"` // UUID ID string `json:"id"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs []string `json:"allowed_idps"` + AllowedIDPs []AllowedIdpsh `json:"allowed_idps"` // Audience tag. Aud string `json:"aud"` // When set to `true`, users skip the identity provider selection step during @@ -1145,14 +1042,14 @@ type ZeroTrustAppsAppLauncherApplication struct { // The amount of time that tokens issued for this application will be valid. Must // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsAppLauncherApplicationJSON `json:"-"` + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationAppLauncherApplicationJSON `json:"-"` } -// zeroTrustAppsAppLauncherApplicationJSON contains the JSON metadata for the -// struct [ZeroTrustAppsAppLauncherApplication] -type zeroTrustAppsAppLauncherApplicationJSON struct { +// applicationAppLauncherApplicationJSON contains the JSON metadata for the struct +// [ApplicationAppLauncherApplication] +type applicationAppLauncherApplicationJSON struct { Type apijson.Field ID apijson.Field AllowedIDPs apijson.Field @@ -1167,47 +1064,47 @@ type zeroTrustAppsAppLauncherApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsAppLauncherApplication) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationAppLauncherApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsAppLauncherApplicationJSON) RawJSON() string { +func (r applicationAppLauncherApplicationJSON) RawJSON() string { return r.raw } -func (r ZeroTrustAppsAppLauncherApplication) implementsZeroTrustZeroTrustApps() {} +func (r ApplicationAppLauncherApplication) implementsZeroTrustApplication() {} // The application type. -type ZeroTrustAppsAppLauncherApplicationType string +type ApplicationAppLauncherApplicationType string const ( - ZeroTrustAppsAppLauncherApplicationTypeSelfHosted ZeroTrustAppsAppLauncherApplicationType = "self_hosted" - ZeroTrustAppsAppLauncherApplicationTypeSaas ZeroTrustAppsAppLauncherApplicationType = "saas" - ZeroTrustAppsAppLauncherApplicationTypeSSH ZeroTrustAppsAppLauncherApplicationType = "ssh" - ZeroTrustAppsAppLauncherApplicationTypeVnc ZeroTrustAppsAppLauncherApplicationType = "vnc" - ZeroTrustAppsAppLauncherApplicationTypeAppLauncher ZeroTrustAppsAppLauncherApplicationType = "app_launcher" - ZeroTrustAppsAppLauncherApplicationTypeWARP ZeroTrustAppsAppLauncherApplicationType = "warp" - ZeroTrustAppsAppLauncherApplicationTypeBiso ZeroTrustAppsAppLauncherApplicationType = "biso" - ZeroTrustAppsAppLauncherApplicationTypeBookmark ZeroTrustAppsAppLauncherApplicationType = "bookmark" - ZeroTrustAppsAppLauncherApplicationTypeDashSSO ZeroTrustAppsAppLauncherApplicationType = "dash_sso" + ApplicationAppLauncherApplicationTypeSelfHosted ApplicationAppLauncherApplicationType = "self_hosted" + ApplicationAppLauncherApplicationTypeSaas ApplicationAppLauncherApplicationType = "saas" + ApplicationAppLauncherApplicationTypeSSH ApplicationAppLauncherApplicationType = "ssh" + ApplicationAppLauncherApplicationTypeVnc ApplicationAppLauncherApplicationType = "vnc" + ApplicationAppLauncherApplicationTypeAppLauncher ApplicationAppLauncherApplicationType = "app_launcher" + ApplicationAppLauncherApplicationTypeWARP ApplicationAppLauncherApplicationType = "warp" + ApplicationAppLauncherApplicationTypeBiso ApplicationAppLauncherApplicationType = "biso" + ApplicationAppLauncherApplicationTypeBookmark ApplicationAppLauncherApplicationType = "bookmark" + ApplicationAppLauncherApplicationTypeDashSSO ApplicationAppLauncherApplicationType = "dash_sso" ) -func (r ZeroTrustAppsAppLauncherApplicationType) IsKnown() bool { +func (r ApplicationAppLauncherApplicationType) IsKnown() bool { switch r { - case ZeroTrustAppsAppLauncherApplicationTypeSelfHosted, ZeroTrustAppsAppLauncherApplicationTypeSaas, ZeroTrustAppsAppLauncherApplicationTypeSSH, ZeroTrustAppsAppLauncherApplicationTypeVnc, ZeroTrustAppsAppLauncherApplicationTypeAppLauncher, ZeroTrustAppsAppLauncherApplicationTypeWARP, ZeroTrustAppsAppLauncherApplicationTypeBiso, ZeroTrustAppsAppLauncherApplicationTypeBookmark, ZeroTrustAppsAppLauncherApplicationTypeDashSSO: + case ApplicationAppLauncherApplicationTypeSelfHosted, ApplicationAppLauncherApplicationTypeSaas, ApplicationAppLauncherApplicationTypeSSH, ApplicationAppLauncherApplicationTypeVnc, ApplicationAppLauncherApplicationTypeAppLauncher, ApplicationAppLauncherApplicationTypeWARP, ApplicationAppLauncherApplicationTypeBiso, ApplicationAppLauncherApplicationTypeBookmark, ApplicationAppLauncherApplicationTypeDashSSO: return true } return false } -type ZeroTrustAppsDeviceEnrollmentPermissionsApplication struct { +type ApplicationDeviceEnrollmentPermissionsApplication struct { // The application type. - Type ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType `json:"type,required"` + Type ApplicationDeviceEnrollmentPermissionsApplicationType `json:"type,required"` // UUID ID string `json:"id"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs []string `json:"allowed_idps"` + AllowedIDPs []AllowedIdpsh `json:"allowed_idps"` // Audience tag. Aud string `json:"aud"` // When set to `true`, users skip the identity provider selection step during @@ -1222,14 +1119,14 @@ type ZeroTrustAppsDeviceEnrollmentPermissionsApplication struct { // The amount of time that tokens issued for this application will be valid. Must // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsDeviceEnrollmentPermissionsApplicationJSON `json:"-"` + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationDeviceEnrollmentPermissionsApplicationJSON `json:"-"` } -// zeroTrustAppsDeviceEnrollmentPermissionsApplicationJSON contains the JSON -// metadata for the struct [ZeroTrustAppsDeviceEnrollmentPermissionsApplication] -type zeroTrustAppsDeviceEnrollmentPermissionsApplicationJSON struct { +// applicationDeviceEnrollmentPermissionsApplicationJSON contains the JSON metadata +// for the struct [ApplicationDeviceEnrollmentPermissionsApplication] +type applicationDeviceEnrollmentPermissionsApplicationJSON struct { Type apijson.Field ID apijson.Field AllowedIDPs apijson.Field @@ -1244,47 +1141,47 @@ type zeroTrustAppsDeviceEnrollmentPermissionsApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsDeviceEnrollmentPermissionsApplication) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationDeviceEnrollmentPermissionsApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsDeviceEnrollmentPermissionsApplicationJSON) RawJSON() string { +func (r applicationDeviceEnrollmentPermissionsApplicationJSON) RawJSON() string { return r.raw } -func (r ZeroTrustAppsDeviceEnrollmentPermissionsApplication) implementsZeroTrustZeroTrustApps() {} +func (r ApplicationDeviceEnrollmentPermissionsApplication) implementsZeroTrustApplication() {} // The application type. -type ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType string +type ApplicationDeviceEnrollmentPermissionsApplicationType string const ( - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeSelfHosted ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "self_hosted" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeSaas ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "saas" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeSSH ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "ssh" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeVnc ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "vnc" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeAppLauncher ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "app_launcher" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeWARP ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "warp" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeBiso ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "biso" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeBookmark ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "bookmark" - ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeDashSSO ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType = "dash_sso" + ApplicationDeviceEnrollmentPermissionsApplicationTypeSelfHosted ApplicationDeviceEnrollmentPermissionsApplicationType = "self_hosted" + ApplicationDeviceEnrollmentPermissionsApplicationTypeSaas ApplicationDeviceEnrollmentPermissionsApplicationType = "saas" + ApplicationDeviceEnrollmentPermissionsApplicationTypeSSH ApplicationDeviceEnrollmentPermissionsApplicationType = "ssh" + ApplicationDeviceEnrollmentPermissionsApplicationTypeVnc ApplicationDeviceEnrollmentPermissionsApplicationType = "vnc" + ApplicationDeviceEnrollmentPermissionsApplicationTypeAppLauncher ApplicationDeviceEnrollmentPermissionsApplicationType = "app_launcher" + ApplicationDeviceEnrollmentPermissionsApplicationTypeWARP ApplicationDeviceEnrollmentPermissionsApplicationType = "warp" + ApplicationDeviceEnrollmentPermissionsApplicationTypeBiso ApplicationDeviceEnrollmentPermissionsApplicationType = "biso" + ApplicationDeviceEnrollmentPermissionsApplicationTypeBookmark ApplicationDeviceEnrollmentPermissionsApplicationType = "bookmark" + ApplicationDeviceEnrollmentPermissionsApplicationTypeDashSSO ApplicationDeviceEnrollmentPermissionsApplicationType = "dash_sso" ) -func (r ZeroTrustAppsDeviceEnrollmentPermissionsApplicationType) IsKnown() bool { +func (r ApplicationDeviceEnrollmentPermissionsApplicationType) IsKnown() bool { switch r { - case ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeSelfHosted, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeSaas, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeSSH, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeVnc, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeAppLauncher, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeWARP, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeBiso, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeBookmark, ZeroTrustAppsDeviceEnrollmentPermissionsApplicationTypeDashSSO: + case ApplicationDeviceEnrollmentPermissionsApplicationTypeSelfHosted, ApplicationDeviceEnrollmentPermissionsApplicationTypeSaas, ApplicationDeviceEnrollmentPermissionsApplicationTypeSSH, ApplicationDeviceEnrollmentPermissionsApplicationTypeVnc, ApplicationDeviceEnrollmentPermissionsApplicationTypeAppLauncher, ApplicationDeviceEnrollmentPermissionsApplicationTypeWARP, ApplicationDeviceEnrollmentPermissionsApplicationTypeBiso, ApplicationDeviceEnrollmentPermissionsApplicationTypeBookmark, ApplicationDeviceEnrollmentPermissionsApplicationTypeDashSSO: return true } return false } -type ZeroTrustAppsBrowserIsolationPermissionsApplication struct { +type ApplicationBrowserIsolationPermissionsApplication struct { // The application type. - Type ZeroTrustAppsBrowserIsolationPermissionsApplicationType `json:"type,required"` + Type ApplicationBrowserIsolationPermissionsApplicationType `json:"type,required"` // UUID ID string `json:"id"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs []string `json:"allowed_idps"` + AllowedIDPs []AllowedIdpsh `json:"allowed_idps"` // Audience tag. Aud string `json:"aud"` // When set to `true`, users skip the identity provider selection step during @@ -1299,14 +1196,14 @@ type ZeroTrustAppsBrowserIsolationPermissionsApplication struct { // The amount of time that tokens issued for this application will be valid. Must // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsBrowserIsolationPermissionsApplicationJSON `json:"-"` + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationBrowserIsolationPermissionsApplicationJSON `json:"-"` } -// zeroTrustAppsBrowserIsolationPermissionsApplicationJSON contains the JSON -// metadata for the struct [ZeroTrustAppsBrowserIsolationPermissionsApplication] -type zeroTrustAppsBrowserIsolationPermissionsApplicationJSON struct { +// applicationBrowserIsolationPermissionsApplicationJSON contains the JSON metadata +// for the struct [ApplicationBrowserIsolationPermissionsApplication] +type applicationBrowserIsolationPermissionsApplicationJSON struct { Type apijson.Field ID apijson.Field AllowedIDPs apijson.Field @@ -1321,40 +1218,40 @@ type zeroTrustAppsBrowserIsolationPermissionsApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsBrowserIsolationPermissionsApplication) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationBrowserIsolationPermissionsApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsBrowserIsolationPermissionsApplicationJSON) RawJSON() string { +func (r applicationBrowserIsolationPermissionsApplicationJSON) RawJSON() string { return r.raw } -func (r ZeroTrustAppsBrowserIsolationPermissionsApplication) implementsZeroTrustZeroTrustApps() {} +func (r ApplicationBrowserIsolationPermissionsApplication) implementsZeroTrustApplication() {} // The application type. -type ZeroTrustAppsBrowserIsolationPermissionsApplicationType string +type ApplicationBrowserIsolationPermissionsApplicationType string const ( - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeSelfHosted ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "self_hosted" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeSaas ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "saas" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeSSH ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "ssh" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeVnc ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "vnc" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeAppLauncher ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "app_launcher" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeWARP ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "warp" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeBiso ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "biso" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeBookmark ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "bookmark" - ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeDashSSO ZeroTrustAppsBrowserIsolationPermissionsApplicationType = "dash_sso" + ApplicationBrowserIsolationPermissionsApplicationTypeSelfHosted ApplicationBrowserIsolationPermissionsApplicationType = "self_hosted" + ApplicationBrowserIsolationPermissionsApplicationTypeSaas ApplicationBrowserIsolationPermissionsApplicationType = "saas" + ApplicationBrowserIsolationPermissionsApplicationTypeSSH ApplicationBrowserIsolationPermissionsApplicationType = "ssh" + ApplicationBrowserIsolationPermissionsApplicationTypeVnc ApplicationBrowserIsolationPermissionsApplicationType = "vnc" + ApplicationBrowserIsolationPermissionsApplicationTypeAppLauncher ApplicationBrowserIsolationPermissionsApplicationType = "app_launcher" + ApplicationBrowserIsolationPermissionsApplicationTypeWARP ApplicationBrowserIsolationPermissionsApplicationType = "warp" + ApplicationBrowserIsolationPermissionsApplicationTypeBiso ApplicationBrowserIsolationPermissionsApplicationType = "biso" + ApplicationBrowserIsolationPermissionsApplicationTypeBookmark ApplicationBrowserIsolationPermissionsApplicationType = "bookmark" + ApplicationBrowserIsolationPermissionsApplicationTypeDashSSO ApplicationBrowserIsolationPermissionsApplicationType = "dash_sso" ) -func (r ZeroTrustAppsBrowserIsolationPermissionsApplicationType) IsKnown() bool { +func (r ApplicationBrowserIsolationPermissionsApplicationType) IsKnown() bool { switch r { - case ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeSelfHosted, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeSaas, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeSSH, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeVnc, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeAppLauncher, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeWARP, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeBiso, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeBookmark, ZeroTrustAppsBrowserIsolationPermissionsApplicationTypeDashSSO: + case ApplicationBrowserIsolationPermissionsApplicationTypeSelfHosted, ApplicationBrowserIsolationPermissionsApplicationTypeSaas, ApplicationBrowserIsolationPermissionsApplicationTypeSSH, ApplicationBrowserIsolationPermissionsApplicationTypeVnc, ApplicationBrowserIsolationPermissionsApplicationTypeAppLauncher, ApplicationBrowserIsolationPermissionsApplicationTypeWARP, ApplicationBrowserIsolationPermissionsApplicationTypeBiso, ApplicationBrowserIsolationPermissionsApplicationTypeBookmark, ApplicationBrowserIsolationPermissionsApplicationTypeDashSSO: return true } return false } -type ZeroTrustAppsBookmarkApplication struct { +type ApplicationBookmarkApplication struct { // UUID ID string `json:"id"` // Displays the application in the App Launcher. @@ -1372,14 +1269,14 @@ type ZeroTrustAppsBookmarkApplication struct { // applications in the App Launcher dashboard. Tags []string `json:"tags"` // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAppsBookmarkApplicationJSON `json:"-"` + Type string `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON applicationBookmarkApplicationJSON `json:"-"` } -// zeroTrustAppsBookmarkApplicationJSON contains the JSON metadata for the struct -// [ZeroTrustAppsBookmarkApplication] -type zeroTrustAppsBookmarkApplicationJSON struct { +// applicationBookmarkApplicationJSON contains the JSON metadata for the struct +// [ApplicationBookmarkApplication] +type applicationBookmarkApplicationJSON struct { ID apijson.Field AppLauncherVisible apijson.Field Aud apijson.Field @@ -1394,67 +1291,97 @@ type zeroTrustAppsBookmarkApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAppsBookmarkApplication) UnmarshalJSON(data []byte) (err error) { +func (r *ApplicationBookmarkApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAppsBookmarkApplicationJSON) RawJSON() string { +func (r applicationBookmarkApplicationJSON) RawJSON() string { return r.raw } -func (r ZeroTrustAppsBookmarkApplication) implementsZeroTrustZeroTrustApps() {} +func (r ApplicationBookmarkApplication) implementsZeroTrustApplication() {} -type AccessApplicationDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON accessApplicationDeleteResponseJSON `json:"-"` -} - -// accessApplicationDeleteResponseJSON contains the JSON metadata for the struct -// [AccessApplicationDeleteResponse] -type accessApplicationDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type ApplicationParam struct { + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. + AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` + AllowedIDPs param.Field[interface{}] `json:"allowed_idps,required"` + // Displays the application in the App Launcher. + AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + CorsHeaders param.Field[CorsHeadersParam] `json:"cors_headers"` + // The custom error message shown to a user when they are denied access to the + // application. + CustomDenyMessage param.Field[string] `json:"custom_deny_message"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing identity-based rules. + CustomDenyURL param.Field[string] `json:"custom_deny_url"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing non-identity rules. + CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` + CustomPages param.Field[interface{}] `json:"custom_pages,required"` + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain param.Field[string] `json:"domain"` + // Enables the binding cookie, which increases security against compromised + // authorization tokens and CSRF attacks. + EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` + // Enables the HttpOnly cookie attribute, which increases security against XSS + // attacks. + HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL param.Field[string] `json:"logo_url"` + // The name of the application. + Name param.Field[string] `json:"name"` + // Enables cookie paths to scope an application's JWT to the application path. If + // disabled, the JWT will scope to the hostname by default + PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` + // Sets the SameSite cookie setting, which provides increased security against CSRF + // attacks. + SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` + SelfHostedDomains param.Field[interface{}] `json:"self_hosted_domains,required"` + // Returns a 401 status code when the request is blocked by a Service Auth policy. + ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration param.Field[string] `json:"session_duration"` + // Enables automatic authentication through cloudflared. + SkipInterstitial param.Field[bool] `json:"skip_interstitial"` + Tags param.Field[interface{}] `json:"tags,required"` + // The application type. + Type param.Field[string] `json:"type"` + SaasApp param.Field[interface{}] `json:"saas_app,required"` } -func (r accessApplicationDeleteResponseJSON) RawJSON() string { - return r.raw +func (r ApplicationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type AccessApplicationRevokeTokensResponse = interface{} - -// This interface is a union satisfied by one of the following: -// [AccessApplicationNewParamsSelfHostedApplication], -// [AccessApplicationNewParamsSaaSApplication], -// [AccessApplicationNewParamsBrowserSSHApplication], -// [AccessApplicationNewParamsBrowserVncApplication], -// [AccessApplicationNewParamsAppLauncherApplication], -// [AccessApplicationNewParamsDeviceEnrollmentPermissionsApplication], -// [AccessApplicationNewParamsBrowserIsolationPermissionsApplication], -// [AccessApplicationNewParamsBookmarkApplication]. -type AccessApplicationNewParams interface { - ImplementsAccessApplicationNewParams() - - getAccountID() param.Field[string] +func (r ApplicationParam) implementsZeroTrustApplicationUnionParam() {} - getZoneID() param.Field[string] +// Satisfied by [zero_trust.ApplicationSelfHostedApplicationParam], +// [zero_trust.ApplicationSaaSApplicationParam], +// [zero_trust.ApplicationBrowserSSHApplicationParam], +// [zero_trust.ApplicationBrowserVncApplicationParam], +// [zero_trust.ApplicationAppLauncherApplicationParam], +// [zero_trust.ApplicationDeviceEnrollmentPermissionsApplicationParam], +// [zero_trust.ApplicationBrowserIsolationPermissionsApplicationParam], +// [zero_trust.ApplicationBookmarkApplicationParam], [ApplicationParam]. +type ApplicationUnionParam interface { + implementsZeroTrustApplicationUnionParam() } -type AccessApplicationNewParamsSelfHostedApplication struct { +type ApplicationSelfHostedApplicationParam struct { // The primary hostname and path that Access will secure. If the app is visible in // the App Launcher dashboard, this is the domain that will be displayed. Domain param.Field[string] `json:"domain,required"` // The application type. Type param.Field[string] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` // When set to true, users can authenticate to this application using their WARP // session. When set to false this application will always require direct IdP // authentication. This setting always overrides the organization setting for WARP @@ -1462,13 +1389,13 @@ type AccessApplicationNewParamsSelfHostedApplication struct { AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` + AllowedIDPs param.Field[[]AllowedIdpshParam] `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[AccessApplicationNewParamsSelfHostedApplicationCorsHeaders] `json:"cors_headers"` + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + CorsHeaders param.Field[CorsHeadersParam] `json:"cors_headers"` // The custom error message shown to a user when they are denied access to the // application. CustomDenyMessage param.Field[string] `json:"custom_deny_message"` @@ -1479,7 +1406,7 @@ type AccessApplicationNewParamsSelfHostedApplication struct { // application when failing non-identity rules. CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` + CustomPages param.Field[[]CustomPageshParam] `json:"custom_pages"` // Enables the binding cookie, which increases security against compromised // authorization tokens and CSRF attacks. EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` @@ -1497,7 +1424,7 @@ type AccessApplicationNewParamsSelfHostedApplication struct { // attacks. SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` + SelfHostedDomains param.Field[[]SelfHostedDomainshParam] `json:"self_hosted_domains"` // Returns a 401 status code when the request is blocked by a Service Auth policy. ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` // The amount of time that tokens issued for this application will be valid. Must @@ -1511,88 +1438,28 @@ type AccessApplicationNewParamsSelfHostedApplication struct { Tags param.Field[[]string] `json:"tags"` } -func (r AccessApplicationNewParamsSelfHostedApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationNewParamsSelfHostedApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationNewParamsSelfHostedApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationNewParamsSelfHostedApplication) ImplementsAccessApplicationNewParams() { - -} - -type AccessApplicationNewParamsSelfHostedApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]string] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]string] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r AccessApplicationNewParamsSelfHostedApplicationCorsHeaders) MarshalJSON() (data []byte, err error) { +func (r ApplicationSelfHostedApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod string - -const ( - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodGet AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "GET" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodPost AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "POST" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodHead AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodPut AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodDelete AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodConnect AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodOptions AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodTrace AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" - AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodPatch AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodGet, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodPost, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodHead, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodPut, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodDelete, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodConnect, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodOptions, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodTrace, AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} +func (r ApplicationSelfHostedApplicationParam) implementsZeroTrustApplicationUnionParam() {} -type AccessApplicationNewParamsSaaSApplication struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` +type ApplicationSaaSApplicationParam struct { // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` + AllowedIDPs param.Field[[]AllowedIdpshParam] `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` + CustomPages param.Field[[]CustomPageshParam] `json:"custom_pages"` // The image URL for the logo shown in the App Launcher dashboard. LogoURL param.Field[string] `json:"logo_url"` // The name of the application. - Name param.Field[string] `json:"name"` - SaasApp param.Field[AccessApplicationNewParamsSaaSApplicationSaasApp] `json:"saas_app"` + Name param.Field[string] `json:"name"` + SaasApp param.Field[ApplicationSaaSApplicationSaasAppUnionParam] `json:"saas_app"` // The tags you want assigned to an application. Tags are used to filter // applications in the App Launcher dashboard. Tags param.Field[[]string] `json:"tags"` @@ -1600,44 +1467,27 @@ type AccessApplicationNewParamsSaaSApplication struct { Type param.Field[string] `json:"type"` } -func (r AccessApplicationNewParamsSaaSApplication) MarshalJSON() (data []byte, err error) { +func (r ApplicationSaaSApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationNewParamsSaaSApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationNewParamsSaaSApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationNewParamsSaaSApplication) ImplementsAccessApplicationNewParams() { - -} - -// Satisfied by -// [zero_trust.AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasApp], -// [zero_trust.AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasApp]. -type AccessApplicationNewParamsSaaSApplicationSaasApp interface { - implementsZeroTrustAccessApplicationNewParamsSaaSApplicationSaasApp() -} +func (r ApplicationSaaSApplicationParam) implementsZeroTrustApplicationUnionParam() {} -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasApp struct { +type ApplicationSaaSApplicationSaasAppParam struct { // Optional identifier indicating the authentication protocol used for the saas // app. Required for OIDC. Default if unset is "saml" - AuthType param.Field[AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType] `json:"auth_type"` + AuthType param.Field[ApplicationSaaSApplicationSaasAppAuthType] `json:"auth_type"` // The service provider's endpoint that is responsible for receiving and parsing a // SAML assertion. - ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` - CustomAttributes param.Field[AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] `json:"custom_attributes"` + ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` + CustomAttributes param.Field[interface{}] `json:"custom_attributes,required"` // The URL that the user will be redirected to after a successful login for IDP // initiated logins. DefaultRelayState param.Field[string] `json:"default_relay_state"` // The unique identifier for your SaaS application. IDPEntityID param.Field[string] `json:"idp_entity_id"` // The format of the name identifier sent to the SaaS application. - NameIDFormat param.Field[AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat] `json:"name_id_format"` + NameIDFormat param.Field[SaasAppNameIDFormat] `json:"name_id_format"` // A [JSONata](https://jsonata.org/) expression that transforms an application's // user identities into a NameID value for its SAML assertion. This expression // should evaluate to a singular string. The output of this expression can override @@ -1650,103 +1500,50 @@ type AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasApp struct { // can transform id, email, name, and groups values. It can also transform fields // listed in the saml_attributes or oidc_fields of the identity provider used to // authenticate. The output of this expression must be a JSON object. - SamlAttributeTransformJsonata param.Field[string] `json:"saml_attribute_transform_jsonata"` + SAMLAttributeTransformJsonata param.Field[string] `json:"saml_attribute_transform_jsonata"` // A globally unique name for an identity or service provider. SpEntityID param.Field[string] `json:"sp_entity_id"` // The endpoint where your SaaS application will send login requests. SSOEndpoint param.Field[string] `json:"sso_endpoint"` + // The URL where this applications tile redirects users + AppLauncherURL param.Field[string] `json:"app_launcher_url"` + // The application client id + ClientID param.Field[string] `json:"client_id"` + // The application client secret, only returned on POST request. + ClientSecret param.Field[string] `json:"client_secret"` + GrantTypes param.Field[interface{}] `json:"grant_types,required"` + // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint + GroupFilterRegex param.Field[string] `json:"group_filter_regex"` + RedirectURIs param.Field[interface{}] `json:"redirect_uris,required"` + Scopes param.Field[interface{}] `json:"scopes,required"` } -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasApp) MarshalJSON() (data []byte, err error) { +func (r ApplicationSaaSApplicationSaasAppParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationNewParamsSaaSApplicationSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType string - -const ( - AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType) IsKnown() bool { - switch r { - case AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml, AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc: - return true - } - return false -} - -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name param.Field[string] `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat param.Field[AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat] `json:"name_format"` - Source param.Field[AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] `json:"source"` +func (r ApplicationSaaSApplicationSaasAppParam) implementsZeroTrustApplicationSaaSApplicationSaasAppUnionParam() { } -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// Satisfied by [zero_trust.SAMLSaasAppParam], +// [zero_trust.ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppParam], +// [ApplicationSaaSApplicationSaasAppParam]. +type ApplicationSaaSApplicationSaasAppUnionParam interface { + implementsZeroTrustApplicationSaaSApplicationSaasAppUnionParam() } -// A globally unique name for an identity or service provider. -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat) IsKnown() bool { - switch r { - case AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified, AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic, AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI: - return true - } - return false -} - -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name param.Field[string] `json:"name"` -} - -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The format of the name identifier sent to the SaaS application. -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat) IsKnown() bool { - switch r { - case AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID, AccessApplicationNewParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail: - return true - } - return false -} - -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasApp struct { +type ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppParam struct { // The URL where this applications tile redirects users AppLauncherURL param.Field[string] `json:"app_launcher_url"` // Identifier of the authentication protocol used for the saas app. Required for // OIDC. - AuthType param.Field[AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType] `json:"auth_type"` + AuthType param.Field[ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppAuthType] `json:"auth_type"` // The application client id ClientID param.Field[string] `json:"client_id"` // The application client secret, only returned on POST request. ClientSecret param.Field[string] `json:"client_secret"` // The OIDC flows supported by this application - GrantTypes param.Field[[]AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType] `json:"grant_types"` + GrantTypes param.Field[[]ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppGrantType] `json:"grant_types"` // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint GroupFilterRegex param.Field[string] `json:"group_filter_regex"` // The Access public certificate that will be used to verify your identity. @@ -1755,75 +1552,22 @@ type AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasApp struct { // tokens RedirectURIs param.Field[[]string] `json:"redirect_uris"` // Define the user information shared with access - Scopes param.Field[[]AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScope] `json:"scopes"` + Scopes param.Field[[]ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppScope] `json:"scopes"` } -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasApp) MarshalJSON() (data []byte, err error) { +func (r ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationNewParamsSaaSApplicationSaasApp() { -} - -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType string - -const ( - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType) IsKnown() bool { - switch r { - case AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml, AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc: - return true - } - return false -} - -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType string - -const ( - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType) IsKnown() bool { - switch r { - case AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode, AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce: - return true - } - return false -} - -type AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScope string - -const ( - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" - AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" -) - -func (r AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScope) IsKnown() bool { - switch r { - case AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid, AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups, AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail, AccessApplicationNewParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile: - return true - } - return false +func (r ApplicationSaaSApplicationSaasAppAccessOIDCSaasAppParam) implementsZeroTrustApplicationSaaSApplicationSaasAppUnionParam() { } -type AccessApplicationNewParamsBrowserSSHApplication struct { +type ApplicationBrowserSSHApplicationParam struct { // The primary hostname and path that Access will secure. If the app is visible in // the App Launcher dashboard, this is the domain that will be displayed. Domain param.Field[string] `json:"domain,required"` // The application type. Type param.Field[string] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` // When set to true, users can authenticate to this application using their WARP // session. When set to false this application will always require direct IdP // authentication. This setting always overrides the organization setting for WARP @@ -1831,13 +1575,13 @@ type AccessApplicationNewParamsBrowserSSHApplication struct { AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` + AllowedIDPs param.Field[[]AllowedIdpshParam] `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[AccessApplicationNewParamsBrowserSSHApplicationCorsHeaders] `json:"cors_headers"` + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + CorsHeaders param.Field[CorsHeadersParam] `json:"cors_headers"` // The custom error message shown to a user when they are denied access to the // application. CustomDenyMessage param.Field[string] `json:"custom_deny_message"` @@ -1848,7 +1592,7 @@ type AccessApplicationNewParamsBrowserSSHApplication struct { // application when failing non-identity rules. CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` + CustomPages param.Field[[]CustomPageshParam] `json:"custom_pages"` // Enables the binding cookie, which increases security against compromised // authorization tokens and CSRF attacks. EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` @@ -1866,7 +1610,7 @@ type AccessApplicationNewParamsBrowserSSHApplication struct { // attacks. SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` + SelfHostedDomains param.Field[[]SelfHostedDomainshParam] `json:"self_hosted_domains"` // Returns a 401 status code when the request is blocked by a Service Auth policy. ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` // The amount of time that tokens issued for this application will be valid. Must @@ -1880,78 +1624,18 @@ type AccessApplicationNewParamsBrowserSSHApplication struct { Tags param.Field[[]string] `json:"tags"` } -func (r AccessApplicationNewParamsBrowserSSHApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationNewParamsBrowserSSHApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationNewParamsBrowserSSHApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationNewParamsBrowserSSHApplication) ImplementsAccessApplicationNewParams() { - -} - -type AccessApplicationNewParamsBrowserSSHApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]string] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]string] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r AccessApplicationNewParamsBrowserSSHApplicationCorsHeaders) MarshalJSON() (data []byte, err error) { +func (r ApplicationBrowserSSHApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod string - -const ( - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodGet AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodPost AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodHead AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodPut AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodDelete AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodConnect AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodOptions AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodTrace AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" - AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodPatch AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodGet, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodPost, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodHead, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodPut, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodDelete, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodConnect, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodOptions, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodTrace, AccessApplicationNewParamsBrowserSSHApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} +func (r ApplicationBrowserSSHApplicationParam) implementsZeroTrustApplicationUnionParam() {} -type AccessApplicationNewParamsBrowserVncApplication struct { +type ApplicationBrowserVncApplicationParam struct { // The primary hostname and path that Access will secure. If the app is visible in // the App Launcher dashboard, this is the domain that will be displayed. Domain param.Field[string] `json:"domain,required"` // The application type. Type param.Field[string] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` // When set to true, users can authenticate to this application using their WARP // session. When set to false this application will always require direct IdP // authentication. This setting always overrides the organization setting for WARP @@ -1959,13 +1643,13 @@ type AccessApplicationNewParamsBrowserVncApplication struct { AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` + AllowedIDPs param.Field[[]AllowedIdpshParam] `json:"allowed_idps"` // Displays the application in the App Launcher. AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[AccessApplicationNewParamsBrowserVncApplicationCorsHeaders] `json:"cors_headers"` + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + CorsHeaders param.Field[CorsHeadersParam] `json:"cors_headers"` // The custom error message shown to a user when they are denied access to the // application. CustomDenyMessage param.Field[string] `json:"custom_deny_message"` @@ -1976,7 +1660,7 @@ type AccessApplicationNewParamsBrowserVncApplication struct { // application when failing non-identity rules. CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` + CustomPages param.Field[[]CustomPageshParam] `json:"custom_pages"` // Enables the binding cookie, which increases security against compromised // authorization tokens and CSRF attacks. EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` @@ -1994,7 +1678,7 @@ type AccessApplicationNewParamsBrowserVncApplication struct { // attacks. SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` + SelfHostedDomains param.Field[[]SelfHostedDomainshParam] `json:"self_hosted_domains"` // Returns a 401 status code when the request is blocked by a Service Auth policy. ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` // The amount of time that tokens issued for this application will be valid. Must @@ -2008,78 +1692,18 @@ type AccessApplicationNewParamsBrowserVncApplication struct { Tags param.Field[[]string] `json:"tags"` } -func (r AccessApplicationNewParamsBrowserVncApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationNewParamsBrowserVncApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationNewParamsBrowserVncApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationNewParamsBrowserVncApplication) ImplementsAccessApplicationNewParams() { - -} - -type AccessApplicationNewParamsBrowserVncApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]string] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]string] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r AccessApplicationNewParamsBrowserVncApplicationCorsHeaders) MarshalJSON() (data []byte, err error) { +func (r ApplicationBrowserVncApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod string - -const ( - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodGet AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "GET" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodPost AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "POST" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodHead AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodPut AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodDelete AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodConnect AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodOptions AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodTrace AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" - AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodPatch AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodGet, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodPost, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodHead, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodPut, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodDelete, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodConnect, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodOptions, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodTrace, AccessApplicationNewParamsBrowserVncApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} +func (r ApplicationBrowserVncApplicationParam) implementsZeroTrustApplicationUnionParam() {} -type AccessApplicationNewParamsAppLauncherApplication struct { +type ApplicationAppLauncherApplicationParam struct { // The application type. - Type param.Field[AccessApplicationNewParamsAppLauncherApplicationType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type param.Field[ApplicationAppLauncherApplicationType] `json:"type,required"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` + AllowedIDPs param.Field[[]AllowedIdpshParam] `json:"allowed_idps"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` @@ -2089,55 +1713,18 @@ type AccessApplicationNewParamsAppLauncherApplication struct { SessionDuration param.Field[string] `json:"session_duration"` } -func (r AccessApplicationNewParamsAppLauncherApplication) MarshalJSON() (data []byte, err error) { +func (r ApplicationAppLauncherApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationNewParamsAppLauncherApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationNewParamsAppLauncherApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationNewParamsAppLauncherApplication) ImplementsAccessApplicationNewParams() { - -} - -// The application type. -type AccessApplicationNewParamsAppLauncherApplicationType string - -const ( - AccessApplicationNewParamsAppLauncherApplicationTypeSelfHosted AccessApplicationNewParamsAppLauncherApplicationType = "self_hosted" - AccessApplicationNewParamsAppLauncherApplicationTypeSaas AccessApplicationNewParamsAppLauncherApplicationType = "saas" - AccessApplicationNewParamsAppLauncherApplicationTypeSSH AccessApplicationNewParamsAppLauncherApplicationType = "ssh" - AccessApplicationNewParamsAppLauncherApplicationTypeVnc AccessApplicationNewParamsAppLauncherApplicationType = "vnc" - AccessApplicationNewParamsAppLauncherApplicationTypeAppLauncher AccessApplicationNewParamsAppLauncherApplicationType = "app_launcher" - AccessApplicationNewParamsAppLauncherApplicationTypeWARP AccessApplicationNewParamsAppLauncherApplicationType = "warp" - AccessApplicationNewParamsAppLauncherApplicationTypeBiso AccessApplicationNewParamsAppLauncherApplicationType = "biso" - AccessApplicationNewParamsAppLauncherApplicationTypeBookmark AccessApplicationNewParamsAppLauncherApplicationType = "bookmark" - AccessApplicationNewParamsAppLauncherApplicationTypeDashSSO AccessApplicationNewParamsAppLauncherApplicationType = "dash_sso" -) - -func (r AccessApplicationNewParamsAppLauncherApplicationType) IsKnown() bool { - switch r { - case AccessApplicationNewParamsAppLauncherApplicationTypeSelfHosted, AccessApplicationNewParamsAppLauncherApplicationTypeSaas, AccessApplicationNewParamsAppLauncherApplicationTypeSSH, AccessApplicationNewParamsAppLauncherApplicationTypeVnc, AccessApplicationNewParamsAppLauncherApplicationTypeAppLauncher, AccessApplicationNewParamsAppLauncherApplicationTypeWARP, AccessApplicationNewParamsAppLauncherApplicationTypeBiso, AccessApplicationNewParamsAppLauncherApplicationTypeBookmark, AccessApplicationNewParamsAppLauncherApplicationTypeDashSSO: - return true - } - return false -} +func (r ApplicationAppLauncherApplicationParam) implementsZeroTrustApplicationUnionParam() {} -type AccessApplicationNewParamsDeviceEnrollmentPermissionsApplication struct { +type ApplicationDeviceEnrollmentPermissionsApplicationParam struct { // The application type. - Type param.Field[AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type param.Field[ApplicationDeviceEnrollmentPermissionsApplicationType] `json:"type,required"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` + AllowedIDPs param.Field[[]AllowedIdpshParam] `json:"allowed_idps"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` @@ -2147,55 +1734,19 @@ type AccessApplicationNewParamsDeviceEnrollmentPermissionsApplication struct { SessionDuration param.Field[string] `json:"session_duration"` } -func (r AccessApplicationNewParamsDeviceEnrollmentPermissionsApplication) MarshalJSON() (data []byte, err error) { +func (r ApplicationDeviceEnrollmentPermissionsApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationNewParamsDeviceEnrollmentPermissionsApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationNewParamsDeviceEnrollmentPermissionsApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationNewParamsDeviceEnrollmentPermissionsApplication) ImplementsAccessApplicationNewParams() { - -} - -// The application type. -type AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType string - -const ( - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeSelfHosted AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "self_hosted" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeSaas AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "saas" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeSSH AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "ssh" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeVnc AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "vnc" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeAppLauncher AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "app_launcher" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeWARP AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "warp" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeBiso AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "biso" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeBookmark AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "bookmark" - AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeDashSSO AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType = "dash_sso" -) - -func (r AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationType) IsKnown() bool { - switch r { - case AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeSelfHosted, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeSaas, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeSSH, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeVnc, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeAppLauncher, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeWARP, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeBiso, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeBookmark, AccessApplicationNewParamsDeviceEnrollmentPermissionsApplicationTypeDashSSO: - return true - } - return false +func (r ApplicationDeviceEnrollmentPermissionsApplicationParam) implementsZeroTrustApplicationUnionParam() { } -type AccessApplicationNewParamsBrowserIsolationPermissionsApplication struct { +type ApplicationBrowserIsolationPermissionsApplicationParam struct { // The application type. - Type param.Field[AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type param.Field[ApplicationBrowserIsolationPermissionsApplicationType] `json:"type,required"` // The identity providers your users can select when connecting to this // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` + AllowedIDPs param.Field[[]AllowedIdpshParam] `json:"allowed_idps"` // When set to `true`, users skip the identity provider selection step during // login. You must specify only one identity provider in allowed_idps. AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` @@ -2205,50 +1756,14 @@ type AccessApplicationNewParamsBrowserIsolationPermissionsApplication struct { SessionDuration param.Field[string] `json:"session_duration"` } -func (r AccessApplicationNewParamsBrowserIsolationPermissionsApplication) MarshalJSON() (data []byte, err error) { +func (r ApplicationBrowserIsolationPermissionsApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationNewParamsBrowserIsolationPermissionsApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationNewParamsBrowserIsolationPermissionsApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationNewParamsBrowserIsolationPermissionsApplication) ImplementsAccessApplicationNewParams() { - -} - -// The application type. -type AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType string - -const ( - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeSelfHosted AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "self_hosted" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeSaas AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "saas" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeSSH AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "ssh" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeVnc AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "vnc" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeAppLauncher AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "app_launcher" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeWARP AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "warp" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeBiso AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "biso" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeBookmark AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "bookmark" - AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeDashSSO AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType = "dash_sso" -) - -func (r AccessApplicationNewParamsBrowserIsolationPermissionsApplicationType) IsKnown() bool { - switch r { - case AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeSelfHosted, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeSaas, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeSSH, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeVnc, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeAppLauncher, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeWARP, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeBiso, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeBookmark, AccessApplicationNewParamsBrowserIsolationPermissionsApplicationTypeDashSSO: - return true - } - return false +func (r ApplicationBrowserIsolationPermissionsApplicationParam) implementsZeroTrustApplicationUnionParam() { } -type AccessApplicationNewParamsBookmarkApplication struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` +type ApplicationBookmarkApplicationParam struct { // Displays the application in the App Launcher. AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` // The URL or domain of the bookmark. @@ -2264,1023 +1779,407 @@ type AccessApplicationNewParamsBookmarkApplication struct { Type param.Field[string] `json:"type"` } -func (r AccessApplicationNewParamsBookmarkApplication) MarshalJSON() (data []byte, err error) { +func (r ApplicationBookmarkApplicationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationNewParamsBookmarkApplication) getAccountID() param.Field[string] { - return r.AccountID -} +func (r ApplicationBookmarkApplicationParam) implementsZeroTrustApplicationUnionParam() {} -func (r AccessApplicationNewParamsBookmarkApplication) getZoneID() param.Field[string] { - return r.ZoneID +type CorsHeaders struct { + // Allows all HTTP request headers. + AllowAllHeaders bool `json:"allow_all_headers"` + // Allows all HTTP request methods. + AllowAllMethods bool `json:"allow_all_methods"` + // Allows all origins. + AllowAllOrigins bool `json:"allow_all_origins"` + // When set to `true`, includes credentials (cookies, authorization headers, or TLS + // client certificates) with requests. + AllowCredentials bool `json:"allow_credentials"` + // Allowed HTTP request headers. + AllowedHeaders []AllowedHeadersh `json:"allowed_headers"` + // Allowed HTTP request methods. + AllowedMethods []AllowedMethodsh `json:"allowed_methods"` + // Allowed origins. + AllowedOrigins []AllowedOriginsh `json:"allowed_origins"` + // The maximum number of seconds the results of a preflight request can be cached. + MaxAge float64 `json:"max_age"` + JSON corsHeadersJSON `json:"-"` } -func (AccessApplicationNewParamsBookmarkApplication) ImplementsAccessApplicationNewParams() { +// corsHeadersJSON contains the JSON metadata for the struct [CorsHeaders] +type corsHeadersJSON struct { + AllowAllHeaders apijson.Field + AllowAllMethods apijson.Field + AllowAllOrigins apijson.Field + AllowCredentials apijson.Field + AllowedHeaders apijson.Field + AllowedMethods apijson.Field + AllowedOrigins apijson.Field + MaxAge apijson.Field + raw string + ExtraFields map[string]apijson.Field +} +func (r *CorsHeaders) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -type AccessApplicationNewResponseEnvelope struct { - Errors []AccessApplicationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustApps `json:"result,required"` - // Whether the API call was successful - Success AccessApplicationNewResponseEnvelopeSuccess `json:"success,required"` - JSON accessApplicationNewResponseEnvelopeJSON `json:"-"` +func (r corsHeadersJSON) RawJSON() string { + return r.raw } -// accessApplicationNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [AccessApplicationNewResponseEnvelope] -type accessApplicationNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field +type CorsHeadersParam struct { + // Allows all HTTP request headers. + AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` + // Allows all HTTP request methods. + AllowAllMethods param.Field[bool] `json:"allow_all_methods"` + // Allows all origins. + AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` + // When set to `true`, includes credentials (cookies, authorization headers, or TLS + // client certificates) with requests. + AllowCredentials param.Field[bool] `json:"allow_credentials"` + // Allowed HTTP request headers. + AllowedHeaders param.Field[[]AllowedHeadershParam] `json:"allowed_headers"` + // Allowed HTTP request methods. + AllowedMethods param.Field[[]AllowedMethodsh] `json:"allowed_methods"` + // Allowed origins. + AllowedOrigins param.Field[[]AllowedOriginshParam] `json:"allowed_origins"` + // The maximum number of seconds the results of a preflight request can be cached. + MaxAge param.Field[float64] `json:"max_age"` } -func (r *AccessApplicationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r CorsHeadersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r accessApplicationNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessApplicationNewResponseEnvelopeErrors] -type accessApplicationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessApplicationNewResponseEnvelopeMessages] -type accessApplicationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +type CustomPagesh = string -func (r accessApplicationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} +type CustomPageshParam = string -// Whether the API call was successful -type AccessApplicationNewResponseEnvelopeSuccess bool +// A globally unique name for an identity or service provider. +type SaasAppNameFormat string const ( - AccessApplicationNewResponseEnvelopeSuccessTrue AccessApplicationNewResponseEnvelopeSuccess = true + SaasAppNameFormatUrnOasisNamesTcSAML2_0AttrnameFormatUnspecified SaasAppNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" + SaasAppNameFormatUrnOasisNamesTcSAML2_0AttrnameFormatBasic SaasAppNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" + SaasAppNameFormatUrnOasisNamesTcSAML2_0AttrnameFormatURI SaasAppNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" ) -func (r AccessApplicationNewResponseEnvelopeSuccess) IsKnown() bool { +func (r SaasAppNameFormat) IsKnown() bool { switch r { - case AccessApplicationNewResponseEnvelopeSuccessTrue: + case SaasAppNameFormatUrnOasisNamesTcSAML2_0AttrnameFormatUnspecified, SaasAppNameFormatUrnOasisNamesTcSAML2_0AttrnameFormatBasic, SaasAppNameFormatUrnOasisNamesTcSAML2_0AttrnameFormatURI: return true } return false } -// This interface is a union satisfied by one of the following: -// [AccessApplicationUpdateParamsSelfHostedApplication], -// [AccessApplicationUpdateParamsSaaSApplication], -// [AccessApplicationUpdateParamsBrowserSSHApplication], -// [AccessApplicationUpdateParamsBrowserVncApplication], -// [AccessApplicationUpdateParamsAppLauncherApplication], -// [AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplication], -// [AccessApplicationUpdateParamsBrowserIsolationPermissionsApplication], -// [AccessApplicationUpdateParamsBookmarkApplication]. -type AccessApplicationUpdateParams interface { - ImplementsAccessApplicationUpdateParams() - - getAccountID() param.Field[string] - - getZoneID() param.Field[string] -} - -type AccessApplicationUpdateParamsSelfHostedApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain param.Field[string] `json:"domain,required"` - // The application type. - Type param.Field[string] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[AccessApplicationUpdateParamsSelfHostedApplicationCorsHeaders] `json:"cors_headers"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage param.Field[string] `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL param.Field[string] `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL param.Field[string] `json:"logo_url"` - // The name of the application. - Name param.Field[string] `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial param.Field[bool] `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags param.Field[[]string] `json:"tags"` -} - -func (r AccessApplicationUpdateParamsSelfHostedApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationUpdateParamsSelfHostedApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationUpdateParamsSelfHostedApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationUpdateParamsSelfHostedApplication) ImplementsAccessApplicationUpdateParams() { - -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsSelfHostedApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsSelfHostedApplicationAppID() -} - -type AccessApplicationUpdateParamsSelfHostedApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]string] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]string] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r AccessApplicationUpdateParamsSelfHostedApplicationCorsHeaders) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod string +// The format of the name identifier sent to the SaaS application. +type SaasAppNameIDFormat string const ( - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodGet AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "GET" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodPost AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "POST" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodHead AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodPut AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodDelete AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodConnect AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodOptions AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodTrace AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" - AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodPatch AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" + SaasAppNameIDFormatID SaasAppNameIDFormat = "id" + SaasAppNameIDFormatEmail SaasAppNameIDFormat = "email" ) -func (r AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod) IsKnown() bool { +func (r SaasAppNameIDFormat) IsKnown() bool { switch r { - case AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodGet, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodPost, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodHead, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodPut, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodDelete, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodConnect, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodOptions, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodTrace, AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodPatch: + case SaasAppNameIDFormatID, SaasAppNameIDFormatEmail: return true } return false } -type AccessApplicationUpdateParamsSaaSApplication struct { - // 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. - ZoneID param.Field[string] `path:"zone_id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL param.Field[string] `json:"logo_url"` - // The name of the application. - Name param.Field[string] `json:"name"` - SaasApp param.Field[AccessApplicationUpdateParamsSaaSApplicationSaasApp] `json:"saas_app"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags param.Field[[]string] `json:"tags"` - // The application type. - Type param.Field[string] `json:"type"` -} - -func (r AccessApplicationUpdateParamsSaaSApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type SaasAppSource struct { + // The name of the IdP attribute. + Name string `json:"name"` + JSON saasAppSourceJSON `json:"-"` } -func (r AccessApplicationUpdateParamsSaaSApplication) getAccountID() param.Field[string] { - return r.AccountID +// saasAppSourceJSON contains the JSON metadata for the struct [SaasAppSource] +type saasAppSourceJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r AccessApplicationUpdateParamsSaaSApplication) getZoneID() param.Field[string] { - return r.ZoneID +func (r *SaasAppSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (AccessApplicationUpdateParamsSaaSApplication) ImplementsAccessApplicationUpdateParams() { - +func (r saasAppSourceJSON) RawJSON() string { + return r.raw } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsSaaSApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsSaaSApplicationAppID() +type SaasAppSourceParam struct { + // The name of the IdP attribute. + Name param.Field[string] `json:"name"` } -// Satisfied by -// [zero_trust.AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasApp], -// [zero_trust.AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasApp]. -type AccessApplicationUpdateParamsSaaSApplicationSaasApp interface { - implementsZeroTrustAccessApplicationUpdateParamsSaaSApplicationSaasApp() +func (r SaasAppSourceParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasApp struct { +type SAMLSaasApp struct { // Optional identifier indicating the authentication protocol used for the saas // app. Required for OIDC. Default if unset is "saml" - AuthType param.Field[AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType] `json:"auth_type"` + AuthType SAMLSaasAppAuthType `json:"auth_type"` // The service provider's endpoint that is responsible for receiving and parsing a // SAML assertion. - ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` - CustomAttributes param.Field[AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] `json:"custom_attributes"` + ConsumerServiceURL string `json:"consumer_service_url"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + CustomAttributes SAMLSaasAppCustomAttributes `json:"custom_attributes"` // The URL that the user will be redirected to after a successful login for IDP // initiated logins. - DefaultRelayState param.Field[string] `json:"default_relay_state"` + DefaultRelayState string `json:"default_relay_state"` // The unique identifier for your SaaS application. - IDPEntityID param.Field[string] `json:"idp_entity_id"` + IDPEntityID string `json:"idp_entity_id"` // The format of the name identifier sent to the SaaS application. - NameIDFormat param.Field[AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat] `json:"name_id_format"` + NameIDFormat SaasAppNameIDFormat `json:"name_id_format"` // A [JSONata](https://jsonata.org/) expression that transforms an application's // user identities into a NameID value for its SAML assertion. This expression // should evaluate to a singular string. The output of this expression can override // the `name_id_format` setting. - NameIDTransformJsonata param.Field[string] `json:"name_id_transform_jsonata"` + NameIDTransformJsonata string `json:"name_id_transform_jsonata"` // The Access public certificate that will be used to verify your identity. - PublicKey param.Field[string] `json:"public_key"` + PublicKey string `json:"public_key"` // A [JSONata] (https://jsonata.org/) expression that transforms an application's // user identities into attribute assertions in the SAML response. The expression // can transform id, email, name, and groups values. It can also transform fields // listed in the saml_attributes or oidc_fields of the identity provider used to // authenticate. The output of this expression must be a JSON object. - SamlAttributeTransformJsonata param.Field[string] `json:"saml_attribute_transform_jsonata"` + SAMLAttributeTransformJsonata string `json:"saml_attribute_transform_jsonata"` // A globally unique name for an identity or service provider. - SpEntityID param.Field[string] `json:"sp_entity_id"` + SpEntityID string `json:"sp_entity_id"` // The endpoint where your SaaS application will send login requests. - SSOEndpoint param.Field[string] `json:"sso_endpoint"` -} - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationUpdateParamsSaaSApplicationSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType string - -const ( - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthType) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc: - return true - } - return false -} - -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name param.Field[string] `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat param.Field[AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat] `json:"name_format"` - Source param.Field[AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] `json:"source"` -} - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A globally unique name for an identity or service provider. -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI: - return true - } - return false -} - -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name param.Field[string] `json:"name"` -} - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The format of the name identifier sent to the SaaS application. -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail: - return true - } - return false -} - -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasApp struct { - // The URL where this applications tile redirects users - AppLauncherURL param.Field[string] `json:"app_launcher_url"` - // Identifier of the authentication protocol used for the saas app. Required for - // OIDC. - AuthType param.Field[AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType] `json:"auth_type"` - // The application client id - ClientID param.Field[string] `json:"client_id"` - // The application client secret, only returned on POST request. - ClientSecret param.Field[string] `json:"client_secret"` - // The OIDC flows supported by this application - GrantTypes param.Field[[]AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType] `json:"grant_types"` - // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint - GroupFilterRegex param.Field[string] `json:"group_filter_regex"` - // The Access public certificate that will be used to verify your identity. - PublicKey param.Field[string] `json:"public_key"` - // The permitted URL's for Cloudflare to return Authorization codes and Access/ID - // tokens - RedirectURIs param.Field[[]string] `json:"redirect_uris"` - // Define the user information shared with access - Scopes param.Field[[]AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScope] `json:"scopes"` -} - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationUpdateParamsSaaSApplicationSaasApp() { + SSOEndpoint string `json:"sso_endpoint"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON samlSaasAppJSON `json:"-"` } -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType string - -const ( - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthType) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc: - return true - } - return false -} - -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType string - -const ( - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantType) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce: - return true - } - return false -} - -type AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScope string - -const ( - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" - AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" -) - -func (r AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScope) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail, AccessApplicationUpdateParamsSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile: - return true - } - return false -} - -type AccessApplicationUpdateParamsBrowserSSHApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain param.Field[string] `json:"domain,required"` - // The application type. - Type param.Field[string] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeaders] `json:"cors_headers"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage param.Field[string] `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL param.Field[string] `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL param.Field[string] `json:"logo_url"` - // The name of the application. - Name param.Field[string] `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial param.Field[bool] `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags param.Field[[]string] `json:"tags"` -} - -func (r AccessApplicationUpdateParamsBrowserSSHApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationUpdateParamsBrowserSSHApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationUpdateParamsBrowserSSHApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationUpdateParamsBrowserSSHApplication) ImplementsAccessApplicationUpdateParams() { - -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsBrowserSSHApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsBrowserSSHApplicationAppID() -} - -type AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]string] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]string] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeaders) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod string - -const ( - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodGet AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodPost AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodHead AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodPut AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodDelete AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodConnect AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodOptions AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodTrace AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" - AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodPatch AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodGet, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodPost, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodHead, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodPut, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodDelete, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodConnect, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodOptions, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodTrace, AccessApplicationUpdateParamsBrowserSSHApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} - -type AccessApplicationUpdateParamsBrowserVncApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain param.Field[string] `json:"domain,required"` - // The application type. - Type param.Field[string] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[AccessApplicationUpdateParamsBrowserVncApplicationCorsHeaders] `json:"cors_headers"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage param.Field[string] `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL param.Field[string] `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL param.Field[string] `json:"logo_url"` - // The name of the application. - Name param.Field[string] `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial param.Field[bool] `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags param.Field[[]string] `json:"tags"` -} - -func (r AccessApplicationUpdateParamsBrowserVncApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationUpdateParamsBrowserVncApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationUpdateParamsBrowserVncApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationUpdateParamsBrowserVncApplication) ImplementsAccessApplicationUpdateParams() { - -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsBrowserVncApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsBrowserVncApplicationAppID() -} - -type AccessApplicationUpdateParamsBrowserVncApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]string] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]string] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r AccessApplicationUpdateParamsBrowserVncApplicationCorsHeaders) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod string - -const ( - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodGet AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "GET" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodPost AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "POST" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodHead AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodPut AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodDelete AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodConnect AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodOptions AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodTrace AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" - AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodPatch AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" -) - -func (r AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethod) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodGet, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodPost, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodHead, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodPut, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodDelete, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodConnect, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodOptions, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodTrace, AccessApplicationUpdateParamsBrowserVncApplicationCorsHeadersAllowedMethodPatch: - return true - } - return false -} - -type AccessApplicationUpdateParamsAppLauncherApplication struct { - // The application type. - Type param.Field[AccessApplicationUpdateParamsAppLauncherApplicationType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` -} - -func (r AccessApplicationUpdateParamsAppLauncherApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationUpdateParamsAppLauncherApplication) getAccountID() param.Field[string] { - return r.AccountID +// samlSaasAppJSON contains the JSON metadata for the struct [SAMLSaasApp] +type samlSaasAppJSON struct { + AuthType apijson.Field + ConsumerServiceURL apijson.Field + CreatedAt apijson.Field + CustomAttributes apijson.Field + DefaultRelayState apijson.Field + IDPEntityID apijson.Field + NameIDFormat apijson.Field + NameIDTransformJsonata apijson.Field + PublicKey apijson.Field + SAMLAttributeTransformJsonata apijson.Field + SpEntityID apijson.Field + SSOEndpoint apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r AccessApplicationUpdateParamsAppLauncherApplication) getZoneID() param.Field[string] { - return r.ZoneID +func (r *SAMLSaasApp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (AccessApplicationUpdateParamsAppLauncherApplication) ImplementsAccessApplicationUpdateParams() { - +func (r samlSaasAppJSON) RawJSON() string { + return r.raw } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsAppLauncherApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsAppLauncherApplicationAppID() -} +func (r SAMLSaasApp) implementsZeroTrustApplicationSaaSApplicationSaasApp() {} -// The application type. -type AccessApplicationUpdateParamsAppLauncherApplicationType string +// Optional identifier indicating the authentication protocol used for the saas +// app. Required for OIDC. Default if unset is "saml" +type SAMLSaasAppAuthType string const ( - AccessApplicationUpdateParamsAppLauncherApplicationTypeSelfHosted AccessApplicationUpdateParamsAppLauncherApplicationType = "self_hosted" - AccessApplicationUpdateParamsAppLauncherApplicationTypeSaas AccessApplicationUpdateParamsAppLauncherApplicationType = "saas" - AccessApplicationUpdateParamsAppLauncherApplicationTypeSSH AccessApplicationUpdateParamsAppLauncherApplicationType = "ssh" - AccessApplicationUpdateParamsAppLauncherApplicationTypeVnc AccessApplicationUpdateParamsAppLauncherApplicationType = "vnc" - AccessApplicationUpdateParamsAppLauncherApplicationTypeAppLauncher AccessApplicationUpdateParamsAppLauncherApplicationType = "app_launcher" - AccessApplicationUpdateParamsAppLauncherApplicationTypeWARP AccessApplicationUpdateParamsAppLauncherApplicationType = "warp" - AccessApplicationUpdateParamsAppLauncherApplicationTypeBiso AccessApplicationUpdateParamsAppLauncherApplicationType = "biso" - AccessApplicationUpdateParamsAppLauncherApplicationTypeBookmark AccessApplicationUpdateParamsAppLauncherApplicationType = "bookmark" - AccessApplicationUpdateParamsAppLauncherApplicationTypeDashSSO AccessApplicationUpdateParamsAppLauncherApplicationType = "dash_sso" + SAMLSaasAppAuthTypeSAML SAMLSaasAppAuthType = "saml" + SAMLSaasAppAuthTypeOIDC SAMLSaasAppAuthType = "oidc" ) -func (r AccessApplicationUpdateParamsAppLauncherApplicationType) IsKnown() bool { +func (r SAMLSaasAppAuthType) IsKnown() bool { switch r { - case AccessApplicationUpdateParamsAppLauncherApplicationTypeSelfHosted, AccessApplicationUpdateParamsAppLauncherApplicationTypeSaas, AccessApplicationUpdateParamsAppLauncherApplicationTypeSSH, AccessApplicationUpdateParamsAppLauncherApplicationTypeVnc, AccessApplicationUpdateParamsAppLauncherApplicationTypeAppLauncher, AccessApplicationUpdateParamsAppLauncherApplicationTypeWARP, AccessApplicationUpdateParamsAppLauncherApplicationTypeBiso, AccessApplicationUpdateParamsAppLauncherApplicationTypeBookmark, AccessApplicationUpdateParamsAppLauncherApplicationTypeDashSSO: + case SAMLSaasAppAuthTypeSAML, SAMLSaasAppAuthTypeOIDC: return true } return false } -type AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplication struct { - // The application type. - Type param.Field[AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` +type SAMLSaasAppCustomAttributes struct { + // The name of the attribute. + Name string `json:"name"` + // A globally unique name for an identity or service provider. + NameFormat SaasAppNameFormat `json:"name_format"` + Source SaasAppSource `json:"source"` + JSON samlSaasAppCustomAttributesJSON `json:"-"` } -func (r AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// samlSaasAppCustomAttributesJSON contains the JSON metadata for the struct +// [SAMLSaasAppCustomAttributes] +type samlSaasAppCustomAttributesJSON struct { + Name apijson.Field + NameFormat apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SAMLSaasAppCustomAttributes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r samlSaasAppCustomAttributesJSON) RawJSON() string { + return r.raw } -func (r AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplication) getAccountID() param.Field[string] { - return r.AccountID +type SAMLSaasAppParam struct { + // Optional identifier indicating the authentication protocol used for the saas + // app. Required for OIDC. Default if unset is "saml" + AuthType param.Field[SAMLSaasAppAuthType] `json:"auth_type"` + // The service provider's endpoint that is responsible for receiving and parsing a + // SAML assertion. + ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` + CustomAttributes param.Field[SAMLSaasAppCustomAttributesParam] `json:"custom_attributes"` + // The URL that the user will be redirected to after a successful login for IDP + // initiated logins. + DefaultRelayState param.Field[string] `json:"default_relay_state"` + // The unique identifier for your SaaS application. + IDPEntityID param.Field[string] `json:"idp_entity_id"` + // The format of the name identifier sent to the SaaS application. + NameIDFormat param.Field[SaasAppNameIDFormat] `json:"name_id_format"` + // A [JSONata](https://jsonata.org/) expression that transforms an application's + // user identities into a NameID value for its SAML assertion. This expression + // should evaluate to a singular string. The output of this expression can override + // the `name_id_format` setting. + NameIDTransformJsonata param.Field[string] `json:"name_id_transform_jsonata"` + // The Access public certificate that will be used to verify your identity. + PublicKey param.Field[string] `json:"public_key"` + // A [JSONata] (https://jsonata.org/) expression that transforms an application's + // user identities into attribute assertions in the SAML response. The expression + // can transform id, email, name, and groups values. It can also transform fields + // listed in the saml_attributes or oidc_fields of the identity provider used to + // authenticate. The output of this expression must be a JSON object. + SAMLAttributeTransformJsonata param.Field[string] `json:"saml_attribute_transform_jsonata"` + // A globally unique name for an identity or service provider. + SpEntityID param.Field[string] `json:"sp_entity_id"` + // The endpoint where your SaaS application will send login requests. + SSOEndpoint param.Field[string] `json:"sso_endpoint"` } -func (r AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplication) getZoneID() param.Field[string] { - return r.ZoneID +func (r SAMLSaasAppParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplication) ImplementsAccessApplicationUpdateParams() { +func (r SAMLSaasAppParam) implementsZeroTrustApplicationSaaSApplicationSaasAppUnionParam() {} +type SAMLSaasAppCustomAttributesParam struct { + // The name of the attribute. + Name param.Field[string] `json:"name"` + // A globally unique name for an identity or service provider. + NameFormat param.Field[SaasAppNameFormat] `json:"name_format"` + Source param.Field[SaasAppSourceParam] `json:"source"` } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationAppID() +func (r SAMLSaasAppCustomAttributesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// The application type. -type AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType string +type SelfHostedDomainsh = string -const ( - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeSelfHosted AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "self_hosted" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeSaas AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "saas" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeSSH AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "ssh" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeVnc AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "vnc" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeAppLauncher AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "app_launcher" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeWARP AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "warp" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeBiso AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "biso" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeBookmark AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "bookmark" - AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeDashSSO AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType = "dash_sso" -) +type SelfHostedDomainshParam = string -func (r AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationType) IsKnown() bool { - switch r { - case AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeSelfHosted, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeSaas, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeSSH, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeVnc, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeAppLauncher, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeWARP, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeBiso, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeBookmark, AccessApplicationUpdateParamsDeviceEnrollmentPermissionsApplicationTypeDashSSO: - return true - } - return false +type AccessApplicationDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessApplicationDeleteResponseJSON `json:"-"` } -type AccessApplicationUpdateParamsBrowserIsolationPermissionsApplication struct { - // The application type. - Type param.Field[AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType] `json:"type,required"` +// accessApplicationDeleteResponseJSON contains the JSON metadata for the struct +// [AccessApplicationDeleteResponse] +type accessApplicationDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationRevokeTokensResponse = interface{} + +type AccessApplicationNewParams struct { + Application ApplicationUnionParam `json:"application,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. ZoneID param.Field[string] `path:"zone_id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIDPs param.Field[[]string] `json:"allowed_idps"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` } -func (r AccessApplicationUpdateParamsBrowserIsolationPermissionsApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r AccessApplicationNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Application) } -func (r AccessApplicationUpdateParamsBrowserIsolationPermissionsApplication) getAccountID() param.Field[string] { - return r.AccountID +type AccessApplicationNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Application `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationNewResponseEnvelopeJSON `json:"-"` } -func (r AccessApplicationUpdateParamsBrowserIsolationPermissionsApplication) getZoneID() param.Field[string] { - return r.ZoneID +// accessApplicationNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationNewResponseEnvelope] +type accessApplicationNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (AccessApplicationUpdateParamsBrowserIsolationPermissionsApplication) ImplementsAccessApplicationUpdateParams() { - +func (r *AccessApplicationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationAppID() +func (r accessApplicationNewResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// The application type. -type AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType string +// Whether the API call was successful +type AccessApplicationNewResponseEnvelopeSuccess bool const ( - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeSelfHosted AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "self_hosted" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeSaas AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "saas" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeSSH AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "ssh" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeVnc AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "vnc" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeAppLauncher AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "app_launcher" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeWARP AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "warp" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeBiso AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "biso" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeBookmark AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "bookmark" - AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeDashSSO AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType = "dash_sso" + AccessApplicationNewResponseEnvelopeSuccessTrue AccessApplicationNewResponseEnvelopeSuccess = true ) -func (r AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationType) IsKnown() bool { +func (r AccessApplicationNewResponseEnvelopeSuccess) IsKnown() bool { switch r { - case AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeSelfHosted, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeSaas, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeSSH, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeVnc, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeAppLauncher, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeWARP, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeBiso, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeBookmark, AccessApplicationUpdateParamsBrowserIsolationPermissionsApplicationTypeDashSSO: + case AccessApplicationNewResponseEnvelopeSuccessTrue: return true } return false } -type AccessApplicationUpdateParamsBookmarkApplication struct { +type AccessApplicationUpdateParams struct { + Application ApplicationUnionParam `json:"application,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. ZoneID param.Field[string] `path:"zone_id"` - // Displays the application in the App Launcher. - AppLauncherVisible param.Field[bool] `json:"app_launcher_visible"` - // The URL or domain of the bookmark. - Domain param.Field[string] `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL param.Field[string] `json:"logo_url"` - // The name of the application. - Name param.Field[string] `json:"name"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags param.Field[[]string] `json:"tags"` - // The application type. - Type param.Field[string] `json:"type"` -} - -func (r AccessApplicationUpdateParamsBookmarkApplication) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationUpdateParamsBookmarkApplication) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r AccessApplicationUpdateParamsBookmarkApplication) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (AccessApplicationUpdateParamsBookmarkApplication) ImplementsAccessApplicationUpdateParams() { - } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUpdateParamsBookmarkApplicationAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsBookmarkApplicationAppID() +func (r AccessApplicationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Application) } type AccessApplicationUpdateResponseEnvelope struct { - Errors []AccessApplicationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustApps `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Application `json:"result,required"` // Whether the API call was successful Success AccessApplicationUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationUpdateResponseEnvelopeJSON `json:"-"` @@ -3305,52 +2204,6 @@ func (r accessApplicationUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessApplicationUpdateResponseEnvelopeErrors] -type accessApplicationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessApplicationUpdateResponseEnvelopeMessages] -type accessApplicationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationUpdateResponseEnvelopeSuccess bool @@ -3380,17 +2233,10 @@ type AccessApplicationDeleteParams struct { ZoneID param.Field[string] `path:"zone_id"` } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationDeleteParamsAppID interface { - ImplementsZeroTrustAccessApplicationDeleteParamsAppID() -} - type AccessApplicationDeleteResponseEnvelope struct { - Errors []AccessApplicationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessApplicationDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessApplicationDeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessApplicationDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationDeleteResponseEnvelopeJSON `json:"-"` @@ -3415,52 +2261,6 @@ func (r accessApplicationDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessApplicationDeleteResponseEnvelopeErrors] -type accessApplicationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessApplicationDeleteResponseEnvelopeMessages] -type accessApplicationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationDeleteResponseEnvelopeSuccess bool @@ -3483,17 +2283,10 @@ type AccessApplicationGetParams struct { ZoneID param.Field[string] `path:"zone_id"` } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationGetParamsAppID interface { - ImplementsZeroTrustAccessApplicationGetParamsAppID() -} - type AccessApplicationGetResponseEnvelope struct { - Errors []AccessApplicationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustApps `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Application `json:"result,required"` // Whether the API call was successful Success AccessApplicationGetResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationGetResponseEnvelopeJSON `json:"-"` @@ -3518,52 +2311,6 @@ func (r accessApplicationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessApplicationGetResponseEnvelopeErrors] -type accessApplicationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessApplicationGetResponseEnvelopeMessages] -type accessApplicationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationGetResponseEnvelopeSuccess bool @@ -3586,13 +2333,6 @@ type AccessApplicationRevokeTokensParams struct { ZoneID param.Field[string] `path:"zone_id"` } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationRevokeTokensParamsAppID interface { - ImplementsZeroTrustAccessApplicationRevokeTokensParamsAppID() -} - type AccessApplicationRevokeTokensResponseEnvelope struct { Result AccessApplicationRevokeTokensResponse `json:"result,nullable"` Success AccessApplicationRevokeTokensResponseEnvelopeSuccess `json:"success"` diff --git a/zero_trust/accessapplication_test.go b/zero_trust/accessapplication_test.go index 3c0a8bb0dcc..ef99ad6c7ea 100644 --- a/zero_trust/accessapplication_test.go +++ b/zero_trust/accessapplication_test.go @@ -29,40 +29,42 @@ func TestAccessApplicationNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.ZeroTrust.Access.Applications.New(context.TODO(), zero_trust.AccessApplicationNewParamsSelfHostedApplication{ - Domain: cloudflare.F("test.example.com/admin"), - Type: cloudflare.F("self_hosted"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - AllowAuthenticateViaWARP: cloudflare.F(true), - AllowedIDPs: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - AppLauncherVisible: cloudflare.F(true), - AutoRedirectToIdentity: cloudflare.F(true), - CorsHeaders: cloudflare.F(zero_trust.AccessApplicationNewParamsSelfHostedApplicationCorsHeaders{ - AllowAllHeaders: cloudflare.F(true), - AllowAllMethods: cloudflare.F(true), - AllowAllOrigins: cloudflare.F(true), - AllowCredentials: cloudflare.F(true), - AllowedHeaders: cloudflare.F([]string{"string", "string", "string"}), - AllowedMethods: cloudflare.F([]zero_trust.AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethod{zero_trust.AccessApplicationNewParamsSelfHostedApplicationCorsHeadersAllowedMethodGet}), - AllowedOrigins: cloudflare.F([]string{"https://example.com"}), - MaxAge: cloudflare.F(-1.000000), - }), - CustomDenyMessage: cloudflare.F("string"), - CustomDenyURL: cloudflare.F("string"), - CustomNonIdentityDenyURL: cloudflare.F("string"), - CustomPages: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - EnableBindingCookie: cloudflare.F(true), - HTTPOnlyCookieAttribute: cloudflare.F(true), - LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), - Name: cloudflare.F("Admin Site"), - PathCookieAttribute: cloudflare.F(true), - SameSiteCookieAttribute: cloudflare.F("strict"), - SelfHostedDomains: cloudflare.F([]string{"test.example.com/admin", "test.anotherexample.com/staff"}), - ServiceAuth401Redirect: cloudflare.F(true), - SessionDuration: cloudflare.F("24h"), - SkipInterstitial: cloudflare.F(true), - Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), + _, err := client.ZeroTrust.Access.Applications.New(context.TODO(), zero_trust.AccessApplicationNewParams{ + Application: zero_trust.ApplicationSelfHostedApplicationParam{ + AllowAuthenticateViaWARP: cloudflare.F(true), + AllowedIDPs: cloudflare.F([]zero_trust.AllowedIdpshParam{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + AppLauncherVisible: cloudflare.F(true), + AutoRedirectToIdentity: cloudflare.F(true), + CorsHeaders: cloudflare.F(zero_trust.CorsHeadersParam{ + AllowAllHeaders: cloudflare.F(true), + AllowAllMethods: cloudflare.F(true), + AllowAllOrigins: cloudflare.F(true), + AllowCredentials: cloudflare.F(true), + AllowedHeaders: cloudflare.F([]zero_trust.AllowedHeadershParam{"string", "string", "string"}), + AllowedMethods: cloudflare.F([]zero_trust.AllowedMethodsh{zero_trust.AllowedMethodshGet}), + AllowedOrigins: cloudflare.F([]zero_trust.AllowedOriginshParam{"https://example.com"}), + MaxAge: cloudflare.F(-1.000000), + }), + CustomDenyMessage: cloudflare.F("string"), + CustomDenyURL: cloudflare.F("string"), + CustomNonIdentityDenyURL: cloudflare.F("string"), + CustomPages: cloudflare.F([]zero_trust.CustomPageshParam{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + Domain: cloudflare.F("test.example.com/admin"), + EnableBindingCookie: cloudflare.F(true), + HTTPOnlyCookieAttribute: cloudflare.F(true), + LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), + Name: cloudflare.F("Admin Site"), + PathCookieAttribute: cloudflare.F(true), + SameSiteCookieAttribute: cloudflare.F("strict"), + SelfHostedDomains: cloudflare.F([]zero_trust.SelfHostedDomainshParam{"test.example.com/admin", "test.anotherexample.com/staff"}), + ServiceAuth401Redirect: cloudflare.F(true), + SessionDuration: cloudflare.F("24h"), + SkipInterstitial: cloudflare.F(true), + Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), + Type: cloudflare.F("self_hosted"), + }, + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), }) if err != nil { var apierr *cloudflare.Error @@ -90,40 +92,42 @@ func TestAccessApplicationUpdateWithOptionalParams(t *testing.T) { _, err := client.ZeroTrust.Access.Applications.Update( context.TODO(), shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), - zero_trust.AccessApplicationUpdateParamsSelfHostedApplication{ - Domain: cloudflare.F("test.example.com/admin"), - Type: cloudflare.F("self_hosted"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - AllowAuthenticateViaWARP: cloudflare.F(true), - AllowedIDPs: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - AppLauncherVisible: cloudflare.F(true), - AutoRedirectToIdentity: cloudflare.F(true), - CorsHeaders: cloudflare.F(zero_trust.AccessApplicationUpdateParamsSelfHostedApplicationCorsHeaders{ - AllowAllHeaders: cloudflare.F(true), - AllowAllMethods: cloudflare.F(true), - AllowAllOrigins: cloudflare.F(true), - AllowCredentials: cloudflare.F(true), - AllowedHeaders: cloudflare.F([]string{"string", "string", "string"}), - AllowedMethods: cloudflare.F([]zero_trust.AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethod{zero_trust.AccessApplicationUpdateParamsSelfHostedApplicationCorsHeadersAllowedMethodGet}), - AllowedOrigins: cloudflare.F([]string{"https://example.com"}), - MaxAge: cloudflare.F(-1.000000), - }), - CustomDenyMessage: cloudflare.F("string"), - CustomDenyURL: cloudflare.F("string"), - CustomNonIdentityDenyURL: cloudflare.F("string"), - CustomPages: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - EnableBindingCookie: cloudflare.F(true), - HTTPOnlyCookieAttribute: cloudflare.F(true), - LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), - Name: cloudflare.F("Admin Site"), - PathCookieAttribute: cloudflare.F(true), - SameSiteCookieAttribute: cloudflare.F("strict"), - SelfHostedDomains: cloudflare.F([]string{"test.example.com/admin", "test.anotherexample.com/staff"}), - ServiceAuth401Redirect: cloudflare.F(true), - SessionDuration: cloudflare.F("24h"), - SkipInterstitial: cloudflare.F(true), - Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), + zero_trust.AccessApplicationUpdateParams{ + Application: zero_trust.ApplicationSelfHostedApplicationParam{ + AllowAuthenticateViaWARP: cloudflare.F(true), + AllowedIDPs: cloudflare.F([]zero_trust.AllowedIdpshParam{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + AppLauncherVisible: cloudflare.F(true), + AutoRedirectToIdentity: cloudflare.F(true), + CorsHeaders: cloudflare.F(zero_trust.CorsHeadersParam{ + AllowAllHeaders: cloudflare.F(true), + AllowAllMethods: cloudflare.F(true), + AllowAllOrigins: cloudflare.F(true), + AllowCredentials: cloudflare.F(true), + AllowedHeaders: cloudflare.F([]zero_trust.AllowedHeadershParam{"string", "string", "string"}), + AllowedMethods: cloudflare.F([]zero_trust.AllowedMethodsh{zero_trust.AllowedMethodshGet}), + AllowedOrigins: cloudflare.F([]zero_trust.AllowedOriginshParam{"https://example.com"}), + MaxAge: cloudflare.F(-1.000000), + }), + CustomDenyMessage: cloudflare.F("string"), + CustomDenyURL: cloudflare.F("string"), + CustomNonIdentityDenyURL: cloudflare.F("string"), + CustomPages: cloudflare.F([]zero_trust.CustomPageshParam{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + Domain: cloudflare.F("test.example.com/admin"), + EnableBindingCookie: cloudflare.F(true), + HTTPOnlyCookieAttribute: cloudflare.F(true), + LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), + Name: cloudflare.F("Admin Site"), + PathCookieAttribute: cloudflare.F(true), + SameSiteCookieAttribute: cloudflare.F("strict"), + SelfHostedDomains: cloudflare.F([]zero_trust.SelfHostedDomainshParam{"test.example.com/admin", "test.anotherexample.com/staff"}), + ServiceAuth401Redirect: cloudflare.F(true), + SessionDuration: cloudflare.F("24h"), + SkipInterstitial: cloudflare.F(true), + Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), + Type: cloudflare.F("self_hosted"), + }, + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), }, ) if err != nil { diff --git a/zero_trust/accessapplicationca.go b/zero_trust/accessapplicationca.go index caa05c2f129..14e654432cb 100644 --- a/zero_trust/accessapplicationca.go +++ b/zero_trust/accessapplicationca.go @@ -36,7 +36,7 @@ func NewAccessApplicationCAService(opts ...option.RequestOption) (r *AccessAppli } // Generates a new short-lived certificate CA and public key. -func (r *AccessApplicationCAService) New(ctx context.Context, uuid string, body AccessApplicationCANewParams, opts ...option.RequestOption) (res *AccessApplicationCANewResponse, err error) { +func (r *AccessApplicationCAService) New(ctx context.Context, uuid string, body AccessApplicationCANewParams, opts ...option.RequestOption) (res *AccessApplicationCANewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationCANewResponseEnvelope var accountOrZone string @@ -58,7 +58,7 @@ func (r *AccessApplicationCAService) New(ctx context.Context, uuid string, body } // Lists short-lived certificate CAs and their public keys. -func (r *AccessApplicationCAService) List(ctx context.Context, query AccessApplicationCAListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustCA], err error) { +func (r *AccessApplicationCAService) List(ctx context.Context, query AccessApplicationCAListParams, opts ...option.RequestOption) (res *pagination.SinglePage[CA], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -85,7 +85,7 @@ func (r *AccessApplicationCAService) List(ctx context.Context, query AccessAppli } // Lists short-lived certificate CAs and their public keys. -func (r *AccessApplicationCAService) ListAutoPaging(ctx context.Context, query AccessApplicationCAListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustCA] { +func (r *AccessApplicationCAService) ListAutoPaging(ctx context.Context, query AccessApplicationCAListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[CA] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -112,7 +112,7 @@ func (r *AccessApplicationCAService) Delete(ctx context.Context, uuid string, bo } // Fetches a short-lived certificate CA and its public key. -func (r *AccessApplicationCAService) Get(ctx context.Context, uuid string, query AccessApplicationCAGetParams, opts ...option.RequestOption) (res *AccessApplicationCAGetResponse, err error) { +func (r *AccessApplicationCAService) Get(ctx context.Context, uuid string, query AccessApplicationCAGetParams, opts ...option.RequestOption) (res *AccessApplicationCAGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationCAGetResponseEnvelope var accountOrZone string @@ -133,19 +133,19 @@ func (r *AccessApplicationCAService) Get(ctx context.Context, uuid string, query return } -type ZeroTrustCA struct { +type CA struct { // The ID of the CA. ID string `json:"id"` // The Application Audience (AUD) tag. Identifies the application associated with // the CA. Aud string `json:"aud"` // The public key to add to your SSH server configuration. - PublicKey string `json:"public_key"` - JSON zeroTrustCAJSON `json:"-"` + PublicKey string `json:"public_key"` + JSON caJSON `json:"-"` } -// zeroTrustCAJSON contains the JSON metadata for the struct [ZeroTrustCA] -type zeroTrustCAJSON struct { +// caJSON contains the JSON metadata for the struct [CA] +type caJSON struct { ID apijson.Field Aud apijson.Field PublicKey apijson.Field @@ -153,23 +153,23 @@ type zeroTrustCAJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustCA) UnmarshalJSON(data []byte) (err error) { +func (r *CA) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustCAJSON) RawJSON() string { +func (r caJSON) RawJSON() string { return r.raw } // Union satisfied by [zero_trust.AccessApplicationCANewResponseUnknown] or // [shared.UnionString]. -type AccessApplicationCANewResponse interface { - ImplementsZeroTrustAccessApplicationCANewResponse() +type AccessApplicationCANewResponseUnion interface { + ImplementsZeroTrustAccessApplicationCANewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessApplicationCANewResponse)(nil)).Elem(), + reflect.TypeOf((*AccessApplicationCANewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -202,13 +202,13 @@ func (r accessApplicationCADeleteResponseJSON) RawJSON() string { // Union satisfied by [zero_trust.AccessApplicationCAGetResponseUnknown] or // [shared.UnionString]. -type AccessApplicationCAGetResponse interface { - ImplementsZeroTrustAccessApplicationCAGetResponse() +type AccessApplicationCAGetResponseUnion interface { + ImplementsZeroTrustAccessApplicationCAGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessApplicationCAGetResponse)(nil)).Elem(), + reflect.TypeOf((*AccessApplicationCAGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -225,9 +225,9 @@ type AccessApplicationCANewParams struct { } type AccessApplicationCANewResponseEnvelope struct { - Errors []AccessApplicationCANewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationCANewResponseEnvelopeMessages `json:"messages,required"` - Result AccessApplicationCANewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessApplicationCANewResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessApplicationCANewResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationCANewResponseEnvelopeJSON `json:"-"` @@ -252,52 +252,6 @@ func (r accessApplicationCANewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationCANewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationCANewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationCANewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessApplicationCANewResponseEnvelopeErrors] -type accessApplicationCANewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationCANewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationCANewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationCANewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationCANewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationCANewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessApplicationCANewResponseEnvelopeMessages] -type accessApplicationCANewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationCANewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationCANewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationCANewResponseEnvelopeSuccess bool @@ -328,9 +282,9 @@ type AccessApplicationCADeleteParams struct { } type AccessApplicationCADeleteResponseEnvelope struct { - Errors []AccessApplicationCADeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationCADeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessApplicationCADeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessApplicationCADeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessApplicationCADeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationCADeleteResponseEnvelopeJSON `json:"-"` @@ -355,52 +309,6 @@ func (r accessApplicationCADeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationCADeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationCADeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationCADeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessApplicationCADeleteResponseEnvelopeErrors] -type accessApplicationCADeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationCADeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationCADeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationCADeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationCADeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationCADeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessApplicationCADeleteResponseEnvelopeMessages] -type accessApplicationCADeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationCADeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationCADeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationCADeleteResponseEnvelopeSuccess bool @@ -424,9 +332,9 @@ type AccessApplicationCAGetParams struct { } type AccessApplicationCAGetResponseEnvelope struct { - Errors []AccessApplicationCAGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationCAGetResponseEnvelopeMessages `json:"messages,required"` - Result AccessApplicationCAGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessApplicationCAGetResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessApplicationCAGetResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationCAGetResponseEnvelopeJSON `json:"-"` @@ -451,52 +359,6 @@ func (r accessApplicationCAGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationCAGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationCAGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationCAGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessApplicationCAGetResponseEnvelopeErrors] -type accessApplicationCAGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationCAGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationCAGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationCAGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationCAGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationCAGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessApplicationCAGetResponseEnvelopeMessages] -type accessApplicationCAGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationCAGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationCAGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationCAGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accessapplicationpolicy.go b/zero_trust/accessapplicationpolicy.go index 377d61f633c..5a0847a3f7a 100644 --- a/zero_trust/accessapplicationpolicy.go +++ b/zero_trust/accessapplicationpolicy.go @@ -6,15 +6,14 @@ import ( "context" "fmt" "net/http" - "reflect" "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" - "github.com/tidwall/gjson" ) // AccessApplicationPolicyService contains methods and other services that help @@ -36,7 +35,7 @@ func NewAccessApplicationPolicyService(opts ...option.RequestOption) (r *AccessA } // Create a new Access policy for an application. -func (r *AccessApplicationPolicyService) New(ctx context.Context, uuid string, params AccessApplicationPolicyNewParams, opts ...option.RequestOption) (res *ZeroTrustPolicies, err error) { +func (r *AccessApplicationPolicyService) New(ctx context.Context, uuid string, params AccessApplicationPolicyNewParams, opts ...option.RequestOption) (res *Policy, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationPolicyNewResponseEnvelope var accountOrZone string @@ -58,7 +57,7 @@ func (r *AccessApplicationPolicyService) New(ctx context.Context, uuid string, p } // Update a configured Access policy. -func (r *AccessApplicationPolicyService) Update(ctx context.Context, uuid1 string, uuid string, params AccessApplicationPolicyUpdateParams, opts ...option.RequestOption) (res *ZeroTrustPolicies, err error) { +func (r *AccessApplicationPolicyService) Update(ctx context.Context, uuid1 string, uuid string, params AccessApplicationPolicyUpdateParams, opts ...option.RequestOption) (res *Policy, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationPolicyUpdateResponseEnvelope var accountOrZone string @@ -80,7 +79,7 @@ func (r *AccessApplicationPolicyService) Update(ctx context.Context, uuid1 strin } // Lists Access policies configured for an application. -func (r *AccessApplicationPolicyService) List(ctx context.Context, uuid string, query AccessApplicationPolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustPolicies], err error) { +func (r *AccessApplicationPolicyService) List(ctx context.Context, uuid string, query AccessApplicationPolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Policy], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -107,7 +106,7 @@ func (r *AccessApplicationPolicyService) List(ctx context.Context, uuid string, } // Lists Access policies configured for an application. -func (r *AccessApplicationPolicyService) ListAutoPaging(ctx context.Context, uuid string, query AccessApplicationPolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustPolicies] { +func (r *AccessApplicationPolicyService) ListAutoPaging(ctx context.Context, uuid string, query AccessApplicationPolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Policy] { return pagination.NewSinglePageAutoPager(r.List(ctx, uuid, query, opts...)) } @@ -134,7 +133,7 @@ func (r *AccessApplicationPolicyService) Delete(ctx context.Context, uuid1 strin } // Fetches a single Access policy. -func (r *AccessApplicationPolicyService) Get(ctx context.Context, uuid1 string, uuid string, query AccessApplicationPolicyGetParams, opts ...option.RequestOption) (res *ZeroTrustPolicies, err error) { +func (r *AccessApplicationPolicyService) Get(ctx context.Context, uuid1 string, uuid string, query AccessApplicationPolicyGetParams, opts ...option.RequestOption) (res *Policy, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationPolicyGetResponseEnvelope var accountOrZone string @@ -155,23 +154,65 @@ func (r *AccessApplicationPolicyService) Get(ctx context.Context, uuid1 string, return } -type ZeroTrustPolicies struct { +// A group of email addresses that can approve a temporary authentication request. +type ApprovalGroup struct { + // The number of approvals needed to obtain access. + ApprovalsNeeded float64 `json:"approvals_needed,required"` + // A list of emails that can approve the access request. + EmailAddresses []string `json:"email_addresses"` + // The UUID of an re-usable email list. + EmailListUUID string `json:"email_list_uuid"` + JSON approvalGroupJSON `json:"-"` +} + +// approvalGroupJSON contains the JSON metadata for the struct [ApprovalGroup] +type approvalGroupJSON struct { + ApprovalsNeeded apijson.Field + EmailAddresses apijson.Field + EmailListUUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ApprovalGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r approvalGroupJSON) RawJSON() string { + return r.raw +} + +// A group of email addresses that can approve a temporary authentication request. +type ApprovalGroupParam struct { + // The number of approvals needed to obtain access. + ApprovalsNeeded param.Field[float64] `json:"approvals_needed,required"` + // A list of emails that can approve the access request. + EmailAddresses param.Field[[]string] `json:"email_addresses"` + // The UUID of an re-usable email list. + EmailListUUID param.Field[string] `json:"email_list_uuid"` +} + +func (r ApprovalGroupParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Policy struct { // UUID ID string `json:"id"` // Administrators who can approve a temporary authentication request. - ApprovalGroups []ZeroTrustPoliciesApprovalGroup `json:"approval_groups"` + ApprovalGroups []ApprovalGroup `json:"approval_groups"` // Requires the user to request access from an administrator at the start of each // session. ApprovalRequired bool `json:"approval_required"` CreatedAt time.Time `json:"created_at" format:"date-time"` // The action Access will take if a user matches this policy. - Decision ZeroTrustPoliciesDecision `json:"decision"` + Decision PolicyDecision `json:"decision"` // Rules evaluated with a NOT logical operator. To match the policy, a user cannot // meet any of the Exclude rules. - Exclude []ZeroTrustPoliciesExclude `json:"exclude"` + Exclude []AccessRule `json:"exclude"` // Rules evaluated with an OR logical operator. A user needs to meet only one of // the Include rules. - Include []ZeroTrustPoliciesInclude `json:"include"` + Include []AccessRule `json:"include"` // Require this application to be served in an isolated browser for users matching // this policy. 'Client Web Isolation' must be on for the account in order to use // this feature. @@ -186,18 +227,17 @@ type ZeroTrustPolicies struct { PurposeJustificationRequired bool `json:"purpose_justification_required"` // Rules evaluated with an AND logical operator. To match the policy, a user must // meet all of the Require rules. - Require []ZeroTrustPoliciesRequire `json:"require"` + Require []AccessRule `json:"require"` // The amount of time that tokens issued for the application will be valid. Must be // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, // m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustPoliciesJSON `json:"-"` + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON policyJSON `json:"-"` } -// zeroTrustPoliciesJSON contains the JSON metadata for the struct -// [ZeroTrustPolicies] -type zeroTrustPoliciesJSON struct { +// policyJSON contains the JSON metadata for the struct [Policy] +type policyJSON struct { ID apijson.Field ApprovalGroups apijson.Field ApprovalRequired apijson.Field @@ -217,5666 +257,262 @@ type zeroTrustPoliciesJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustPolicies) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesJSON) RawJSON() string { - return r.raw -} - -// A group of email addresses that can approve a temporary authentication request. -type ZeroTrustPoliciesApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded float64 `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses []string `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID string `json:"email_list_uuid"` - JSON zeroTrustPoliciesApprovalGroupJSON `json:"-"` -} - -// zeroTrustPoliciesApprovalGroupJSON contains the JSON metadata for the struct -// [ZeroTrustPoliciesApprovalGroup] -type zeroTrustPoliciesApprovalGroupJSON struct { - ApprovalsNeeded apijson.Field - EmailAddresses apijson.Field - EmailListUUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesApprovalGroup) UnmarshalJSON(data []byte) (err error) { +func (r *Policy) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustPoliciesApprovalGroupJSON) RawJSON() string { +func (r policyJSON) RawJSON() string { return r.raw } // The action Access will take if a user matches this policy. -type ZeroTrustPoliciesDecision string - -const ( - ZeroTrustPoliciesDecisionAllow ZeroTrustPoliciesDecision = "allow" - ZeroTrustPoliciesDecisionDeny ZeroTrustPoliciesDecision = "deny" - ZeroTrustPoliciesDecisionNonIdentity ZeroTrustPoliciesDecision = "non_identity" - ZeroTrustPoliciesDecisionBypass ZeroTrustPoliciesDecision = "bypass" -) - -func (r ZeroTrustPoliciesDecision) IsKnown() bool { - switch r { - case ZeroTrustPoliciesDecisionAllow, ZeroTrustPoliciesDecisionDeny, ZeroTrustPoliciesDecisionNonIdentity, ZeroTrustPoliciesDecisionBypass: - return true - } - return false -} - -// Matches a specific email. -// -// Union satisfied by [zero_trust.ZeroTrustPoliciesExcludeAccessEmailRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessEmailListRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessDomainRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessEveryoneRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessIPRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessIPListRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessCertificateRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessAccessGroupRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessAzureGroupRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessGitHubOrganizationRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessGsuiteGroupRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessOktaGroupRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessSamlGroupRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessServiceTokenRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessAnyValidServiceTokenRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessExternalEvaluationRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessCountryRule], -// [zero_trust.ZeroTrustPoliciesExcludeAccessAuthenticationMethodRule] or -// [zero_trust.ZeroTrustPoliciesExcludeAccessDevicePostureRule]. -type ZeroTrustPoliciesExclude interface { - implementsZeroTrustZeroTrustPoliciesExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustPoliciesExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustPoliciesExcludeAccessEmailRule struct { - Email ZeroTrustPoliciesExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustPoliciesExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessEmailRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesExcludeAccessEmailRule] -type zeroTrustPoliciesExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessEmailRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustPoliciesExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessEmailRuleEmailJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessEmailRuleEmail] -type zeroTrustPoliciesExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustPoliciesExcludeAccessEmailListRule struct { - EmailList ZeroTrustPoliciesExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustPoliciesExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessEmailListRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessEmailListRule] -type zeroTrustPoliciesExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessEmailListRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustPoliciesExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessEmailListRuleEmailListJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessEmailListRuleEmailList] -type zeroTrustPoliciesExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustPoliciesExcludeAccessDomainRule struct { - EmailDomain ZeroTrustPoliciesExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustPoliciesExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessDomainRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesExcludeAccessDomainRule] -type zeroTrustPoliciesExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessDomainRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustPoliciesExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessDomainRuleEmailDomainJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessDomainRuleEmailDomain] -type zeroTrustPoliciesExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustPoliciesExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustPoliciesExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessEveryoneRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessEveryoneRule] -type zeroTrustPoliciesExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessEveryoneRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -// Matches an IP address block. -type ZeroTrustPoliciesExcludeAccessIPRule struct { - IP ZeroTrustPoliciesExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustPoliciesExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessIPRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesExcludeAccessIPRule] -type zeroTrustPoliciesExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessIPRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustPoliciesExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessIPRuleIPJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesExcludeAccessIPRuleIP] -type zeroTrustPoliciesExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustPoliciesExcludeAccessIPListRule struct { - IPList ZeroTrustPoliciesExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustPoliciesExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessIPListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesExcludeAccessIPListRule] -type zeroTrustPoliciesExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessIPListRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustPoliciesExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessIPListRuleIPListJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesExcludeAccessIPListRuleIPList] -type zeroTrustPoliciesExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustPoliciesExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustPoliciesExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessCertificateRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessCertificateRule] -type zeroTrustPoliciesExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessCertificateRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -// Matches an Access group. -type ZeroTrustPoliciesExcludeAccessAccessGroupRule struct { - Group ZeroTrustPoliciesExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustPoliciesExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessAccessGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessAccessGroupRule] -type zeroTrustPoliciesExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessAccessGroupRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -type ZeroTrustPoliciesExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustPoliciesExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessAccessGroupRuleGroupJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessAccessGroupRuleGroup] -type zeroTrustPoliciesExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustPoliciesExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustPoliciesExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessAzureGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessAzureGroupRule] -type zeroTrustPoliciesExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessAzureGroupRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAdJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustPoliciesExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessGitHubOrganizationRule] -type zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessGitHubOrganizationRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -type ZeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustPoliciesExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustPoliciesExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessGsuiteGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessGsuiteGroupRule] -type zeroTrustPoliciesExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessGsuiteGroupRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -type ZeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustPoliciesExcludeAccessOktaGroupRule struct { - Okta ZeroTrustPoliciesExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustPoliciesExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessOktaGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessOktaGroupRule] -type zeroTrustPoliciesExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessOktaGroupRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustPoliciesExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessOktaGroupRuleOktaJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesExcludeAccessOktaGroupRuleOkta] -type zeroTrustPoliciesExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustPoliciesExcludeAccessSamlGroupRule struct { - Saml ZeroTrustPoliciesExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustPoliciesExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessSamlGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessSamlGroupRule] -type zeroTrustPoliciesExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessSamlGroupRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustPoliciesExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessSamlGroupRuleSamlJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesExcludeAccessSamlGroupRuleSaml] -type zeroTrustPoliciesExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustPoliciesExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustPoliciesExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustPoliciesExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessServiceTokenRuleJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesExcludeAccessServiceTokenRule] -type zeroTrustPoliciesExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessServiceTokenRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -type ZeroTrustPoliciesExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON contains the JSON -// metadata for the struct -// [ZeroTrustPoliciesExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustPoliciesExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustPoliciesExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessAnyValidServiceTokenRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessAnyValidServiceTokenRule] -type zeroTrustPoliciesExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustPoliciesExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustPoliciesExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessExternalEvaluationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessExternalEvaluationRule] -type zeroTrustPoliciesExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessExternalEvaluationRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -type ZeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustPoliciesExcludeAccessCountryRule struct { - Geo ZeroTrustPoliciesExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustPoliciesExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessCountryRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesExcludeAccessCountryRule] -type zeroTrustPoliciesExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessCountryRule) implementsZeroTrustZeroTrustPoliciesExclude() {} - -type ZeroTrustPoliciesExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustPoliciesExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessCountryRuleGeoJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesExcludeAccessCountryRuleGeo] -type zeroTrustPoliciesExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustPoliciesExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesExcludeAccessAuthenticationMethodRule] -type zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessAuthenticationMethodRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -type ZeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON contains -// the JSON metadata for the struct -// [ZeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustPoliciesExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustPoliciesExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessDevicePostureRuleJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesExcludeAccessDevicePostureRule] -type zeroTrustPoliciesExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesExcludeAccessDevicePostureRule) implementsZeroTrustZeroTrustPoliciesExclude() { -} - -type ZeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON contains the -// JSON metadata for the struct -// [ZeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [zero_trust.ZeroTrustPoliciesIncludeAccessEmailRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessEmailListRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessDomainRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessEveryoneRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessIPRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessIPListRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessCertificateRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessAccessGroupRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessAzureGroupRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessGitHubOrganizationRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessGsuiteGroupRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessOktaGroupRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessSamlGroupRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessServiceTokenRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessAnyValidServiceTokenRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessExternalEvaluationRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessCountryRule], -// [zero_trust.ZeroTrustPoliciesIncludeAccessAuthenticationMethodRule] or -// [zero_trust.ZeroTrustPoliciesIncludeAccessDevicePostureRule]. -type ZeroTrustPoliciesInclude interface { - implementsZeroTrustZeroTrustPoliciesInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustPoliciesInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustPoliciesIncludeAccessEmailRule struct { - Email ZeroTrustPoliciesIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustPoliciesIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessEmailRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesIncludeAccessEmailRule] -type zeroTrustPoliciesIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessEmailRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustPoliciesIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessEmailRuleEmailJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessEmailRuleEmail] -type zeroTrustPoliciesIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustPoliciesIncludeAccessEmailListRule struct { - EmailList ZeroTrustPoliciesIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustPoliciesIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessEmailListRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessEmailListRule] -type zeroTrustPoliciesIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessEmailListRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustPoliciesIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessEmailListRuleEmailListJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessEmailListRuleEmailList] -type zeroTrustPoliciesIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustPoliciesIncludeAccessDomainRule struct { - EmailDomain ZeroTrustPoliciesIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustPoliciesIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessDomainRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesIncludeAccessDomainRule] -type zeroTrustPoliciesIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessDomainRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustPoliciesIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessDomainRuleEmailDomainJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessDomainRuleEmailDomain] -type zeroTrustPoliciesIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustPoliciesIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustPoliciesIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessEveryoneRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessEveryoneRule] -type zeroTrustPoliciesIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessEveryoneRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -// Matches an IP address block. -type ZeroTrustPoliciesIncludeAccessIPRule struct { - IP ZeroTrustPoliciesIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustPoliciesIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessIPRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesIncludeAccessIPRule] -type zeroTrustPoliciesIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessIPRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustPoliciesIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessIPRuleIPJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesIncludeAccessIPRuleIP] -type zeroTrustPoliciesIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustPoliciesIncludeAccessIPListRule struct { - IPList ZeroTrustPoliciesIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustPoliciesIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessIPListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesIncludeAccessIPListRule] -type zeroTrustPoliciesIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessIPListRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustPoliciesIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessIPListRuleIPListJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesIncludeAccessIPListRuleIPList] -type zeroTrustPoliciesIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustPoliciesIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustPoliciesIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessCertificateRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessCertificateRule] -type zeroTrustPoliciesIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessCertificateRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -// Matches an Access group. -type ZeroTrustPoliciesIncludeAccessAccessGroupRule struct { - Group ZeroTrustPoliciesIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustPoliciesIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessAccessGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessAccessGroupRule] -type zeroTrustPoliciesIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessAccessGroupRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -type ZeroTrustPoliciesIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustPoliciesIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessAccessGroupRuleGroupJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessAccessGroupRuleGroup] -type zeroTrustPoliciesIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustPoliciesIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustPoliciesIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessAzureGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessAzureGroupRule] -type zeroTrustPoliciesIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessAzureGroupRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAdJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustPoliciesIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessGitHubOrganizationRule] -type zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessGitHubOrganizationRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -type ZeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustPoliciesIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustPoliciesIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessGsuiteGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessGsuiteGroupRule] -type zeroTrustPoliciesIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessGsuiteGroupRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -type ZeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustPoliciesIncludeAccessOktaGroupRule struct { - Okta ZeroTrustPoliciesIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustPoliciesIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessOktaGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessOktaGroupRule] -type zeroTrustPoliciesIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessOktaGroupRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustPoliciesIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessOktaGroupRuleOktaJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesIncludeAccessOktaGroupRuleOkta] -type zeroTrustPoliciesIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustPoliciesIncludeAccessSamlGroupRule struct { - Saml ZeroTrustPoliciesIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustPoliciesIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessSamlGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessSamlGroupRule] -type zeroTrustPoliciesIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessSamlGroupRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustPoliciesIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessSamlGroupRuleSamlJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesIncludeAccessSamlGroupRuleSaml] -type zeroTrustPoliciesIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustPoliciesIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustPoliciesIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustPoliciesIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessServiceTokenRuleJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesIncludeAccessServiceTokenRule] -type zeroTrustPoliciesIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessServiceTokenRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -type ZeroTrustPoliciesIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON contains the JSON -// metadata for the struct -// [ZeroTrustPoliciesIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustPoliciesIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustPoliciesIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessAnyValidServiceTokenRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessAnyValidServiceTokenRule] -type zeroTrustPoliciesIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustPoliciesIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustPoliciesIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessExternalEvaluationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessExternalEvaluationRule] -type zeroTrustPoliciesIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessExternalEvaluationRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -type ZeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustPoliciesIncludeAccessCountryRule struct { - Geo ZeroTrustPoliciesIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustPoliciesIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessCountryRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesIncludeAccessCountryRule] -type zeroTrustPoliciesIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessCountryRule) implementsZeroTrustZeroTrustPoliciesInclude() {} - -type ZeroTrustPoliciesIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustPoliciesIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessCountryRuleGeoJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesIncludeAccessCountryRuleGeo] -type zeroTrustPoliciesIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustPoliciesIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesIncludeAccessAuthenticationMethodRule] -type zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessAuthenticationMethodRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -type ZeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON contains -// the JSON metadata for the struct -// [ZeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustPoliciesIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustPoliciesIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessDevicePostureRuleJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesIncludeAccessDevicePostureRule] -type zeroTrustPoliciesIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesIncludeAccessDevicePostureRule) implementsZeroTrustZeroTrustPoliciesInclude() { -} - -type ZeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON contains the -// JSON metadata for the struct -// [ZeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [zero_trust.ZeroTrustPoliciesRequireAccessEmailRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessEmailListRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessDomainRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessEveryoneRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessIPRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessIPListRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessCertificateRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessAccessGroupRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessAzureGroupRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessGitHubOrganizationRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessGsuiteGroupRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessOktaGroupRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessSamlGroupRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessServiceTokenRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessAnyValidServiceTokenRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessExternalEvaluationRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessCountryRule], -// [zero_trust.ZeroTrustPoliciesRequireAccessAuthenticationMethodRule] or -// [zero_trust.ZeroTrustPoliciesRequireAccessDevicePostureRule]. -type ZeroTrustPoliciesRequire interface { - implementsZeroTrustZeroTrustPoliciesRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustPoliciesRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustPoliciesRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustPoliciesRequireAccessEmailRule struct { - Email ZeroTrustPoliciesRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustPoliciesRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessEmailRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesRequireAccessEmailRule] -type zeroTrustPoliciesRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessEmailRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustPoliciesRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessEmailRuleEmailJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessEmailRuleEmail] -type zeroTrustPoliciesRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustPoliciesRequireAccessEmailListRule struct { - EmailList ZeroTrustPoliciesRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustPoliciesRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessEmailListRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessEmailListRule] -type zeroTrustPoliciesRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessEmailListRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustPoliciesRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessEmailListRuleEmailListJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessEmailListRuleEmailList] -type zeroTrustPoliciesRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustPoliciesRequireAccessDomainRule struct { - EmailDomain ZeroTrustPoliciesRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustPoliciesRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessDomainRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesRequireAccessDomainRule] -type zeroTrustPoliciesRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessDomainRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustPoliciesRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessDomainRuleEmailDomainJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessDomainRuleEmailDomain] -type zeroTrustPoliciesRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustPoliciesRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustPoliciesRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessEveryoneRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessEveryoneRule] -type zeroTrustPoliciesRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessEveryoneRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -// Matches an IP address block. -type ZeroTrustPoliciesRequireAccessIPRule struct { - IP ZeroTrustPoliciesRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustPoliciesRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessIPRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesRequireAccessIPRule] -type zeroTrustPoliciesRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessIPRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustPoliciesRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessIPRuleIPJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesRequireAccessIPRuleIP] -type zeroTrustPoliciesRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustPoliciesRequireAccessIPListRule struct { - IPList ZeroTrustPoliciesRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustPoliciesRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessIPListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesRequireAccessIPListRule] -type zeroTrustPoliciesRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessIPListRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustPoliciesRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessIPListRuleIPListJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesRequireAccessIPListRuleIPList] -type zeroTrustPoliciesRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustPoliciesRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustPoliciesRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessCertificateRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessCertificateRule] -type zeroTrustPoliciesRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessCertificateRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -// Matches an Access group. -type ZeroTrustPoliciesRequireAccessAccessGroupRule struct { - Group ZeroTrustPoliciesRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustPoliciesRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessAccessGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessAccessGroupRule] -type zeroTrustPoliciesRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessAccessGroupRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -type ZeroTrustPoliciesRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustPoliciesRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessAccessGroupRuleGroupJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessAccessGroupRuleGroup] -type zeroTrustPoliciesRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustPoliciesRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustPoliciesRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustPoliciesRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessAzureGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessAzureGroupRule] -type zeroTrustPoliciesRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessAzureGroupRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustPoliciesRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessAzureGroupRuleAzureAdJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessAzureGroupRuleAzureAd] -type zeroTrustPoliciesRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustPoliciesRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustPoliciesRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessGitHubOrganizationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessGitHubOrganizationRule] -type zeroTrustPoliciesRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessGitHubOrganizationRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -type ZeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustPoliciesRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustPoliciesRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessGsuiteGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessGsuiteGroupRule] -type zeroTrustPoliciesRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessGsuiteGroupRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -type ZeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustPoliciesRequireAccessOktaGroupRule struct { - Okta ZeroTrustPoliciesRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustPoliciesRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessOktaGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessOktaGroupRule] -type zeroTrustPoliciesRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessOktaGroupRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustPoliciesRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessOktaGroupRuleOktaJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesRequireAccessOktaGroupRuleOkta] -type zeroTrustPoliciesRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustPoliciesRequireAccessSamlGroupRule struct { - Saml ZeroTrustPoliciesRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustPoliciesRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessSamlGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessSamlGroupRule] -type zeroTrustPoliciesRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessSamlGroupRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustPoliciesRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessSamlGroupRuleSamlJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesRequireAccessSamlGroupRuleSaml] -type zeroTrustPoliciesRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustPoliciesRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustPoliciesRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustPoliciesRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessServiceTokenRuleJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesRequireAccessServiceTokenRule] -type zeroTrustPoliciesRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessServiceTokenRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -type ZeroTrustPoliciesRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustPoliciesRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessServiceTokenRuleServiceTokenJSON contains the JSON -// metadata for the struct -// [ZeroTrustPoliciesRequireAccessServiceTokenRuleServiceToken] -type zeroTrustPoliciesRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustPoliciesRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustPoliciesRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessAnyValidServiceTokenRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessAnyValidServiceTokenRule] -type zeroTrustPoliciesRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessAnyValidServiceTokenRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustPoliciesRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustPoliciesRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessExternalEvaluationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessExternalEvaluationRule] -type zeroTrustPoliciesRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessExternalEvaluationRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -type ZeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustPoliciesRequireAccessCountryRule struct { - Geo ZeroTrustPoliciesRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustPoliciesRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessCountryRuleJSON contains the JSON metadata for the -// struct [ZeroTrustPoliciesRequireAccessCountryRule] -type zeroTrustPoliciesRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessCountryRule) implementsZeroTrustZeroTrustPoliciesRequire() {} - -type ZeroTrustPoliciesRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustPoliciesRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessCountryRuleGeoJSON contains the JSON metadata for -// the struct [ZeroTrustPoliciesRequireAccessCountryRuleGeo] -type zeroTrustPoliciesRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustPoliciesRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustPoliciesRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessAuthenticationMethodRuleJSON contains the JSON -// metadata for the struct [ZeroTrustPoliciesRequireAccessAuthenticationMethodRule] -type zeroTrustPoliciesRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessAuthenticationMethodRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -type ZeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON contains -// the JSON metadata for the struct -// [ZeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustPoliciesRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustPoliciesRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustPoliciesRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessDevicePostureRuleJSON contains the JSON metadata -// for the struct [ZeroTrustPoliciesRequireAccessDevicePostureRule] -type zeroTrustPoliciesRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustPoliciesRequireAccessDevicePostureRule) implementsZeroTrustZeroTrustPoliciesRequire() { -} - -type ZeroTrustPoliciesRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustPoliciesRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustPoliciesRequireAccessDevicePostureRuleDevicePostureJSON contains the -// JSON metadata for the struct -// [ZeroTrustPoliciesRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustPoliciesRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustPoliciesRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustPoliciesRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationPolicyDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON accessApplicationPolicyDeleteResponseJSON `json:"-"` -} - -// accessApplicationPolicyDeleteResponseJSON contains the JSON metadata for the -// struct [AccessApplicationPolicyDeleteResponse] -type accessApplicationPolicyDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationPolicyNewParams struct { - // The action Access will take if a user matches this policy. - Decision param.Field[AccessApplicationPolicyNewParamsDecision] `json:"decision,required"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]AccessApplicationPolicyNewParamsInclude] `json:"include,required"` - // The name of the Access policy. - Name param.Field[string] `json:"name,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. - ZoneID param.Field[string] `path:"zone_id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups param.Field[[]AccessApplicationPolicyNewParamsApprovalGroup] `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired param.Field[bool] `json:"approval_required"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]AccessApplicationPolicyNewParamsExclude] `json:"exclude"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired param.Field[bool] `json:"isolation_required"` - // The order of execution for this policy. Must be unique for each policy. - Precedence param.Field[int64] `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require param.Field[[]AccessApplicationPolicyNewParamsRequire] `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration param.Field[string] `json:"session_duration"` -} - -func (r AccessApplicationPolicyNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action Access will take if a user matches this policy. -type AccessApplicationPolicyNewParamsDecision string - -const ( - AccessApplicationPolicyNewParamsDecisionAllow AccessApplicationPolicyNewParamsDecision = "allow" - AccessApplicationPolicyNewParamsDecisionDeny AccessApplicationPolicyNewParamsDecision = "deny" - AccessApplicationPolicyNewParamsDecisionNonIdentity AccessApplicationPolicyNewParamsDecision = "non_identity" - AccessApplicationPolicyNewParamsDecisionBypass AccessApplicationPolicyNewParamsDecision = "bypass" -) - -func (r AccessApplicationPolicyNewParamsDecision) IsKnown() bool { - switch r { - case AccessApplicationPolicyNewParamsDecisionAllow, AccessApplicationPolicyNewParamsDecisionDeny, AccessApplicationPolicyNewParamsDecisionNonIdentity, AccessApplicationPolicyNewParamsDecisionBypass: - return true - } - return false -} - -// Matches a specific email. -// -// Satisfied by -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailListRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessDomainRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessIPRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessIPListRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessCertificateRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessCountryRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule], -// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule]. -type AccessApplicationPolicyNewParamsInclude interface { - implementsZeroTrustAccessApplicationPolicyNewParamsInclude() -} - -// Matches a specific email. -type AccessApplicationPolicyNewParamsIncludeAccessEmailRule struct { - Email param.Field[AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessApplicationPolicyNewParamsIncludeAccessEmailListRule struct { - EmailList param.Field[AccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessApplicationPolicyNewParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[AccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -// Matches an IP address block. -type AccessApplicationPolicyNewParamsIncludeAccessIPRule struct { - IP param.Field[AccessApplicationPolicyNewParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessApplicationPolicyNewParamsIncludeAccessIPListRule struct { - IPList param.Field[AccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessApplicationPolicyNewParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -// Matches an Access group. -type AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule struct { - Group param.Field[AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessApplicationPolicyNewParamsIncludeAccessCountryRule struct { - Geo param.Field[AccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A group of email addresses that can approve a temporary authentication request. -type AccessApplicationPolicyNewParamsApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded param.Field[float64] `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses param.Field[[]string] `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID param.Field[string] `json:"email_list_uuid"` -} - -func (r AccessApplicationPolicyNewParamsApprovalGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailListRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessDomainRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessIPRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessIPListRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessCertificateRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessCountryRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule], -// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule]. -type AccessApplicationPolicyNewParamsExclude interface { - implementsZeroTrustAccessApplicationPolicyNewParamsExclude() -} - -// Matches a specific email. -type AccessApplicationPolicyNewParamsExcludeAccessEmailRule struct { - Email param.Field[AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessApplicationPolicyNewParamsExcludeAccessEmailListRule struct { - EmailList param.Field[AccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessApplicationPolicyNewParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[AccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -// Matches an IP address block. -type AccessApplicationPolicyNewParamsExcludeAccessIPRule struct { - IP param.Field[AccessApplicationPolicyNewParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessApplicationPolicyNewParamsExcludeAccessIPListRule struct { - IPList param.Field[AccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessApplicationPolicyNewParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -// Matches an Access group. -type AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule struct { - Group param.Field[AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessApplicationPolicyNewParamsExcludeAccessCountryRule struct { - Geo param.Field[AccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailListRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessDomainRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessEveryoneRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessIPRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessIPListRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessCertificateRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessCountryRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule], -// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule]. -type AccessApplicationPolicyNewParamsRequire interface { - implementsZeroTrustAccessApplicationPolicyNewParamsRequire() -} - -// Matches a specific email. -type AccessApplicationPolicyNewParamsRequireAccessEmailRule struct { - Email param.Field[AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessApplicationPolicyNewParamsRequireAccessEmailListRule struct { - EmailList param.Field[AccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessApplicationPolicyNewParamsRequireAccessDomainRule struct { - EmailDomain param.Field[AccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessApplicationPolicyNewParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -// Matches an IP address block. -type AccessApplicationPolicyNewParamsRequireAccessIPRule struct { - IP param.Field[AccessApplicationPolicyNewParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessApplicationPolicyNewParamsRequireAccessIPListRule struct { - IPList param.Field[AccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessApplicationPolicyNewParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -// Matches an Access group. -type AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule struct { - Group param.Field[AccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[AccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule struct { - Okta param.Field[AccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule struct { - Saml param.Field[AccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[AccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessApplicationPolicyNewParamsRequireAccessCountryRule struct { - Geo param.Field[AccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[AccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type AccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccessApplicationPolicyNewResponseEnvelope struct { - Errors []AccessApplicationPolicyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationPolicyNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustPolicies `json:"result,required"` - // Whether the API call was successful - Success AccessApplicationPolicyNewResponseEnvelopeSuccess `json:"success,required"` - JSON accessApplicationPolicyNewResponseEnvelopeJSON `json:"-"` -} - -// accessApplicationPolicyNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [AccessApplicationPolicyNewResponseEnvelope] -type accessApplicationPolicyNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationPolicyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationPolicyNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessApplicationPolicyNewResponseEnvelopeErrors] -type accessApplicationPolicyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationPolicyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationPolicyNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessApplicationPolicyNewResponseEnvelopeMessages] -type accessApplicationPolicyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccessApplicationPolicyNewResponseEnvelopeSuccess bool - -const ( - AccessApplicationPolicyNewResponseEnvelopeSuccessTrue AccessApplicationPolicyNewResponseEnvelopeSuccess = true -) - -func (r AccessApplicationPolicyNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case AccessApplicationPolicyNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type AccessApplicationPolicyUpdateParams struct { - // The action Access will take if a user matches this policy. - Decision param.Field[AccessApplicationPolicyUpdateParamsDecision] `json:"decision,required"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]AccessApplicationPolicyUpdateParamsInclude] `json:"include,required"` - // The name of the Access policy. - Name param.Field[string] `json:"name,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. - ZoneID param.Field[string] `path:"zone_id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups param.Field[[]AccessApplicationPolicyUpdateParamsApprovalGroup] `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired param.Field[bool] `json:"approval_required"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]AccessApplicationPolicyUpdateParamsExclude] `json:"exclude"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired param.Field[bool] `json:"isolation_required"` - // The order of execution for this policy. Must be unique for each policy. - Precedence param.Field[int64] `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require param.Field[[]AccessApplicationPolicyUpdateParamsRequire] `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration param.Field[string] `json:"session_duration"` -} - -func (r AccessApplicationPolicyUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action Access will take if a user matches this policy. -type AccessApplicationPolicyUpdateParamsDecision string - -const ( - AccessApplicationPolicyUpdateParamsDecisionAllow AccessApplicationPolicyUpdateParamsDecision = "allow" - AccessApplicationPolicyUpdateParamsDecisionDeny AccessApplicationPolicyUpdateParamsDecision = "deny" - AccessApplicationPolicyUpdateParamsDecisionNonIdentity AccessApplicationPolicyUpdateParamsDecision = "non_identity" - AccessApplicationPolicyUpdateParamsDecisionBypass AccessApplicationPolicyUpdateParamsDecision = "bypass" -) - -func (r AccessApplicationPolicyUpdateParamsDecision) IsKnown() bool { - switch r { - case AccessApplicationPolicyUpdateParamsDecisionAllow, AccessApplicationPolicyUpdateParamsDecisionDeny, AccessApplicationPolicyUpdateParamsDecisionNonIdentity, AccessApplicationPolicyUpdateParamsDecisionBypass: - return true - } - return false -} - -// Matches a specific email. -// -// Satisfied by -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessIPRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule]. -type AccessApplicationPolicyUpdateParamsInclude interface { - implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() -} - -// Matches a specific email. -type AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule struct { - Email param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule struct { - EmailList param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -// Matches an IP address block. -type AccessApplicationPolicyUpdateParamsIncludeAccessIPRule struct { - IP param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule struct { - IPList param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -// Matches an Access group. -type AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule struct { - Group param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule struct { - Geo param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A group of email addresses that can approve a temporary authentication request. -type AccessApplicationPolicyUpdateParamsApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded param.Field[float64] `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses param.Field[[]string] `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID param.Field[string] `json:"email_list_uuid"` -} - -func (r AccessApplicationPolicyUpdateParamsApprovalGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessIPRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule]. -type AccessApplicationPolicyUpdateParamsExclude interface { - implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() -} - -// Matches a specific email. -type AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule struct { - Email param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule struct { - EmailList param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -// Matches an IP address block. -type AccessApplicationPolicyUpdateParamsExcludeAccessIPRule struct { - IP param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule struct { - IPList param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -// Matches an Access group. -type AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule struct { - Group param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule struct { - Geo param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessDomainRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessIPRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessIPListRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessCountryRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule], -// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule]. -type AccessApplicationPolicyUpdateParamsRequire interface { - implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() -} - -// Matches a specific email. -type AccessApplicationPolicyUpdateParamsRequireAccessEmailRule struct { - Email param.Field[AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule struct { - EmailList param.Field[AccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessApplicationPolicyUpdateParamsRequireAccessDomainRule struct { - EmailDomain param.Field[AccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -// Matches an IP address block. -type AccessApplicationPolicyUpdateParamsRequireAccessIPRule struct { - IP param.Field[AccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessApplicationPolicyUpdateParamsRequireAccessIPListRule struct { - IPList param.Field[AccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -// Matches an Access group. -type AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule struct { - Group param.Field[AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule struct { - Okta param.Field[AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule struct { - Saml param.Field[AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} +type PolicyDecision string -type AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} +const ( + PolicyDecisionAllow PolicyDecision = "allow" + PolicyDecisionDeny PolicyDecision = "deny" + PolicyDecisionNonIdentity PolicyDecision = "non_identity" + PolicyDecisionBypass PolicyDecision = "bypass" +) -func (r AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r PolicyDecision) IsKnown() bool { + switch r { + case PolicyDecisionAllow, PolicyDecisionDeny, PolicyDecisionNonIdentity, PolicyDecisionBypass: + return true + } + return false } -// Matches any valid Access Service Token -type AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +type PolicyParam struct { + // Administrators who can approve a temporary authentication request. + ApprovalGroups param.Field[[]ApprovalGroupParam] `json:"approval_groups"` + // Requires the user to request access from an administrator at the start of each + // session. + ApprovalRequired param.Field[bool] `json:"approval_required"` + // The action Access will take if a user matches this policy. + Decision param.Field[PolicyDecision] `json:"decision"` + // Rules evaluated with a NOT logical operator. To match the policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessRuleUnionParam] `json:"exclude"` + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessRuleUnionParam] `json:"include"` + // Require this application to be served in an isolated browser for users matching + // this policy. 'Client Web Isolation' must be on for the account in order to use + // this feature. + IsolationRequired param.Field[bool] `json:"isolation_required"` + // The name of the Access policy. + Name param.Field[string] `json:"name"` + // The order of execution for this policy. Must be unique for each policy. + Precedence param.Field[int64] `json:"precedence"` + // A custom message that will appear on the purpose justification screen. + PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` + // Require users to enter a justification when they log in to the application. + PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` + // Rules evaluated with an AND logical operator. To match the policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessRuleUnionParam] `json:"require"` + // The amount of time that tokens issued for the application will be valid. Must be + // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + // m, h. + SessionDuration param.Field[string] `json:"session_duration"` } -func (r AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { +func (r PolicyParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +type AccessApplicationPolicyDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessApplicationPolicyDeleteResponseJSON `json:"-"` } -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +// accessApplicationPolicyDeleteResponseJSON contains the JSON metadata for the +// struct [AccessApplicationPolicyDeleteResponse] +type accessApplicationPolicyDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *AccessApplicationPolicyDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +func (r accessApplicationPolicyDeleteResponseJSON) RawJSON() string { + return r.raw } -type AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` +type AccessApplicationPolicyNewParams struct { + // The action Access will take if a user matches this policy. + Decision param.Field[AccessApplicationPolicyNewParamsDecision] `json:"decision,required"` + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessRuleUnionParam] `json:"include,required"` + // The name of the Access policy. + Name param.Field[string] `json:"name,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. + ZoneID param.Field[string] `path:"zone_id"` + // Administrators who can approve a temporary authentication request. + ApprovalGroups param.Field[[]ApprovalGroupParam] `json:"approval_groups"` + // Requires the user to request access from an administrator at the start of each + // session. + ApprovalRequired param.Field[bool] `json:"approval_required"` + // Rules evaluated with a NOT logical operator. To match the policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessRuleUnionParam] `json:"exclude"` + // Require this application to be served in an isolated browser for users matching + // this policy. 'Client Web Isolation' must be on for the account in order to use + // this feature. + IsolationRequired param.Field[bool] `json:"isolation_required"` + // The order of execution for this policy. Must be unique for each policy. + Precedence param.Field[int64] `json:"precedence"` + // A custom message that will appear on the purpose justification screen. + PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` + // Require users to enter a justification when they log in to the application. + PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` + // Rules evaluated with an AND logical operator. To match the policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessRuleUnionParam] `json:"require"` + // The amount of time that tokens issued for the application will be valid. Must be + // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + // m, h. + SessionDuration param.Field[string] `json:"session_duration"` } -func (r AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { +func (r AccessApplicationPolicyNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Matches a specific country -type AccessApplicationPolicyUpdateParamsRequireAccessCountryRule struct { - Geo param.Field[AccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} +// The action Access will take if a user matches this policy. +type AccessApplicationPolicyNewParamsDecision string -func (r AccessApplicationPolicyUpdateParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} +const ( + AccessApplicationPolicyNewParamsDecisionAllow AccessApplicationPolicyNewParamsDecision = "allow" + AccessApplicationPolicyNewParamsDecisionDeny AccessApplicationPolicyNewParamsDecision = "deny" + AccessApplicationPolicyNewParamsDecisionNonIdentity AccessApplicationPolicyNewParamsDecision = "non_identity" + AccessApplicationPolicyNewParamsDecisionBypass AccessApplicationPolicyNewParamsDecision = "bypass" +) -func (r AccessApplicationPolicyUpdateParamsRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +func (r AccessApplicationPolicyNewParamsDecision) IsKnown() bool { + switch r { + case AccessApplicationPolicyNewParamsDecisionAllow, AccessApplicationPolicyNewParamsDecisionDeny, AccessApplicationPolicyNewParamsDecisionNonIdentity, AccessApplicationPolicyNewParamsDecisionBypass: + return true + } + return false } -type AccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` +type AccessApplicationPolicyNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Policy `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationPolicyNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationPolicyNewResponseEnvelopeJSON `json:"-"` } -func (r AccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// accessApplicationPolicyNewResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessApplicationPolicyNewResponseEnvelope] +type accessApplicationPolicyNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Enforce different MFA options -type AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +func (r *AccessApplicationPolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r accessApplicationPolicyNewResponseEnvelopeJSON) RawJSON() string { + return r.raw } -func (r AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} +// Whether the API call was successful +type AccessApplicationPolicyNewResponseEnvelopeSuccess bool -type AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} +const ( + AccessApplicationPolicyNewResponseEnvelopeSuccessTrue AccessApplicationPolicyNewResponseEnvelopeSuccess = true +) -func (r AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r AccessApplicationPolicyNewResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case AccessApplicationPolicyNewResponseEnvelopeSuccessTrue: + return true + } + return false } -// Enforces a device posture rule has run successfully -type AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +type AccessApplicationPolicyUpdateParams struct { + // The action Access will take if a user matches this policy. + Decision param.Field[AccessApplicationPolicyUpdateParamsDecision] `json:"decision,required"` + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessRuleUnionParam] `json:"include,required"` + // The name of the Access policy. + Name param.Field[string] `json:"name,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. + ZoneID param.Field[string] `path:"zone_id"` + // Administrators who can approve a temporary authentication request. + ApprovalGroups param.Field[[]ApprovalGroupParam] `json:"approval_groups"` + // Requires the user to request access from an administrator at the start of each + // session. + ApprovalRequired param.Field[bool] `json:"approval_required"` + // Rules evaluated with a NOT logical operator. To match the policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessRuleUnionParam] `json:"exclude"` + // Require this application to be served in an isolated browser for users matching + // this policy. 'Client Web Isolation' must be on for the account in order to use + // this feature. + IsolationRequired param.Field[bool] `json:"isolation_required"` + // The order of execution for this policy. Must be unique for each policy. + Precedence param.Field[int64] `json:"precedence"` + // A custom message that will appear on the purpose justification screen. + PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` + // Require users to enter a justification when they log in to the application. + PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` + // Rules evaluated with an AND logical operator. To match the policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessRuleUnionParam] `json:"require"` + // The amount of time that tokens issued for the application will be valid. Must be + // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + // m, h. + SessionDuration param.Field[string] `json:"session_duration"` } -func (r AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { +func (r AccessApplicationPolicyUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} +// The action Access will take if a user matches this policy. +type AccessApplicationPolicyUpdateParamsDecision string -type AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} +const ( + AccessApplicationPolicyUpdateParamsDecisionAllow AccessApplicationPolicyUpdateParamsDecision = "allow" + AccessApplicationPolicyUpdateParamsDecisionDeny AccessApplicationPolicyUpdateParamsDecision = "deny" + AccessApplicationPolicyUpdateParamsDecisionNonIdentity AccessApplicationPolicyUpdateParamsDecision = "non_identity" + AccessApplicationPolicyUpdateParamsDecisionBypass AccessApplicationPolicyUpdateParamsDecision = "bypass" +) -func (r AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r AccessApplicationPolicyUpdateParamsDecision) IsKnown() bool { + switch r { + case AccessApplicationPolicyUpdateParamsDecisionAllow, AccessApplicationPolicyUpdateParamsDecisionDeny, AccessApplicationPolicyUpdateParamsDecisionNonIdentity, AccessApplicationPolicyUpdateParamsDecisionBypass: + return true + } + return false } type AccessApplicationPolicyUpdateResponseEnvelope struct { - Errors []AccessApplicationPolicyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationPolicyUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustPolicies `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Policy `json:"result,required"` // Whether the API call was successful Success AccessApplicationPolicyUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationPolicyUpdateResponseEnvelopeJSON `json:"-"` @@ -5901,52 +537,6 @@ func (r accessApplicationPolicyUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationPolicyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AccessApplicationPolicyUpdateResponseEnvelopeErrors] -type accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationPolicyUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessApplicationPolicyUpdateResponseEnvelopeMessages] -type accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationPolicyUpdateResponseEnvelopeSuccess bool @@ -5977,9 +567,9 @@ type AccessApplicationPolicyDeleteParams struct { } type AccessApplicationPolicyDeleteResponseEnvelope struct { - Errors []AccessApplicationPolicyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationPolicyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessApplicationPolicyDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessApplicationPolicyDeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessApplicationPolicyDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationPolicyDeleteResponseEnvelopeJSON `json:"-"` @@ -6004,52 +594,6 @@ func (r accessApplicationPolicyDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationPolicyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AccessApplicationPolicyDeleteResponseEnvelopeErrors] -type accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationPolicyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessApplicationPolicyDeleteResponseEnvelopeMessages] -type accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationPolicyDeleteResponseEnvelopeSuccess bool @@ -6073,9 +617,9 @@ type AccessApplicationPolicyGetParams struct { } type AccessApplicationPolicyGetResponseEnvelope struct { - Errors []AccessApplicationPolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationPolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustPolicies `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Policy `json:"result,required"` // Whether the API call was successful Success AccessApplicationPolicyGetResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationPolicyGetResponseEnvelopeJSON `json:"-"` @@ -6100,52 +644,6 @@ func (r accessApplicationPolicyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessApplicationPolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationPolicyGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessApplicationPolicyGetResponseEnvelopeErrors] -type accessApplicationPolicyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationPolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationPolicyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationPolicyGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessApplicationPolicyGetResponseEnvelopeMessages] -type accessApplicationPolicyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationPolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationPolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationPolicyGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accessapplicationpolicy_test.go b/zero_trust/accessapplicationpolicy_test.go index 0f2c2fcc19c..cae43abecca 100644 --- a/zero_trust/accessapplicationpolicy_test.go +++ b/zero_trust/accessapplicationpolicy_test.go @@ -33,23 +33,23 @@ func TestAccessApplicationPolicyNewWithOptionalParams(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.AccessApplicationPolicyNewParams{ Decision: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsDecisionAllow), - Include: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsInclude{zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ + Include: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), Name: cloudflare.F("Allow devs"), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - ApprovalGroups: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsApprovalGroup{{ + ApprovalGroups: cloudflare.F([]zero_trust.ApprovalGroupParam{{ ApprovalsNeeded: cloudflare.F(1.000000), EmailAddresses: cloudflare.F([]string{"test1@cloudflare.com", "test2@cloudflare.com"}), EmailListUUID: cloudflare.F("string"), @@ -59,36 +59,36 @@ func TestAccessApplicationPolicyNewWithOptionalParams(t *testing.T) { EmailListUUID: cloudflare.F("597147a1-976b-4ef2-9af0-81d5d007fc34"), }}), ApprovalRequired: cloudflare.F(true), - Exclude: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsExclude{zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ + Exclude: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), IsolationRequired: cloudflare.F(false), Precedence: cloudflare.F(int64(0)), PurposeJustificationPrompt: cloudflare.F("Please enter a justification for entering this protected domain."), PurposeJustificationRequired: cloudflare.F(true), - Require: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsRequire{zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ + Require: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), SessionDuration: cloudflare.F("24h"), }, ) @@ -121,23 +121,23 @@ func TestAccessApplicationPolicyUpdateWithOptionalParams(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.AccessApplicationPolicyUpdateParams{ Decision: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsDecisionAllow), - Include: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsInclude{zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ + Include: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), Name: cloudflare.F("Allow devs"), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - ApprovalGroups: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsApprovalGroup{{ + ApprovalGroups: cloudflare.F([]zero_trust.ApprovalGroupParam{{ ApprovalsNeeded: cloudflare.F(1.000000), EmailAddresses: cloudflare.F([]string{"test1@cloudflare.com", "test2@cloudflare.com"}), EmailListUUID: cloudflare.F("string"), @@ -147,36 +147,36 @@ func TestAccessApplicationPolicyUpdateWithOptionalParams(t *testing.T) { EmailListUUID: cloudflare.F("597147a1-976b-4ef2-9af0-81d5d007fc34"), }}), ApprovalRequired: cloudflare.F(true), - Exclude: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsExclude{zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ + Exclude: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), IsolationRequired: cloudflare.F(false), Precedence: cloudflare.F(int64(0)), PurposeJustificationPrompt: cloudflare.F("Please enter a justification for entering this protected domain."), PurposeJustificationRequired: cloudflare.F(true), - Require: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsRequire{zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ + Require: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), SessionDuration: cloudflare.F("24h"), }, ) diff --git a/zero_trust/accessapplicationuserpolicycheck.go b/zero_trust/accessapplicationuserpolicycheck.go index 57d544d9f1b..595405ba8d0 100644 --- a/zero_trust/accessapplicationuserpolicycheck.go +++ b/zero_trust/accessapplicationuserpolicycheck.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewAccessApplicationUserPolicyCheckService(opts ...option.RequestOption) (r } // Tests if a specific user has permission to access an application. -func (r *AccessApplicationUserPolicyCheckService) List(ctx context.Context, appID AccessApplicationUserPolicyCheckListParamsAppID, query AccessApplicationUserPolicyCheckListParams, opts ...option.RequestOption) (res *AccessApplicationUserPolicyCheckListResponse, err error) { +func (r *AccessApplicationUserPolicyCheckService) List(ctx context.Context, appID AppIDUnionParam, query AccessApplicationUserPolicyCheckListParams, opts ...option.RequestOption) (res *AccessApplicationUserPolicyCheckListResponse, err error) { opts = append(r.Options[:], opts...) var env AccessApplicationUserPolicyCheckListResponseEnvelope var accountOrZone string @@ -53,6 +54,27 @@ func (r *AccessApplicationUserPolicyCheckService) List(ctx context.Context, appI return } +type UserPolicyCheckGeo struct { + Country string `json:"country"` + JSON userPolicyCheckGeoJSON `json:"-"` +} + +// userPolicyCheckGeoJSON contains the JSON metadata for the struct +// [UserPolicyCheckGeo] +type userPolicyCheckGeoJSON struct { + Country apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UserPolicyCheckGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r userPolicyCheckGeoJSON) RawJSON() string { + return r.raw +} + type AccessApplicationUserPolicyCheckListResponse struct { AppState AccessApplicationUserPolicyCheckListResponseAppState `json:"app_state"` UserIdentity AccessApplicationUserPolicyCheckListResponseUserIdentity `json:"user_identity"` @@ -78,7 +100,7 @@ func (r accessApplicationUserPolicyCheckListResponseJSON) RawJSON() string { type AccessApplicationUserPolicyCheckListResponseAppState struct { // UUID - AppUid string `json:"app_uid"` + AppUID string `json:"app_uid"` Aud string `json:"aud"` Hostname string `json:"hostname"` Name string `json:"name"` @@ -90,7 +112,7 @@ type AccessApplicationUserPolicyCheckListResponseAppState struct { // accessApplicationUserPolicyCheckListResponseAppStateJSON contains the JSON // metadata for the struct [AccessApplicationUserPolicyCheckListResponseAppState] type accessApplicationUserPolicyCheckListResponseAppStateJSON struct { - AppUid apijson.Field + AppUID apijson.Field Aud apijson.Field Hostname apijson.Field Name apijson.Field @@ -109,15 +131,15 @@ func (r accessApplicationUserPolicyCheckListResponseAppStateJSON) RawJSON() stri } type AccessApplicationUserPolicyCheckListResponseUserIdentity struct { - ID string `json:"id"` - AccountID string `json:"account_id"` - DeviceSessions interface{} `json:"device_sessions"` - Email string `json:"email"` - Geo AccessApplicationUserPolicyCheckListResponseUserIdentityGeo `json:"geo"` - Iat int64 `json:"iat"` - IsGateway bool `json:"is_gateway"` - IsWARP bool `json:"is_warp"` - Name string `json:"name"` + ID string `json:"id"` + AccountID string `json:"account_id"` + DeviceSessions interface{} `json:"device_sessions"` + Email string `json:"email"` + Geo UserPolicyCheckGeo `json:"geo"` + Iat int64 `json:"iat"` + IsGateway bool `json:"is_gateway"` + IsWARP bool `json:"is_warp"` + Name string `json:"name"` // UUID UserUUID string `json:"user_uuid"` Version int64 `json:"version"` @@ -151,28 +173,6 @@ func (r accessApplicationUserPolicyCheckListResponseUserIdentityJSON) RawJSON() return r.raw } -type AccessApplicationUserPolicyCheckListResponseUserIdentityGeo struct { - Country string `json:"country"` - JSON accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON `json:"-"` -} - -// accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON contains the -// JSON metadata for the struct -// [AccessApplicationUserPolicyCheckListResponseUserIdentityGeo] -type accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON struct { - Country apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationUserPolicyCheckListResponseUserIdentityGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON) RawJSON() string { - return r.raw -} - type AccessApplicationUserPolicyCheckListParams struct { // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. AccountID param.Field[string] `path:"account_id"` @@ -180,17 +180,10 @@ type AccessApplicationUserPolicyCheckListParams struct { ZoneID param.Field[string] `path:"zone_id"` } -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AccessApplicationUserPolicyCheckListParamsAppID interface { - ImplementsZeroTrustAccessApplicationUserPolicyCheckListParamsAppID() -} - type AccessApplicationUserPolicyCheckListResponseEnvelope struct { - Errors []AccessApplicationUserPolicyCheckListResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessApplicationUserPolicyCheckListResponseEnvelopeMessages `json:"messages,required"` - Result AccessApplicationUserPolicyCheckListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessApplicationUserPolicyCheckListResponse `json:"result,required"` // Whether the API call was successful Success AccessApplicationUserPolicyCheckListResponseEnvelopeSuccess `json:"success,required"` JSON accessApplicationUserPolicyCheckListResponseEnvelopeJSON `json:"-"` @@ -215,54 +208,6 @@ func (r accessApplicationUserPolicyCheckListResponseEnvelopeJSON) RawJSON() stri return r.raw } -type AccessApplicationUserPolicyCheckListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AccessApplicationUserPolicyCheckListResponseEnvelopeErrors] -type accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationUserPolicyCheckListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessApplicationUserPolicyCheckListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [AccessApplicationUserPolicyCheckListResponseEnvelopeMessages] -type accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessApplicationUserPolicyCheckListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessApplicationUserPolicyCheckListResponseEnvelopeSuccess bool diff --git a/zero_trust/accessbookmark.go b/zero_trust/accessbookmark.go index bdd767216a5..0a156212fb2 100644 --- a/zero_trust/accessbookmark.go +++ b/zero_trust/accessbookmark.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -33,7 +34,7 @@ func NewAccessBookmarkService(opts ...option.RequestOption) (r *AccessBookmarkSe } // Create a new Bookmark application. -func (r *AccessBookmarkService) New(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustBookmarks, err error) { +func (r *AccessBookmarkService) New(ctx context.Context, identifier string, uuid string, body AccessBookmarkNewParams, opts ...option.RequestOption) (res *Bookmark, err error) { opts = append(r.Options[:], opts...) var env AccessBookmarkNewResponseEnvelope path := fmt.Sprintf("accounts/%s/access/bookmarks/%s", identifier, uuid) @@ -46,7 +47,7 @@ func (r *AccessBookmarkService) New(ctx context.Context, identifier string, uuid } // Updates a configured Bookmark application. -func (r *AccessBookmarkService) Update(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustBookmarks, err error) { +func (r *AccessBookmarkService) Update(ctx context.Context, identifier string, uuid string, body AccessBookmarkUpdateParams, opts ...option.RequestOption) (res *Bookmark, err error) { opts = append(r.Options[:], opts...) var env AccessBookmarkUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/access/bookmarks/%s", identifier, uuid) @@ -59,7 +60,7 @@ func (r *AccessBookmarkService) Update(ctx context.Context, identifier string, u } // Lists Bookmark applications. -func (r *AccessBookmarkService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustBookmarks], err error) { +func (r *AccessBookmarkService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[Bookmark], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -77,12 +78,12 @@ func (r *AccessBookmarkService) List(ctx context.Context, identifier string, opt } // Lists Bookmark applications. -func (r *AccessBookmarkService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustBookmarks] { +func (r *AccessBookmarkService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Bookmark] { return pagination.NewSinglePageAutoPager(r.List(ctx, identifier, opts...)) } // Deletes a Bookmark application. -func (r *AccessBookmarkService) Delete(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *AccessBookmarkDeleteResponse, err error) { +func (r *AccessBookmarkService) Delete(ctx context.Context, identifier string, uuid string, body AccessBookmarkDeleteParams, opts ...option.RequestOption) (res *AccessBookmarkDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env AccessBookmarkDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/access/bookmarks/%s", identifier, uuid) @@ -95,7 +96,7 @@ func (r *AccessBookmarkService) Delete(ctx context.Context, identifier string, u } // Fetches a single Bookmark application. -func (r *AccessBookmarkService) Get(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustBookmarks, err error) { +func (r *AccessBookmarkService) Get(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *Bookmark, err error) { opts = append(r.Options[:], opts...) var env AccessBookmarkGetResponseEnvelope path := fmt.Sprintf("accounts/%s/access/bookmarks/%s", identifier, uuid) @@ -107,7 +108,7 @@ func (r *AccessBookmarkService) Get(ctx context.Context, identifier string, uuid return } -type ZeroTrustBookmarks struct { +type Bookmark struct { // The unique identifier for the Bookmark application. ID string `json:"id"` // Displays the application in the App Launcher. @@ -118,14 +119,13 @@ type ZeroTrustBookmarks struct { // The image URL for the logo shown in the App Launcher dashboard. LogoURL string `json:"logo_url"` // The name of the Bookmark application. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustBookmarksJSON `json:"-"` + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON bookmarkJSON `json:"-"` } -// zeroTrustBookmarksJSON contains the JSON metadata for the struct -// [ZeroTrustBookmarks] -type zeroTrustBookmarksJSON struct { +// bookmarkJSON contains the JSON metadata for the struct [Bookmark] +type bookmarkJSON struct { ID apijson.Field AppLauncherVisible apijson.Field CreatedAt apijson.Field @@ -137,11 +137,11 @@ type zeroTrustBookmarksJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustBookmarks) UnmarshalJSON(data []byte) (err error) { +func (r *Bookmark) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustBookmarksJSON) RawJSON() string { +func (r bookmarkJSON) RawJSON() string { return r.raw } @@ -167,10 +167,18 @@ func (r accessBookmarkDeleteResponseJSON) RawJSON() string { return r.raw } +type AccessBookmarkNewParams struct { + Body interface{} `json:"body,required"` +} + +func (r AccessBookmarkNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type AccessBookmarkNewResponseEnvelope struct { - Errors []AccessBookmarkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessBookmarkNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustBookmarks `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Bookmark `json:"result,required"` // Whether the API call was successful Success AccessBookmarkNewResponseEnvelopeSuccess `json:"success,required"` JSON accessBookmarkNewResponseEnvelopeJSON `json:"-"` @@ -195,52 +203,6 @@ func (r accessBookmarkNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessBookmarkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessBookmarkNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessBookmarkNewResponseEnvelopeErrors] -type accessBookmarkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessBookmarkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessBookmarkNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessBookmarkNewResponseEnvelopeMessages] -type accessBookmarkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessBookmarkNewResponseEnvelopeSuccess bool @@ -256,10 +218,18 @@ func (r AccessBookmarkNewResponseEnvelopeSuccess) IsKnown() bool { return false } +type AccessBookmarkUpdateParams struct { + Body interface{} `json:"body,required"` +} + +func (r AccessBookmarkUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type AccessBookmarkUpdateResponseEnvelope struct { - Errors []AccessBookmarkUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessBookmarkUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustBookmarks `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Bookmark `json:"result,required"` // Whether the API call was successful Success AccessBookmarkUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessBookmarkUpdateResponseEnvelopeJSON `json:"-"` @@ -284,52 +254,6 @@ func (r accessBookmarkUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessBookmarkUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessBookmarkUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessBookmarkUpdateResponseEnvelopeErrors] -type accessBookmarkUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessBookmarkUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessBookmarkUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessBookmarkUpdateResponseEnvelopeMessages] -type accessBookmarkUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessBookmarkUpdateResponseEnvelopeSuccess bool @@ -345,10 +269,18 @@ func (r AccessBookmarkUpdateResponseEnvelopeSuccess) IsKnown() bool { return false } +type AccessBookmarkDeleteParams struct { + Body interface{} `json:"body,required"` +} + +func (r AccessBookmarkDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + type AccessBookmarkDeleteResponseEnvelope struct { - Errors []AccessBookmarkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessBookmarkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessBookmarkDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessBookmarkDeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessBookmarkDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessBookmarkDeleteResponseEnvelopeJSON `json:"-"` @@ -373,52 +305,6 @@ func (r accessBookmarkDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessBookmarkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessBookmarkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessBookmarkDeleteResponseEnvelopeErrors] -type accessBookmarkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessBookmarkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessBookmarkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessBookmarkDeleteResponseEnvelopeMessages] -type accessBookmarkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessBookmarkDeleteResponseEnvelopeSuccess bool @@ -435,9 +321,9 @@ func (r AccessBookmarkDeleteResponseEnvelopeSuccess) IsKnown() bool { } type AccessBookmarkGetResponseEnvelope struct { - Errors []AccessBookmarkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessBookmarkGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustBookmarks `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Bookmark `json:"result,required"` // Whether the API call was successful Success AccessBookmarkGetResponseEnvelopeSuccess `json:"success,required"` JSON accessBookmarkGetResponseEnvelopeJSON `json:"-"` @@ -462,52 +348,6 @@ func (r accessBookmarkGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessBookmarkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessBookmarkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessBookmarkGetResponseEnvelopeErrors] -type accessBookmarkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessBookmarkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessBookmarkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessBookmarkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessBookmarkGetResponseEnvelopeMessages] -type accessBookmarkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessBookmarkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessBookmarkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessBookmarkGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accessbookmark_test.go b/zero_trust/accessbookmark_test.go index 129404f6317..98f7e866fe1 100644 --- a/zero_trust/accessbookmark_test.go +++ b/zero_trust/accessbookmark_test.go @@ -11,6 +11,7 @@ import ( "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/zero_trust" ) func TestAccessBookmarkNew(t *testing.T) { @@ -31,6 +32,9 @@ func TestAccessBookmarkNew(t *testing.T) { context.TODO(), "699d98642c564d2e855e9661899b7252", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessBookmarkNewParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error @@ -59,6 +63,9 @@ func TestAccessBookmarkUpdate(t *testing.T) { context.TODO(), "699d98642c564d2e855e9661899b7252", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessBookmarkUpdateParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error @@ -111,6 +118,9 @@ func TestAccessBookmarkDelete(t *testing.T) { context.TODO(), "699d98642c564d2e855e9661899b7252", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessBookmarkDeleteParams{ + Body: map[string]interface{}{}, + }, ) if err != nil { var apierr *cloudflare.Error diff --git a/zero_trust/accesscertificate.go b/zero_trust/accesscertificate.go index b2fc09a2614..64381b7d953 100644 --- a/zero_trust/accesscertificate.go +++ b/zero_trust/accesscertificate.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -36,7 +37,7 @@ func NewAccessCertificateService(opts ...option.RequestOption) (r *AccessCertifi } // Adds a new mTLS root certificate to Access. -func (r *AccessCertificateService) New(ctx context.Context, params AccessCertificateNewParams, opts ...option.RequestOption) (res *ZeroTrustCertificates, err error) { +func (r *AccessCertificateService) New(ctx context.Context, params AccessCertificateNewParams, opts ...option.RequestOption) (res *Certificate, err error) { opts = append(r.Options[:], opts...) var env AccessCertificateNewResponseEnvelope var accountOrZone string @@ -58,7 +59,7 @@ func (r *AccessCertificateService) New(ctx context.Context, params AccessCertifi } // Updates a configured mTLS certificate. -func (r *AccessCertificateService) Update(ctx context.Context, uuid string, params AccessCertificateUpdateParams, opts ...option.RequestOption) (res *ZeroTrustCertificates, err error) { +func (r *AccessCertificateService) Update(ctx context.Context, uuid string, params AccessCertificateUpdateParams, opts ...option.RequestOption) (res *Certificate, err error) { opts = append(r.Options[:], opts...) var env AccessCertificateUpdateResponseEnvelope var accountOrZone string @@ -80,7 +81,7 @@ func (r *AccessCertificateService) Update(ctx context.Context, uuid string, para } // Lists all mTLS root certificates. -func (r *AccessCertificateService) List(ctx context.Context, query AccessCertificateListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustCertificates], err error) { +func (r *AccessCertificateService) List(ctx context.Context, query AccessCertificateListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Certificate], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -107,7 +108,7 @@ func (r *AccessCertificateService) List(ctx context.Context, query AccessCertifi } // Lists all mTLS root certificates. -func (r *AccessCertificateService) ListAutoPaging(ctx context.Context, query AccessCertificateListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustCertificates] { +func (r *AccessCertificateService) ListAutoPaging(ctx context.Context, query AccessCertificateListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Certificate] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -134,7 +135,7 @@ func (r *AccessCertificateService) Delete(ctx context.Context, uuid string, body } // Fetches a single mTLS certificate. -func (r *AccessCertificateService) Get(ctx context.Context, uuid string, query AccessCertificateGetParams, opts ...option.RequestOption) (res *ZeroTrustCertificates, err error) { +func (r *AccessCertificateService) Get(ctx context.Context, uuid string, query AccessCertificateGetParams, opts ...option.RequestOption) (res *Certificate, err error) { opts = append(r.Options[:], opts...) var env AccessCertificateGetResponseEnvelope var accountOrZone string @@ -155,24 +156,27 @@ func (r *AccessCertificateService) Get(ctx context.Context, uuid string, query A return } -type ZeroTrustCertificates struct { +type AssociatedHostnames = 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 []string `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. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustCertificatesJSON `json:"-"` + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON certificateJSON `json:"-"` } -// zeroTrustCertificatesJSON contains the JSON metadata for the struct -// [ZeroTrustCertificates] -type zeroTrustCertificatesJSON struct { +// certificateJSON contains the JSON metadata for the struct [Certificate] +type certificateJSON struct { ID apijson.Field AssociatedHostnames apijson.Field CreatedAt apijson.Field @@ -184,11 +188,11 @@ type zeroTrustCertificatesJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustCertificates) UnmarshalJSON(data []byte) (err error) { +func (r *Certificate) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustCertificatesJSON) RawJSON() string { +func (r certificateJSON) RawJSON() string { return r.raw } @@ -224,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[[]string] `json:"associated_hostnames"` + AssociatedHostnames param.Field[[]AssociatedHostnamesParam] `json:"associated_hostnames"` } func (r AccessCertificateNewParams) MarshalJSON() (data []byte, err error) { @@ -232,9 +236,9 @@ func (r AccessCertificateNewParams) MarshalJSON() (data []byte, err error) { } type AccessCertificateNewResponseEnvelope struct { - Errors []AccessCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustCertificates `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Certificate `json:"result,required"` // Whether the API call was successful Success AccessCertificateNewResponseEnvelopeSuccess `json:"success,required"` JSON accessCertificateNewResponseEnvelopeJSON `json:"-"` @@ -259,52 +263,6 @@ func (r accessCertificateNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessCertificateNewResponseEnvelopeErrors] -type accessCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessCertificateNewResponseEnvelopeMessages] -type accessCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCertificateNewResponseEnvelopeSuccess bool @@ -322,7 +280,7 @@ func (r AccessCertificateNewResponseEnvelopeSuccess) IsKnown() bool { type AccessCertificateUpdateParams struct { // The hostnames of the applications that will use this certificate. - AssociatedHostnames param.Field[[]string] `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. @@ -336,9 +294,9 @@ func (r AccessCertificateUpdateParams) MarshalJSON() (data []byte, err error) { } type AccessCertificateUpdateResponseEnvelope struct { - Errors []AccessCertificateUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCertificateUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustCertificates `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Certificate `json:"result,required"` // Whether the API call was successful Success AccessCertificateUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessCertificateUpdateResponseEnvelopeJSON `json:"-"` @@ -363,52 +321,6 @@ func (r accessCertificateUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCertificateUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCertificateUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessCertificateUpdateResponseEnvelopeErrors] -type accessCertificateUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCertificateUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCertificateUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessCertificateUpdateResponseEnvelopeMessages] -type accessCertificateUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCertificateUpdateResponseEnvelopeSuccess bool @@ -439,9 +351,9 @@ type AccessCertificateDeleteParams struct { } type AccessCertificateDeleteResponseEnvelope struct { - Errors []AccessCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessCertificateDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessCertificateDeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessCertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -466,52 +378,6 @@ func (r accessCertificateDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessCertificateDeleteResponseEnvelopeErrors] -type accessCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessCertificateDeleteResponseEnvelopeMessages] -type accessCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCertificateDeleteResponseEnvelopeSuccess bool @@ -535,9 +401,9 @@ type AccessCertificateGetParams struct { } type AccessCertificateGetResponseEnvelope struct { - Errors []AccessCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustCertificates `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Certificate `json:"result,required"` // Whether the API call was successful Success AccessCertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON accessCertificateGetResponseEnvelopeJSON `json:"-"` @@ -562,52 +428,6 @@ func (r accessCertificateGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessCertificateGetResponseEnvelopeErrors] -type accessCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessCertificateGetResponseEnvelopeMessages] -type accessCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCertificateGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accesscertificate_test.go b/zero_trust/accesscertificate_test.go index 544c7641d3b..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([]string{"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([]string{"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/accesscertificatesetting.go b/zero_trust/accesscertificatesetting.go index 6422bdafd42..fc110331af3 100644 --- a/zero_trust/accesscertificatesetting.go +++ b/zero_trust/accesscertificatesetting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewAccessCertificateSettingService(opts ...option.RequestOption) (r *Access } // Updates an mTLS certificate's hostname settings. -func (r *AccessCertificateSettingService) Update(ctx context.Context, params AccessCertificateSettingUpdateParams, opts ...option.RequestOption) (res *[]ZeroTrustSettings, err error) { +func (r *AccessCertificateSettingService) Update(ctx context.Context, params AccessCertificateSettingUpdateParams, opts ...option.RequestOption) (res *[]CertificateSettings, err error) { opts = append(r.Options[:], opts...) var env AccessCertificateSettingUpdateResponseEnvelope var accountOrZone string @@ -54,7 +55,7 @@ func (r *AccessCertificateSettingService) Update(ctx context.Context, params Acc } // List all mTLS hostname settings for this account or zone. -func (r *AccessCertificateSettingService) Get(ctx context.Context, query AccessCertificateSettingGetParams, opts ...option.RequestOption) (res *[]ZeroTrustSettings, err error) { +func (r *AccessCertificateSettingService) Get(ctx context.Context, query AccessCertificateSettingGetParams, opts ...option.RequestOption) (res *[]CertificateSettings, err error) { opts = append(r.Options[:], opts...) var env AccessCertificateSettingGetResponseEnvelope var accountOrZone string @@ -75,7 +76,7 @@ func (r *AccessCertificateSettingService) Get(ctx context.Context, query AccessC return } -type ZeroTrustSettings struct { +type CertificateSettings struct { // Request client certificates for this hostname in China. Can only be set to true // if this zone is china network enabled. ChinaNetwork bool `json:"china_network,required"` @@ -84,13 +85,13 @@ type ZeroTrustSettings struct { // allow logging on the origin. ClientCertificateForwarding bool `json:"client_certificate_forwarding,required"` // The hostname that these settings apply to. - Hostname string `json:"hostname,required"` - JSON zeroTrustSettingsJSON `json:"-"` + Hostname string `json:"hostname,required"` + JSON certificateSettingsJSON `json:"-"` } -// zeroTrustSettingsJSON contains the JSON metadata for the struct -// [ZeroTrustSettings] -type zeroTrustSettingsJSON struct { +// certificateSettingsJSON contains the JSON metadata for the struct +// [CertificateSettings] +type certificateSettingsJSON struct { ChinaNetwork apijson.Field ClientCertificateForwarding apijson.Field Hostname apijson.Field @@ -98,15 +99,15 @@ type zeroTrustSettingsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustSettings) UnmarshalJSON(data []byte) (err error) { +func (r *CertificateSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustSettingsJSON) RawJSON() string { +func (r certificateSettingsJSON) RawJSON() string { return r.raw } -type ZeroTrustSettingsParam struct { +type CertificateSettingsParam struct { // Request client certificates for this hostname in China. Can only be set to true // if this zone is china network enabled. ChinaNetwork param.Field[bool] `json:"china_network,required"` @@ -118,12 +119,12 @@ type ZeroTrustSettingsParam struct { Hostname param.Field[string] `json:"hostname,required"` } -func (r ZeroTrustSettingsParam) MarshalJSON() (data []byte, err error) { +func (r CertificateSettingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type AccessCertificateSettingUpdateParams struct { - Settings param.Field[[]ZeroTrustSettingsParam] `json:"settings,required"` + Settings param.Field[[]CertificateSettingsParam] `json:"settings,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. @@ -135,9 +136,9 @@ func (r AccessCertificateSettingUpdateParams) MarshalJSON() (data []byte, err er } type AccessCertificateSettingUpdateResponseEnvelope struct { - Errors []AccessCertificateSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCertificateSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustSettings `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []CertificateSettings `json:"result,required,nullable"` // Whether the API call was successful Success AccessCertificateSettingUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo AccessCertificateSettingUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -164,52 +165,6 @@ func (r accessCertificateSettingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCertificateSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCertificateSettingUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AccessCertificateSettingUpdateResponseEnvelopeErrors] -type accessCertificateSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCertificateSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCertificateSettingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessCertificateSettingUpdateResponseEnvelopeMessages] -type accessCertificateSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCertificateSettingUpdateResponseEnvelopeSuccess bool @@ -265,9 +220,9 @@ type AccessCertificateSettingGetParams struct { } type AccessCertificateSettingGetResponseEnvelope struct { - Errors []AccessCertificateSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCertificateSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustSettings `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []CertificateSettings `json:"result,required,nullable"` // Whether the API call was successful Success AccessCertificateSettingGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo AccessCertificateSettingGetResponseEnvelopeResultInfo `json:"result_info"` @@ -294,52 +249,6 @@ func (r accessCertificateSettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCertificateSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCertificateSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessCertificateSettingGetResponseEnvelopeErrors] -type accessCertificateSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCertificateSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCertificateSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCertificateSettingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessCertificateSettingGetResponseEnvelopeMessages] -type accessCertificateSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCertificateSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCertificateSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCertificateSettingGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accesscertificatesetting_test.go b/zero_trust/accesscertificatesetting_test.go index c62486226af..3d5510ccf27 100644 --- a/zero_trust/accesscertificatesetting_test.go +++ b/zero_trust/accesscertificatesetting_test.go @@ -29,7 +29,7 @@ func TestAccessCertificateSettingUpdateWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.ZeroTrust.Access.Certificates.Settings.Update(context.TODO(), zero_trust.AccessCertificateSettingUpdateParams{ - Settings: cloudflare.F([]zero_trust.ZeroTrustSettingsParam{{ + Settings: cloudflare.F([]zero_trust.CertificateSettingsParam{{ ChinaNetwork: cloudflare.F(false), ClientCertificateForwarding: cloudflare.F(true), Hostname: cloudflare.F("admin.example.com"), diff --git a/zero_trust/accesscustompage.go b/zero_trust/accesscustompage.go index 3d47d001aaf..e6c286b2fe5 100644 --- a/zero_trust/accesscustompage.go +++ b/zero_trust/accesscustompage.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -34,7 +35,7 @@ func NewAccessCustomPageService(opts ...option.RequestOption) (r *AccessCustomPa } // Create a custom page -func (r *AccessCustomPageService) New(ctx context.Context, identifier string, body AccessCustomPageNewParams, opts ...option.RequestOption) (res *ZeroTrustCustomPageWithoutHTML, err error) { +func (r *AccessCustomPageService) New(ctx context.Context, identifier string, body AccessCustomPageNewParams, opts ...option.RequestOption) (res *CustomPageWithoutHTML, err error) { opts = append(r.Options[:], opts...) var env AccessCustomPageNewResponseEnvelope path := fmt.Sprintf("accounts/%s/access/custom_pages", identifier) @@ -47,7 +48,7 @@ func (r *AccessCustomPageService) New(ctx context.Context, identifier string, bo } // Update a custom page -func (r *AccessCustomPageService) Update(ctx context.Context, identifier string, uuid string, body AccessCustomPageUpdateParams, opts ...option.RequestOption) (res *ZeroTrustCustomPageWithoutHTML, err error) { +func (r *AccessCustomPageService) Update(ctx context.Context, identifier string, uuid string, body AccessCustomPageUpdateParams, opts ...option.RequestOption) (res *CustomPageWithoutHTML, err error) { opts = append(r.Options[:], opts...) var env AccessCustomPageUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) @@ -60,7 +61,7 @@ func (r *AccessCustomPageService) Update(ctx context.Context, identifier string, } // List custom pages -func (r *AccessCustomPageService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustCustomPageWithoutHTML], err error) { +func (r *AccessCustomPageService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[CustomPageWithoutHTML], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -78,7 +79,7 @@ func (r *AccessCustomPageService) List(ctx context.Context, identifier string, o } // List custom pages -func (r *AccessCustomPageService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustCustomPageWithoutHTML] { +func (r *AccessCustomPageService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[CustomPageWithoutHTML] { return pagination.NewSinglePageAutoPager(r.List(ctx, identifier, opts...)) } @@ -96,7 +97,7 @@ func (r *AccessCustomPageService) Delete(ctx context.Context, identifier string, } // Fetches a custom page and also returns its HTML. -func (r *AccessCustomPageService) Get(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustCustomPage, err error) { +func (r *AccessCustomPageService) Get(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *CustomPage, err error) { opts = append(r.Options[:], opts...) var env AccessCustomPageGetResponseEnvelope path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) @@ -108,106 +109,120 @@ func (r *AccessCustomPageService) Get(ctx context.Context, identifier string, uu return } -type ZeroTrustCustomPage struct { +type CustomPage struct { // Custom page HTML. CustomHTML string `json:"custom_html,required"` // Custom page name. Name string `json:"name,required"` // Custom page type. - Type ZeroTrustCustomPageType `json:"type,required"` + Type CustomPageType `json:"type,required"` // Number of apps the custom page is assigned to. AppCount int64 `json:"app_count"` CreatedAt time.Time `json:"created_at" format:"date-time"` // UUID - Uid string `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustCustomPageJSON `json:"-"` + UID string `json:"uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON customPageJSON `json:"-"` } -// zeroTrustCustomPageJSON contains the JSON metadata for the struct -// [ZeroTrustCustomPage] -type zeroTrustCustomPageJSON struct { +// customPageJSON contains the JSON metadata for the struct [CustomPage] +type customPageJSON struct { CustomHTML apijson.Field Name apijson.Field Type apijson.Field AppCount apijson.Field CreatedAt apijson.Field - Uid apijson.Field + UID apijson.Field UpdatedAt apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustCustomPage) UnmarshalJSON(data []byte) (err error) { +func (r *CustomPage) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustCustomPageJSON) RawJSON() string { +func (r customPageJSON) RawJSON() string { return r.raw } // Custom page type. -type ZeroTrustCustomPageType string +type CustomPageType string const ( - ZeroTrustCustomPageTypeIdentityDenied ZeroTrustCustomPageType = "identity_denied" - ZeroTrustCustomPageTypeForbidden ZeroTrustCustomPageType = "forbidden" + CustomPageTypeIdentityDenied CustomPageType = "identity_denied" + CustomPageTypeForbidden CustomPageType = "forbidden" ) -func (r ZeroTrustCustomPageType) IsKnown() bool { +func (r CustomPageType) IsKnown() bool { switch r { - case ZeroTrustCustomPageTypeIdentityDenied, ZeroTrustCustomPageTypeForbidden: + case CustomPageTypeIdentityDenied, CustomPageTypeForbidden: return true } return false } -type ZeroTrustCustomPageWithoutHTML struct { +type CustomPageParam struct { + // Custom page HTML. + CustomHTML param.Field[string] `json:"custom_html,required"` + // Custom page name. + Name param.Field[string] `json:"name,required"` + // Custom page type. + Type param.Field[CustomPageType] `json:"type,required"` + // Number of apps the custom page is assigned to. + AppCount param.Field[int64] `json:"app_count"` +} + +func (r CustomPageParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type CustomPageWithoutHTML struct { // Custom page name. Name string `json:"name,required"` // Custom page type. - Type ZeroTrustCustomPageWithoutHTMLType `json:"type,required"` + Type CustomPageWithoutHTMLType `json:"type,required"` // Number of apps the custom page is assigned to. AppCount int64 `json:"app_count"` CreatedAt time.Time `json:"created_at" format:"date-time"` // UUID - Uid string `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustCustomPageWithoutHTMLJSON `json:"-"` + UID string `json:"uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON customPageWithoutHTMLJSON `json:"-"` } -// zeroTrustCustomPageWithoutHTMLJSON contains the JSON metadata for the struct -// [ZeroTrustCustomPageWithoutHTML] -type zeroTrustCustomPageWithoutHTMLJSON struct { +// customPageWithoutHTMLJSON contains the JSON metadata for the struct +// [CustomPageWithoutHTML] +type customPageWithoutHTMLJSON struct { Name apijson.Field Type apijson.Field AppCount apijson.Field CreatedAt apijson.Field - Uid apijson.Field + UID apijson.Field UpdatedAt apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustCustomPageWithoutHTML) UnmarshalJSON(data []byte) (err error) { +func (r *CustomPageWithoutHTML) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustCustomPageWithoutHTMLJSON) RawJSON() string { +func (r customPageWithoutHTMLJSON) RawJSON() string { return r.raw } // Custom page type. -type ZeroTrustCustomPageWithoutHTMLType string +type CustomPageWithoutHTMLType string const ( - ZeroTrustCustomPageWithoutHTMLTypeIdentityDenied ZeroTrustCustomPageWithoutHTMLType = "identity_denied" - ZeroTrustCustomPageWithoutHTMLTypeForbidden ZeroTrustCustomPageWithoutHTMLType = "forbidden" + CustomPageWithoutHTMLTypeIdentityDenied CustomPageWithoutHTMLType = "identity_denied" + CustomPageWithoutHTMLTypeForbidden CustomPageWithoutHTMLType = "forbidden" ) -func (r ZeroTrustCustomPageWithoutHTMLType) IsKnown() bool { +func (r CustomPageWithoutHTMLType) IsKnown() bool { switch r { - case ZeroTrustCustomPageWithoutHTMLTypeIdentityDenied, ZeroTrustCustomPageWithoutHTMLTypeForbidden: + case CustomPageWithoutHTMLTypeIdentityDenied, CustomPageWithoutHTMLTypeForbidden: return true } return false @@ -236,40 +251,17 @@ func (r accessCustomPageDeleteResponseJSON) RawJSON() string { } type AccessCustomPageNewParams struct { - // Custom page HTML. - CustomHTML param.Field[string] `json:"custom_html,required"` - // Custom page name. - Name param.Field[string] `json:"name,required"` - // Custom page type. - Type param.Field[AccessCustomPageNewParamsType] `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount param.Field[int64] `json:"app_count"` + CustomPage CustomPageParam `json:"custom_page,required"` } func (r AccessCustomPageNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Custom page type. -type AccessCustomPageNewParamsType string - -const ( - AccessCustomPageNewParamsTypeIdentityDenied AccessCustomPageNewParamsType = "identity_denied" - AccessCustomPageNewParamsTypeForbidden AccessCustomPageNewParamsType = "forbidden" -) - -func (r AccessCustomPageNewParamsType) IsKnown() bool { - switch r { - case AccessCustomPageNewParamsTypeIdentityDenied, AccessCustomPageNewParamsTypeForbidden: - return true - } - return false + return apijson.MarshalRoot(r.CustomPage) } type AccessCustomPageNewResponseEnvelope struct { - Errors []AccessCustomPageNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCustomPageNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustCustomPageWithoutHTML `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomPageWithoutHTML `json:"result,required"` // Whether the API call was successful Success AccessCustomPageNewResponseEnvelopeSuccess `json:"success,required"` JSON accessCustomPageNewResponseEnvelopeJSON `json:"-"` @@ -294,52 +286,6 @@ func (r accessCustomPageNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCustomPageNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCustomPageNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessCustomPageNewResponseEnvelopeErrors] -type accessCustomPageNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCustomPageNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCustomPageNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessCustomPageNewResponseEnvelopeMessages] -type accessCustomPageNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCustomPageNewResponseEnvelopeSuccess bool @@ -356,40 +302,17 @@ func (r AccessCustomPageNewResponseEnvelopeSuccess) IsKnown() bool { } type AccessCustomPageUpdateParams struct { - // Custom page HTML. - CustomHTML param.Field[string] `json:"custom_html,required"` - // Custom page name. - Name param.Field[string] `json:"name,required"` - // Custom page type. - Type param.Field[AccessCustomPageUpdateParamsType] `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount param.Field[int64] `json:"app_count"` + CustomPage CustomPageParam `json:"custom_page,required"` } func (r AccessCustomPageUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Custom page type. -type AccessCustomPageUpdateParamsType string - -const ( - AccessCustomPageUpdateParamsTypeIdentityDenied AccessCustomPageUpdateParamsType = "identity_denied" - AccessCustomPageUpdateParamsTypeForbidden AccessCustomPageUpdateParamsType = "forbidden" -) - -func (r AccessCustomPageUpdateParamsType) IsKnown() bool { - switch r { - case AccessCustomPageUpdateParamsTypeIdentityDenied, AccessCustomPageUpdateParamsTypeForbidden: - return true - } - return false + return apijson.MarshalRoot(r.CustomPage) } type AccessCustomPageUpdateResponseEnvelope struct { - Errors []AccessCustomPageUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCustomPageUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustCustomPageWithoutHTML `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomPageWithoutHTML `json:"result,required"` // Whether the API call was successful Success AccessCustomPageUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessCustomPageUpdateResponseEnvelopeJSON `json:"-"` @@ -414,52 +337,6 @@ func (r accessCustomPageUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCustomPageUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCustomPageUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessCustomPageUpdateResponseEnvelopeErrors] -type accessCustomPageUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCustomPageUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCustomPageUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessCustomPageUpdateResponseEnvelopeMessages] -type accessCustomPageUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCustomPageUpdateResponseEnvelopeSuccess bool @@ -476,9 +353,9 @@ func (r AccessCustomPageUpdateResponseEnvelopeSuccess) IsKnown() bool { } type AccessCustomPageDeleteResponseEnvelope struct { - Errors []AccessCustomPageDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCustomPageDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessCustomPageDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessCustomPageDeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessCustomPageDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessCustomPageDeleteResponseEnvelopeJSON `json:"-"` @@ -503,52 +380,6 @@ func (r accessCustomPageDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCustomPageDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCustomPageDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessCustomPageDeleteResponseEnvelopeErrors] -type accessCustomPageDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCustomPageDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCustomPageDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessCustomPageDeleteResponseEnvelopeMessages] -type accessCustomPageDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCustomPageDeleteResponseEnvelopeSuccess bool @@ -565,9 +396,9 @@ func (r AccessCustomPageDeleteResponseEnvelopeSuccess) IsKnown() bool { } type AccessCustomPageGetResponseEnvelope struct { - Errors []AccessCustomPageGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessCustomPageGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustCustomPage `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomPage `json:"result,required"` // Whether the API call was successful Success AccessCustomPageGetResponseEnvelopeSuccess `json:"success,required"` JSON accessCustomPageGetResponseEnvelopeJSON `json:"-"` @@ -592,52 +423,6 @@ func (r accessCustomPageGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessCustomPageGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessCustomPageGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessCustomPageGetResponseEnvelopeErrors] -type accessCustomPageGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessCustomPageGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessCustomPageGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessCustomPageGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessCustomPageGetResponseEnvelopeMessages] -type accessCustomPageGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessCustomPageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessCustomPageGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessCustomPageGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accesscustompage_test.go b/zero_trust/accesscustompage_test.go index 08b1fce1d8e..59147eca3f1 100644 --- a/zero_trust/accesscustompage_test.go +++ b/zero_trust/accesscustompage_test.go @@ -32,10 +32,12 @@ func TestAccessCustomPageNewWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", zero_trust.AccessCustomPageNewParams{ - CustomHTML: cloudflare.F("

Access Denied

"), - Name: cloudflare.F("string"), - Type: cloudflare.F(zero_trust.AccessCustomPageNewParamsTypeIdentityDenied), - AppCount: cloudflare.F(int64(0)), + CustomPage: zero_trust.CustomPageParam{ + AppCount: cloudflare.F(int64(0)), + CustomHTML: cloudflare.F("

Access Denied

"), + Name: cloudflare.F("string"), + Type: cloudflare.F(zero_trust.CustomPageTypeIdentityDenied), + }, }, ) if err != nil { @@ -66,10 +68,12 @@ func TestAccessCustomPageUpdateWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.AccessCustomPageUpdateParams{ - CustomHTML: cloudflare.F("

Access Denied

"), - Name: cloudflare.F("string"), - Type: cloudflare.F(zero_trust.AccessCustomPageUpdateParamsTypeIdentityDenied), - AppCount: cloudflare.F(int64(0)), + CustomPage: zero_trust.CustomPageParam{ + AppCount: cloudflare.F(int64(0)), + CustomHTML: cloudflare.F("

Access Denied

"), + Name: cloudflare.F("string"), + Type: cloudflare.F(zero_trust.CustomPageTypeIdentityDenied), + }, }, ) if err != nil { diff --git a/zero_trust/accessgroup.go b/zero_trust/accessgroup.go index 8b466311810..ce12cccf5e9 100644 --- a/zero_trust/accessgroup.go +++ b/zero_trust/accessgroup.go @@ -6,15 +6,14 @@ import ( "context" "fmt" "net/http" - "reflect" "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" - "github.com/tidwall/gjson" ) // AccessGroupService contains methods and other services that help with @@ -36,7 +35,7 @@ func NewAccessGroupService(opts ...option.RequestOption) (r *AccessGroupService) } // Creates a new Access group. -func (r *AccessGroupService) New(ctx context.Context, params AccessGroupNewParams, opts ...option.RequestOption) (res *ZeroTrustGroups, err error) { +func (r *AccessGroupService) New(ctx context.Context, params AccessGroupNewParams, opts ...option.RequestOption) (res *ZeroTrustGroup, err error) { opts = append(r.Options[:], opts...) var env AccessGroupNewResponseEnvelope var accountOrZone string @@ -58,7 +57,7 @@ func (r *AccessGroupService) New(ctx context.Context, params AccessGroupNewParam } // Updates a configured Access group. -func (r *AccessGroupService) Update(ctx context.Context, uuid string, params AccessGroupUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGroups, err error) { +func (r *AccessGroupService) Update(ctx context.Context, uuid string, params AccessGroupUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGroup, err error) { opts = append(r.Options[:], opts...) var env AccessGroupUpdateResponseEnvelope var accountOrZone string @@ -80,7 +79,7 @@ func (r *AccessGroupService) Update(ctx context.Context, uuid string, params Acc } // Lists all Access groups. -func (r *AccessGroupService) List(ctx context.Context, query AccessGroupListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGroups], err error) { +func (r *AccessGroupService) List(ctx context.Context, query AccessGroupListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGroup], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -107,7 +106,7 @@ func (r *AccessGroupService) List(ctx context.Context, query AccessGroupListPara } // Lists all Access groups. -func (r *AccessGroupService) ListAutoPaging(ctx context.Context, query AccessGroupListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGroups] { +func (r *AccessGroupService) ListAutoPaging(ctx context.Context, query AccessGroupListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGroup] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -134,7 +133,7 @@ func (r *AccessGroupService) Delete(ctx context.Context, uuid string, body Acces } // Fetches a single Access group. -func (r *AccessGroupService) Get(ctx context.Context, uuid string, query AccessGroupGetParams, opts ...option.RequestOption) (res *ZeroTrustGroups, err error) { +func (r *AccessGroupService) Get(ctx context.Context, uuid string, query AccessGroupGetParams, opts ...option.RequestOption) (res *ZeroTrustGroup, err error) { opts = append(r.Options[:], opts...) var env AccessGroupGetResponseEnvelope var accountOrZone string @@ -155,30 +154,30 @@ func (r *AccessGroupService) Get(ctx context.Context, uuid string, query AccessG return } -type ZeroTrustGroups struct { +type ZeroTrustGroup struct { // UUID ID string `json:"id"` CreatedAt time.Time `json:"created_at" format:"date-time"` // Rules evaluated with a NOT logical operator. To match a policy, a user cannot // meet any of the Exclude rules. - Exclude []ZeroTrustGroupsExclude `json:"exclude"` + Exclude []AccessRule `json:"exclude"` // Rules evaluated with an OR logical operator. A user needs to meet only one of // the Include rules. - Include []ZeroTrustGroupsInclude `json:"include"` + Include []AccessRule `json:"include"` // Rules evaluated with an AND logical operator. To match a policy, a user must // meet all of the Require rules. - IsDefault []ZeroTrustGroupsIsDefault `json:"is_default"` + IsDefault []AccessRule `json:"is_default"` // The name of the Access group. Name string `json:"name"` // Rules evaluated with an AND logical operator. To match a policy, a user must // meet all of the Require rules. - Require []ZeroTrustGroupsRequire `json:"require"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGroupsJSON `json:"-"` + Require []AccessRule `json:"require"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON zeroTrustGroupJSON `json:"-"` } -// zeroTrustGroupsJSON contains the JSON metadata for the struct [ZeroTrustGroups] -type zeroTrustGroupsJSON struct { +// zeroTrustGroupJSON contains the JSON metadata for the struct [ZeroTrustGroup] +type zeroTrustGroupJSON struct { ID apijson.Field CreatedAt apijson.Field Exclude apijson.Field @@ -191,6445 +190,131 @@ type zeroTrustGroupsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGroups) UnmarshalJSON(data []byte) (err error) { +func (r *ZeroTrustGroup) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGroupsJSON) RawJSON() string { +func (r zeroTrustGroupJSON) RawJSON() string { return r.raw } -// Matches a specific email. -// -// Union satisfied by [zero_trust.ZeroTrustGroupsExcludeAccessEmailRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessEmailListRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessDomainRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessEveryoneRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessIPRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessIPListRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessCertificateRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessAccessGroupRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessAzureGroupRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessGitHubOrganizationRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessGsuiteGroupRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessOktaGroupRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessSamlGroupRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessServiceTokenRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessAnyValidServiceTokenRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessExternalEvaluationRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessCountryRule], -// [zero_trust.ZeroTrustGroupsExcludeAccessAuthenticationMethodRule] or -// [zero_trust.ZeroTrustGroupsExcludeAccessDevicePostureRule]. -type ZeroTrustGroupsExclude interface { - implementsZeroTrustZeroTrustGroupsExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGroupsExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustGroupsExcludeAccessEmailRule struct { - Email ZeroTrustGroupsExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustGroupsExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessEmailRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessEmailRule] -type zeroTrustGroupsExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessEmailRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustGroupsExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessEmailRuleEmailJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessEmailRuleEmail] -type zeroTrustGroupsExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustGroupsExcludeAccessEmailListRule struct { - EmailList ZeroTrustGroupsExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustGroupsExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessEmailListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessEmailListRule] -type zeroTrustGroupsExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessEmailListRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustGroupsExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessEmailListRuleEmailListJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsExcludeAccessEmailListRuleEmailList] -type zeroTrustGroupsExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustGroupsExcludeAccessDomainRule struct { - EmailDomain ZeroTrustGroupsExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustGroupsExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessDomainRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessDomainRule] -type zeroTrustGroupsExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessDomainRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustGroupsExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessDomainRuleEmailDomainJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsExcludeAccessDomainRuleEmailDomain] -type zeroTrustGroupsExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustGroupsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustGroupsExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessEveryoneRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessEveryoneRule] -type zeroTrustGroupsExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessEveryoneRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -// Matches an IP address block. -type ZeroTrustGroupsExcludeAccessIPRule struct { - IP ZeroTrustGroupsExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustGroupsExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessIPRuleJSON contains the JSON metadata for the struct -// [ZeroTrustGroupsExcludeAccessIPRule] -type zeroTrustGroupsExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessIPRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustGroupsExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessIPRuleIPJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessIPRuleIP] -type zeroTrustGroupsExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustGroupsExcludeAccessIPListRule struct { - IPList ZeroTrustGroupsExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustGroupsExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessIPListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessIPListRule] -type zeroTrustGroupsExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessIPListRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustGroupsExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessIPListRuleIPListJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessIPListRuleIPList] -type zeroTrustGroupsExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustGroupsExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustGroupsExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessCertificateRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessCertificateRule] -type zeroTrustGroupsExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessCertificateRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -// Matches an Access group. -type ZeroTrustGroupsExcludeAccessAccessGroupRule struct { - Group ZeroTrustGroupsExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustGroupsExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessAccessGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessAccessGroupRule] -type zeroTrustGroupsExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessAccessGroupRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustGroupsExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessAccessGroupRuleGroupJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsExcludeAccessAccessGroupRuleGroup] -type zeroTrustGroupsExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustGroupsExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustGroupsExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustGroupsExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessAzureGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessAzureGroupRule] -type zeroTrustGroupsExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessAzureGroupRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustGroupsExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessAzureGroupRuleAzureAdJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustGroupsExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustGroupsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustGroupsExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessGitHubOrganizationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsExcludeAccessGitHubOrganizationRule] -type zeroTrustGroupsExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessGitHubOrganizationRule) implementsZeroTrustZeroTrustGroupsExclude() { -} - -type ZeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustGroupsExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustGroupsExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessGsuiteGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessGsuiteGroupRule] -type zeroTrustGroupsExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessGsuiteGroupRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustGroupsExcludeAccessOktaGroupRule struct { - Okta ZeroTrustGroupsExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustGroupsExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessOktaGroupRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessOktaGroupRule] -type zeroTrustGroupsExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessOktaGroupRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustGroupsExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessOktaGroupRuleOktaJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessOktaGroupRuleOkta] -type zeroTrustGroupsExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustGroupsExcludeAccessSamlGroupRule struct { - Saml ZeroTrustGroupsExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustGroupsExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessSamlGroupRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessSamlGroupRule] -type zeroTrustGroupsExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessSamlGroupRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustGroupsExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessSamlGroupRuleSamlJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessSamlGroupRuleSaml] -type zeroTrustGroupsExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustGroupsExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustGroupsExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustGroupsExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessServiceTokenRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessServiceTokenRule] -type zeroTrustGroupsExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessServiceTokenRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustGroupsExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessServiceTokenRuleServiceTokenJSON contains the JSON -// metadata for the struct -// [ZeroTrustGroupsExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustGroupsExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustGroupsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustGroupsExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessAnyValidServiceTokenRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsExcludeAccessAnyValidServiceTokenRule] -type zeroTrustGroupsExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustZeroTrustGroupsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustGroupsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustGroupsExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessExternalEvaluationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsExcludeAccessExternalEvaluationRule] -type zeroTrustGroupsExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessExternalEvaluationRule) implementsZeroTrustZeroTrustGroupsExclude() { -} - -type ZeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustGroupsExcludeAccessCountryRule struct { - Geo ZeroTrustGroupsExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustGroupsExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessCountryRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsExcludeAccessCountryRule] -type zeroTrustGroupsExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessCountryRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustGroupsExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessCountryRuleGeoJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessCountryRuleGeo] -type zeroTrustGroupsExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustGroupsExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustGroupsExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessAuthenticationMethodRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsExcludeAccessAuthenticationMethodRule] -type zeroTrustGroupsExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessAuthenticationMethodRule) implementsZeroTrustZeroTrustGroupsExclude() { -} - -type ZeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON contains the -// JSON metadata for the struct -// [ZeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustGroupsExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustGroupsExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustGroupsExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessDevicePostureRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsExcludeAccessDevicePostureRule] -type zeroTrustGroupsExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsExcludeAccessDevicePostureRule) implementsZeroTrustZeroTrustGroupsExclude() {} - -type ZeroTrustGroupsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustGroupsExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustGroupsExcludeAccessDevicePostureRuleDevicePostureJSON contains the JSON -// metadata for the struct -// [ZeroTrustGroupsExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustGroupsExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [zero_trust.ZeroTrustGroupsIncludeAccessEmailRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessEmailListRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessDomainRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessEveryoneRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessIPRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessIPListRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessCertificateRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessAccessGroupRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessAzureGroupRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessGitHubOrganizationRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessGsuiteGroupRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessOktaGroupRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessSamlGroupRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessServiceTokenRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessAnyValidServiceTokenRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessExternalEvaluationRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessCountryRule], -// [zero_trust.ZeroTrustGroupsIncludeAccessAuthenticationMethodRule] or -// [zero_trust.ZeroTrustGroupsIncludeAccessDevicePostureRule]. -type ZeroTrustGroupsInclude interface { - implementsZeroTrustZeroTrustGroupsInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGroupsInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustGroupsIncludeAccessEmailRule struct { - Email ZeroTrustGroupsIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustGroupsIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessEmailRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessEmailRule] -type zeroTrustGroupsIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessEmailRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustGroupsIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessEmailRuleEmailJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessEmailRuleEmail] -type zeroTrustGroupsIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustGroupsIncludeAccessEmailListRule struct { - EmailList ZeroTrustGroupsIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustGroupsIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessEmailListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessEmailListRule] -type zeroTrustGroupsIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessEmailListRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustGroupsIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessEmailListRuleEmailListJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIncludeAccessEmailListRuleEmailList] -type zeroTrustGroupsIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustGroupsIncludeAccessDomainRule struct { - EmailDomain ZeroTrustGroupsIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustGroupsIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessDomainRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessDomainRule] -type zeroTrustGroupsIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessDomainRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustGroupsIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessDomainRuleEmailDomainJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIncludeAccessDomainRuleEmailDomain] -type zeroTrustGroupsIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustGroupsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustGroupsIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessEveryoneRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessEveryoneRule] -type zeroTrustGroupsIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessEveryoneRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -// Matches an IP address block. -type ZeroTrustGroupsIncludeAccessIPRule struct { - IP ZeroTrustGroupsIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustGroupsIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessIPRuleJSON contains the JSON metadata for the struct -// [ZeroTrustGroupsIncludeAccessIPRule] -type zeroTrustGroupsIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessIPRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustGroupsIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessIPRuleIPJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessIPRuleIP] -type zeroTrustGroupsIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustGroupsIncludeAccessIPListRule struct { - IPList ZeroTrustGroupsIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustGroupsIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessIPListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessIPListRule] -type zeroTrustGroupsIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessIPListRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustGroupsIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessIPListRuleIPListJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessIPListRuleIPList] -type zeroTrustGroupsIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustGroupsIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustGroupsIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessCertificateRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessCertificateRule] -type zeroTrustGroupsIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessCertificateRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -// Matches an Access group. -type ZeroTrustGroupsIncludeAccessAccessGroupRule struct { - Group ZeroTrustGroupsIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustGroupsIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessAccessGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessAccessGroupRule] -type zeroTrustGroupsIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessAccessGroupRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustGroupsIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessAccessGroupRuleGroupJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIncludeAccessAccessGroupRuleGroup] -type zeroTrustGroupsIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustGroupsIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustGroupsIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustGroupsIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessAzureGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessAzureGroupRule] -type zeroTrustGroupsIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessAzureGroupRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustGroupsIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessAzureGroupRuleAzureAdJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustGroupsIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustGroupsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustGroupsIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessGitHubOrganizationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIncludeAccessGitHubOrganizationRule] -type zeroTrustGroupsIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessGitHubOrganizationRule) implementsZeroTrustZeroTrustGroupsInclude() { -} - -type ZeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustGroupsIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustGroupsIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessGsuiteGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessGsuiteGroupRule] -type zeroTrustGroupsIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessGsuiteGroupRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustGroupsIncludeAccessOktaGroupRule struct { - Okta ZeroTrustGroupsIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustGroupsIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessOktaGroupRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessOktaGroupRule] -type zeroTrustGroupsIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessOktaGroupRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustGroupsIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessOktaGroupRuleOktaJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessOktaGroupRuleOkta] -type zeroTrustGroupsIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustGroupsIncludeAccessSamlGroupRule struct { - Saml ZeroTrustGroupsIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustGroupsIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessSamlGroupRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessSamlGroupRule] -type zeroTrustGroupsIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessSamlGroupRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustGroupsIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessSamlGroupRuleSamlJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessSamlGroupRuleSaml] -type zeroTrustGroupsIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustGroupsIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustGroupsIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustGroupsIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessServiceTokenRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessServiceTokenRule] -type zeroTrustGroupsIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessServiceTokenRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustGroupsIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessServiceTokenRuleServiceTokenJSON contains the JSON -// metadata for the struct -// [ZeroTrustGroupsIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustGroupsIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustGroupsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustGroupsIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessAnyValidServiceTokenRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIncludeAccessAnyValidServiceTokenRule] -type zeroTrustGroupsIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustZeroTrustGroupsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustGroupsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustGroupsIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessExternalEvaluationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIncludeAccessExternalEvaluationRule] -type zeroTrustGroupsIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessExternalEvaluationRule) implementsZeroTrustZeroTrustGroupsInclude() { -} - -type ZeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustGroupsIncludeAccessCountryRule struct { - Geo ZeroTrustGroupsIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustGroupsIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessCountryRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIncludeAccessCountryRule] -type zeroTrustGroupsIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessCountryRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustGroupsIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessCountryRuleGeoJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessCountryRuleGeo] -type zeroTrustGroupsIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustGroupsIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustGroupsIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessAuthenticationMethodRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIncludeAccessAuthenticationMethodRule] -type zeroTrustGroupsIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessAuthenticationMethodRule) implementsZeroTrustZeroTrustGroupsInclude() { -} - -type ZeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON contains the -// JSON metadata for the struct -// [ZeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustGroupsIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustGroupsIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustGroupsIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessDevicePostureRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIncludeAccessDevicePostureRule] -type zeroTrustGroupsIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIncludeAccessDevicePostureRule) implementsZeroTrustZeroTrustGroupsInclude() {} - -type ZeroTrustGroupsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustGroupsIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustGroupsIncludeAccessDevicePostureRuleDevicePostureJSON contains the JSON -// metadata for the struct -// [ZeroTrustGroupsIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustGroupsIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [zero_trust.ZeroTrustGroupsIsDefaultAccessEmailRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessEmailListRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessDomainRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessEveryoneRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessIPRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessIPListRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessCertificateRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessAccessGroupRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessAzureGroupRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessGsuiteGroupRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessOktaGroupRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessSamlGroupRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessServiceTokenRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessExternalEvaluationRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessCountryRule], -// [zero_trust.ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRule] or -// [zero_trust.ZeroTrustGroupsIsDefaultAccessDevicePostureRule]. -type ZeroTrustGroupsIsDefault interface { - implementsZeroTrustZeroTrustGroupsIsDefault() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGroupsIsDefault)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsIsDefaultAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustGroupsIsDefaultAccessEmailRule struct { - Email ZeroTrustGroupsIsDefaultAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustGroupsIsDefaultAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessEmailRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIsDefaultAccessEmailRule] -type zeroTrustGroupsIsDefaultAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessEmailRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustGroupsIsDefaultAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessEmailRuleEmailJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessEmailRuleEmail] -type zeroTrustGroupsIsDefaultAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustGroupsIsDefaultAccessEmailListRule struct { - EmailList ZeroTrustGroupsIsDefaultAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustGroupsIsDefaultAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessEmailListRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessEmailListRule] -type zeroTrustGroupsIsDefaultAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessEmailListRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustGroupsIsDefaultAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessEmailListRuleEmailListJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessEmailListRuleEmailList] -type zeroTrustGroupsIsDefaultAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustGroupsIsDefaultAccessDomainRule struct { - EmailDomain ZeroTrustGroupsIsDefaultAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustGroupsIsDefaultAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessDomainRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIsDefaultAccessDomainRule] -type zeroTrustGroupsIsDefaultAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessDomainRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustGroupsIsDefaultAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessDomainRuleEmailDomainJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessDomainRuleEmailDomain] -type zeroTrustGroupsIsDefaultAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustGroupsIsDefaultAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustGroupsIsDefaultAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessEveryoneRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessEveryoneRule] -type zeroTrustGroupsIsDefaultAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessEveryoneRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -// Matches an IP address block. -type ZeroTrustGroupsIsDefaultAccessIPRule struct { - IP ZeroTrustGroupsIsDefaultAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustGroupsIsDefaultAccessIPRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessIPRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIsDefaultAccessIPRule] -type zeroTrustGroupsIsDefaultAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessIPRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustGroupsIsDefaultAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessIPRuleIPJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIsDefaultAccessIPRuleIP] -type zeroTrustGroupsIsDefaultAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustGroupsIsDefaultAccessIPListRule struct { - IPList ZeroTrustGroupsIsDefaultAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustGroupsIsDefaultAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessIPListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIsDefaultAccessIPListRule] -type zeroTrustGroupsIsDefaultAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessIPListRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustGroupsIsDefaultAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessIPListRuleIPListJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIsDefaultAccessIPListRuleIPList] -type zeroTrustGroupsIsDefaultAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustGroupsIsDefaultAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustGroupsIsDefaultAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessCertificateRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessCertificateRule] -type zeroTrustGroupsIsDefaultAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessCertificateRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -// Matches an Access group. -type ZeroTrustGroupsIsDefaultAccessAccessGroupRule struct { - Group ZeroTrustGroupsIsDefaultAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustGroupsIsDefaultAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessAccessGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessAccessGroupRule] -type zeroTrustGroupsIsDefaultAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessAccessGroupRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -type ZeroTrustGroupsIsDefaultAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustGroupsIsDefaultAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessAccessGroupRuleGroupJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessAccessGroupRuleGroup] -type zeroTrustGroupsIsDefaultAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustGroupsIsDefaultAccessAzureGroupRule struct { - AzureAd ZeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustGroupsIsDefaultAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessAzureGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessAzureGroupRule] -type zeroTrustGroupsIsDefaultAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessAzureGroupRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAd] -type zeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRule] -type zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -type ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustGroupsIsDefaultAccessGsuiteGroupRule struct { - Gsuite ZeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessGsuiteGroupRule] -type zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessGsuiteGroupRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -type ZeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuite] -type zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustGroupsIsDefaultAccessOktaGroupRule struct { - Okta ZeroTrustGroupsIsDefaultAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustGroupsIsDefaultAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessOktaGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessOktaGroupRule] -type zeroTrustGroupsIsDefaultAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessOktaGroupRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustGroupsIsDefaultAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessOktaGroupRuleOktaJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIsDefaultAccessOktaGroupRuleOkta] -type zeroTrustGroupsIsDefaultAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustGroupsIsDefaultAccessSamlGroupRule struct { - Saml ZeroTrustGroupsIsDefaultAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustGroupsIsDefaultAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessSamlGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessSamlGroupRule] -type zeroTrustGroupsIsDefaultAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessSamlGroupRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustGroupsIsDefaultAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessSamlGroupRuleSamlJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIsDefaultAccessSamlGroupRuleSaml] -type zeroTrustGroupsIsDefaultAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustGroupsIsDefaultAccessServiceTokenRule struct { - ServiceToken ZeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustGroupsIsDefaultAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessServiceTokenRuleJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIsDefaultAccessServiceTokenRule] -type zeroTrustGroupsIsDefaultAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessServiceTokenRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -type ZeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON contains the JSON -// metadata for the struct -// [ZeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceToken] -type zeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRule] -type zeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessAnyValidServiceTokenRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustGroupsIsDefaultAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessExternalEvaluationRule] -type zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessExternalEvaluationRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -type ZeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustGroupsIsDefaultAccessCountryRule struct { - Geo ZeroTrustGroupsIsDefaultAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustGroupsIsDefaultAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessCountryRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsIsDefaultAccessCountryRule] -type zeroTrustGroupsIsDefaultAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessCountryRule) implementsZeroTrustZeroTrustGroupsIsDefault() {} - -type ZeroTrustGroupsIsDefaultAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustGroupsIsDefaultAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessCountryRuleGeoJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsIsDefaultAccessCountryRuleGeo] -type zeroTrustGroupsIsDefaultAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRule] -type zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -type ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON contains -// the JSON metadata for the struct -// [ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustGroupsIsDefaultAccessDevicePostureRule struct { - DevicePosture ZeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustGroupsIsDefaultAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessDevicePostureRuleJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsIsDefaultAccessDevicePostureRule] -type zeroTrustGroupsIsDefaultAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsIsDefaultAccessDevicePostureRule) implementsZeroTrustZeroTrustGroupsIsDefault() { -} - -type ZeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON contains the -// JSON metadata for the struct -// [ZeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePosture] -type zeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [zero_trust.ZeroTrustGroupsRequireAccessEmailRule], -// [zero_trust.ZeroTrustGroupsRequireAccessEmailListRule], -// [zero_trust.ZeroTrustGroupsRequireAccessDomainRule], -// [zero_trust.ZeroTrustGroupsRequireAccessEveryoneRule], -// [zero_trust.ZeroTrustGroupsRequireAccessIPRule], -// [zero_trust.ZeroTrustGroupsRequireAccessIPListRule], -// [zero_trust.ZeroTrustGroupsRequireAccessCertificateRule], -// [zero_trust.ZeroTrustGroupsRequireAccessAccessGroupRule], -// [zero_trust.ZeroTrustGroupsRequireAccessAzureGroupRule], -// [zero_trust.ZeroTrustGroupsRequireAccessGitHubOrganizationRule], -// [zero_trust.ZeroTrustGroupsRequireAccessGsuiteGroupRule], -// [zero_trust.ZeroTrustGroupsRequireAccessOktaGroupRule], -// [zero_trust.ZeroTrustGroupsRequireAccessSamlGroupRule], -// [zero_trust.ZeroTrustGroupsRequireAccessServiceTokenRule], -// [zero_trust.ZeroTrustGroupsRequireAccessAnyValidServiceTokenRule], -// [zero_trust.ZeroTrustGroupsRequireAccessExternalEvaluationRule], -// [zero_trust.ZeroTrustGroupsRequireAccessCountryRule], -// [zero_trust.ZeroTrustGroupsRequireAccessAuthenticationMethodRule] or -// [zero_trust.ZeroTrustGroupsRequireAccessDevicePostureRule]. -type ZeroTrustGroupsRequire interface { - implementsZeroTrustZeroTrustGroupsRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGroupsRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGroupsRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustGroupsRequireAccessEmailRule struct { - Email ZeroTrustGroupsRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustGroupsRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessEmailRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessEmailRule] -type zeroTrustGroupsRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessEmailRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustGroupsRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessEmailRuleEmailJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessEmailRuleEmail] -type zeroTrustGroupsRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustGroupsRequireAccessEmailListRule struct { - EmailList ZeroTrustGroupsRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustGroupsRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessEmailListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessEmailListRule] -type zeroTrustGroupsRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessEmailListRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustGroupsRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessEmailListRuleEmailListJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsRequireAccessEmailListRuleEmailList] -type zeroTrustGroupsRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustGroupsRequireAccessDomainRule struct { - EmailDomain ZeroTrustGroupsRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustGroupsRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessDomainRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessDomainRule] -type zeroTrustGroupsRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessDomainRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustGroupsRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessDomainRuleEmailDomainJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsRequireAccessDomainRuleEmailDomain] -type zeroTrustGroupsRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustGroupsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustGroupsRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessEveryoneRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessEveryoneRule] -type zeroTrustGroupsRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessEveryoneRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -// Matches an IP address block. -type ZeroTrustGroupsRequireAccessIPRule struct { - IP ZeroTrustGroupsRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustGroupsRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessIPRuleJSON contains the JSON metadata for the struct -// [ZeroTrustGroupsRequireAccessIPRule] -type zeroTrustGroupsRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessIPRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustGroupsRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessIPRuleIPJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessIPRuleIP] -type zeroTrustGroupsRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustGroupsRequireAccessIPListRule struct { - IPList ZeroTrustGroupsRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustGroupsRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessIPListRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessIPListRule] -type zeroTrustGroupsRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessIPListRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustGroupsRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessIPListRuleIPListJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessIPListRuleIPList] -type zeroTrustGroupsRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustGroupsRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustGroupsRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessCertificateRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessCertificateRule] -type zeroTrustGroupsRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessCertificateRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -// Matches an Access group. -type ZeroTrustGroupsRequireAccessAccessGroupRule struct { - Group ZeroTrustGroupsRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustGroupsRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessAccessGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessAccessGroupRule] -type zeroTrustGroupsRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessAccessGroupRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustGroupsRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessAccessGroupRuleGroupJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsRequireAccessAccessGroupRuleGroup] -type zeroTrustGroupsRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustGroupsRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustGroupsRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustGroupsRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessAzureGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessAzureGroupRule] -type zeroTrustGroupsRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessAzureGroupRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustGroupsRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessAzureGroupRuleAzureAdJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsRequireAccessAzureGroupRuleAzureAd] -type zeroTrustGroupsRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustGroupsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustGroupsRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessGitHubOrganizationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsRequireAccessGitHubOrganizationRule] -type zeroTrustGroupsRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessGitHubOrganizationRule) implementsZeroTrustZeroTrustGroupsRequire() { -} - -type ZeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustGroupsRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustGroupsRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustGroupsRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessGsuiteGroupRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessGsuiteGroupRule] -type zeroTrustGroupsRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessGsuiteGroupRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustGroupsRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata -// for the struct [ZeroTrustGroupsRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustGroupsRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustGroupsRequireAccessOktaGroupRule struct { - Okta ZeroTrustGroupsRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustGroupsRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessOktaGroupRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessOktaGroupRule] -type zeroTrustGroupsRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessOktaGroupRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustGroupsRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessOktaGroupRuleOktaJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessOktaGroupRuleOkta] -type zeroTrustGroupsRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustGroupsRequireAccessSamlGroupRule struct { - Saml ZeroTrustGroupsRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustGroupsRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessSamlGroupRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessSamlGroupRule] -type zeroTrustGroupsRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessSamlGroupRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustGroupsRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessSamlGroupRuleSamlJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessSamlGroupRuleSaml] -type zeroTrustGroupsRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustGroupsRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustGroupsRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustGroupsRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessServiceTokenRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessServiceTokenRule] -type zeroTrustGroupsRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessServiceTokenRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustGroupsRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessServiceTokenRuleServiceTokenJSON contains the JSON -// metadata for the struct -// [ZeroTrustGroupsRequireAccessServiceTokenRuleServiceToken] -type zeroTrustGroupsRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustGroupsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustGroupsRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessAnyValidServiceTokenRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsRequireAccessAnyValidServiceTokenRule] -type zeroTrustGroupsRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustZeroTrustGroupsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustGroupsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustGroupsRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessExternalEvaluationRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsRequireAccessExternalEvaluationRule] -type zeroTrustGroupsRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessExternalEvaluationRule) implementsZeroTrustZeroTrustGroupsRequire() { -} - -type ZeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustGroupsRequireAccessCountryRule struct { - Geo ZeroTrustGroupsRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustGroupsRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessCountryRuleJSON contains the JSON metadata for the -// struct [ZeroTrustGroupsRequireAccessCountryRule] -type zeroTrustGroupsRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessCountryRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustGroupsRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessCountryRuleGeoJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessCountryRuleGeo] -type zeroTrustGroupsRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustGroupsRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustGroupsRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessAuthenticationMethodRuleJSON contains the JSON -// metadata for the struct [ZeroTrustGroupsRequireAccessAuthenticationMethodRule] -type zeroTrustGroupsRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessAuthenticationMethodRule) implementsZeroTrustZeroTrustGroupsRequire() { -} - -type ZeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON contains the -// JSON metadata for the struct -// [ZeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustGroupsRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustGroupsRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustGroupsRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessDevicePostureRuleJSON contains the JSON metadata for -// the struct [ZeroTrustGroupsRequireAccessDevicePostureRule] -type zeroTrustGroupsRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGroupsRequireAccessDevicePostureRule) implementsZeroTrustZeroTrustGroupsRequire() {} - -type ZeroTrustGroupsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustGroupsRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustGroupsRequireAccessDevicePostureRuleDevicePostureJSON contains the JSON -// metadata for the struct -// [ZeroTrustGroupsRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustGroupsRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGroupsRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGroupsRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type AccessGroupDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON accessGroupDeleteResponseJSON `json:"-"` -} - -// accessGroupDeleteResponseJSON contains the JSON metadata for the struct -// [AccessGroupDeleteResponse] -type accessGroupDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type AccessGroupNewParams struct { - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]AccessGroupNewParamsInclude] `json:"include,required"` - // The name of the Access group. - Name param.Field[string] `json:"name,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. - ZoneID param.Field[string] `path:"zone_id"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]AccessGroupNewParamsExclude] `json:"exclude"` - // Whether this is the default group - IsDefault param.Field[bool] `json:"is_default"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require param.Field[[]AccessGroupNewParamsRequire] `json:"require"` -} - -func (r AccessGroupNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [zero_trust.AccessGroupNewParamsIncludeAccessEmailRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessEmailListRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessDomainRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessEveryoneRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessIPRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessIPListRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessCertificateRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessAccessGroupRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessAzureGroupRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessGitHubOrganizationRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessGsuiteGroupRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessOktaGroupRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessSamlGroupRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessServiceTokenRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessExternalEvaluationRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessCountryRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessAuthenticationMethodRule], -// [zero_trust.AccessGroupNewParamsIncludeAccessDevicePostureRule]. -type AccessGroupNewParamsInclude interface { - implementsZeroTrustAccessGroupNewParamsInclude() -} - -// Matches a specific email. -type AccessGroupNewParamsIncludeAccessEmailRule struct { - Email param.Field[AccessGroupNewParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessGroupNewParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessEmailRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessGroupNewParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessGroupNewParamsIncludeAccessEmailListRule struct { - EmailList param.Field[AccessGroupNewParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessGroupNewParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessGroupNewParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[AccessGroupNewParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessGroupNewParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessDomainRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessGroupNewParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessGroupNewParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessGroupNewParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -// Matches an IP address block. -type AccessGroupNewParamsIncludeAccessIPRule struct { - IP param.Field[AccessGroupNewParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessGroupNewParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessIPRule) implementsZeroTrustAccessGroupNewParamsInclude() {} - -type AccessGroupNewParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessGroupNewParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessGroupNewParamsIncludeAccessIPListRule struct { - IPList param.Field[AccessGroupNewParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessGroupNewParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessIPListRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessGroupNewParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessGroupNewParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -// Matches an Access group. -type AccessGroupNewParamsIncludeAccessAccessGroupRule struct { - Group param.Field[AccessGroupNewParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessGroupNewParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessGroupNewParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessGroupNewParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessGroupNewParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessGroupNewParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessGroupNewParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessGroupNewParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessGroupNewParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[AccessGroupNewParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessGroupNewParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupNewParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessGroupNewParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[AccessGroupNewParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessGroupNewParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessGroupNewParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessGroupNewParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessGroupNewParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessGroupNewParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessGroupNewParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessGroupNewParamsIncludeAccessCountryRule struct { - Geo param.Field[AccessGroupNewParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessGroupNewParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessCountryRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessGroupNewParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessGroupNewParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessGroupNewParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessGroupNewParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessGroupNewParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type AccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [zero_trust.AccessGroupNewParamsExcludeAccessEmailRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessEmailListRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessDomainRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessEveryoneRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessIPRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessIPListRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessCertificateRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessAccessGroupRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessAzureGroupRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessGitHubOrganizationRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessGsuiteGroupRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessOktaGroupRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessSamlGroupRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessServiceTokenRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessExternalEvaluationRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessCountryRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessAuthenticationMethodRule], -// [zero_trust.AccessGroupNewParamsExcludeAccessDevicePostureRule]. -type AccessGroupNewParamsExclude interface { - implementsZeroTrustAccessGroupNewParamsExclude() -} - -// Matches a specific email. -type AccessGroupNewParamsExcludeAccessEmailRule struct { - Email param.Field[AccessGroupNewParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessGroupNewParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessEmailRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessGroupNewParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessGroupNewParamsExcludeAccessEmailListRule struct { - EmailList param.Field[AccessGroupNewParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessGroupNewParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessGroupNewParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[AccessGroupNewParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessGroupNewParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessDomainRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessGroupNewParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessGroupNewParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessGroupNewParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -// Matches an IP address block. -type AccessGroupNewParamsExcludeAccessIPRule struct { - IP param.Field[AccessGroupNewParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessGroupNewParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessIPRule) implementsZeroTrustAccessGroupNewParamsExclude() {} - -type AccessGroupNewParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessGroupNewParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessGroupNewParamsExcludeAccessIPListRule struct { - IPList param.Field[AccessGroupNewParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessGroupNewParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessIPListRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessGroupNewParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessGroupNewParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -// Matches an Access group. -type AccessGroupNewParamsExcludeAccessAccessGroupRule struct { - Group param.Field[AccessGroupNewParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessGroupNewParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessGroupNewParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessGroupNewParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessGroupNewParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessGroupNewParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessGroupNewParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessGroupNewParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessGroupNewParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[AccessGroupNewParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessGroupNewParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupNewParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessGroupNewParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[AccessGroupNewParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessGroupNewParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessGroupNewParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessGroupNewParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessGroupNewParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessGroupNewParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessGroupNewParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessGroupNewParamsExcludeAccessCountryRule struct { - Geo param.Field[AccessGroupNewParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessGroupNewParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessCountryRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessGroupNewParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessGroupNewParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessGroupNewParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessGroupNewParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessGroupNewParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type AccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [zero_trust.AccessGroupNewParamsRequireAccessEmailRule], -// [zero_trust.AccessGroupNewParamsRequireAccessEmailListRule], -// [zero_trust.AccessGroupNewParamsRequireAccessDomainRule], -// [zero_trust.AccessGroupNewParamsRequireAccessEveryoneRule], -// [zero_trust.AccessGroupNewParamsRequireAccessIPRule], -// [zero_trust.AccessGroupNewParamsRequireAccessIPListRule], -// [zero_trust.AccessGroupNewParamsRequireAccessCertificateRule], -// [zero_trust.AccessGroupNewParamsRequireAccessAccessGroupRule], -// [zero_trust.AccessGroupNewParamsRequireAccessAzureGroupRule], -// [zero_trust.AccessGroupNewParamsRequireAccessGitHubOrganizationRule], -// [zero_trust.AccessGroupNewParamsRequireAccessGsuiteGroupRule], -// [zero_trust.AccessGroupNewParamsRequireAccessOktaGroupRule], -// [zero_trust.AccessGroupNewParamsRequireAccessSamlGroupRule], -// [zero_trust.AccessGroupNewParamsRequireAccessServiceTokenRule], -// [zero_trust.AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule], -// [zero_trust.AccessGroupNewParamsRequireAccessExternalEvaluationRule], -// [zero_trust.AccessGroupNewParamsRequireAccessCountryRule], -// [zero_trust.AccessGroupNewParamsRequireAccessAuthenticationMethodRule], -// [zero_trust.AccessGroupNewParamsRequireAccessDevicePostureRule]. -type AccessGroupNewParamsRequire interface { - implementsZeroTrustAccessGroupNewParamsRequire() -} - -// Matches a specific email. -type AccessGroupNewParamsRequireAccessEmailRule struct { - Email param.Field[AccessGroupNewParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessGroupNewParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessEmailRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessGroupNewParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessGroupNewParamsRequireAccessEmailListRule struct { - EmailList param.Field[AccessGroupNewParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessGroupNewParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessGroupNewParamsRequireAccessDomainRule struct { - EmailDomain param.Field[AccessGroupNewParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessGroupNewParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessDomainRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessGroupNewParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessGroupNewParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessGroupNewParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -// Matches an IP address block. -type AccessGroupNewParamsRequireAccessIPRule struct { - IP param.Field[AccessGroupNewParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessGroupNewParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessIPRule) implementsZeroTrustAccessGroupNewParamsRequire() {} - -type AccessGroupNewParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessGroupNewParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessGroupNewParamsRequireAccessIPListRule struct { - IPList param.Field[AccessGroupNewParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessGroupNewParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessIPListRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessGroupNewParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessGroupNewParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -// Matches an Access group. -type AccessGroupNewParamsRequireAccessAccessGroupRule struct { - Group param.Field[AccessGroupNewParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessGroupNewParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupNewParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessGroupNewParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[AccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessGroupNewParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessGroupNewParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessGroupNewParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessGroupNewParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessGroupNewParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessGroupNewParamsRequireAccessOktaGroupRule struct { - Okta param.Field[AccessGroupNewParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessGroupNewParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupNewParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessGroupNewParamsRequireAccessSamlGroupRule struct { - Saml param.Field[AccessGroupNewParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessGroupNewParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessGroupNewParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessGroupNewParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[AccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessGroupNewParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessGroupNewParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessGroupNewParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessGroupNewParamsRequireAccessCountryRule struct { - Geo param.Field[AccessGroupNewParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessGroupNewParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessCountryRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessGroupNewParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessGroupNewParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessGroupNewParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessGroupNewParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[AccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessGroupNewParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupNewParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type AccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccessGroupNewResponseEnvelope struct { - Errors []AccessGroupNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessGroupNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGroups `json:"result,required"` - // Whether the API call was successful - Success AccessGroupNewResponseEnvelopeSuccess `json:"success,required"` - JSON accessGroupNewResponseEnvelopeJSON `json:"-"` -} - -// accessGroupNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [AccessGroupNewResponseEnvelope] -type accessGroupNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccessGroupNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessGroupNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessGroupNewResponseEnvelopeErrors] -type accessGroupNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessGroupNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessGroupNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessGroupNewResponseEnvelopeMessages] -type accessGroupNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccessGroupNewResponseEnvelopeSuccess bool - -const ( - AccessGroupNewResponseEnvelopeSuccessTrue AccessGroupNewResponseEnvelopeSuccess = true -) - -func (r AccessGroupNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case AccessGroupNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type AccessGroupUpdateParams struct { - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]AccessGroupUpdateParamsInclude] `json:"include,required"` - // The name of the Access group. - Name param.Field[string] `json:"name,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. - ZoneID param.Field[string] `path:"zone_id"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]AccessGroupUpdateParamsExclude] `json:"exclude"` - // Whether this is the default group - IsDefault param.Field[bool] `json:"is_default"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require param.Field[[]AccessGroupUpdateParamsRequire] `json:"require"` -} - -func (r AccessGroupUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessEmailListRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessDomainRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessEveryoneRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessIPRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessIPListRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessCertificateRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessAccessGroupRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessAzureGroupRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessOktaGroupRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessSamlGroupRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessServiceTokenRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessCountryRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule], -// [zero_trust.AccessGroupUpdateParamsIncludeAccessDevicePostureRule]. -type AccessGroupUpdateParamsInclude interface { - implementsZeroTrustAccessGroupUpdateParamsInclude() -} - -// Matches a specific email. -type AccessGroupUpdateParamsIncludeAccessEmailRule struct { - Email param.Field[AccessGroupUpdateParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessGroupUpdateParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessGroupUpdateParamsIncludeAccessEmailListRule struct { - EmailList param.Field[AccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessGroupUpdateParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[AccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessGroupUpdateParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -// Matches an IP address block. -type AccessGroupUpdateParamsIncludeAccessIPRule struct { - IP param.Field[AccessGroupUpdateParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessGroupUpdateParamsIncludeAccessIPListRule struct { - IPList param.Field[AccessGroupUpdateParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessGroupUpdateParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -// Matches an Access group. -type AccessGroupUpdateParamsIncludeAccessAccessGroupRule struct { - Group param.Field[AccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessGroupUpdateParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessGroupUpdateParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[AccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessGroupUpdateParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[AccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessGroupUpdateParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessGroupUpdateParamsIncludeAccessCountryRule struct { - Geo param.Field[AccessGroupUpdateParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessGroupUpdateParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type AccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessEmailListRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessDomainRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessEveryoneRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessIPRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessIPListRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessCertificateRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessAccessGroupRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessAzureGroupRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessOktaGroupRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessSamlGroupRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessServiceTokenRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessCountryRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule], -// [zero_trust.AccessGroupUpdateParamsExcludeAccessDevicePostureRule]. -type AccessGroupUpdateParamsExclude interface { - implementsZeroTrustAccessGroupUpdateParamsExclude() -} - -// Matches a specific email. -type AccessGroupUpdateParamsExcludeAccessEmailRule struct { - Email param.Field[AccessGroupUpdateParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessGroupUpdateParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessGroupUpdateParamsExcludeAccessEmailListRule struct { - EmailList param.Field[AccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessGroupUpdateParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[AccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessGroupUpdateParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -// Matches an IP address block. -type AccessGroupUpdateParamsExcludeAccessIPRule struct { - IP param.Field[AccessGroupUpdateParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessGroupUpdateParamsExcludeAccessIPListRule struct { - IPList param.Field[AccessGroupUpdateParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessGroupUpdateParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -// Matches an Access group. -type AccessGroupUpdateParamsExcludeAccessAccessGroupRule struct { - Group param.Field[AccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessGroupUpdateParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[AccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessGroupUpdateParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[AccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessGroupUpdateParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[AccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessGroupUpdateParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[AccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessGroupUpdateParamsExcludeAccessCountryRule struct { - Geo param.Field[AccessGroupUpdateParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type AccessGroupUpdateParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[AccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type AccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r AccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessEmailListRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessDomainRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessEveryoneRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessIPRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessIPListRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessCertificateRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessAccessGroupRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessAzureGroupRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessGsuiteGroupRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessOktaGroupRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessSamlGroupRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessServiceTokenRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessExternalEvaluationRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessCountryRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule], -// [zero_trust.AccessGroupUpdateParamsRequireAccessDevicePostureRule]. -type AccessGroupUpdateParamsRequire interface { - implementsZeroTrustAccessGroupUpdateParamsRequire() -} - -// Matches a specific email. -type AccessGroupUpdateParamsRequireAccessEmailRule struct { - Email param.Field[AccessGroupUpdateParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r AccessGroupUpdateParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type AccessGroupUpdateParamsRequireAccessEmailListRule struct { - EmailList param.Field[AccessGroupUpdateParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type AccessGroupUpdateParamsRequireAccessDomainRule struct { - EmailDomain param.Field[AccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type AccessGroupUpdateParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -// Matches an IP address block. -type AccessGroupUpdateParamsRequireAccessIPRule struct { - IP param.Field[AccessGroupUpdateParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type AccessGroupUpdateParamsRequireAccessIPListRule struct { - IPList param.Field[AccessGroupUpdateParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type AccessGroupUpdateParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -// Matches an Access group. -type AccessGroupUpdateParamsRequireAccessAccessGroupRule struct { - Group param.Field[AccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type AccessGroupUpdateParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[AccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type AccessGroupDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessGroupDeleteResponseJSON `json:"-"` } -// Matches a Github organization. Requires a Github identity provider. -type AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[AccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +// accessGroupDeleteResponseJSON contains the JSON metadata for the struct +// [AccessGroupDeleteResponse] +type accessGroupDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *AccessGroupDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +func (r accessGroupDeleteResponseJSON) RawJSON() string { + return r.raw } -type AccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. +type AccessGroupNewParams struct { + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessRuleUnionParam] `json:"include,required"` + // The name of the Access group. Name param.Field[string] `json:"name,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. + ZoneID param.Field[string] `path:"zone_id"` + // Rules evaluated with a NOT logical operator. To match a policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessRuleUnionParam] `json:"exclude"` + // Whether this is the default group + IsDefault param.Field[bool] `json:"is_default"` + // Rules evaluated with an AND logical operator. To match a policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessRuleUnionParam] `json:"require"` } -func (r AccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type AccessGroupUpdateParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[AccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type AccessGroupUpdateParamsRequireAccessOktaGroupRule struct { - Okta param.Field[AccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type AccessGroupUpdateParamsRequireAccessSamlGroupRule struct { - Saml param.Field[AccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type AccessGroupUpdateParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[AccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type AccessGroupUpdateParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[AccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type AccessGroupUpdateParamsRequireAccessCountryRule struct { - Geo param.Field[AccessGroupUpdateParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessGroupUpdateParamsRequireAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type AccessGroupUpdateParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { +func (r AccessGroupNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Enforce different MFA options -type AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[AccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type AccessGroupNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ZeroTrustGroup `json:"result,required"` + // Whether the API call was successful + Success AccessGroupNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessGroupNewResponseEnvelopeJSON `json:"-"` } -func (r AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +// accessGroupNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessGroupNewResponseEnvelope] +type accessGroupNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type AccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` +func (r *AccessGroupNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r AccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r accessGroupNewResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// Enforces a device posture rule has run successfully -type AccessGroupUpdateParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[AccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} +// Whether the API call was successful +type AccessGroupNewResponseEnvelopeSuccess bool -func (r AccessGroupUpdateParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} +const ( + AccessGroupNewResponseEnvelopeSuccessTrue AccessGroupNewResponseEnvelopeSuccess = true +) -func (r AccessGroupUpdateParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +func (r AccessGroupNewResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case AccessGroupNewResponseEnvelopeSuccessTrue: + return true + } + return false } -type AccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` +type AccessGroupUpdateParams struct { + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessRuleUnionParam] `json:"include,required"` + // The name of the Access group. + Name param.Field[string] `json:"name,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. + ZoneID param.Field[string] `path:"zone_id"` + // Rules evaluated with a NOT logical operator. To match a policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessRuleUnionParam] `json:"exclude"` + // Whether this is the default group + IsDefault param.Field[bool] `json:"is_default"` + // Rules evaluated with an AND logical operator. To match a policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessRuleUnionParam] `json:"require"` } -func (r AccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { +func (r AccessGroupUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type AccessGroupUpdateResponseEnvelope struct { - Errors []AccessGroupUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessGroupUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGroups `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ZeroTrustGroup `json:"result,required"` // Whether the API call was successful Success AccessGroupUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessGroupUpdateResponseEnvelopeJSON `json:"-"` @@ -6654,52 +339,6 @@ func (r accessGroupUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessGroupUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessGroupUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessGroupUpdateResponseEnvelopeErrors] -type accessGroupUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessGroupUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessGroupUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessGroupUpdateResponseEnvelopeMessages] -type accessGroupUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessGroupUpdateResponseEnvelopeSuccess bool @@ -6730,9 +369,9 @@ type AccessGroupDeleteParams struct { } type AccessGroupDeleteResponseEnvelope struct { - Errors []AccessGroupDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessGroupDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessGroupDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessGroupDeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessGroupDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessGroupDeleteResponseEnvelopeJSON `json:"-"` @@ -6757,52 +396,6 @@ func (r accessGroupDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessGroupDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessGroupDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessGroupDeleteResponseEnvelopeErrors] -type accessGroupDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessGroupDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessGroupDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessGroupDeleteResponseEnvelopeMessages] -type accessGroupDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessGroupDeleteResponseEnvelopeSuccess bool @@ -6826,9 +419,9 @@ type AccessGroupGetParams struct { } type AccessGroupGetResponseEnvelope struct { - Errors []AccessGroupGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessGroupGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGroups `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ZeroTrustGroup `json:"result,required"` // Whether the API call was successful Success AccessGroupGetResponseEnvelopeSuccess `json:"success,required"` JSON accessGroupGetResponseEnvelopeJSON `json:"-"` @@ -6853,52 +446,6 @@ func (r accessGroupGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessGroupGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessGroupGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessGroupGetResponseEnvelopeErrors] -type accessGroupGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessGroupGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessGroupGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessGroupGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessGroupGetResponseEnvelopeMessages] -type accessGroupGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessGroupGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessGroupGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessGroupGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accessgroup_test.go b/zero_trust/accessgroup_test.go index be6e61e35f8..82ae5698f67 100644 --- a/zero_trust/accessgroup_test.go +++ b/zero_trust/accessgroup_test.go @@ -29,49 +29,49 @@ func TestAccessGroupNewWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.ZeroTrust.Access.Groups.New(context.TODO(), zero_trust.AccessGroupNewParams{ - Include: cloudflare.F([]zero_trust.AccessGroupNewParamsInclude{zero_trust.AccessGroupNewParamsIncludeAccessEmailRule(zero_trust.AccessGroupNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsIncludeAccessEmailRuleEmail{ + Include: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupNewParamsIncludeAccessEmailRule(zero_trust.AccessGroupNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupNewParamsIncludeAccessEmailRule(zero_trust.AccessGroupNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), Name: cloudflare.F("Allow devs"), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - Exclude: cloudflare.F([]zero_trust.AccessGroupNewParamsExclude{zero_trust.AccessGroupNewParamsExcludeAccessEmailRule(zero_trust.AccessGroupNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsExcludeAccessEmailRuleEmail{ + Exclude: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupNewParamsExcludeAccessEmailRule(zero_trust.AccessGroupNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupNewParamsExcludeAccessEmailRule(zero_trust.AccessGroupNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), IsDefault: cloudflare.F(true), - Require: cloudflare.F([]zero_trust.AccessGroupNewParamsRequire{zero_trust.AccessGroupNewParamsRequireAccessEmailRule(zero_trust.AccessGroupNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsRequireAccessEmailRuleEmail{ + Require: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupNewParamsRequireAccessEmailRule(zero_trust.AccessGroupNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupNewParamsRequireAccessEmailRule(zero_trust.AccessGroupNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupNewParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), }) if err != nil { var apierr *cloudflare.Error @@ -100,49 +100,49 @@ func TestAccessGroupUpdateWithOptionalParams(t *testing.T) { context.TODO(), "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.AccessGroupUpdateParams{ - Include: cloudflare.F([]zero_trust.AccessGroupUpdateParamsInclude{zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ + Include: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), Name: cloudflare.F("Allow devs"), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - Exclude: cloudflare.F([]zero_trust.AccessGroupUpdateParamsExclude{zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ + Exclude: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), IsDefault: cloudflare.F(true), - Require: cloudflare.F([]zero_trust.AccessGroupUpdateParamsRequire{zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRuleEmail{ + Require: cloudflare.F([]zero_trust.AccessRuleUnionParam{zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - }), zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRuleEmail{ + }, zero_trust.EmailRuleParam{ + Email: cloudflare.F(zero_trust.EmailRuleEmailParam{ Email: cloudflare.F("test@example.com"), }), - })}), + }}), }, ) if err != nil { diff --git a/zero_trust/accesskey.go b/zero_trust/accesskey.go index 67bcce6073c..abc0bb05cbd 100644 --- a/zero_trust/accesskey.go +++ b/zero_trust/accesskey.go @@ -35,7 +35,7 @@ func NewAccessKeyService(opts ...option.RequestOption) (r *AccessKeyService) { } // Updates the Access key rotation settings for an account. -func (r *AccessKeyService) Update(ctx context.Context, identifier string, body AccessKeyUpdateParams, opts ...option.RequestOption) (res *AccessKeyUpdateResponse, err error) { +func (r *AccessKeyService) Update(ctx context.Context, identifier string, body AccessKeyUpdateParams, opts ...option.RequestOption) (res *AccessKeyUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessKeyUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/access/keys", identifier) @@ -48,7 +48,7 @@ func (r *AccessKeyService) Update(ctx context.Context, identifier string, body A } // Gets the Access key rotation settings for an account. -func (r *AccessKeyService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *AccessKeyGetResponse, err error) { +func (r *AccessKeyService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *AccessKeyGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessKeyGetResponseEnvelope path := fmt.Sprintf("accounts/%s/access/keys", identifier) @@ -61,7 +61,7 @@ func (r *AccessKeyService) Get(ctx context.Context, identifier string, opts ...o } // Perfoms a key rotation for an account. -func (r *AccessKeyService) Rotate(ctx context.Context, identifier string, opts ...option.RequestOption) (res *AccessKeyRotateResponse, err error) { +func (r *AccessKeyService) Rotate(ctx context.Context, identifier string, opts ...option.RequestOption) (res *AccessKeyRotateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env AccessKeyRotateResponseEnvelope path := fmt.Sprintf("accounts/%s/access/keys/rotate", identifier) @@ -75,13 +75,13 @@ func (r *AccessKeyService) Rotate(ctx context.Context, identifier string, opts . // Union satisfied by [zero_trust.AccessKeyUpdateResponseUnknown] or // [shared.UnionString]. -type AccessKeyUpdateResponse interface { - ImplementsZeroTrustAccessKeyUpdateResponse() +type AccessKeyUpdateResponseUnion interface { + ImplementsZeroTrustAccessKeyUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessKeyUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*AccessKeyUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -92,13 +92,13 @@ func init() { // Union satisfied by [zero_trust.AccessKeyGetResponseUnknown] or // [shared.UnionString]. -type AccessKeyGetResponse interface { - ImplementsZeroTrustAccessKeyGetResponse() +type AccessKeyGetResponseUnion interface { + ImplementsZeroTrustAccessKeyGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessKeyGetResponse)(nil)).Elem(), + reflect.TypeOf((*AccessKeyGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -109,13 +109,13 @@ func init() { // Union satisfied by [zero_trust.AccessKeyRotateResponseUnknown] or // [shared.UnionString]. -type AccessKeyRotateResponse interface { - ImplementsZeroTrustAccessKeyRotateResponse() +type AccessKeyRotateResponseUnion interface { + ImplementsZeroTrustAccessKeyRotateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*AccessKeyRotateResponse)(nil)).Elem(), + reflect.TypeOf((*AccessKeyRotateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -134,9 +134,9 @@ func (r AccessKeyUpdateParams) MarshalJSON() (data []byte, err error) { } type AccessKeyUpdateResponseEnvelope struct { - Errors []AccessKeyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessKeyUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AccessKeyUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessKeyUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessKeyUpdateResponseEnvelopeSuccess `json:"success,required"` // The number of days until the next key rotation. @@ -170,52 +170,6 @@ func (r accessKeyUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessKeyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessKeyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessKeyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessKeyUpdateResponseEnvelopeErrors] -type accessKeyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessKeyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessKeyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessKeyUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessKeyUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessKeyUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessKeyUpdateResponseEnvelopeMessages] -type accessKeyUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessKeyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessKeyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessKeyUpdateResponseEnvelopeSuccess bool @@ -232,9 +186,9 @@ func (r AccessKeyUpdateResponseEnvelopeSuccess) IsKnown() bool { } type AccessKeyGetResponseEnvelope struct { - Errors []AccessKeyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessKeyGetResponseEnvelopeMessages `json:"messages,required"` - Result AccessKeyGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessKeyGetResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessKeyGetResponseEnvelopeSuccess `json:"success,required"` // The number of days until the next key rotation. @@ -268,52 +222,6 @@ func (r accessKeyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessKeyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessKeyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessKeyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AccessKeyGetResponseEnvelopeErrors] -type accessKeyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessKeyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessKeyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessKeyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessKeyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessKeyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessKeyGetResponseEnvelopeMessages] -type accessKeyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessKeyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessKeyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessKeyGetResponseEnvelopeSuccess bool @@ -330,9 +238,9 @@ func (r AccessKeyGetResponseEnvelopeSuccess) IsKnown() bool { } type AccessKeyRotateResponseEnvelope struct { - Errors []AccessKeyRotateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessKeyRotateResponseEnvelopeMessages `json:"messages,required"` - Result AccessKeyRotateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessKeyRotateResponseUnion `json:"result,required"` // Whether the API call was successful Success AccessKeyRotateResponseEnvelopeSuccess `json:"success,required"` // The number of days until the next key rotation. @@ -366,52 +274,6 @@ func (r accessKeyRotateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessKeyRotateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessKeyRotateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessKeyRotateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessKeyRotateResponseEnvelopeErrors] -type accessKeyRotateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessKeyRotateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessKeyRotateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessKeyRotateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessKeyRotateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessKeyRotateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessKeyRotateResponseEnvelopeMessages] -type accessKeyRotateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessKeyRotateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessKeyRotateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessKeyRotateResponseEnvelopeSuccess bool diff --git a/zero_trust/accesslogaccessrequest.go b/zero_trust/accesslogaccessrequest.go index 6740cc2baf1..8441e77005f 100644 --- a/zero_trust/accesslogaccessrequest.go +++ b/zero_trust/accesslogaccessrequest.go @@ -10,6 +10,7 @@ import ( "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" ) @@ -32,7 +33,7 @@ func NewAccessLogAccessRequestService(opts ...option.RequestOption) (r *AccessLo } // Gets a list of Access authentication audit logs for an account. -func (r *AccessLogAccessRequestService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]ZeroTrustAccessRequests, err error) { +func (r *AccessLogAccessRequestService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]AccessRequests, err error) { opts = append(r.Options[:], opts...) var env AccessLogAccessRequestListResponseEnvelope path := fmt.Sprintf("accounts/%s/access/logs/access_requests", identifier) @@ -44,7 +45,7 @@ func (r *AccessLogAccessRequestService) List(ctx context.Context, identifier str return } -type ZeroTrustAccessRequests struct { +type AccessRequests struct { // The event that occurred, such as a login attempt. Action string `json:"action"` // The result of the authentication event. @@ -52,7 +53,7 @@ type ZeroTrustAccessRequests struct { // The URL of the Access application. AppDomain string `json:"app_domain"` // The unique identifier for the Access application. - AppUid string `json:"app_uid"` + AppUID string `json:"app_uid"` // The IdP used to authenticate. Connection string `json:"connection"` CreatedAt time.Time `json:"created_at" format:"date-time"` @@ -61,17 +62,16 @@ type ZeroTrustAccessRequests struct { // The unique identifier for the request to Cloudflare. RayID string `json:"ray_id"` // The email address of the authenticating user. - UserEmail string `json:"user_email" format:"email"` - JSON zeroTrustAccessRequestsJSON `json:"-"` + UserEmail string `json:"user_email" format:"email"` + JSON accessRequestsJSON `json:"-"` } -// zeroTrustAccessRequestsJSON contains the JSON metadata for the struct -// [ZeroTrustAccessRequests] -type zeroTrustAccessRequestsJSON struct { +// accessRequestsJSON contains the JSON metadata for the struct [AccessRequests] +type accessRequestsJSON struct { Action apijson.Field Allowed apijson.Field AppDomain apijson.Field - AppUid apijson.Field + AppUID apijson.Field Connection apijson.Field CreatedAt apijson.Field IPAddress apijson.Field @@ -81,18 +81,18 @@ type zeroTrustAccessRequestsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAccessRequests) UnmarshalJSON(data []byte) (err error) { +func (r *AccessRequests) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAccessRequestsJSON) RawJSON() string { +func (r accessRequestsJSON) RawJSON() string { return r.raw } type AccessLogAccessRequestListResponseEnvelope struct { - Errors []AccessLogAccessRequestListResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessLogAccessRequestListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessRequests `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []AccessRequests `json:"result,required,nullable"` // Whether the API call was successful Success AccessLogAccessRequestListResponseEnvelopeSuccess `json:"success,required"` ResultInfo AccessLogAccessRequestListResponseEnvelopeResultInfo `json:"result_info"` @@ -119,52 +119,6 @@ func (r accessLogAccessRequestListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessLogAccessRequestListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessLogAccessRequestListResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessLogAccessRequestListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessLogAccessRequestListResponseEnvelopeErrors] -type accessLogAccessRequestListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessLogAccessRequestListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessLogAccessRequestListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessLogAccessRequestListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessLogAccessRequestListResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessLogAccessRequestListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessLogAccessRequestListResponseEnvelopeMessages] -type accessLogAccessRequestListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessLogAccessRequestListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessLogAccessRequestListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessLogAccessRequestListResponseEnvelopeSuccess bool diff --git a/zero_trust/accessservicetoken.go b/zero_trust/accessservicetoken.go index a337ccd925d..edb33d0f945 100644 --- a/zero_trust/accessservicetoken.go +++ b/zero_trust/accessservicetoken.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -58,7 +59,7 @@ func (r *AccessServiceTokenService) New(ctx context.Context, params AccessServic } // Updates a configured service token. -func (r *AccessServiceTokenService) Update(ctx context.Context, uuid string, params AccessServiceTokenUpdateParams, opts ...option.RequestOption) (res *ZeroTrustServiceTokens, err error) { +func (r *AccessServiceTokenService) Update(ctx context.Context, uuid string, params AccessServiceTokenUpdateParams, opts ...option.RequestOption) (res *ServiceToken, err error) { opts = append(r.Options[:], opts...) var env AccessServiceTokenUpdateResponseEnvelope var accountOrZone string @@ -80,7 +81,7 @@ func (r *AccessServiceTokenService) Update(ctx context.Context, uuid string, par } // Lists all service tokens. -func (r *AccessServiceTokenService) List(ctx context.Context, query AccessServiceTokenListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustServiceTokens], err error) { +func (r *AccessServiceTokenService) List(ctx context.Context, query AccessServiceTokenListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ServiceToken], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -107,12 +108,12 @@ func (r *AccessServiceTokenService) List(ctx context.Context, query AccessServic } // Lists all service tokens. -func (r *AccessServiceTokenService) ListAutoPaging(ctx context.Context, query AccessServiceTokenListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustServiceTokens] { +func (r *AccessServiceTokenService) ListAutoPaging(ctx context.Context, query AccessServiceTokenListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ServiceToken] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a service token. -func (r *AccessServiceTokenService) Delete(ctx context.Context, uuid string, body AccessServiceTokenDeleteParams, opts ...option.RequestOption) (res *ZeroTrustServiceTokens, err error) { +func (r *AccessServiceTokenService) Delete(ctx context.Context, uuid string, body AccessServiceTokenDeleteParams, opts ...option.RequestOption) (res *ServiceToken, err error) { opts = append(r.Options[:], opts...) var env AccessServiceTokenDeleteResponseEnvelope var accountOrZone string @@ -134,7 +135,7 @@ func (r *AccessServiceTokenService) Delete(ctx context.Context, uuid string, bod } // Refreshes the expiration of a service token. -func (r *AccessServiceTokenService) Refresh(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustServiceTokens, err error) { +func (r *AccessServiceTokenService) Refresh(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ServiceToken, err error) { opts = append(r.Options[:], opts...) var env AccessServiceTokenRefreshResponseEnvelope path := fmt.Sprintf("accounts/%s/access/service_tokens/%s/refresh", identifier, uuid) @@ -159,7 +160,7 @@ func (r *AccessServiceTokenService) Rotate(ctx context.Context, identifier strin return } -type ZeroTrustServiceTokens struct { +type ServiceToken struct { // The ID of the service token. ID interface{} `json:"id"` // The Client ID for the service token. Access will check for this value in the @@ -171,14 +172,13 @@ type ZeroTrustServiceTokens struct { // default is 1 year in hours (8760h). Duration string `json:"duration"` // The name of the service token. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustServiceTokensJSON `json:"-"` + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON serviceTokenJSON `json:"-"` } -// zeroTrustServiceTokensJSON contains the JSON metadata for the struct -// [ZeroTrustServiceTokens] -type zeroTrustServiceTokensJSON struct { +// serviceTokenJSON contains the JSON metadata for the struct [ServiceToken] +type serviceTokenJSON struct { ID apijson.Field ClientID apijson.Field CreatedAt apijson.Field @@ -189,11 +189,11 @@ type zeroTrustServiceTokensJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustServiceTokens) UnmarshalJSON(data []byte) (err error) { +func (r *ServiceToken) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustServiceTokensJSON) RawJSON() string { +func (r serviceTokenJSON) RawJSON() string { return r.raw } @@ -299,9 +299,9 @@ func (r AccessServiceTokenNewParams) MarshalJSON() (data []byte, err error) { } type AccessServiceTokenNewResponseEnvelope struct { - Errors []AccessServiceTokenNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessServiceTokenNewResponseEnvelopeMessages `json:"messages,required"` - Result AccessServiceTokenNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessServiceTokenNewResponse `json:"result,required"` // Whether the API call was successful Success AccessServiceTokenNewResponseEnvelopeSuccess `json:"success,required"` JSON accessServiceTokenNewResponseEnvelopeJSON `json:"-"` @@ -326,52 +326,6 @@ func (r accessServiceTokenNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessServiceTokenNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessServiceTokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AccessServiceTokenNewResponseEnvelopeErrors] -type accessServiceTokenNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessServiceTokenNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessServiceTokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccessServiceTokenNewResponseEnvelopeMessages] -type accessServiceTokenNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessServiceTokenNewResponseEnvelopeSuccess bool @@ -405,9 +359,9 @@ func (r AccessServiceTokenUpdateParams) MarshalJSON() (data []byte, err error) { } type AccessServiceTokenUpdateResponseEnvelope struct { - Errors []AccessServiceTokenUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessServiceTokenUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustServiceTokens `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ServiceToken `json:"result,required"` // Whether the API call was successful Success AccessServiceTokenUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessServiceTokenUpdateResponseEnvelopeJSON `json:"-"` @@ -432,52 +386,6 @@ func (r accessServiceTokenUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessServiceTokenUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessServiceTokenUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessServiceTokenUpdateResponseEnvelopeErrors] -type accessServiceTokenUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessServiceTokenUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessServiceTokenUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessServiceTokenUpdateResponseEnvelopeMessages] -type accessServiceTokenUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessServiceTokenUpdateResponseEnvelopeSuccess bool @@ -508,9 +416,9 @@ type AccessServiceTokenDeleteParams struct { } type AccessServiceTokenDeleteResponseEnvelope struct { - Errors []AccessServiceTokenDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessServiceTokenDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustServiceTokens `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ServiceToken `json:"result,required"` // Whether the API call was successful Success AccessServiceTokenDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessServiceTokenDeleteResponseEnvelopeJSON `json:"-"` @@ -535,52 +443,6 @@ func (r accessServiceTokenDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessServiceTokenDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessServiceTokenDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessServiceTokenDeleteResponseEnvelopeErrors] -type accessServiceTokenDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessServiceTokenDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessServiceTokenDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessServiceTokenDeleteResponseEnvelopeMessages] -type accessServiceTokenDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessServiceTokenDeleteResponseEnvelopeSuccess bool @@ -597,9 +459,9 @@ func (r AccessServiceTokenDeleteResponseEnvelopeSuccess) IsKnown() bool { } type AccessServiceTokenRefreshResponseEnvelope struct { - Errors []AccessServiceTokenRefreshResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessServiceTokenRefreshResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustServiceTokens `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ServiceToken `json:"result,required"` // Whether the API call was successful Success AccessServiceTokenRefreshResponseEnvelopeSuccess `json:"success,required"` JSON accessServiceTokenRefreshResponseEnvelopeJSON `json:"-"` @@ -624,52 +486,6 @@ func (r accessServiceTokenRefreshResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessServiceTokenRefreshResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenRefreshResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessServiceTokenRefreshResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessServiceTokenRefreshResponseEnvelopeErrors] -type accessServiceTokenRefreshResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenRefreshResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenRefreshResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessServiceTokenRefreshResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenRefreshResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessServiceTokenRefreshResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessServiceTokenRefreshResponseEnvelopeMessages] -type accessServiceTokenRefreshResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenRefreshResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenRefreshResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessServiceTokenRefreshResponseEnvelopeSuccess bool @@ -686,9 +502,9 @@ func (r AccessServiceTokenRefreshResponseEnvelopeSuccess) IsKnown() bool { } type AccessServiceTokenRotateResponseEnvelope struct { - Errors []AccessServiceTokenRotateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessServiceTokenRotateResponseEnvelopeMessages `json:"messages,required"` - Result AccessServiceTokenRotateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessServiceTokenRotateResponse `json:"result,required"` // Whether the API call was successful Success AccessServiceTokenRotateResponseEnvelopeSuccess `json:"success,required"` JSON accessServiceTokenRotateResponseEnvelopeJSON `json:"-"` @@ -713,52 +529,6 @@ func (r accessServiceTokenRotateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessServiceTokenRotateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenRotateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessServiceTokenRotateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessServiceTokenRotateResponseEnvelopeErrors] -type accessServiceTokenRotateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenRotateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenRotateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessServiceTokenRotateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessServiceTokenRotateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessServiceTokenRotateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AccessServiceTokenRotateResponseEnvelopeMessages] -type accessServiceTokenRotateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessServiceTokenRotateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessServiceTokenRotateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessServiceTokenRotateResponseEnvelopeSuccess bool diff --git a/zero_trust/accesstag.go b/zero_trust/accesstag.go index f185de05dc2..7b0bbb5566e 100644 --- a/zero_trust/accesstag.go +++ b/zero_trust/accesstag.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -33,7 +34,7 @@ func NewAccessTagService(opts ...option.RequestOption) (r *AccessTagService) { } // Create a tag -func (r *AccessTagService) New(ctx context.Context, identifier string, body AccessTagNewParams, opts ...option.RequestOption) (res *ZeroTrustTag, err error) { +func (r *AccessTagService) New(ctx context.Context, identifier string, body AccessTagNewParams, opts ...option.RequestOption) (res *Tag, err error) { opts = append(r.Options[:], opts...) var env AccessTagNewResponseEnvelope path := fmt.Sprintf("accounts/%s/access/tags", identifier) @@ -46,7 +47,7 @@ func (r *AccessTagService) New(ctx context.Context, identifier string, body Acce } // Update a tag -func (r *AccessTagService) Update(ctx context.Context, identifier string, tagName string, body AccessTagUpdateParams, opts ...option.RequestOption) (res *ZeroTrustTag, err error) { +func (r *AccessTagService) Update(ctx context.Context, identifier string, tagName string, body AccessTagUpdateParams, opts ...option.RequestOption) (res *Tag, err error) { opts = append(r.Options[:], opts...) var env AccessTagUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, tagName) @@ -59,7 +60,7 @@ func (r *AccessTagService) Update(ctx context.Context, identifier string, tagNam } // List tags -func (r *AccessTagService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustTag], err error) { +func (r *AccessTagService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[Tag], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -77,7 +78,7 @@ func (r *AccessTagService) List(ctx context.Context, identifier string, opts ... } // List tags -func (r *AccessTagService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustTag] { +func (r *AccessTagService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Tag] { return pagination.NewSinglePageAutoPager(r.List(ctx, identifier, opts...)) } @@ -95,7 +96,7 @@ func (r *AccessTagService) Delete(ctx context.Context, identifier string, name s } // Get a tag -func (r *AccessTagService) Get(ctx context.Context, identifier string, name string, opts ...option.RequestOption) (res *ZeroTrustTag, err error) { +func (r *AccessTagService) Get(ctx context.Context, identifier string, name string, opts ...option.RequestOption) (res *Tag, err error) { opts = append(r.Options[:], opts...) var env AccessTagGetResponseEnvelope path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, name) @@ -108,18 +109,18 @@ func (r *AccessTagService) Get(ctx context.Context, identifier string, name stri } // A tag -type ZeroTrustTag struct { +type Tag struct { // The name of the tag Name string `json:"name,required"` // The number of applications that have this tag - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustTagJSON `json:"-"` + AppCount int64 `json:"app_count"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON tagJSON `json:"-"` } -// zeroTrustTagJSON contains the JSON metadata for the struct [ZeroTrustTag] -type zeroTrustTagJSON struct { +// tagJSON contains the JSON metadata for the struct [Tag] +type tagJSON struct { Name apijson.Field AppCount apijson.Field CreatedAt apijson.Field @@ -128,11 +129,11 @@ type zeroTrustTagJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustTag) UnmarshalJSON(data []byte) (err error) { +func (r *Tag) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustTagJSON) RawJSON() string { +func (r tagJSON) RawJSON() string { return r.raw } @@ -168,10 +169,10 @@ func (r AccessTagNewParams) MarshalJSON() (data []byte, err error) { } type AccessTagNewResponseEnvelope struct { - Errors []AccessTagNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessTagNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A tag - Result ZeroTrustTag `json:"result,required"` + Result Tag `json:"result,required"` // Whether the API call was successful Success AccessTagNewResponseEnvelopeSuccess `json:"success,required"` JSON accessTagNewResponseEnvelopeJSON `json:"-"` @@ -196,52 +197,6 @@ func (r accessTagNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessTagNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessTagNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AccessTagNewResponseEnvelopeErrors] -type accessTagNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessTagNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessTagNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessTagNewResponseEnvelopeMessages] -type accessTagNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessTagNewResponseEnvelopeSuccess bool @@ -267,10 +222,10 @@ func (r AccessTagUpdateParams) MarshalJSON() (data []byte, err error) { } type AccessTagUpdateResponseEnvelope struct { - Errors []AccessTagUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessTagUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A tag - Result ZeroTrustTag `json:"result,required"` + Result Tag `json:"result,required"` // Whether the API call was successful Success AccessTagUpdateResponseEnvelopeSuccess `json:"success,required"` JSON accessTagUpdateResponseEnvelopeJSON `json:"-"` @@ -295,52 +250,6 @@ func (r accessTagUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessTagUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessTagUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessTagUpdateResponseEnvelopeErrors] -type accessTagUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessTagUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessTagUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessTagUpdateResponseEnvelopeMessages] -type accessTagUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessTagUpdateResponseEnvelopeSuccess bool @@ -357,9 +266,9 @@ func (r AccessTagUpdateResponseEnvelopeSuccess) IsKnown() bool { } type AccessTagDeleteResponseEnvelope struct { - Errors []AccessTagDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessTagDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccessTagDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessTagDeleteResponse `json:"result,required"` // Whether the API call was successful Success AccessTagDeleteResponseEnvelopeSuccess `json:"success,required"` JSON accessTagDeleteResponseEnvelopeJSON `json:"-"` @@ -384,52 +293,6 @@ func (r accessTagDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessTagDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessTagDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccessTagDeleteResponseEnvelopeErrors] -type accessTagDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessTagDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessTagDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessTagDeleteResponseEnvelopeMessages] -type accessTagDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessTagDeleteResponseEnvelopeSuccess bool @@ -446,10 +309,10 @@ func (r AccessTagDeleteResponseEnvelopeSuccess) IsKnown() bool { } type AccessTagGetResponseEnvelope struct { - Errors []AccessTagGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessTagGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A tag - Result ZeroTrustTag `json:"result,required"` + Result Tag `json:"result,required"` // Whether the API call was successful Success AccessTagGetResponseEnvelopeSuccess `json:"success,required"` JSON accessTagGetResponseEnvelopeJSON `json:"-"` @@ -474,52 +337,6 @@ func (r accessTagGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessTagGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessTagGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [AccessTagGetResponseEnvelopeErrors] -type accessTagGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessTagGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessTagGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessTagGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccessTagGetResponseEnvelopeMessages] -type accessTagGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessTagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessTagGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessTagGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accessuser.go b/zero_trust/accessuser.go index c56e48ebf46..dbc0bcb1235 100644 --- a/zero_trust/accessuser.go +++ b/zero_trust/accessuser.go @@ -38,7 +38,7 @@ func NewAccessUserService(opts ...option.RequestOption) (r *AccessUserService) { } // Gets a list of users for an account. -func (r *AccessUserService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustUsers], err error) { +func (r *AccessUserService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *pagination.SinglePage[AccessUser], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -56,11 +56,11 @@ func (r *AccessUserService) List(ctx context.Context, identifier string, opts .. } // Gets a list of users for an account. -func (r *AccessUserService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustUsers] { +func (r *AccessUserService) ListAutoPaging(ctx context.Context, identifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AccessUser] { return pagination.NewSinglePageAutoPager(r.List(ctx, identifier, opts...)) } -type ZeroTrustUsers struct { +type AccessUser struct { // UUID ID string `json:"id"` // True if the user has authenticated with Cloudflare Access. @@ -77,15 +77,15 @@ type ZeroTrustUsers struct { // The name of the user. Name string `json:"name"` // The unique API identifier for the Zero Trust seat. - SeatUid string `json:"seat_uid"` + SeatUID string `json:"seat_uid"` // The unique API identifier for the user. - Uid string `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustUsersJSON `json:"-"` + UID string `json:"uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessUserJSON `json:"-"` } -// zeroTrustUsersJSON contains the JSON metadata for the struct [ZeroTrustUsers] -type zeroTrustUsersJSON struct { +// accessUserJSON contains the JSON metadata for the struct [AccessUser] +type accessUserJSON struct { ID apijson.Field AccessSeat apijson.Field ActiveDeviceCount apijson.Field @@ -94,17 +94,17 @@ type zeroTrustUsersJSON struct { GatewaySeat apijson.Field LastSuccessfulLogin apijson.Field Name apijson.Field - SeatUid apijson.Field - Uid apijson.Field + SeatUID apijson.Field + UID apijson.Field UpdatedAt apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustUsers) UnmarshalJSON(data []byte) (err error) { +func (r *AccessUser) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustUsersJSON) RawJSON() string { +func (r accessUserJSON) RawJSON() string { return r.raw } diff --git a/zero_trust/accessuseractivesession.go b/zero_trust/accessuseractivesession.go index 2726d7ebf63..91ca68e0250 100644 --- a/zero_trust/accessuseractivesession.go +++ b/zero_trust/accessuseractivesession.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -125,7 +126,7 @@ type AccessUserActiveSessionListResponseMetadataApp struct { Hostname string `json:"hostname"` Name string `json:"name"` Type string `json:"type"` - Uid string `json:"uid"` + UID string `json:"uid"` JSON accessUserActiveSessionListResponseMetadataAppJSON `json:"-"` } @@ -135,7 +136,7 @@ type accessUserActiveSessionListResponseMetadataAppJSON struct { Hostname apijson.Field Name apijson.Field Type apijson.Field - Uid apijson.Field + UID apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -156,7 +157,7 @@ type AccessUserActiveSessionGetResponse struct { DeviceSessions map[string]AccessUserActiveSessionGetResponseDeviceSession `json:"device_sessions"` DevicePosture map[string]AccessUserActiveSessionGetResponseDevicePosture `json:"devicePosture"` Email string `json:"email"` - Geo AccessUserActiveSessionGetResponseGeo `json:"geo"` + Geo UserPolicyCheckGeo `json:"geo"` Iat float64 `json:"iat"` IDP AccessUserActiveSessionGetResponseIDP `json:"idp"` IP string `json:"ip"` @@ -286,27 +287,6 @@ func (r accessUserActiveSessionGetResponseDevicePostureCheckJSON) RawJSON() stri return r.raw } -type AccessUserActiveSessionGetResponseGeo struct { - Country string `json:"country"` - JSON accessUserActiveSessionGetResponseGeoJSON `json:"-"` -} - -// accessUserActiveSessionGetResponseGeoJSON contains the JSON metadata for the -// struct [AccessUserActiveSessionGetResponseGeo] -type accessUserActiveSessionGetResponseGeoJSON struct { - Country apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessUserActiveSessionGetResponseGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessUserActiveSessionGetResponseGeoJSON) RawJSON() string { - return r.raw -} - type AccessUserActiveSessionGetResponseIDP struct { ID string `json:"id"` Type string `json:"type"` @@ -360,9 +340,9 @@ func (r accessUserActiveSessionGetResponseMTLSAuthJSON) RawJSON() string { } type AccessUserActiveSessionGetResponseEnvelope struct { - Errors []AccessUserActiveSessionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessUserActiveSessionGetResponseEnvelopeMessages `json:"messages,required"` - Result AccessUserActiveSessionGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result AccessUserActiveSessionGetResponse `json:"result,required"` // Whether the API call was successful Success AccessUserActiveSessionGetResponseEnvelopeSuccess `json:"success,required"` JSON accessUserActiveSessionGetResponseEnvelopeJSON `json:"-"` @@ -387,52 +367,6 @@ func (r accessUserActiveSessionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessUserActiveSessionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessUserActiveSessionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessUserActiveSessionGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AccessUserActiveSessionGetResponseEnvelopeErrors] -type accessUserActiveSessionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessUserActiveSessionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessUserActiveSessionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessUserActiveSessionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessUserActiveSessionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessUserActiveSessionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessUserActiveSessionGetResponseEnvelopeMessages] -type accessUserActiveSessionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessUserActiveSessionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessUserActiveSessionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessUserActiveSessionGetResponseEnvelopeSuccess bool diff --git a/zero_trust/accessuserlastseenidentity.go b/zero_trust/accessuserlastseenidentity.go index 9033e5cc4b7..4949df6c6b4 100644 --- a/zero_trust/accessuserlastseenidentity.go +++ b/zero_trust/accessuserlastseenidentity.go @@ -9,6 +9,7 @@ import ( "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" ) @@ -31,7 +32,7 @@ func NewAccessUserLastSeenIdentityService(opts ...option.RequestOption) (r *Acce } // Get last seen identity for a single user. -func (r *AccessUserLastSeenIdentityService) Get(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *ZeroTrustIdentity, err error) { +func (r *AccessUserLastSeenIdentityService) Get(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *Identity, err error) { opts = append(r.Options[:], opts...) var env AccessUserLastSeenIdentityGetResponseEnvelope path := fmt.Sprintf("accounts/%s/access/users/%s/last_seen_identity", identifier, id) @@ -43,31 +44,30 @@ func (r *AccessUserLastSeenIdentityService) Get(ctx context.Context, identifier return } -type ZeroTrustIdentity struct { - AccountID string `json:"account_id"` - AuthStatus string `json:"auth_status"` - CommonName string `json:"common_name"` - DeviceID string `json:"device_id"` - DeviceSessions map[string]ZeroTrustIdentityDeviceSession `json:"device_sessions"` - DevicePosture map[string]ZeroTrustIdentityDevicePosture `json:"devicePosture"` - Email string `json:"email"` - Geo ZeroTrustIdentityGeo `json:"geo"` - Iat float64 `json:"iat"` - IDP ZeroTrustIdentityIDP `json:"idp"` - IP string `json:"ip"` - IsGateway bool `json:"is_gateway"` - IsWARP bool `json:"is_warp"` - MTLSAuth ZeroTrustIdentityMTLSAuth `json:"mtls_auth"` - ServiceTokenID string `json:"service_token_id"` - ServiceTokenStatus bool `json:"service_token_status"` - UserUUID string `json:"user_uuid"` - Version float64 `json:"version"` - JSON zeroTrustIdentityJSON `json:"-"` -} - -// zeroTrustIdentityJSON contains the JSON metadata for the struct -// [ZeroTrustIdentity] -type zeroTrustIdentityJSON struct { +type Identity struct { + AccountID string `json:"account_id"` + AuthStatus string `json:"auth_status"` + CommonName string `json:"common_name"` + DeviceID string `json:"device_id"` + DeviceSessions map[string]IdentityDeviceSession `json:"device_sessions"` + DevicePosture map[string]IdentityDevicePosture `json:"devicePosture"` + Email string `json:"email"` + Geo UserPolicyCheckGeo `json:"geo"` + Iat float64 `json:"iat"` + IDP IdentityIDP `json:"idp"` + IP string `json:"ip"` + IsGateway bool `json:"is_gateway"` + IsWARP bool `json:"is_warp"` + MTLSAuth IdentityMTLSAuth `json:"mtls_auth"` + ServiceTokenID string `json:"service_token_id"` + ServiceTokenStatus bool `json:"service_token_status"` + UserUUID string `json:"user_uuid"` + Version float64 `json:"version"` + JSON identityJSON `json:"-"` +} + +// identityJSON contains the JSON metadata for the struct [Identity] +type identityJSON struct { AccountID apijson.Field AuthStatus apijson.Field CommonName apijson.Field @@ -90,51 +90,51 @@ type zeroTrustIdentityJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentity) UnmarshalJSON(data []byte) (err error) { +func (r *Identity) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityJSON) RawJSON() string { +func (r identityJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityDeviceSession struct { - LastAuthenticated float64 `json:"last_authenticated"` - JSON zeroTrustIdentityDeviceSessionJSON `json:"-"` +type IdentityDeviceSession struct { + LastAuthenticated float64 `json:"last_authenticated"` + JSON identityDeviceSessionJSON `json:"-"` } -// zeroTrustIdentityDeviceSessionJSON contains the JSON metadata for the struct -// [ZeroTrustIdentityDeviceSession] -type zeroTrustIdentityDeviceSessionJSON struct { +// identityDeviceSessionJSON contains the JSON metadata for the struct +// [IdentityDeviceSession] +type identityDeviceSessionJSON struct { LastAuthenticated apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityDeviceSession) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityDeviceSession) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityDeviceSessionJSON) RawJSON() string { +func (r identityDeviceSessionJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityDevicePosture struct { - ID string `json:"id"` - Check ZeroTrustIdentityDevicePostureCheck `json:"check"` - Data interface{} `json:"data"` - Description string `json:"description"` - Error string `json:"error"` - RuleName string `json:"rule_name"` - Success bool `json:"success"` - Timestamp string `json:"timestamp"` - Type string `json:"type"` - JSON zeroTrustIdentityDevicePostureJSON `json:"-"` +type IdentityDevicePosture struct { + ID string `json:"id"` + Check IdentityDevicePostureCheck `json:"check"` + Data interface{} `json:"data"` + Description string `json:"description"` + Error string `json:"error"` + RuleName string `json:"rule_name"` + Success bool `json:"success"` + Timestamp string `json:"timestamp"` + Type string `json:"type"` + JSON identityDevicePostureJSON `json:"-"` } -// zeroTrustIdentityDevicePostureJSON contains the JSON metadata for the struct -// [ZeroTrustIdentityDevicePosture] -type zeroTrustIdentityDevicePostureJSON struct { +// identityDevicePostureJSON contains the JSON metadata for the struct +// [IdentityDevicePosture] +type identityDevicePostureJSON struct { ID apijson.Field Check apijson.Field Data apijson.Field @@ -148,93 +148,71 @@ type zeroTrustIdentityDevicePostureJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityDevicePosture) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityDevicePosture) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityDevicePostureJSON) RawJSON() string { +func (r identityDevicePostureJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityDevicePostureCheck struct { - Exists bool `json:"exists"` - Path string `json:"path"` - JSON zeroTrustIdentityDevicePostureCheckJSON `json:"-"` +type IdentityDevicePostureCheck struct { + Exists bool `json:"exists"` + Path string `json:"path"` + JSON identityDevicePostureCheckJSON `json:"-"` } -// zeroTrustIdentityDevicePostureCheckJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityDevicePostureCheck] -type zeroTrustIdentityDevicePostureCheckJSON struct { +// identityDevicePostureCheckJSON contains the JSON metadata for the struct +// [IdentityDevicePostureCheck] +type identityDevicePostureCheckJSON struct { Exists apijson.Field Path apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityDevicePostureCheck) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityDevicePostureCheck) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityDevicePostureCheckJSON) RawJSON() string { +func (r identityDevicePostureCheckJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityGeo struct { - Country string `json:"country"` - JSON zeroTrustIdentityGeoJSON `json:"-"` +type IdentityIDP struct { + ID string `json:"id"` + Type string `json:"type"` + JSON identityIDPJSON `json:"-"` } -// zeroTrustIdentityGeoJSON contains the JSON metadata for the struct -// [ZeroTrustIdentityGeo] -type zeroTrustIdentityGeoJSON struct { - Country apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityGeoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityIDP struct { - ID string `json:"id"` - Type string `json:"type"` - JSON zeroTrustIdentityIDPJSON `json:"-"` -} - -// zeroTrustIdentityIDPJSON contains the JSON metadata for the struct -// [ZeroTrustIdentityIDP] -type zeroTrustIdentityIDPJSON struct { +// identityIDPJSON contains the JSON metadata for the struct [IdentityIDP] +type identityIDPJSON struct { ID apijson.Field Type apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityIDP) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityIDP) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityIDPJSON) RawJSON() string { +func (r identityIDPJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityMTLSAuth struct { - AuthStatus string `json:"auth_status"` - CERTIssuerDn string `json:"cert_issuer_dn"` - CERTIssuerSki string `json:"cert_issuer_ski"` - CERTPresented bool `json:"cert_presented"` - CERTSerial string `json:"cert_serial"` - JSON zeroTrustIdentityMTLSAuthJSON `json:"-"` +type IdentityMTLSAuth struct { + AuthStatus string `json:"auth_status"` + CERTIssuerDn string `json:"cert_issuer_dn"` + CERTIssuerSki string `json:"cert_issuer_ski"` + CERTPresented bool `json:"cert_presented"` + CERTSerial string `json:"cert_serial"` + JSON identityMTLSAuthJSON `json:"-"` } -// zeroTrustIdentityMTLSAuthJSON contains the JSON metadata for the struct -// [ZeroTrustIdentityMTLSAuth] -type zeroTrustIdentityMTLSAuthJSON struct { +// identityMTLSAuthJSON contains the JSON metadata for the struct +// [IdentityMTLSAuth] +type identityMTLSAuthJSON struct { AuthStatus apijson.Field CERTIssuerDn apijson.Field CERTIssuerSki apijson.Field @@ -244,18 +222,18 @@ type zeroTrustIdentityMTLSAuthJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityMTLSAuth) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityMTLSAuth) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityMTLSAuthJSON) RawJSON() string { +func (r identityMTLSAuthJSON) RawJSON() string { return r.raw } type AccessUserLastSeenIdentityGetResponseEnvelope struct { - Errors []AccessUserLastSeenIdentityGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccessUserLastSeenIdentityGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentity `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Identity `json:"result,required"` // Whether the API call was successful Success AccessUserLastSeenIdentityGetResponseEnvelopeSuccess `json:"success,required"` JSON accessUserLastSeenIdentityGetResponseEnvelopeJSON `json:"-"` @@ -280,52 +258,6 @@ func (r accessUserLastSeenIdentityGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type AccessUserLastSeenIdentityGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AccessUserLastSeenIdentityGetResponseEnvelopeErrors] -type accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessUserLastSeenIdentityGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccessUserLastSeenIdentityGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AccessUserLastSeenIdentityGetResponseEnvelopeMessages] -type accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccessUserLastSeenIdentityGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type AccessUserLastSeenIdentityGetResponseEnvelopeSuccess bool diff --git a/zero_trust/aliases.go b/zero_trust/aliases.go index 7c806a4a161..dbb24fc538b 100644 --- a/zero_trust/aliases.go +++ b/zero_trust/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/zero_trust/connectivitysetting.go b/zero_trust/connectivitysetting.go index 3d29c177aa4..a376a94b5a1 100644 --- a/zero_trust/connectivitysetting.go +++ b/zero_trust/connectivitysetting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -121,9 +122,9 @@ func (r ConnectivitySettingEditParams) MarshalJSON() (data []byte, err error) { } type ConnectivitySettingEditResponseEnvelope struct { - Errors []ConnectivitySettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ConnectivitySettingEditResponseEnvelopeMessages `json:"messages,required"` - Result ConnectivitySettingEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ConnectivitySettingEditResponse `json:"result,required"` // Whether the API call was successful Success ConnectivitySettingEditResponseEnvelopeSuccess `json:"success,required"` JSON connectivitySettingEditResponseEnvelopeJSON `json:"-"` @@ -148,52 +149,6 @@ func (r connectivitySettingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConnectivitySettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON connectivitySettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// connectivitySettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ConnectivitySettingEditResponseEnvelopeErrors] -type connectivitySettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConnectivitySettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r connectivitySettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConnectivitySettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON connectivitySettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// connectivitySettingEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ConnectivitySettingEditResponseEnvelopeMessages] -type connectivitySettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConnectivitySettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r connectivitySettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConnectivitySettingEditResponseEnvelopeSuccess bool @@ -215,9 +170,9 @@ type ConnectivitySettingGetParams struct { } type ConnectivitySettingGetResponseEnvelope struct { - Errors []ConnectivitySettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ConnectivitySettingGetResponseEnvelopeMessages `json:"messages,required"` - Result ConnectivitySettingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ConnectivitySettingGetResponse `json:"result,required"` // Whether the API call was successful Success ConnectivitySettingGetResponseEnvelopeSuccess `json:"success,required"` JSON connectivitySettingGetResponseEnvelopeJSON `json:"-"` @@ -242,52 +197,6 @@ func (r connectivitySettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ConnectivitySettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON connectivitySettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// connectivitySettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ConnectivitySettingGetResponseEnvelopeErrors] -type connectivitySettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConnectivitySettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r connectivitySettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ConnectivitySettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON connectivitySettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// connectivitySettingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ConnectivitySettingGetResponseEnvelopeMessages] -type connectivitySettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ConnectivitySettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r connectivitySettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ConnectivitySettingGetResponseEnvelopeSuccess bool diff --git a/zero_trust/device.go b/zero_trust/device.go index 6c254ac7f31..27a823d0460 100644 --- a/zero_trust/device.go +++ b/zero_trust/device.go @@ -52,7 +52,7 @@ func NewDeviceService(opts ...option.RequestOption) (r *DeviceService) { } // Fetches a list of enrolled devices. -func (r *DeviceService) List(ctx context.Context, query DeviceListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustDevices], err error) { +func (r *DeviceService) List(ctx context.Context, query DeviceListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Device], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -70,12 +70,12 @@ func (r *DeviceService) List(ctx context.Context, query DeviceListParams, opts . } // Fetches a list of enrolled devices. -func (r *DeviceService) ListAutoPaging(ctx context.Context, query DeviceListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustDevices] { +func (r *DeviceService) ListAutoPaging(ctx context.Context, query DeviceListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Device] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Fetches details for a single device. -func (r *DeviceService) Get(ctx context.Context, deviceID string, query DeviceGetParams, opts ...option.RequestOption) (res *DeviceGetResponse, err error) { +func (r *DeviceService) Get(ctx context.Context, deviceID string, query DeviceGetParams, opts ...option.RequestOption) (res *DeviceGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DeviceGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/%s", query.AccountID, deviceID) @@ -87,14 +87,14 @@ func (r *DeviceService) Get(ctx context.Context, deviceID string, query DeviceGe return } -type ZeroTrustDevices struct { +type Device struct { // Device ID. ID string `json:"id"` // When the device was created. Created time.Time `json:"created" format:"date-time"` // True if the device was deleted. - Deleted bool `json:"deleted"` - DeviceType ZeroTrustDevicesDeviceType `json:"device_type"` + Deleted bool `json:"deleted"` + DeviceType DeviceDeviceType `json:"device_type"` // IPv4 or IPv6 address. IP string `json:"ip"` // The device's public key. @@ -122,16 +122,15 @@ type ZeroTrustDevices struct { // The device serial number. SerialNumber string `json:"serial_number"` // When the device was updated. - Updated time.Time `json:"updated" format:"date-time"` - User ZeroTrustDevicesUser `json:"user"` + Updated time.Time `json:"updated" format:"date-time"` + User DeviceUser `json:"user"` // The WARP client version. - Version string `json:"version"` - JSON zeroTrustDevicesJSON `json:"-"` + Version string `json:"version"` + JSON deviceJSON `json:"-"` } -// zeroTrustDevicesJSON contains the JSON metadata for the struct -// [ZeroTrustDevices] -type zeroTrustDevicesJSON struct { +// deviceJSON contains the JSON metadata for the struct [Device] +type deviceJSON struct { ID apijson.Field Created apijson.Field Deleted apijson.Field @@ -156,45 +155,44 @@ type zeroTrustDevicesJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustDevices) UnmarshalJSON(data []byte) (err error) { +func (r *Device) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustDevicesJSON) RawJSON() string { +func (r deviceJSON) RawJSON() string { return r.raw } -type ZeroTrustDevicesDeviceType string +type DeviceDeviceType string const ( - ZeroTrustDevicesDeviceTypeWindows ZeroTrustDevicesDeviceType = "windows" - ZeroTrustDevicesDeviceTypeMac ZeroTrustDevicesDeviceType = "mac" - ZeroTrustDevicesDeviceTypeLinux ZeroTrustDevicesDeviceType = "linux" - ZeroTrustDevicesDeviceTypeAndroid ZeroTrustDevicesDeviceType = "android" - ZeroTrustDevicesDeviceTypeIos ZeroTrustDevicesDeviceType = "ios" + DeviceDeviceTypeWindows DeviceDeviceType = "windows" + DeviceDeviceTypeMac DeviceDeviceType = "mac" + DeviceDeviceTypeLinux DeviceDeviceType = "linux" + DeviceDeviceTypeAndroid DeviceDeviceType = "android" + DeviceDeviceTypeIos DeviceDeviceType = "ios" ) -func (r ZeroTrustDevicesDeviceType) IsKnown() bool { +func (r DeviceDeviceType) IsKnown() bool { switch r { - case ZeroTrustDevicesDeviceTypeWindows, ZeroTrustDevicesDeviceTypeMac, ZeroTrustDevicesDeviceTypeLinux, ZeroTrustDevicesDeviceTypeAndroid, ZeroTrustDevicesDeviceTypeIos: + case DeviceDeviceTypeWindows, DeviceDeviceTypeMac, DeviceDeviceTypeLinux, DeviceDeviceTypeAndroid, DeviceDeviceTypeIos: return true } return false } -type ZeroTrustDevicesUser struct { +type DeviceUser struct { // UUID ID string `json:"id"` // The contact email address of the user. Email string `json:"email"` // The enrolled device user's name. - Name string `json:"name"` - JSON zeroTrustDevicesUserJSON `json:"-"` + Name string `json:"name"` + JSON deviceUserJSON `json:"-"` } -// zeroTrustDevicesUserJSON contains the JSON metadata for the struct -// [ZeroTrustDevicesUser] -type zeroTrustDevicesUserJSON struct { +// deviceUserJSON contains the JSON metadata for the struct [DeviceUser] +type deviceUserJSON struct { ID apijson.Field Email apijson.Field Name apijson.Field @@ -202,23 +200,23 @@ type zeroTrustDevicesUserJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustDevicesUser) UnmarshalJSON(data []byte) (err error) { +func (r *DeviceUser) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustDevicesUserJSON) RawJSON() string { +func (r deviceUserJSON) RawJSON() string { return r.raw } // Union satisfied by [zero_trust.DeviceGetResponseUnknown] or // [shared.UnionString]. -type DeviceGetResponse interface { - ImplementsZeroTrustDeviceGetResponse() +type DeviceGetResponseUnion interface { + ImplementsZeroTrustDeviceGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DeviceGetResponse)(nil)).Elem(), + reflect.TypeOf((*DeviceGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -236,9 +234,9 @@ type DeviceGetParams struct { } type DeviceGetResponseEnvelope struct { - Errors []DeviceGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceGetResponseEnvelopeMessages `json:"messages,required"` - Result DeviceGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceGetResponseUnion `json:"result,required"` // Whether the API call was successful. Success DeviceGetResponseEnvelopeSuccess `json:"success,required"` JSON deviceGetResponseEnvelopeJSON `json:"-"` @@ -263,52 +261,6 @@ func (r deviceGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DeviceGetResponseEnvelopeErrors] -type deviceGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [DeviceGetResponseEnvelopeMessages] -type deviceGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicedextest.go b/zero_trust/devicedextest.go index a0601e39dc7..633b440e34c 100644 --- a/zero_trust/devicedextest.go +++ b/zero_trust/devicedextest.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -33,7 +34,7 @@ func NewDeviceDEXTestService(opts ...option.RequestOption) (r *DeviceDEXTestServ } // Create a DEX test. -func (r *DeviceDEXTestService) New(ctx context.Context, params DeviceDEXTestNewParams, opts ...option.RequestOption) (res *DEXTestSchemasHTTP, err error) { +func (r *DeviceDEXTestService) New(ctx context.Context, params DeviceDEXTestNewParams, opts ...option.RequestOption) (res *SchemaHTTP, err error) { opts = append(r.Options[:], opts...) var env DeviceDEXTestNewResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/dex_tests", params.AccountID) @@ -46,7 +47,7 @@ func (r *DeviceDEXTestService) New(ctx context.Context, params DeviceDEXTestNewP } // Update a DEX test. -func (r *DeviceDEXTestService) Update(ctx context.Context, dexTestID string, params DeviceDEXTestUpdateParams, opts ...option.RequestOption) (res *DEXTestSchemasHTTP, err error) { +func (r *DeviceDEXTestService) Update(ctx context.Context, dexTestID string, params DeviceDEXTestUpdateParams, opts ...option.RequestOption) (res *SchemaHTTP, err error) { opts = append(r.Options[:], opts...) var env DeviceDEXTestUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/dex_tests/%s", params.AccountID, dexTestID) @@ -59,7 +60,7 @@ func (r *DeviceDEXTestService) Update(ctx context.Context, dexTestID string, par } // Fetch all DEX tests. -func (r *DeviceDEXTestService) List(ctx context.Context, query DeviceDEXTestListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DEXTestSchemasHTTP], err error) { +func (r *DeviceDEXTestService) List(ctx context.Context, query DeviceDEXTestListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SchemaHTTP], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -77,13 +78,13 @@ func (r *DeviceDEXTestService) List(ctx context.Context, query DeviceDEXTestList } // Fetch all DEX tests. -func (r *DeviceDEXTestService) ListAutoPaging(ctx context.Context, query DeviceDEXTestListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DEXTestSchemasHTTP] { +func (r *DeviceDEXTestService) ListAutoPaging(ctx context.Context, query DeviceDEXTestListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SchemaHTTP] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete a Device DEX test. Returns the remaining device dex tests for the // account. -func (r *DeviceDEXTestService) Delete(ctx context.Context, dexTestID string, body DeviceDEXTestDeleteParams, opts ...option.RequestOption) (res *[]DEXTestSchemasHTTP, err error) { +func (r *DeviceDEXTestService) Delete(ctx context.Context, dexTestID string, body DeviceDEXTestDeleteParams, opts ...option.RequestOption) (res *[]SchemaHTTP, err error) { opts = append(r.Options[:], opts...) var env DeviceDEXTestDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/dex_tests/%s", body.AccountID, dexTestID) @@ -96,7 +97,7 @@ func (r *DeviceDEXTestService) Delete(ctx context.Context, dexTestID string, bod } // Fetch a single DEX test. -func (r *DeviceDEXTestService) Get(ctx context.Context, dexTestID string, query DeviceDEXTestGetParams, opts ...option.RequestOption) (res *DEXTestSchemasHTTP, err error) { +func (r *DeviceDEXTestService) Get(ctx context.Context, dexTestID string, query DeviceDEXTestGetParams, opts ...option.RequestOption) (res *SchemaHTTP, err error) { opts = append(r.Options[:], opts...) var env DeviceDEXTestGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/dex_tests/%s", query.AccountID, dexTestID) @@ -108,76 +109,121 @@ func (r *DeviceDEXTestService) Get(ctx context.Context, dexTestID string, query return } -type DEXTestSchemasHTTP struct { - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data DEXTestSchemasHTTPData `json:"data,required"` - // Determines whether or not the test is active. - Enabled bool `json:"enabled,required"` - // How often the test will run. - Interval string `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name string `json:"name,required"` - // Additional details about the test. - Description string `json:"description"` - JSON dexTestSchemasHTTPJSON `json:"-"` +// The configuration object which contains the details for the WARP client to +// conduct the test. +type SchemaData struct { + // The desired endpoint to test. + Host string `json:"host"` + // The type of test. + Kind string `json:"kind"` + // The HTTP request method type. + Method string `json:"method"` + JSON schemaDataJSON `json:"-"` } -// dexTestSchemasHTTPJSON contains the JSON metadata for the struct -// [DEXTestSchemasHTTP] -type dexTestSchemasHTTPJSON struct { - Data apijson.Field - Enabled apijson.Field - Interval apijson.Field - Name apijson.Field - Description apijson.Field +// schemaDataJSON contains the JSON metadata for the struct [SchemaData] +type schemaDataJSON struct { + Host apijson.Field + Kind apijson.Field + Method apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DEXTestSchemasHTTP) UnmarshalJSON(data []byte) (err error) { +func (r *SchemaData) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dexTestSchemasHTTPJSON) RawJSON() string { +func (r schemaDataJSON) RawJSON() string { return r.raw } // The configuration object which contains the details for the WARP client to // conduct the test. -type DEXTestSchemasHTTPData struct { +type SchemaDataParam struct { // The desired endpoint to test. - Host string `json:"host"` + Host param.Field[string] `json:"host"` // The type of test. - Kind string `json:"kind"` + Kind param.Field[string] `json:"kind"` // The HTTP request method type. - Method string `json:"method"` - JSON dexTestSchemasHTTPDataJSON `json:"-"` + Method param.Field[string] `json:"method"` } -// dexTestSchemasHTTPDataJSON contains the JSON metadata for the struct -// [DEXTestSchemasHTTPData] -type dexTestSchemasHTTPDataJSON struct { - Host apijson.Field - Kind apijson.Field - Method apijson.Field +func (r SchemaDataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SchemaHTTP struct { + // The configuration object which contains the details for the WARP client to + // conduct the test. + Data SchemaData `json:"data,required"` + // Determines whether or not the test is active. + Enabled bool `json:"enabled,required"` + // How often the test will run. + Interval string `json:"interval,required"` + // The name of the DEX test. Must be unique. + Name string `json:"name,required"` + // Additional details about the test. + Description string `json:"description"` + // Device settings profiles targeted by this test + TargetPolicies []SchemaHTTPTargetPolicy `json:"target_policies"` + Targeted bool `json:"targeted"` + JSON schemaHTTPJSON `json:"-"` +} + +// schemaHTTPJSON contains the JSON metadata for the struct [SchemaHTTP] +type schemaHTTPJSON struct { + Data apijson.Field + Enabled apijson.Field + Interval apijson.Field + Name apijson.Field + Description apijson.Field + TargetPolicies apijson.Field + Targeted apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SchemaHTTP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r schemaHTTPJSON) RawJSON() string { + return r.raw +} + +type SchemaHTTPTargetPolicy struct { + // The id of the device settings profile + ID string `json:"id"` + // Whether the profile is the account default + Default bool `json:"default"` + // The name of the device settings profile + Name string `json:"name"` + JSON schemaHTTPTargetPolicyJSON `json:"-"` +} + +// schemaHTTPTargetPolicyJSON contains the JSON metadata for the struct +// [SchemaHTTPTargetPolicy] +type schemaHTTPTargetPolicyJSON struct { + ID apijson.Field + Default apijson.Field + Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DEXTestSchemasHTTPData) UnmarshalJSON(data []byte) (err error) { +func (r *SchemaHTTPTargetPolicy) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dexTestSchemasHTTPDataJSON) RawJSON() string { +func (r schemaHTTPTargetPolicyJSON) RawJSON() string { return r.raw } -type DeviceDEXTestNewParams struct { - AccountID param.Field[string] `path:"account_id,required"` +type SchemaHTTPParam struct { // The configuration object which contains the details for the WARP client to // conduct the test. - Data param.Field[DeviceDEXTestNewParamsData] `json:"data,required"` + Data param.Field[SchemaDataParam] `json:"data,required"` // Determines whether or not the test is active. Enabled param.Field[bool] `json:"enabled,required"` // How often the test will run. @@ -186,31 +232,41 @@ type DeviceDEXTestNewParams struct { Name param.Field[string] `json:"name,required"` // Additional details about the test. Description param.Field[string] `json:"description"` + // Device settings profiles targeted by this test + TargetPolicies param.Field[[]SchemaHTTPTargetPolicyParam] `json:"target_policies"` + Targeted param.Field[bool] `json:"targeted"` } -func (r DeviceDEXTestNewParams) MarshalJSON() (data []byte, err error) { +func (r SchemaHTTPParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The configuration object which contains the details for the WARP client to -// conduct the test. -type DeviceDEXTestNewParamsData struct { - // The desired endpoint to test. - Host param.Field[string] `json:"host"` - // The type of test. - Kind param.Field[string] `json:"kind"` - // The HTTP request method type. - Method param.Field[string] `json:"method"` +type SchemaHTTPTargetPolicyParam struct { + // The id of the device settings profile + ID param.Field[string] `json:"id"` + // Whether the profile is the account default + Default param.Field[bool] `json:"default"` + // The name of the device settings profile + Name param.Field[string] `json:"name"` } -func (r DeviceDEXTestNewParamsData) MarshalJSON() (data []byte, err error) { +func (r SchemaHTTPTargetPolicyParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +type DeviceDEXTestNewParams struct { + AccountID param.Field[string] `path:"account_id,required"` + SchemaHTTP SchemaHTTPParam `json:"schema_http,required"` +} + +func (r DeviceDEXTestNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.SchemaHTTP) +} + type DeviceDEXTestNewResponseEnvelope struct { - Errors []DeviceDEXTestNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceDEXTestNewResponseEnvelopeMessages `json:"messages,required"` - Result DEXTestSchemasHTTP `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SchemaHTTP `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceDEXTestNewResponseEnvelopeSuccess `json:"success,required"` JSON deviceDEXTestNewResponseEnvelopeJSON `json:"-"` @@ -235,52 +291,6 @@ func (r deviceDEXTestNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceDEXTestNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceDEXTestNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceDEXTestNewResponseEnvelopeErrors] -type deviceDEXTestNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceDEXTestNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceDEXTestNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DeviceDEXTestNewResponseEnvelopeMessages] -type deviceDEXTestNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceDEXTestNewResponseEnvelopeSuccess bool @@ -297,43 +307,18 @@ func (r DeviceDEXTestNewResponseEnvelopeSuccess) IsKnown() bool { } type DeviceDEXTestUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data param.Field[DeviceDEXTestUpdateParamsData] `json:"data,required"` - // Determines whether or not the test is active. - Enabled param.Field[bool] `json:"enabled,required"` - // How often the test will run. - Interval param.Field[string] `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name param.Field[string] `json:"name,required"` - // Additional details about the test. - Description param.Field[string] `json:"description"` + AccountID param.Field[string] `path:"account_id,required"` + SchemaHTTP SchemaHTTPParam `json:"schema_http,required"` } func (r DeviceDEXTestUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type DeviceDEXTestUpdateParamsData struct { - // The desired endpoint to test. - Host param.Field[string] `json:"host"` - // The type of test. - Kind param.Field[string] `json:"kind"` - // The HTTP request method type. - Method param.Field[string] `json:"method"` -} - -func (r DeviceDEXTestUpdateParamsData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.SchemaHTTP) } type DeviceDEXTestUpdateResponseEnvelope struct { - Errors []DeviceDEXTestUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceDEXTestUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DEXTestSchemasHTTP `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SchemaHTTP `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceDEXTestUpdateResponseEnvelopeSuccess `json:"success,required"` JSON deviceDEXTestUpdateResponseEnvelopeJSON `json:"-"` @@ -358,52 +343,6 @@ func (r deviceDEXTestUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceDEXTestUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceDEXTestUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceDEXTestUpdateResponseEnvelopeErrors] -type deviceDEXTestUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceDEXTestUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceDEXTestUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DeviceDEXTestUpdateResponseEnvelopeMessages] -type deviceDEXTestUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceDEXTestUpdateResponseEnvelopeSuccess bool @@ -428,9 +367,9 @@ type DeviceDEXTestDeleteParams struct { } type DeviceDEXTestDeleteResponseEnvelope struct { - Errors []DeviceDEXTestDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceDEXTestDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []DEXTestSchemasHTTP `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SchemaHTTP `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceDEXTestDeleteResponseEnvelopeSuccess `json:"success,required"` JSON deviceDEXTestDeleteResponseEnvelopeJSON `json:"-"` @@ -455,52 +394,6 @@ func (r deviceDEXTestDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceDEXTestDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceDEXTestDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceDEXTestDeleteResponseEnvelopeErrors] -type deviceDEXTestDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceDEXTestDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceDEXTestDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DeviceDEXTestDeleteResponseEnvelopeMessages] -type deviceDEXTestDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceDEXTestDeleteResponseEnvelopeSuccess bool @@ -521,9 +414,9 @@ type DeviceDEXTestGetParams struct { } type DeviceDEXTestGetResponseEnvelope struct { - Errors []DeviceDEXTestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceDEXTestGetResponseEnvelopeMessages `json:"messages,required"` - Result DEXTestSchemasHTTP `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SchemaHTTP `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceDEXTestGetResponseEnvelopeSuccess `json:"success,required"` JSON deviceDEXTestGetResponseEnvelopeJSON `json:"-"` @@ -548,52 +441,6 @@ func (r deviceDEXTestGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceDEXTestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceDEXTestGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceDEXTestGetResponseEnvelopeErrors] -type deviceDEXTestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceDEXTestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceDEXTestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceDEXTestGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DeviceDEXTestGetResponseEnvelopeMessages] -type deviceDEXTestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceDEXTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceDEXTestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceDEXTestGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicedextest_test.go b/zero_trust/devicedextest_test.go index 0829ee44384..dac8acee177 100644 --- a/zero_trust/devicedextest_test.go +++ b/zero_trust/devicedextest_test.go @@ -30,15 +30,31 @@ func TestDeviceDEXTestNewWithOptionalParams(t *testing.T) { ) _, err := client.ZeroTrust.Devices.DEXTests.New(context.TODO(), zero_trust.DeviceDEXTestNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Data: cloudflare.F(zero_trust.DeviceDEXTestNewParamsData{ - Host: cloudflare.F("https://dash.cloudflare.com"), - Kind: cloudflare.F("http"), - Method: cloudflare.F("GET"), - }), - Enabled: cloudflare.F(true), - Interval: cloudflare.F("30m"), - Name: cloudflare.F("HTTP dash health check"), - Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), + SchemaHTTP: zero_trust.SchemaHTTPParam{ + Data: cloudflare.F(zero_trust.SchemaDataParam{ + Host: cloudflare.F("https://dash.cloudflare.com"), + Kind: cloudflare.F("http"), + Method: cloudflare.F("GET"), + }), + Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), + Enabled: cloudflare.F(true), + Interval: cloudflare.F("30m"), + Name: cloudflare.F("HTTP dash health check"), + TargetPolicies: cloudflare.F([]zero_trust.SchemaHTTPTargetPolicyParam{{ + Default: cloudflare.F(true), + ID: cloudflare.F("string"), + Name: cloudflare.F("string"), + }, { + Default: cloudflare.F(true), + ID: cloudflare.F("string"), + Name: cloudflare.F("string"), + }, { + Default: cloudflare.F(true), + ID: cloudflare.F("string"), + Name: cloudflare.F("string"), + }}), + Targeted: cloudflare.F(true), + }, }) if err != nil { var apierr *cloudflare.Error @@ -68,15 +84,31 @@ func TestDeviceDEXTestUpdateWithOptionalParams(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.DeviceDEXTestUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Data: cloudflare.F(zero_trust.DeviceDEXTestUpdateParamsData{ - Host: cloudflare.F("https://dash.cloudflare.com"), - Kind: cloudflare.F("http"), - Method: cloudflare.F("GET"), - }), - Enabled: cloudflare.F(true), - Interval: cloudflare.F("30m"), - Name: cloudflare.F("HTTP dash health check"), - Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), + SchemaHTTP: zero_trust.SchemaHTTPParam{ + Data: cloudflare.F(zero_trust.SchemaDataParam{ + Host: cloudflare.F("https://dash.cloudflare.com"), + Kind: cloudflare.F("http"), + Method: cloudflare.F("GET"), + }), + Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), + Enabled: cloudflare.F(true), + Interval: cloudflare.F("30m"), + Name: cloudflare.F("HTTP dash health check"), + TargetPolicies: cloudflare.F([]zero_trust.SchemaHTTPTargetPolicyParam{{ + Default: cloudflare.F(true), + ID: cloudflare.F("string"), + Name: cloudflare.F("string"), + }, { + Default: cloudflare.F(true), + ID: cloudflare.F("string"), + Name: cloudflare.F("string"), + }, { + Default: cloudflare.F(true), + ID: cloudflare.F("string"), + Name: cloudflare.F("string"), + }}), + Targeted: cloudflare.F(true), + }, }, ) if err != nil { diff --git a/zero_trust/devicenetwork.go b/zero_trust/devicenetwork.go index 9c90aa58340..151d3cdbe80 100644 --- a/zero_trust/devicenetwork.go +++ b/zero_trust/devicenetwork.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -33,7 +34,7 @@ func NewDeviceNetworkService(opts ...option.RequestOption) (r *DeviceNetworkServ } // Creates a new device managed network. -func (r *DeviceNetworkService) New(ctx context.Context, params DeviceNetworkNewParams, opts ...option.RequestOption) (res *DeviceManagedNetworks, err error) { +func (r *DeviceNetworkService) New(ctx context.Context, params DeviceNetworkNewParams, opts ...option.RequestOption) (res *DeviceNetwork, err error) { opts = append(r.Options[:], opts...) var env DeviceNetworkNewResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/networks", params.AccountID) @@ -46,7 +47,7 @@ func (r *DeviceNetworkService) New(ctx context.Context, params DeviceNetworkNewP } // Updates a configured device managed network. -func (r *DeviceNetworkService) Update(ctx context.Context, networkID string, params DeviceNetworkUpdateParams, opts ...option.RequestOption) (res *DeviceManagedNetworks, err error) { +func (r *DeviceNetworkService) Update(ctx context.Context, networkID string, params DeviceNetworkUpdateParams, opts ...option.RequestOption) (res *DeviceNetwork, err error) { opts = append(r.Options[:], opts...) var env DeviceNetworkUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/networks/%s", params.AccountID, networkID) @@ -59,7 +60,7 @@ func (r *DeviceNetworkService) Update(ctx context.Context, networkID string, par } // Fetches a list of managed networks for an account. -func (r *DeviceNetworkService) List(ctx context.Context, query DeviceNetworkListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DeviceManagedNetworks], err error) { +func (r *DeviceNetworkService) List(ctx context.Context, query DeviceNetworkListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DeviceNetwork], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -77,16 +78,16 @@ func (r *DeviceNetworkService) List(ctx context.Context, query DeviceNetworkList } // Fetches a list of managed networks for an account. -func (r *DeviceNetworkService) ListAutoPaging(ctx context.Context, query DeviceNetworkListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DeviceManagedNetworks] { +func (r *DeviceNetworkService) ListAutoPaging(ctx context.Context, query DeviceNetworkListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DeviceNetwork] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a device managed network and fetches a list of the remaining device // managed networks for an account. -func (r *DeviceNetworkService) Delete(ctx context.Context, networkID string, body DeviceNetworkDeleteParams, opts ...option.RequestOption) (res *[]DeviceManagedNetworks, err error) { +func (r *DeviceNetworkService) Delete(ctx context.Context, networkID string, params DeviceNetworkDeleteParams, opts ...option.RequestOption) (res *[]DeviceNetwork, err error) { opts = append(r.Options[:], opts...) var env DeviceNetworkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/devices/networks/%s", body.AccountID, networkID) + path := fmt.Sprintf("accounts/%s/devices/networks/%s", params.AccountID, networkID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -96,7 +97,7 @@ func (r *DeviceNetworkService) Delete(ctx context.Context, networkID string, bod } // Fetches details for a single managed network. -func (r *DeviceNetworkService) Get(ctx context.Context, networkID string, query DeviceNetworkGetParams, opts ...option.RequestOption) (res *DeviceManagedNetworks, err error) { +func (r *DeviceNetworkService) Get(ctx context.Context, networkID string, query DeviceNetworkGetParams, opts ...option.RequestOption) (res *DeviceNetwork, err error) { opts = append(r.Options[:], opts...) var env DeviceNetworkGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/networks/%s", query.AccountID, networkID) @@ -108,22 +109,21 @@ func (r *DeviceNetworkService) Get(ctx context.Context, networkID string, query return } -type DeviceManagedNetworks struct { +type DeviceNetwork struct { // The configuration object containing information for the WARP client to detect // the managed network. - Config DeviceManagedNetworksConfig `json:"config"` + Config DeviceNetworkConfig `json:"config"` // The name of the device managed network. This name must be unique. Name string `json:"name"` // API UUID. NetworkID string `json:"network_id"` // The type of device managed network. - Type DeviceManagedNetworksType `json:"type"` - JSON deviceManagedNetworksJSON `json:"-"` + Type DeviceNetworkType `json:"type"` + JSON deviceNetworkJSON `json:"-"` } -// deviceManagedNetworksJSON contains the JSON metadata for the struct -// [DeviceManagedNetworks] -type deviceManagedNetworksJSON struct { +// deviceNetworkJSON contains the JSON metadata for the struct [DeviceNetwork] +type deviceNetworkJSON struct { Config apijson.Field Name apijson.Field NetworkID apijson.Field @@ -132,54 +132,54 @@ type deviceManagedNetworksJSON struct { ExtraFields map[string]apijson.Field } -func (r *DeviceManagedNetworks) UnmarshalJSON(data []byte) (err error) { +func (r *DeviceNetwork) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r deviceManagedNetworksJSON) RawJSON() string { +func (r deviceNetworkJSON) RawJSON() string { return r.raw } // The configuration object containing information for the WARP client to detect // the managed network. -type DeviceManagedNetworksConfig struct { +type DeviceNetworkConfig struct { // A network address of the form "host:port" that the WARP client will use to // detect the presence of a TLS host. TLSSockaddr string `json:"tls_sockaddr,required"` // The SHA-256 hash of the TLS certificate presented by the host found at // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid // timestamp, etc) will be used to validate the certificate. - Sha256 string `json:"sha256"` - JSON deviceManagedNetworksConfigJSON `json:"-"` + Sha256 string `json:"sha256"` + JSON deviceNetworkConfigJSON `json:"-"` } -// deviceManagedNetworksConfigJSON contains the JSON metadata for the struct -// [DeviceManagedNetworksConfig] -type deviceManagedNetworksConfigJSON struct { +// deviceNetworkConfigJSON contains the JSON metadata for the struct +// [DeviceNetworkConfig] +type deviceNetworkConfigJSON struct { TLSSockaddr apijson.Field Sha256 apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DeviceManagedNetworksConfig) UnmarshalJSON(data []byte) (err error) { +func (r *DeviceNetworkConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r deviceManagedNetworksConfigJSON) RawJSON() string { +func (r deviceNetworkConfigJSON) RawJSON() string { return r.raw } // The type of device managed network. -type DeviceManagedNetworksType string +type DeviceNetworkType string const ( - DeviceManagedNetworksTypeTLS DeviceManagedNetworksType = "tls" + DeviceNetworkTypeTLS DeviceNetworkType = "tls" ) -func (r DeviceManagedNetworksType) IsKnown() bool { +func (r DeviceNetworkType) IsKnown() bool { switch r { - case DeviceManagedNetworksTypeTLS: + case DeviceNetworkTypeTLS: return true } return false @@ -232,9 +232,9 @@ func (r DeviceNetworkNewParamsType) IsKnown() bool { } type DeviceNetworkNewResponseEnvelope struct { - Errors []DeviceNetworkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceNetworkNewResponseEnvelopeMessages `json:"messages,required"` - Result DeviceManagedNetworks `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceNetwork `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceNetworkNewResponseEnvelopeSuccess `json:"success,required"` JSON deviceNetworkNewResponseEnvelopeJSON `json:"-"` @@ -259,52 +259,6 @@ func (r deviceNetworkNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceNetworkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceNetworkNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceNetworkNewResponseEnvelopeErrors] -type deviceNetworkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceNetworkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceNetworkNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DeviceNetworkNewResponseEnvelopeMessages] -type deviceNetworkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceNetworkNewResponseEnvelopeSuccess bool @@ -367,9 +321,9 @@ func (r DeviceNetworkUpdateParamsType) IsKnown() bool { } type DeviceNetworkUpdateResponseEnvelope struct { - Errors []DeviceNetworkUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceNetworkUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DeviceManagedNetworks `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceNetwork `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceNetworkUpdateResponseEnvelopeSuccess `json:"success,required"` JSON deviceNetworkUpdateResponseEnvelopeJSON `json:"-"` @@ -394,52 +348,6 @@ func (r deviceNetworkUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceNetworkUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceNetworkUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceNetworkUpdateResponseEnvelopeErrors] -type deviceNetworkUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceNetworkUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceNetworkUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DeviceNetworkUpdateResponseEnvelopeMessages] -type deviceNetworkUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceNetworkUpdateResponseEnvelopeSuccess bool @@ -461,12 +369,17 @@ type DeviceNetworkListParams struct { type DeviceNetworkDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DeviceNetworkDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DeviceNetworkDeleteResponseEnvelope struct { - Errors []DeviceNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []DeviceManagedNetworks `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []DeviceNetwork `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo DeviceNetworkDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -493,52 +406,6 @@ func (r deviceNetworkDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceNetworkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceNetworkDeleteResponseEnvelopeErrors] -type deviceNetworkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceNetworkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DeviceNetworkDeleteResponseEnvelopeMessages] -type deviceNetworkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceNetworkDeleteResponseEnvelopeSuccess bool @@ -590,9 +457,9 @@ type DeviceNetworkGetParams struct { } type DeviceNetworkGetResponseEnvelope struct { - Errors []DeviceNetworkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceNetworkGetResponseEnvelopeMessages `json:"messages,required"` - Result DeviceManagedNetworks `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceNetwork `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceNetworkGetResponseEnvelopeSuccess `json:"success,required"` JSON deviceNetworkGetResponseEnvelopeJSON `json:"-"` @@ -617,52 +484,6 @@ func (r deviceNetworkGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceNetworkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceNetworkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceNetworkGetResponseEnvelopeErrors] -type deviceNetworkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceNetworkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceNetworkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceNetworkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DeviceNetworkGetResponseEnvelopeMessages] -type deviceNetworkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceNetworkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceNetworkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceNetworkGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicenetwork_test.go b/zero_trust/devicenetwork_test.go index ef5b7f7e10e..f897bd17f7b 100644 --- a/zero_trust/devicenetwork_test.go +++ b/zero_trust/devicenetwork_test.go @@ -127,6 +127,7 @@ func TestDeviceNetworkDelete(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.DeviceNetworkDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/deviceoverridecode.go b/zero_trust/deviceoverridecode.go index ef2a3a06954..ffb1207a666 100644 --- a/zero_trust/deviceoverridecode.go +++ b/zero_trust/deviceoverridecode.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -105,9 +106,9 @@ type DeviceOverrideCodeListParams struct { } type DeviceOverrideCodeListResponseEnvelope struct { - Errors []DeviceOverrideCodeListResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceOverrideCodeListResponseEnvelopeMessages `json:"messages,required"` - Result DeviceOverrideCodeListResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceOverrideCodeListResponse `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceOverrideCodeListResponseEnvelopeSuccess `json:"success,required"` ResultInfo DeviceOverrideCodeListResponseEnvelopeResultInfo `json:"result_info"` @@ -134,52 +135,6 @@ func (r deviceOverrideCodeListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceOverrideCodeListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceOverrideCodeListResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceOverrideCodeListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DeviceOverrideCodeListResponseEnvelopeErrors] -type deviceOverrideCodeListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceOverrideCodeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceOverrideCodeListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceOverrideCodeListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceOverrideCodeListResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceOverrideCodeListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DeviceOverrideCodeListResponseEnvelopeMessages] -type deviceOverrideCodeListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceOverrideCodeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceOverrideCodeListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceOverrideCodeListResponseEnvelopeSuccess bool diff --git a/zero_trust/devicepolicy.go b/zero_trust/devicepolicy.go index 8760004a4c6..f76fcf349a2 100644 --- a/zero_trust/devicepolicy.go +++ b/zero_trust/devicepolicy.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -42,7 +43,7 @@ func NewDevicePolicyService(opts ...option.RequestOption) (r *DevicePolicyServic // Creates a device settings profile to be applied to certain devices matching the // criteria. -func (r *DevicePolicyService) New(ctx context.Context, params DevicePolicyNewParams, opts ...option.RequestOption) (res *DevicesDeviceSettingsPolicy, err error) { +func (r *DevicePolicyService) New(ctx context.Context, params DevicePolicyNewParams, opts ...option.RequestOption) (res *SettingsPolicy, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyNewResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy", params.AccountID) @@ -55,7 +56,7 @@ func (r *DevicePolicyService) New(ctx context.Context, params DevicePolicyNewPar } // Fetches a list of the device settings profiles for an account. -func (r *DevicePolicyService) List(ctx context.Context, query DevicePolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DevicesDeviceSettingsPolicy], err error) { +func (r *DevicePolicyService) List(ctx context.Context, query DevicePolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SettingsPolicy], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -73,16 +74,16 @@ func (r *DevicePolicyService) List(ctx context.Context, query DevicePolicyListPa } // Fetches a list of the device settings profiles for an account. -func (r *DevicePolicyService) ListAutoPaging(ctx context.Context, query DevicePolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DevicesDeviceSettingsPolicy] { +func (r *DevicePolicyService) ListAutoPaging(ctx context.Context, query DevicePolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SettingsPolicy] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a device settings profile and fetches a list of the remaining profiles // for an account. -func (r *DevicePolicyService) Delete(ctx context.Context, policyID string, body DevicePolicyDeleteParams, opts ...option.RequestOption) (res *[]DevicesDeviceSettingsPolicy, err error) { +func (r *DevicePolicyService) Delete(ctx context.Context, policyID string, params DevicePolicyDeleteParams, opts ...option.RequestOption) (res *[]SettingsPolicy, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/devices/policy/%s", body.AccountID, policyID) + path := fmt.Sprintf("accounts/%s/devices/policy/%s", params.AccountID, policyID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -92,7 +93,7 @@ func (r *DevicePolicyService) Delete(ctx context.Context, policyID string, body } // Updates a configured device settings profile. -func (r *DevicePolicyService) Edit(ctx context.Context, policyID string, params DevicePolicyEditParams, opts ...option.RequestOption) (res *DevicesDeviceSettingsPolicy, err error) { +func (r *DevicePolicyService) Edit(ctx context.Context, policyID string, params DevicePolicyEditParams, opts ...option.RequestOption) (res *SettingsPolicy, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyEditResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/%s", params.AccountID, policyID) @@ -105,7 +106,7 @@ func (r *DevicePolicyService) Edit(ctx context.Context, policyID string, params } // Fetches a device settings profile by ID. -func (r *DevicePolicyService) Get(ctx context.Context, policyID string, query DevicePolicyGetParams, opts ...option.RequestOption) (res *DevicesDeviceSettingsPolicy, err error) { +func (r *DevicePolicyService) Get(ctx context.Context, policyID string, query DevicePolicyGetParams, opts ...option.RequestOption) (res *SettingsPolicy, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/%s", query.AccountID, policyID) @@ -117,7 +118,7 @@ func (r *DevicePolicyService) Get(ctx context.Context, policyID string, query De return } -type DevicesDeviceSettingsPolicy struct { +type SettingsPolicy struct { // Whether to allow the user to switch WARP between modes. AllowModeSwitch bool `json:"allow_mode_switch"` // Whether to receive update notifications when a new version of the client is @@ -139,12 +140,12 @@ type DevicesDeviceSettingsPolicy struct { DisableAutoFallback bool `json:"disable_auto_fallback"` // Whether the policy will be applied to matching devices. Enabled bool `json:"enabled"` - Exclude []DevicesSplitTunnel `json:"exclude"` + Exclude []SplitTunnelExclude `json:"exclude"` // Whether to add Microsoft IPs to Split Tunnel exclusions. - ExcludeOfficeIPs bool `json:"exclude_office_ips"` - FallbackDomains []DevicesFallbackDomain `json:"fallback_domains"` - GatewayUniqueID string `json:"gateway_unique_id"` - Include []DevicesSplitTunnelInclude `json:"include"` + ExcludeOfficeIPs bool `json:"exclude_office_ips"` + FallbackDomains []FallbackDomain `json:"fallback_domains"` + GatewayUniqueID string `json:"gateway_unique_id"` + Include []SplitTunnelInclude `json:"include"` // The amount of time in minutes a user is allowed access to their LAN. A value of // 0 will allow LAN access until the next WARP reconnection, such as a reboot or a // laptop waking from sleep. Note that this field is omitted from the response if @@ -161,18 +162,18 @@ type DevicesDeviceSettingsPolicy struct { PolicyID string `json:"policy_id"` // The precedence of the policy. Lower values indicate higher precedence. Policies // will be evaluated in ascending order of this field. - Precedence float64 `json:"precedence"` - ServiceModeV2 DevicesDeviceSettingsPolicyServiceModeV2 `json:"service_mode_v2"` + Precedence float64 `json:"precedence"` + ServiceModeV2 SettingsPolicyServiceModeV2 `json:"service_mode_v2"` // The URL to launch when the Send Feedback button is clicked. SupportURL string `json:"support_url"` // Whether to allow the user to turn off the WARP switch and disconnect the client. - SwitchLocked bool `json:"switch_locked"` - JSON devicesDeviceSettingsPolicyJSON `json:"-"` + SwitchLocked bool `json:"switch_locked"` + TargetTests []SettingsPolicyTargetTest `json:"target_tests"` + JSON settingsPolicyJSON `json:"-"` } -// devicesDeviceSettingsPolicyJSON contains the JSON metadata for the struct -// [DevicesDeviceSettingsPolicy] -type devicesDeviceSettingsPolicyJSON struct { +// settingsPolicyJSON contains the JSON metadata for the struct [SettingsPolicy] +type settingsPolicyJSON struct { AllowModeSwitch apijson.Field AllowUpdates apijson.Field AllowedToLeave apijson.Field @@ -196,40 +197,66 @@ type devicesDeviceSettingsPolicyJSON struct { ServiceModeV2 apijson.Field SupportURL apijson.Field SwitchLocked apijson.Field + TargetTests apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicesDeviceSettingsPolicy) UnmarshalJSON(data []byte) (err error) { +func (r *SettingsPolicy) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicesDeviceSettingsPolicyJSON) RawJSON() string { +func (r settingsPolicyJSON) RawJSON() string { return r.raw } -type DevicesDeviceSettingsPolicyServiceModeV2 struct { +type SettingsPolicyServiceModeV2 struct { // The mode to run the WARP client under. Mode string `json:"mode"` // The port number when used with proxy mode. - Port float64 `json:"port"` - JSON devicesDeviceSettingsPolicyServiceModeV2JSON `json:"-"` + Port float64 `json:"port"` + JSON settingsPolicyServiceModeV2JSON `json:"-"` } -// devicesDeviceSettingsPolicyServiceModeV2JSON contains the JSON metadata for the -// struct [DevicesDeviceSettingsPolicyServiceModeV2] -type devicesDeviceSettingsPolicyServiceModeV2JSON struct { +// settingsPolicyServiceModeV2JSON contains the JSON metadata for the struct +// [SettingsPolicyServiceModeV2] +type settingsPolicyServiceModeV2JSON struct { Mode apijson.Field Port apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicesDeviceSettingsPolicyServiceModeV2) UnmarshalJSON(data []byte) (err error) { +func (r *SettingsPolicyServiceModeV2) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingsPolicyServiceModeV2JSON) RawJSON() string { + return r.raw +} + +type SettingsPolicyTargetTest struct { + // The id of the DEX test targeting this policy + ID string `json:"id"` + // The name of the DEX test targeting this policy + Name string `json:"name"` + JSON settingsPolicyTargetTestJSON `json:"-"` +} + +// settingsPolicyTargetTestJSON contains the JSON metadata for the struct +// [SettingsPolicyTargetTest] +type settingsPolicyTargetTestJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingsPolicyTargetTest) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicesDeviceSettingsPolicyServiceModeV2JSON) RawJSON() string { +func (r settingsPolicyTargetTestJSON) RawJSON() string { return r.raw } @@ -300,9 +327,9 @@ func (r DevicePolicyNewParamsServiceModeV2) MarshalJSON() (data []byte, err erro } type DevicePolicyNewResponseEnvelope struct { - Errors []DevicePolicyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyNewResponseEnvelopeMessages `json:"messages,required"` - Result DevicesDeviceSettingsPolicy `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SettingsPolicy `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyNewResponseEnvelopeResultInfo `json:"result_info"` @@ -329,52 +356,6 @@ func (r devicePolicyNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePolicyNewResponseEnvelopeErrors] -type devicePolicyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DevicePolicyNewResponseEnvelopeMessages] -type devicePolicyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyNewResponseEnvelopeSuccess bool @@ -427,12 +408,17 @@ type DevicePolicyListParams struct { type DevicePolicyDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DevicePolicyDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DevicePolicyDeleteResponseEnvelope struct { - Errors []DevicePolicyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []DevicesDeviceSettingsPolicy `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SettingsPolicy `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyDeleteResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyDeleteResponseEnvelopeResultInfo `json:"result_info"` @@ -459,52 +445,6 @@ func (r devicePolicyDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePolicyDeleteResponseEnvelopeErrors] -type devicePolicyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DevicePolicyDeleteResponseEnvelopeMessages] -type devicePolicyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyDeleteResponseEnvelopeSuccess bool @@ -604,9 +544,9 @@ func (r DevicePolicyEditParamsServiceModeV2) MarshalJSON() (data []byte, err err } type DevicePolicyEditResponseEnvelope struct { - Errors []DevicePolicyEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyEditResponseEnvelopeMessages `json:"messages,required"` - Result DevicesDeviceSettingsPolicy `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SettingsPolicy `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyEditResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyEditResponseEnvelopeResultInfo `json:"result_info"` @@ -633,52 +573,6 @@ func (r devicePolicyEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePolicyEditResponseEnvelopeErrors] -type devicePolicyEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DevicePolicyEditResponseEnvelopeMessages] -type devicePolicyEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyEditResponseEnvelopeSuccess bool @@ -730,9 +624,9 @@ type DevicePolicyGetParams struct { } type DevicePolicyGetResponseEnvelope struct { - Errors []DevicePolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result DevicesDeviceSettingsPolicy `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SettingsPolicy `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyGetResponseEnvelopeResultInfo `json:"result_info"` @@ -759,52 +653,6 @@ func (r devicePolicyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePolicyGetResponseEnvelopeErrors] -type devicePolicyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DevicePolicyGetResponseEnvelopeMessages] -type devicePolicyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicepolicy_test.go b/zero_trust/devicepolicy_test.go index b3e6a6b85f9..bf407178c6d 100644 --- a/zero_trust/devicepolicy_test.go +++ b/zero_trust/devicepolicy_test.go @@ -105,6 +105,7 @@ func TestDevicePolicyDelete(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.DevicePolicyDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/devicepolicydefaultpolicy.go b/zero_trust/devicepolicydefaultpolicy.go index 35ee35e40c4..ff8284d2e44 100644 --- a/zero_trust/devicepolicydefaultpolicy.go +++ b/zero_trust/devicepolicydefaultpolicy.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -51,9 +52,9 @@ type DevicePolicyDefaultPolicyGetParams struct { } type DevicePolicyDefaultPolicyGetResponseEnvelope struct { - Errors []DevicePolicyDefaultPolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyDefaultPolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result []DevicePolicyDefaultPolicyGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []DevicePolicyDefaultPolicyGetResponse `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyDefaultPolicyGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo `json:"result_info"` @@ -80,52 +81,6 @@ func (r devicePolicyDefaultPolicyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyDefaultPolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DevicePolicyDefaultPolicyGetResponseEnvelopeErrors] -type devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyDefaultPolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyDefaultPolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DevicePolicyDefaultPolicyGetResponseEnvelopeMessages] -type devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyDefaultPolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyDefaultPolicyGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicepolicyexclude.go b/zero_trust/devicepolicyexclude.go index 5eea5c3b966..4dd7ce3bce8 100644 --- a/zero_trust/devicepolicyexclude.go +++ b/zero_trust/devicepolicyexclude.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -33,7 +34,7 @@ func NewDevicePolicyExcludeService(opts ...option.RequestOption) (r *DevicePolic } // Sets the list of routes excluded from the WARP client's tunnel. -func (r *DevicePolicyExcludeService) Update(ctx context.Context, params DevicePolicyExcludeUpdateParams, opts ...option.RequestOption) (res *[]DevicesSplitTunnel, err error) { +func (r *DevicePolicyExcludeService) Update(ctx context.Context, params DevicePolicyExcludeUpdateParams, opts ...option.RequestOption) (res *[]SplitTunnelExclude, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyExcludeUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/exclude", params.AccountID) @@ -46,7 +47,7 @@ func (r *DevicePolicyExcludeService) Update(ctx context.Context, params DevicePo } // Fetches the list of routes excluded from the WARP client's tunnel. -func (r *DevicePolicyExcludeService) List(ctx context.Context, query DevicePolicyExcludeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DevicesSplitTunnel], err error) { +func (r *DevicePolicyExcludeService) List(ctx context.Context, query DevicePolicyExcludeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SplitTunnelExclude], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -64,13 +65,13 @@ func (r *DevicePolicyExcludeService) List(ctx context.Context, query DevicePolic } // Fetches the list of routes excluded from the WARP client's tunnel. -func (r *DevicePolicyExcludeService) ListAutoPaging(ctx context.Context, query DevicePolicyExcludeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DevicesSplitTunnel] { +func (r *DevicePolicyExcludeService) ListAutoPaging(ctx context.Context, query DevicePolicyExcludeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SplitTunnelExclude] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Fetches the list of routes excluded from the WARP client's tunnel for a specific // device settings profile. -func (r *DevicePolicyExcludeService) Get(ctx context.Context, policyID string, query DevicePolicyExcludeGetParams, opts ...option.RequestOption) (res *[]DevicesSplitTunnel, err error) { +func (r *DevicePolicyExcludeService) Get(ctx context.Context, policyID string, query DevicePolicyExcludeGetParams, opts ...option.RequestOption) (res *[]SplitTunnelExclude, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyExcludeGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/%s/exclude", query.AccountID, policyID) @@ -82,7 +83,7 @@ func (r *DevicePolicyExcludeService) Get(ctx context.Context, policyID string, q return } -type DevicesSplitTunnel struct { +type SplitTunnelExclude struct { // The address in CIDR format to exclude from the tunnel. If `address` is present, // `host` must not be present. Address string `json:"address,required"` @@ -91,12 +92,12 @@ type DevicesSplitTunnel struct { // The domain name to exclude from the tunnel. If `host` is present, `address` must // not be present. Host string `json:"host"` - JSON devicesSplitTunnelJSON `json:"-"` + JSON splitTunnelExcludeJSON `json:"-"` } -// devicesSplitTunnelJSON contains the JSON metadata for the struct -// [DevicesSplitTunnel] -type devicesSplitTunnelJSON struct { +// splitTunnelExcludeJSON contains the JSON metadata for the struct +// [SplitTunnelExclude] +type splitTunnelExcludeJSON struct { Address apijson.Field Description apijson.Field Host apijson.Field @@ -104,15 +105,15 @@ type devicesSplitTunnelJSON struct { ExtraFields map[string]apijson.Field } -func (r *DevicesSplitTunnel) UnmarshalJSON(data []byte) (err error) { +func (r *SplitTunnelExclude) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicesSplitTunnelJSON) RawJSON() string { +func (r splitTunnelExcludeJSON) RawJSON() string { return r.raw } -type DevicesSplitTunnelParam struct { +type SplitTunnelExcludeParam struct { // The address in CIDR format to exclude from the tunnel. If `address` is present, // `host` must not be present. Address param.Field[string] `json:"address,required"` @@ -123,13 +124,13 @@ type DevicesSplitTunnelParam struct { Host param.Field[string] `json:"host"` } -func (r DevicesSplitTunnelParam) MarshalJSON() (data []byte, err error) { +func (r SplitTunnelExcludeParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type DevicePolicyExcludeUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]DevicesSplitTunnelParam] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body []SplitTunnelExcludeParam `json:"body,required"` } func (r DevicePolicyExcludeUpdateParams) MarshalJSON() (data []byte, err error) { @@ -137,9 +138,9 @@ func (r DevicePolicyExcludeUpdateParams) MarshalJSON() (data []byte, err error) } type DevicePolicyExcludeUpdateResponseEnvelope struct { - Errors []DevicePolicyExcludeUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyExcludeUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []DevicesSplitTunnel `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SplitTunnelExclude `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyExcludeUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyExcludeUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -166,52 +167,6 @@ func (r devicePolicyExcludeUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyExcludeUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DevicePolicyExcludeUpdateResponseEnvelopeErrors] -type devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyExcludeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyExcludeUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DevicePolicyExcludeUpdateResponseEnvelopeMessages] -type devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyExcludeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyExcludeUpdateResponseEnvelopeSuccess bool @@ -267,9 +222,9 @@ type DevicePolicyExcludeGetParams struct { } type DevicePolicyExcludeGetResponseEnvelope struct { - Errors []DevicePolicyExcludeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyExcludeGetResponseEnvelopeMessages `json:"messages,required"` - Result []DevicesSplitTunnel `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SplitTunnelExclude `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyExcludeGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyExcludeGetResponseEnvelopeResultInfo `json:"result_info"` @@ -296,52 +251,6 @@ func (r devicePolicyExcludeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyExcludeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyExcludeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyExcludeGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DevicePolicyExcludeGetResponseEnvelopeErrors] -type devicePolicyExcludeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyExcludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyExcludeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyExcludeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyExcludeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyExcludeGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DevicePolicyExcludeGetResponseEnvelopeMessages] -type devicePolicyExcludeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyExcludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyExcludeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyExcludeGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicepolicyexclude_test.go b/zero_trust/devicepolicyexclude_test.go index 3cff66521c0..3c60baff497 100644 --- a/zero_trust/devicepolicyexclude_test.go +++ b/zero_trust/devicepolicyexclude_test.go @@ -30,7 +30,7 @@ func TestDevicePolicyExcludeUpdate(t *testing.T) { ) _, err := client.ZeroTrust.Devices.Policies.Excludes.Update(context.TODO(), zero_trust.DevicePolicyExcludeUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]zero_trust.DevicesSplitTunnelParam{{ + Body: []zero_trust.SplitTunnelExcludeParam{{ Address: cloudflare.F("192.0.2.0/24"), Description: cloudflare.F("Exclude testing domains from the tunnel"), Host: cloudflare.F("*.example.com"), @@ -42,7 +42,7 @@ func TestDevicePolicyExcludeUpdate(t *testing.T) { Address: cloudflare.F("192.0.2.0/24"), Description: cloudflare.F("Exclude testing domains from the tunnel"), Host: cloudflare.F("*.example.com"), - }}), + }}, }) if err != nil { var apierr *cloudflare.Error diff --git a/zero_trust/devicepolicyfallbackdomain.go b/zero_trust/devicepolicyfallbackdomain.go index e652eddc092..960bf9903df 100644 --- a/zero_trust/devicepolicyfallbackdomain.go +++ b/zero_trust/devicepolicyfallbackdomain.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -35,7 +36,7 @@ func NewDevicePolicyFallbackDomainService(opts ...option.RequestOption) (r *Devi // Sets the list of domains to bypass Gateway DNS resolution. These domains will // use the specified local DNS resolver instead. This will only apply to the // specified device settings profile. -func (r *DevicePolicyFallbackDomainService) Update(ctx context.Context, policyID string, params DevicePolicyFallbackDomainUpdateParams, opts ...option.RequestOption) (res *[]DevicesFallbackDomain, err error) { +func (r *DevicePolicyFallbackDomainService) Update(ctx context.Context, policyID string, params DevicePolicyFallbackDomainUpdateParams, opts ...option.RequestOption) (res *[]FallbackDomain, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyFallbackDomainUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/%s/fallback_domains", params.AccountID, policyID) @@ -49,7 +50,7 @@ func (r *DevicePolicyFallbackDomainService) Update(ctx context.Context, policyID // Fetches a list of domains to bypass Gateway DNS resolution. These domains will // use the specified local DNS resolver instead. -func (r *DevicePolicyFallbackDomainService) List(ctx context.Context, query DevicePolicyFallbackDomainListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DevicesFallbackDomain], err error) { +func (r *DevicePolicyFallbackDomainService) List(ctx context.Context, query DevicePolicyFallbackDomainListParams, opts ...option.RequestOption) (res *pagination.SinglePage[FallbackDomain], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -68,14 +69,14 @@ func (r *DevicePolicyFallbackDomainService) List(ctx context.Context, query Devi // Fetches a list of domains to bypass Gateway DNS resolution. These domains will // use the specified local DNS resolver instead. -func (r *DevicePolicyFallbackDomainService) ListAutoPaging(ctx context.Context, query DevicePolicyFallbackDomainListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DevicesFallbackDomain] { +func (r *DevicePolicyFallbackDomainService) ListAutoPaging(ctx context.Context, query DevicePolicyFallbackDomainListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[FallbackDomain] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Fetches the list of domains to bypass Gateway DNS resolution from a specified // device settings profile. These domains will use the specified local DNS resolver // instead. -func (r *DevicePolicyFallbackDomainService) Get(ctx context.Context, policyID string, query DevicePolicyFallbackDomainGetParams, opts ...option.RequestOption) (res *[]DevicesFallbackDomain, err error) { +func (r *DevicePolicyFallbackDomainService) Get(ctx context.Context, policyID string, query DevicePolicyFallbackDomainGetParams, opts ...option.RequestOption) (res *[]FallbackDomain, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyFallbackDomainGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/%s/fallback_domains", query.AccountID, policyID) @@ -87,19 +88,18 @@ func (r *DevicePolicyFallbackDomainService) Get(ctx context.Context, policyID st return } -type DevicesFallbackDomain struct { +type FallbackDomain struct { // The domain suffix to match when resolving locally. Suffix string `json:"suffix,required"` // A description of the fallback domain, displayed in the client UI. Description string `json:"description"` // A list of IP addresses to handle domain resolution. - DNSServer []interface{} `json:"dns_server"` - JSON devicesFallbackDomainJSON `json:"-"` + DNSServer []interface{} `json:"dns_server"` + JSON fallbackDomainJSON `json:"-"` } -// devicesFallbackDomainJSON contains the JSON metadata for the struct -// [DevicesFallbackDomain] -type devicesFallbackDomainJSON struct { +// fallbackDomainJSON contains the JSON metadata for the struct [FallbackDomain] +type fallbackDomainJSON struct { Suffix apijson.Field Description apijson.Field DNSServer apijson.Field @@ -107,15 +107,15 @@ type devicesFallbackDomainJSON struct { ExtraFields map[string]apijson.Field } -func (r *DevicesFallbackDomain) UnmarshalJSON(data []byte) (err error) { +func (r *FallbackDomain) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicesFallbackDomainJSON) RawJSON() string { +func (r fallbackDomainJSON) RawJSON() string { return r.raw } -type DevicesFallbackDomainParam struct { +type FallbackDomainParam struct { // The domain suffix to match when resolving locally. Suffix param.Field[string] `json:"suffix,required"` // A description of the fallback domain, displayed in the client UI. @@ -124,13 +124,13 @@ type DevicesFallbackDomainParam struct { DNSServer param.Field[[]interface{}] `json:"dns_server"` } -func (r DevicesFallbackDomainParam) MarshalJSON() (data []byte, err error) { +func (r FallbackDomainParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type DevicePolicyFallbackDomainUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]DevicesFallbackDomainParam] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body []FallbackDomainParam `json:"body,required"` } func (r DevicePolicyFallbackDomainUpdateParams) MarshalJSON() (data []byte, err error) { @@ -138,9 +138,9 @@ func (r DevicePolicyFallbackDomainUpdateParams) MarshalJSON() (data []byte, err } type DevicePolicyFallbackDomainUpdateResponseEnvelope struct { - Errors []DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []DevicesFallbackDomain `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []FallbackDomain `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -167,53 +167,6 @@ func (r devicePolicyFallbackDomainUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors] -type devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages] -type devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess bool @@ -270,9 +223,9 @@ type DevicePolicyFallbackDomainGetParams struct { } type DevicePolicyFallbackDomainGetResponseEnvelope struct { - Errors []DevicePolicyFallbackDomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyFallbackDomainGetResponseEnvelopeMessages `json:"messages,required"` - Result []DevicesFallbackDomain `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []FallbackDomain `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyFallbackDomainGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyFallbackDomainGetResponseEnvelopeResultInfo `json:"result_info"` @@ -299,52 +252,6 @@ func (r devicePolicyFallbackDomainGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyFallbackDomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DevicePolicyFallbackDomainGetResponseEnvelopeErrors] -type devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyFallbackDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyFallbackDomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DevicePolicyFallbackDomainGetResponseEnvelopeMessages] -type devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyFallbackDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyFallbackDomainGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicepolicyfallbackdomain_test.go b/zero_trust/devicepolicyfallbackdomain_test.go index 4d7b008cdc3..caf5294f085 100644 --- a/zero_trust/devicepolicyfallbackdomain_test.go +++ b/zero_trust/devicepolicyfallbackdomain_test.go @@ -33,7 +33,7 @@ func TestDevicePolicyFallbackDomainUpdate(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.DevicePolicyFallbackDomainUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]zero_trust.DevicesFallbackDomainParam{{ + Body: []zero_trust.FallbackDomainParam{{ Description: cloudflare.F("Domain bypass for local development"), DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), Suffix: cloudflare.F("example.com"), @@ -45,7 +45,7 @@ func TestDevicePolicyFallbackDomainUpdate(t *testing.T) { Description: cloudflare.F("Domain bypass for local development"), DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), Suffix: cloudflare.F("example.com"), - }}), + }}, }, ) if err != nil { diff --git a/zero_trust/devicepolicyinclude.go b/zero_trust/devicepolicyinclude.go index 659a17963b7..86528171c3a 100644 --- a/zero_trust/devicepolicyinclude.go +++ b/zero_trust/devicepolicyinclude.go @@ -11,6 +11,7 @@ import ( "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" ) @@ -33,7 +34,7 @@ func NewDevicePolicyIncludeService(opts ...option.RequestOption) (r *DevicePolic } // Sets the list of routes included in the WARP client's tunnel. -func (r *DevicePolicyIncludeService) Update(ctx context.Context, params DevicePolicyIncludeUpdateParams, opts ...option.RequestOption) (res *[]DevicesSplitTunnelInclude, err error) { +func (r *DevicePolicyIncludeService) Update(ctx context.Context, params DevicePolicyIncludeUpdateParams, opts ...option.RequestOption) (res *[]SplitTunnelInclude, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyIncludeUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/include", params.AccountID) @@ -46,7 +47,7 @@ func (r *DevicePolicyIncludeService) Update(ctx context.Context, params DevicePo } // Fetches the list of routes included in the WARP client's tunnel. -func (r *DevicePolicyIncludeService) List(ctx context.Context, query DevicePolicyIncludeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DevicesSplitTunnelInclude], err error) { +func (r *DevicePolicyIncludeService) List(ctx context.Context, query DevicePolicyIncludeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SplitTunnelInclude], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -64,13 +65,13 @@ func (r *DevicePolicyIncludeService) List(ctx context.Context, query DevicePolic } // Fetches the list of routes included in the WARP client's tunnel. -func (r *DevicePolicyIncludeService) ListAutoPaging(ctx context.Context, query DevicePolicyIncludeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DevicesSplitTunnelInclude] { +func (r *DevicePolicyIncludeService) ListAutoPaging(ctx context.Context, query DevicePolicyIncludeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SplitTunnelInclude] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Fetches the list of routes included in the WARP client's tunnel for a specific // device settings profile. -func (r *DevicePolicyIncludeService) Get(ctx context.Context, policyID string, query DevicePolicyIncludeGetParams, opts ...option.RequestOption) (res *[]DevicesSplitTunnelInclude, err error) { +func (r *DevicePolicyIncludeService) Get(ctx context.Context, policyID string, query DevicePolicyIncludeGetParams, opts ...option.RequestOption) (res *[]SplitTunnelInclude, err error) { opts = append(r.Options[:], opts...) var env DevicePolicyIncludeGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/policy/%s/include", query.AccountID, policyID) @@ -82,7 +83,7 @@ func (r *DevicePolicyIncludeService) Get(ctx context.Context, policyID string, q return } -type DevicesSplitTunnelInclude struct { +type SplitTunnelInclude struct { // The address in CIDR format to include in the tunnel. If address is present, host // must not be present. Address string `json:"address,required"` @@ -90,13 +91,13 @@ type DevicesSplitTunnelInclude struct { Description string `json:"description,required"` // The domain name to include in the tunnel. If host is present, address must not // be present. - Host string `json:"host"` - JSON devicesSplitTunnelIncludeJSON `json:"-"` + Host string `json:"host"` + JSON splitTunnelIncludeJSON `json:"-"` } -// devicesSplitTunnelIncludeJSON contains the JSON metadata for the struct -// [DevicesSplitTunnelInclude] -type devicesSplitTunnelIncludeJSON struct { +// splitTunnelIncludeJSON contains the JSON metadata for the struct +// [SplitTunnelInclude] +type splitTunnelIncludeJSON struct { Address apijson.Field Description apijson.Field Host apijson.Field @@ -104,15 +105,15 @@ type devicesSplitTunnelIncludeJSON struct { ExtraFields map[string]apijson.Field } -func (r *DevicesSplitTunnelInclude) UnmarshalJSON(data []byte) (err error) { +func (r *SplitTunnelInclude) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicesSplitTunnelIncludeJSON) RawJSON() string { +func (r splitTunnelIncludeJSON) RawJSON() string { return r.raw } -type DevicesSplitTunnelIncludeParam struct { +type SplitTunnelIncludeParam struct { // The address in CIDR format to include in the tunnel. If address is present, host // must not be present. Address param.Field[string] `json:"address,required"` @@ -123,13 +124,13 @@ type DevicesSplitTunnelIncludeParam struct { Host param.Field[string] `json:"host"` } -func (r DevicesSplitTunnelIncludeParam) MarshalJSON() (data []byte, err error) { +func (r SplitTunnelIncludeParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type DevicePolicyIncludeUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]DevicesSplitTunnelIncludeParam] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body []SplitTunnelIncludeParam `json:"body,required"` } func (r DevicePolicyIncludeUpdateParams) MarshalJSON() (data []byte, err error) { @@ -137,9 +138,9 @@ func (r DevicePolicyIncludeUpdateParams) MarshalJSON() (data []byte, err error) } type DevicePolicyIncludeUpdateResponseEnvelope struct { - Errors []DevicePolicyIncludeUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyIncludeUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []DevicesSplitTunnelInclude `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SplitTunnelInclude `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyIncludeUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyIncludeUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -166,52 +167,6 @@ func (r devicePolicyIncludeUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyIncludeUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DevicePolicyIncludeUpdateResponseEnvelopeErrors] -type devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyIncludeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyIncludeUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DevicePolicyIncludeUpdateResponseEnvelopeMessages] -type devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyIncludeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyIncludeUpdateResponseEnvelopeSuccess bool @@ -267,9 +222,9 @@ type DevicePolicyIncludeGetParams struct { } type DevicePolicyIncludeGetResponseEnvelope struct { - Errors []DevicePolicyIncludeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePolicyIncludeGetResponseEnvelopeMessages `json:"messages,required"` - Result []DevicesSplitTunnelInclude `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []SplitTunnelInclude `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePolicyIncludeGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DevicePolicyIncludeGetResponseEnvelopeResultInfo `json:"result_info"` @@ -296,52 +251,6 @@ func (r devicePolicyIncludeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePolicyIncludeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyIncludeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePolicyIncludeGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DevicePolicyIncludeGetResponseEnvelopeErrors] -type devicePolicyIncludeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyIncludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyIncludeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePolicyIncludeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePolicyIncludeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePolicyIncludeGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DevicePolicyIncludeGetResponseEnvelopeMessages] -type devicePolicyIncludeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePolicyIncludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePolicyIncludeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePolicyIncludeGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicepolicyinclude_test.go b/zero_trust/devicepolicyinclude_test.go index 2920f1678d5..73855c68548 100644 --- a/zero_trust/devicepolicyinclude_test.go +++ b/zero_trust/devicepolicyinclude_test.go @@ -30,7 +30,7 @@ func TestDevicePolicyIncludeUpdate(t *testing.T) { ) _, err := client.ZeroTrust.Devices.Policies.Includes.Update(context.TODO(), zero_trust.DevicePolicyIncludeUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]zero_trust.DevicesSplitTunnelIncludeParam{{ + Body: []zero_trust.SplitTunnelIncludeParam{{ Address: cloudflare.F("192.0.2.0/24"), Description: cloudflare.F("Include testing domains from the tunnel"), Host: cloudflare.F("*.example.com"), @@ -42,7 +42,7 @@ func TestDevicePolicyIncludeUpdate(t *testing.T) { Address: cloudflare.F("192.0.2.0/24"), Description: cloudflare.F("Include testing domains from the tunnel"), Host: cloudflare.F("*.example.com"), - }}), + }}, }) if err != nil { var apierr *cloudflare.Error diff --git a/zero_trust/deviceposture.go b/zero_trust/deviceposture.go index ae76f2ae774..1c0bb0fcc78 100644 --- a/zero_trust/deviceposture.go +++ b/zero_trust/deviceposture.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -37,7 +38,7 @@ func NewDevicePostureService(opts ...option.RequestOption) (r *DevicePostureServ } // Creates a new device posture rule. -func (r *DevicePostureService) New(ctx context.Context, params DevicePostureNewParams, opts ...option.RequestOption) (res *DevicePostureRules, err error) { +func (r *DevicePostureService) New(ctx context.Context, params DevicePostureNewParams, opts ...option.RequestOption) (res *DevicePostureRule, err error) { opts = append(r.Options[:], opts...) var env DevicePostureNewResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/posture", params.AccountID) @@ -50,7 +51,7 @@ func (r *DevicePostureService) New(ctx context.Context, params DevicePostureNewP } // Updates a device posture rule. -func (r *DevicePostureService) Update(ctx context.Context, ruleID string, params DevicePostureUpdateParams, opts ...option.RequestOption) (res *DevicePostureRules, err error) { +func (r *DevicePostureService) Update(ctx context.Context, ruleID string, params DevicePostureUpdateParams, opts ...option.RequestOption) (res *DevicePostureRule, err error) { opts = append(r.Options[:], opts...) var env DevicePostureUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/posture/%s", params.AccountID, ruleID) @@ -63,7 +64,7 @@ func (r *DevicePostureService) Update(ctx context.Context, ruleID string, params } // Fetches device posture rules for a Zero Trust account. -func (r *DevicePostureService) List(ctx context.Context, query DevicePostureListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DevicePostureRules], err error) { +func (r *DevicePostureService) List(ctx context.Context, query DevicePostureListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DevicePostureRule], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -81,15 +82,15 @@ func (r *DevicePostureService) List(ctx context.Context, query DevicePostureList } // Fetches device posture rules for a Zero Trust account. -func (r *DevicePostureService) ListAutoPaging(ctx context.Context, query DevicePostureListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DevicePostureRules] { +func (r *DevicePostureService) ListAutoPaging(ctx context.Context, query DevicePostureListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DevicePostureRule] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a device posture rule. -func (r *DevicePostureService) Delete(ctx context.Context, ruleID string, body DevicePostureDeleteParams, opts ...option.RequestOption) (res *DevicePostureDeleteResponse, err error) { +func (r *DevicePostureService) Delete(ctx context.Context, ruleID string, params DevicePostureDeleteParams, opts ...option.RequestOption) (res *DevicePostureDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env DevicePostureDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/devices/posture/%s", body.AccountID, ruleID) + path := fmt.Sprintf("accounts/%s/devices/posture/%s", params.AccountID, ruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -99,7 +100,7 @@ func (r *DevicePostureService) Delete(ctx context.Context, ruleID string, body D } // Fetches a single device posture rule. -func (r *DevicePostureService) Get(ctx context.Context, ruleID string, query DevicePostureGetParams, opts ...option.RequestOption) (res *DevicePostureRules, err error) { +func (r *DevicePostureService) Get(ctx context.Context, ruleID string, query DevicePostureGetParams, opts ...option.RequestOption) (res *DevicePostureRule, err error) { opts = append(r.Options[:], opts...) var env DevicePostureGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/posture/%s", query.AccountID, ruleID) @@ -111,2275 +112,1416 @@ func (r *DevicePostureService) Get(ctx context.Context, ruleID string, query Dev return } -type DevicePostureRules struct { - // API UUID. - ID string `json:"id"` - // The description of the device posture rule. - Description string `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration string `json:"expiration"` - // The value to be checked against. - Input DevicePostureRulesInput `json:"input"` - // The conditions that the client must match to run the rule. - Match []DevicePostureRulesMatch `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 - // five minutes). Minimum: `1m`. - Schedule string `json:"schedule"` - // The type of device posture rule. - Type DevicePostureRulesType `json:"type"` - JSON devicePostureRulesJSON `json:"-"` +type CarbonblackInput = string + +type CarbonblackInputParam = string + +type ClientCertificateInput struct { + // UUID of Cloudflare managed certificate. + CertificateID string `json:"certificate_id,required"` + // Common Name that is protected by the certificate + Cn string `json:"cn,required"` + JSON clientCertificateInputJSON `json:"-"` } -// devicePostureRulesJSON contains the JSON metadata for the struct -// [DevicePostureRules] -type devicePostureRulesJSON struct { - ID apijson.Field - Description apijson.Field - Expiration apijson.Field - Input apijson.Field - Match apijson.Field - Name apijson.Field - Schedule apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field +// clientCertificateInputJSON contains the JSON metadata for the struct +// [ClientCertificateInput] +type clientCertificateInputJSON struct { + CertificateID apijson.Field + Cn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateInputJSON) RawJSON() string { + return r.raw +} + +func (r ClientCertificateInput) implementsZeroTrustDeviceInput() {} + +type ClientCertificateInputParam struct { + // UUID of Cloudflare managed certificate. + CertificateID param.Field[string] `json:"certificate_id,required"` + // Common Name that is protected by the certificate + Cn param.Field[string] `json:"cn,required"` +} + +func (r ClientCertificateInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ClientCertificateInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +type CrowdstrikeInput struct { + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + // For more details on last seen, please refer to the Crowdstrike documentation. + LastSeen string `json:"last_seen"` + // operator + Operator CrowdstrikeInputOperator `json:"operator"` + // Os Version + OS string `json:"os"` + // overall + Overall string `json:"overall"` + // SensorConfig + SensorConfig string `json:"sensor_config"` + // For more details on state, please refer to the Crowdstrike documentation. + State CrowdstrikeInputState `json:"state"` + // Version + Version string `json:"version"` + // Version Operator + VersionOperator CrowdstrikeInputVersionOperator `json:"versionOperator"` + JSON crowdstrikeInputJSON `json:"-"` +} + +// crowdstrikeInputJSON contains the JSON metadata for the struct +// [CrowdstrikeInput] +type crowdstrikeInputJSON struct { + ConnectionID apijson.Field + LastSeen apijson.Field + Operator apijson.Field + OS apijson.Field + Overall apijson.Field + SensorConfig apijson.Field + State apijson.Field + Version apijson.Field + VersionOperator apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *DevicePostureRules) UnmarshalJSON(data []byte) (err error) { +func (r *CrowdstrikeInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesJSON) RawJSON() string { +func (r crowdstrikeInputJSON) RawJSON() string { + return r.raw +} + +func (r CrowdstrikeInput) implementsZeroTrustDeviceInput() {} + +// operator +type CrowdstrikeInputOperator string + +const ( + CrowdstrikeInputOperatorLess CrowdstrikeInputOperator = "<" + CrowdstrikeInputOperatorLessOrEquals CrowdstrikeInputOperator = "<=" + CrowdstrikeInputOperatorGreater CrowdstrikeInputOperator = ">" + CrowdstrikeInputOperatorGreaterOrEquals CrowdstrikeInputOperator = ">=" + CrowdstrikeInputOperatorEquals CrowdstrikeInputOperator = "==" +) + +func (r CrowdstrikeInputOperator) IsKnown() bool { + switch r { + case CrowdstrikeInputOperatorLess, CrowdstrikeInputOperatorLessOrEquals, CrowdstrikeInputOperatorGreater, CrowdstrikeInputOperatorGreaterOrEquals, CrowdstrikeInputOperatorEquals: + return true + } + return false +} + +// For more details on state, please refer to the Crowdstrike documentation. +type CrowdstrikeInputState string + +const ( + CrowdstrikeInputStateOnline CrowdstrikeInputState = "online" + CrowdstrikeInputStateOffline CrowdstrikeInputState = "offline" + CrowdstrikeInputStateUnknown CrowdstrikeInputState = "unknown" +) + +func (r CrowdstrikeInputState) IsKnown() bool { + switch r { + case CrowdstrikeInputStateOnline, CrowdstrikeInputStateOffline, CrowdstrikeInputStateUnknown: + return true + } + return false +} + +// Version Operator +type CrowdstrikeInputVersionOperator string + +const ( + CrowdstrikeInputVersionOperatorLess CrowdstrikeInputVersionOperator = "<" + CrowdstrikeInputVersionOperatorLessOrEquals CrowdstrikeInputVersionOperator = "<=" + CrowdstrikeInputVersionOperatorGreater CrowdstrikeInputVersionOperator = ">" + CrowdstrikeInputVersionOperatorGreaterOrEquals CrowdstrikeInputVersionOperator = ">=" + CrowdstrikeInputVersionOperatorEquals CrowdstrikeInputVersionOperator = "==" +) + +func (r CrowdstrikeInputVersionOperator) IsKnown() bool { + switch r { + case CrowdstrikeInputVersionOperatorLess, CrowdstrikeInputVersionOperatorLessOrEquals, CrowdstrikeInputVersionOperatorGreater, CrowdstrikeInputVersionOperatorGreaterOrEquals, CrowdstrikeInputVersionOperatorEquals: + return true + } + return false +} + +type CrowdstrikeInputParam struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // For more details on last seen, please refer to the Crowdstrike documentation. + LastSeen param.Field[string] `json:"last_seen"` + // operator + Operator param.Field[CrowdstrikeInputOperator] `json:"operator"` + // Os Version + OS param.Field[string] `json:"os"` + // overall + Overall param.Field[string] `json:"overall"` + // SensorConfig + SensorConfig param.Field[string] `json:"sensor_config"` + // For more details on state, please refer to the Crowdstrike documentation. + State param.Field[CrowdstrikeInputState] `json:"state"` + // Version + Version param.Field[string] `json:"version"` + // Version Operator + VersionOperator param.Field[CrowdstrikeInputVersionOperator] `json:"versionOperator"` +} + +func (r CrowdstrikeInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r CrowdstrikeInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +// The value to be checked against. +type DeviceInput struct { + // Whether or not file exists + Exists bool `json:"exists"` + // Operating system + OperatingSystem DeviceInputOperatingSystem `json:"operating_system"` + // File path. + Path string `json:"path"` + // SHA-256. + Sha256 string `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint string `json:"thumbprint"` + // List ID. + ID string `json:"id"` + // Domain + Domain string `json:"domain"` + // operator + Operator DeviceInputOperator `json:"operator"` + // Operating System Distribution Name (linux only) + OSDistroName string `json:"os_distro_name"` + // Version of OS Distribution (linux only) + OSDistroRevision string `json:"os_distro_revision"` + // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, + // the kernel release version. (Mac, iOS, and Linux only) + OSVersionExtra string `json:"os_version_extra"` + // Version of OS + Version string `json:"version"` + // Enabled + Enabled bool `json:"enabled"` + CheckDisks interface{} `json:"checkDisks,required"` + // Whether to check all disks for encryption. + RequireAll bool `json:"requireAll"` + // UUID of Cloudflare managed certificate. + CertificateID string `json:"certificate_id"` + // Common Name that is protected by the certificate + Cn string `json:"cn"` + // Compliance Status + ComplianceStatus DeviceInputComplianceStatus `json:"compliance_status"` + // Posture Integration ID. + ConnectionID string `json:"connection_id"` + // For more details on last seen, please refer to the Crowdstrike documentation. + LastSeen string `json:"last_seen"` + // Os Version + OS string `json:"os"` + // overall + Overall string `json:"overall"` + // SensorConfig + SensorConfig string `json:"sensor_config"` + // For more details on state, please refer to the Crowdstrike documentation. + State DeviceInputState `json:"state"` + // Version Operator + VersionOperator DeviceInputVersionOperator `json:"versionOperator"` + // Count Operator + CountOperator DeviceInputCountOperator `json:"countOperator"` + // The Number of Issues. + IssueCount string `json:"issue_count"` + // For more details on eid last seen, refer to the Tanium documentation. + EidLastSeen string `json:"eid_last_seen"` + // For more details on risk level, refer to the Tanium documentation. + RiskLevel DeviceInputRiskLevel `json:"risk_level"` + // Score Operator + ScoreOperator DeviceInputScoreOperator `json:"scoreOperator"` + // For more details on total score, refer to the Tanium documentation. + TotalScore float64 `json:"total_score"` + // The Number of active threats. + ActiveThreats float64 `json:"active_threats"` + // Whether device is infected. + Infected bool `json:"infected"` + // Whether device is active. + IsActive bool `json:"is_active"` + // Network status of device. + NetworkStatus DeviceInputNetworkStatus `json:"network_status"` + JSON deviceInputJSON `json:"-"` + union DeviceInputUnion +} + +// deviceInputJSON contains the JSON metadata for the struct [DeviceInput] +type deviceInputJSON struct { + Exists apijson.Field + OperatingSystem apijson.Field + Path apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field + ID apijson.Field + Domain apijson.Field + Operator apijson.Field + OSDistroName apijson.Field + OSDistroRevision apijson.Field + OSVersionExtra apijson.Field + Version apijson.Field + Enabled apijson.Field + CheckDisks apijson.Field + RequireAll apijson.Field + CertificateID apijson.Field + Cn apijson.Field + ComplianceStatus apijson.Field + ConnectionID apijson.Field + LastSeen apijson.Field + OS apijson.Field + Overall apijson.Field + SensorConfig apijson.Field + State apijson.Field + VersionOperator apijson.Field + CountOperator apijson.Field + IssueCount apijson.Field + EidLastSeen apijson.Field + RiskLevel apijson.Field + ScoreOperator apijson.Field + TotalScore apijson.Field + ActiveThreats apijson.Field + Infected apijson.Field + IsActive apijson.Field + NetworkStatus apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r deviceInputJSON) RawJSON() string { return r.raw } +func (r *DeviceInput) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r DeviceInput) AsUnion() DeviceInputUnion { + return r.union +} + // The value to be checked against. // -// Union satisfied by -// [zero_trust.DevicePostureRulesInputTeamsDevicesFileInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesOSVersionInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesFirewallInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesSentineloneInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesCarbonblackInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesApplicationInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesClientCertificateInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesIntuneInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesKolideInputRequest], -// [zero_trust.DevicePostureRulesInputTeamsDevicesTaniumInputRequest] or -// [zero_trust.DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest]. -type DevicePostureRulesInput interface { - implementsZeroTrustDevicePostureRulesInput() +// Union satisfied by [zero_trust.FileInput], [zero_trust.UniqueClientIDInput], +// [zero_trust.DomainJoinedInput], [zero_trust.OSVersionInput], +// [zero_trust.FirewallInput], [zero_trust.SentineloneInput], +// [zero_trust.DeviceInputTeamsDevicesCarbonblackInputRequest], +// [zero_trust.DiskEncryptionInput], +// [zero_trust.DeviceInputTeamsDevicesApplicationInputRequest], +// [zero_trust.ClientCertificateInput], [zero_trust.WorkspaceOneInput], +// [zero_trust.CrowdstrikeInput], [zero_trust.IntuneInput], +// [zero_trust.KolideInput], [zero_trust.TaniumInput] or +// [zero_trust.SentineloneS2sInput]. +type DeviceInputUnion interface { + implementsZeroTrustDeviceInput() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DevicePostureRulesInput)(nil)).Elem(), + reflect.TypeOf((*DeviceInputUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesFileInputRequest{}), + Type: reflect.TypeOf(FileInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest{}), + Type: reflect.TypeOf(UniqueClientIDInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest{}), + Type: reflect.TypeOf(DomainJoinedInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesOSVersionInputRequest{}), + Type: reflect.TypeOf(OSVersionInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesFirewallInputRequest{}), + Type: reflect.TypeOf(FirewallInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesSentineloneInputRequest{}), + Type: reflect.TypeOf(SentineloneInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesCarbonblackInputRequest{}), + Type: reflect.TypeOf(DeviceInputTeamsDevicesCarbonblackInputRequest{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest{}), + Type: reflect.TypeOf(DiskEncryptionInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesApplicationInputRequest{}), + Type: reflect.TypeOf(DeviceInputTeamsDevicesApplicationInputRequest{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesClientCertificateInputRequest{}), + Type: reflect.TypeOf(ClientCertificateInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest{}), + Type: reflect.TypeOf(WorkspaceOneInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest{}), + Type: reflect.TypeOf(CrowdstrikeInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesIntuneInputRequest{}), + Type: reflect.TypeOf(IntuneInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesKolideInputRequest{}), + Type: reflect.TypeOf(KolideInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesTaniumInputRequest{}), + Type: reflect.TypeOf(TaniumInput{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest{}), + Type: reflect.TypeOf(SentineloneS2sInput{}), }, ) } -type DevicePostureRulesInputTeamsDevicesFileInputRequest struct { +type DeviceInputTeamsDevicesCarbonblackInputRequest struct { // Operating system - OperatingSystem DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem `json:"operating_system,required"` + OperatingSystem DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystem `json:"operating_system,required"` // File path. Path string `json:"path,required"` - // Whether or not file exists - Exists bool `json:"exists"` // SHA-256. Sha256 string `json:"sha256"` // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON devicePostureRulesInputTeamsDevicesFileInputRequestJSON `json:"-"` + Thumbprint string `json:"thumbprint"` + JSON deviceInputTeamsDevicesCarbonblackInputRequestJSON `json:"-"` } -// devicePostureRulesInputTeamsDevicesFileInputRequestJSON contains the JSON -// metadata for the struct [DevicePostureRulesInputTeamsDevicesFileInputRequest] -type devicePostureRulesInputTeamsDevicesFileInputRequestJSON struct { +// deviceInputTeamsDevicesCarbonblackInputRequestJSON contains the JSON metadata +// for the struct [DeviceInputTeamsDevicesCarbonblackInputRequest] +type deviceInputTeamsDevicesCarbonblackInputRequestJSON struct { OperatingSystem apijson.Field Path apijson.Field - Exists apijson.Field Sha256 apijson.Field Thumbprint apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicePostureRulesInputTeamsDevicesFileInputRequest) UnmarshalJSON(data []byte) (err error) { +func (r *DeviceInputTeamsDevicesCarbonblackInputRequest) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesInputTeamsDevicesFileInputRequestJSON) RawJSON() string { +func (r deviceInputTeamsDevicesCarbonblackInputRequestJSON) RawJSON() string { return r.raw } -func (r DevicePostureRulesInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} +func (r DeviceInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDeviceInput() {} // Operating system -type DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem string +type DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystem string const ( - DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemWindows DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemLinux DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemMac DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem = "mac" + DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" + DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" + DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" ) -func (r DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem) IsKnown() bool { +func (r DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystem) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemWindows, DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemLinux, DevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemMac: + case DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows, DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux, DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac: return true } return false } -type DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID string `json:"id,required"` - // Operating System - OperatingSystem DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem `json:"operating_system,required"` - JSON devicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON `json:"-"` +type DeviceInputTeamsDevicesApplicationInputRequest struct { + // Operating system + OperatingSystem DeviceInputTeamsDevicesApplicationInputRequestOperatingSystem `json:"operating_system,required"` + // Path for the application. + Path string `json:"path,required"` + // SHA-256. + Sha256 string `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint string `json:"thumbprint"` + JSON deviceInputTeamsDevicesApplicationInputRequestJSON `json:"-"` } -// devicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON contains the -// JSON metadata for the struct -// [DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest] -type devicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON struct { - ID apijson.Field +// deviceInputTeamsDevicesApplicationInputRequestJSON contains the JSON metadata +// for the struct [DeviceInputTeamsDevicesApplicationInputRequest] +type deviceInputTeamsDevicesApplicationInputRequestJSON struct { OperatingSystem apijson.Field + Path apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest) UnmarshalJSON(data []byte) (err error) { +func (r *DeviceInputTeamsDevicesApplicationInputRequest) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON) RawJSON() string { +func (r deviceInputTeamsDevicesApplicationInputRequestJSON) RawJSON() string { return r.raw } -func (r DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} +func (r DeviceInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDeviceInput() {} -// Operating System -type DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string +// Operating system +type DeviceInputTeamsDevicesApplicationInputRequestOperatingSystem string const ( - DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" + DeviceInputTeamsDevicesApplicationInputRequestOperatingSystemWindows DeviceInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" + DeviceInputTeamsDevicesApplicationInputRequestOperatingSystemLinux DeviceInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" + DeviceInputTeamsDevicesApplicationInputRequestOperatingSystemMac DeviceInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" ) -func (r DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem) IsKnown() bool { +func (r DeviceInputTeamsDevicesApplicationInputRequestOperatingSystem) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid, DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos, DevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos: + case DeviceInputTeamsDevicesApplicationInputRequestOperatingSystemWindows, DeviceInputTeamsDevicesApplicationInputRequestOperatingSystemLinux, DeviceInputTeamsDevicesApplicationInputRequestOperatingSystemMac: return true } return false } -type DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystem `json:"operating_system,required"` - // Domain - Domain string `json:"domain"` - JSON devicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON `json:"-"` -} - -// devicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON contains the -// JSON metadata for the struct -// [DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest] -type devicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON struct { - OperatingSystem apijson.Field - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +// Operating system +type DeviceInputOperatingSystem string -func (r devicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON) RawJSON() string { - return r.raw -} +const ( + DeviceInputOperatingSystemWindows DeviceInputOperatingSystem = "windows" + DeviceInputOperatingSystemLinux DeviceInputOperatingSystem = "linux" + DeviceInputOperatingSystemMac DeviceInputOperatingSystem = "mac" + DeviceInputOperatingSystemAndroid DeviceInputOperatingSystem = "android" + DeviceInputOperatingSystemIos DeviceInputOperatingSystem = "ios" + DeviceInputOperatingSystemChromeos DeviceInputOperatingSystem = "chromeos" +) -func (r DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureRulesInput() { +func (r DeviceInputOperatingSystem) IsKnown() bool { + switch r { + case DeviceInputOperatingSystemWindows, DeviceInputOperatingSystemLinux, DeviceInputOperatingSystemMac, DeviceInputOperatingSystemAndroid, DeviceInputOperatingSystemIos, DeviceInputOperatingSystemChromeos: + return true + } + return false } -// Operating System -type DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string +// operator +type DeviceInputOperator string const ( - DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" + DeviceInputOperatorLess DeviceInputOperator = "<" + DeviceInputOperatorLessOrEquals DeviceInputOperator = "<=" + DeviceInputOperatorGreater DeviceInputOperator = ">" + DeviceInputOperatorGreaterOrEquals DeviceInputOperator = ">=" + DeviceInputOperatorEquals DeviceInputOperator = "==" ) -func (r DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystem) IsKnown() bool { +func (r DeviceInputOperator) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows: + case DeviceInputOperatorLess, DeviceInputOperatorLessOrEquals, DeviceInputOperatorGreater, DeviceInputOperatorGreaterOrEquals, DeviceInputOperatorEquals: return true } return false } -type DevicePostureRulesInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystem `json:"operating_system,required"` - // Operator - Operator DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator `json:"operator,required"` - // Version of OS - Version string `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName string `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision string `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra string `json:"os_version_extra"` - JSON devicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON `json:"-"` -} +// Compliance Status +type DeviceInputComplianceStatus string -// devicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON contains the JSON -// metadata for the struct -// [DevicePostureRulesInputTeamsDevicesOSVersionInputRequest] -type devicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON struct { - OperatingSystem apijson.Field - Operator apijson.Field - Version apijson.Field - OSDistroName apijson.Field - OSDistroRevision apijson.Field - OSVersionExtra apijson.Field - raw string - ExtraFields map[string]apijson.Field -} +const ( + DeviceInputComplianceStatusCompliant DeviceInputComplianceStatus = "compliant" + DeviceInputComplianceStatusNoncompliant DeviceInputComplianceStatus = "noncompliant" + DeviceInputComplianceStatusUnknown DeviceInputComplianceStatus = "unknown" + DeviceInputComplianceStatusNotapplicable DeviceInputComplianceStatus = "notapplicable" + DeviceInputComplianceStatusIngraceperiod DeviceInputComplianceStatus = "ingraceperiod" + DeviceInputComplianceStatusError DeviceInputComplianceStatus = "error" +) -func (r *DevicePostureRulesInputTeamsDevicesOSVersionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r DeviceInputComplianceStatus) IsKnown() bool { + switch r { + case DeviceInputComplianceStatusCompliant, DeviceInputComplianceStatusNoncompliant, DeviceInputComplianceStatusUnknown, DeviceInputComplianceStatusNotapplicable, DeviceInputComplianceStatusIngraceperiod, DeviceInputComplianceStatusError: + return true + } + return false } -func (r devicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON) RawJSON() string { - return r.raw -} +// For more details on state, please refer to the Crowdstrike documentation. +type DeviceInputState string + +const ( + DeviceInputStateOnline DeviceInputState = "online" + DeviceInputStateOffline DeviceInputState = "offline" + DeviceInputStateUnknown DeviceInputState = "unknown" +) -func (r DevicePostureRulesInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureRulesInput() { +func (r DeviceInputState) IsKnown() bool { + switch r { + case DeviceInputStateOnline, DeviceInputStateOffline, DeviceInputStateUnknown: + return true + } + return false } -// Operating System -type DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystem string +// Version Operator +type DeviceInputVersionOperator string const ( - DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" + DeviceInputVersionOperatorLess DeviceInputVersionOperator = "<" + DeviceInputVersionOperatorLessOrEquals DeviceInputVersionOperator = "<=" + DeviceInputVersionOperatorGreater DeviceInputVersionOperator = ">" + DeviceInputVersionOperatorGreaterOrEquals DeviceInputVersionOperator = ">=" + DeviceInputVersionOperatorEquals DeviceInputVersionOperator = "==" ) -func (r DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystem) IsKnown() bool { +func (r DeviceInputVersionOperator) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows: + case DeviceInputVersionOperatorLess, DeviceInputVersionOperatorLessOrEquals, DeviceInputVersionOperatorGreater, DeviceInputVersionOperatorGreaterOrEquals, DeviceInputVersionOperatorEquals: return true } return false } -// Operator -type DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator string +// Count Operator +type DeviceInputCountOperator string const ( - DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorLess DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = "<" - DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorLessOrEquals DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = "<=" - DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorGreater DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = ">" - DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorGreaterOrEquals DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = ">=" - DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorEquals DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = "==" + DeviceInputCountOperatorLess DeviceInputCountOperator = "<" + DeviceInputCountOperatorLessOrEquals DeviceInputCountOperator = "<=" + DeviceInputCountOperatorGreater DeviceInputCountOperator = ">" + DeviceInputCountOperatorGreaterOrEquals DeviceInputCountOperator = ">=" + DeviceInputCountOperatorEquals DeviceInputCountOperator = "==" ) -func (r DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator) IsKnown() bool { +func (r DeviceInputCountOperator) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorLess, DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorLessOrEquals, DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorGreater, DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorGreaterOrEquals, DevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorEquals: + case DeviceInputCountOperatorLess, DeviceInputCountOperatorLessOrEquals, DeviceInputCountOperatorGreater, DeviceInputCountOperatorGreaterOrEquals, DeviceInputCountOperatorEquals: return true } return false } -type DevicePostureRulesInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled bool `json:"enabled,required"` - // Operating System - OperatingSystem DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem `json:"operating_system,required"` - JSON devicePostureRulesInputTeamsDevicesFirewallInputRequestJSON `json:"-"` -} +// For more details on risk level, refer to the Tanium documentation. +type DeviceInputRiskLevel string -// devicePostureRulesInputTeamsDevicesFirewallInputRequestJSON contains the JSON -// metadata for the struct -// [DevicePostureRulesInputTeamsDevicesFirewallInputRequest] -type devicePostureRulesInputTeamsDevicesFirewallInputRequestJSON struct { - Enabled apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} +const ( + DeviceInputRiskLevelLow DeviceInputRiskLevel = "low" + DeviceInputRiskLevelMedium DeviceInputRiskLevel = "medium" + DeviceInputRiskLevelHigh DeviceInputRiskLevel = "high" + DeviceInputRiskLevelCritical DeviceInputRiskLevel = "critical" +) -func (r *DevicePostureRulesInputTeamsDevicesFirewallInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r DeviceInputRiskLevel) IsKnown() bool { + switch r { + case DeviceInputRiskLevelLow, DeviceInputRiskLevelMedium, DeviceInputRiskLevelHigh, DeviceInputRiskLevelCritical: + return true + } + return false } -func (r devicePostureRulesInputTeamsDevicesFirewallInputRequestJSON) RawJSON() string { - return r.raw -} +// Score Operator +type DeviceInputScoreOperator string + +const ( + DeviceInputScoreOperatorLess DeviceInputScoreOperator = "<" + DeviceInputScoreOperatorLessOrEquals DeviceInputScoreOperator = "<=" + DeviceInputScoreOperatorGreater DeviceInputScoreOperator = ">" + DeviceInputScoreOperatorGreaterOrEquals DeviceInputScoreOperator = ">=" + DeviceInputScoreOperatorEquals DeviceInputScoreOperator = "==" +) -func (r DevicePostureRulesInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureRulesInput() { +func (r DeviceInputScoreOperator) IsKnown() bool { + switch r { + case DeviceInputScoreOperatorLess, DeviceInputScoreOperatorLessOrEquals, DeviceInputScoreOperatorGreater, DeviceInputScoreOperatorGreaterOrEquals, DeviceInputScoreOperatorEquals: + return true + } + return false } -// Operating System -type DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem string +// Network status of device. +type DeviceInputNetworkStatus string const ( - DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystemWindows DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystemMac DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" + DeviceInputNetworkStatusConnected DeviceInputNetworkStatus = "connected" + DeviceInputNetworkStatusDisconnected DeviceInputNetworkStatus = "disconnected" + DeviceInputNetworkStatusDisconnecting DeviceInputNetworkStatus = "disconnecting" + DeviceInputNetworkStatusConnecting DeviceInputNetworkStatus = "connecting" ) -func (r DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem) IsKnown() bool { +func (r DeviceInputNetworkStatus) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystemWindows, DevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystemMac: + case DeviceInputNetworkStatusConnected, DeviceInputNetworkStatusDisconnected, DeviceInputNetworkStatusDisconnecting, DeviceInputNetworkStatusConnecting: return true } return false } -type DevicePostureRulesInputTeamsDevicesSentineloneInputRequest struct { +// The value to be checked against. +type DeviceInputParam struct { + // Whether or not file exists + Exists param.Field[bool] `json:"exists"` // Operating system - OperatingSystem DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem `json:"operating_system,required"` + OperatingSystem param.Field[DeviceInputOperatingSystem] `json:"operating_system"` // File path. - Path string `json:"path,required"` + Path param.Field[string] `json:"path"` // SHA-256. - Sha256 string `json:"sha256"` + Sha256 param.Field[string] `json:"sha256"` // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON devicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON `json:"-"` + Thumbprint param.Field[string] `json:"thumbprint"` + // List ID. + ID param.Field[string] `json:"id"` + // Domain + Domain param.Field[string] `json:"domain"` + // operator + Operator param.Field[DeviceInputOperator] `json:"operator"` + // Operating System Distribution Name (linux only) + OSDistroName param.Field[string] `json:"os_distro_name"` + // Version of OS Distribution (linux only) + OSDistroRevision param.Field[string] `json:"os_distro_revision"` + // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, + // the kernel release version. (Mac, iOS, and Linux only) + OSVersionExtra param.Field[string] `json:"os_version_extra"` + // Version of OS + Version param.Field[string] `json:"version"` + // Enabled + Enabled param.Field[bool] `json:"enabled"` + CheckDisks param.Field[interface{}] `json:"checkDisks,required"` + // Whether to check all disks for encryption. + RequireAll param.Field[bool] `json:"requireAll"` + // UUID of Cloudflare managed certificate. + CertificateID param.Field[string] `json:"certificate_id"` + // Common Name that is protected by the certificate + Cn param.Field[string] `json:"cn"` + // Compliance Status + ComplianceStatus param.Field[DeviceInputComplianceStatus] `json:"compliance_status"` + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id"` + // For more details on last seen, please refer to the Crowdstrike documentation. + LastSeen param.Field[string] `json:"last_seen"` + // Os Version + OS param.Field[string] `json:"os"` + // overall + Overall param.Field[string] `json:"overall"` + // SensorConfig + SensorConfig param.Field[string] `json:"sensor_config"` + // For more details on state, please refer to the Crowdstrike documentation. + State param.Field[DeviceInputState] `json:"state"` + // Version Operator + VersionOperator param.Field[DeviceInputVersionOperator] `json:"versionOperator"` + // Count Operator + CountOperator param.Field[DeviceInputCountOperator] `json:"countOperator"` + // The Number of Issues. + IssueCount param.Field[string] `json:"issue_count"` + // For more details on eid last seen, refer to the Tanium documentation. + EidLastSeen param.Field[string] `json:"eid_last_seen"` + // For more details on risk level, refer to the Tanium documentation. + RiskLevel param.Field[DeviceInputRiskLevel] `json:"risk_level"` + // Score Operator + ScoreOperator param.Field[DeviceInputScoreOperator] `json:"scoreOperator"` + // For more details on total score, refer to the Tanium documentation. + TotalScore param.Field[float64] `json:"total_score"` + // The Number of active threats. + ActiveThreats param.Field[float64] `json:"active_threats"` + // Whether device is infected. + Infected param.Field[bool] `json:"infected"` + // Whether device is active. + IsActive param.Field[bool] `json:"is_active"` + // Network status of device. + NetworkStatus param.Field[DeviceInputNetworkStatus] `json:"network_status"` } -// devicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON contains the JSON -// metadata for the struct -// [DevicePostureRulesInputTeamsDevicesSentineloneInputRequest] -type devicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r DeviceInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *DevicePostureRulesInputTeamsDevicesSentineloneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r DeviceInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +// The value to be checked against. +// +// Satisfied by [zero_trust.FileInputParam], [zero_trust.UniqueClientIDInputParam], +// [zero_trust.DomainJoinedInputParam], [zero_trust.OSVersionInputParam], +// [zero_trust.FirewallInputParam], [zero_trust.SentineloneInputParam], +// [zero_trust.DeviceInputTeamsDevicesCarbonblackInputRequestParam], +// [zero_trust.DiskEncryptionInputParam], +// [zero_trust.DeviceInputTeamsDevicesApplicationInputRequestParam], +// [zero_trust.ClientCertificateInputParam], [zero_trust.WorkspaceOneInputParam], +// [zero_trust.CrowdstrikeInputParam], [zero_trust.IntuneInputParam], +// [zero_trust.KolideInputParam], [zero_trust.TaniumInputParam], +// [zero_trust.SentineloneS2sInputParam], [DeviceInputParam]. +type DeviceInputUnionParam interface { + implementsZeroTrustDeviceInputUnionParam() +} + +type DeviceInputTeamsDevicesCarbonblackInputRequestParam struct { + // Operating system + OperatingSystem param.Field[DeviceInputTeamsDevicesCarbonblackInputRequestOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` } -func (r devicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON) RawJSON() string { - return r.raw +func (r DeviceInputTeamsDevicesCarbonblackInputRequestParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r DevicePostureRulesInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureRulesInput() { +func (r DeviceInputTeamsDevicesCarbonblackInputRequestParam) implementsZeroTrustDeviceInputUnionParam() { } -// Operating system -type DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem string +type DeviceInputTeamsDevicesApplicationInputRequestParam struct { + // Operating system + OperatingSystem param.Field[DeviceInputTeamsDevicesApplicationInputRequestOperatingSystem] `json:"operating_system,required"` + // Path for the application. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DeviceInputTeamsDevicesApplicationInputRequestParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DeviceInputTeamsDevicesApplicationInputRequestParam) implementsZeroTrustDeviceInputUnionParam() { +} + +type DeviceMatch struct { + Platform DeviceMatchPlatform `json:"platform"` + JSON deviceMatchJSON `json:"-"` +} + +// deviceMatchJSON contains the JSON metadata for the struct [DeviceMatch] +type deviceMatchJSON struct { + Platform apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceMatch) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceMatchJSON) RawJSON() string { + return r.raw +} + +type DeviceMatchPlatform string const ( - DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemMac DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" + DeviceMatchPlatformWindows DeviceMatchPlatform = "windows" + DeviceMatchPlatformMac DeviceMatchPlatform = "mac" + DeviceMatchPlatformLinux DeviceMatchPlatform = "linux" + DeviceMatchPlatformAndroid DeviceMatchPlatform = "android" + DeviceMatchPlatformIos DeviceMatchPlatform = "ios" ) -func (r DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem) IsKnown() bool { +func (r DeviceMatchPlatform) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows, DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux, DevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemMac: + case DeviceMatchPlatformWindows, DeviceMatchPlatformMac, DeviceMatchPlatformLinux, DeviceMatchPlatformAndroid, DeviceMatchPlatformIos: return true } return false } -type DevicePostureRulesInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON devicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON `json:"-"` +type DeviceMatchParam struct { + Platform param.Field[DeviceMatchPlatform] `json:"platform"` } -// devicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON contains the JSON -// metadata for the struct -// [DevicePostureRulesInputTeamsDevicesCarbonblackInputRequest] -type devicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r DeviceMatchParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *DevicePostureRulesInputTeamsDevicesCarbonblackInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type DevicePostureRule struct { + // API UUID. + ID string `json:"id"` + // The description of the device posture rule. + Description string `json:"description"` + // Sets the expiration time for a posture check result. If empty, the result + // remains valid until it is overwritten by new data from the WARP client. + Expiration string `json:"expiration"` + // The value to be checked against. + Input DeviceInput `json:"input"` + // The conditions that the client must match to run the rule. + Match []DeviceMatch `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 + // five minutes). Minimum: `1m`. + Schedule string `json:"schedule"` + // The type of device posture rule. + Type DevicePostureRuleType `json:"type"` + JSON devicePostureRuleJSON `json:"-"` } -func (r devicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON) RawJSON() string { - return r.raw +// devicePostureRuleJSON contains the JSON metadata for the struct +// [DevicePostureRule] +type devicePostureRuleJSON struct { + ID apijson.Field + Description apijson.Field + Expiration apijson.Field + Input apijson.Field + Match apijson.Field + Name apijson.Field + Schedule apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r DevicePostureRulesInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureRulesInput() { +func (r *DevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// Operating system -type DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem string +func (r devicePostureRuleJSON) RawJSON() string { + return r.raw +} + +// The type of device posture rule. +type DevicePostureRuleType string const ( - DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" + DevicePostureRuleTypeFile DevicePostureRuleType = "file" + DevicePostureRuleTypeApplication DevicePostureRuleType = "application" + DevicePostureRuleTypeTanium DevicePostureRuleType = "tanium" + DevicePostureRuleTypeGateway DevicePostureRuleType = "gateway" + DevicePostureRuleTypeWARP DevicePostureRuleType = "warp" + DevicePostureRuleTypeDiskEncryption DevicePostureRuleType = "disk_encryption" + DevicePostureRuleTypeSentinelone DevicePostureRuleType = "sentinelone" + DevicePostureRuleTypeCarbonblack DevicePostureRuleType = "carbonblack" + DevicePostureRuleTypeFirewall DevicePostureRuleType = "firewall" + DevicePostureRuleTypeOSVersion DevicePostureRuleType = "os_version" + DevicePostureRuleTypeDomainJoined DevicePostureRuleType = "domain_joined" + DevicePostureRuleTypeClientCertificate DevicePostureRuleType = "client_certificate" + DevicePostureRuleTypeUniqueClientID DevicePostureRuleType = "unique_client_id" + DevicePostureRuleTypeKolide DevicePostureRuleType = "kolide" + DevicePostureRuleTypeTaniumS2s DevicePostureRuleType = "tanium_s2s" + DevicePostureRuleTypeCrowdstrikeS2s DevicePostureRuleType = "crowdstrike_s2s" + DevicePostureRuleTypeIntune DevicePostureRuleType = "intune" + DevicePostureRuleTypeWorkspaceOne DevicePostureRuleType = "workspace_one" + DevicePostureRuleTypeSentineloneS2s DevicePostureRuleType = "sentinelone_s2s" ) -func (r DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem) IsKnown() bool { +func (r DevicePostureRuleType) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows, DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux, DevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac: + case DevicePostureRuleTypeFile, DevicePostureRuleTypeApplication, DevicePostureRuleTypeTanium, DevicePostureRuleTypeGateway, DevicePostureRuleTypeWARP, DevicePostureRuleTypeDiskEncryption, DevicePostureRuleTypeSentinelone, DevicePostureRuleTypeCarbonblack, DevicePostureRuleTypeFirewall, DevicePostureRuleTypeOSVersion, DevicePostureRuleTypeDomainJoined, DevicePostureRuleTypeClientCertificate, DevicePostureRuleTypeUniqueClientID, DevicePostureRuleTypeKolide, DevicePostureRuleTypeTaniumS2s, DevicePostureRuleTypeCrowdstrikeS2s, DevicePostureRuleTypeIntune, DevicePostureRuleTypeWorkspaceOne, DevicePostureRuleTypeSentineloneS2s: return true } return false } -type DevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest struct { +type DiskEncryptionInput struct { // List of volume names to be checked for encryption. - CheckDisks []string `json:"checkDisks"` + CheckDisks []CarbonblackInput `json:"checkDisks"` // Whether to check all disks for encryption. - RequireAll bool `json:"requireAll"` - JSON devicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON `json:"-"` + RequireAll bool `json:"requireAll"` + JSON diskEncryptionInputJSON `json:"-"` } -// devicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON contains the -// JSON metadata for the struct -// [DevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest] -type devicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON struct { +// diskEncryptionInputJSON contains the JSON metadata for the struct +// [DiskEncryptionInput] +type diskEncryptionInputJSON struct { CheckDisks apijson.Field RequireAll apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest) UnmarshalJSON(data []byte) (err error) { +func (r *DiskEncryptionInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON) RawJSON() string { +func (r diskEncryptionInputJSON) RawJSON() string { return r.raw } -func (r DevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureRulesInput() { +func (r DiskEncryptionInput) implementsZeroTrustDeviceInput() {} + +type DiskEncryptionInputParam struct { + // List of volume names to be checked for encryption. + CheckDisks param.Field[[]CarbonblackInputParam] `json:"checkDisks"` + // Whether to check all disks for encryption. + RequireAll param.Field[bool] `json:"requireAll"` } -type DevicePostureRulesInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem `json:"operating_system,required"` - // Path for the application. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON devicePostureRulesInputTeamsDevicesApplicationInputRequestJSON `json:"-"` +func (r DiskEncryptionInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DiskEncryptionInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +type DomainJoinedInput struct { + // Operating System + OperatingSystem DomainJoinedInputOperatingSystem `json:"operating_system,required"` + // Domain + Domain string `json:"domain"` + JSON domainJoinedInputJSON `json:"-"` } -// devicePostureRulesInputTeamsDevicesApplicationInputRequestJSON contains the JSON -// metadata for the struct -// [DevicePostureRulesInputTeamsDevicesApplicationInputRequest] -type devicePostureRulesInputTeamsDevicesApplicationInputRequestJSON struct { +// domainJoinedInputJSON contains the JSON metadata for the struct +// [DomainJoinedInput] +type domainJoinedInputJSON struct { OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field + Domain apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicePostureRulesInputTeamsDevicesApplicationInputRequest) UnmarshalJSON(data []byte) (err error) { +func (r *DomainJoinedInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesInputTeamsDevicesApplicationInputRequestJSON) RawJSON() string { +func (r domainJoinedInputJSON) RawJSON() string { return r.raw } -func (r DevicePostureRulesInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} +func (r DomainJoinedInput) implementsZeroTrustDeviceInput() {} -// Operating system -type DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem string +// Operating System +type DomainJoinedInputOperatingSystem string const ( - DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemWindows DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemLinux DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemMac DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" + DomainJoinedInputOperatingSystemWindows DomainJoinedInputOperatingSystem = "windows" ) -func (r DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem) IsKnown() bool { +func (r DomainJoinedInputOperatingSystem) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemWindows, DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemLinux, DevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemMac: + case DomainJoinedInputOperatingSystemWindows: return true } return false } -type DevicePostureRulesInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID string `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn string `json:"cn,required"` - JSON devicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON `json:"-"` +type DomainJoinedInputParam struct { + // Operating System + OperatingSystem param.Field[DomainJoinedInputOperatingSystem] `json:"operating_system,required"` + // Domain + Domain param.Field[string] `json:"domain"` } -// devicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON contains -// the JSON metadata for the struct -// [DevicePostureRulesInputTeamsDevicesClientCertificateInputRequest] -type devicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON struct { - CertificateID apijson.Field - Cn apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r DomainJoinedInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *DevicePostureRulesInputTeamsDevicesClientCertificateInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r DomainJoinedInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +type FileInput struct { + // Operating system + OperatingSystem FileInputOperatingSystem `json:"operating_system,required"` + // File path. + Path string `json:"path,required"` + // Whether or not file exists + Exists bool `json:"exists"` + // SHA-256. + Sha256 string `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint string `json:"thumbprint"` + JSON fileInputJSON `json:"-"` } -func (r devicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r DevicePostureRulesInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} - -type DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON devicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON `json:"-"` -} - -// devicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON contains the -// JSON metadata for the struct -// [DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest] -type devicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field +// fileInputJSON contains the JSON metadata for the struct [FileInput] +type fileInputJSON struct { + OperatingSystem apijson.Field + Path apijson.Field + Exists apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest) UnmarshalJSON(data []byte) (err error) { +func (r *FileInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON) RawJSON() string { +func (r fileInputJSON) RawJSON() string { return r.raw } -func (r DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} +func (r FileInput) implementsZeroTrustDeviceInput() {} -// Compliance Status -type DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string +// Operating system +type FileInputOperatingSystem string const ( - DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" + FileInputOperatingSystemWindows FileInputOperatingSystem = "windows" + FileInputOperatingSystemLinux FileInputOperatingSystem = "linux" + FileInputOperatingSystemMac FileInputOperatingSystem = "mac" ) -func (r DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus) IsKnown() bool { +func (r FileInputOperatingSystem) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant, DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant, DevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown: + case FileInputOperatingSystemWindows, FileInputOperatingSystemLinux, FileInputOperatingSystemMac: return true } return false } -type DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen string `json:"last_seen"` - // Operator - Operator DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator `json:"operator"` - // Os Version - OS string `json:"os"` - // overall - Overall string `json:"overall"` - // SensorConfig - SensorConfig string `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState `json:"state"` - // Version - Version string `json:"version"` - // Version Operator - VersionOperator DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator `json:"versionOperator"` - JSON devicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON `json:"-"` +type FileInputParam struct { + // Operating system + OperatingSystem param.Field[FileInputOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // Whether or not file exists + Exists param.Field[bool] `json:"exists"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` } -// devicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON contains the JSON -// metadata for the struct -// [DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest] -type devicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON struct { - ConnectionID apijson.Field - LastSeen apijson.Field - Operator apijson.Field - OS apijson.Field - Overall apijson.Field - SensorConfig apijson.Field - State apijson.Field - Version apijson.Field - VersionOperator apijson.Field +func (r FileInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r FileInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +type FirewallInput struct { + // Enabled + Enabled bool `json:"enabled,required"` + // Operating System + OperatingSystem FirewallInputOperatingSystem `json:"operating_system,required"` + JSON firewallInputJSON `json:"-"` +} + +// firewallInputJSON contains the JSON metadata for the struct [FirewallInput] +type firewallInputJSON struct { + Enabled apijson.Field + OperatingSystem apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest) UnmarshalJSON(data []byte) (err error) { +func (r *FirewallInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON) RawJSON() string { +func (r firewallInputJSON) RawJSON() string { return r.raw } -func (r DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} +func (r FirewallInput) implementsZeroTrustDeviceInput() {} -// Operator -type DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator string +// Operating System +type FirewallInputOperatingSystem string const ( - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorLess DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorLessOrEquals DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorGreater DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorGreaterOrEquals DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorEquals DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" + FirewallInputOperatingSystemWindows FirewallInputOperatingSystem = "windows" + FirewallInputOperatingSystemMac FirewallInputOperatingSystem = "mac" ) -func (r DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator) IsKnown() bool { +func (r FirewallInputOperatingSystem) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorLess, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorLessOrEquals, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorGreater, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorGreaterOrEquals, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorEquals: + case FirewallInputOperatingSystemWindows, FirewallInputOperatingSystemMac: return true } return false } -// For more details on state, please refer to the Crowdstrike documentation. -type DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateOnline DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState = "online" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateOffline DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateUnknown DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -func (r DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateOnline, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateOffline, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateUnknown: - return true - } - return false +type FirewallInputParam struct { + // Enabled + Enabled param.Field[bool] `json:"enabled,required"` + // Operating System + OperatingSystem param.Field[FirewallInputOperatingSystem] `json:"operating_system,required"` } -// Version Operator -type DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLess DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLessOrEquals DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreater DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreaterOrEquals DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorEquals DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -func (r DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLess, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLessOrEquals, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreater, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreaterOrEquals, DevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorEquals: - return true - } - return false +func (r FirewallInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type DevicePostureRulesInputTeamsDevicesIntuneInputRequest struct { +func (r FirewallInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +type IntuneInput struct { // Compliance Status - ComplianceStatus DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus `json:"compliance_status,required"` + ComplianceStatus IntuneInputComplianceStatus `json:"compliance_status,required"` // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON devicePostureRulesInputTeamsDevicesIntuneInputRequestJSON `json:"-"` + ConnectionID string `json:"connection_id,required"` + JSON intuneInputJSON `json:"-"` } -// devicePostureRulesInputTeamsDevicesIntuneInputRequestJSON contains the JSON -// metadata for the struct [DevicePostureRulesInputTeamsDevicesIntuneInputRequest] -type devicePostureRulesInputTeamsDevicesIntuneInputRequestJSON struct { +// intuneInputJSON contains the JSON metadata for the struct [IntuneInput] +type intuneInputJSON struct { ComplianceStatus apijson.Field ConnectionID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DevicePostureRulesInputTeamsDevicesIntuneInputRequest) UnmarshalJSON(data []byte) (err error) { +func (r *IntuneInput) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureRulesInputTeamsDevicesIntuneInputRequestJSON) RawJSON() string { +func (r intuneInputJSON) RawJSON() string { return r.raw } -func (r DevicePostureRulesInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} +func (r IntuneInput) implementsZeroTrustDeviceInput() {} // Compliance Status -type DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusError DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -func (r DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant, DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant, DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown, DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable, DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod, DevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusError: - return true - } - return false -} - -type DevicePostureRulesInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // Count Operator - CountOperator DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator `json:"countOperator,required"` - // The Number of Issues. - IssueCount string `json:"issue_count,required"` - JSON devicePostureRulesInputTeamsDevicesKolideInputRequestJSON `json:"-"` -} - -// devicePostureRulesInputTeamsDevicesKolideInputRequestJSON contains the JSON -// metadata for the struct [DevicePostureRulesInputTeamsDevicesKolideInputRequest] -type devicePostureRulesInputTeamsDevicesKolideInputRequestJSON struct { - ConnectionID apijson.Field - CountOperator apijson.Field - IssueCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureRulesInputTeamsDevicesKolideInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureRulesInputTeamsDevicesKolideInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r DevicePostureRulesInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} - -// Count Operator -type DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator string +type IntuneInputComplianceStatus string const ( - DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorLess DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = "<" - DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorLessOrEquals DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = "<=" - DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorGreater DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = ">" - DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorGreaterOrEquals DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = ">=" - DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorEquals DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = "==" + IntuneInputComplianceStatusCompliant IntuneInputComplianceStatus = "compliant" + IntuneInputComplianceStatusNoncompliant IntuneInputComplianceStatus = "noncompliant" + IntuneInputComplianceStatusUnknown IntuneInputComplianceStatus = "unknown" + IntuneInputComplianceStatusNotapplicable IntuneInputComplianceStatus = "notapplicable" + IntuneInputComplianceStatusIngraceperiod IntuneInputComplianceStatus = "ingraceperiod" + IntuneInputComplianceStatusError IntuneInputComplianceStatus = "error" ) -func (r DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator) IsKnown() bool { +func (r IntuneInputComplianceStatus) IsKnown() bool { switch r { - case DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorLess, DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorLessOrEquals, DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorGreater, DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorGreaterOrEquals, DevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorEquals: + case IntuneInputComplianceStatusCompliant, IntuneInputComplianceStatusNoncompliant, IntuneInputComplianceStatusUnknown, IntuneInputComplianceStatusNotapplicable, IntuneInputComplianceStatusIngraceperiod, IntuneInputComplianceStatusError: return true } return false } -type DevicePostureRulesInputTeamsDevicesTaniumInputRequest struct { +type IntuneInputParam struct { + // Compliance Status + ComplianceStatus param.Field[IntuneInputComplianceStatus] `json:"compliance_status,required"` // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen string `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel `json:"risk_level"` - // Score Operator - ScoreOperator DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore float64 `json:"total_score"` - JSON devicePostureRulesInputTeamsDevicesTaniumInputRequestJSON `json:"-"` -} - -// devicePostureRulesInputTeamsDevicesTaniumInputRequestJSON contains the JSON -// metadata for the struct [DevicePostureRulesInputTeamsDevicesTaniumInputRequest] -type devicePostureRulesInputTeamsDevicesTaniumInputRequestJSON struct { - ConnectionID apijson.Field - EidLastSeen apijson.Field - Operator apijson.Field - RiskLevel apijson.Field - ScoreOperator apijson.Field - TotalScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureRulesInputTeamsDevicesTaniumInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureRulesInputTeamsDevicesTaniumInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r DevicePostureRulesInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator string - -const ( - DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorLess DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = "<" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorLessOrEquals DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = "<=" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorGreater DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = ">" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorGreaterOrEquals DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = ">=" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorEquals DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -func (r DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorLess, DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorLessOrEquals, DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorGreater, DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorGreaterOrEquals, DevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorEquals: - return true - } - return false + ConnectionID param.Field[string] `json:"connection_id,required"` } -// For more details on risk level, refer to the Tanium documentation. -type DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelLow DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelMedium DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelHigh DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelCritical DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -func (r DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelLow, DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelMedium, DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelHigh, DevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelCritical: - return true - } - return false +func (r IntuneInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// Score Operator -type DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorLess DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorLessOrEquals DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorGreater DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorGreaterOrEquals DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorEquals DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -func (r DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorLess, DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorLessOrEquals, DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorGreater, DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorGreaterOrEquals, DevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorEquals: - return true - } - return false -} +func (r IntuneInputParam) implementsZeroTrustDeviceInputUnionParam() {} -type DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest struct { +type KolideInput struct { // Posture Integration ID. ConnectionID string `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats float64 `json:"active_threats"` - // Whether device is infected. - Infected bool `json:"infected"` - // Whether device is active. - IsActive bool `json:"is_active"` - // Network status of device. - NetworkStatus DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus `json:"network_status"` - // operator - Operator DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator `json:"operator"` - JSON devicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON `json:"-"` + // Count Operator + CountOperator KolideInputCountOperator `json:"countOperator,required"` + // The Number of Issues. + IssueCount string `json:"issue_count,required"` + JSON kolideInputJSON `json:"-"` } -// devicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON contains the -// JSON metadata for the struct -// [DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest] -type devicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON struct { +// kolideInputJSON contains the JSON metadata for the struct [KolideInput] +type kolideInputJSON struct { ConnectionID apijson.Field - ActiveThreats apijson.Field - Infected apijson.Field - IsActive apijson.Field - NetworkStatus apijson.Field - Operator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureRulesInput() { -} - -// Network status of device. -type DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -func (r DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected, DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected, DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting, DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting: - return true - } - return false -} - -// operator -type DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorLess DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorLessOrEquals DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorGreater DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorGreaterOrEquals DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorEquals DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -func (r DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator) IsKnown() bool { - switch r { - case DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorLess, DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorLessOrEquals, DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorGreater, DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorGreaterOrEquals, DevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorEquals: - return true - } - return false -} - -type DevicePostureRulesMatch struct { - Platform DevicePostureRulesMatchPlatform `json:"platform"` - JSON devicePostureRulesMatchJSON `json:"-"` -} - -// devicePostureRulesMatchJSON contains the JSON metadata for the struct -// [DevicePostureRulesMatch] -type devicePostureRulesMatchJSON struct { - Platform apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureRulesMatch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureRulesMatchJSON) RawJSON() string { - return r.raw -} - -type DevicePostureRulesMatchPlatform string - -const ( - DevicePostureRulesMatchPlatformWindows DevicePostureRulesMatchPlatform = "windows" - DevicePostureRulesMatchPlatformMac DevicePostureRulesMatchPlatform = "mac" - DevicePostureRulesMatchPlatformLinux DevicePostureRulesMatchPlatform = "linux" - DevicePostureRulesMatchPlatformAndroid DevicePostureRulesMatchPlatform = "android" - DevicePostureRulesMatchPlatformIos DevicePostureRulesMatchPlatform = "ios" -) - -func (r DevicePostureRulesMatchPlatform) IsKnown() bool { - switch r { - case DevicePostureRulesMatchPlatformWindows, DevicePostureRulesMatchPlatformMac, DevicePostureRulesMatchPlatformLinux, DevicePostureRulesMatchPlatformAndroid, DevicePostureRulesMatchPlatformIos: - return true - } - return false -} - -// The type of device posture rule. -type DevicePostureRulesType string - -const ( - DevicePostureRulesTypeFile DevicePostureRulesType = "file" - DevicePostureRulesTypeApplication DevicePostureRulesType = "application" - DevicePostureRulesTypeTanium DevicePostureRulesType = "tanium" - DevicePostureRulesTypeGateway DevicePostureRulesType = "gateway" - DevicePostureRulesTypeWARP DevicePostureRulesType = "warp" - DevicePostureRulesTypeDiskEncryption DevicePostureRulesType = "disk_encryption" - DevicePostureRulesTypeSentinelone DevicePostureRulesType = "sentinelone" - DevicePostureRulesTypeCarbonblack DevicePostureRulesType = "carbonblack" - DevicePostureRulesTypeFirewall DevicePostureRulesType = "firewall" - DevicePostureRulesTypeOSVersion DevicePostureRulesType = "os_version" - DevicePostureRulesTypeDomainJoined DevicePostureRulesType = "domain_joined" - DevicePostureRulesTypeClientCertificate DevicePostureRulesType = "client_certificate" - DevicePostureRulesTypeUniqueClientID DevicePostureRulesType = "unique_client_id" - DevicePostureRulesTypeKolide DevicePostureRulesType = "kolide" - DevicePostureRulesTypeTaniumS2s DevicePostureRulesType = "tanium_s2s" - DevicePostureRulesTypeCrowdstrikeS2s DevicePostureRulesType = "crowdstrike_s2s" - DevicePostureRulesTypeIntune DevicePostureRulesType = "intune" - DevicePostureRulesTypeWorkspaceOne DevicePostureRulesType = "workspace_one" - DevicePostureRulesTypeSentineloneS2s DevicePostureRulesType = "sentinelone_s2s" -) - -func (r DevicePostureRulesType) IsKnown() bool { - switch r { - case DevicePostureRulesTypeFile, DevicePostureRulesTypeApplication, DevicePostureRulesTypeTanium, DevicePostureRulesTypeGateway, DevicePostureRulesTypeWARP, DevicePostureRulesTypeDiskEncryption, DevicePostureRulesTypeSentinelone, DevicePostureRulesTypeCarbonblack, DevicePostureRulesTypeFirewall, DevicePostureRulesTypeOSVersion, DevicePostureRulesTypeDomainJoined, DevicePostureRulesTypeClientCertificate, DevicePostureRulesTypeUniqueClientID, DevicePostureRulesTypeKolide, DevicePostureRulesTypeTaniumS2s, DevicePostureRulesTypeCrowdstrikeS2s, DevicePostureRulesTypeIntune, DevicePostureRulesTypeWorkspaceOne, DevicePostureRulesTypeSentineloneS2s: - return true - } - return false -} - -type DevicePostureDeleteResponse struct { - // API UUID. - ID string `json:"id"` - JSON devicePostureDeleteResponseJSON `json:"-"` -} - -// devicePostureDeleteResponseJSON contains the JSON metadata for the struct -// [DevicePostureDeleteResponse] -type devicePostureDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type DevicePostureNewParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // The name of the device posture rule. - Name param.Field[string] `json:"name,required"` - // The type of device posture rule. - Type param.Field[DevicePostureNewParamsType] `json:"type,required"` - // The description of the device posture rule. - Description param.Field[string] `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration param.Field[string] `json:"expiration"` - // The value to be checked against. - Input param.Field[DevicePostureNewParamsInput] `json:"input"` - // The conditions that the client must match to run the rule. - Match param.Field[[]DevicePostureNewParamsMatch] `json:"match"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule param.Field[string] `json:"schedule"` -} - -func (r DevicePostureNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of device posture rule. -type DevicePostureNewParamsType string - -const ( - DevicePostureNewParamsTypeFile DevicePostureNewParamsType = "file" - DevicePostureNewParamsTypeApplication DevicePostureNewParamsType = "application" - DevicePostureNewParamsTypeTanium DevicePostureNewParamsType = "tanium" - DevicePostureNewParamsTypeGateway DevicePostureNewParamsType = "gateway" - DevicePostureNewParamsTypeWARP DevicePostureNewParamsType = "warp" - DevicePostureNewParamsTypeDiskEncryption DevicePostureNewParamsType = "disk_encryption" - DevicePostureNewParamsTypeSentinelone DevicePostureNewParamsType = "sentinelone" - DevicePostureNewParamsTypeCarbonblack DevicePostureNewParamsType = "carbonblack" - DevicePostureNewParamsTypeFirewall DevicePostureNewParamsType = "firewall" - DevicePostureNewParamsTypeOSVersion DevicePostureNewParamsType = "os_version" - DevicePostureNewParamsTypeDomainJoined DevicePostureNewParamsType = "domain_joined" - DevicePostureNewParamsTypeClientCertificate DevicePostureNewParamsType = "client_certificate" - DevicePostureNewParamsTypeUniqueClientID DevicePostureNewParamsType = "unique_client_id" - DevicePostureNewParamsTypeKolide DevicePostureNewParamsType = "kolide" - DevicePostureNewParamsTypeTaniumS2s DevicePostureNewParamsType = "tanium_s2s" - DevicePostureNewParamsTypeCrowdstrikeS2s DevicePostureNewParamsType = "crowdstrike_s2s" - DevicePostureNewParamsTypeIntune DevicePostureNewParamsType = "intune" - DevicePostureNewParamsTypeWorkspaceOne DevicePostureNewParamsType = "workspace_one" - DevicePostureNewParamsTypeSentineloneS2s DevicePostureNewParamsType = "sentinelone_s2s" -) - -func (r DevicePostureNewParamsType) IsKnown() bool { - switch r { - case DevicePostureNewParamsTypeFile, DevicePostureNewParamsTypeApplication, DevicePostureNewParamsTypeTanium, DevicePostureNewParamsTypeGateway, DevicePostureNewParamsTypeWARP, DevicePostureNewParamsTypeDiskEncryption, DevicePostureNewParamsTypeSentinelone, DevicePostureNewParamsTypeCarbonblack, DevicePostureNewParamsTypeFirewall, DevicePostureNewParamsTypeOSVersion, DevicePostureNewParamsTypeDomainJoined, DevicePostureNewParamsTypeClientCertificate, DevicePostureNewParamsTypeUniqueClientID, DevicePostureNewParamsTypeKolide, DevicePostureNewParamsTypeTaniumS2s, DevicePostureNewParamsTypeCrowdstrikeS2s, DevicePostureNewParamsTypeIntune, DevicePostureNewParamsTypeWorkspaceOne, DevicePostureNewParamsTypeSentineloneS2s: - return true - } - return false -} - -// The value to be checked against. -// -// Satisfied by -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesKolideInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest], -// [zero_trust.DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest]. -type DevicePostureNewParamsInput interface { - implementsZeroTrustDevicePostureNewParamsInput() -} - -type DevicePostureNewParamsInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // Whether or not file exists - Exists param.Field[bool] `json:"exists"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesFileInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows, DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux, DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemMac: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID param.Field[string] `json:"id,required"` - // Operating System - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem] `json:"operating_system,required"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" -) - -func (r DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid, DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos, DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem] `json:"operating_system,required"` - // Domain - Domain param.Field[string] `json:"domain"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -func (r DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem] `json:"operating_system,required"` - // Operator - Operator param.Field[DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator] `json:"operator,required"` - // Version of OS - Version param.Field[string] `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName param.Field[string] `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision param.Field[string] `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra param.Field[string] `json:"os_version_extra"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" -) - -func (r DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows: - return true - } - return false -} - -// Operator -type DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator string - -const ( - DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorLess DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "<" - DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorLessOrEquals DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "<=" - DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorGreater DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = ">" - DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorGreaterOrEquals DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = ">=" - DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorEquals DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "==" -) - -func (r DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorLess, DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorLessOrEquals, DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorGreater, DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorGreaterOrEquals, DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorEquals: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled param.Field[bool] `json:"enabled,required"` - // Operating System - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem] `json:"operating_system,required"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows, DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest struct { - // Operating system - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows, DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux, DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows, DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux, DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks param.Field[[]string] `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll param.Field[bool] `json:"requireAll"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -type DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem] `json:"operating_system,required"` - // Path for the application. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem string - -const ( - DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows, DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux, DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID param.Field[string] `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn param.Field[string] `json:"cn,required"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -type DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus] `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Compliance Status -type DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) - -func (r DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant, DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant, DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen param.Field[string] `json:"last_seen"` - // Operator - Operator param.Field[DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator] `json:"operator"` - // Os Version - OS param.Field[string] `json:"os"` - // overall - Overall param.Field[string] `json:"overall"` - // SensorConfig - SensorConfig param.Field[string] `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State param.Field[DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState] `json:"state"` - // Version - Version param.Field[string] `json:"version"` - // Version Operator - VersionOperator param.Field[DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator] `json:"versionOperator"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operator -type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator string - -const ( - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLess DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLessOrEquals DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreater DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreaterOrEquals DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorEquals DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" -) - -func (r DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLess, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLessOrEquals, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreater, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreaterOrEquals, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorEquals: - return true - } - return false -} - -// For more details on state, please refer to the Crowdstrike documentation. -type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "online" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -func (r DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown: - return true - } - return false -} - -// Version Operator -type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLess DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLessOrEquals DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreater DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreaterOrEquals DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorEquals DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -func (r DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLess, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLessOrEquals, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreater, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreaterOrEquals, DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorEquals: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus] `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Compliance Status -type DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -func (r DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant, DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant, DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown, DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable, DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod, DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // Count Operator - CountOperator param.Field[DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator] `json:"countOperator,required"` - // The Number of Issues. - IssueCount param.Field[string] `json:"issue_count,required"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesKolideInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Count Operator -type DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator string - -const ( - DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorLess DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "<" - DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorLessOrEquals DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "<=" - DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorGreater DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = ">" - DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorGreaterOrEquals DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = ">=" - DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorEquals DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "==" -) - -func (r DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorLess, DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorLessOrEquals, DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorGreater, DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorGreaterOrEquals, DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorEquals: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen param.Field[string] `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator param.Field[DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator] `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel param.Field[DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel] `json:"risk_level"` - // Score Operator - ScoreOperator param.Field[DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator] `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore param.Field[float64] `json:"total_score"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator string - -const ( - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorLess DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "<" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorLessOrEquals DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "<=" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorGreater DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = ">" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorGreaterOrEquals DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = ">=" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorEquals DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -func (r DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorLess, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorLessOrEquals, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorGreater, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorGreaterOrEquals, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorEquals: - return true - } - return false -} - -// For more details on risk level, refer to the Tanium documentation. -type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -func (r DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical: - return true - } - return false -} - -// Score Operator -type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLess DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLessOrEquals DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreater DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreaterOrEquals DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorEquals DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -func (r DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLess, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLessOrEquals, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreater, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreaterOrEquals, DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorEquals: - return true - } - return false -} - -type DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats param.Field[float64] `json:"active_threats"` - // Whether device is infected. - Infected param.Field[bool] `json:"infected"` - // Whether device is active. - IsActive param.Field[bool] `json:"is_active"` - // Network status of device. - NetworkStatus param.Field[DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus] `json:"network_status"` - // operator - Operator param.Field[DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator] `json:"operator"` -} - -func (r DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Network status of device. -type DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -func (r DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected, DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected, DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting, DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting: - return true - } - return false -} - -// operator -type DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLess DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLessOrEquals DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreater DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreaterOrEquals DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorEquals DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -func (r DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator) IsKnown() bool { - switch r { - case DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLess, DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLessOrEquals, DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreater, DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreaterOrEquals, DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorEquals: - return true - } - return false -} - -type DevicePostureNewParamsMatch struct { - Platform param.Field[DevicePostureNewParamsMatchPlatform] `json:"platform"` -} - -func (r DevicePostureNewParamsMatch) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DevicePostureNewParamsMatchPlatform string - -const ( - DevicePostureNewParamsMatchPlatformWindows DevicePostureNewParamsMatchPlatform = "windows" - DevicePostureNewParamsMatchPlatformMac DevicePostureNewParamsMatchPlatform = "mac" - DevicePostureNewParamsMatchPlatformLinux DevicePostureNewParamsMatchPlatform = "linux" - DevicePostureNewParamsMatchPlatformAndroid DevicePostureNewParamsMatchPlatform = "android" - DevicePostureNewParamsMatchPlatformIos DevicePostureNewParamsMatchPlatform = "ios" -) - -func (r DevicePostureNewParamsMatchPlatform) IsKnown() bool { - switch r { - case DevicePostureNewParamsMatchPlatformWindows, DevicePostureNewParamsMatchPlatformMac, DevicePostureNewParamsMatchPlatformLinux, DevicePostureNewParamsMatchPlatformAndroid, DevicePostureNewParamsMatchPlatformIos: - return true - } - return false -} - -type DevicePostureNewResponseEnvelope struct { - Errors []DevicePostureNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureNewResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureRules `json:"result,required,nullable"` - // Whether the API call was successful. - Success DevicePostureNewResponseEnvelopeSuccess `json:"success,required"` - JSON devicePostureNewResponseEnvelopeJSON `json:"-"` -} - -// devicePostureNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [DevicePostureNewResponseEnvelope] -type devicePostureNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DevicePostureNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePostureNewResponseEnvelopeErrors] -type devicePostureNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DevicePostureNewResponseEnvelopeMessages] -type devicePostureNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type DevicePostureNewResponseEnvelopeSuccess bool - -const ( - DevicePostureNewResponseEnvelopeSuccessTrue DevicePostureNewResponseEnvelopeSuccess = true -) - -func (r DevicePostureNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case DevicePostureNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type DevicePostureUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // The name of the device posture rule. - Name param.Field[string] `json:"name,required"` - // The type of device posture rule. - Type param.Field[DevicePostureUpdateParamsType] `json:"type,required"` - // The description of the device posture rule. - Description param.Field[string] `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration param.Field[string] `json:"expiration"` - // The value to be checked against. - Input param.Field[DevicePostureUpdateParamsInput] `json:"input"` - // The conditions that the client must match to run the rule. - Match param.Field[[]DevicePostureUpdateParamsMatch] `json:"match"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule param.Field[string] `json:"schedule"` -} - -func (r DevicePostureUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of device posture rule. -type DevicePostureUpdateParamsType string - -const ( - DevicePostureUpdateParamsTypeFile DevicePostureUpdateParamsType = "file" - DevicePostureUpdateParamsTypeApplication DevicePostureUpdateParamsType = "application" - DevicePostureUpdateParamsTypeTanium DevicePostureUpdateParamsType = "tanium" - DevicePostureUpdateParamsTypeGateway DevicePostureUpdateParamsType = "gateway" - DevicePostureUpdateParamsTypeWARP DevicePostureUpdateParamsType = "warp" - DevicePostureUpdateParamsTypeDiskEncryption DevicePostureUpdateParamsType = "disk_encryption" - DevicePostureUpdateParamsTypeSentinelone DevicePostureUpdateParamsType = "sentinelone" - DevicePostureUpdateParamsTypeCarbonblack DevicePostureUpdateParamsType = "carbonblack" - DevicePostureUpdateParamsTypeFirewall DevicePostureUpdateParamsType = "firewall" - DevicePostureUpdateParamsTypeOSVersion DevicePostureUpdateParamsType = "os_version" - DevicePostureUpdateParamsTypeDomainJoined DevicePostureUpdateParamsType = "domain_joined" - DevicePostureUpdateParamsTypeClientCertificate DevicePostureUpdateParamsType = "client_certificate" - DevicePostureUpdateParamsTypeUniqueClientID DevicePostureUpdateParamsType = "unique_client_id" - DevicePostureUpdateParamsTypeKolide DevicePostureUpdateParamsType = "kolide" - DevicePostureUpdateParamsTypeTaniumS2s DevicePostureUpdateParamsType = "tanium_s2s" - DevicePostureUpdateParamsTypeCrowdstrikeS2s DevicePostureUpdateParamsType = "crowdstrike_s2s" - DevicePostureUpdateParamsTypeIntune DevicePostureUpdateParamsType = "intune" - DevicePostureUpdateParamsTypeWorkspaceOne DevicePostureUpdateParamsType = "workspace_one" - DevicePostureUpdateParamsTypeSentineloneS2s DevicePostureUpdateParamsType = "sentinelone_s2s" -) - -func (r DevicePostureUpdateParamsType) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsTypeFile, DevicePostureUpdateParamsTypeApplication, DevicePostureUpdateParamsTypeTanium, DevicePostureUpdateParamsTypeGateway, DevicePostureUpdateParamsTypeWARP, DevicePostureUpdateParamsTypeDiskEncryption, DevicePostureUpdateParamsTypeSentinelone, DevicePostureUpdateParamsTypeCarbonblack, DevicePostureUpdateParamsTypeFirewall, DevicePostureUpdateParamsTypeOSVersion, DevicePostureUpdateParamsTypeDomainJoined, DevicePostureUpdateParamsTypeClientCertificate, DevicePostureUpdateParamsTypeUniqueClientID, DevicePostureUpdateParamsTypeKolide, DevicePostureUpdateParamsTypeTaniumS2s, DevicePostureUpdateParamsTypeCrowdstrikeS2s, DevicePostureUpdateParamsTypeIntune, DevicePostureUpdateParamsTypeWorkspaceOne, DevicePostureUpdateParamsTypeSentineloneS2s: - return true - } - return false -} - -// The value to be checked against. -// -// Satisfied by -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest], -// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest]. -type DevicePostureUpdateParamsInput interface { - implementsZeroTrustDevicePostureUpdateParamsInput() -} - -type DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // Whether or not file exists - Exists param.Field[bool] `json:"exists"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating system -type DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows, DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux, DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemMac: - return true - } - return false + CountOperator apijson.Field + IssueCount apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID param.Field[string] `json:"id,required"` - // Operating System - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem] `json:"operating_system,required"` +func (r *KolideInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r kolideInputJSON) RawJSON() string { + return r.raw } -func (r DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} +func (r KolideInput) implementsZeroTrustDeviceInput() {} -// Operating System -type DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string +// Count Operator +type KolideInputCountOperator string const ( - DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" + KolideInputCountOperatorLess KolideInputCountOperator = "<" + KolideInputCountOperatorLessOrEquals KolideInputCountOperator = "<=" + KolideInputCountOperatorGreater KolideInputCountOperator = ">" + KolideInputCountOperatorGreaterOrEquals KolideInputCountOperator = ">=" + KolideInputCountOperatorEquals KolideInputCountOperator = "==" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem) IsKnown() bool { +func (r KolideInputCountOperator) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid, DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos, DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos: + case KolideInputCountOperatorLess, KolideInputCountOperatorLessOrEquals, KolideInputCountOperatorGreater, KolideInputCountOperatorGreaterOrEquals, KolideInputCountOperatorEquals: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem] `json:"operating_system,required"` - // Domain - Domain param.Field[string] `json:"domain"` +type KolideInputParam struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // Count Operator + CountOperator param.Field[KolideInputCountOperator] `json:"countOperator,required"` + // The Number of Issues. + IssueCount param.Field[string] `json:"issue_count,required"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest) MarshalJSON() (data []byte, err error) { +func (r KolideInputParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating System -type DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -func (r DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows: - return true - } - return false -} +func (r KolideInputParam) implementsZeroTrustDeviceInputUnionParam() {} -type DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest struct { +type OSVersionInput struct { // Operating System - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem] `json:"operating_system,required"` - // Operator - Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator] `json:"operator,required"` + OperatingSystem OSVersionInputOperatingSystem `json:"operating_system,required"` + // operator + Operator OSVersionInputOperator `json:"operator,required"` // Version of OS - Version param.Field[string] `json:"version,required"` + Version string `json:"version,required"` // Operating System Distribution Name (linux only) - OSDistroName param.Field[string] `json:"os_distro_name"` + OSDistroName string `json:"os_distro_name"` // Version of OS Distribution (linux only) - OSDistroRevision param.Field[string] `json:"os_distro_revision"` + OSDistroRevision string `json:"os_distro_revision"` // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra param.Field[string] `json:"os_version_extra"` + OSVersionExtra string `json:"os_version_extra"` + JSON osVersionInputJSON `json:"-"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// osVersionInputJSON contains the JSON metadata for the struct [OSVersionInput] +type osVersionInputJSON struct { + OperatingSystem apijson.Field + Operator apijson.Field + Version apijson.Field + OSDistroName apijson.Field + OSDistroRevision apijson.Field + OSVersionExtra apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OSVersionInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +func (r osVersionInputJSON) RawJSON() string { + return r.raw } +func (r OSVersionInput) implementsZeroTrustDeviceInput() {} + // Operating System -type DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem string +type OSVersionInputOperatingSystem string const ( - DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" + OSVersionInputOperatingSystemWindows OSVersionInputOperatingSystem = "windows" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem) IsKnown() bool { +func (r OSVersionInputOperatingSystem) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows: + case OSVersionInputOperatingSystemWindows: return true } return false } -// Operator -type DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator string +// operator +type OSVersionInputOperator string const ( - DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorLess DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "<" - DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorLessOrEquals DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "<=" - DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorGreater DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = ">" - DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorGreaterOrEquals DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = ">=" - DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorEquals DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "==" + OSVersionInputOperatorLess OSVersionInputOperator = "<" + OSVersionInputOperatorLessOrEquals OSVersionInputOperator = "<=" + OSVersionInputOperatorGreater OSVersionInputOperator = ">" + OSVersionInputOperatorGreaterOrEquals OSVersionInputOperator = ">=" + OSVersionInputOperatorEquals OSVersionInputOperator = "==" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator) IsKnown() bool { +func (r OSVersionInputOperator) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorLess, DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorLessOrEquals, DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorGreater, DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorGreaterOrEquals, DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorEquals: + case OSVersionInputOperatorLess, OSVersionInputOperatorLessOrEquals, OSVersionInputOperatorGreater, OSVersionInputOperatorGreaterOrEquals, OSVersionInputOperatorEquals: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled param.Field[bool] `json:"enabled,required"` +type OSVersionInputParam struct { // Operating System - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem] `json:"operating_system,required"` + OperatingSystem param.Field[OSVersionInputOperatingSystem] `json:"operating_system,required"` + // operator + Operator param.Field[OSVersionInputOperator] `json:"operator,required"` + // Version of OS + Version param.Field[string] `json:"version,required"` + // Operating System Distribution Name (linux only) + OSDistroName param.Field[string] `json:"os_distro_name"` + // Version of OS Distribution (linux only) + OSDistroRevision param.Field[string] `json:"os_distro_revision"` + // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, + // the kernel release version. (Mac, iOS, and Linux only) + OSVersionExtra param.Field[string] `json:"os_version_extra"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest) MarshalJSON() (data []byte, err error) { +func (r OSVersionInputParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating System -type DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows, DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac: - return true - } - return false -} +func (r OSVersionInputParam) implementsZeroTrustDeviceInputUnionParam() {} -type DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest struct { +type SentineloneInput struct { // Operating system - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem] `json:"operating_system,required"` + OperatingSystem SentineloneInputOperatingSystem `json:"operating_system,required"` // File path. - Path param.Field[string] `json:"path,required"` + Path string `json:"path,required"` // SHA-256. - Sha256 param.Field[string] `json:"sha256"` + Sha256 string `json:"sha256"` // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` + Thumbprint string `json:"thumbprint"` + JSON sentineloneInputJSON `json:"-"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// sentineloneInputJSON contains the JSON metadata for the struct +// [SentineloneInput] +type sentineloneInputJSON struct { + OperatingSystem apijson.Field + Path apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SentineloneInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +func (r sentineloneInputJSON) RawJSON() string { + return r.raw } +func (r SentineloneInput) implementsZeroTrustDeviceInput() {} + // Operating system -type DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem string +type SentineloneInputOperatingSystem string const ( - DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" + SentineloneInputOperatingSystemWindows SentineloneInputOperatingSystem = "windows" + SentineloneInputOperatingSystemLinux SentineloneInputOperatingSystem = "linux" + SentineloneInputOperatingSystemMac SentineloneInputOperatingSystem = "mac" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem) IsKnown() bool { +func (r SentineloneInputOperatingSystem) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows, DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux, DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac: + case SentineloneInputOperatingSystemWindows, SentineloneInputOperatingSystemLinux, SentineloneInputOperatingSystemMac: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest struct { +type SentineloneInputParam struct { // Operating system - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem] `json:"operating_system,required"` + OperatingSystem param.Field[SentineloneInputOperatingSystem] `json:"operating_system,required"` // File path. Path param.Field[string] `json:"path,required"` // SHA-256. @@ -2388,443 +1530,521 @@ type DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest struct { Thumbprint param.Field[string] `json:"thumbprint"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest) MarshalJSON() (data []byte, err error) { +func (r SentineloneInputParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating system -type DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -func (r DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows, DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux, DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac: - return true - } - return false -} - -type DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks param.Field[[]string] `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll param.Field[bool] `json:"requireAll"` -} +func (r SentineloneInputParam) implementsZeroTrustDeviceInputUnionParam() {} -func (r DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type SentineloneS2sInput struct { + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + // The Number of active threats. + ActiveThreats float64 `json:"active_threats"` + // Whether device is infected. + Infected bool `json:"infected"` + // Whether device is active. + IsActive bool `json:"is_active"` + // Network status of device. + NetworkStatus SentineloneS2sInputNetworkStatus `json:"network_status"` + // operator + Operator SentineloneS2sInputOperator `json:"operator"` + JSON sentineloneS2sInputJSON `json:"-"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +// sentineloneS2sInputJSON contains the JSON metadata for the struct +// [SentineloneS2sInput] +type sentineloneS2sInputJSON struct { + ConnectionID apijson.Field + ActiveThreats apijson.Field + Infected apijson.Field + IsActive apijson.Field + NetworkStatus apijson.Field + Operator apijson.Field + raw string + ExtraFields map[string]apijson.Field } -type DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem] `json:"operating_system,required"` - // Path for the application. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` +func (r *SentineloneS2sInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r sentineloneS2sInputJSON) RawJSON() string { + return r.raw } -func (r DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} +func (r SentineloneS2sInput) implementsZeroTrustDeviceInput() {} -// Operating system -type DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem string +// Network status of device. +type SentineloneS2sInputNetworkStatus string const ( - DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" + SentineloneS2sInputNetworkStatusConnected SentineloneS2sInputNetworkStatus = "connected" + SentineloneS2sInputNetworkStatusDisconnected SentineloneS2sInputNetworkStatus = "disconnected" + SentineloneS2sInputNetworkStatusDisconnecting SentineloneS2sInputNetworkStatus = "disconnecting" + SentineloneS2sInputNetworkStatusConnecting SentineloneS2sInputNetworkStatus = "connecting" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem) IsKnown() bool { +func (r SentineloneS2sInputNetworkStatus) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows, DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux, DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac: + case SentineloneS2sInputNetworkStatusConnected, SentineloneS2sInputNetworkStatusDisconnected, SentineloneS2sInputNetworkStatusDisconnecting, SentineloneS2sInputNetworkStatusConnecting: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID param.Field[string] `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn param.Field[string] `json:"cn,required"` -} +// operator +type SentineloneS2sInputOperator string -func (r DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} +const ( + SentineloneS2sInputOperatorLess SentineloneS2sInputOperator = "<" + SentineloneS2sInputOperatorLessOrEquals SentineloneS2sInputOperator = "<=" + SentineloneS2sInputOperatorGreater SentineloneS2sInputOperator = ">" + SentineloneS2sInputOperatorGreaterOrEquals SentineloneS2sInputOperator = ">=" + SentineloneS2sInputOperatorEquals SentineloneS2sInputOperator = "==" +) -func (r DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +func (r SentineloneS2sInputOperator) IsKnown() bool { + switch r { + case SentineloneS2sInputOperatorLess, SentineloneS2sInputOperatorLessOrEquals, SentineloneS2sInputOperatorGreater, SentineloneS2sInputOperatorGreaterOrEquals, SentineloneS2sInputOperatorEquals: + return true + } + return false } -type DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus] `json:"compliance_status,required"` +type SentineloneS2sInputParam struct { // Posture Integration ID. ConnectionID param.Field[string] `json:"connection_id,required"` + // The Number of active threats. + ActiveThreats param.Field[float64] `json:"active_threats"` + // Whether device is infected. + Infected param.Field[bool] `json:"infected"` + // Whether device is active. + IsActive param.Field[bool] `json:"is_active"` + // Network status of device. + NetworkStatus param.Field[SentineloneS2sInputNetworkStatus] `json:"network_status"` + // operator + Operator param.Field[SentineloneS2sInputOperator] `json:"operator"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest) MarshalJSON() (data []byte, err error) { +func (r SentineloneS2sInputParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Compliance Status -type DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) +func (r SentineloneS2sInputParam) implementsZeroTrustDeviceInputUnionParam() {} -func (r DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant, DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant, DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown: - return true - } - return false +type TaniumInput struct { + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + // For more details on eid last seen, refer to the Tanium documentation. + EidLastSeen string `json:"eid_last_seen"` + // Operator to evaluate risk_level or eid_last_seen. + Operator TaniumInputOperator `json:"operator"` + // For more details on risk level, refer to the Tanium documentation. + RiskLevel TaniumInputRiskLevel `json:"risk_level"` + // Score Operator + ScoreOperator TaniumInputScoreOperator `json:"scoreOperator"` + // For more details on total score, refer to the Tanium documentation. + TotalScore float64 `json:"total_score"` + JSON taniumInputJSON `json:"-"` } -type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen param.Field[string] `json:"last_seen"` - // Operator - Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator] `json:"operator"` - // Os Version - OS param.Field[string] `json:"os"` - // overall - Overall param.Field[string] `json:"overall"` - // SensorConfig - SensorConfig param.Field[string] `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State param.Field[DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState] `json:"state"` - // Version - Version param.Field[string] `json:"version"` - // Version Operator - VersionOperator param.Field[DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator] `json:"versionOperator"` +// taniumInputJSON contains the JSON metadata for the struct [TaniumInput] +type taniumInputJSON struct { + ConnectionID apijson.Field + EidLastSeen apijson.Field + Operator apijson.Field + RiskLevel apijson.Field + ScoreOperator apijson.Field + TotalScore apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *TaniumInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +func (r taniumInputJSON) RawJSON() string { + return r.raw } -// Operator -type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator string +func (r TaniumInput) implementsZeroTrustDeviceInput() {} + +// Operator to evaluate risk_level or eid_last_seen. +type TaniumInputOperator string const ( - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLess DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLessOrEquals DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreater DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreaterOrEquals DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorEquals DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" + TaniumInputOperatorLess TaniumInputOperator = "<" + TaniumInputOperatorLessOrEquals TaniumInputOperator = "<=" + TaniumInputOperatorGreater TaniumInputOperator = ">" + TaniumInputOperatorGreaterOrEquals TaniumInputOperator = ">=" + TaniumInputOperatorEquals TaniumInputOperator = "==" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator) IsKnown() bool { +func (r TaniumInputOperator) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLess, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorLessOrEquals, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreater, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorGreaterOrEquals, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorEquals: + case TaniumInputOperatorLess, TaniumInputOperatorLessOrEquals, TaniumInputOperatorGreater, TaniumInputOperatorGreaterOrEquals, TaniumInputOperatorEquals: return true } return false } -// For more details on state, please refer to the Crowdstrike documentation. -type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState string +// For more details on risk level, refer to the Tanium documentation. +type TaniumInputRiskLevel string const ( - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "online" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" + TaniumInputRiskLevelLow TaniumInputRiskLevel = "low" + TaniumInputRiskLevelMedium TaniumInputRiskLevel = "medium" + TaniumInputRiskLevelHigh TaniumInputRiskLevel = "high" + TaniumInputRiskLevelCritical TaniumInputRiskLevel = "critical" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState) IsKnown() bool { +func (r TaniumInputRiskLevel) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown: + case TaniumInputRiskLevelLow, TaniumInputRiskLevelMedium, TaniumInputRiskLevelHigh, TaniumInputRiskLevelCritical: return true } return false } -// Version Operator -type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string +// Score Operator +type TaniumInputScoreOperator string const ( - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLess DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLessOrEquals DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreater DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreaterOrEquals DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorEquals DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" + TaniumInputScoreOperatorLess TaniumInputScoreOperator = "<" + TaniumInputScoreOperatorLessOrEquals TaniumInputScoreOperator = "<=" + TaniumInputScoreOperatorGreater TaniumInputScoreOperator = ">" + TaniumInputScoreOperatorGreaterOrEquals TaniumInputScoreOperator = ">=" + TaniumInputScoreOperatorEquals TaniumInputScoreOperator = "==" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator) IsKnown() bool { +func (r TaniumInputScoreOperator) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLess, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorLessOrEquals, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreater, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorGreaterOrEquals, DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorEquals: + case TaniumInputScoreOperatorLess, TaniumInputScoreOperatorLessOrEquals, TaniumInputScoreOperatorGreater, TaniumInputScoreOperatorGreaterOrEquals, TaniumInputScoreOperatorEquals: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus] `json:"compliance_status,required"` +type TaniumInputParam struct { // Posture Integration ID. ConnectionID param.Field[string] `json:"connection_id,required"` + // For more details on eid last seen, refer to the Tanium documentation. + EidLastSeen param.Field[string] `json:"eid_last_seen"` + // Operator to evaluate risk_level or eid_last_seen. + Operator param.Field[TaniumInputOperator] `json:"operator"` + // For more details on risk level, refer to the Tanium documentation. + RiskLevel param.Field[TaniumInputRiskLevel] `json:"risk_level"` + // Score Operator + ScoreOperator param.Field[TaniumInputScoreOperator] `json:"scoreOperator"` + // For more details on total score, refer to the Tanium documentation. + TotalScore param.Field[float64] `json:"total_score"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest) MarshalJSON() (data []byte, err error) { +func (r TaniumInputParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +func (r TaniumInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +type UniqueClientIDInput struct { + // List ID. + ID string `json:"id,required"` + // Operating System + OperatingSystem UniqueClientIDInputOperatingSystem `json:"operating_system,required"` + JSON uniqueClientIDInputJSON `json:"-"` } -// Compliance Status -type DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus string +// uniqueClientIDInputJSON contains the JSON metadata for the struct +// [UniqueClientIDInput] +type uniqueClientIDInputJSON struct { + ID apijson.Field + OperatingSystem apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UniqueClientIDInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uniqueClientIDInputJSON) RawJSON() string { + return r.raw +} + +func (r UniqueClientIDInput) implementsZeroTrustDeviceInput() {} + +// Operating System +type UniqueClientIDInputOperatingSystem string const ( - DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" + UniqueClientIDInputOperatingSystemAndroid UniqueClientIDInputOperatingSystem = "android" + UniqueClientIDInputOperatingSystemIos UniqueClientIDInputOperatingSystem = "ios" + UniqueClientIDInputOperatingSystemChromeos UniqueClientIDInputOperatingSystem = "chromeos" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus) IsKnown() bool { +func (r UniqueClientIDInputOperatingSystem) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant, DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant, DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown, DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable, DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod, DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError: + case UniqueClientIDInputOperatingSystemAndroid, UniqueClientIDInputOperatingSystemIos, UniqueClientIDInputOperatingSystemChromeos: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // Count Operator - CountOperator param.Field[DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator] `json:"countOperator,required"` - // The Number of Issues. - IssueCount param.Field[string] `json:"issue_count,required"` +type UniqueClientIDInputParam struct { + // List ID. + ID param.Field[string] `json:"id,required"` + // Operating System + OperatingSystem param.Field[UniqueClientIDInputOperatingSystem] `json:"operating_system,required"` +} + +func (r UniqueClientIDInputParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r UniqueClientIDInputParam) implementsZeroTrustDeviceInputUnionParam() {} + +type WorkspaceOneInput struct { + // Compliance Status + ComplianceStatus WorkspaceOneInputComplianceStatus `json:"compliance_status,required"` + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + JSON workspaceOneInputJSON `json:"-"` +} + +// workspaceOneInputJSON contains the JSON metadata for the struct +// [WorkspaceOneInput] +type workspaceOneInputJSON struct { + ComplianceStatus apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *WorkspaceOneInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +func (r workspaceOneInputJSON) RawJSON() string { + return r.raw } -// Count Operator -type DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator string +func (r WorkspaceOneInput) implementsZeroTrustDeviceInput() {} + +// Compliance Status +type WorkspaceOneInputComplianceStatus string const ( - DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorLess DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "<" - DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorLessOrEquals DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "<=" - DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorGreater DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = ">" - DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorGreaterOrEquals DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = ">=" - DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorEquals DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "==" + WorkspaceOneInputComplianceStatusCompliant WorkspaceOneInputComplianceStatus = "compliant" + WorkspaceOneInputComplianceStatusNoncompliant WorkspaceOneInputComplianceStatus = "noncompliant" + WorkspaceOneInputComplianceStatusUnknown WorkspaceOneInputComplianceStatus = "unknown" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator) IsKnown() bool { +func (r WorkspaceOneInputComplianceStatus) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorLess, DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorLessOrEquals, DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorGreater, DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorGreaterOrEquals, DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorEquals: + case WorkspaceOneInputComplianceStatusCompliant, WorkspaceOneInputComplianceStatusNoncompliant, WorkspaceOneInputComplianceStatusUnknown: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest struct { +type WorkspaceOneInputParam struct { + // Compliance Status + ComplianceStatus param.Field[WorkspaceOneInputComplianceStatus] `json:"compliance_status,required"` // Posture Integration ID. ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen param.Field[string] `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator] `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel param.Field[DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel] `json:"risk_level"` - // Score Operator - ScoreOperator param.Field[DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator] `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore param.Field[float64] `json:"total_score"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest) MarshalJSON() (data []byte, err error) { +func (r WorkspaceOneInputParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} +func (r WorkspaceOneInputParam) implementsZeroTrustDeviceInputUnionParam() {} -// Operator to evaluate risk_level or eid_last_seen. -type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator string +type DevicePostureDeleteResponse struct { + // API UUID. + ID string `json:"id"` + JSON devicePostureDeleteResponseJSON `json:"-"` +} -const ( - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorLess DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "<" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorLessOrEquals DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "<=" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorGreater DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = ">" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorGreaterOrEquals DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = ">=" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorEquals DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "==" -) +// devicePostureDeleteResponseJSON contains the JSON metadata for the struct +// [DevicePostureDeleteResponse] +type devicePostureDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -func (r DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorLess, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorLessOrEquals, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorGreater, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorGreaterOrEquals, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorEquals: - return true - } - return false +func (r *DevicePostureDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// For more details on risk level, refer to the Tanium documentation. -type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel string +func (r devicePostureDeleteResponseJSON) RawJSON() string { + return r.raw +} -const ( - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) +type DevicePostureNewParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // The name of the device posture rule. + Name param.Field[string] `json:"name,required"` + // The type of device posture rule. + Type param.Field[DevicePostureNewParamsType] `json:"type,required"` + // The description of the device posture rule. + Description param.Field[string] `json:"description"` + // Sets the expiration time for a posture check result. If empty, the result + // remains valid until it is overwritten by new data from the WARP client. + Expiration param.Field[string] `json:"expiration"` + // The value to be checked against. + Input param.Field[DeviceInputUnionParam] `json:"input"` + // The conditions that the client must match to run the rule. + Match param.Field[[]DeviceMatchParam] `json:"match"` + // Polling frequency for the WARP client posture check. Default: `5m` (poll every + // five minutes). Minimum: `1m`. + Schedule param.Field[string] `json:"schedule"` +} -func (r DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical: - return true - } - return false +func (r DevicePostureNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// Score Operator -type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator string +// The type of device posture rule. +type DevicePostureNewParamsType string const ( - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLess DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLessOrEquals DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreater DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreaterOrEquals DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorEquals DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "==" + DevicePostureNewParamsTypeFile DevicePostureNewParamsType = "file" + DevicePostureNewParamsTypeApplication DevicePostureNewParamsType = "application" + DevicePostureNewParamsTypeTanium DevicePostureNewParamsType = "tanium" + DevicePostureNewParamsTypeGateway DevicePostureNewParamsType = "gateway" + DevicePostureNewParamsTypeWARP DevicePostureNewParamsType = "warp" + DevicePostureNewParamsTypeDiskEncryption DevicePostureNewParamsType = "disk_encryption" + DevicePostureNewParamsTypeSentinelone DevicePostureNewParamsType = "sentinelone" + DevicePostureNewParamsTypeCarbonblack DevicePostureNewParamsType = "carbonblack" + DevicePostureNewParamsTypeFirewall DevicePostureNewParamsType = "firewall" + DevicePostureNewParamsTypeOSVersion DevicePostureNewParamsType = "os_version" + DevicePostureNewParamsTypeDomainJoined DevicePostureNewParamsType = "domain_joined" + DevicePostureNewParamsTypeClientCertificate DevicePostureNewParamsType = "client_certificate" + DevicePostureNewParamsTypeUniqueClientID DevicePostureNewParamsType = "unique_client_id" + DevicePostureNewParamsTypeKolide DevicePostureNewParamsType = "kolide" + DevicePostureNewParamsTypeTaniumS2s DevicePostureNewParamsType = "tanium_s2s" + DevicePostureNewParamsTypeCrowdstrikeS2s DevicePostureNewParamsType = "crowdstrike_s2s" + DevicePostureNewParamsTypeIntune DevicePostureNewParamsType = "intune" + DevicePostureNewParamsTypeWorkspaceOne DevicePostureNewParamsType = "workspace_one" + DevicePostureNewParamsTypeSentineloneS2s DevicePostureNewParamsType = "sentinelone_s2s" ) -func (r DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator) IsKnown() bool { +func (r DevicePostureNewParamsType) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLess, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorLessOrEquals, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreater, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorGreaterOrEquals, DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorEquals: + case DevicePostureNewParamsTypeFile, DevicePostureNewParamsTypeApplication, DevicePostureNewParamsTypeTanium, DevicePostureNewParamsTypeGateway, DevicePostureNewParamsTypeWARP, DevicePostureNewParamsTypeDiskEncryption, DevicePostureNewParamsTypeSentinelone, DevicePostureNewParamsTypeCarbonblack, DevicePostureNewParamsTypeFirewall, DevicePostureNewParamsTypeOSVersion, DevicePostureNewParamsTypeDomainJoined, DevicePostureNewParamsTypeClientCertificate, DevicePostureNewParamsTypeUniqueClientID, DevicePostureNewParamsTypeKolide, DevicePostureNewParamsTypeTaniumS2s, DevicePostureNewParamsTypeCrowdstrikeS2s, DevicePostureNewParamsTypeIntune, DevicePostureNewParamsTypeWorkspaceOne, DevicePostureNewParamsTypeSentineloneS2s: return true } return false } -type DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats param.Field[float64] `json:"active_threats"` - // Whether device is infected. - Infected param.Field[bool] `json:"infected"` - // Whether device is active. - IsActive param.Field[bool] `json:"is_active"` - // Network status of device. - NetworkStatus param.Field[DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus] `json:"network_status"` - // operator - Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator] `json:"operator"` +type DevicePostureNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DevicePostureRule `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureNewResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureNewResponseEnvelopeJSON `json:"-"` } -func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// devicePostureNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePostureNewResponseEnvelope] +type devicePostureNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +func (r *DevicePostureNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// Network status of device. -type DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus) IsKnown() bool { - switch r { - case DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected, DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected, DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting, DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting: - return true - } - return false +func (r devicePostureNewResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// operator -type DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator string +// Whether the API call was successful. +type DevicePostureNewResponseEnvelopeSuccess bool const ( - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLess DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLessOrEquals DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreater DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreaterOrEquals DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorEquals DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" + DevicePostureNewResponseEnvelopeSuccessTrue DevicePostureNewResponseEnvelopeSuccess = true ) -func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator) IsKnown() bool { +func (r DevicePostureNewResponseEnvelopeSuccess) IsKnown() bool { switch r { - case DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLess, DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorLessOrEquals, DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreater, DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorGreaterOrEquals, DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorEquals: + case DevicePostureNewResponseEnvelopeSuccessTrue: return true } return false } -type DevicePostureUpdateParamsMatch struct { - Platform param.Field[DevicePostureUpdateParamsMatchPlatform] `json:"platform"` +type DevicePostureUpdateParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // The name of the device posture rule. + Name param.Field[string] `json:"name,required"` + // The type of device posture rule. + Type param.Field[DevicePostureUpdateParamsType] `json:"type,required"` + // The description of the device posture rule. + Description param.Field[string] `json:"description"` + // Sets the expiration time for a posture check result. If empty, the result + // remains valid until it is overwritten by new data from the WARP client. + Expiration param.Field[string] `json:"expiration"` + // The value to be checked against. + Input param.Field[DeviceInputUnionParam] `json:"input"` + // The conditions that the client must match to run the rule. + Match param.Field[[]DeviceMatchParam] `json:"match"` + // Polling frequency for the WARP client posture check. Default: `5m` (poll every + // five minutes). Minimum: `1m`. + Schedule param.Field[string] `json:"schedule"` } -func (r DevicePostureUpdateParamsMatch) MarshalJSON() (data []byte, err error) { +func (r DevicePostureUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type DevicePostureUpdateParamsMatchPlatform string +// The type of device posture rule. +type DevicePostureUpdateParamsType string const ( - DevicePostureUpdateParamsMatchPlatformWindows DevicePostureUpdateParamsMatchPlatform = "windows" - DevicePostureUpdateParamsMatchPlatformMac DevicePostureUpdateParamsMatchPlatform = "mac" - DevicePostureUpdateParamsMatchPlatformLinux DevicePostureUpdateParamsMatchPlatform = "linux" - DevicePostureUpdateParamsMatchPlatformAndroid DevicePostureUpdateParamsMatchPlatform = "android" - DevicePostureUpdateParamsMatchPlatformIos DevicePostureUpdateParamsMatchPlatform = "ios" + DevicePostureUpdateParamsTypeFile DevicePostureUpdateParamsType = "file" + DevicePostureUpdateParamsTypeApplication DevicePostureUpdateParamsType = "application" + DevicePostureUpdateParamsTypeTanium DevicePostureUpdateParamsType = "tanium" + DevicePostureUpdateParamsTypeGateway DevicePostureUpdateParamsType = "gateway" + DevicePostureUpdateParamsTypeWARP DevicePostureUpdateParamsType = "warp" + DevicePostureUpdateParamsTypeDiskEncryption DevicePostureUpdateParamsType = "disk_encryption" + DevicePostureUpdateParamsTypeSentinelone DevicePostureUpdateParamsType = "sentinelone" + DevicePostureUpdateParamsTypeCarbonblack DevicePostureUpdateParamsType = "carbonblack" + DevicePostureUpdateParamsTypeFirewall DevicePostureUpdateParamsType = "firewall" + DevicePostureUpdateParamsTypeOSVersion DevicePostureUpdateParamsType = "os_version" + DevicePostureUpdateParamsTypeDomainJoined DevicePostureUpdateParamsType = "domain_joined" + DevicePostureUpdateParamsTypeClientCertificate DevicePostureUpdateParamsType = "client_certificate" + DevicePostureUpdateParamsTypeUniqueClientID DevicePostureUpdateParamsType = "unique_client_id" + DevicePostureUpdateParamsTypeKolide DevicePostureUpdateParamsType = "kolide" + DevicePostureUpdateParamsTypeTaniumS2s DevicePostureUpdateParamsType = "tanium_s2s" + DevicePostureUpdateParamsTypeCrowdstrikeS2s DevicePostureUpdateParamsType = "crowdstrike_s2s" + DevicePostureUpdateParamsTypeIntune DevicePostureUpdateParamsType = "intune" + DevicePostureUpdateParamsTypeWorkspaceOne DevicePostureUpdateParamsType = "workspace_one" + DevicePostureUpdateParamsTypeSentineloneS2s DevicePostureUpdateParamsType = "sentinelone_s2s" ) -func (r DevicePostureUpdateParamsMatchPlatform) IsKnown() bool { +func (r DevicePostureUpdateParamsType) IsKnown() bool { switch r { - case DevicePostureUpdateParamsMatchPlatformWindows, DevicePostureUpdateParamsMatchPlatformMac, DevicePostureUpdateParamsMatchPlatformLinux, DevicePostureUpdateParamsMatchPlatformAndroid, DevicePostureUpdateParamsMatchPlatformIos: + case DevicePostureUpdateParamsTypeFile, DevicePostureUpdateParamsTypeApplication, DevicePostureUpdateParamsTypeTanium, DevicePostureUpdateParamsTypeGateway, DevicePostureUpdateParamsTypeWARP, DevicePostureUpdateParamsTypeDiskEncryption, DevicePostureUpdateParamsTypeSentinelone, DevicePostureUpdateParamsTypeCarbonblack, DevicePostureUpdateParamsTypeFirewall, DevicePostureUpdateParamsTypeOSVersion, DevicePostureUpdateParamsTypeDomainJoined, DevicePostureUpdateParamsTypeClientCertificate, DevicePostureUpdateParamsTypeUniqueClientID, DevicePostureUpdateParamsTypeKolide, DevicePostureUpdateParamsTypeTaniumS2s, DevicePostureUpdateParamsTypeCrowdstrikeS2s, DevicePostureUpdateParamsTypeIntune, DevicePostureUpdateParamsTypeWorkspaceOne, DevicePostureUpdateParamsTypeSentineloneS2s: return true } return false } type DevicePostureUpdateResponseEnvelope struct { - Errors []DevicePostureUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureRules `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DevicePostureRule `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePostureUpdateResponseEnvelopeSuccess `json:"success,required"` JSON devicePostureUpdateResponseEnvelopeJSON `json:"-"` @@ -2849,52 +2069,6 @@ func (r devicePostureUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePostureUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePostureUpdateResponseEnvelopeErrors] -type devicePostureUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DevicePostureUpdateResponseEnvelopeMessages] -type devicePostureUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePostureUpdateResponseEnvelopeSuccess bool @@ -2916,12 +2090,17 @@ type DevicePostureListParams struct { type DevicePostureDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DevicePostureDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DevicePostureDeleteResponseEnvelope struct { - Errors []DevicePostureDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DevicePostureDeleteResponse `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePostureDeleteResponseEnvelopeSuccess `json:"success,required"` JSON devicePostureDeleteResponseEnvelopeJSON `json:"-"` @@ -2946,52 +2125,6 @@ func (r devicePostureDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePostureDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePostureDeleteResponseEnvelopeErrors] -type devicePostureDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DevicePostureDeleteResponseEnvelopeMessages] -type devicePostureDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePostureDeleteResponseEnvelopeSuccess bool @@ -3012,9 +2145,9 @@ type DevicePostureGetParams struct { } type DevicePostureGetResponseEnvelope struct { - Errors []DevicePostureGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureGetResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureRules `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DevicePostureRule `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePostureGetResponseEnvelopeSuccess `json:"success,required"` JSON devicePostureGetResponseEnvelopeJSON `json:"-"` @@ -3039,52 +2172,6 @@ func (r devicePostureGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePostureGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DevicePostureGetResponseEnvelopeErrors] -type devicePostureGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DevicePostureGetResponseEnvelopeMessages] -type devicePostureGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePostureGetResponseEnvelopeSuccess bool diff --git a/zero_trust/deviceposture_test.go b/zero_trust/deviceposture_test.go index 87da9dcc0ad..09ef0eda59d 100644 --- a/zero_trust/deviceposture_test.go +++ b/zero_trust/deviceposture_test.go @@ -34,19 +34,19 @@ func TestDevicePostureNewWithOptionalParams(t *testing.T) { Type: cloudflare.F(zero_trust.DevicePostureNewParamsTypeFile), Description: cloudflare.F("The rule for admin serial numbers"), Expiration: cloudflare.F("1h"), - Input: cloudflare.F[zero_trust.DevicePostureNewParamsInput](zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequest(zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequest{ + Input: cloudflare.F[zero_trust.DeviceInputUnionParam](zero_trust.FileInputParam{ Exists: cloudflare.F(true), - OperatingSystem: cloudflare.F(zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux), + OperatingSystem: cloudflare.F(zero_trust.FileInputOperatingSystemLinux), Path: cloudflare.F("/bin/cat"), Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), - })), - Match: cloudflare.F([]zero_trust.DevicePostureNewParamsMatch{{ - Platform: cloudflare.F(zero_trust.DevicePostureNewParamsMatchPlatformWindows), + }), + Match: cloudflare.F([]zero_trust.DeviceMatchParam{{ + Platform: cloudflare.F(zero_trust.DeviceMatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.DevicePostureNewParamsMatchPlatformWindows), + Platform: cloudflare.F(zero_trust.DeviceMatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.DevicePostureNewParamsMatchPlatformWindows), + Platform: cloudflare.F(zero_trust.DeviceMatchPlatformWindows), }}), Schedule: cloudflare.F("1h"), }) @@ -82,19 +82,19 @@ func TestDevicePostureUpdateWithOptionalParams(t *testing.T) { Type: cloudflare.F(zero_trust.DevicePostureUpdateParamsTypeFile), Description: cloudflare.F("The rule for admin serial numbers"), Expiration: cloudflare.F("1h"), - Input: cloudflare.F[zero_trust.DevicePostureUpdateParamsInput](zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest(zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest{ + Input: cloudflare.F[zero_trust.DeviceInputUnionParam](zero_trust.FileInputParam{ Exists: cloudflare.F(true), - OperatingSystem: cloudflare.F(zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux), + OperatingSystem: cloudflare.F(zero_trust.FileInputOperatingSystemLinux), Path: cloudflare.F("/bin/cat"), Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), - })), - Match: cloudflare.F([]zero_trust.DevicePostureUpdateParamsMatch{{ - Platform: cloudflare.F(zero_trust.DevicePostureUpdateParamsMatchPlatformWindows), + }), + Match: cloudflare.F([]zero_trust.DeviceMatchParam{{ + Platform: cloudflare.F(zero_trust.DeviceMatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.DevicePostureUpdateParamsMatchPlatformWindows), + Platform: cloudflare.F(zero_trust.DeviceMatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.DevicePostureUpdateParamsMatchPlatformWindows), + Platform: cloudflare.F(zero_trust.DeviceMatchPlatformWindows), }}), Schedule: cloudflare.F("1h"), }, @@ -153,6 +153,7 @@ func TestDevicePostureDelete(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.DevicePostureDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/devicepostureintegration.go b/zero_trust/devicepostureintegration.go index 6cdd84c77e6..020bfceae32 100644 --- a/zero_trust/devicepostureintegration.go +++ b/zero_trust/devicepostureintegration.go @@ -36,7 +36,7 @@ func NewDevicePostureIntegrationService(opts ...option.RequestOption) (r *Device } // Create a new device posture integration. -func (r *DevicePostureIntegrationService) New(ctx context.Context, params DevicePostureIntegrationNewParams, opts ...option.RequestOption) (res *DevicePostureIntegrations, err error) { +func (r *DevicePostureIntegrationService) New(ctx context.Context, params DevicePostureIntegrationNewParams, opts ...option.RequestOption) (res *Integration, err error) { opts = append(r.Options[:], opts...) var env DevicePostureIntegrationNewResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/posture/integration", params.AccountID) @@ -49,7 +49,7 @@ func (r *DevicePostureIntegrationService) New(ctx context.Context, params Device } // Fetches the list of device posture integrations for an account. -func (r *DevicePostureIntegrationService) List(ctx context.Context, query DevicePostureIntegrationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DevicePostureIntegrations], err error) { +func (r *DevicePostureIntegrationService) List(ctx context.Context, query DevicePostureIntegrationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Integration], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -67,15 +67,15 @@ func (r *DevicePostureIntegrationService) List(ctx context.Context, query Device } // Fetches the list of device posture integrations for an account. -func (r *DevicePostureIntegrationService) ListAutoPaging(ctx context.Context, query DevicePostureIntegrationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DevicePostureIntegrations] { +func (r *DevicePostureIntegrationService) ListAutoPaging(ctx context.Context, query DevicePostureIntegrationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Integration] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Delete a configured device posture integration. -func (r *DevicePostureIntegrationService) Delete(ctx context.Context, integrationID string, body DevicePostureIntegrationDeleteParams, opts ...option.RequestOption) (res *DevicePostureIntegrationDeleteResponse, err error) { +func (r *DevicePostureIntegrationService) Delete(ctx context.Context, integrationID string, params DevicePostureIntegrationDeleteParams, opts ...option.RequestOption) (res *DevicePostureIntegrationDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DevicePostureIntegrationDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/devices/posture/integration/%s", body.AccountID, integrationID) + path := fmt.Sprintf("accounts/%s/devices/posture/integration/%s", params.AccountID, integrationID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -85,7 +85,7 @@ func (r *DevicePostureIntegrationService) Delete(ctx context.Context, integratio } // Updates a configured device posture integration. -func (r *DevicePostureIntegrationService) Edit(ctx context.Context, integrationID string, params DevicePostureIntegrationEditParams, opts ...option.RequestOption) (res *DevicePostureIntegrations, err error) { +func (r *DevicePostureIntegrationService) Edit(ctx context.Context, integrationID string, params DevicePostureIntegrationEditParams, opts ...option.RequestOption) (res *Integration, err error) { opts = append(r.Options[:], opts...) var env DevicePostureIntegrationEditResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/posture/integration/%s", params.AccountID, integrationID) @@ -98,7 +98,7 @@ func (r *DevicePostureIntegrationService) Edit(ctx context.Context, integrationI } // Fetches details for a single device posture integration. -func (r *DevicePostureIntegrationService) Get(ctx context.Context, integrationID string, query DevicePostureIntegrationGetParams, opts ...option.RequestOption) (res *DevicePostureIntegrations, err error) { +func (r *DevicePostureIntegrationService) Get(ctx context.Context, integrationID string, query DevicePostureIntegrationGetParams, opts ...option.RequestOption) (res *Integration, err error) { opts = append(r.Options[:], opts...) var env DevicePostureIntegrationGetResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/posture/integration/%s", query.AccountID, integrationID) @@ -110,24 +110,23 @@ func (r *DevicePostureIntegrationService) Get(ctx context.Context, integrationID return } -type DevicePostureIntegrations struct { +type Integration struct { // API UUID. ID string `json:"id"` // The configuration object containing third-party integration information. - Config DevicePostureIntegrationsConfig `json:"config"` + Config IntegrationConfig `json:"config"` // The interval between each posture check with the third-party API. Use `m` for // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). Interval string `json:"interval"` // The name of the device posture integration. Name string `json:"name"` // The type of device posture integration. - Type DevicePostureIntegrationsType `json:"type"` - JSON devicePostureIntegrationsJSON `json:"-"` + Type IntegrationType `json:"type"` + JSON integrationJSON `json:"-"` } -// devicePostureIntegrationsJSON contains the JSON metadata for the struct -// [DevicePostureIntegrations] -type devicePostureIntegrationsJSON struct { +// integrationJSON contains the JSON metadata for the struct [Integration] +type integrationJSON struct { ID apijson.Field Config apijson.Field Interval apijson.Field @@ -137,28 +136,28 @@ type devicePostureIntegrationsJSON struct { ExtraFields map[string]apijson.Field } -func (r *DevicePostureIntegrations) UnmarshalJSON(data []byte) (err error) { +func (r *Integration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureIntegrationsJSON) RawJSON() string { +func (r integrationJSON) RawJSON() string { return r.raw } // The configuration object containing third-party integration information. -type DevicePostureIntegrationsConfig struct { +type IntegrationConfig struct { // The Workspace One API URL provided in the Workspace One Admin Dashboard. APIURL string `json:"api_url,required"` // The Workspace One Authorization URL depending on your region. AuthURL string `json:"auth_url,required"` // The Workspace One client ID provided in the Workspace One Admin Dashboard. - ClientID string `json:"client_id,required"` - JSON devicePostureIntegrationsConfigJSON `json:"-"` + ClientID string `json:"client_id,required"` + JSON integrationConfigJSON `json:"-"` } -// devicePostureIntegrationsConfigJSON contains the JSON metadata for the struct -// [DevicePostureIntegrationsConfig] -type devicePostureIntegrationsConfigJSON struct { +// integrationConfigJSON contains the JSON metadata for the struct +// [IntegrationConfig] +type integrationConfigJSON struct { APIURL apijson.Field AuthURL apijson.Field ClientID apijson.Field @@ -166,30 +165,30 @@ type devicePostureIntegrationsConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *DevicePostureIntegrationsConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IntegrationConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r devicePostureIntegrationsConfigJSON) RawJSON() string { +func (r integrationConfigJSON) RawJSON() string { return r.raw } // The type of device posture integration. -type DevicePostureIntegrationsType string +type IntegrationType string const ( - DevicePostureIntegrationsTypeWorkspaceOne DevicePostureIntegrationsType = "workspace_one" - DevicePostureIntegrationsTypeCrowdstrikeS2s DevicePostureIntegrationsType = "crowdstrike_s2s" - DevicePostureIntegrationsTypeUptycs DevicePostureIntegrationsType = "uptycs" - DevicePostureIntegrationsTypeIntune DevicePostureIntegrationsType = "intune" - DevicePostureIntegrationsTypeKolide DevicePostureIntegrationsType = "kolide" - DevicePostureIntegrationsTypeTanium DevicePostureIntegrationsType = "tanium" - DevicePostureIntegrationsTypeSentineloneS2s DevicePostureIntegrationsType = "sentinelone_s2s" + IntegrationTypeWorkspaceOne IntegrationType = "workspace_one" + IntegrationTypeCrowdstrikeS2s IntegrationType = "crowdstrike_s2s" + IntegrationTypeUptycs IntegrationType = "uptycs" + IntegrationTypeIntune IntegrationType = "intune" + IntegrationTypeKolide IntegrationType = "kolide" + IntegrationTypeTanium IntegrationType = "tanium" + IntegrationTypeSentineloneS2s IntegrationType = "sentinelone_s2s" ) -func (r DevicePostureIntegrationsType) IsKnown() bool { +func (r IntegrationType) IsKnown() bool { switch r { - case DevicePostureIntegrationsTypeWorkspaceOne, DevicePostureIntegrationsTypeCrowdstrikeS2s, DevicePostureIntegrationsTypeUptycs, DevicePostureIntegrationsTypeIntune, DevicePostureIntegrationsTypeKolide, DevicePostureIntegrationsTypeTanium, DevicePostureIntegrationsTypeSentineloneS2s: + case IntegrationTypeWorkspaceOne, IntegrationTypeCrowdstrikeS2s, IntegrationTypeUptycs, IntegrationTypeIntune, IntegrationTypeKolide, IntegrationTypeTanium, IntegrationTypeSentineloneS2s: return true } return false @@ -197,13 +196,13 @@ func (r DevicePostureIntegrationsType) IsKnown() bool { // Union satisfied by [zero_trust.DevicePostureIntegrationDeleteResponseUnknown] or // [shared.UnionString]. -type DevicePostureIntegrationDeleteResponse interface { - ImplementsZeroTrustDevicePostureIntegrationDeleteResponse() +type DevicePostureIntegrationDeleteResponseUnion interface { + ImplementsZeroTrustDevicePostureIntegrationDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DevicePostureIntegrationDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*DevicePostureIntegrationDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -215,7 +214,7 @@ func init() { type DevicePostureIntegrationNewParams struct { AccountID param.Field[string] `path:"account_id,required"` // The configuration object containing third-party integration information. - Config param.Field[DevicePostureIntegrationNewParamsConfig] `json:"config,required"` + Config param.Field[DevicePostureIntegrationNewParamsConfigUnion] `json:"config,required"` // The interval between each posture check with the third-party API. Use `m` for // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). Interval param.Field[string] `json:"interval,required"` @@ -229,6 +228,35 @@ func (r DevicePostureIntegrationNewParams) MarshalJSON() (data []byte, err error return apijson.MarshalRoot(r) } +// The configuration object containing third-party integration information. +type DevicePostureIntegrationNewParamsConfig struct { + // The Workspace One API URL provided in the Workspace One Admin Dashboard. + APIURL param.Field[string] `json:"api_url"` + // The Workspace One Authorization URL depending on your region. + AuthURL param.Field[string] `json:"auth_url"` + // The Workspace One client ID provided in the Workspace One Admin Dashboard. + ClientID param.Field[string] `json:"client_id"` + // The Workspace One client secret provided in the Workspace One Admin Dashboard. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Crowdstrike customer ID. + CustomerID param.Field[string] `json:"customer_id"` + // The Uptycs client secret. + ClientKey param.Field[string] `json:"client_key"` + // If present, this id will be passed in the `CF-Access-Client-ID` header when + // hitting the `api_url` + AccessClientID param.Field[string] `json:"access_client_id"` + // If present, this secret will be passed in the `CF-Access-Client-Secret` header + // when hitting the `api_url` + AccessClientSecret param.Field[string] `json:"access_client_secret"` +} + +func (r DevicePostureIntegrationNewParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfig) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { +} + // The configuration object containing third-party integration information. // // Satisfied by @@ -238,9 +266,10 @@ func (r DevicePostureIntegrationNewParams) MarshalJSON() (data []byte, err error // [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest], // [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest], // [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest], -// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest]. -type DevicePostureIntegrationNewParamsConfig interface { - implementsZeroTrustDevicePostureIntegrationNewParamsConfig() +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest], +// [DevicePostureIntegrationNewParamsConfig]. +type DevicePostureIntegrationNewParamsConfigUnion interface { + implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() } type DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest struct { @@ -258,7 +287,7 @@ func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigReq return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { } type DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest struct { @@ -276,7 +305,7 @@ func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequ return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { } type DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest struct { @@ -294,7 +323,7 @@ func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { } type DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest struct { @@ -310,7 +339,7 @@ func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { } type DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest struct { @@ -324,7 +353,7 @@ func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { } type DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest struct { @@ -344,7 +373,7 @@ func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { } type DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest struct { @@ -358,7 +387,7 @@ func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigR return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfigUnion() { } // The type of device posture integration. @@ -383,9 +412,9 @@ func (r DevicePostureIntegrationNewParamsType) IsKnown() bool { } type DevicePostureIntegrationNewResponseEnvelope struct { - Errors []DevicePostureIntegrationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureIntegrationNewResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureIntegrations `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Integration `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePostureIntegrationNewResponseEnvelopeSuccess `json:"success,required"` JSON devicePostureIntegrationNewResponseEnvelopeJSON `json:"-"` @@ -410,52 +439,6 @@ func (r devicePostureIntegrationNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePostureIntegrationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureIntegrationNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DevicePostureIntegrationNewResponseEnvelopeErrors] -type devicePostureIntegrationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureIntegrationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureIntegrationNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DevicePostureIntegrationNewResponseEnvelopeMessages] -type devicePostureIntegrationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePostureIntegrationNewResponseEnvelopeSuccess bool @@ -477,12 +460,17 @@ type DevicePostureIntegrationListParams struct { type DevicePostureIntegrationDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DevicePostureIntegrationDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DevicePostureIntegrationDeleteResponseEnvelope struct { - Errors []DevicePostureIntegrationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureIntegrationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureIntegrationDeleteResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DevicePostureIntegrationDeleteResponseUnion `json:"result,required"` // Whether the API call was successful. Success DevicePostureIntegrationDeleteResponseEnvelopeSuccess `json:"success,required"` JSON devicePostureIntegrationDeleteResponseEnvelopeJSON `json:"-"` @@ -507,52 +495,6 @@ func (r devicePostureIntegrationDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePostureIntegrationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DevicePostureIntegrationDeleteResponseEnvelopeErrors] -type devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureIntegrationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DevicePostureIntegrationDeleteResponseEnvelopeMessages] -type devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePostureIntegrationDeleteResponseEnvelopeSuccess bool @@ -571,7 +513,7 @@ func (r DevicePostureIntegrationDeleteResponseEnvelopeSuccess) IsKnown() bool { type DevicePostureIntegrationEditParams struct { AccountID param.Field[string] `path:"account_id,required"` // The configuration object containing third-party integration information. - Config param.Field[DevicePostureIntegrationEditParamsConfig] `json:"config"` + Config param.Field[DevicePostureIntegrationEditParamsConfigUnion] `json:"config"` // The interval between each posture check with the third-party API. Use `m` for // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). Interval param.Field[string] `json:"interval"` @@ -585,6 +527,35 @@ func (r DevicePostureIntegrationEditParams) MarshalJSON() (data []byte, err erro return apijson.MarshalRoot(r) } +// The configuration object containing third-party integration information. +type DevicePostureIntegrationEditParamsConfig struct { + // The Workspace One API URL provided in the Workspace One Admin Dashboard. + APIURL param.Field[string] `json:"api_url"` + // The Workspace One Authorization URL depending on your region. + AuthURL param.Field[string] `json:"auth_url"` + // The Workspace One client ID provided in the Workspace One Admin Dashboard. + ClientID param.Field[string] `json:"client_id"` + // The Workspace One client secret provided in the Workspace One Admin Dashboard. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Crowdstrike customer ID. + CustomerID param.Field[string] `json:"customer_id"` + // The Uptycs client secret. + ClientKey param.Field[string] `json:"client_key"` + // If present, this id will be passed in the `CF-Access-Client-ID` header when + // hitting the `api_url` + AccessClientID param.Field[string] `json:"access_client_id"` + // If present, this secret will be passed in the `CF-Access-Client-Secret` header + // when hitting the `api_url` + AccessClientSecret param.Field[string] `json:"access_client_secret"` +} + +func (r DevicePostureIntegrationEditParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfig) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { +} + // The configuration object containing third-party integration information. // // Satisfied by @@ -594,9 +565,10 @@ func (r DevicePostureIntegrationEditParams) MarshalJSON() (data []byte, err erro // [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest], // [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest], // [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest], -// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest]. -type DevicePostureIntegrationEditParamsConfig interface { - implementsZeroTrustDevicePostureIntegrationEditParamsConfig() +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest], +// [DevicePostureIntegrationEditParamsConfig]. +type DevicePostureIntegrationEditParamsConfigUnion interface { + implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() } type DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest struct { @@ -614,7 +586,7 @@ func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRe return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { } type DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest struct { @@ -632,7 +604,7 @@ func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigReq return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { } type DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest struct { @@ -650,7 +622,7 @@ func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { } type DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest struct { @@ -666,7 +638,7 @@ func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { } type DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest struct { @@ -680,7 +652,7 @@ func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { } type DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest struct { @@ -700,7 +672,7 @@ func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest) return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { } type DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest struct { @@ -714,7 +686,7 @@ func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfig return apijson.MarshalRoot(r) } -func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfigUnion() { } // The type of device posture integration. @@ -739,9 +711,9 @@ func (r DevicePostureIntegrationEditParamsType) IsKnown() bool { } type DevicePostureIntegrationEditResponseEnvelope struct { - Errors []DevicePostureIntegrationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureIntegrationEditResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureIntegrations `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Integration `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePostureIntegrationEditResponseEnvelopeSuccess `json:"success,required"` JSON devicePostureIntegrationEditResponseEnvelopeJSON `json:"-"` @@ -766,52 +738,6 @@ func (r devicePostureIntegrationEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePostureIntegrationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureIntegrationEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DevicePostureIntegrationEditResponseEnvelopeErrors] -type devicePostureIntegrationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureIntegrationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureIntegrationEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DevicePostureIntegrationEditResponseEnvelopeMessages] -type devicePostureIntegrationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePostureIntegrationEditResponseEnvelopeSuccess bool @@ -832,9 +758,9 @@ type DevicePostureIntegrationGetParams struct { } type DevicePostureIntegrationGetResponseEnvelope struct { - Errors []DevicePostureIntegrationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DevicePostureIntegrationGetResponseEnvelopeMessages `json:"messages,required"` - Result DevicePostureIntegrations `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Integration `json:"result,required,nullable"` // Whether the API call was successful. Success DevicePostureIntegrationGetResponseEnvelopeSuccess `json:"success,required"` JSON devicePostureIntegrationGetResponseEnvelopeJSON `json:"-"` @@ -859,52 +785,6 @@ func (r devicePostureIntegrationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DevicePostureIntegrationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// devicePostureIntegrationGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DevicePostureIntegrationGetResponseEnvelopeErrors] -type devicePostureIntegrationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DevicePostureIntegrationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON devicePostureIntegrationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// devicePostureIntegrationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DevicePostureIntegrationGetResponseEnvelopeMessages] -type devicePostureIntegrationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DevicePostureIntegrationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r devicePostureIntegrationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DevicePostureIntegrationGetResponseEnvelopeSuccess bool diff --git a/zero_trust/devicepostureintegration_test.go b/zero_trust/devicepostureintegration_test.go index 8b60cf44499..dcb58a0734e 100644 --- a/zero_trust/devicepostureintegration_test.go +++ b/zero_trust/devicepostureintegration_test.go @@ -30,12 +30,12 @@ func TestDevicePostureIntegrationNewWithOptionalParams(t *testing.T) { ) _, err := client.ZeroTrust.Devices.Posture.Integrations.New(context.TODO(), zero_trust.DevicePostureIntegrationNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Config: cloudflare.F[zero_trust.DevicePostureIntegrationNewParamsConfig](zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest(zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ + Config: cloudflare.F[zero_trust.DevicePostureIntegrationNewParamsConfigUnion](zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ APIURL: cloudflare.F("https://as123.awmdm.com/API"), AuthURL: cloudflare.F("https://na.uemauth.vmwservices.com/connect/token"), ClientID: cloudflare.F("example client id"), ClientSecret: cloudflare.F("example client secret"), - })), + }), Interval: cloudflare.F("10m"), Name: cloudflare.F("My Workspace One Integration"), Type: cloudflare.F(zero_trust.DevicePostureIntegrationNewParamsTypeWorkspaceOne), @@ -94,6 +94,7 @@ func TestDevicePostureIntegrationDelete(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.DevicePostureIntegrationDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -124,12 +125,12 @@ func TestDevicePostureIntegrationEditWithOptionalParams(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.DevicePostureIntegrationEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Config: cloudflare.F[zero_trust.DevicePostureIntegrationEditParamsConfig](zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest(zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ + Config: cloudflare.F[zero_trust.DevicePostureIntegrationEditParamsConfigUnion](zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ APIURL: cloudflare.F("https://as123.awmdm.com/API"), AuthURL: cloudflare.F("https://na.uemauth.vmwservices.com/connect/token"), ClientID: cloudflare.F("example client id"), ClientSecret: cloudflare.F("example client secret"), - })), + }), Interval: cloudflare.F("10m"), Name: cloudflare.F("My Workspace One Integration"), Type: cloudflare.F(zero_trust.DevicePostureIntegrationEditParamsTypeWorkspaceOne), diff --git a/zero_trust/devicerevoke.go b/zero_trust/devicerevoke.go index cd28e4d32c6..6dfeef73042 100644 --- a/zero_trust/devicerevoke.go +++ b/zero_trust/devicerevoke.go @@ -35,7 +35,7 @@ func NewDeviceRevokeService(opts ...option.RequestOption) (r *DeviceRevokeServic } // Revokes a list of devices. -func (r *DeviceRevokeService) New(ctx context.Context, params DeviceRevokeNewParams, opts ...option.RequestOption) (res *DeviceRevokeNewResponse, err error) { +func (r *DeviceRevokeService) New(ctx context.Context, params DeviceRevokeNewParams, opts ...option.RequestOption) (res *DeviceRevokeNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DeviceRevokeNewResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/revoke", params.AccountID) @@ -49,13 +49,13 @@ func (r *DeviceRevokeService) New(ctx context.Context, params DeviceRevokeNewPar // Union satisfied by [zero_trust.DeviceRevokeNewResponseUnknown] or // [shared.UnionString]. -type DeviceRevokeNewResponse interface { - ImplementsZeroTrustDeviceRevokeNewResponse() +type DeviceRevokeNewResponseUnion interface { + ImplementsZeroTrustDeviceRevokeNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DeviceRevokeNewResponse)(nil)).Elem(), + reflect.TypeOf((*DeviceRevokeNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -67,7 +67,7 @@ func init() { type DeviceRevokeNewParams struct { AccountID param.Field[string] `path:"account_id,required"` // A list of device ids to revoke. - Body param.Field[[]string] `json:"body,required"` + Body []string `json:"body,required"` } func (r DeviceRevokeNewParams) MarshalJSON() (data []byte, err error) { @@ -75,9 +75,9 @@ func (r DeviceRevokeNewParams) MarshalJSON() (data []byte, err error) { } type DeviceRevokeNewResponseEnvelope struct { - Errors []DeviceRevokeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceRevokeNewResponseEnvelopeMessages `json:"messages,required"` - Result DeviceRevokeNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceRevokeNewResponseUnion `json:"result,required"` // Whether the API call was successful. Success DeviceRevokeNewResponseEnvelopeSuccess `json:"success,required"` JSON deviceRevokeNewResponseEnvelopeJSON `json:"-"` @@ -102,52 +102,6 @@ func (r deviceRevokeNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceRevokeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceRevokeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceRevokeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceRevokeNewResponseEnvelopeErrors] -type deviceRevokeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceRevokeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceRevokeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceRevokeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceRevokeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceRevokeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DeviceRevokeNewResponseEnvelopeMessages] -type deviceRevokeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceRevokeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceRevokeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceRevokeNewResponseEnvelopeSuccess bool diff --git a/zero_trust/devicerevoke_test.go b/zero_trust/devicerevoke_test.go index 5937a6e35fa..91b21b1a4ca 100644 --- a/zero_trust/devicerevoke_test.go +++ b/zero_trust/devicerevoke_test.go @@ -30,7 +30,7 @@ func TestDeviceRevokeNew(t *testing.T) { ) _, err := client.ZeroTrust.Devices.Revoke.New(context.TODO(), zero_trust.DeviceRevokeNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}), + Body: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}, }) if err != nil { var apierr *cloudflare.Error diff --git a/zero_trust/devicesetting.go b/zero_trust/devicesetting.go index f3177392f9c..8238a8f3d96 100644 --- a/zero_trust/devicesetting.go +++ b/zero_trust/devicesetting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewDeviceSettingService(opts ...option.RequestOption) (r *DeviceSettingServ } // Updates the current device settings for a Zero Trust account. -func (r *DeviceSettingService) Update(ctx context.Context, params DeviceSettingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccountDeviceSettings, err error) { +func (r *DeviceSettingService) Update(ctx context.Context, params DeviceSettingUpdateParams, opts ...option.RequestOption) (res *DeviceSettings, err error) { opts = append(r.Options[:], opts...) var env DeviceSettingUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/settings", params.AccountID) @@ -45,7 +46,7 @@ func (r *DeviceSettingService) Update(ctx context.Context, params DeviceSettingU } // Describes the current device settings for a Zero Trust account. -func (r *DeviceSettingService) List(ctx context.Context, query DeviceSettingListParams, opts ...option.RequestOption) (res *ZeroTrustAccountDeviceSettings, err error) { +func (r *DeviceSettingService) List(ctx context.Context, query DeviceSettingListParams, opts ...option.RequestOption) (res *DeviceSettings, err error) { opts = append(r.Options[:], opts...) var env DeviceSettingListResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/settings", query.AccountID) @@ -57,7 +58,7 @@ func (r *DeviceSettingService) List(ctx context.Context, query DeviceSettingList return } -type ZeroTrustAccountDeviceSettings struct { +type DeviceSettings struct { // Enable gateway proxy filtering on TCP. GatewayProxyEnabled bool `json:"gateway_proxy_enabled"` // Enable gateway proxy filtering on UDP. @@ -65,13 +66,12 @@ type ZeroTrustAccountDeviceSettings struct { // Enable installation of cloudflare managed root certificate. RootCertificateInstallationEnabled bool `json:"root_certificate_installation_enabled"` // Enable using CGNAT virtual IPv4. - UseZtVirtualIP bool `json:"use_zt_virtual_ip"` - JSON zeroTrustAccountDeviceSettingsJSON `json:"-"` + UseZtVirtualIP bool `json:"use_zt_virtual_ip"` + JSON deviceSettingsJSON `json:"-"` } -// zeroTrustAccountDeviceSettingsJSON contains the JSON metadata for the struct -// [ZeroTrustAccountDeviceSettings] -type zeroTrustAccountDeviceSettingsJSON struct { +// deviceSettingsJSON contains the JSON metadata for the struct [DeviceSettings] +type deviceSettingsJSON struct { GatewayProxyEnabled apijson.Field GatewayUdpProxyEnabled apijson.Field RootCertificateInstallationEnabled apijson.Field @@ -80,16 +80,15 @@ type zeroTrustAccountDeviceSettingsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustAccountDeviceSettings) UnmarshalJSON(data []byte) (err error) { +func (r *DeviceSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustAccountDeviceSettingsJSON) RawJSON() string { +func (r deviceSettingsJSON) RawJSON() string { return r.raw } -type DeviceSettingUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` +type DeviceSettingsParam struct { // Enable gateway proxy filtering on TCP. GatewayProxyEnabled param.Field[bool] `json:"gateway_proxy_enabled"` // Enable gateway proxy filtering on UDP. @@ -100,14 +99,23 @@ type DeviceSettingUpdateParams struct { UseZtVirtualIP param.Field[bool] `json:"use_zt_virtual_ip"` } -func (r DeviceSettingUpdateParams) MarshalJSON() (data []byte, err error) { +func (r DeviceSettingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +type DeviceSettingUpdateParams struct { + AccountID param.Field[string] `path:"account_id,required"` + DeviceSettings DeviceSettingsParam `json:"device_settings,required"` +} + +func (r DeviceSettingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.DeviceSettings) +} + type DeviceSettingUpdateResponseEnvelope struct { - Errors []DeviceSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccountDeviceSettings `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceSettings `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceSettingUpdateResponseEnvelopeSuccess `json:"success,required"` JSON deviceSettingUpdateResponseEnvelopeJSON `json:"-"` @@ -132,52 +140,6 @@ func (r deviceSettingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceSettingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceSettingUpdateResponseEnvelopeErrors] -type deviceSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceSettingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DeviceSettingUpdateResponseEnvelopeMessages] -type deviceSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceSettingUpdateResponseEnvelopeSuccess bool @@ -198,9 +160,9 @@ type DeviceSettingListParams struct { } type DeviceSettingListResponseEnvelope struct { - Errors []DeviceSettingListResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceSettingListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccountDeviceSettings `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceSettings `json:"result,required,nullable"` // Whether the API call was successful. Success DeviceSettingListResponseEnvelopeSuccess `json:"success,required"` JSON deviceSettingListResponseEnvelopeJSON `json:"-"` @@ -225,52 +187,6 @@ func (r deviceSettingListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceSettingListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceSettingListResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceSettingListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceSettingListResponseEnvelopeErrors] -type deviceSettingListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceSettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceSettingListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceSettingListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceSettingListResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceSettingListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DeviceSettingListResponseEnvelopeMessages] -type deviceSettingListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceSettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceSettingListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceSettingListResponseEnvelopeSuccess bool diff --git a/zero_trust/devicesetting_test.go b/zero_trust/devicesetting_test.go index 16ef4ca63be..3ccd554d41c 100644 --- a/zero_trust/devicesetting_test.go +++ b/zero_trust/devicesetting_test.go @@ -29,11 +29,13 @@ func TestDeviceSettingUpdateWithOptionalParams(t *testing.T) { option.WithAPIEmail("user@example.com"), ) _, err := client.ZeroTrust.Devices.Settings.Update(context.TODO(), zero_trust.DeviceSettingUpdateParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - GatewayProxyEnabled: cloudflare.F(true), - GatewayUdpProxyEnabled: cloudflare.F(true), - RootCertificateInstallationEnabled: cloudflare.F(true), - UseZtVirtualIP: cloudflare.F(true), + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + DeviceSettings: zero_trust.DeviceSettingsParam{ + GatewayProxyEnabled: cloudflare.F(true), + GatewayUdpProxyEnabled: cloudflare.F(true), + RootCertificateInstallationEnabled: cloudflare.F(true), + UseZtVirtualIP: cloudflare.F(true), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/zero_trust/deviceunrevoke.go b/zero_trust/deviceunrevoke.go index 872b2409b0d..f2bcd4e770d 100644 --- a/zero_trust/deviceunrevoke.go +++ b/zero_trust/deviceunrevoke.go @@ -35,7 +35,7 @@ func NewDeviceUnrevokeService(opts ...option.RequestOption) (r *DeviceUnrevokeSe } // Unrevokes a list of devices. -func (r *DeviceUnrevokeService) New(ctx context.Context, params DeviceUnrevokeNewParams, opts ...option.RequestOption) (res *DeviceUnrevokeNewResponse, err error) { +func (r *DeviceUnrevokeService) New(ctx context.Context, params DeviceUnrevokeNewParams, opts ...option.RequestOption) (res *DeviceUnrevokeNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DeviceUnrevokeNewResponseEnvelope path := fmt.Sprintf("accounts/%s/devices/unrevoke", params.AccountID) @@ -49,13 +49,13 @@ func (r *DeviceUnrevokeService) New(ctx context.Context, params DeviceUnrevokeNe // Union satisfied by [zero_trust.DeviceUnrevokeNewResponseUnknown] or // [shared.UnionString]. -type DeviceUnrevokeNewResponse interface { - ImplementsZeroTrustDeviceUnrevokeNewResponse() +type DeviceUnrevokeNewResponseUnion interface { + ImplementsZeroTrustDeviceUnrevokeNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DeviceUnrevokeNewResponse)(nil)).Elem(), + reflect.TypeOf((*DeviceUnrevokeNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -67,7 +67,7 @@ func init() { type DeviceUnrevokeNewParams struct { AccountID param.Field[string] `path:"account_id,required"` // A list of device ids to unrevoke. - Body param.Field[[]string] `json:"body,required"` + Body []string `json:"body,required"` } func (r DeviceUnrevokeNewParams) MarshalJSON() (data []byte, err error) { @@ -75,9 +75,9 @@ func (r DeviceUnrevokeNewParams) MarshalJSON() (data []byte, err error) { } type DeviceUnrevokeNewResponseEnvelope struct { - Errors []DeviceUnrevokeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DeviceUnrevokeNewResponseEnvelopeMessages `json:"messages,required"` - Result DeviceUnrevokeNewResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DeviceUnrevokeNewResponseUnion `json:"result,required"` // Whether the API call was successful. Success DeviceUnrevokeNewResponseEnvelopeSuccess `json:"success,required"` JSON deviceUnrevokeNewResponseEnvelopeJSON `json:"-"` @@ -102,52 +102,6 @@ func (r deviceUnrevokeNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DeviceUnrevokeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceUnrevokeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// deviceUnrevokeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DeviceUnrevokeNewResponseEnvelopeErrors] -type deviceUnrevokeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceUnrevokeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceUnrevokeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DeviceUnrevokeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON deviceUnrevokeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// deviceUnrevokeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DeviceUnrevokeNewResponseEnvelopeMessages] -type deviceUnrevokeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DeviceUnrevokeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r deviceUnrevokeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful. type DeviceUnrevokeNewResponseEnvelopeSuccess bool diff --git a/zero_trust/deviceunrevoke_test.go b/zero_trust/deviceunrevoke_test.go index 4536f0f66ef..5c0c8cf4822 100644 --- a/zero_trust/deviceunrevoke_test.go +++ b/zero_trust/deviceunrevoke_test.go @@ -30,7 +30,7 @@ func TestDeviceUnrevokeNew(t *testing.T) { ) _, err := client.ZeroTrust.Devices.Unrevoke.New(context.TODO(), zero_trust.DeviceUnrevokeNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}), + Body: []string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}, }) if err != nil { var apierr *cloudflare.Error diff --git a/zero_trust/dex.go b/zero_trust/dex.go index 067e73a263a..7f9a503bfbc 100644 --- a/zero_trust/dex.go +++ b/zero_trust/dex.go @@ -3,6 +3,7 @@ package zero_trust import ( + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -34,3 +35,210 @@ func NewDEXService(opts ...option.RequestOption) (r *DEXService) { r.TracerouteTests = NewDEXTracerouteTestService(opts...) return } + +type DeviceExperienceMonitor struct { + ID string `json:"id,required"` + // Whether the policy is the default for the account + Default bool `json:"default,required"` + Name string `json:"name,required"` + JSON deviceExperienceMonitorJSON `json:"-"` +} + +// deviceExperienceMonitorJSON contains the JSON metadata for the struct +// [DeviceExperienceMonitor] +type deviceExperienceMonitorJSON struct { + ID apijson.Field + Default apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceExperienceMonitor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceExperienceMonitorJSON) RawJSON() string { + return r.raw +} + +type NetworkPath struct { + // API Resource UUID tag. + ID string `json:"id,required"` + DeviceName string `json:"deviceName"` + // The interval at which the Traceroute synthetic application test is set to run. + Interval string `json:"interval"` + Kind NetworkPathKind `json:"kind"` + Name string `json:"name"` + NetworkPath NetworkPathNetworkPath `json:"networkPath,nullable"` + // The host of the Traceroute synthetic application test + URL string `json:"url"` + JSON networkPathJSON `json:"-"` +} + +// networkPathJSON contains the JSON metadata for the struct [NetworkPath] +type networkPathJSON struct { + ID apijson.Field + DeviceName apijson.Field + Interval apijson.Field + Kind apijson.Field + Name apijson.Field + NetworkPath apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkPath) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkPathJSON) RawJSON() string { + return r.raw +} + +type NetworkPathKind string + +const ( + NetworkPathKindTraceroute NetworkPathKind = "traceroute" +) + +func (r NetworkPathKind) IsKnown() bool { + switch r { + case NetworkPathKindTraceroute: + return true + } + return false +} + +type NetworkPathNetworkPath struct { + Slots []NetworkPathNetworkPathSlot `json:"slots,required"` + // Specifies the sampling applied, if any, to the slots response. When sampled, + // results shown represent the first test run to the start of each sampling + // interval. + Sampling NetworkPathNetworkPathSampling `json:"sampling,nullable"` + JSON networkPathNetworkPathJSON `json:"-"` +} + +// networkPathNetworkPathJSON contains the JSON metadata for the struct +// [NetworkPathNetworkPath] +type networkPathNetworkPathJSON struct { + Slots apijson.Field + Sampling apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkPathNetworkPath) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkPathNetworkPathJSON) RawJSON() string { + return r.raw +} + +type NetworkPathNetworkPathSlot struct { + // API Resource UUID tag. + ID string `json:"id,required"` + // Round trip time in ms of the client to app mile + ClientToAppRTTMs int64 `json:"clientToAppRttMs,required,nullable"` + // Round trip time in ms of the client to Cloudflare egress mile + ClientToCfEgressRTTMs int64 `json:"clientToCfEgressRttMs,required,nullable"` + // Round trip time in ms of the client to Cloudflare ingress mile + ClientToCfIngressRTTMs int64 `json:"clientToCfIngressRttMs,required,nullable"` + Timestamp string `json:"timestamp,required"` + // Round trip time in ms of the client to ISP mile + ClientToIspRTTMs int64 `json:"clientToIspRttMs,nullable"` + JSON networkPathNetworkPathSlotJSON `json:"-"` +} + +// networkPathNetworkPathSlotJSON contains the JSON metadata for the struct +// [NetworkPathNetworkPathSlot] +type networkPathNetworkPathSlotJSON struct { + ID apijson.Field + ClientToAppRTTMs apijson.Field + ClientToCfEgressRTTMs apijson.Field + ClientToCfIngressRTTMs apijson.Field + Timestamp apijson.Field + ClientToIspRTTMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkPathNetworkPathSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkPathNetworkPathSlotJSON) RawJSON() string { + return r.raw +} + +// Specifies the sampling applied, if any, to the slots response. When sampled, +// results shown represent the first test run to the start of each sampling +// interval. +type NetworkPathNetworkPathSampling struct { + Unit NetworkPathNetworkPathSamplingUnit `json:"unit,required"` + Value int64 `json:"value,required"` + JSON networkPathNetworkPathSamplingJSON `json:"-"` +} + +// networkPathNetworkPathSamplingJSON contains the JSON metadata for the struct +// [NetworkPathNetworkPathSampling] +type networkPathNetworkPathSamplingJSON struct { + Unit apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkPathNetworkPathSampling) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkPathNetworkPathSamplingJSON) RawJSON() string { + return r.raw +} + +type NetworkPathNetworkPathSamplingUnit string + +const ( + NetworkPathNetworkPathSamplingUnitHours NetworkPathNetworkPathSamplingUnit = "hours" +) + +func (r NetworkPathNetworkPathSamplingUnit) IsKnown() bool { + switch r { + case NetworkPathNetworkPathSamplingUnitHours: + return true + } + return false +} + +type Percentiles struct { + // p50 observed in the time period + P50 float64 `json:"p50,nullable"` + // p90 observed in the time period + P90 float64 `json:"p90,nullable"` + // p95 observed in the time period + P95 float64 `json:"p95,nullable"` + // p99 observed in the time period + P99 float64 `json:"p99,nullable"` + JSON percentilesJSON `json:"-"` +} + +// percentilesJSON contains the JSON metadata for the struct [Percentiles] +type percentilesJSON struct { + P50 apijson.Field + P90 apijson.Field + P95 apijson.Field + P99 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Percentiles) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r percentilesJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/dexcolo.go b/zero_trust/dexcolo.go index 82af5930321..6375b3bf6ba 100644 --- a/zero_trust/dexcolo.go +++ b/zero_trust/dexcolo.go @@ -75,7 +75,7 @@ type DEXColoListParams struct { // URLQuery serializes [DEXColoListParams]'s query parameters as `url.Values`. func (r DEXColoListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/zero_trust/dexfleetstatus.go b/zero_trust/dexfleetstatus.go index c01d7ea2119..6fe89f787a4 100644 --- a/zero_trust/dexfleetstatus.go +++ b/zero_trust/dexfleetstatus.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -57,6 +58,29 @@ func (r *DEXFleetStatusService) OverTime(ctx context.Context, params DEXFleetSta return } +type LiveStat struct { + // Number of unique devices + UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` + Value string `json:"value"` + JSON liveStatJSON `json:"-"` +} + +// liveStatJSON contains the JSON metadata for the struct [LiveStat] +type liveStatJSON struct { + UniqueDevicesTotal apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveStat) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveStatJSON) RawJSON() string { + return r.raw +} + type DEXFleetStatusLiveResponse struct { DeviceStats DEXFleetStatusLiveResponseDeviceStats `json:"deviceStats"` JSON dexFleetStatusLiveResponseJSON `json:"-"` @@ -79,11 +103,11 @@ func (r dexFleetStatusLiveResponseJSON) RawJSON() string { } type DEXFleetStatusLiveResponseDeviceStats struct { - ByColo []DEXFleetStatusLiveResponseDeviceStatsByColo `json:"byColo,nullable"` - ByMode []DEXFleetStatusLiveResponseDeviceStatsByMode `json:"byMode,nullable"` - ByPlatform []DEXFleetStatusLiveResponseDeviceStatsByPlatform `json:"byPlatform,nullable"` - ByStatus []DEXFleetStatusLiveResponseDeviceStatsByStatus `json:"byStatus,nullable"` - ByVersion []DEXFleetStatusLiveResponseDeviceStatsByVersion `json:"byVersion,nullable"` + ByColo []LiveStat `json:"byColo,nullable"` + ByMode []LiveStat `json:"byMode,nullable"` + ByPlatform []LiveStat `json:"byPlatform,nullable"` + ByStatus []LiveStat `json:"byStatus,nullable"` + ByVersion []LiveStat `json:"byVersion,nullable"` // Number of unique devices UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` JSON dexFleetStatusLiveResponseDeviceStatsJSON `json:"-"` @@ -110,126 +134,6 @@ func (r dexFleetStatusLiveResponseDeviceStatsJSON) RawJSON() string { return r.raw } -type DEXFleetStatusLiveResponseDeviceStatsByColo struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON dexFleetStatusLiveResponseDeviceStatsByColoJSON `json:"-"` -} - -// dexFleetStatusLiveResponseDeviceStatsByColoJSON contains the JSON metadata for -// the struct [DEXFleetStatusLiveResponseDeviceStatsByColo] -type dexFleetStatusLiveResponseDeviceStatsByColoJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXFleetStatusLiveResponseDeviceStatsByColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexFleetStatusLiveResponseDeviceStatsByColoJSON) RawJSON() string { - return r.raw -} - -type DEXFleetStatusLiveResponseDeviceStatsByMode struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON dexFleetStatusLiveResponseDeviceStatsByModeJSON `json:"-"` -} - -// dexFleetStatusLiveResponseDeviceStatsByModeJSON contains the JSON metadata for -// the struct [DEXFleetStatusLiveResponseDeviceStatsByMode] -type dexFleetStatusLiveResponseDeviceStatsByModeJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXFleetStatusLiveResponseDeviceStatsByMode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexFleetStatusLiveResponseDeviceStatsByModeJSON) RawJSON() string { - return r.raw -} - -type DEXFleetStatusLiveResponseDeviceStatsByPlatform struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON dexFleetStatusLiveResponseDeviceStatsByPlatformJSON `json:"-"` -} - -// dexFleetStatusLiveResponseDeviceStatsByPlatformJSON contains the JSON metadata -// for the struct [DEXFleetStatusLiveResponseDeviceStatsByPlatform] -type dexFleetStatusLiveResponseDeviceStatsByPlatformJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXFleetStatusLiveResponseDeviceStatsByPlatform) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexFleetStatusLiveResponseDeviceStatsByPlatformJSON) RawJSON() string { - return r.raw -} - -type DEXFleetStatusLiveResponseDeviceStatsByStatus struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON dexFleetStatusLiveResponseDeviceStatsByStatusJSON `json:"-"` -} - -// dexFleetStatusLiveResponseDeviceStatsByStatusJSON contains the JSON metadata for -// the struct [DEXFleetStatusLiveResponseDeviceStatsByStatus] -type dexFleetStatusLiveResponseDeviceStatsByStatusJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXFleetStatusLiveResponseDeviceStatsByStatus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexFleetStatusLiveResponseDeviceStatsByStatusJSON) RawJSON() string { - return r.raw -} - -type DEXFleetStatusLiveResponseDeviceStatsByVersion struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON dexFleetStatusLiveResponseDeviceStatsByVersionJSON `json:"-"` -} - -// dexFleetStatusLiveResponseDeviceStatsByVersionJSON contains the JSON metadata -// for the struct [DEXFleetStatusLiveResponseDeviceStatsByVersion] -type dexFleetStatusLiveResponseDeviceStatsByVersionJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXFleetStatusLiveResponseDeviceStatsByVersion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexFleetStatusLiveResponseDeviceStatsByVersionJSON) RawJSON() string { - return r.raw -} - type DEXFleetStatusLiveParams struct { AccountID param.Field[string] `path:"account_id,required"` // Number of minutes before current time @@ -240,15 +144,15 @@ type DEXFleetStatusLiveParams struct { // `url.Values`. func (r DEXFleetStatusLiveParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DEXFleetStatusLiveResponseEnvelope struct { - Errors []DEXFleetStatusLiveResponseEnvelopeErrors `json:"errors,required"` - Messages []DEXFleetStatusLiveResponseEnvelopeMessages `json:"messages,required"` - Result DEXFleetStatusLiveResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DEXFleetStatusLiveResponse `json:"result,required"` // Whether the API call was successful Success DEXFleetStatusLiveResponseEnvelopeSuccess `json:"success,required"` JSON dexFleetStatusLiveResponseEnvelopeJSON `json:"-"` @@ -273,52 +177,6 @@ func (r dexFleetStatusLiveResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DEXFleetStatusLiveResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexFleetStatusLiveResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexFleetStatusLiveResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DEXFleetStatusLiveResponseEnvelopeErrors] -type dexFleetStatusLiveResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXFleetStatusLiveResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexFleetStatusLiveResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DEXFleetStatusLiveResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexFleetStatusLiveResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexFleetStatusLiveResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DEXFleetStatusLiveResponseEnvelopeMessages] -type dexFleetStatusLiveResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXFleetStatusLiveResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexFleetStatusLiveResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DEXFleetStatusLiveResponseEnvelopeSuccess bool @@ -350,7 +208,7 @@ type DEXFleetStatusOverTimeParams struct { // `url.Values`. func (r DEXFleetStatusOverTimeParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/zero_trust/dexfleetstatusdevice.go b/zero_trust/dexfleetstatusdevice.go index a62ac3ab4ba..062f0a97f30 100644 --- a/zero_trust/dexfleetstatusdevice.go +++ b/zero_trust/dexfleetstatusdevice.go @@ -35,7 +35,7 @@ func NewDEXFleetStatusDeviceService(opts ...option.RequestOption) (r *DEXFleetSt } // List details for devices using WARP -func (r *DEXFleetStatusDeviceService) List(ctx context.Context, params DEXFleetStatusDeviceListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DigitalExperienceMonitoringDevice], err error) { +func (r *DEXFleetStatusDeviceService) List(ctx context.Context, params DEXFleetStatusDeviceListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DEXFleetStatusDeviceListResponse], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -53,35 +53,39 @@ func (r *DEXFleetStatusDeviceService) List(ctx context.Context, params DEXFleetS } // List details for devices using WARP -func (r *DEXFleetStatusDeviceService) ListAutoPaging(ctx context.Context, params DEXFleetStatusDeviceListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DigitalExperienceMonitoringDevice] { +func (r *DEXFleetStatusDeviceService) ListAutoPaging(ctx context.Context, params DEXFleetStatusDeviceListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DEXFleetStatusDeviceListResponse] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } -type DigitalExperienceMonitoringDevice struct { +type DEXFleetStatusDeviceListResponse struct { // Cloudflare colo Colo string `json:"colo,required"` // Device identifier (UUID v4) - DeviceID string `json:"deviceId,required"` + DeviceID string `json:"deviceId,required"` + Mode interface{} `json:"mode,required"` // Operating system Platform string `json:"platform,required"` // Network status - Status string `json:"status,required"` + Status string `json:"status,required"` + Timestamp interface{} `json:"timestamp,required"` // WARP client version Version string `json:"version,required"` // Device identifier (human readable) DeviceName string `json:"deviceName"` // User contact email address - PersonEmail string `json:"personEmail"` - JSON digitalExperienceMonitoringDeviceJSON `json:"-"` + PersonEmail string `json:"personEmail"` + JSON dexFleetStatusDeviceListResponseJSON `json:"-"` } -// digitalExperienceMonitoringDeviceJSON contains the JSON metadata for the struct -// [DigitalExperienceMonitoringDevice] -type digitalExperienceMonitoringDeviceJSON struct { +// dexFleetStatusDeviceListResponseJSON contains the JSON metadata for the struct +// [DEXFleetStatusDeviceListResponse] +type dexFleetStatusDeviceListResponseJSON struct { Colo apijson.Field DeviceID apijson.Field + Mode apijson.Field Platform apijson.Field Status apijson.Field + Timestamp apijson.Field Version apijson.Field DeviceName apijson.Field PersonEmail apijson.Field @@ -89,11 +93,11 @@ type digitalExperienceMonitoringDeviceJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringDevice) UnmarshalJSON(data []byte) (err error) { +func (r *DEXFleetStatusDeviceListResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringDeviceJSON) RawJSON() string { +func (r dexFleetStatusDeviceListResponseJSON) RawJSON() string { return r.raw } @@ -127,7 +131,7 @@ type DEXFleetStatusDeviceListParams struct { // `url.Values`. func (r DEXFleetStatusDeviceListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/zero_trust/dexhttptest.go b/zero_trust/dexhttptest.go index a16d24dddc3..2230b301a93 100644 --- a/zero_trust/dexhttptest.go +++ b/zero_trust/dexhttptest.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -37,7 +38,7 @@ func NewDEXHTTPTestService(opts ...option.RequestOption) (r *DEXHTTPTestService) // Get test details and aggregate performance metrics for an http test for a given // time period between 1 hour and 7 days. -func (r *DEXHTTPTestService) Get(ctx context.Context, testID string, params DEXHTTPTestGetParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringHTTPDetails, err error) { +func (r *DEXHTTPTestService) Get(ctx context.Context, testID string, params DEXHTTPTestGetParams, opts ...option.RequestOption) (res *HTTPDetails, err error) { opts = append(r.Options[:], opts...) var env DexhttpTestGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dex/http-tests/%s", params.AccountID, testID) @@ -49,24 +50,25 @@ func (r *DEXHTTPTestService) Get(ctx context.Context, testID string, params DEXH return } -type DigitalExperienceMonitoringHTTPDetails struct { +type HTTPDetails struct { // The url of the HTTP synthetic application test - Host string `json:"host"` - HTTPStats DigitalExperienceMonitoringHTTPDetailsHTTPStats `json:"httpStats,nullable"` - HTTPStatsByColo []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo `json:"httpStatsByColo"` + Host string `json:"host"` + HTTPStats HTTPDetailsHTTPStats `json:"httpStats,nullable"` + HTTPStatsByColo []HTTPDetailsHTTPStatsByColo `json:"httpStatsByColo"` // The interval at which the HTTP synthetic application test is set to run. - Interval string `json:"interval"` - Kind DigitalExperienceMonitoringHTTPDetailsKind `json:"kind"` + Interval string `json:"interval"` + Kind HTTPDetailsKind `json:"kind"` // The HTTP method to use when running the test Method string `json:"method"` // The name of the HTTP synthetic application test - Name string `json:"name"` - JSON digitalExperienceMonitoringHTTPDetailsJSON `json:"-"` + Name string `json:"name"` + TargetPolicies []DeviceExperienceMonitor `json:"target_policies,nullable"` + Targeted bool `json:"targeted"` + JSON httpDetailsJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsJSON contains the JSON metadata for the -// struct [DigitalExperienceMonitoringHTTPDetails] -type digitalExperienceMonitoringHTTPDetailsJSON struct { +// httpDetailsJSON contains the JSON metadata for the struct [HTTPDetails] +type httpDetailsJSON struct { Host apijson.Field HTTPStats apijson.Field HTTPStatsByColo apijson.Field @@ -74,31 +76,35 @@ type digitalExperienceMonitoringHTTPDetailsJSON struct { Kind apijson.Field Method apijson.Field Name apijson.Field + TargetPolicies apijson.Field + Targeted apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetails) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetails) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsJSON) RawJSON() string { +func (r httpDetailsJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStats struct { - DNSResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs `json:"dnsResponseTimeMs,required"` - HTTPStatusCode []DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode `json:"httpStatusCode,required"` - ResourceFetchTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs `json:"resourceFetchTimeMs,required"` - ServerResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs `json:"serverResponseTimeMs,required"` +type HTTPDetailsHTTPStats struct { + AvailabilityPct HTTPDetailsHTTPStatsAvailabilityPct `json:"availabilityPct,required"` + DNSResponseTimeMs TestStatOverTime `json:"dnsResponseTimeMs,required"` + HTTPStatusCode []HTTPDetailsHTTPStatsHTTPStatusCode `json:"httpStatusCode,required"` + ResourceFetchTimeMs TestStatOverTime `json:"resourceFetchTimeMs,required"` + ServerResponseTimeMs TestStatOverTime `json:"serverResponseTimeMs,required"` // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON `json:"-"` + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON httpDetailsHTTPStatsJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON contains the JSON metadata -// for the struct [DigitalExperienceMonitoringHTTPDetailsHTTPStats] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON struct { +// httpDetailsHTTPStatsJSON contains the JSON metadata for the struct +// [HTTPDetailsHTTPStats] +type httpDetailsHTTPStatsJSON struct { + AvailabilityPct apijson.Field DNSResponseTimeMs apijson.Field HTTPStatusCode apijson.Field ResourceFetchTimeMs apijson.Field @@ -108,29 +114,28 @@ type digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStats) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStats) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON) RawJSON() string { +func (r httpDetailsHTTPStatsJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs struct { - Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot `json:"slots,required"` +type HTTPDetailsHTTPStatsAvailabilityPct struct { + Slots []HTTPDetailsHTTPStatsAvailabilityPctSlot `json:"slots,required"` // average observed in the time period - Avg int64 `json:"avg,nullable"` + Avg float64 `json:"avg,nullable"` // highest observed in the time period - Max int64 `json:"max,nullable"` + Max float64 `json:"max,nullable"` // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON `json:"-"` + Min float64 `json:"min,nullable"` + JSON httpDetailsHTTPStatsAvailabilityPctJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON struct { +// httpDetailsHTTPStatsAvailabilityPctJSON contains the JSON metadata for the +// struct [HTTPDetailsHTTPStatsAvailabilityPct] +type httpDetailsHTTPStatsAvailabilityPctJSON struct { Slots apijson.Field Avg apijson.Field Max apijson.Field @@ -139,51 +144,49 @@ type digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON struct ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStatsAvailabilityPct) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON) RawJSON() string { +func (r httpDetailsHTTPStatsAvailabilityPctJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON `json:"-"` +type HTTPDetailsHTTPStatsAvailabilityPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON httpDetailsHTTPStatsAvailabilityPctSlotJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON struct { +// httpDetailsHTTPStatsAvailabilityPctSlotJSON contains the JSON metadata for the +// struct [HTTPDetailsHTTPStatsAvailabilityPctSlot] +type httpDetailsHTTPStatsAvailabilityPctSlotJSON struct { Timestamp apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStatsAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON) RawJSON() string { +func (r httpDetailsHTTPStatsAvailabilityPctSlotJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode struct { - Status200 int64 `json:"status200,required"` - Status300 int64 `json:"status300,required"` - Status400 int64 `json:"status400,required"` - Status500 int64 `json:"status500,required"` - Timestamp string `json:"timestamp,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON `json:"-"` +type HTTPDetailsHTTPStatsHTTPStatusCode struct { + Status200 int64 `json:"status200,required"` + Status300 int64 `json:"status300,required"` + Status400 int64 `json:"status400,required"` + Status500 int64 `json:"status500,required"` + Timestamp string `json:"timestamp,required"` + JSON httpDetailsHTTPStatsHTTPStatusCodeJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON contains the -// JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON struct { +// httpDetailsHTTPStatsHTTPStatusCodeJSON contains the JSON metadata for the struct +// [HTTPDetailsHTTPStatsHTTPStatusCode] +type httpDetailsHTTPStatsHTTPStatusCodeJSON struct { Status200 apijson.Field Status300 apijson.Field Status400 apijson.Field @@ -193,138 +196,30 @@ type digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStatsHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON) RawJSON() string { +func (r httpDetailsHTTPStatsHTTPStatusCodeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs struct { - Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs struct { - Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo struct { - Colo string `json:"colo,required"` - DNSResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs `json:"dnsResponseTimeMs,required"` - HTTPStatusCode []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode `json:"httpStatusCode,required"` - ResourceFetchTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs `json:"resourceFetchTimeMs,required"` - ServerResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs `json:"serverResponseTimeMs,required"` +type HTTPDetailsHTTPStatsByColo struct { + AvailabilityPct HTTPDetailsHTTPStatsByColoAvailabilityPct `json:"availabilityPct,required"` + Colo string `json:"colo,required"` + DNSResponseTimeMs TestStatOverTime `json:"dnsResponseTimeMs,required"` + HTTPStatusCode []HTTPDetailsHTTPStatsByColoHTTPStatusCode `json:"httpStatusCode,required"` + ResourceFetchTimeMs TestStatOverTime `json:"resourceFetchTimeMs,required"` + ServerResponseTimeMs TestStatOverTime `json:"serverResponseTimeMs,required"` // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON `json:"-"` + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON httpDetailsHTTPStatsByColoJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON contains the JSON -// metadata for the struct [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON struct { +// httpDetailsHTTPStatsByColoJSON contains the JSON metadata for the struct +// [HTTPDetailsHTTPStatsByColo] +type httpDetailsHTTPStatsByColoJSON struct { + AvailabilityPct apijson.Field Colo apijson.Field DNSResponseTimeMs apijson.Field HTTPStatusCode apijson.Field @@ -335,29 +230,28 @@ type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStatsByColo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON) RawJSON() string { +func (r httpDetailsHTTPStatsByColoJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs struct { - Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot `json:"slots,required"` +type HTTPDetailsHTTPStatsByColoAvailabilityPct struct { + Slots []HTTPDetailsHTTPStatsByColoAvailabilityPctSlot `json:"slots,required"` // average observed in the time period - Avg int64 `json:"avg,nullable"` + Avg float64 `json:"avg,nullable"` // highest observed in the time period - Max int64 `json:"max,nullable"` + Max float64 `json:"max,nullable"` // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON `json:"-"` + Min float64 `json:"min,nullable"` + JSON httpDetailsHTTPStatsByColoAvailabilityPctJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON struct { +// httpDetailsHTTPStatsByColoAvailabilityPctJSON contains the JSON metadata for the +// struct [HTTPDetailsHTTPStatsByColoAvailabilityPct] +type httpDetailsHTTPStatsByColoAvailabilityPctJSON struct { Slots apijson.Field Avg apijson.Field Max apijson.Field @@ -366,51 +260,49 @@ type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStatsByColoAvailabilityPct) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON) RawJSON() string { +func (r httpDetailsHTTPStatsByColoAvailabilityPctJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON `json:"-"` +type HTTPDetailsHTTPStatsByColoAvailabilityPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON httpDetailsHTTPStatsByColoAvailabilityPctSlotJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON struct { +// httpDetailsHTTPStatsByColoAvailabilityPctSlotJSON contains the JSON metadata for +// the struct [HTTPDetailsHTTPStatsByColoAvailabilityPctSlot] +type httpDetailsHTTPStatsByColoAvailabilityPctSlotJSON struct { Timestamp apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStatsByColoAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON) RawJSON() string { +func (r httpDetailsHTTPStatsByColoAvailabilityPctSlotJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode struct { - Status200 int64 `json:"status200,required"` - Status300 int64 `json:"status300,required"` - Status400 int64 `json:"status400,required"` - Status500 int64 `json:"status500,required"` - Timestamp string `json:"timestamp,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON `json:"-"` +type HTTPDetailsHTTPStatsByColoHTTPStatusCode struct { + Status200 int64 `json:"status200,required"` + Status300 int64 `json:"status300,required"` + Status400 int64 `json:"status400,required"` + Status500 int64 `json:"status500,required"` + Timestamp string `json:"timestamp,required"` + JSON httpDetailsHTTPStatsByColoHTTPStatusCodeJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON struct { +// httpDetailsHTTPStatsByColoHTTPStatusCodeJSON contains the JSON metadata for the +// struct [HTTPDetailsHTTPStatsByColoHTTPStatusCode] +type httpDetailsHTTPStatsByColoHTTPStatusCodeJSON struct { Status200 apijson.Field Status300 apijson.Field Status400 apijson.Field @@ -420,133 +312,23 @@ type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON str ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs struct { - Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs struct { - Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot] -type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsHTTPStatsByColoHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON) RawJSON() string { +func (r httpDetailsHTTPStatsByColoHTTPStatusCodeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsKind string +type HTTPDetailsKind string const ( - DigitalExperienceMonitoringHTTPDetailsKindHTTP DigitalExperienceMonitoringHTTPDetailsKind = "http" + HTTPDetailsKindHTTP HTTPDetailsKind = "http" ) -func (r DigitalExperienceMonitoringHTTPDetailsKind) IsKnown() bool { +func (r HTTPDetailsKind) IsKnown() bool { switch r { - case DigitalExperienceMonitoringHTTPDetailsKindHTTP: + case HTTPDetailsKindHTTP: return true } return false @@ -571,7 +353,7 @@ type DEXHTTPTestGetParams struct { // URLQuery serializes [DEXHTTPTestGetParams]'s query parameters as `url.Values`. func (r DEXHTTPTestGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -593,9 +375,9 @@ func (r DexhttpTestGetParamsInterval) IsKnown() bool { } type DexhttpTestGetResponseEnvelope struct { - Errors []DexhttpTestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DexhttpTestGetResponseEnvelopeMessages `json:"messages,required"` - Result DigitalExperienceMonitoringHTTPDetails `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HTTPDetails `json:"result,required"` // Whether the API call was successful Success DexhttpTestGetResponseEnvelopeSuccess `json:"success,required"` JSON dexhttpTestGetResponseEnvelopeJSON `json:"-"` @@ -620,52 +402,6 @@ func (r dexhttpTestGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DexhttpTestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexhttpTestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexhttpTestGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DexhttpTestGetResponseEnvelopeErrors] -type dexhttpTestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DexhttpTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexhttpTestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DexhttpTestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexhttpTestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexhttpTestGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DexhttpTestGetResponseEnvelopeMessages] -type dexhttpTestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DexhttpTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexhttpTestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DexhttpTestGetResponseEnvelopeSuccess bool diff --git a/zero_trust/dexhttptestpercentile.go b/zero_trust/dexhttptestpercentile.go index eadb9806590..acbdf4cb7ab 100644 --- a/zero_trust/dexhttptestpercentile.go +++ b/zero_trust/dexhttptestpercentile.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -35,7 +36,7 @@ func NewDEXHTTPTestPercentileService(opts ...option.RequestOption) (r *DEXHTTPTe // Get percentiles for an http test for a given time period between 1 hour and 7 // days. -func (r *DEXHTTPTestPercentileService) Get(ctx context.Context, testID string, params DEXHTTPTestPercentileGetParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringHTTPDetailsPercentiles, err error) { +func (r *DEXHTTPTestPercentileService) Get(ctx context.Context, testID string, params DEXHTTPTestPercentileGetParams, opts ...option.RequestOption) (res *HTTPDetailsPercentiles, err error) { opts = append(r.Options[:], opts...) var env DexhttpTestPercentileGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dex/http-tests/%s/percentiles", params.AccountID, testID) @@ -47,16 +48,16 @@ func (r *DEXHTTPTestPercentileService) Get(ctx context.Context, testID string, p return } -type DigitalExperienceMonitoringHTTPDetailsPercentiles struct { - DNSResponseTimeMs DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs `json:"dnsResponseTimeMs"` - ResourceFetchTimeMs DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs `json:"resourceFetchTimeMs"` - ServerResponseTimeMs DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs `json:"serverResponseTimeMs"` - JSON digitalExperienceMonitoringHTTPDetailsPercentilesJSON `json:"-"` +type HTTPDetailsPercentiles struct { + DNSResponseTimeMs Percentiles `json:"dnsResponseTimeMs"` + ResourceFetchTimeMs Percentiles `json:"resourceFetchTimeMs"` + ServerResponseTimeMs Percentiles `json:"serverResponseTimeMs"` + JSON httpDetailsPercentilesJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsPercentilesJSON contains the JSON metadata -// for the struct [DigitalExperienceMonitoringHTTPDetailsPercentiles] -type digitalExperienceMonitoringHTTPDetailsPercentilesJSON struct { +// httpDetailsPercentilesJSON contains the JSON metadata for the struct +// [HTTPDetailsPercentiles] +type httpDetailsPercentilesJSON struct { DNSResponseTimeMs apijson.Field ResourceFetchTimeMs apijson.Field ServerResponseTimeMs apijson.Field @@ -64,107 +65,64 @@ type digitalExperienceMonitoringHTTPDetailsPercentilesJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsPercentiles) UnmarshalJSON(data []byte) (err error) { +func (r *HTTPDetailsPercentiles) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsPercentilesJSON) RawJSON() string { +func (r httpDetailsPercentilesJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs] -type digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field +type TestStatOverTime struct { + Slots []TestStatOverTimeSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON testStatOverTimeJSON `json:"-"` +} + +// testStatOverTimeJSON contains the JSON metadata for the struct +// [TestStatOverTime] +type testStatOverTimeJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { +func (r *TestStatOverTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON) RawJSON() string { +func (r testStatOverTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON `json:"-"` +type TestStatOverTimeSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON testStatOverTimeSlotJSON `json:"-"` } -// digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs] -type digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field +// testStatOverTimeSlotJSON contains the JSON metadata for the struct +// [TestStatOverTimeSlot] +type testStatOverTimeSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { +func (r *TestStatOverTimeSlot) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs] -type digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON) RawJSON() string { +func (r testStatOverTimeSlotJSON) RawJSON() string { return r.raw } @@ -186,15 +144,15 @@ type DEXHTTPTestPercentileGetParams struct { // `url.Values`. func (r DEXHTTPTestPercentileGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DexhttpTestPercentileGetResponseEnvelope struct { - Errors []DexhttpTestPercentileGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DexhttpTestPercentileGetResponseEnvelopeMessages `json:"messages,required"` - Result DigitalExperienceMonitoringHTTPDetailsPercentiles `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result HTTPDetailsPercentiles `json:"result,required"` // Whether the API call was successful Success DexhttpTestPercentileGetResponseEnvelopeSuccess `json:"success,required"` JSON dexhttpTestPercentileGetResponseEnvelopeJSON `json:"-"` @@ -219,52 +177,6 @@ func (r dexhttpTestPercentileGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DexhttpTestPercentileGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexhttpTestPercentileGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexhttpTestPercentileGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DexhttpTestPercentileGetResponseEnvelopeErrors] -type dexhttpTestPercentileGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DexhttpTestPercentileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexhttpTestPercentileGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DexhttpTestPercentileGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexhttpTestPercentileGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexhttpTestPercentileGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DexhttpTestPercentileGetResponseEnvelopeMessages] -type dexhttpTestPercentileGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DexhttpTestPercentileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexhttpTestPercentileGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DexhttpTestPercentileGetResponseEnvelopeSuccess bool diff --git a/zero_trust/dextest.go b/zero_trust/dextest.go index c7649f84a9f..22528a34052 100644 --- a/zero_trust/dextest.go +++ b/zero_trust/dextest.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -58,56 +59,97 @@ func (r *DEXTestService) ListAutoPaging(ctx context.Context, params DEXTestListP return pagination.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...)) } -type DigitalExperienceMonitoringTests struct { - OverviewMetrics DigitalExperienceMonitoringTestsOverviewMetrics `json:"overviewMetrics,required"` +type AggregateTimePeriod struct { + Units AggregateTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON aggregateTimePeriodJSON `json:"-"` +} + +// aggregateTimePeriodJSON contains the JSON metadata for the struct +// [AggregateTimePeriod] +type aggregateTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AggregateTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aggregateTimePeriodJSON) RawJSON() string { + return r.raw +} + +type AggregateTimePeriodUnits string + +const ( + AggregateTimePeriodUnitsHours AggregateTimePeriodUnits = "hours" + AggregateTimePeriodUnitsDays AggregateTimePeriodUnits = "days" + AggregateTimePeriodUnitsTestRuns AggregateTimePeriodUnits = "testRuns" +) + +func (r AggregateTimePeriodUnits) IsKnown() bool { + switch r { + case AggregateTimePeriodUnitsHours, AggregateTimePeriodUnitsDays, AggregateTimePeriodUnitsTestRuns: + return true + } + return false +} + +type Tests struct { + OverviewMetrics TestsOverviewMetrics `json:"overviewMetrics,required"` // array of test results objects. - Tests []DigitalExperienceMonitoringTestsTest `json:"tests,required"` - JSON digitalExperienceMonitoringTestsJSON `json:"-"` + Tests []TestsTest `json:"tests,required"` + JSON testsJSON `json:"-"` } -// digitalExperienceMonitoringTestsJSON contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTests] -type digitalExperienceMonitoringTestsJSON struct { +// testsJSON contains the JSON metadata for the struct [Tests] +type testsJSON struct { OverviewMetrics apijson.Field Tests apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTests) UnmarshalJSON(data []byte) (err error) { +func (r *Tests) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsJSON) RawJSON() string { +func (r testsJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsOverviewMetrics struct { +type TestsOverviewMetrics struct { // number of tests. TestsTotal int64 `json:"testsTotal,required"` + // percentage availability for all HTTP test results in response + AvgHTTPAvailabilityPct float64 `json:"avgHttpAvailabilityPct,nullable"` // percentage availability for all traceroutes results in response - AvgTracerouteAvailabilityPct float64 `json:"avgTracerouteAvailabilityPct,nullable"` - JSON digitalExperienceMonitoringTestsOverviewMetricsJSON `json:"-"` + AvgTracerouteAvailabilityPct float64 `json:"avgTracerouteAvailabilityPct,nullable"` + JSON testsOverviewMetricsJSON `json:"-"` } -// digitalExperienceMonitoringTestsOverviewMetricsJSON contains the JSON metadata -// for the struct [DigitalExperienceMonitoringTestsOverviewMetrics] -type digitalExperienceMonitoringTestsOverviewMetricsJSON struct { +// testsOverviewMetricsJSON contains the JSON metadata for the struct +// [TestsOverviewMetrics] +type testsOverviewMetricsJSON struct { TestsTotal apijson.Field + AvgHTTPAvailabilityPct apijson.Field AvgTracerouteAvailabilityPct apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsOverviewMetrics) UnmarshalJSON(data []byte) (err error) { +func (r *TestsOverviewMetrics) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsOverviewMetricsJSON) RawJSON() string { +func (r testsOverviewMetricsJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTest struct { +type TestsTest struct { // API Resource UUID tag. ID string `json:"id,required"` // date the test was created. @@ -121,22 +163,23 @@ type DigitalExperienceMonitoringTestsTest struct { // The interval at which the synthetic application test is set to run. Interval string `json:"interval,required"` // test type, http or traceroute - Kind DigitalExperienceMonitoringTestsTestsKind `json:"kind,required"` + Kind TestsTestsKind `json:"kind,required"` // name given to this test - Name string `json:"name,required"` - Updated string `json:"updated,required"` - HTTPResults DigitalExperienceMonitoringTestsTestsHTTPResults `json:"httpResults,nullable"` - HTTPResultsByColo []DigitalExperienceMonitoringTestsTestsHTTPResultsByColo `json:"httpResultsByColo"` + Name string `json:"name,required"` + Updated string `json:"updated,required"` + HTTPResults TestsTestsHTTPResults `json:"httpResults,nullable"` + HTTPResultsByColo []TestsTestsHTTPResultsByColo `json:"httpResultsByColo"` // for HTTP, the method to use when running the test - Method string `json:"method"` - TracerouteResults DigitalExperienceMonitoringTestsTestsTracerouteResults `json:"tracerouteResults,nullable"` - TracerouteResultsByColo []DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo `json:"tracerouteResultsByColo"` - JSON digitalExperienceMonitoringTestsTestJSON `json:"-"` + Method string `json:"method"` + TargetPolicies []DeviceExperienceMonitor `json:"target_policies,nullable"` + Targeted bool `json:"targeted"` + TracerouteResults TestsTestsTracerouteResults `json:"tracerouteResults,nullable"` + TracerouteResultsByColo []TestsTestsTracerouteResultsByColo `json:"tracerouteResultsByColo"` + JSON testsTestJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestJSON contains the JSON metadata for the -// struct [DigitalExperienceMonitoringTestsTest] -type digitalExperienceMonitoringTestsTestJSON struct { +// testsTestJSON contains the JSON metadata for the struct [TestsTest] +type testsTestJSON struct { ID apijson.Field Created apijson.Field Description apijson.Field @@ -149,68 +192,69 @@ type digitalExperienceMonitoringTestsTestJSON struct { HTTPResults apijson.Field HTTPResultsByColo apijson.Field Method apijson.Field + TargetPolicies apijson.Field + Targeted apijson.Field TracerouteResults apijson.Field TracerouteResultsByColo apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTest) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTest) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestJSON) RawJSON() string { +func (r testsTestJSON) RawJSON() string { return r.raw } // test type, http or traceroute -type DigitalExperienceMonitoringTestsTestsKind string +type TestsTestsKind string const ( - DigitalExperienceMonitoringTestsTestsKindHTTP DigitalExperienceMonitoringTestsTestsKind = "http" - DigitalExperienceMonitoringTestsTestsKindTraceroute DigitalExperienceMonitoringTestsTestsKind = "traceroute" + TestsTestsKindHTTP TestsTestsKind = "http" + TestsTestsKindTraceroute TestsTestsKind = "traceroute" ) -func (r DigitalExperienceMonitoringTestsTestsKind) IsKnown() bool { +func (r TestsTestsKind) IsKnown() bool { switch r { - case DigitalExperienceMonitoringTestsTestsKindHTTP, DigitalExperienceMonitoringTestsTestsKindTraceroute: + case TestsTestsKindHTTP, TestsTestsKindTraceroute: return true } return false } -type DigitalExperienceMonitoringTestsTestsHTTPResults struct { - ResourceFetchTime DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime `json:"resourceFetchTime,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsJSON `json:"-"` +type TestsTestsHTTPResults struct { + ResourceFetchTime TestsTestsHTTPResultsResourceFetchTime `json:"resourceFetchTime,required"` + JSON testsTestsHTTPResultsJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsJSON contains the JSON metadata -// for the struct [DigitalExperienceMonitoringTestsTestsHTTPResults] -type digitalExperienceMonitoringTestsTestsHTTPResultsJSON struct { +// testsTestsHTTPResultsJSON contains the JSON metadata for the struct +// [TestsTestsHTTPResults] +type testsTestsHTTPResultsJSON struct { ResourceFetchTime apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResults) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResults) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsJSON) RawJSON() string { +func (r testsTestsHTTPResultsJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime struct { - History []DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime `json:"overTime,nullable"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON `json:"-"` +type TestsTestsHTTPResultsResourceFetchTime struct { + History []TestsTestsHTTPResultsResourceFetchTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime TestsTestsHTTPResultsResourceFetchTimeOverTime `json:"overTime,nullable"` + JSON testsTestsHTTPResultsResourceFetchTimeJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime] -type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON struct { +// testsTestsHTTPResultsResourceFetchTimeJSON contains the JSON metadata for the +// struct [TestsTestsHTTPResultsResourceFetchTime] +type testsTestsHTTPResultsResourceFetchTimeJSON struct { History apijson.Field AvgMs apijson.Field OverTime apijson.Field @@ -218,25 +262,24 @@ type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON struc ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsResourceFetchTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON) RawJSON() string { +func (r testsTestsHTTPResultsResourceFetchTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory struct { - TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON `json:"-"` +type TestsTestsHTTPResultsResourceFetchTimeHistory struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON testsTestsHTTPResultsResourceFetchTimeHistoryJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory] -type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON struct { +// testsTestsHTTPResultsResourceFetchTimeHistoryJSON contains the JSON metadata for +// the struct [TestsTestsHTTPResultsResourceFetchTimeHistory] +type testsTestsHTTPResultsResourceFetchTimeHistoryJSON struct { TimePeriod apijson.Field AvgMs apijson.Field DeltaPct apijson.Field @@ -244,177 +287,94 @@ type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSO ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON) RawJSON() string { +func (r testsTestsHTTPResultsResourceFetchTimeHistoryJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON `json:"-"` +type TestsTestsHTTPResultsResourceFetchTimeOverTime struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + Values []TestsTestsHTTPResultsResourceFetchTimeOverTimeValue `json:"values,required"` + JSON testsTestsHTTPResultsResourceFetchTimeOverTimeJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod] -type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsTestRuns: - return true - } - return false -} - -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime struct { - TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue `json:"values,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime] -type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON struct { +// testsTestsHTTPResultsResourceFetchTimeOverTimeJSON contains the JSON metadata +// for the struct [TestsTestsHTTPResultsResourceFetchTimeOverTime] +type testsTestsHTTPResultsResourceFetchTimeOverTimeJSON struct { TimePeriod apijson.Field Values apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON) RawJSON() string { +func (r testsTestsHTTPResultsResourceFetchTimeOverTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod] -type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field +type TestsTestsHTTPResultsResourceFetchTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON testsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON `json:"-"` } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsTestRuns: - return true - } - return false -} - -type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue] -type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON struct { +// testsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON contains the JSON +// metadata for the struct [TestsTestsHTTPResultsResourceFetchTimeOverTimeValue] +type testsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON struct { AvgMs apijson.Field Timestamp apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON) RawJSON() string { +func (r testsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColo struct { +type TestsTestsHTTPResultsByColo struct { // Cloudflare colo - Colo string `json:"colo,required"` - ResourceFetchTime DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime `json:"resourceFetchTime,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON `json:"-"` + Colo string `json:"colo,required"` + ResourceFetchTime TestsTestsHTTPResultsByColoResourceFetchTime `json:"resourceFetchTime,required"` + JSON testsTestsHTTPResultsByColoJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON contains the JSON -// metadata for the struct [DigitalExperienceMonitoringTestsTestsHTTPResultsByColo] -type digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON struct { +// testsTestsHTTPResultsByColoJSON contains the JSON metadata for the struct +// [TestsTestsHTTPResultsByColo] +type testsTestsHTTPResultsByColoJSON struct { Colo apijson.Field ResourceFetchTime apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColo) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsByColo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON) RawJSON() string { +func (r testsTestsHTTPResultsByColoJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime struct { - History []DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime `json:"overTime,nullable"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON `json:"-"` +type TestsTestsHTTPResultsByColoResourceFetchTime struct { + History []TestsTestsHTTPResultsByColoResourceFetchTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime TestsTestsHTTPResultsByColoResourceFetchTimeOverTime `json:"overTime,nullable"` + JSON testsTestsHTTPResultsByColoResourceFetchTimeJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime] -type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON struct { +// testsTestsHTTPResultsByColoResourceFetchTimeJSON contains the JSON metadata for +// the struct [TestsTestsHTTPResultsByColoResourceFetchTime] +type testsTestsHTTPResultsByColoResourceFetchTimeJSON struct { History apijson.Field AvgMs apijson.Field OverTime apijson.Field @@ -422,25 +382,24 @@ type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsByColoResourceFetchTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON) RawJSON() string { +func (r testsTestsHTTPResultsByColoResourceFetchTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory struct { - TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON `json:"-"` +type TestsTestsHTTPResultsByColoResourceFetchTimeHistory struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON testsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory] -type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON struct { +// testsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON contains the JSON +// metadata for the struct [TestsTestsHTTPResultsByColoResourceFetchTimeHistory] +type testsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON struct { TimePeriod apijson.Field AvgMs apijson.Field DeltaPct apijson.Field @@ -448,174 +407,92 @@ type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHist ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod] -type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsByColoResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON) RawJSON() string { +func (r testsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsTestRuns: - return true - } - return false -} - -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime struct { - TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue `json:"values,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON `json:"-"` +type TestsTestsHTTPResultsByColoResourceFetchTimeOverTime struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + Values []TestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue `json:"values,required"` + JSON testsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime] -type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON struct { +// testsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON contains the JSON +// metadata for the struct [TestsTestsHTTPResultsByColoResourceFetchTimeOverTime] +type testsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON struct { TimePeriod apijson.Field Values apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod] -type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsByColoResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON) RawJSON() string { +func (r testsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsTestRuns: - return true - } - return false +type TestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON testsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON `json:"-"` } -type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue] -type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON struct { +// testsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON contains the JSON +// metadata for the struct +// [TestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue] +type testsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON struct { AvgMs apijson.Field Timestamp apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON) RawJSON() string { +func (r testsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResults struct { - RoundTripTime DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime `json:"roundTripTime,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsJSON `json:"-"` +type TestsTestsTracerouteResults struct { + RoundTripTime TestsTestsTracerouteResultsRoundTripTime `json:"roundTripTime,required"` + JSON testsTestsTracerouteResultsJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsJSON contains the JSON -// metadata for the struct [DigitalExperienceMonitoringTestsTestsTracerouteResults] -type digitalExperienceMonitoringTestsTestsTracerouteResultsJSON struct { +// testsTestsTracerouteResultsJSON contains the JSON metadata for the struct +// [TestsTestsTracerouteResults] +type testsTestsTracerouteResultsJSON struct { RoundTripTime apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResults) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResults) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsJSON) RawJSON() string { +func (r testsTestsTracerouteResultsJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime struct { - History []DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime `json:"overTime,nullable"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON `json:"-"` +type TestsTestsTracerouteResultsRoundTripTime struct { + History []TestsTestsTracerouteResultsRoundTripTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime TestsTestsTracerouteResultsRoundTripTimeOverTime `json:"overTime,nullable"` + JSON testsTestsTracerouteResultsRoundTripTimeJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime] -type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON struct { +// testsTestsTracerouteResultsRoundTripTimeJSON contains the JSON metadata for the +// struct [TestsTestsTracerouteResultsRoundTripTime] +type testsTestsTracerouteResultsRoundTripTimeJSON struct { History apijson.Field AvgMs apijson.Field OverTime apijson.Field @@ -623,25 +500,24 @@ type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON str ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsRoundTripTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON) RawJSON() string { +func (r testsTestsTracerouteResultsRoundTripTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory struct { - TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON `json:"-"` +type TestsTestsTracerouteResultsRoundTripTimeHistory struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON testsTestsTracerouteResultsRoundTripTimeHistoryJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory] -type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON struct { +// testsTestsTracerouteResultsRoundTripTimeHistoryJSON contains the JSON metadata +// for the struct [TestsTestsTracerouteResultsRoundTripTimeHistory] +type testsTestsTracerouteResultsRoundTripTimeHistoryJSON struct { TimePeriod apijson.Field AvgMs apijson.Field DeltaPct apijson.Field @@ -649,178 +525,94 @@ type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJ ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod] -type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON) RawJSON() string { +func (r testsTestsTracerouteResultsRoundTripTimeHistoryJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsTestRuns: - return true - } - return false -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime struct { - TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue `json:"values,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON `json:"-"` +type TestsTestsTracerouteResultsRoundTripTimeOverTime struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + Values []TestsTestsTracerouteResultsRoundTripTimeOverTimeValue `json:"values,required"` + JSON testsTestsTracerouteResultsRoundTripTimeOverTimeJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime] -type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON struct { +// testsTestsTracerouteResultsRoundTripTimeOverTimeJSON contains the JSON metadata +// for the struct [TestsTestsTracerouteResultsRoundTripTimeOverTime] +type testsTestsTracerouteResultsRoundTripTimeOverTimeJSON struct { TimePeriod apijson.Field Values apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON) RawJSON() string { +func (r testsTestsTracerouteResultsRoundTripTimeOverTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON `json:"-"` +type TestsTestsTracerouteResultsRoundTripTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON testsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod] -type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsTestRuns: - return true - } - return false -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue] -type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON struct { +// testsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON contains the JSON +// metadata for the struct [TestsTestsTracerouteResultsRoundTripTimeOverTimeValue] +type testsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON struct { AvgMs apijson.Field Timestamp apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON) RawJSON() string { +func (r testsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo struct { +type TestsTestsTracerouteResultsByColo struct { // Cloudflare colo - Colo string `json:"colo,required"` - RoundTripTime DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime `json:"roundTripTime,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON `json:"-"` + Colo string `json:"colo,required"` + RoundTripTime TestsTestsTracerouteResultsByColoRoundTripTime `json:"roundTripTime,required"` + JSON testsTestsTracerouteResultsByColoJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON contains the -// JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo] -type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON struct { +// testsTestsTracerouteResultsByColoJSON contains the JSON metadata for the struct +// [TestsTestsTracerouteResultsByColo] +type testsTestsTracerouteResultsByColoJSON struct { Colo apijson.Field RoundTripTime apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsByColo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON) RawJSON() string { +func (r testsTestsTracerouteResultsByColoJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime struct { - History []DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime `json:"overTime,nullable"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON `json:"-"` +type TestsTestsTracerouteResultsByColoRoundTripTime struct { + History []TestsTestsTracerouteResultsByColoRoundTripTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime TestsTestsTracerouteResultsByColoRoundTripTimeOverTime `json:"overTime,nullable"` + JSON testsTestsTracerouteResultsByColoRoundTripTimeJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime] -type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON struct { +// testsTestsTracerouteResultsByColoRoundTripTimeJSON contains the JSON metadata +// for the struct [TestsTestsTracerouteResultsByColoRoundTripTime] +type testsTestsTracerouteResultsByColoRoundTripTimeJSON struct { History apijson.Field AvgMs apijson.Field OverTime apijson.Field @@ -828,25 +620,24 @@ type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJS ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsByColoRoundTripTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON) RawJSON() string { +func (r testsTestsTracerouteResultsByColoRoundTripTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory struct { - TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON `json:"-"` +type TestsTestsTracerouteResultsByColoRoundTripTimeHistory struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON testsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory] -type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON struct { +// testsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON contains the JSON +// metadata for the struct [TestsTestsTracerouteResultsByColoRoundTripTimeHistory] +type testsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON struct { TimePeriod apijson.Field AvgMs apijson.Field DeltaPct apijson.Field @@ -854,146 +645,65 @@ type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHi ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsByColoRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON) RawJSON() string { +func (r testsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod] -type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field +type TestsTestsTracerouteResultsByColoRoundTripTimeOverTime struct { + TimePeriod AggregateTimePeriod `json:"timePeriod,required"` + Values []TestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue `json:"values,required"` + JSON testsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON `json:"-"` } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsTestRuns: - return true - } - return false -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime struct { - TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue `json:"values,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime] -type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON struct { +// testsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON contains the JSON +// metadata for the struct [TestsTestsTracerouteResultsByColoRoundTripTimeOverTime] +type testsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON struct { TimePeriod apijson.Field Values apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod struct { - Units DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON `json:"-"` -} - -// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod] -type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsByColoRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON) RawJSON() string { +func (r testsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits string - -const ( - DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "hours" - DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "days" - DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "testRuns" -) - -func (r DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsHours, DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsDays, DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsTestRuns: - return true - } - return false -} - -type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON `json:"-"` +type TestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON testsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON `json:"-"` } -// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue] -type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON struct { +// testsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON contains the +// JSON metadata for the struct +// [TestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue] +type testsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON struct { AvgMs apijson.Field Timestamp apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { +func (r *TestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON) RawJSON() string { +func (r testsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON) RawJSON() string { return r.raw } type DEXTestListResponse struct { - Errors []DEXTestListResponseError `json:"errors,required"` - Messages []DEXTestListResponseMessage `json:"messages,required"` - Result DigitalExperienceMonitoringTests `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Tests `json:"result,required"` // Whether the API call was successful Success DEXTestListResponseSuccess `json:"success,required"` ResultInfo DEXTestListResponseResultInfo `json:"result_info"` @@ -1020,52 +730,6 @@ func (r dexTestListResponseJSON) RawJSON() string { return r.raw } -type DEXTestListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTestListResponseErrorJSON `json:"-"` -} - -// dexTestListResponseErrorJSON contains the JSON metadata for the struct -// [DEXTestListResponseError] -type dexTestListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTestListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTestListResponseErrorJSON) RawJSON() string { - return r.raw -} - -type DEXTestListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTestListResponseMessageJSON `json:"-"` -} - -// dexTestListResponseMessageJSON contains the JSON metadata for the struct -// [DEXTestListResponseMessage] -type dexTestListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTestListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTestListResponseMessageJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DEXTestListResponseSuccess bool @@ -1131,7 +795,7 @@ type DEXTestListParams struct { // URLQuery serializes [DEXTestListParams]'s query parameters as `url.Values`. func (r DEXTestListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } diff --git a/zero_trust/dextestuniquedevice.go b/zero_trust/dextestuniquedevice.go index 6452600ae28..75a80f6ddfa 100644 --- a/zero_trust/dextestuniquedevice.go +++ b/zero_trust/dextestuniquedevice.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -35,7 +36,7 @@ func NewDEXTestUniqueDeviceService(opts ...option.RequestOption) (r *DEXTestUniq // Returns unique count of devices that have run synthetic application monitoring // tests in the past 7 days. -func (r *DEXTestUniqueDeviceService) List(ctx context.Context, params DEXTestUniqueDeviceListParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringUniqueDevices, err error) { +func (r *DEXTestUniqueDeviceService) List(ctx context.Context, params DEXTestUniqueDeviceListParams, opts ...option.RequestOption) (res *UniqueDevices, err error) { opts = append(r.Options[:], opts...) var env DEXTestUniqueDeviceListResponseEnvelope path := fmt.Sprintf("accounts/%s/dex/tests/unique-devices", params.AccountID) @@ -47,25 +48,24 @@ func (r *DEXTestUniqueDeviceService) List(ctx context.Context, params DEXTestUni return } -type DigitalExperienceMonitoringUniqueDevices struct { +type UniqueDevices struct { // total number of unique devices - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON digitalExperienceMonitoringUniqueDevicesJSON `json:"-"` + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON uniqueDevicesJSON `json:"-"` } -// digitalExperienceMonitoringUniqueDevicesJSON contains the JSON metadata for the -// struct [DigitalExperienceMonitoringUniqueDevices] -type digitalExperienceMonitoringUniqueDevicesJSON struct { +// uniqueDevicesJSON contains the JSON metadata for the struct [UniqueDevices] +type uniqueDevicesJSON struct { UniqueDevicesTotal apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringUniqueDevices) UnmarshalJSON(data []byte) (err error) { +func (r *UniqueDevices) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringUniqueDevicesJSON) RawJSON() string { +func (r uniqueDevicesJSON) RawJSON() string { return r.raw } @@ -82,15 +82,15 @@ type DEXTestUniqueDeviceListParams struct { // `url.Values`. func (r DEXTestUniqueDeviceListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DEXTestUniqueDeviceListResponseEnvelope struct { - Errors []DEXTestUniqueDeviceListResponseEnvelopeErrors `json:"errors,required"` - Messages []DEXTestUniqueDeviceListResponseEnvelopeMessages `json:"messages,required"` - Result DigitalExperienceMonitoringUniqueDevices `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result UniqueDevices `json:"result,required"` // Whether the API call was successful Success DEXTestUniqueDeviceListResponseEnvelopeSuccess `json:"success,required"` JSON dexTestUniqueDeviceListResponseEnvelopeJSON `json:"-"` @@ -115,52 +115,6 @@ func (r dexTestUniqueDeviceListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DEXTestUniqueDeviceListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTestUniqueDeviceListResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexTestUniqueDeviceListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DEXTestUniqueDeviceListResponseEnvelopeErrors] -type dexTestUniqueDeviceListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTestUniqueDeviceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTestUniqueDeviceListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DEXTestUniqueDeviceListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTestUniqueDeviceListResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexTestUniqueDeviceListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DEXTestUniqueDeviceListResponseEnvelopeMessages] -type dexTestUniqueDeviceListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTestUniqueDeviceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTestUniqueDeviceListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DEXTestUniqueDeviceListResponseEnvelopeSuccess bool diff --git a/zero_trust/dextraceroutetest.go b/zero_trust/dextraceroutetest.go index e9ff7e19d41..2403a34a88f 100644 --- a/zero_trust/dextraceroutetest.go +++ b/zero_trust/dextraceroutetest.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -35,7 +36,7 @@ func NewDEXTracerouteTestService(opts ...option.RequestOption) (r *DEXTraceroute // Get test details and aggregate performance metrics for an traceroute test for a // given time period between 1 hour and 7 days. -func (r *DEXTracerouteTestService) Get(ctx context.Context, testID string, params DEXTracerouteTestGetParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteDetails, err error) { +func (r *DEXTracerouteTestService) Get(ctx context.Context, testID string, params DEXTracerouteTestGetParams, opts ...option.RequestOption) (res *Traceroute, err error) { opts = append(r.Options[:], opts...) var env DEXTracerouteTestGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s", params.AccountID, testID) @@ -48,7 +49,7 @@ func (r *DEXTracerouteTestService) Get(ctx context.Context, testID string, param } // Get a breakdown of metrics by hop for individual traceroute test runs -func (r *DEXTracerouteTestService) NetworkPath(ctx context.Context, testID string, params DEXTracerouteTestNetworkPathParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteTestNetworkPath, err error) { +func (r *DEXTracerouteTestService) NetworkPath(ctx context.Context, testID string, params DEXTracerouteTestNetworkPathParams, opts ...option.RequestOption) (res *NetworkPath, err error) { opts = append(r.Options[:], opts...) var env DEXTracerouteTestNetworkPathResponseEnvelope path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s/network-path", params.AccountID, testID) @@ -62,7 +63,7 @@ func (r *DEXTracerouteTestService) NetworkPath(ctx context.Context, testID strin // Get percentiles for a traceroute test for a given time period between 1 hour and // 7 days. -func (r *DEXTracerouteTestService) Percentiles(ctx context.Context, testID string, params DEXTracerouteTestPercentilesParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteDetailsPercentiles, err error) { +func (r *DEXTracerouteTestService) Percentiles(ctx context.Context, testID string, params DEXTracerouteTestPercentilesParams, opts ...option.RequestOption) (res *DEXTracerouteTestPercentilesResponse, err error) { opts = append(r.Options[:], opts...) var env DEXTracerouteTestPercentilesResponseEnvelope path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s/percentiles", params.AccountID, testID) @@ -74,68 +75,70 @@ func (r *DEXTracerouteTestService) Percentiles(ctx context.Context, testID strin return } -type DigitalExperienceMonitoringTracerouteDetails struct { +type Traceroute struct { // The host of the Traceroute synthetic application test Host string `json:"host,required"` // The interval at which the Traceroute synthetic application test is set to run. - Interval string `json:"interval,required"` - Kind DigitalExperienceMonitoringTracerouteDetailsKind `json:"kind,required"` + Interval string `json:"interval,required"` + Kind TracerouteKind `json:"kind,required"` // The name of the Traceroute synthetic application test - Name string `json:"name,required"` - TracerouteStats DigitalExperienceMonitoringTracerouteDetailsTracerouteStats `json:"tracerouteStats,nullable"` - TracerouteStatsByColo []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo `json:"tracerouteStatsByColo"` - JSON digitalExperienceMonitoringTracerouteDetailsJSON `json:"-"` + Name string `json:"name,required"` + TargetPolicies []DeviceExperienceMonitor `json:"target_policies,nullable"` + Targeted bool `json:"targeted"` + TracerouteStats TracerouteTracerouteStats `json:"tracerouteStats,nullable"` + TracerouteStatsByColo []TracerouteTracerouteStatsByColo `json:"tracerouteStatsByColo"` + JSON tracerouteJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsJSON contains the JSON metadata for -// the struct [DigitalExperienceMonitoringTracerouteDetails] -type digitalExperienceMonitoringTracerouteDetailsJSON struct { +// tracerouteJSON contains the JSON metadata for the struct [Traceroute] +type tracerouteJSON struct { Host apijson.Field Interval apijson.Field Kind apijson.Field Name apijson.Field + TargetPolicies apijson.Field + Targeted apijson.Field TracerouteStats apijson.Field TracerouteStatsByColo apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetails) UnmarshalJSON(data []byte) (err error) { +func (r *Traceroute) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsJSON) RawJSON() string { +func (r tracerouteJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsKind string +type TracerouteKind string const ( - DigitalExperienceMonitoringTracerouteDetailsKindTraceroute DigitalExperienceMonitoringTracerouteDetailsKind = "traceroute" + TracerouteKindTraceroute TracerouteKind = "traceroute" ) -func (r DigitalExperienceMonitoringTracerouteDetailsKind) IsKnown() bool { +func (r TracerouteKind) IsKnown() bool { switch r { - case DigitalExperienceMonitoringTracerouteDetailsKindTraceroute: + case TracerouteKindTraceroute: return true } return false } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStats struct { - AvailabilityPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct `json:"availabilityPct,required"` - HopsCount DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount `json:"hopsCount,required"` - PacketLossPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct `json:"packetLossPct,required"` - RoundTripTimeMs DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs `json:"roundTripTimeMs,required"` +type TracerouteTracerouteStats struct { + AvailabilityPct TracerouteTracerouteStatsAvailabilityPct `json:"availabilityPct,required"` + HopsCount TestStatOverTime `json:"hopsCount,required"` + PacketLossPct TracerouteTracerouteStatsPacketLossPct `json:"packetLossPct,required"` + RoundTripTimeMs TestStatOverTime `json:"roundTripTimeMs,required"` // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON `json:"-"` + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON tracerouteTracerouteStatsJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON contains the -// JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStats] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON struct { +// tracerouteTracerouteStatsJSON contains the JSON metadata for the struct +// [TracerouteTracerouteStats] +type tracerouteTracerouteStatsJSON struct { AvailabilityPct apijson.Field HopsCount apijson.Field PacketLossPct apijson.Field @@ -145,29 +148,28 @@ type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStats) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStats) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON) RawJSON() string { +func (r tracerouteTracerouteStatsJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot `json:"slots,required"` +type TracerouteTracerouteStatsAvailabilityPct struct { + Slots []TracerouteTracerouteStatsAvailabilityPctSlot `json:"slots,required"` // average observed in the time period Avg float64 `json:"avg,nullable"` // highest observed in the time period Max float64 `json:"max,nullable"` // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON `json:"-"` + Min float64 `json:"min,nullable"` + JSON tracerouteTracerouteStatsAvailabilityPctJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON struct { +// tracerouteTracerouteStatsAvailabilityPctJSON contains the JSON metadata for the +// struct [TracerouteTracerouteStatsAvailabilityPct] +type tracerouteTracerouteStatsAvailabilityPctJSON struct { Slots apijson.Field Avg apijson.Field Max apijson.Field @@ -176,108 +178,51 @@ type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJ ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsAvailabilityPct) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON) RawJSON() string { +func (r tracerouteTracerouteStatsAvailabilityPctJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON `json:"-"` +type TracerouteTracerouteStatsAvailabilityPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON tracerouteTracerouteStatsAvailabilityPctSlotJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON struct { +// tracerouteTracerouteStatsAvailabilityPctSlotJSON contains the JSON metadata for +// the struct [TracerouteTracerouteStatsAvailabilityPctSlot] +type tracerouteTracerouteStatsAvailabilityPctSlotJSON struct { Timestamp apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON) RawJSON() string { +func (r tracerouteTracerouteStatsAvailabilityPctSlotJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot `json:"slots,required"` +type TracerouteTracerouteStatsPacketLossPct struct { + Slots []TracerouteTracerouteStatsPacketLossPctSlot `json:"slots,required"` // average observed in the time period Avg float64 `json:"avg,nullable"` // highest observed in the time period Max float64 `json:"max,nullable"` // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON `json:"-"` + Min float64 `json:"min,nullable"` + JSON tracerouteTracerouteStatsPacketLossPctJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON struct { +// tracerouteTracerouteStatsPacketLossPctJSON contains the JSON metadata for the +// struct [TracerouteTracerouteStatsPacketLossPct] +type tracerouteTracerouteStatsPacketLossPctJSON struct { Slots apijson.Field Avg apijson.Field Max apijson.Field @@ -286,108 +231,51 @@ type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSO ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsPacketLossPct) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON) RawJSON() string { +func (r tracerouteTracerouteStatsPacketLossPctJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON `json:"-"` +type TracerouteTracerouteStatsPacketLossPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON tracerouteTracerouteStatsPacketLossPctSlotJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON struct { +// tracerouteTracerouteStatsPacketLossPctSlotJSON contains the JSON metadata for +// the struct [TracerouteTracerouteStatsPacketLossPctSlot] +type tracerouteTracerouteStatsPacketLossPctSlotJSON struct { Timestamp apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON) RawJSON() string { +func (r tracerouteTracerouteStatsPacketLossPctSlotJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo struct { - AvailabilityPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct `json:"availabilityPct,required"` - Colo string `json:"colo,required"` - HopsCount DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount `json:"hopsCount,required"` - PacketLossPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct `json:"packetLossPct,required"` - RoundTripTimeMs DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs `json:"roundTripTimeMs,required"` +type TracerouteTracerouteStatsByColo struct { + AvailabilityPct TracerouteTracerouteStatsByColoAvailabilityPct `json:"availabilityPct,required"` + Colo string `json:"colo,required"` + HopsCount TestStatOverTime `json:"hopsCount,required"` + PacketLossPct TracerouteTracerouteStatsByColoPacketLossPct `json:"packetLossPct,required"` + RoundTripTimeMs TestStatOverTime `json:"roundTripTimeMs,required"` // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON `json:"-"` + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON tracerouteTracerouteStatsByColoJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON struct { +// tracerouteTracerouteStatsByColoJSON contains the JSON metadata for the struct +// [TracerouteTracerouteStatsByColo] +type tracerouteTracerouteStatsByColoJSON struct { AvailabilityPct apijson.Field Colo apijson.Field HopsCount apijson.Field @@ -398,29 +286,28 @@ type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON struc ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsByColo) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON) RawJSON() string { +func (r tracerouteTracerouteStatsByColoJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot `json:"slots,required"` +type TracerouteTracerouteStatsByColoAvailabilityPct struct { + Slots []TracerouteTracerouteStatsByColoAvailabilityPctSlot `json:"slots,required"` // average observed in the time period Avg float64 `json:"avg,nullable"` // highest observed in the time period Max float64 `json:"max,nullable"` // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON `json:"-"` + Min float64 `json:"min,nullable"` + JSON tracerouteTracerouteStatsByColoAvailabilityPctJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON struct { +// tracerouteTracerouteStatsByColoAvailabilityPctJSON contains the JSON metadata +// for the struct [TracerouteTracerouteStatsByColoAvailabilityPct] +type tracerouteTracerouteStatsByColoAvailabilityPctJSON struct { Slots apijson.Field Avg apijson.Field Max apijson.Field @@ -429,163 +316,51 @@ type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabili ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsByColoAvailabilityPct) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON) RawJSON() string { +func (r tracerouteTracerouteStatsByColoAvailabilityPctJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON `json:"-"` +type TracerouteTracerouteStatsByColoAvailabilityPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON tracerouteTracerouteStatsByColoAvailabilityPctSlotJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON struct { +// tracerouteTracerouteStatsByColoAvailabilityPctSlotJSON contains the JSON +// metadata for the struct [TracerouteTracerouteStatsByColoAvailabilityPctSlot] +type tracerouteTracerouteStatsByColoAvailabilityPctSlotJSON struct { Timestamp apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsByColoAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON) RawJSON() string { +func (r tracerouteTracerouteStatsByColoAvailabilityPctSlotJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot `json:"slots,required"` +type TracerouteTracerouteStatsByColoPacketLossPct struct { + Slots []TracerouteTracerouteStatsByColoPacketLossPctSlot `json:"slots,required"` // average observed in the time period Avg float64 `json:"avg,nullable"` // highest observed in the time period Max float64 `json:"max,nullable"` // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs struct { - Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON `json:"-"` + Min float64 `json:"min,nullable"` + JSON tracerouteTracerouteStatsByColoPacketLossPctJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON struct { +// tracerouteTracerouteStatsByColoPacketLossPctJSON contains the JSON metadata for +// the struct [TracerouteTracerouteStatsByColoPacketLossPct] +type tracerouteTracerouteStatsByColoPacketLossPctJSON struct { Slots apijson.Field Avg apijson.Field Max apijson.Field @@ -594,49 +369,47 @@ type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripT ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsByColoPacketLossPct) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON) RawJSON() string { +func (r tracerouteTracerouteStatsByColoPacketLossPctJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON `json:"-"` +type TracerouteTracerouteStatsByColoPacketLossPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON tracerouteTracerouteStatsByColoPacketLossPctSlotJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot] -type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON struct { +// tracerouteTracerouteStatsByColoPacketLossPctSlotJSON contains the JSON metadata +// for the struct [TracerouteTracerouteStatsByColoPacketLossPctSlot] +type tracerouteTracerouteStatsByColoPacketLossPctSlotJSON struct { Timestamp apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot) UnmarshalJSON(data []byte) (err error) { +func (r *TracerouteTracerouteStatsByColoPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON) RawJSON() string { +func (r tracerouteTracerouteStatsByColoPacketLossPctSlotJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteDetailsPercentiles struct { - HopsCount DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount `json:"hopsCount"` - PacketLossPct DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct `json:"packetLossPct"` - RoundTripTimeMs DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs `json:"roundTripTimeMs"` - JSON digitalExperienceMonitoringTracerouteDetailsPercentilesJSON `json:"-"` +type DEXTracerouteTestPercentilesResponse struct { + HopsCount Percentiles `json:"hopsCount"` + PacketLossPct Percentiles `json:"packetLossPct"` + RoundTripTimeMs Percentiles `json:"roundTripTimeMs"` + JSON dexTracerouteTestPercentilesResponseJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteDetailsPercentilesJSON contains the JSON -// metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsPercentiles] -type digitalExperienceMonitoringTracerouteDetailsPercentilesJSON struct { +// dexTracerouteTestPercentilesResponseJSON contains the JSON metadata for the +// struct [DEXTracerouteTestPercentilesResponse] +type dexTracerouteTestPercentilesResponseJSON struct { HopsCount apijson.Field PacketLossPct apijson.Field RoundTripTimeMs apijson.Field @@ -644,265 +417,14 @@ type digitalExperienceMonitoringTracerouteDetailsPercentilesJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteDetailsPercentiles) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsPercentilesJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount] -type digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct] -type digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs] -type digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteTestNetworkPath struct { - // API Resource UUID tag. - ID string `json:"id,required"` - DeviceName string `json:"deviceName"` - // The interval at which the Traceroute synthetic application test is set to run. - Interval string `json:"interval"` - Kind DigitalExperienceMonitoringTracerouteTestNetworkPathKind `json:"kind"` - Name string `json:"name"` - NetworkPath DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath `json:"networkPath,nullable"` - // The host of the Traceroute synthetic application test - URL string `json:"url"` - JSON digitalExperienceMonitoringTracerouteTestNetworkPathJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteTestNetworkPathJSON contains the JSON -// metadata for the struct [DigitalExperienceMonitoringTracerouteTestNetworkPath] -type digitalExperienceMonitoringTracerouteTestNetworkPathJSON struct { - ID apijson.Field - DeviceName apijson.Field - Interval apijson.Field - Kind apijson.Field - Name apijson.Field - NetworkPath apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteTestNetworkPath) UnmarshalJSON(data []byte) (err error) { +func (r *DEXTracerouteTestPercentilesResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteTestNetworkPathJSON) RawJSON() string { +func (r dexTracerouteTestPercentilesResponseJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteTestNetworkPathKind string - -const ( - DigitalExperienceMonitoringTracerouteTestNetworkPathKindTraceroute DigitalExperienceMonitoringTracerouteTestNetworkPathKind = "traceroute" -) - -func (r DigitalExperienceMonitoringTracerouteTestNetworkPathKind) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTracerouteTestNetworkPathKindTraceroute: - return true - } - return false -} - -type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath struct { - Slots []DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot `json:"slots,required"` - // Specifies the sampling applied, if any, to the slots response. When sampled, - // results shown represent the first test run to the start of each sampling - // interval. - Sampling DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling `json:"sampling,nullable"` - JSON digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON contains the -// JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath] -type digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON struct { - Slots apijson.Field - Sampling apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot struct { - // API Resource UUID tag. - ID string `json:"id,required"` - // Round trip time in ms of the client to app mile - ClientToAppRTTMs int64 `json:"clientToAppRttMs,required,nullable"` - // Round trip time in ms of the client to Cloudflare egress mile - ClientToCfEgressRTTMs int64 `json:"clientToCfEgressRttMs,required,nullable"` - // Round trip time in ms of the client to Cloudflare ingress mile - ClientToCfIngressRTTMs int64 `json:"clientToCfIngressRttMs,required,nullable"` - Timestamp string `json:"timestamp,required"` - // Round trip time in ms of the client to ISP mile - ClientToIspRTTMs int64 `json:"clientToIspRttMs,nullable"` - JSON digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON contains -// the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot] -type digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON struct { - ID apijson.Field - ClientToAppRTTMs apijson.Field - ClientToCfEgressRTTMs apijson.Field - ClientToCfIngressRTTMs apijson.Field - Timestamp apijson.Field - ClientToIspRTTMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON) RawJSON() string { - return r.raw -} - -// Specifies the sampling applied, if any, to the slots response. When sampled, -// results shown represent the first test run to the start of each sampling -// interval. -type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling struct { - Unit DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnit `json:"unit,required"` - Value int64 `json:"value,required"` - JSON digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON `json:"-"` -} - -// digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling] -type digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON struct { - Unit apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON) RawJSON() string { - return r.raw -} - -type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnit string - -const ( - DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnitHours DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnit = "hours" -) - -func (r DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnit) IsKnown() bool { - switch r { - case DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnitHours: - return true - } - return false -} - type DEXTracerouteTestGetParams struct { AccountID param.Field[string] `path:"account_id,required"` // Time interval for aggregate time slots. @@ -923,7 +445,7 @@ type DEXTracerouteTestGetParams struct { // `url.Values`. func (r DEXTracerouteTestGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -945,9 +467,9 @@ func (r DEXTracerouteTestGetParamsInterval) IsKnown() bool { } type DEXTracerouteTestGetResponseEnvelope struct { - Errors []DEXTracerouteTestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DEXTracerouteTestGetResponseEnvelopeMessages `json:"messages,required"` - Result DigitalExperienceMonitoringTracerouteDetails `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Traceroute `json:"result,required"` // Whether the API call was successful Success DEXTracerouteTestGetResponseEnvelopeSuccess `json:"success,required"` JSON dexTracerouteTestGetResponseEnvelopeJSON `json:"-"` @@ -972,52 +494,6 @@ func (r dexTracerouteTestGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DEXTracerouteTestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexTracerouteTestGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DEXTracerouteTestGetResponseEnvelopeErrors] -type dexTracerouteTestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DEXTracerouteTestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexTracerouteTestGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DEXTracerouteTestGetResponseEnvelopeMessages] -type dexTracerouteTestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DEXTracerouteTestGetResponseEnvelopeSuccess bool @@ -1049,7 +525,7 @@ type DEXTracerouteTestNetworkPathParams struct { // `url.Values`. func (r DEXTracerouteTestNetworkPathParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -1071,9 +547,9 @@ func (r DEXTracerouteTestNetworkPathParamsInterval) IsKnown() bool { } type DEXTracerouteTestNetworkPathResponseEnvelope struct { - Errors []DEXTracerouteTestNetworkPathResponseEnvelopeErrors `json:"errors,required"` - Messages []DEXTracerouteTestNetworkPathResponseEnvelopeMessages `json:"messages,required"` - Result DigitalExperienceMonitoringTracerouteTestNetworkPath `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NetworkPath `json:"result,required"` // Whether the API call was successful Success DEXTracerouteTestNetworkPathResponseEnvelopeSuccess `json:"success,required"` JSON dexTracerouteTestNetworkPathResponseEnvelopeJSON `json:"-"` @@ -1098,52 +574,6 @@ func (r dexTracerouteTestNetworkPathResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DEXTracerouteTestNetworkPathResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DEXTracerouteTestNetworkPathResponseEnvelopeErrors] -type dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestNetworkPathResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DEXTracerouteTestNetworkPathResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DEXTracerouteTestNetworkPathResponseEnvelopeMessages] -type dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestNetworkPathResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DEXTracerouteTestNetworkPathResponseEnvelopeSuccess bool @@ -1177,15 +607,15 @@ type DEXTracerouteTestPercentilesParams struct { // `url.Values`. func (r DEXTracerouteTestPercentilesParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type DEXTracerouteTestPercentilesResponseEnvelope struct { - Errors []DEXTracerouteTestPercentilesResponseEnvelopeErrors `json:"errors,required"` - Messages []DEXTracerouteTestPercentilesResponseEnvelopeMessages `json:"messages,required"` - Result DigitalExperienceMonitoringTracerouteDetailsPercentiles `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DEXTracerouteTestPercentilesResponse `json:"result,required"` // Whether the API call was successful Success DEXTracerouteTestPercentilesResponseEnvelopeSuccess `json:"success,required"` JSON dexTracerouteTestPercentilesResponseEnvelopeJSON `json:"-"` @@ -1210,52 +640,6 @@ func (r dexTracerouteTestPercentilesResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DEXTracerouteTestPercentilesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DEXTracerouteTestPercentilesResponseEnvelopeErrors] -type dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestPercentilesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DEXTracerouteTestPercentilesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DEXTracerouteTestPercentilesResponseEnvelopeMessages] -type dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestPercentilesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DEXTracerouteTestPercentilesResponseEnvelopeSuccess bool diff --git a/zero_trust/dextraceroutetestresultnetworkpath.go b/zero_trust/dextraceroutetestresultnetworkpath.go index cf89d230d0e..6717f267c86 100644 --- a/zero_trust/dextraceroutetestresultnetworkpath.go +++ b/zero_trust/dextraceroutetestresultnetworkpath.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewDEXTracerouteTestResultNetworkPathService(opts ...option.RequestOption) // Get a breakdown of hops and performance metrics for a specific traceroute test // run -func (r *DEXTracerouteTestResultNetworkPathService) Get(ctx context.Context, testResultID string, query DEXTracerouteTestResultNetworkPathGetParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteTestResultNetworkPath, err error) { +func (r *DEXTracerouteTestResultNetworkPathService) Get(ctx context.Context, testResultID string, query DEXTracerouteTestResultNetworkPathGetParams, opts ...option.RequestOption) (res *DEXTracerouteTestResultNetworkPathGetResponse, err error) { opts = append(r.Options[:], opts...) var env DEXTracerouteTestResultNetworkPathGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dex/traceroute-test-results/%s/network-path", query.AccountID, testResultID) @@ -46,9 +47,9 @@ func (r *DEXTracerouteTestResultNetworkPathService) Get(ctx context.Context, tes return } -type DigitalExperienceMonitoringTracerouteTestResultNetworkPath struct { +type DEXTracerouteTestResultNetworkPathGetResponse struct { // an array of the hops taken by the device to reach the end destination - Hops []DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop `json:"hops,required"` + Hops []DEXTracerouteTestResultNetworkPathGetResponseHop `json:"hops,required"` // API Resource UUID tag. ResultID string `json:"resultId,required"` // date time of this traceroute test @@ -58,14 +59,13 @@ type DigitalExperienceMonitoringTracerouteTestResultNetworkPath struct { // API Resource UUID tag. TestID string `json:"testId"` // name of the tracroute test - TestName string `json:"testName"` - JSON digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON `json:"-"` + TestName string `json:"testName"` + JSON dexTracerouteTestResultNetworkPathGetResponseJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON contains the JSON -// metadata for the struct -// [DigitalExperienceMonitoringTracerouteTestResultNetworkPath] -type digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON struct { +// dexTracerouteTestResultNetworkPathGetResponseJSON contains the JSON metadata for +// the struct [DEXTracerouteTestResultNetworkPathGetResponse] +type dexTracerouteTestResultNetworkPathGetResponseJSON struct { Hops apijson.Field ResultID apijson.Field TimeStart apijson.Field @@ -76,31 +76,30 @@ type digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteTestResultNetworkPath) UnmarshalJSON(data []byte) (err error) { +func (r *DEXTracerouteTestResultNetworkPathGetResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON) RawJSON() string { +func (r dexTracerouteTestResultNetworkPathGetResponseJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop struct { - TTL int64 `json:"ttl,required"` - ASN int64 `json:"asn,nullable"` - Aso string `json:"aso,nullable"` - IPAddress string `json:"ipAddress,nullable"` - Location DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation `json:"location,nullable"` - Mile DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile `json:"mile,nullable"` - Name string `json:"name,nullable"` - PacketLossPct float64 `json:"packetLossPct,nullable"` - RTTMs int64 `json:"rttMs,nullable"` - JSON digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON `json:"-"` +type DEXTracerouteTestResultNetworkPathGetResponseHop struct { + TTL int64 `json:"ttl,required"` + ASN int64 `json:"asn,nullable"` + Aso string `json:"aso,nullable"` + IPAddress string `json:"ipAddress,nullable"` + Location DEXTracerouteTestResultNetworkPathGetResponseHopsLocation `json:"location,nullable"` + Mile DEXTracerouteTestResultNetworkPathGetResponseHopsMile `json:"mile,nullable"` + Name string `json:"name,nullable"` + PacketLossPct float64 `json:"packetLossPct,nullable"` + RTTMs int64 `json:"rttMs,nullable"` + JSON dexTracerouteTestResultNetworkPathGetResponseHopJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON contains the -// JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop] -type digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON struct { +// dexTracerouteTestResultNetworkPathGetResponseHopJSON contains the JSON metadata +// for the struct [DEXTracerouteTestResultNetworkPathGetResponseHop] +type dexTracerouteTestResultNetworkPathGetResponseHopJSON struct { TTL apijson.Field ASN apijson.Field Aso apijson.Field @@ -114,25 +113,25 @@ type digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON struct { ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop) UnmarshalJSON(data []byte) (err error) { +func (r *DEXTracerouteTestResultNetworkPathGetResponseHop) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON) RawJSON() string { +func (r dexTracerouteTestResultNetworkPathGetResponseHopJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation struct { - City string `json:"city,nullable"` - State string `json:"state,nullable"` - Zip string `json:"zip,nullable"` - JSON digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON `json:"-"` +type DEXTracerouteTestResultNetworkPathGetResponseHopsLocation struct { + City string `json:"city,nullable"` + State string `json:"state,nullable"` + Zip string `json:"zip,nullable"` + JSON dexTracerouteTestResultNetworkPathGetResponseHopsLocationJSON `json:"-"` } -// digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON -// contains the JSON metadata for the struct -// [DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation] -type digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON struct { +// dexTracerouteTestResultNetworkPathGetResponseHopsLocationJSON contains the JSON +// metadata for the struct +// [DEXTracerouteTestResultNetworkPathGetResponseHopsLocation] +type dexTracerouteTestResultNetworkPathGetResponseHopsLocationJSON struct { City apijson.Field State apijson.Field Zip apijson.Field @@ -140,26 +139,26 @@ type digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON ExtraFields map[string]apijson.Field } -func (r *DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation) UnmarshalJSON(data []byte) (err error) { +func (r *DEXTracerouteTestResultNetworkPathGetResponseHopsLocation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON) RawJSON() string { +func (r dexTracerouteTestResultNetworkPathGetResponseHopsLocationJSON) RawJSON() string { return r.raw } -type DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile string +type DEXTracerouteTestResultNetworkPathGetResponseHopsMile string const ( - DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToApp DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-app" - DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToCfEgress DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-cf-egress" - DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToCfIngress DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-cf-ingress" - DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToIsp DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-isp" + DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToApp DEXTracerouteTestResultNetworkPathGetResponseHopsMile = "client-to-app" + DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToCfEgress DEXTracerouteTestResultNetworkPathGetResponseHopsMile = "client-to-cf-egress" + DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToCfIngress DEXTracerouteTestResultNetworkPathGetResponseHopsMile = "client-to-cf-ingress" + DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToIsp DEXTracerouteTestResultNetworkPathGetResponseHopsMile = "client-to-isp" ) -func (r DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile) IsKnown() bool { +func (r DEXTracerouteTestResultNetworkPathGetResponseHopsMile) IsKnown() bool { switch r { - case DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToApp, DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToCfEgress, DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToCfIngress, DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToIsp: + case DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToApp, DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToCfEgress, DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToCfIngress, DEXTracerouteTestResultNetworkPathGetResponseHopsMileClientToIsp: return true } return false @@ -170,9 +169,9 @@ type DEXTracerouteTestResultNetworkPathGetParams struct { } type DEXTracerouteTestResultNetworkPathGetResponseEnvelope struct { - Errors []DEXTracerouteTestResultNetworkPathGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DEXTracerouteTestResultNetworkPathGetResponseEnvelopeMessages `json:"messages,required"` - Result DigitalExperienceMonitoringTracerouteTestResultNetworkPath `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DEXTracerouteTestResultNetworkPathGetResponse `json:"result,required"` // Whether the API call was successful Success DEXTracerouteTestResultNetworkPathGetResponseEnvelopeSuccess `json:"success,required"` JSON dexTracerouteTestResultNetworkPathGetResponseEnvelopeJSON `json:"-"` @@ -197,54 +196,6 @@ func (r dexTracerouteTestResultNetworkPathGetResponseEnvelopeJSON) RawJSON() str return r.raw } -type DEXTracerouteTestResultNetworkPathGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestResultNetworkPathGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dexTracerouteTestResultNetworkPathGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [DEXTracerouteTestResultNetworkPathGetResponseEnvelopeErrors] -type dexTracerouteTestResultNetworkPathGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestResultNetworkPathGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestResultNetworkPathGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DEXTracerouteTestResultNetworkPathGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dexTracerouteTestResultNetworkPathGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dexTracerouteTestResultNetworkPathGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [DEXTracerouteTestResultNetworkPathGetResponseEnvelopeMessages] -type dexTracerouteTestResultNetworkPathGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DEXTracerouteTestResultNetworkPathGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dexTracerouteTestResultNetworkPathGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DEXTracerouteTestResultNetworkPathGetResponseEnvelopeSuccess bool diff --git a/zero_trust/dlpdataset.go b/zero_trust/dlpdataset.go index 6fc62998d60..92ea4f32345 100644 --- a/zero_trust/dlpdataset.go +++ b/zero_trust/dlpdataset.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -35,7 +36,7 @@ func NewDLPDatasetService(opts ...option.RequestOption) (r *DLPDatasetService) { } // Create a new dataset. -func (r *DLPDatasetService) New(ctx context.Context, params DLPDatasetNewParams, opts ...option.RequestOption) (res *DLPDatasetCreation, err error) { +func (r *DLPDatasetService) New(ctx context.Context, params DLPDatasetNewParams, opts ...option.RequestOption) (res *DatasetCreation, err error) { opts = append(r.Options[:], opts...) var env DLPDatasetNewResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/datasets", params.AccountID) @@ -48,7 +49,7 @@ func (r *DLPDatasetService) New(ctx context.Context, params DLPDatasetNewParams, } // Update details about a dataset. -func (r *DLPDatasetService) Update(ctx context.Context, datasetID string, params DLPDatasetUpdateParams, opts ...option.RequestOption) (res *DLPDataset, err error) { +func (r *DLPDatasetService) Update(ctx context.Context, datasetID string, params DLPDatasetUpdateParams, opts ...option.RequestOption) (res *Dataset, err error) { opts = append(r.Options[:], opts...) var env DLPDatasetUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", params.AccountID, datasetID) @@ -61,7 +62,7 @@ func (r *DLPDatasetService) Update(ctx context.Context, datasetID string, params } // Fetch all datasets with information about available versions. -func (r *DLPDatasetService) List(ctx context.Context, query DLPDatasetListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DLPDataset], err error) { +func (r *DLPDatasetService) List(ctx context.Context, query DLPDatasetListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Dataset], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -79,7 +80,7 @@ func (r *DLPDatasetService) List(ctx context.Context, query DLPDatasetListParams } // Fetch all datasets with information about available versions. -func (r *DLPDatasetService) ListAutoPaging(ctx context.Context, query DLPDatasetListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DLPDataset] { +func (r *DLPDatasetService) ListAutoPaging(ctx context.Context, query DLPDatasetListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Dataset] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -95,7 +96,7 @@ func (r *DLPDatasetService) Delete(ctx context.Context, datasetID string, body D } // Fetch a specific dataset with information about available versions. -func (r *DLPDatasetService) Get(ctx context.Context, datasetID string, query DLPDatasetGetParams, opts ...option.RequestOption) (res *DLPDataset, err error) { +func (r *DLPDatasetService) Get(ctx context.Context, datasetID string, query DLPDatasetGetParams, opts ...option.RequestOption) (res *Dataset, err error) { opts = append(r.Options[:], opts...) var env DLPDatasetGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", query.AccountID, datasetID) @@ -107,21 +108,21 @@ func (r *DLPDatasetService) Get(ctx context.Context, datasetID string, query DLP return } -type DLPDataset struct { - ID string `json:"id,required" format:"uuid"` - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - Name string `json:"name,required"` - NumCells int64 `json:"num_cells,required"` - Secret bool `json:"secret,required"` - Status DLPDatasetStatus `json:"status,required"` - UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` - Uploads []DLPDatasetUpload `json:"uploads,required"` - Description string `json:"description,nullable"` - JSON dlpDatasetJSON `json:"-"` +type Dataset struct { + ID string `json:"id,required" format:"uuid"` + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + Name string `json:"name,required"` + NumCells int64 `json:"num_cells,required"` + Secret bool `json:"secret,required"` + Status DatasetStatus `json:"status,required"` + UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` + Uploads []DatasetUpload `json:"uploads,required"` + Description string `json:"description,nullable"` + JSON datasetJSON `json:"-"` } -// dlpDatasetJSON contains the JSON metadata for the struct [DLPDataset] -type dlpDatasetJSON struct { +// datasetJSON contains the JSON metadata for the struct [Dataset] +type datasetJSON struct { ID apijson.Field CreatedAt apijson.Field Name apijson.Field @@ -135,41 +136,40 @@ type dlpDatasetJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPDataset) UnmarshalJSON(data []byte) (err error) { +func (r *Dataset) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpDatasetJSON) RawJSON() string { +func (r datasetJSON) RawJSON() string { return r.raw } -type DLPDatasetStatus string +type DatasetStatus string const ( - DLPDatasetStatusEmpty DLPDatasetStatus = "empty" - DLPDatasetStatusUploading DLPDatasetStatus = "uploading" - DLPDatasetStatusFailed DLPDatasetStatus = "failed" - DLPDatasetStatusComplete DLPDatasetStatus = "complete" + DatasetStatusEmpty DatasetStatus = "empty" + DatasetStatusUploading DatasetStatus = "uploading" + DatasetStatusFailed DatasetStatus = "failed" + DatasetStatusComplete DatasetStatus = "complete" ) -func (r DLPDatasetStatus) IsKnown() bool { +func (r DatasetStatus) IsKnown() bool { switch r { - case DLPDatasetStatusEmpty, DLPDatasetStatusUploading, DLPDatasetStatusFailed, DLPDatasetStatusComplete: + case DatasetStatusEmpty, DatasetStatusUploading, DatasetStatusFailed, DatasetStatusComplete: return true } return false } -type DLPDatasetUpload struct { - NumCells int64 `json:"num_cells,required"` - Status DLPDatasetUploadsStatus `json:"status,required"` - Version int64 `json:"version,required"` - JSON dlpDatasetUploadJSON `json:"-"` +type DatasetUpload struct { + NumCells int64 `json:"num_cells,required"` + Status DatasetUploadsStatus `json:"status,required"` + Version int64 `json:"version,required"` + JSON datasetUploadJSON `json:"-"` } -// dlpDatasetUploadJSON contains the JSON metadata for the struct -// [DLPDatasetUpload] -type dlpDatasetUploadJSON struct { +// datasetUploadJSON contains the JSON metadata for the struct [DatasetUpload] +type datasetUploadJSON struct { NumCells apijson.Field Status apijson.Field Version apijson.Field @@ -177,47 +177,46 @@ type dlpDatasetUploadJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPDatasetUpload) UnmarshalJSON(data []byte) (err error) { +func (r *DatasetUpload) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpDatasetUploadJSON) RawJSON() string { +func (r datasetUploadJSON) RawJSON() string { return r.raw } -type DLPDatasetUploadsStatus string +type DatasetUploadsStatus string const ( - DLPDatasetUploadsStatusEmpty DLPDatasetUploadsStatus = "empty" - DLPDatasetUploadsStatusUploading DLPDatasetUploadsStatus = "uploading" - DLPDatasetUploadsStatusFailed DLPDatasetUploadsStatus = "failed" - DLPDatasetUploadsStatusComplete DLPDatasetUploadsStatus = "complete" + DatasetUploadsStatusEmpty DatasetUploadsStatus = "empty" + DatasetUploadsStatusUploading DatasetUploadsStatus = "uploading" + DatasetUploadsStatusFailed DatasetUploadsStatus = "failed" + DatasetUploadsStatusComplete DatasetUploadsStatus = "complete" ) -func (r DLPDatasetUploadsStatus) IsKnown() bool { +func (r DatasetUploadsStatus) IsKnown() bool { switch r { - case DLPDatasetUploadsStatusEmpty, DLPDatasetUploadsStatusUploading, DLPDatasetUploadsStatusFailed, DLPDatasetUploadsStatusComplete: + case DatasetUploadsStatusEmpty, DatasetUploadsStatusUploading, DatasetUploadsStatusFailed, DatasetUploadsStatusComplete: return true } return false } -type DLPDatasetArray []DLPDataset +type DatasetArray []Dataset -type DLPDatasetCreation struct { - Dataset DLPDataset `json:"dataset,required"` - MaxCells int64 `json:"max_cells,required"` +type DatasetCreation struct { + Dataset Dataset `json:"dataset,required"` + MaxCells int64 `json:"max_cells,required"` // The version to use when uploading the dataset. Version int64 `json:"version,required"` // The secret to use for Exact Data Match datasets. This is not present in Custom // Wordlists. - Secret string `json:"secret" format:"password"` - JSON dlpDatasetCreationJSON `json:"-"` + Secret string `json:"secret" format:"password"` + JSON datasetCreationJSON `json:"-"` } -// dlpDatasetCreationJSON contains the JSON metadata for the struct -// [DLPDatasetCreation] -type dlpDatasetCreationJSON struct { +// datasetCreationJSON contains the JSON metadata for the struct [DatasetCreation] +type datasetCreationJSON struct { Dataset apijson.Field MaxCells apijson.Field Version apijson.Field @@ -226,11 +225,11 @@ type dlpDatasetCreationJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPDatasetCreation) UnmarshalJSON(data []byte) (err error) { +func (r *DatasetCreation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpDatasetCreationJSON) RawJSON() string { +func (r datasetCreationJSON) RawJSON() string { return r.raw } @@ -250,10 +249,10 @@ func (r DLPDatasetNewParams) MarshalJSON() (data []byte, err error) { } type DLPDatasetNewResponseEnvelope struct { - Errors []DLPDatasetNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPDatasetNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` Success bool `json:"success,required"` - Result DLPDatasetCreation `json:"result"` + Result DatasetCreation `json:"result"` ResultInfo DLPDatasetNewResponseEnvelopeResultInfo `json:"result_info"` JSON dlpDatasetNewResponseEnvelopeJSON `json:"-"` } @@ -278,52 +277,6 @@ func (r dlpDatasetNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPDatasetNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpDatasetNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPDatasetNewResponseEnvelopeErrors] -type dlpDatasetNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPDatasetNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpDatasetNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DLPDatasetNewResponseEnvelopeMessages] -type dlpDatasetNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type DLPDatasetNewResponseEnvelopeResultInfo struct { // total number of pages Count int64 `json:"count,required"` @@ -366,10 +319,10 @@ func (r DLPDatasetUpdateParams) MarshalJSON() (data []byte, err error) { } type DLPDatasetUpdateResponseEnvelope struct { - Errors []DLPDatasetUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPDatasetUpdateResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` Success bool `json:"success,required"` - Result DLPDataset `json:"result"` + Result Dataset `json:"result"` ResultInfo DLPDatasetUpdateResponseEnvelopeResultInfo `json:"result_info"` JSON dlpDatasetUpdateResponseEnvelopeJSON `json:"-"` } @@ -394,52 +347,6 @@ func (r dlpDatasetUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPDatasetUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpDatasetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPDatasetUpdateResponseEnvelopeErrors] -type dlpDatasetUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPDatasetUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpDatasetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DLPDatasetUpdateResponseEnvelopeMessages] -type dlpDatasetUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type DLPDatasetUpdateResponseEnvelopeResultInfo struct { // total number of pages Count int64 `json:"count,required"` @@ -484,10 +391,10 @@ type DLPDatasetGetParams struct { } type DLPDatasetGetResponseEnvelope struct { - Errors []DLPDatasetGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPDatasetGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` Success bool `json:"success,required"` - Result DLPDataset `json:"result"` + Result Dataset `json:"result"` ResultInfo DLPDatasetGetResponseEnvelopeResultInfo `json:"result_info"` JSON dlpDatasetGetResponseEnvelopeJSON `json:"-"` } @@ -512,52 +419,6 @@ func (r dlpDatasetGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPDatasetGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpDatasetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPDatasetGetResponseEnvelopeErrors] -type dlpDatasetGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPDatasetGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpDatasetGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DLPDatasetGetResponseEnvelopeMessages] -type dlpDatasetGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type DLPDatasetGetResponseEnvelopeResultInfo struct { // total number of pages Count int64 `json:"count,required"` diff --git a/zero_trust/dlpdatasetupload.go b/zero_trust/dlpdatasetupload.go index 893e6b00204..6f17dd6f6a7 100644 --- a/zero_trust/dlpdatasetupload.go +++ b/zero_trust/dlpdatasetupload.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewDLPDatasetUploadService(opts ...option.RequestOption) (r *DLPDatasetUplo } // Prepare to upload a new version of a dataset. -func (r *DLPDatasetUploadService) New(ctx context.Context, datasetID string, body DLPDatasetUploadNewParams, opts ...option.RequestOption) (res *DLPDatasetNewVersion, err error) { +func (r *DLPDatasetUploadService) New(ctx context.Context, datasetID string, body DLPDatasetUploadNewParams, opts ...option.RequestOption) (res *NewVersion, err error) { opts = append(r.Options[:], opts...) var env DLPDatasetUploadNewResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/datasets/%s/upload", body.AccountID, datasetID) @@ -45,11 +46,11 @@ func (r *DLPDatasetUploadService) New(ctx context.Context, datasetID string, bod } // Upload a new version of a dataset. -func (r *DLPDatasetUploadService) Edit(ctx context.Context, datasetID string, version int64, body DLPDatasetUploadEditParams, opts ...option.RequestOption) (res *DLPDataset, err error) { +func (r *DLPDatasetUploadService) Edit(ctx context.Context, datasetID string, version int64, params DLPDatasetUploadEditParams, opts ...option.RequestOption) (res *Dataset, err error) { opts = append(r.Options[:], opts...) var env DLPDatasetUploadEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/datasets/%s/upload/%v", body.AccountID, datasetID, version) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + path := fmt.Sprintf("accounts/%s/dlp/datasets/%s/upload/%v", params.AccountID, datasetID, version) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) if err != nil { return } @@ -57,16 +58,15 @@ func (r *DLPDatasetUploadService) Edit(ctx context.Context, datasetID string, ve return } -type DLPDatasetNewVersion struct { - MaxCells int64 `json:"max_cells,required"` - Version int64 `json:"version,required"` - Secret string `json:"secret" format:"password"` - JSON dlpDatasetNewVersionJSON `json:"-"` +type NewVersion struct { + MaxCells int64 `json:"max_cells,required"` + Version int64 `json:"version,required"` + Secret string `json:"secret" format:"password"` + JSON newVersionJSON `json:"-"` } -// dlpDatasetNewVersionJSON contains the JSON metadata for the struct -// [DLPDatasetNewVersion] -type dlpDatasetNewVersionJSON struct { +// newVersionJSON contains the JSON metadata for the struct [NewVersion] +type newVersionJSON struct { MaxCells apijson.Field Version apijson.Field Secret apijson.Field @@ -74,11 +74,11 @@ type dlpDatasetNewVersionJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPDatasetNewVersion) UnmarshalJSON(data []byte) (err error) { +func (r *NewVersion) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpDatasetNewVersionJSON) RawJSON() string { +func (r newVersionJSON) RawJSON() string { return r.raw } @@ -87,10 +87,10 @@ type DLPDatasetUploadNewParams struct { } type DLPDatasetUploadNewResponseEnvelope struct { - Errors []DLPDatasetUploadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPDatasetUploadNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` Success bool `json:"success,required"` - Result DLPDatasetNewVersion `json:"result"` + Result NewVersion `json:"result"` ResultInfo DLPDatasetUploadNewResponseEnvelopeResultInfo `json:"result_info"` JSON dlpDatasetUploadNewResponseEnvelopeJSON `json:"-"` } @@ -115,52 +115,6 @@ func (r dlpDatasetUploadNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPDatasetUploadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetUploadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpDatasetUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPDatasetUploadNewResponseEnvelopeErrors] -type dlpDatasetUploadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPDatasetUploadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetUploadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpDatasetUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DLPDatasetUploadNewResponseEnvelopeMessages] -type dlpDatasetUploadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type DLPDatasetUploadNewResponseEnvelopeResultInfo struct { // total number of pages Count int64 `json:"count,required"` @@ -194,13 +148,18 @@ func (r dlpDatasetUploadNewResponseEnvelopeResultInfoJSON) RawJSON() string { type DLPDatasetUploadEditParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DLPDatasetUploadEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DLPDatasetUploadEditResponseEnvelope struct { - Errors []DLPDatasetUploadEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPDatasetUploadEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` Success bool `json:"success,required"` - Result DLPDataset `json:"result"` + Result Dataset `json:"result"` ResultInfo DLPDatasetUploadEditResponseEnvelopeResultInfo `json:"result_info"` JSON dlpDatasetUploadEditResponseEnvelopeJSON `json:"-"` } @@ -225,52 +184,6 @@ func (r dlpDatasetUploadEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPDatasetUploadEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetUploadEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpDatasetUploadEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DLPDatasetUploadEditResponseEnvelopeErrors] -type dlpDatasetUploadEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetUploadEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetUploadEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPDatasetUploadEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpDatasetUploadEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpDatasetUploadEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DLPDatasetUploadEditResponseEnvelopeMessages] -type dlpDatasetUploadEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPDatasetUploadEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpDatasetUploadEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type DLPDatasetUploadEditResponseEnvelopeResultInfo struct { // total number of pages Count int64 `json:"count,required"` diff --git a/zero_trust/dlpdatasetupload_test.go b/zero_trust/dlpdatasetupload_test.go index c9567db5f5d..194c2632519 100644 --- a/zero_trust/dlpdatasetupload_test.go +++ b/zero_trust/dlpdatasetupload_test.go @@ -64,6 +64,7 @@ func TestDLPDatasetUploadEdit(t *testing.T) { int64(0), zero_trust.DLPDatasetUploadEditParams{ AccountID: cloudflare.F("string"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/dlppattern.go b/zero_trust/dlppattern.go index 5db88d0e433..55606e98fdb 100644 --- a/zero_trust/dlppattern.go +++ b/zero_trust/dlppattern.go @@ -10,6 +10,8 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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/logpush" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -34,7 +36,7 @@ func NewDLPPatternService(opts ...option.RequestOption) (r *DLPPatternService) { // regular expression is too complex or can match an unbounded-length string. Your // regex will be rejected if it uses the Kleene Star -- be sure to bound the // maximum number of characters that can be matched. -func (r *DLPPatternService) Validate(ctx context.Context, params DLPPatternValidateParams, opts ...option.RequestOption) (res *DLPPatternValidateResponse, err error) { +func (r *DLPPatternService) Validate(ctx context.Context, params DLPPatternValidateParams, opts ...option.RequestOption) (res *logpush.OwnershipValidation, err error) { opts = append(r.Options[:], opts...) var env DLPPatternValidateResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/patterns/validate", params.AccountID) @@ -46,27 +48,6 @@ func (r *DLPPatternService) Validate(ctx context.Context, params DLPPatternValid return } -type DLPPatternValidateResponse struct { - Valid bool `json:"valid"` - JSON dlpPatternValidateResponseJSON `json:"-"` -} - -// dlpPatternValidateResponseJSON contains the JSON metadata for the struct -// [DLPPatternValidateResponse] -type dlpPatternValidateResponseJSON struct { - Valid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPatternValidateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPatternValidateResponseJSON) RawJSON() string { - return r.raw -} - type DLPPatternValidateParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -79,9 +60,9 @@ func (r DLPPatternValidateParams) MarshalJSON() (data []byte, err error) { } type DLPPatternValidateResponseEnvelope struct { - Errors []DLPPatternValidateResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPPatternValidateResponseEnvelopeMessages `json:"messages,required"` - Result DLPPatternValidateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result logpush.OwnershipValidation `json:"result,required,nullable"` // Whether the API call was successful Success DLPPatternValidateResponseEnvelopeSuccess `json:"success,required"` JSON dlpPatternValidateResponseEnvelopeJSON `json:"-"` @@ -106,52 +87,6 @@ func (r dlpPatternValidateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPPatternValidateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpPatternValidateResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpPatternValidateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPPatternValidateResponseEnvelopeErrors] -type dlpPatternValidateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPatternValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPatternValidateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPPatternValidateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpPatternValidateResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpPatternValidateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DLPPatternValidateResponseEnvelopeMessages] -type dlpPatternValidateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPatternValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPatternValidateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPPatternValidateResponseEnvelopeSuccess bool diff --git a/zero_trust/dlppayloadlog.go b/zero_trust/dlppayloadlog.go index 399bf43ff51..d5884b7236c 100644 --- a/zero_trust/dlppayloadlog.go +++ b/zero_trust/dlppayloadlog.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -111,9 +112,9 @@ func (r DLPPayloadLogUpdateParams) MarshalJSON() (data []byte, err error) { } type DLPPayloadLogUpdateResponseEnvelope struct { - Errors []DLPPayloadLogUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPPayloadLogUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DLPPayloadLogUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DLPPayloadLogUpdateResponse `json:"result,required"` // Whether the API call was successful Success DLPPayloadLogUpdateResponseEnvelopeSuccess `json:"success,required"` JSON dlpPayloadLogUpdateResponseEnvelopeJSON `json:"-"` @@ -138,52 +139,6 @@ func (r dlpPayloadLogUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPPayloadLogUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpPayloadLogUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpPayloadLogUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPPayloadLogUpdateResponseEnvelopeErrors] -type dlpPayloadLogUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPayloadLogUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPayloadLogUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPPayloadLogUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpPayloadLogUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpPayloadLogUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DLPPayloadLogUpdateResponseEnvelopeMessages] -type dlpPayloadLogUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPayloadLogUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPayloadLogUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPPayloadLogUpdateResponseEnvelopeSuccess bool @@ -205,9 +160,9 @@ type DLPPayloadLogGetParams struct { } type DLPPayloadLogGetResponseEnvelope struct { - Errors []DLPPayloadLogGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPPayloadLogGetResponseEnvelopeMessages `json:"messages,required"` - Result DLPPayloadLogGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DLPPayloadLogGetResponse `json:"result,required"` // Whether the API call was successful Success DLPPayloadLogGetResponseEnvelopeSuccess `json:"success,required"` JSON dlpPayloadLogGetResponseEnvelopeJSON `json:"-"` @@ -232,52 +187,6 @@ func (r dlpPayloadLogGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPPayloadLogGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpPayloadLogGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpPayloadLogGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPPayloadLogGetResponseEnvelopeErrors] -type dlpPayloadLogGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPayloadLogGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPayloadLogGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPPayloadLogGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpPayloadLogGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpPayloadLogGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DLPPayloadLogGetResponseEnvelopeMessages] -type dlpPayloadLogGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPayloadLogGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPayloadLogGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPPayloadLogGetResponseEnvelopeSuccess bool diff --git a/zero_trust/dlpprofile.go b/zero_trust/dlpprofile.go index c4da93720f3..e96d9b5c228 100644 --- a/zero_trust/dlpprofile.go +++ b/zero_trust/dlpprofile.go @@ -13,6 +13,7 @@ import ( "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" ) @@ -39,7 +40,7 @@ func NewDLPProfileService(opts ...option.RequestOption) (r *DLPProfileService) { } // Lists all DLP profiles in an account. -func (r *DLPProfileService) List(ctx context.Context, query DLPProfileListParams, opts ...option.RequestOption) (res *pagination.SinglePage[DLPProfiles], err error) { +func (r *DLPProfileService) List(ctx context.Context, query DLPProfileListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Profile], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -57,7 +58,7 @@ func (r *DLPProfileService) List(ctx context.Context, query DLPProfileListParams } // Lists all DLP profiles in an account. -func (r *DLPProfileService) ListAutoPaging(ctx context.Context, query DLPProfileListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[DLPProfiles] { +func (r *DLPProfileService) ListAutoPaging(ctx context.Context, query DLPProfileListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Profile] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -74,50 +75,147 @@ func (r *DLPProfileService) Get(ctx context.Context, profileID string, query DLP return } -// Union satisfied by [zero_trust.DLPPredefinedProfile], -// [zero_trust.DLPCustomProfile] or [zero_trust.DLPProfilesDLPIntegrationProfile]. -type DLPProfiles interface { - implementsZeroTrustDLPProfiles() +// Scan the context of predefined entries to only return matches surrounded by +// keywords. +type ContextAwareness struct { + // If true, scan the context of predefined entries to only return matches + // surrounded by keywords. + Enabled bool `json:"enabled,required"` + // Content types to exclude from context analysis and return all matches. + Skip SkipConfiguration `json:"skip,required"` + JSON contextAwarenessJSON `json:"-"` +} + +// contextAwarenessJSON contains the JSON metadata for the struct +// [ContextAwareness] +type contextAwarenessJSON struct { + Enabled apijson.Field + Skip apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ContextAwareness) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r contextAwarenessJSON) RawJSON() string { + return r.raw +} + +// Scan the context of predefined entries to only return matches surrounded by +// keywords. +type ContextAwarenessParam struct { + // If true, scan the context of predefined entries to only return matches + // surrounded by keywords. + Enabled param.Field[bool] `json:"enabled,required"` + // Content types to exclude from context analysis and return all matches. + Skip param.Field[SkipConfigurationParam] `json:"skip,required"` +} + +func (r ContextAwarenessParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Profile struct { + // Related DLP policies will trigger when the match count exceeds the number set. + AllowedMatchCount float64 `json:"allowed_match_count"` + // Scan the context of predefined entries to only return matches surrounded by + // keywords. + ContextAwareness ContextAwareness `json:"context_awareness"` + Entries interface{} `json:"entries,required"` + // The ID for this profile + ID string `json:"id"` + // The name of the profile. + Name string `json:"name"` + // If true, scan images via OCR to determine if any text present matches filters. + OCREnabled bool `json:"ocr_enabled"` + // The type of the profile. + Type ProfileType `json:"type"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The description of the profile. + Description string `json:"description"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON profileJSON `json:"-"` + union ProfileUnion +} + +// profileJSON contains the JSON metadata for the struct [Profile] +type profileJSON struct { + AllowedMatchCount apijson.Field + ContextAwareness apijson.Field + Entries apijson.Field + ID apijson.Field + Name apijson.Field + OCREnabled apijson.Field + Type apijson.Field + CreatedAt apijson.Field + Description apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r profileJSON) RawJSON() string { + return r.raw +} + +func (r *Profile) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r Profile) AsUnion() ProfileUnion { + return r.union +} + +// Union satisfied by [zero_trust.PredefinedProfile], [zero_trust.CustomProfile] or +// [zero_trust.ProfileDLPIntegrationProfile]. +type ProfileUnion interface { + implementsZeroTrustProfile() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DLPProfiles)(nil)).Elem(), + reflect.TypeOf((*ProfileUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DLPPredefinedProfile{}), + Type: reflect.TypeOf(PredefinedProfile{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DLPCustomProfile{}), + Type: reflect.TypeOf(CustomProfile{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DLPProfilesDLPIntegrationProfile{}), + Type: reflect.TypeOf(ProfileDLPIntegrationProfile{}), }, ) } -type DLPProfilesDLPIntegrationProfile struct { +type ProfileDLPIntegrationProfile struct { // The ID for this profile ID string `json:"id"` CreatedAt time.Time `json:"created_at" format:"date-time"` // The description of the profile. Description string `json:"description"` // The entries for this profile. - Entries []DLPProfilesDLPIntegrationProfileEntry `json:"entries"` + Entries []ProfileDLPIntegrationProfileEntry `json:"entries"` // The name of the profile. Name string `json:"name"` // The type of the profile. - Type DLPProfilesDLPIntegrationProfileType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON dlpProfilesDLPIntegrationProfileJSON `json:"-"` + Type ProfileDLPIntegrationProfileType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON profileDLPIntegrationProfileJSON `json:"-"` } -// dlpProfilesDLPIntegrationProfileJSON contains the JSON metadata for the struct -// [DLPProfilesDLPIntegrationProfile] -type dlpProfilesDLPIntegrationProfileJSON struct { +// profileDLPIntegrationProfileJSON contains the JSON metadata for the struct +// [ProfileDLPIntegrationProfile] +type profileDLPIntegrationProfileJSON struct { ID apijson.Field CreatedAt apijson.Field Description apijson.Field @@ -129,18 +227,18 @@ type dlpProfilesDLPIntegrationProfileJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPProfilesDLPIntegrationProfile) UnmarshalJSON(data []byte) (err error) { +func (r *ProfileDLPIntegrationProfile) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpProfilesDLPIntegrationProfileJSON) RawJSON() string { +func (r profileDLPIntegrationProfileJSON) RawJSON() string { return r.raw } -func (r DLPProfilesDLPIntegrationProfile) implementsZeroTrustDLPProfiles() {} +func (r ProfileDLPIntegrationProfile) implementsZeroTrustProfile() {} // An entry derived from an integration -type DLPProfilesDLPIntegrationProfileEntry struct { +type ProfileDLPIntegrationProfileEntry struct { // The ID for this entry ID string `json:"id"` CreatedAt time.Time `json:"created_at" format:"date-time"` @@ -149,14 +247,14 @@ type DLPProfilesDLPIntegrationProfileEntry struct { // The name of the entry. Name string `json:"name"` // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON dlpProfilesDLPIntegrationProfileEntryJSON `json:"-"` + ProfileID interface{} `json:"profile_id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON profileDLPIntegrationProfileEntryJSON `json:"-"` } -// dlpProfilesDLPIntegrationProfileEntryJSON contains the JSON metadata for the -// struct [DLPProfilesDLPIntegrationProfileEntry] -type dlpProfilesDLPIntegrationProfileEntryJSON struct { +// profileDLPIntegrationProfileEntryJSON contains the JSON metadata for the struct +// [ProfileDLPIntegrationProfileEntry] +type profileDLPIntegrationProfileEntryJSON struct { ID apijson.Field CreatedAt apijson.Field Enabled apijson.Field @@ -167,47 +265,152 @@ type dlpProfilesDLPIntegrationProfileEntryJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPProfilesDLPIntegrationProfileEntry) UnmarshalJSON(data []byte) (err error) { +func (r *ProfileDLPIntegrationProfileEntry) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpProfilesDLPIntegrationProfileEntryJSON) RawJSON() string { +func (r profileDLPIntegrationProfileEntryJSON) RawJSON() string { return r.raw } // The type of the profile. -type DLPProfilesDLPIntegrationProfileType string +type ProfileDLPIntegrationProfileType string const ( - DLPProfilesDLPIntegrationProfileTypeIntegration DLPProfilesDLPIntegrationProfileType = "integration" + ProfileDLPIntegrationProfileTypeIntegration ProfileDLPIntegrationProfileType = "integration" ) -func (r DLPProfilesDLPIntegrationProfileType) IsKnown() bool { +func (r ProfileDLPIntegrationProfileType) IsKnown() bool { switch r { - case DLPProfilesDLPIntegrationProfileTypeIntegration: + case ProfileDLPIntegrationProfileTypeIntegration: return true } return false } -// Union satisfied by [zero_trust.DLPPredefinedProfile], -// [zero_trust.DLPCustomProfile] or +// The type of the profile. +type ProfileType string + +const ( + ProfileTypePredefined ProfileType = "predefined" + ProfileTypeCustom ProfileType = "custom" + ProfileTypeIntegration ProfileType = "integration" +) + +func (r ProfileType) IsKnown() bool { + switch r { + case ProfileTypePredefined, ProfileTypeCustom, ProfileTypeIntegration: + return true + } + return false +} + +// Content types to exclude from context analysis and return all matches. +type SkipConfiguration struct { + // If the content type is a file, skip context analysis and return all matches. + Files bool `json:"files,required"` + JSON skipConfigurationJSON `json:"-"` +} + +// skipConfigurationJSON contains the JSON metadata for the struct +// [SkipConfiguration] +type skipConfigurationJSON struct { + Files apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SkipConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r skipConfigurationJSON) RawJSON() string { + return r.raw +} + +// Content types to exclude from context analysis and return all matches. +type SkipConfigurationParam struct { + // If the content type is a file, skip context analysis and return all matches. + Files param.Field[bool] `json:"files,required"` +} + +func (r SkipConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPProfileGetResponse struct { + // Related DLP policies will trigger when the match count exceeds the number set. + AllowedMatchCount float64 `json:"allowed_match_count"` + // Scan the context of predefined entries to only return matches surrounded by + // keywords. + ContextAwareness ContextAwareness `json:"context_awareness"` + Entries interface{} `json:"entries,required"` + // The ID for this profile + ID string `json:"id"` + // The name of the profile. + Name string `json:"name"` + // If true, scan images via OCR to determine if any text present matches filters. + OCREnabled bool `json:"ocr_enabled"` + // The type of the profile. + Type DLPProfileGetResponseType `json:"type"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The description of the profile. + Description string `json:"description"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON dlpProfileGetResponseJSON `json:"-"` + union DLPProfileGetResponseUnion +} + +// dlpProfileGetResponseJSON contains the JSON metadata for the struct +// [DLPProfileGetResponse] +type dlpProfileGetResponseJSON struct { + AllowedMatchCount apijson.Field + ContextAwareness apijson.Field + Entries apijson.Field + ID apijson.Field + Name apijson.Field + OCREnabled apijson.Field + Type apijson.Field + CreatedAt apijson.Field + Description apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r dlpProfileGetResponseJSON) RawJSON() string { + return r.raw +} + +func (r *DLPProfileGetResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r DLPProfileGetResponse) AsUnion() DLPProfileGetResponseUnion { + return r.union +} + +// Union satisfied by [zero_trust.PredefinedProfile], [zero_trust.CustomProfile] or // [zero_trust.DLPProfileGetResponseDLPIntegrationProfile]. -type DLPProfileGetResponse interface { +type DLPProfileGetResponseUnion interface { implementsZeroTrustDLPProfileGetResponse() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DLPProfileGetResponse)(nil)).Elem(), + reflect.TypeOf((*DLPProfileGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DLPPredefinedProfile{}), + Type: reflect.TypeOf(PredefinedProfile{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DLPCustomProfile{}), + Type: reflect.TypeOf(CustomProfile{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -307,6 +510,23 @@ func (r DLPProfileGetResponseDLPIntegrationProfileType) IsKnown() bool { return false } +// The type of the profile. +type DLPProfileGetResponseType string + +const ( + DLPProfileGetResponseTypePredefined DLPProfileGetResponseType = "predefined" + DLPProfileGetResponseTypeCustom DLPProfileGetResponseType = "custom" + DLPProfileGetResponseTypeIntegration DLPProfileGetResponseType = "integration" +) + +func (r DLPProfileGetResponseType) IsKnown() bool { + switch r { + case DLPProfileGetResponseTypePredefined, DLPProfileGetResponseTypeCustom, DLPProfileGetResponseTypeIntegration: + return true + } + return false +} + type DLPProfileListParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` @@ -318,9 +538,9 @@ type DLPProfileGetParams struct { } type DLPProfileGetResponseEnvelope struct { - Errors []DLPProfileGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPProfileGetResponseEnvelopeMessages `json:"messages,required"` - Result DLPProfileGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DLPProfileGetResponse `json:"result,required"` // Whether the API call was successful Success DLPProfileGetResponseEnvelopeSuccess `json:"success,required"` JSON dlpProfileGetResponseEnvelopeJSON `json:"-"` @@ -345,52 +565,6 @@ func (r dlpProfileGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPProfileGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpProfileGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPProfileGetResponseEnvelopeErrors] -type dlpProfileGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPProfileGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpProfileGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DLPProfileGetResponseEnvelopeMessages] -type dlpProfileGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPProfileGetResponseEnvelopeSuccess bool diff --git a/zero_trust/dlpprofilecustom.go b/zero_trust/dlpprofilecustom.go index 1cc2fb552f2..b07dedce7b5 100644 --- a/zero_trust/dlpprofilecustom.go +++ b/zero_trust/dlpprofilecustom.go @@ -36,7 +36,7 @@ func NewDLPProfileCustomService(opts ...option.RequestOption) (r *DLPProfileCust } // Creates a set of DLP custom profiles. -func (r *DLPProfileCustomService) New(ctx context.Context, params DLPProfileCustomNewParams, opts ...option.RequestOption) (res *[]DLPCustomProfile, err error) { +func (r *DLPProfileCustomService) New(ctx context.Context, params DLPProfileCustomNewParams, opts ...option.RequestOption) (res *[]CustomProfile, err error) { opts = append(r.Options[:], opts...) var env DLPProfileCustomNewResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/profiles/custom", params.AccountID) @@ -49,7 +49,7 @@ func (r *DLPProfileCustomService) New(ctx context.Context, params DLPProfileCust } // Updates a DLP custom profile. -func (r *DLPProfileCustomService) Update(ctx context.Context, profileID string, params DLPProfileCustomUpdateParams, opts ...option.RequestOption) (res *DLPCustomProfile, err error) { +func (r *DLPProfileCustomService) Update(ctx context.Context, profileID string, params DLPProfileCustomUpdateParams, opts ...option.RequestOption) (res *CustomProfile, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", params.AccountID, profileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) @@ -57,10 +57,10 @@ func (r *DLPProfileCustomService) Update(ctx context.Context, profileID string, } // Deletes a DLP custom profile. -func (r *DLPProfileCustomService) Delete(ctx context.Context, profileID string, body DLPProfileCustomDeleteParams, opts ...option.RequestOption) (res *DLPProfileCustomDeleteResponse, err error) { +func (r *DLPProfileCustomService) Delete(ctx context.Context, profileID string, params DLPProfileCustomDeleteParams, opts ...option.RequestOption) (res *DLPProfileCustomDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env DLPProfileCustomDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", body.AccountID, profileID) + path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", params.AccountID, profileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -70,7 +70,7 @@ func (r *DLPProfileCustomService) Delete(ctx context.Context, profileID string, } // Fetches a custom DLP profile. -func (r *DLPProfileCustomService) Get(ctx context.Context, profileID string, query DLPProfileCustomGetParams, opts ...option.RequestOption) (res *DLPCustomProfile, err error) { +func (r *DLPProfileCustomService) Get(ctx context.Context, profileID string, query DLPProfileCustomGetParams, opts ...option.RequestOption) (res *CustomProfile, err error) { opts = append(r.Options[:], opts...) var env DLPProfileCustomGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", query.AccountID, profileID) @@ -82,32 +82,31 @@ func (r *DLPProfileCustomService) Get(ctx context.Context, profileID string, que return } -type DLPCustomProfile struct { +type CustomProfile struct { // The ID for this profile ID string `json:"id"` // Related DLP policies will trigger when the match count exceeds the number set. AllowedMatchCount float64 `json:"allowed_match_count"` // Scan the context of predefined entries to only return matches surrounded by // keywords. - ContextAwareness DLPCustomProfileContextAwareness `json:"context_awareness"` - CreatedAt time.Time `json:"created_at" format:"date-time"` + ContextAwareness ContextAwareness `json:"context_awareness"` + CreatedAt time.Time `json:"created_at" format:"date-time"` // The description of the profile. Description string `json:"description"` // The entries for this profile. - Entries []DLPCustomProfileEntry `json:"entries"` + Entries []CustomProfileEntry `json:"entries"` // The name of the profile. Name string `json:"name"` // If true, scan images via OCR to determine if any text present matches filters. OCREnabled bool `json:"ocr_enabled"` // The type of the profile. - Type DLPCustomProfileType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON dlpCustomProfileJSON `json:"-"` + Type CustomProfileType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON customProfileJSON `json:"-"` } -// dlpCustomProfileJSON contains the JSON metadata for the struct -// [DLPCustomProfile] -type dlpCustomProfileJSON struct { +// customProfileJSON contains the JSON metadata for the struct [CustomProfile] +type customProfileJSON struct { ID apijson.Field AllowedMatchCount apijson.Field ContextAwareness apijson.Field @@ -122,71 +121,20 @@ type dlpCustomProfileJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPCustomProfile) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpCustomProfileJSON) RawJSON() string { - return r.raw -} - -func (r DLPCustomProfile) implementsZeroTrustDLPProfiles() {} - -func (r DLPCustomProfile) implementsZeroTrustDLPProfileGetResponse() {} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type DLPCustomProfileContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip DLPCustomProfileContextAwarenessSkip `json:"skip,required"` - JSON dlpCustomProfileContextAwarenessJSON `json:"-"` -} - -// dlpCustomProfileContextAwarenessJSON contains the JSON metadata for the struct -// [DLPCustomProfileContextAwareness] -type dlpCustomProfileContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPCustomProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { +func (r *CustomProfile) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpCustomProfileContextAwarenessJSON) RawJSON() string { +func (r customProfileJSON) RawJSON() string { return r.raw } -// Content types to exclude from context analysis and return all matches. -type DLPCustomProfileContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON dlpCustomProfileContextAwarenessSkipJSON `json:"-"` -} - -// dlpCustomProfileContextAwarenessSkipJSON contains the JSON metadata for the -// struct [DLPCustomProfileContextAwarenessSkip] -type dlpCustomProfileContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} +func (r CustomProfile) implementsZeroTrustProfile() {} -func (r *DLPCustomProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpCustomProfileContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} +func (r CustomProfile) implementsZeroTrustDLPProfileGetResponse() {} // A custom entry that matches a profile -type DLPCustomProfileEntry struct { +type CustomProfileEntry struct { // The ID for this entry ID string `json:"id"` CreatedAt time.Time `json:"created_at" format:"date-time"` @@ -195,16 +143,16 @@ type DLPCustomProfileEntry struct { // The name of the entry. Name string `json:"name"` // A pattern that matches an entry - Pattern DLPCustomProfileEntriesPattern `json:"pattern"` + Pattern Pattern `json:"pattern"` // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON dlpCustomProfileEntryJSON `json:"-"` + ProfileID interface{} `json:"profile_id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON customProfileEntryJSON `json:"-"` } -// dlpCustomProfileEntryJSON contains the JSON metadata for the struct -// [DLPCustomProfileEntry] -type dlpCustomProfileEntryJSON struct { +// customProfileEntryJSON contains the JSON metadata for the struct +// [CustomProfileEntry] +type customProfileEntryJSON struct { ID apijson.Field CreatedAt apijson.Field Enabled apijson.Field @@ -216,81 +164,93 @@ type dlpCustomProfileEntryJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPCustomProfileEntry) UnmarshalJSON(data []byte) (err error) { +func (r *CustomProfileEntry) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpCustomProfileEntryJSON) RawJSON() string { +func (r customProfileEntryJSON) RawJSON() string { return r.raw } +// The type of the profile. +type CustomProfileType string + +const ( + CustomProfileTypeCustom CustomProfileType = "custom" +) + +func (r CustomProfileType) IsKnown() bool { + switch r { + case CustomProfileTypeCustom: + return true + } + return false +} + // A pattern that matches an entry -type DLPCustomProfileEntriesPattern struct { +type Pattern struct { // The regex pattern. Regex string `json:"regex,required"` // Validation algorithm for the pattern. This algorithm will get run on potential // matches, and if it returns false, the entry will not be matched. - Validation DLPCustomProfileEntriesPatternValidation `json:"validation"` - JSON dlpCustomProfileEntriesPatternJSON `json:"-"` + Validation PatternValidation `json:"validation"` + JSON patternJSON `json:"-"` } -// dlpCustomProfileEntriesPatternJSON contains the JSON metadata for the struct -// [DLPCustomProfileEntriesPattern] -type dlpCustomProfileEntriesPatternJSON struct { +// patternJSON contains the JSON metadata for the struct [Pattern] +type patternJSON struct { Regex apijson.Field Validation apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DLPCustomProfileEntriesPattern) UnmarshalJSON(data []byte) (err error) { +func (r *Pattern) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpCustomProfileEntriesPatternJSON) RawJSON() string { +func (r patternJSON) RawJSON() string { return r.raw } // Validation algorithm for the pattern. This algorithm will get run on potential // matches, and if it returns false, the entry will not be matched. -type DLPCustomProfileEntriesPatternValidation string +type PatternValidation string const ( - DLPCustomProfileEntriesPatternValidationLuhn DLPCustomProfileEntriesPatternValidation = "luhn" + PatternValidationLuhn PatternValidation = "luhn" ) -func (r DLPCustomProfileEntriesPatternValidation) IsKnown() bool { +func (r PatternValidation) IsKnown() bool { switch r { - case DLPCustomProfileEntriesPatternValidationLuhn: + case PatternValidationLuhn: return true } return false } -// The type of the profile. -type DLPCustomProfileType string - -const ( - DLPCustomProfileTypeCustom DLPCustomProfileType = "custom" -) +// A pattern that matches an entry +type PatternParam struct { + // The regex pattern. + Regex param.Field[string] `json:"regex,required"` + // Validation algorithm for the pattern. This algorithm will get run on potential + // matches, and if it returns false, the entry will not be matched. + Validation param.Field[PatternValidation] `json:"validation"` +} -func (r DLPCustomProfileType) IsKnown() bool { - switch r { - case DLPCustomProfileTypeCustom: - return true - } - return false +func (r PatternParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Union satisfied by [zero_trust.DLPProfileCustomDeleteResponseUnknown] or // [shared.UnionString]. -type DLPProfileCustomDeleteResponse interface { - ImplementsZeroTrustDLPProfileCustomDeleteResponse() +type DLPProfileCustomDeleteResponseUnion interface { + ImplementsZeroTrustDLPProfileCustomDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*DLPProfileCustomDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*DLPProfileCustomDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -314,7 +274,7 @@ type DLPProfileCustomNewParamsProfile struct { AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` // Scan the context of predefined entries to only return matches surrounded by // keywords. - ContextAwareness param.Field[DLPProfileCustomNewParamsProfilesContextAwareness] `json:"context_awareness"` + ContextAwareness param.Field[ContextAwarenessParam] `json:"context_awareness"` // The description of the profile. Description param.Field[string] `json:"description"` // The entries for this profile. @@ -329,30 +289,6 @@ func (r DLPProfileCustomNewParamsProfile) MarshalJSON() (data []byte, err error) return apijson.MarshalRoot(r) } -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type DLPProfileCustomNewParamsProfilesContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled param.Field[bool] `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip param.Field[DLPProfileCustomNewParamsProfilesContextAwarenessSkip] `json:"skip,required"` -} - -func (r DLPProfileCustomNewParamsProfilesContextAwareness) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Content types to exclude from context analysis and return all matches. -type DLPProfileCustomNewParamsProfilesContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files param.Field[bool] `json:"files,required"` -} - -func (r DLPProfileCustomNewParamsProfilesContextAwarenessSkip) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // A custom entry create payload type DLPProfileCustomNewParamsProfilesEntry struct { // Whether the entry is enabled or not. @@ -360,46 +296,17 @@ type DLPProfileCustomNewParamsProfilesEntry struct { // The name of the entry. Name param.Field[string] `json:"name,required"` // A pattern that matches an entry - Pattern param.Field[DLPProfileCustomNewParamsProfilesEntriesPattern] `json:"pattern,required"` + Pattern param.Field[PatternParam] `json:"pattern,required"` } func (r DLPProfileCustomNewParamsProfilesEntry) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// A pattern that matches an entry -type DLPProfileCustomNewParamsProfilesEntriesPattern struct { - // The regex pattern. - Regex param.Field[string] `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation param.Field[DLPProfileCustomNewParamsProfilesEntriesPatternValidation] `json:"validation"` -} - -func (r DLPProfileCustomNewParamsProfilesEntriesPattern) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type DLPProfileCustomNewParamsProfilesEntriesPatternValidation string - -const ( - DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn DLPProfileCustomNewParamsProfilesEntriesPatternValidation = "luhn" -) - -func (r DLPProfileCustomNewParamsProfilesEntriesPatternValidation) IsKnown() bool { - switch r { - case DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn: - return true - } - return false -} - type DLPProfileCustomNewResponseEnvelope struct { - Errors []DLPProfileCustomNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPProfileCustomNewResponseEnvelopeMessages `json:"messages,required"` - Result []DLPCustomProfile `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []CustomProfile `json:"result,required,nullable"` // Whether the API call was successful Success DLPProfileCustomNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo DLPProfileCustomNewResponseEnvelopeResultInfo `json:"result_info"` @@ -426,52 +333,6 @@ func (r dlpProfileCustomNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPProfileCustomNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileCustomNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpProfileCustomNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPProfileCustomNewResponseEnvelopeErrors] -type dlpProfileCustomNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileCustomNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileCustomNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPProfileCustomNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileCustomNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpProfileCustomNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DLPProfileCustomNewResponseEnvelopeMessages] -type dlpProfileCustomNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileCustomNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileCustomNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPProfileCustomNewResponseEnvelopeSuccess bool @@ -525,7 +386,7 @@ type DLPProfileCustomUpdateParams struct { AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` // Scan the context of predefined entries to only return matches surrounded by // keywords. - ContextAwareness param.Field[DLPProfileCustomUpdateParamsContextAwareness] `json:"context_awareness"` + ContextAwareness param.Field[ContextAwarenessParam] `json:"context_awareness"` // The description of the profile. Description param.Field[string] `json:"description"` // The custom entries for this profile. Array elements with IDs are modifying the @@ -538,37 +399,13 @@ type DLPProfileCustomUpdateParams struct { OCREnabled param.Field[bool] `json:"ocr_enabled"` // Entries from other profiles (e.g. pre-defined Cloudflare profiles, or your // Microsoft Information Protection profiles). - SharedEntries param.Field[[]DLPProfileCustomUpdateParamsSharedEntry] `json:"shared_entries"` + SharedEntries param.Field[[]DLPProfileCustomUpdateParamsSharedEntryUnion] `json:"shared_entries"` } func (r DLPProfileCustomUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type DLPProfileCustomUpdateParamsContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled param.Field[bool] `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip param.Field[DLPProfileCustomUpdateParamsContextAwarenessSkip] `json:"skip,required"` -} - -func (r DLPProfileCustomUpdateParamsContextAwareness) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Content types to exclude from context analysis and return all matches. -type DLPProfileCustomUpdateParamsContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files param.Field[bool] `json:"files,required"` -} - -func (r DLPProfileCustomUpdateParamsContextAwarenessSkip) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // A custom entry that matches a profile type DLPProfileCustomUpdateParamsEntry struct { // Whether the entry is enabled or not. @@ -576,7 +413,7 @@ type DLPProfileCustomUpdateParamsEntry struct { // The name of the entry. Name param.Field[string] `json:"name"` // A pattern that matches an entry - Pattern param.Field[DLPProfileCustomUpdateParamsEntriesPattern] `json:"pattern"` + Pattern param.Field[PatternParam] `json:"pattern"` // ID of the parent profile ProfileID param.Field[interface{}] `json:"profile_id"` } @@ -585,42 +422,27 @@ func (r DLPProfileCustomUpdateParamsEntry) MarshalJSON() (data []byte, err error return apijson.MarshalRoot(r) } -// A pattern that matches an entry -type DLPProfileCustomUpdateParamsEntriesPattern struct { - // The regex pattern. - Regex param.Field[string] `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation param.Field[DLPProfileCustomUpdateParamsEntriesPatternValidation] `json:"validation"` +// Properties of a predefined entry in a custom profile +type DLPProfileCustomUpdateParamsSharedEntry struct { + // Whether the entry is enabled or not. + Enabled param.Field[bool] `json:"enabled"` } -func (r DLPProfileCustomUpdateParamsEntriesPattern) MarshalJSON() (data []byte, err error) { +func (r DLPProfileCustomUpdateParamsSharedEntry) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type DLPProfileCustomUpdateParamsEntriesPatternValidation string - -const ( - DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn DLPProfileCustomUpdateParamsEntriesPatternValidation = "luhn" -) - -func (r DLPProfileCustomUpdateParamsEntriesPatternValidation) IsKnown() bool { - switch r { - case DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn: - return true - } - return false +func (r DLPProfileCustomUpdateParamsSharedEntry) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntryUnion() { } // Properties of a predefined entry in a custom profile // // Satisfied by // [zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined], -// [zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration]. -type DLPProfileCustomUpdateParamsSharedEntry interface { - implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() +// [zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration], +// [DLPProfileCustomUpdateParamsSharedEntry]. +type DLPProfileCustomUpdateParamsSharedEntryUnion interface { + implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntryUnion() } // Properties of a predefined entry in a custom profile @@ -633,7 +455,7 @@ func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined) return apijson.MarshalRoot(r) } -func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() { +func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntryUnion() { } // Properties of an integration entry in a custom profile @@ -646,18 +468,23 @@ func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration return apijson.MarshalRoot(r) } -func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() { +func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntryUnion() { } type DLPProfileCustomDeleteParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r DLPProfileCustomDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type DLPProfileCustomDeleteResponseEnvelope struct { - Errors []DLPProfileCustomDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPProfileCustomDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DLPProfileCustomDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result DLPProfileCustomDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success DLPProfileCustomDeleteResponseEnvelopeSuccess `json:"success,required"` JSON dlpProfileCustomDeleteResponseEnvelopeJSON `json:"-"` @@ -682,52 +509,6 @@ func (r dlpProfileCustomDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPProfileCustomDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileCustomDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpProfileCustomDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DLPProfileCustomDeleteResponseEnvelopeErrors] -type dlpProfileCustomDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileCustomDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileCustomDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPProfileCustomDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileCustomDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpProfileCustomDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DLPProfileCustomDeleteResponseEnvelopeMessages] -type dlpProfileCustomDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileCustomDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileCustomDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPProfileCustomDeleteResponseEnvelopeSuccess bool @@ -749,9 +530,9 @@ type DLPProfileCustomGetParams struct { } type DLPProfileCustomGetResponseEnvelope struct { - Errors []DLPProfileCustomGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPProfileCustomGetResponseEnvelopeMessages `json:"messages,required"` - Result DLPCustomProfile `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomProfile `json:"result,required"` // Whether the API call was successful Success DLPProfileCustomGetResponseEnvelopeSuccess `json:"success,required"` JSON dlpProfileCustomGetResponseEnvelopeJSON `json:"-"` @@ -776,52 +557,6 @@ func (r dlpProfileCustomGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPProfileCustomGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileCustomGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpProfileCustomGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DLPProfileCustomGetResponseEnvelopeErrors] -type dlpProfileCustomGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileCustomGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileCustomGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPProfileCustomGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfileCustomGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpProfileCustomGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DLPProfileCustomGetResponseEnvelopeMessages] -type dlpProfileCustomGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfileCustomGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfileCustomGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPProfileCustomGetResponseEnvelopeSuccess bool diff --git a/zero_trust/dlpprofilecustom_test.go b/zero_trust/dlpprofilecustom_test.go index 61308904952..64cea9e783f 100644 --- a/zero_trust/dlpprofilecustom_test.go +++ b/zero_trust/dlpprofilecustom_test.go @@ -32,9 +32,9 @@ func TestDLPProfileCustomNew(t *testing.T) { AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Profiles: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfile{{ AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwareness{ + ContextAwareness: cloudflare.F(zero_trust.ContextAwarenessParam{ Enabled: cloudflare.F(true), - Skip: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwarenessSkip{ + Skip: cloudflare.F(zero_trust.SkipConfigurationParam{ Files: cloudflare.F(true), }), }), @@ -42,32 +42,32 @@ func TestDLPProfileCustomNew(t *testing.T) { Entries: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfilesEntry{{ Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }}), Name: cloudflare.F("Generic CVV Card Number"), OCREnabled: cloudflare.F(true), }, { AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwareness{ + ContextAwareness: cloudflare.F(zero_trust.ContextAwarenessParam{ Enabled: cloudflare.F(true), - Skip: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwarenessSkip{ + Skip: cloudflare.F(zero_trust.SkipConfigurationParam{ Files: cloudflare.F(true), }), }), @@ -75,32 +75,32 @@ func TestDLPProfileCustomNew(t *testing.T) { Entries: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfilesEntry{{ Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }}), Name: cloudflare.F("Generic CVV Card Number"), OCREnabled: cloudflare.F(true), }, { AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwareness{ + ContextAwareness: cloudflare.F(zero_trust.ContextAwarenessParam{ Enabled: cloudflare.F(true), - Skip: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwarenessSkip{ + Skip: cloudflare.F(zero_trust.SkipConfigurationParam{ Files: cloudflare.F(true), }), }), @@ -108,23 +108,23 @@ func TestDLPProfileCustomNew(t *testing.T) { Entries: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfilesEntry{{ Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), }}), Name: cloudflare.F("Generic CVV Card Number"), @@ -160,9 +160,9 @@ func TestDLPProfileCustomUpdateWithOptionalParams(t *testing.T) { zero_trust.DLPProfileCustomUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsContextAwareness{ + ContextAwareness: cloudflare.F(zero_trust.ContextAwarenessParam{ Enabled: cloudflare.F(true), - Skip: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsContextAwarenessSkip{ + Skip: cloudflare.F(zero_trust.SkipConfigurationParam{ Files: cloudflare.F(true), }), }), @@ -170,37 +170,37 @@ func TestDLPProfileCustomUpdateWithOptionalParams(t *testing.T) { Entries: cloudflare.F([]zero_trust.DLPProfileCustomUpdateParamsEntry{{ Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), ProfileID: cloudflare.F[any](map[string]interface{}{}), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), ProfileID: cloudflare.F[any](map[string]interface{}{}), }, { Enabled: cloudflare.F(true), Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPattern{ + Pattern: cloudflare.F(zero_trust.PatternParam{ Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), + Validation: cloudflare.F(zero_trust.PatternValidationLuhn), }), ProfileID: cloudflare.F[any](map[string]interface{}{}), }}), Name: cloudflare.F("Generic CVV Card Number"), OCREnabled: cloudflare.F(true), - SharedEntries: cloudflare.F([]zero_trust.DLPProfileCustomUpdateParamsSharedEntry{zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ + SharedEntries: cloudflare.F([]zero_trust.DLPProfileCustomUpdateParamsSharedEntryUnion{zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ Enabled: cloudflare.F(true), - }), zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ + }, zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ Enabled: cloudflare.F(true), - }), zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ + }, zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ Enabled: cloudflare.F(true), - })}), + }}), }, ) if err != nil { @@ -231,6 +231,7 @@ func TestDLPProfileCustomDelete(t *testing.T) { "384e129d-25bd-403c-8019-bc19eb7a8a5f", zero_trust.DLPProfileCustomDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/dlpprofilepredefined.go b/zero_trust/dlpprofilepredefined.go index 80438e560b2..0a382f5ca9c 100644 --- a/zero_trust/dlpprofilepredefined.go +++ b/zero_trust/dlpprofilepredefined.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewDLPProfilePredefinedService(opts ...option.RequestOption) (r *DLPProfile } // Updates a DLP predefined profile. Only supports enabling/disabling entries. -func (r *DLPProfilePredefinedService) Update(ctx context.Context, profileID string, params DLPProfilePredefinedUpdateParams, opts ...option.RequestOption) (res *DLPPredefinedProfile, err error) { +func (r *DLPProfilePredefinedService) Update(ctx context.Context, profileID string, params DLPProfilePredefinedUpdateParams, opts ...option.RequestOption) (res *PredefinedProfile, err error) { opts = append(r.Options[:], opts...) path := fmt.Sprintf("accounts/%s/dlp/profiles/predefined/%s", params.AccountID, profileID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) @@ -40,7 +41,7 @@ func (r *DLPProfilePredefinedService) Update(ctx context.Context, profileID stri } // Fetches a predefined DLP profile. -func (r *DLPProfilePredefinedService) Get(ctx context.Context, profileID string, query DLPProfilePredefinedGetParams, opts ...option.RequestOption) (res *DLPPredefinedProfile, err error) { +func (r *DLPProfilePredefinedService) Get(ctx context.Context, profileID string, query DLPProfilePredefinedGetParams, opts ...option.RequestOption) (res *PredefinedProfile, err error) { opts = append(r.Options[:], opts...) var env DLPProfilePredefinedGetResponseEnvelope path := fmt.Sprintf("accounts/%s/dlp/profiles/predefined/%s", query.AccountID, profileID) @@ -52,28 +53,28 @@ func (r *DLPProfilePredefinedService) Get(ctx context.Context, profileID string, return } -type DLPPredefinedProfile struct { +type PredefinedProfile struct { // The ID for this profile ID string `json:"id"` // Related DLP policies will trigger when the match count exceeds the number set. AllowedMatchCount float64 `json:"allowed_match_count"` // Scan the context of predefined entries to only return matches surrounded by // keywords. - ContextAwareness DLPPredefinedProfileContextAwareness `json:"context_awareness"` + ContextAwareness ContextAwareness `json:"context_awareness"` // The entries for this profile. - Entries []DLPPredefinedProfileEntry `json:"entries"` + Entries []PredefinedProfileEntry `json:"entries"` // The name of the profile. Name string `json:"name"` // If true, scan images via OCR to determine if any text present matches filters. OCREnabled bool `json:"ocr_enabled"` // The type of the profile. - Type DLPPredefinedProfileType `json:"type"` - JSON dlpPredefinedProfileJSON `json:"-"` + Type PredefinedProfileType `json:"type"` + JSON predefinedProfileJSON `json:"-"` } -// dlpPredefinedProfileJSON contains the JSON metadata for the struct -// [DLPPredefinedProfile] -type dlpPredefinedProfileJSON struct { +// predefinedProfileJSON contains the JSON metadata for the struct +// [PredefinedProfile] +type predefinedProfileJSON struct { ID apijson.Field AllowedMatchCount apijson.Field ContextAwareness apijson.Field @@ -85,71 +86,20 @@ type dlpPredefinedProfileJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPPredefinedProfile) UnmarshalJSON(data []byte) (err error) { +func (r *PredefinedProfile) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpPredefinedProfileJSON) RawJSON() string { +func (r predefinedProfileJSON) RawJSON() string { return r.raw } -func (r DLPPredefinedProfile) implementsZeroTrustDLPProfiles() {} +func (r PredefinedProfile) implementsZeroTrustProfile() {} -func (r DLPPredefinedProfile) implementsZeroTrustDLPProfileGetResponse() {} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type DLPPredefinedProfileContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip DLPPredefinedProfileContextAwarenessSkip `json:"skip,required"` - JSON dlpPredefinedProfileContextAwarenessJSON `json:"-"` -} - -// dlpPredefinedProfileContextAwarenessJSON contains the JSON metadata for the -// struct [DLPPredefinedProfileContextAwareness] -type dlpPredefinedProfileContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPredefinedProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPredefinedProfileContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type DLPPredefinedProfileContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON dlpPredefinedProfileContextAwarenessSkipJSON `json:"-"` -} - -// dlpPredefinedProfileContextAwarenessSkipJSON contains the JSON metadata for the -// struct [DLPPredefinedProfileContextAwarenessSkip] -type dlpPredefinedProfileContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPPredefinedProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpPredefinedProfileContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} +func (r PredefinedProfile) implementsZeroTrustDLPProfileGetResponse() {} // A predefined entry that matches a profile -type DLPPredefinedProfileEntry struct { +type PredefinedProfileEntry struct { // The ID for this entry ID string `json:"id"` // Whether the entry is enabled or not. @@ -157,13 +107,13 @@ type DLPPredefinedProfileEntry struct { // The name of the entry. Name string `json:"name"` // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - JSON dlpPredefinedProfileEntryJSON `json:"-"` + ProfileID interface{} `json:"profile_id"` + JSON predefinedProfileEntryJSON `json:"-"` } -// dlpPredefinedProfileEntryJSON contains the JSON metadata for the struct -// [DLPPredefinedProfileEntry] -type dlpPredefinedProfileEntryJSON struct { +// predefinedProfileEntryJSON contains the JSON metadata for the struct +// [PredefinedProfileEntry] +type predefinedProfileEntryJSON struct { ID apijson.Field Enabled apijson.Field Name apijson.Field @@ -172,24 +122,24 @@ type dlpPredefinedProfileEntryJSON struct { ExtraFields map[string]apijson.Field } -func (r *DLPPredefinedProfileEntry) UnmarshalJSON(data []byte) (err error) { +func (r *PredefinedProfileEntry) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dlpPredefinedProfileEntryJSON) RawJSON() string { +func (r predefinedProfileEntryJSON) RawJSON() string { return r.raw } // The type of the profile. -type DLPPredefinedProfileType string +type PredefinedProfileType string const ( - DLPPredefinedProfileTypePredefined DLPPredefinedProfileType = "predefined" + PredefinedProfileTypePredefined PredefinedProfileType = "predefined" ) -func (r DLPPredefinedProfileType) IsKnown() bool { +func (r PredefinedProfileType) IsKnown() bool { switch r { - case DLPPredefinedProfileTypePredefined: + case PredefinedProfileTypePredefined: return true } return false @@ -202,7 +152,7 @@ type DLPProfilePredefinedUpdateParams struct { AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` // Scan the context of predefined entries to only return matches surrounded by // keywords. - ContextAwareness param.Field[DLPProfilePredefinedUpdateParamsContextAwareness] `json:"context_awareness"` + ContextAwareness param.Field[ContextAwarenessParam] `json:"context_awareness"` // The entries for this profile. Entries param.Field[[]DLPProfilePredefinedUpdateParamsEntry] `json:"entries"` // If true, scan images via OCR to determine if any text present matches filters. @@ -213,30 +163,6 @@ func (r DLPProfilePredefinedUpdateParams) MarshalJSON() (data []byte, err error) return apijson.MarshalRoot(r) } -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type DLPProfilePredefinedUpdateParamsContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled param.Field[bool] `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip param.Field[DLPProfilePredefinedUpdateParamsContextAwarenessSkip] `json:"skip,required"` -} - -func (r DLPProfilePredefinedUpdateParamsContextAwareness) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Content types to exclude from context analysis and return all matches. -type DLPProfilePredefinedUpdateParamsContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files param.Field[bool] `json:"files,required"` -} - -func (r DLPProfilePredefinedUpdateParamsContextAwarenessSkip) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type DLPProfilePredefinedUpdateParamsEntry struct { // Whether the entry is enabled or not. Enabled param.Field[bool] `json:"enabled"` @@ -252,9 +178,9 @@ type DLPProfilePredefinedGetParams struct { } type DLPProfilePredefinedGetResponseEnvelope struct { - Errors []DLPProfilePredefinedGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DLPProfilePredefinedGetResponseEnvelopeMessages `json:"messages,required"` - Result DLPPredefinedProfile `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result PredefinedProfile `json:"result,required"` // Whether the API call was successful Success DLPProfilePredefinedGetResponseEnvelopeSuccess `json:"success,required"` JSON dlpProfilePredefinedGetResponseEnvelopeJSON `json:"-"` @@ -279,52 +205,6 @@ func (r dlpProfilePredefinedGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DLPProfilePredefinedGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfilePredefinedGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dlpProfilePredefinedGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DLPProfilePredefinedGetResponseEnvelopeErrors] -type dlpProfilePredefinedGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfilePredefinedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfilePredefinedGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DLPProfilePredefinedGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dlpProfilePredefinedGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dlpProfilePredefinedGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DLPProfilePredefinedGetResponseEnvelopeMessages] -type dlpProfilePredefinedGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DLPProfilePredefinedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dlpProfilePredefinedGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DLPProfilePredefinedGetResponseEnvelopeSuccess bool diff --git a/zero_trust/dlpprofilepredefined_test.go b/zero_trust/dlpprofilepredefined_test.go index f726fec1960..e2c30a930b9 100644 --- a/zero_trust/dlpprofilepredefined_test.go +++ b/zero_trust/dlpprofilepredefined_test.go @@ -34,9 +34,9 @@ func TestDLPProfilePredefinedUpdateWithOptionalParams(t *testing.T) { zero_trust.DLPProfilePredefinedUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(zero_trust.DLPProfilePredefinedUpdateParamsContextAwareness{ + ContextAwareness: cloudflare.F(zero_trust.ContextAwarenessParam{ Enabled: cloudflare.F(true), - Skip: cloudflare.F(zero_trust.DLPProfilePredefinedUpdateParamsContextAwarenessSkip{ + Skip: cloudflare.F(zero_trust.SkipConfigurationParam{ Files: cloudflare.F(true), }), }), diff --git a/zero_trust/gateway.go b/zero_trust/gateway.go index 156c7b335ab..43f1dc6fafc 100644 --- a/zero_trust/gateway.go +++ b/zero_trust/gateway.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -135,9 +136,9 @@ type GatewayNewParams struct { } type GatewayNewResponseEnvelope struct { - Errors []GatewayNewResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayNewResponseEnvelopeMessages `json:"messages,required"` - Result GatewayNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayNewResponse `json:"result,required"` // Whether the API call was successful Success GatewayNewResponseEnvelopeSuccess `json:"success,required"` JSON gatewayNewResponseEnvelopeJSON `json:"-"` @@ -162,52 +163,6 @@ func (r gatewayNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [GatewayNewResponseEnvelopeErrors] -type gatewayNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [GatewayNewResponseEnvelopeMessages] -type gatewayNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayNewResponseEnvelopeSuccess bool @@ -228,9 +183,9 @@ type GatewayListParams struct { } type GatewayListResponseEnvelope struct { - Errors []GatewayListResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayListResponseEnvelopeMessages `json:"messages,required"` - Result GatewayListResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayListResponse `json:"result,required"` // Whether the API call was successful Success GatewayListResponseEnvelopeSuccess `json:"success,required"` JSON gatewayListResponseEnvelopeJSON `json:"-"` @@ -255,52 +210,6 @@ func (r gatewayListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [GatewayListResponseEnvelopeErrors] -type gatewayListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayListResponseEnvelopeMessages] -type gatewayListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayListResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewayapptype.go b/zero_trust/gatewayapptype.go index 8a053d74025..99ee6217241 100644 --- a/zero_trust/gatewayapptype.go +++ b/zero_trust/gatewayapptype.go @@ -36,7 +36,7 @@ func NewGatewayAppTypeService(opts ...option.RequestOption) (r *GatewayAppTypeSe } // Fetches all application and application type mappings. -func (r *GatewayAppTypeService) List(ctx context.Context, query GatewayAppTypeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGatewayAppTypes], err error) { +func (r *GatewayAppTypeService) List(ctx context.Context, query GatewayAppTypeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AppType], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -54,33 +54,74 @@ func (r *GatewayAppTypeService) List(ctx context.Context, query GatewayAppTypeLi } // Fetches all application and application type mappings. -func (r *GatewayAppTypeService) ListAutoPaging(ctx context.Context, query GatewayAppTypeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGatewayAppTypes] { +func (r *GatewayAppTypeService) ListAutoPaging(ctx context.Context, query GatewayAppTypeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AppType] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } -// Union satisfied by -// [zero_trust.ZeroTrustGatewayAppTypesZeroTrustGatewayApplication] or -// [zero_trust.ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType]. -type ZeroTrustGatewayAppTypes interface { - implementsZeroTrustZeroTrustGatewayAppTypes() +type AppType struct { + // The identifier for the type of this application. There can be many applications + // with the same type. This refers to the `id` of a returned application type. + ApplicationTypeID int64 `json:"application_type_id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The identifier for this application. There is only one application per ID. + ID int64 `json:"id"` + // The name of the application or application type. + Name string `json:"name"` + // A short summary of applications with this type. + Description string `json:"description"` + JSON appTypeJSON `json:"-"` + union AppTypeUnion +} + +// appTypeJSON contains the JSON metadata for the struct [AppType] +type appTypeJSON struct { + ApplicationTypeID apijson.Field + CreatedAt apijson.Field + ID apijson.Field + Name apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r appTypeJSON) RawJSON() string { + return r.raw +} + +func (r *AppType) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r AppType) AsUnion() AppTypeUnion { + return r.union +} + +// Union satisfied by [zero_trust.AppTypeZeroTrustGatewayApplication] or +// [zero_trust.AppTypeZeroTrustGatewayApplicationType]. +type AppTypeUnion interface { + implementsZeroTrustAppType() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGatewayAppTypes)(nil)).Elem(), + reflect.TypeOf((*AppTypeUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGatewayAppTypesZeroTrustGatewayApplication{}), + Type: reflect.TypeOf(AppTypeZeroTrustGatewayApplication{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType{}), + Type: reflect.TypeOf(AppTypeZeroTrustGatewayApplicationType{}), }, ) } -type ZeroTrustGatewayAppTypesZeroTrustGatewayApplication struct { +type AppTypeZeroTrustGatewayApplication struct { // The identifier for this application. There is only one application per ID. ID int64 `json:"id"` // The identifier for the type of this application. There can be many applications @@ -88,13 +129,13 @@ type ZeroTrustGatewayAppTypesZeroTrustGatewayApplication struct { ApplicationTypeID int64 `json:"application_type_id"` CreatedAt time.Time `json:"created_at" format:"date-time"` // The name of the application or application type. - Name string `json:"name"` - JSON zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON `json:"-"` + Name string `json:"name"` + JSON appTypeZeroTrustGatewayApplicationJSON `json:"-"` } -// zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayAppTypesZeroTrustGatewayApplication] -type zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON struct { +// appTypeZeroTrustGatewayApplicationJSON contains the JSON metadata for the struct +// [AppTypeZeroTrustGatewayApplication] +type appTypeZeroTrustGatewayApplicationJSON struct { ID apijson.Field ApplicationTypeID apijson.Field CreatedAt apijson.Field @@ -103,18 +144,17 @@ type zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayAppTypesZeroTrustGatewayApplication) UnmarshalJSON(data []byte) (err error) { +func (r *AppTypeZeroTrustGatewayApplication) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON) RawJSON() string { +func (r appTypeZeroTrustGatewayApplicationJSON) RawJSON() string { return r.raw } -func (r ZeroTrustGatewayAppTypesZeroTrustGatewayApplication) implementsZeroTrustZeroTrustGatewayAppTypes() { -} +func (r AppTypeZeroTrustGatewayApplication) implementsZeroTrustAppType() {} -type ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType struct { +type AppTypeZeroTrustGatewayApplicationType struct { // The identifier for the type of this application. There can be many applications // with the same type. This refers to the `id` of a returned application type. ID int64 `json:"id"` @@ -122,14 +162,13 @@ type ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType struct { // A short summary of applications with this type. Description string `json:"description"` // The name of the application or application type. - Name string `json:"name"` - JSON zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON `json:"-"` + Name string `json:"name"` + JSON appTypeZeroTrustGatewayApplicationTypeJSON `json:"-"` } -// zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType] -type zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON struct { +// appTypeZeroTrustGatewayApplicationTypeJSON contains the JSON metadata for the +// struct [AppTypeZeroTrustGatewayApplicationType] +type appTypeZeroTrustGatewayApplicationTypeJSON struct { ID apijson.Field CreatedAt apijson.Field Description apijson.Field @@ -138,16 +177,15 @@ type zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType) UnmarshalJSON(data []byte) (err error) { +func (r *AppTypeZeroTrustGatewayApplicationType) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON) RawJSON() string { +func (r appTypeZeroTrustGatewayApplicationTypeJSON) RawJSON() string { return r.raw } -func (r ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType) implementsZeroTrustZeroTrustGatewayAppTypes() { -} +func (r AppTypeZeroTrustGatewayApplicationType) implementsZeroTrustAppType() {} type GatewayAppTypeListParams struct { // Identifier diff --git a/zero_trust/gatewayauditsshsetting.go b/zero_trust/gatewayauditsshsetting.go index 582105ca3d8..a04803dffdc 100644 --- a/zero_trust/gatewayauditsshsetting.go +++ b/zero_trust/gatewayauditsshsetting.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewGatewayAuditSSHSettingService(opts ...option.RequestOption) (r *GatewayA } // Updates Zero Trust Audit SSH settings. -func (r *GatewayAuditSSHSettingService) Update(ctx context.Context, params GatewayAuditSSHSettingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewaySettings, err error) { +func (r *GatewayAuditSSHSettingService) Update(ctx context.Context, params GatewayAuditSSHSettingUpdateParams, opts ...option.RequestOption) (res *GatewaySettings, err error) { opts = append(r.Options[:], opts...) var env GatewayAuditSSHSettingUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/audit_ssh_settings", params.AccountID) @@ -46,7 +47,7 @@ func (r *GatewayAuditSSHSettingService) Update(ctx context.Context, params Gatew } // Get all Zero Trust Audit SSH settings for an account. -func (r *GatewayAuditSSHSettingService) Get(ctx context.Context, query GatewayAuditSSHSettingGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewaySettings, err error) { +func (r *GatewayAuditSSHSettingService) Get(ctx context.Context, query GatewayAuditSSHSettingGetParams, opts ...option.RequestOption) (res *GatewaySettings, err error) { opts = append(r.Options[:], opts...) var env GatewayAuditSSHSettingGetResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/audit_ssh_settings", query.AccountID) @@ -58,19 +59,18 @@ func (r *GatewayAuditSSHSettingService) Get(ctx context.Context, query GatewayAu return } -type ZeroTrustGatewaySettings struct { +type GatewaySettings struct { CreatedAt time.Time `json:"created_at" format:"date-time"` // SSH encryption public key PublicKey string `json:"public_key"` // Seed ID - SeedID string `json:"seed_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewaySettingsJSON `json:"-"` + SeedID string `json:"seed_id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewaySettingsJSON `json:"-"` } -// zeroTrustGatewaySettingsJSON contains the JSON metadata for the struct -// [ZeroTrustGatewaySettings] -type zeroTrustGatewaySettingsJSON struct { +// gatewaySettingsJSON contains the JSON metadata for the struct [GatewaySettings] +type gatewaySettingsJSON struct { CreatedAt apijson.Field PublicKey apijson.Field SeedID apijson.Field @@ -79,11 +79,11 @@ type zeroTrustGatewaySettingsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewaySettings) UnmarshalJSON(data []byte) (err error) { +func (r *GatewaySettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewaySettingsJSON) RawJSON() string { +func (r gatewaySettingsJSON) RawJSON() string { return r.raw } @@ -100,9 +100,9 @@ func (r GatewayAuditSSHSettingUpdateParams) MarshalJSON() (data []byte, err erro } type GatewayAuditSSHSettingUpdateResponseEnvelope struct { - Errors []GatewayAuditSSHSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayAuditSSHSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewaySettings `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewaySettings `json:"result,required"` // Whether the API call was successful Success GatewayAuditSSHSettingUpdateResponseEnvelopeSuccess `json:"success,required"` JSON gatewayAuditSSHSettingUpdateResponseEnvelopeJSON `json:"-"` @@ -127,52 +127,6 @@ func (r gatewayAuditSSHSettingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayAuditSSHSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [GatewayAuditSSHSettingUpdateResponseEnvelopeErrors] -type gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayAuditSSHSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayAuditSSHSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [GatewayAuditSSHSettingUpdateResponseEnvelopeMessages] -type gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayAuditSSHSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayAuditSSHSettingUpdateResponseEnvelopeSuccess bool @@ -193,9 +147,9 @@ type GatewayAuditSSHSettingGetParams struct { } type GatewayAuditSSHSettingGetResponseEnvelope struct { - Errors []GatewayAuditSSHSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayAuditSSHSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewaySettings `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewaySettings `json:"result,required"` // Whether the API call was successful Success GatewayAuditSSHSettingGetResponseEnvelopeSuccess `json:"success,required"` JSON gatewayAuditSSHSettingGetResponseEnvelopeJSON `json:"-"` @@ -220,52 +174,6 @@ func (r gatewayAuditSSHSettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayAuditSSHSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [GatewayAuditSSHSettingGetResponseEnvelopeErrors] -type gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayAuditSSHSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayAuditSSHSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [GatewayAuditSSHSettingGetResponseEnvelopeMessages] -type gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayAuditSSHSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayAuditSSHSettingGetResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewaycategory.go b/zero_trust/gatewaycategory.go index 33bc79c480e..66975e2256b 100644 --- a/zero_trust/gatewaycategory.go +++ b/zero_trust/gatewaycategory.go @@ -33,7 +33,7 @@ func NewGatewayCategoryService(opts ...option.RequestOption) (r *GatewayCategory } // Fetches a list of all categories. -func (r *GatewayCategoryService) List(ctx context.Context, query GatewayCategoryListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGatewayCategories], err error) { +func (r *GatewayCategoryService) List(ctx context.Context, query GatewayCategoryListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Category], 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 *GatewayCategoryService) List(ctx context.Context, query GatewayCategory } // Fetches a list of all categories. -func (r *GatewayCategoryService) ListAutoPaging(ctx context.Context, query GatewayCategoryListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGatewayCategories] { +func (r *GatewayCategoryService) ListAutoPaging(ctx context.Context, query GatewayCategoryListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Category] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } -type ZeroTrustGatewayCategories struct { +type Category struct { // The identifier for this category. There is only one category per ID. ID int64 `json:"id"` // True if the category is in beta and subject to change. @@ -64,19 +64,18 @@ type ZeroTrustGatewayCategories struct { // `blocked` categories are blocked unconditionally for all accounts. // `removalPending` categories can be removed from policies but not added. // `noBlock` categories cannot be blocked. - Class ZeroTrustGatewayCategoriesClass `json:"class"` + Class CategoryClass `json:"class"` // A short summary of domains in the category. Description string `json:"description"` // The name of the category. Name string `json:"name"` // All subcategories for this category. - Subcategories []ZeroTrustGatewayCategoriesSubcategory `json:"subcategories"` - JSON zeroTrustGatewayCategoriesJSON `json:"-"` + Subcategories []CategorySubcategory `json:"subcategories"` + JSON categoryJSON `json:"-"` } -// zeroTrustGatewayCategoriesJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayCategories] -type zeroTrustGatewayCategoriesJSON struct { +// categoryJSON contains the JSON metadata for the struct [Category] +type categoryJSON struct { ID apijson.Field Beta apijson.Field Class apijson.Field @@ -87,11 +86,11 @@ type zeroTrustGatewayCategoriesJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayCategories) UnmarshalJSON(data []byte) (err error) { +func (r *Category) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayCategoriesJSON) RawJSON() string { +func (r categoryJSON) RawJSON() string { return r.raw } @@ -99,25 +98,25 @@ func (r zeroTrustGatewayCategoriesJSON) RawJSON() string { // `blocked` categories are blocked unconditionally for all accounts. // `removalPending` categories can be removed from policies but not added. // `noBlock` categories cannot be blocked. -type ZeroTrustGatewayCategoriesClass string +type CategoryClass string const ( - ZeroTrustGatewayCategoriesClassFree ZeroTrustGatewayCategoriesClass = "free" - ZeroTrustGatewayCategoriesClassPremium ZeroTrustGatewayCategoriesClass = "premium" - ZeroTrustGatewayCategoriesClassBlocked ZeroTrustGatewayCategoriesClass = "blocked" - ZeroTrustGatewayCategoriesClassRemovalPending ZeroTrustGatewayCategoriesClass = "removalPending" - ZeroTrustGatewayCategoriesClassNoBlock ZeroTrustGatewayCategoriesClass = "noBlock" + CategoryClassFree CategoryClass = "free" + CategoryClassPremium CategoryClass = "premium" + CategoryClassBlocked CategoryClass = "blocked" + CategoryClassRemovalPending CategoryClass = "removalPending" + CategoryClassNoBlock CategoryClass = "noBlock" ) -func (r ZeroTrustGatewayCategoriesClass) IsKnown() bool { +func (r CategoryClass) IsKnown() bool { switch r { - case ZeroTrustGatewayCategoriesClassFree, ZeroTrustGatewayCategoriesClassPremium, ZeroTrustGatewayCategoriesClassBlocked, ZeroTrustGatewayCategoriesClassRemovalPending, ZeroTrustGatewayCategoriesClassNoBlock: + case CategoryClassFree, CategoryClassPremium, CategoryClassBlocked, CategoryClassRemovalPending, CategoryClassNoBlock: return true } return false } -type ZeroTrustGatewayCategoriesSubcategory struct { +type CategorySubcategory struct { // The identifier for this category. There is only one category per ID. ID int64 `json:"id"` // True if the category is in beta and subject to change. @@ -126,17 +125,17 @@ type ZeroTrustGatewayCategoriesSubcategory struct { // `blocked` categories are blocked unconditionally for all accounts. // `removalPending` categories can be removed from policies but not added. // `noBlock` categories cannot be blocked. - Class ZeroTrustGatewayCategoriesSubcategoriesClass `json:"class"` + Class CategorySubcategoriesClass `json:"class"` // A short summary of domains in the category. Description string `json:"description"` // The name of the category. - Name string `json:"name"` - JSON zeroTrustGatewayCategoriesSubcategoryJSON `json:"-"` + Name string `json:"name"` + JSON categorySubcategoryJSON `json:"-"` } -// zeroTrustGatewayCategoriesSubcategoryJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayCategoriesSubcategory] -type zeroTrustGatewayCategoriesSubcategoryJSON struct { +// categorySubcategoryJSON contains the JSON metadata for the struct +// [CategorySubcategory] +type categorySubcategoryJSON struct { ID apijson.Field Beta apijson.Field Class apijson.Field @@ -146,11 +145,11 @@ type zeroTrustGatewayCategoriesSubcategoryJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayCategoriesSubcategory) UnmarshalJSON(data []byte) (err error) { +func (r *CategorySubcategory) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayCategoriesSubcategoryJSON) RawJSON() string { +func (r categorySubcategoryJSON) RawJSON() string { return r.raw } @@ -158,19 +157,19 @@ func (r zeroTrustGatewayCategoriesSubcategoryJSON) RawJSON() string { // `blocked` categories are blocked unconditionally for all accounts. // `removalPending` categories can be removed from policies but not added. // `noBlock` categories cannot be blocked. -type ZeroTrustGatewayCategoriesSubcategoriesClass string +type CategorySubcategoriesClass string const ( - ZeroTrustGatewayCategoriesSubcategoriesClassFree ZeroTrustGatewayCategoriesSubcategoriesClass = "free" - ZeroTrustGatewayCategoriesSubcategoriesClassPremium ZeroTrustGatewayCategoriesSubcategoriesClass = "premium" - ZeroTrustGatewayCategoriesSubcategoriesClassBlocked ZeroTrustGatewayCategoriesSubcategoriesClass = "blocked" - ZeroTrustGatewayCategoriesSubcategoriesClassRemovalPending ZeroTrustGatewayCategoriesSubcategoriesClass = "removalPending" - ZeroTrustGatewayCategoriesSubcategoriesClassNoBlock ZeroTrustGatewayCategoriesSubcategoriesClass = "noBlock" + CategorySubcategoriesClassFree CategorySubcategoriesClass = "free" + CategorySubcategoriesClassPremium CategorySubcategoriesClass = "premium" + CategorySubcategoriesClassBlocked CategorySubcategoriesClass = "blocked" + CategorySubcategoriesClassRemovalPending CategorySubcategoriesClass = "removalPending" + CategorySubcategoriesClassNoBlock CategorySubcategoriesClass = "noBlock" ) -func (r ZeroTrustGatewayCategoriesSubcategoriesClass) IsKnown() bool { +func (r CategorySubcategoriesClass) IsKnown() bool { switch r { - case ZeroTrustGatewayCategoriesSubcategoriesClassFree, ZeroTrustGatewayCategoriesSubcategoriesClassPremium, ZeroTrustGatewayCategoriesSubcategoriesClassBlocked, ZeroTrustGatewayCategoriesSubcategoriesClassRemovalPending, ZeroTrustGatewayCategoriesSubcategoriesClassNoBlock: + case CategorySubcategoriesClassFree, CategorySubcategoriesClassPremium, CategorySubcategoriesClassBlocked, CategorySubcategoriesClassRemovalPending, CategorySubcategoriesClassNoBlock: return true } return false diff --git a/zero_trust/gatewayconfiguration.go b/zero_trust/gatewayconfiguration.go index 6f0cf061984..85e0f9cd131 100644 --- a/zero_trust/gatewayconfiguration.go +++ b/zero_trust/gatewayconfiguration.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -75,108 +76,41 @@ func (r *GatewayConfigurationService) Get(ctx context.Context, query GatewayConf return } -// account settings. -type GatewayConfigurationUpdateResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // account settings. - Settings GatewayConfigurationUpdateResponseSettings `json:"settings"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON gatewayConfigurationUpdateResponseJSON `json:"-"` +// Activity log settings. +type ActivityLogSettings struct { + // Enable activity logging. + Enabled bool `json:"enabled"` + JSON activityLogSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseJSON contains the JSON metadata for the struct -// [GatewayConfigurationUpdateResponse] -type gatewayConfigurationUpdateResponseJSON struct { - CreatedAt apijson.Field - Settings apijson.Field - UpdatedAt apijson.Field +// activityLogSettingsJSON contains the JSON metadata for the struct +// [ActivityLogSettings] +type activityLogSettingsJSON struct { + Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// account settings. -type GatewayConfigurationUpdateResponseSettings struct { - // Activity log settings. - ActivityLog GatewayConfigurationUpdateResponseSettingsActivityLog `json:"activity_log"` - // Anti-virus settings. - Antivirus GatewayConfigurationUpdateResponseSettingsAntivirus `json:"antivirus"` - // Block page layout settings. - BlockPage GatewayConfigurationUpdateResponseSettingsBlockPage `json:"block_page"` - // DLP body scanning settings. - BodyScanning GatewayConfigurationUpdateResponseSettingsBodyScanning `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation GatewayConfigurationUpdateResponseSettingsBrowserIsolation `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate GatewayConfigurationUpdateResponseSettingsCustomCertificate `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` - // FIPS settings. - Fips GatewayConfigurationUpdateResponseSettingsFips `json:"fips"` - // Protocol Detection settings. - ProtocolDetection GatewayConfigurationUpdateResponseSettingsProtocolDetection `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt GatewayConfigurationUpdateResponseSettingsTLSDecrypt `json:"tls_decrypt"` - JSON gatewayConfigurationUpdateResponseSettingsJSON `json:"-"` -} - -// gatewayConfigurationUpdateResponseSettingsJSON contains the JSON metadata for -// the struct [GatewayConfigurationUpdateResponseSettings] -type gatewayConfigurationUpdateResponseSettingsJSON struct { - ActivityLog apijson.Field - Antivirus apijson.Field - BlockPage apijson.Field - BodyScanning apijson.Field - BrowserIsolation apijson.Field - CustomCertificate apijson.Field - ExtendedEmailMatching apijson.Field - Fips apijson.Field - ProtocolDetection apijson.Field - TLSDecrypt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationUpdateResponseSettings) UnmarshalJSON(data []byte) (err error) { +func (r *ActivityLogSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsJSON) RawJSON() string { +func (r activityLogSettingsJSON) RawJSON() string { return r.raw } // Activity log settings. -type GatewayConfigurationUpdateResponseSettingsActivityLog struct { +type ActivityLogSettingsParam struct { // Enable activity logging. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationUpdateResponseSettingsActivityLogJSON `json:"-"` -} - -// gatewayConfigurationUpdateResponseSettingsActivityLogJSON contains the JSON -// metadata for the struct [GatewayConfigurationUpdateResponseSettingsActivityLog] -type gatewayConfigurationUpdateResponseSettingsActivityLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationUpdateResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + Enabled param.Field[bool] `json:"enabled"` } -func (r gatewayConfigurationUpdateResponseSettingsActivityLogJSON) RawJSON() string { - return r.raw +func (r ActivityLogSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Anti-virus settings. -type GatewayConfigurationUpdateResponseSettingsAntivirus struct { +type AntiVirusSettings struct { // Enable anti-virus scanning on downloads. EnabledDownloadPhase bool `json:"enabled_download_phase"` // Enable anti-virus scanning on uploads. @@ -185,13 +119,13 @@ type GatewayConfigurationUpdateResponseSettingsAntivirus struct { FailClosed bool `json:"fail_closed"` // Configure a message to display on the user's device when an antivirus search is // performed. - NotificationSettings GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` - JSON gatewayConfigurationUpdateResponseSettingsAntivirusJSON `json:"-"` + NotificationSettings NotificationSettings `json:"notification_settings"` + JSON antiVirusSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseSettingsAntivirusJSON contains the JSON -// metadata for the struct [GatewayConfigurationUpdateResponseSettingsAntivirus] -type gatewayConfigurationUpdateResponseSettingsAntivirusJSON struct { +// antiVirusSettingsJSON contains the JSON metadata for the struct +// [AntiVirusSettings] +type antiVirusSettingsJSON struct { EnabledDownloadPhase apijson.Field EnabledUploadPhase apijson.Field FailClosed apijson.Field @@ -200,48 +134,33 @@ type gatewayConfigurationUpdateResponseSettingsAntivirusJSON struct { ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { +func (r *AntiVirusSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsAntivirusJSON) RawJSON() string { +func (r antiVirusSettingsJSON) RawJSON() string { return r.raw } -// Configure a message to display on the user's device when an antivirus search is -// performed. -type GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` -} - -// gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON -// contains the JSON metadata for the struct -// [GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings] -type gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Anti-virus settings. +type AntiVirusSettingsParam struct { + // Enable anti-virus scanning on downloads. + EnabledDownloadPhase param.Field[bool] `json:"enabled_download_phase"` + // Enable anti-virus scanning on uploads. + EnabledUploadPhase param.Field[bool] `json:"enabled_upload_phase"` + // Block requests for files that cannot be scanned. + FailClosed param.Field[bool] `json:"fail_closed"` + // Configure a message to display on the user's device when an antivirus search is + // performed. + NotificationSettings param.Field[NotificationSettingsParam] `json:"notification_settings"` } -func (r gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { - return r.raw +func (r AntiVirusSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Block page layout settings. -type GatewayConfigurationUpdateResponseSettingsBlockPage struct { +type BlockPageSettings struct { // Block page background color in #rrggbb format. BackgroundColor string `json:"background_color"` // Enable only cipher suites and TLS versions compliant with FIPS 140-2. @@ -259,13 +178,13 @@ type GatewayConfigurationUpdateResponseSettingsBlockPage struct { // Block page title. Name string `json:"name"` // Suppress detailed info at the bottom of the block page. - SuppressFooter bool `json:"suppress_footer"` - JSON gatewayConfigurationUpdateResponseSettingsBlockPageJSON `json:"-"` + SuppressFooter bool `json:"suppress_footer"` + JSON blockPageSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseSettingsBlockPageJSON contains the JSON -// metadata for the struct [GatewayConfigurationUpdateResponseSettingsBlockPage] -type gatewayConfigurationUpdateResponseSettingsBlockPageJSON struct { +// blockPageSettingsJSON contains the JSON metadata for the struct +// [BlockPageSettings] +type blockPageSettingsJSON struct { BackgroundColor apijson.Field Enabled apijson.Field FooterText apijson.Field @@ -279,80 +198,126 @@ type gatewayConfigurationUpdateResponseSettingsBlockPageJSON struct { ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { +func (r *BlockPageSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsBlockPageJSON) RawJSON() string { +func (r blockPageSettingsJSON) RawJSON() string { return r.raw } +// Block page layout settings. +type BlockPageSettingsParam struct { + // Block page background color in #rrggbb format. + BackgroundColor param.Field[string] `json:"background_color"` + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + Enabled param.Field[bool] `json:"enabled"` + // Block page footer text. + FooterText param.Field[string] `json:"footer_text"` + // Block page header text. + HeaderText param.Field[string] `json:"header_text"` + // Full URL to the logo file. + LogoPath param.Field[string] `json:"logo_path"` + // Admin email for users to contact. + MailtoAddress param.Field[string] `json:"mailto_address"` + // Subject line for emails created from block page. + MailtoSubject param.Field[string] `json:"mailto_subject"` + // Block page title. + Name param.Field[string] `json:"name"` + // Suppress detailed info at the bottom of the block page. + SuppressFooter param.Field[bool] `json:"suppress_footer"` +} + +func (r BlockPageSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // DLP body scanning settings. -type GatewayConfigurationUpdateResponseSettingsBodyScanning struct { +type BodyScanningSettings struct { // Set the inspection mode to either `deep` or `shallow`. - InspectionMode string `json:"inspection_mode"` - JSON gatewayConfigurationUpdateResponseSettingsBodyScanningJSON `json:"-"` + InspectionMode string `json:"inspection_mode"` + JSON bodyScanningSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseSettingsBodyScanningJSON contains the JSON -// metadata for the struct [GatewayConfigurationUpdateResponseSettingsBodyScanning] -type gatewayConfigurationUpdateResponseSettingsBodyScanningJSON struct { +// bodyScanningSettingsJSON contains the JSON metadata for the struct +// [BodyScanningSettings] +type bodyScanningSettingsJSON struct { InspectionMode apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { +func (r *BodyScanningSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsBodyScanningJSON) RawJSON() string { +func (r bodyScanningSettingsJSON) RawJSON() string { return r.raw } +// DLP body scanning settings. +type BodyScanningSettingsParam struct { + // Set the inspection mode to either `deep` or `shallow`. + InspectionMode param.Field[string] `json:"inspection_mode"` +} + +func (r BodyScanningSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Browser isolation settings. -type GatewayConfigurationUpdateResponseSettingsBrowserIsolation struct { +type BrowserIsolationSettings struct { // Enable non-identity onramp support for Browser Isolation. NonIdentityEnabled bool `json:"non_identity_enabled"` // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` - JSON gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON `json:"-"` + URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` + JSON browserIsolationSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON contains the JSON -// metadata for the struct -// [GatewayConfigurationUpdateResponseSettingsBrowserIsolation] -type gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON struct { +// browserIsolationSettingsJSON contains the JSON metadata for the struct +// [BrowserIsolationSettings] +type browserIsolationSettingsJSON struct { NonIdentityEnabled apijson.Field URLBrowserIsolationEnabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { +func (r *BrowserIsolationSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON) RawJSON() string { +func (r browserIsolationSettingsJSON) RawJSON() string { return r.raw } +// Browser isolation settings. +type BrowserIsolationSettingsParam struct { + // Enable non-identity onramp support for Browser Isolation. + NonIdentityEnabled param.Field[bool] `json:"non_identity_enabled"` + // Enable Clientless Browser Isolation. + URLBrowserIsolationEnabled param.Field[bool] `json:"url_browser_isolation_enabled"` +} + +func (r BrowserIsolationSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Custom certificate settings for BYO-PKI. -type GatewayConfigurationUpdateResponseSettingsCustomCertificate struct { +type CustomCertificateSettings struct { // Enable use of custom certificate authority for signing Gateway traffic. Enabled bool `json:"enabled,required"` // UUID of certificate (ID from MTLS certificate store). ID string `json:"id"` // Certificate status (internal). - BindingStatus string `json:"binding_status"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON `json:"-"` + BindingStatus string `json:"binding_status"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON customCertificateSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON contains the -// JSON metadata for the struct -// [GatewayConfigurationUpdateResponseSettingsCustomCertificate] -type gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON struct { +// customCertificateSettingsJSON contains the JSON metadata for the struct +// [CustomCertificateSettings] +type customCertificateSettingsJSON struct { Enabled apijson.Field ID apijson.Field BindingStatus apijson.Field @@ -361,164 +326,121 @@ type gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON struct { ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { +func (r *CustomCertificateSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON) RawJSON() string { +func (r customCertificateSettingsJSON) RawJSON() string { return r.raw } -// Extended e-mail matching settings. -type GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON `json:"-"` -} - -// gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON contains the -// JSON metadata for the struct -// [GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching] -type gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Custom certificate settings for BYO-PKI. +type CustomCertificateSettingsParam struct { + // Enable use of custom certificate authority for signing Gateway traffic. + Enabled param.Field[bool] `json:"enabled,required"` + // UUID of certificate (ID from MTLS certificate store). + ID param.Field[string] `json:"id"` } -func (r gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { - return r.raw +func (r CustomCertificateSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// FIPS settings. -type GatewayConfigurationUpdateResponseSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS bool `json:"tls"` - JSON gatewayConfigurationUpdateResponseSettingsFipsJSON `json:"-"` +// Extended e-mail matching settings. +type ExtendedEmailMatching struct { + // Enable matching all variants of user emails (with + or . modifiers) used as + // criteria in Firewall policies. + Enabled bool `json:"enabled"` + JSON extendedEmailMatchingJSON `json:"-"` } -// gatewayConfigurationUpdateResponseSettingsFipsJSON contains the JSON metadata -// for the struct [GatewayConfigurationUpdateResponseSettingsFips] -type gatewayConfigurationUpdateResponseSettingsFipsJSON struct { - TLS apijson.Field +// extendedEmailMatchingJSON contains the JSON metadata for the struct +// [ExtendedEmailMatching] +type extendedEmailMatchingJSON struct { + Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { +func (r *ExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsFipsJSON) RawJSON() string { +func (r extendedEmailMatchingJSON) RawJSON() string { return r.raw } -// Protocol Detection settings. -type GatewayConfigurationUpdateResponseSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON `json:"-"` -} - -// gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON contains the -// JSON metadata for the struct -// [GatewayConfigurationUpdateResponseSettingsProtocolDetection] -type gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationUpdateResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Extended e-mail matching settings. +type ExtendedEmailMatchingParam struct { + // Enable matching all variants of user emails (with + or . modifiers) used as + // criteria in Firewall policies. + Enabled param.Field[bool] `json:"enabled"` } -func (r gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON) RawJSON() string { - return r.raw +func (r ExtendedEmailMatchingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// TLS interception settings. -type GatewayConfigurationUpdateResponseSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON `json:"-"` +// FIPS settings. +type FipsSettings struct { + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + TLS bool `json:"tls"` + JSON fipsSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON contains the JSON -// metadata for the struct [GatewayConfigurationUpdateResponseSettingsTLSDecrypt] -type gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON struct { - Enabled apijson.Field +// fipsSettingsJSON contains the JSON metadata for the struct [FipsSettings] +type fipsSettingsJSON struct { + TLS apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { +func (r *FipsSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON) RawJSON() string { +func (r fipsSettingsJSON) RawJSON() string { return r.raw } -// account settings. -type GatewayConfigurationEditResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // account settings. - Settings GatewayConfigurationEditResponseSettings `json:"settings"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON gatewayConfigurationEditResponseJSON `json:"-"` -} - -// gatewayConfigurationEditResponseJSON contains the JSON metadata for the struct -// [GatewayConfigurationEditResponse] -type gatewayConfigurationEditResponseJSON struct { - CreatedAt apijson.Field - Settings apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// FIPS settings. +type FipsSettingsParam struct { + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + TLS param.Field[bool] `json:"tls"` } -func (r gatewayConfigurationEditResponseJSON) RawJSON() string { - return r.raw +func (r FipsSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // account settings. -type GatewayConfigurationEditResponseSettings struct { +type GatewayConfigurationSettings struct { // Activity log settings. - ActivityLog GatewayConfigurationEditResponseSettingsActivityLog `json:"activity_log"` + ActivityLog ActivityLogSettings `json:"activity_log"` // Anti-virus settings. - Antivirus GatewayConfigurationEditResponseSettingsAntivirus `json:"antivirus"` + Antivirus AntiVirusSettings `json:"antivirus"` // Block page layout settings. - BlockPage GatewayConfigurationEditResponseSettingsBlockPage `json:"block_page"` + BlockPage BlockPageSettings `json:"block_page"` // DLP body scanning settings. - BodyScanning GatewayConfigurationEditResponseSettingsBodyScanning `json:"body_scanning"` + BodyScanning BodyScanningSettings `json:"body_scanning"` // Browser isolation settings. - BrowserIsolation GatewayConfigurationEditResponseSettingsBrowserIsolation `json:"browser_isolation"` + BrowserIsolation BrowserIsolationSettings `json:"browser_isolation"` // Custom certificate settings for BYO-PKI. - CustomCertificate GatewayConfigurationEditResponseSettingsCustomCertificate `json:"custom_certificate"` + CustomCertificate CustomCertificateSettings `json:"custom_certificate"` // Extended e-mail matching settings. - ExtendedEmailMatching GatewayConfigurationEditResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` + ExtendedEmailMatching ExtendedEmailMatching `json:"extended_email_matching"` // FIPS settings. - Fips GatewayConfigurationEditResponseSettingsFips `json:"fips"` + Fips FipsSettings `json:"fips"` // Protocol Detection settings. - ProtocolDetection GatewayConfigurationEditResponseSettingsProtocolDetection `json:"protocol_detection"` + ProtocolDetection ProtocolDetection `json:"protocol_detection"` // TLS interception settings. - TLSDecrypt GatewayConfigurationEditResponseSettingsTLSDecrypt `json:"tls_decrypt"` - JSON gatewayConfigurationEditResponseSettingsJSON `json:"-"` + TLSDecrypt TLSSettings `json:"tls_decrypt"` + JSON gatewayConfigurationSettingsJSON `json:"-"` } -// gatewayConfigurationEditResponseSettingsJSON contains the JSON metadata for the -// struct [GatewayConfigurationEditResponseSettings] -type gatewayConfigurationEditResponseSettingsJSON struct { +// gatewayConfigurationSettingsJSON contains the JSON metadata for the struct +// [GatewayConfigurationSettings] +type gatewayConfigurationSettingsJSON struct { ActivityLog apijson.Field Antivirus apijson.Field BlockPage apijson.Field @@ -533,87 +455,58 @@ type gatewayConfigurationEditResponseSettingsJSON struct { ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationEditResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsJSON) RawJSON() string { - return r.raw -} - -// Activity log settings. -type GatewayConfigurationEditResponseSettingsActivityLog struct { - // Enable activity logging. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationEditResponseSettingsActivityLogJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsActivityLogJSON contains the JSON -// metadata for the struct [GatewayConfigurationEditResponseSettingsActivityLog] -type gatewayConfigurationEditResponseSettingsActivityLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { +func (r *GatewayConfigurationSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationEditResponseSettingsActivityLogJSON) RawJSON() string { +func (r gatewayConfigurationSettingsJSON) RawJSON() string { return r.raw } -// Anti-virus settings. -type GatewayConfigurationEditResponseSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase bool `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase bool `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed bool `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` - JSON gatewayConfigurationEditResponseSettingsAntivirusJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsAntivirusJSON contains the JSON metadata -// for the struct [GatewayConfigurationEditResponseSettingsAntivirus] -type gatewayConfigurationEditResponseSettingsAntivirusJSON struct { - EnabledDownloadPhase apijson.Field - EnabledUploadPhase apijson.Field - FailClosed apijson.Field - NotificationSettings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// account settings. +type GatewayConfigurationSettingsParam struct { + // Activity log settings. + ActivityLog param.Field[ActivityLogSettingsParam] `json:"activity_log"` + // Anti-virus settings. + Antivirus param.Field[AntiVirusSettingsParam] `json:"antivirus"` + // Block page layout settings. + BlockPage param.Field[BlockPageSettingsParam] `json:"block_page"` + // DLP body scanning settings. + BodyScanning param.Field[BodyScanningSettingsParam] `json:"body_scanning"` + // Browser isolation settings. + BrowserIsolation param.Field[BrowserIsolationSettingsParam] `json:"browser_isolation"` + // Custom certificate settings for BYO-PKI. + CustomCertificate param.Field[CustomCertificateSettingsParam] `json:"custom_certificate"` + // Extended e-mail matching settings. + ExtendedEmailMatching param.Field[ExtendedEmailMatchingParam] `json:"extended_email_matching"` + // FIPS settings. + Fips param.Field[FipsSettingsParam] `json:"fips"` + // Protocol Detection settings. + ProtocolDetection param.Field[ProtocolDetectionParam] `json:"protocol_detection"` + // TLS interception settings. + TLSDecrypt param.Field[TLSSettingsParam] `json:"tls_decrypt"` } -func (r gatewayConfigurationEditResponseSettingsAntivirusJSON) RawJSON() string { - return r.raw +func (r GatewayConfigurationSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Configure a message to display on the user's device when an antivirus search is // performed. -type GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings struct { +type NotificationSettings struct { // Set notification on Enabled bool `json:"enabled"` // Customize the message shown in the notification. Msg string `json:"msg"` // Optional URL to direct users to additional information. If not set, the // notification will open a block page. - SupportURL string `json:"support_url"` - JSON gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` + SupportURL string `json:"support_url"` + JSON notificationSettingsJSON `json:"-"` } -// gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON -// contains the JSON metadata for the struct -// [GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings] -type gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON struct { +// notificationSettingsJSON contains the JSON metadata for the struct +// [NotificationSettings] +type notificationSettingsJSON struct { Enabled apijson.Field Msg apijson.Field SupportURL apijson.Field @@ -621,695 +514,17 @@ type gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON s ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { +func (r *NotificationSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { +func (r notificationSettingsJSON) RawJSON() string { return r.raw } -// Block page layout settings. -type GatewayConfigurationEditResponseSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor string `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled bool `json:"enabled"` - // Block page footer text. - FooterText string `json:"footer_text"` - // Block page header text. - HeaderText string `json:"header_text"` - // Full URL to the logo file. - LogoPath string `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress string `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject string `json:"mailto_subject"` - // Block page title. - Name string `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter bool `json:"suppress_footer"` - JSON gatewayConfigurationEditResponseSettingsBlockPageJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsBlockPageJSON contains the JSON metadata -// for the struct [GatewayConfigurationEditResponseSettingsBlockPage] -type gatewayConfigurationEditResponseSettingsBlockPageJSON struct { - BackgroundColor apijson.Field - Enabled apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - MailtoAddress apijson.Field - MailtoSubject apijson.Field - Name apijson.Field - SuppressFooter apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsBlockPageJSON) RawJSON() string { - return r.raw -} - -// DLP body scanning settings. -type GatewayConfigurationEditResponseSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode string `json:"inspection_mode"` - JSON gatewayConfigurationEditResponseSettingsBodyScanningJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsBodyScanningJSON contains the JSON -// metadata for the struct [GatewayConfigurationEditResponseSettingsBodyScanning] -type gatewayConfigurationEditResponseSettingsBodyScanningJSON struct { - InspectionMode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsBodyScanningJSON) RawJSON() string { - return r.raw -} - -// Browser isolation settings. -type GatewayConfigurationEditResponseSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled bool `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` - JSON gatewayConfigurationEditResponseSettingsBrowserIsolationJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsBrowserIsolationJSON contains the JSON -// metadata for the struct -// [GatewayConfigurationEditResponseSettingsBrowserIsolation] -type gatewayConfigurationEditResponseSettingsBrowserIsolationJSON struct { - NonIdentityEnabled apijson.Field - URLBrowserIsolationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsBrowserIsolationJSON) RawJSON() string { - return r.raw -} - -// Custom certificate settings for BYO-PKI. -type GatewayConfigurationEditResponseSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled bool `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID string `json:"id"` - // Certificate status (internal). - BindingStatus string `json:"binding_status"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON gatewayConfigurationEditResponseSettingsCustomCertificateJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsCustomCertificateJSON contains the JSON -// metadata for the struct -// [GatewayConfigurationEditResponseSettingsCustomCertificate] -type gatewayConfigurationEditResponseSettingsCustomCertificateJSON struct { - Enabled apijson.Field - ID apijson.Field - BindingStatus apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsCustomCertificateJSON) RawJSON() string { - return r.raw -} - -// Extended e-mail matching settings. -type GatewayConfigurationEditResponseSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON contains the -// JSON metadata for the struct -// [GatewayConfigurationEditResponseSettingsExtendedEmailMatching] -type gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { - return r.raw -} - -// FIPS settings. -type GatewayConfigurationEditResponseSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS bool `json:"tls"` - JSON gatewayConfigurationEditResponseSettingsFipsJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsFipsJSON contains the JSON metadata for -// the struct [GatewayConfigurationEditResponseSettingsFips] -type gatewayConfigurationEditResponseSettingsFipsJSON struct { - TLS apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsFipsJSON) RawJSON() string { - return r.raw -} - -// Protocol Detection settings. -type GatewayConfigurationEditResponseSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationEditResponseSettingsProtocolDetectionJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsProtocolDetectionJSON contains the JSON -// metadata for the struct -// [GatewayConfigurationEditResponseSettingsProtocolDetection] -type gatewayConfigurationEditResponseSettingsProtocolDetectionJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsProtocolDetectionJSON) RawJSON() string { - return r.raw -} - -// TLS interception settings. -type GatewayConfigurationEditResponseSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationEditResponseSettingsTLSDecryptJSON `json:"-"` -} - -// gatewayConfigurationEditResponseSettingsTLSDecryptJSON contains the JSON -// metadata for the struct [GatewayConfigurationEditResponseSettingsTLSDecrypt] -type gatewayConfigurationEditResponseSettingsTLSDecryptJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseSettingsTLSDecryptJSON) RawJSON() string { - return r.raw -} - -// account settings. -type GatewayConfigurationGetResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // account settings. - Settings GatewayConfigurationGetResponseSettings `json:"settings"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON gatewayConfigurationGetResponseJSON `json:"-"` -} - -// gatewayConfigurationGetResponseJSON contains the JSON metadata for the struct -// [GatewayConfigurationGetResponse] -type gatewayConfigurationGetResponseJSON struct { - CreatedAt apijson.Field - Settings apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseJSON) RawJSON() string { - return r.raw -} - -// account settings. -type GatewayConfigurationGetResponseSettings struct { - // Activity log settings. - ActivityLog GatewayConfigurationGetResponseSettingsActivityLog `json:"activity_log"` - // Anti-virus settings. - Antivirus GatewayConfigurationGetResponseSettingsAntivirus `json:"antivirus"` - // Block page layout settings. - BlockPage GatewayConfigurationGetResponseSettingsBlockPage `json:"block_page"` - // DLP body scanning settings. - BodyScanning GatewayConfigurationGetResponseSettingsBodyScanning `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation GatewayConfigurationGetResponseSettingsBrowserIsolation `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate GatewayConfigurationGetResponseSettingsCustomCertificate `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching GatewayConfigurationGetResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` - // FIPS settings. - Fips GatewayConfigurationGetResponseSettingsFips `json:"fips"` - // Protocol Detection settings. - ProtocolDetection GatewayConfigurationGetResponseSettingsProtocolDetection `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt GatewayConfigurationGetResponseSettingsTLSDecrypt `json:"tls_decrypt"` - JSON gatewayConfigurationGetResponseSettingsJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsJSON contains the JSON metadata for the -// struct [GatewayConfigurationGetResponseSettings] -type gatewayConfigurationGetResponseSettingsJSON struct { - ActivityLog apijson.Field - Antivirus apijson.Field - BlockPage apijson.Field - BodyScanning apijson.Field - BrowserIsolation apijson.Field - CustomCertificate apijson.Field - ExtendedEmailMatching apijson.Field - Fips apijson.Field - ProtocolDetection apijson.Field - TLSDecrypt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsJSON) RawJSON() string { - return r.raw -} - -// Activity log settings. -type GatewayConfigurationGetResponseSettingsActivityLog struct { - // Enable activity logging. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationGetResponseSettingsActivityLogJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsActivityLogJSON contains the JSON -// metadata for the struct [GatewayConfigurationGetResponseSettingsActivityLog] -type gatewayConfigurationGetResponseSettingsActivityLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsActivityLogJSON) RawJSON() string { - return r.raw -} - -// Anti-virus settings. -type GatewayConfigurationGetResponseSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase bool `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase bool `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed bool `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` - JSON gatewayConfigurationGetResponseSettingsAntivirusJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsAntivirusJSON contains the JSON metadata -// for the struct [GatewayConfigurationGetResponseSettingsAntivirus] -type gatewayConfigurationGetResponseSettingsAntivirusJSON struct { - EnabledDownloadPhase apijson.Field - EnabledUploadPhase apijson.Field - FailClosed apijson.Field - NotificationSettings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsAntivirusJSON) RawJSON() string { - return r.raw -} - -// Configure a message to display on the user's device when an antivirus search is -// performed. -type GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON -// contains the JSON metadata for the struct -// [GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings] -type gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Block page layout settings. -type GatewayConfigurationGetResponseSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor string `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled bool `json:"enabled"` - // Block page footer text. - FooterText string `json:"footer_text"` - // Block page header text. - HeaderText string `json:"header_text"` - // Full URL to the logo file. - LogoPath string `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress string `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject string `json:"mailto_subject"` - // Block page title. - Name string `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter bool `json:"suppress_footer"` - JSON gatewayConfigurationGetResponseSettingsBlockPageJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsBlockPageJSON contains the JSON metadata -// for the struct [GatewayConfigurationGetResponseSettingsBlockPage] -type gatewayConfigurationGetResponseSettingsBlockPageJSON struct { - BackgroundColor apijson.Field - Enabled apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - MailtoAddress apijson.Field - MailtoSubject apijson.Field - Name apijson.Field - SuppressFooter apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsBlockPageJSON) RawJSON() string { - return r.raw -} - -// DLP body scanning settings. -type GatewayConfigurationGetResponseSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode string `json:"inspection_mode"` - JSON gatewayConfigurationGetResponseSettingsBodyScanningJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsBodyScanningJSON contains the JSON -// metadata for the struct [GatewayConfigurationGetResponseSettingsBodyScanning] -type gatewayConfigurationGetResponseSettingsBodyScanningJSON struct { - InspectionMode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsBodyScanningJSON) RawJSON() string { - return r.raw -} - -// Browser isolation settings. -type GatewayConfigurationGetResponseSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled bool `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` - JSON gatewayConfigurationGetResponseSettingsBrowserIsolationJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsBrowserIsolationJSON contains the JSON -// metadata for the struct -// [GatewayConfigurationGetResponseSettingsBrowserIsolation] -type gatewayConfigurationGetResponseSettingsBrowserIsolationJSON struct { - NonIdentityEnabled apijson.Field - URLBrowserIsolationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsBrowserIsolationJSON) RawJSON() string { - return r.raw -} - -// Custom certificate settings for BYO-PKI. -type GatewayConfigurationGetResponseSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled bool `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID string `json:"id"` - // Certificate status (internal). - BindingStatus string `json:"binding_status"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON gatewayConfigurationGetResponseSettingsCustomCertificateJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsCustomCertificateJSON contains the JSON -// metadata for the struct -// [GatewayConfigurationGetResponseSettingsCustomCertificate] -type gatewayConfigurationGetResponseSettingsCustomCertificateJSON struct { - Enabled apijson.Field - ID apijson.Field - BindingStatus apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsCustomCertificateJSON) RawJSON() string { - return r.raw -} - -// Extended e-mail matching settings. -type GatewayConfigurationGetResponseSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON contains the -// JSON metadata for the struct -// [GatewayConfigurationGetResponseSettingsExtendedEmailMatching] -type gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { - return r.raw -} - -// FIPS settings. -type GatewayConfigurationGetResponseSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS bool `json:"tls"` - JSON gatewayConfigurationGetResponseSettingsFipsJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsFipsJSON contains the JSON metadata for -// the struct [GatewayConfigurationGetResponseSettingsFips] -type gatewayConfigurationGetResponseSettingsFipsJSON struct { - TLS apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsFipsJSON) RawJSON() string { - return r.raw -} - -// Protocol Detection settings. -type GatewayConfigurationGetResponseSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationGetResponseSettingsProtocolDetectionJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsProtocolDetectionJSON contains the JSON -// metadata for the struct -// [GatewayConfigurationGetResponseSettingsProtocolDetection] -type gatewayConfigurationGetResponseSettingsProtocolDetectionJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsProtocolDetectionJSON) RawJSON() string { - return r.raw -} - -// TLS interception settings. -type GatewayConfigurationGetResponseSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled bool `json:"enabled"` - JSON gatewayConfigurationGetResponseSettingsTLSDecryptJSON `json:"-"` -} - -// gatewayConfigurationGetResponseSettingsTLSDecryptJSON contains the JSON metadata -// for the struct [GatewayConfigurationGetResponseSettingsTLSDecrypt] -type gatewayConfigurationGetResponseSettingsTLSDecryptJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseSettingsTLSDecryptJSON) RawJSON() string { - return r.raw -} - -type GatewayConfigurationUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // account settings. - Settings param.Field[GatewayConfigurationUpdateParamsSettings] `json:"settings"` -} - -func (r GatewayConfigurationUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// account settings. -type GatewayConfigurationUpdateParamsSettings struct { - // Activity log settings. - ActivityLog param.Field[GatewayConfigurationUpdateParamsSettingsActivityLog] `json:"activity_log"` - // Anti-virus settings. - Antivirus param.Field[GatewayConfigurationUpdateParamsSettingsAntivirus] `json:"antivirus"` - // Block page layout settings. - BlockPage param.Field[GatewayConfigurationUpdateParamsSettingsBlockPage] `json:"block_page"` - // DLP body scanning settings. - BodyScanning param.Field[GatewayConfigurationUpdateParamsSettingsBodyScanning] `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation param.Field[GatewayConfigurationUpdateParamsSettingsBrowserIsolation] `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate param.Field[GatewayConfigurationUpdateParamsSettingsCustomCertificate] `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching param.Field[GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching] `json:"extended_email_matching"` - // FIPS settings. - Fips param.Field[GatewayConfigurationUpdateParamsSettingsFips] `json:"fips"` - // Protocol Detection settings. - ProtocolDetection param.Field[GatewayConfigurationUpdateParamsSettingsProtocolDetection] `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt param.Field[GatewayConfigurationUpdateParamsSettingsTLSDecrypt] `json:"tls_decrypt"` -} - -func (r GatewayConfigurationUpdateParamsSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Activity log settings. -type GatewayConfigurationUpdateParamsSettingsActivityLog struct { - // Enable activity logging. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r GatewayConfigurationUpdateParamsSettingsActivityLog) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Anti-virus settings. -type GatewayConfigurationUpdateParamsSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase param.Field[bool] `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase param.Field[bool] `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed param.Field[bool] `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings param.Field[GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings] `json:"notification_settings"` -} - -func (r GatewayConfigurationUpdateParamsSettingsAntivirus) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // Configure a message to display on the user's device when an antivirus search is // performed. -type GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings struct { +type NotificationSettingsParam struct { // Set notification on Enabled param.Field[bool] `json:"enabled"` // Customize the message shown in the notification. @@ -1319,386 +534,223 @@ type GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings struc SupportURL param.Field[string] `json:"support_url"` } -func (r GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Block page layout settings. -type GatewayConfigurationUpdateParamsSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor param.Field[string] `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled param.Field[bool] `json:"enabled"` - // Block page footer text. - FooterText param.Field[string] `json:"footer_text"` - // Block page header text. - HeaderText param.Field[string] `json:"header_text"` - // Full URL to the logo file. - LogoPath param.Field[string] `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress param.Field[string] `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject param.Field[string] `json:"mailto_subject"` - // Block page title. - Name param.Field[string] `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter param.Field[bool] `json:"suppress_footer"` -} - -func (r GatewayConfigurationUpdateParamsSettingsBlockPage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// DLP body scanning settings. -type GatewayConfigurationUpdateParamsSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode param.Field[string] `json:"inspection_mode"` -} - -func (r GatewayConfigurationUpdateParamsSettingsBodyScanning) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Browser isolation settings. -type GatewayConfigurationUpdateParamsSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled param.Field[bool] `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled param.Field[bool] `json:"url_browser_isolation_enabled"` -} - -func (r GatewayConfigurationUpdateParamsSettingsBrowserIsolation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Custom certificate settings for BYO-PKI. -type GatewayConfigurationUpdateParamsSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled param.Field[bool] `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID param.Field[string] `json:"id"` -} - -func (r GatewayConfigurationUpdateParamsSettingsCustomCertificate) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Extended e-mail matching settings. -type GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// FIPS settings. -type GatewayConfigurationUpdateParamsSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS param.Field[bool] `json:"tls"` -} - -func (r GatewayConfigurationUpdateParamsSettingsFips) MarshalJSON() (data []byte, err error) { +func (r NotificationSettingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Protocol Detection settings. -type GatewayConfigurationUpdateParamsSettingsProtocolDetection struct { +type ProtocolDetection struct { // Enable detecting protocol on initial bytes of client traffic. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r GatewayConfigurationUpdateParamsSettingsProtocolDetection) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// TLS interception settings. -type GatewayConfigurationUpdateParamsSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r GatewayConfigurationUpdateParamsSettingsTLSDecrypt) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type GatewayConfigurationUpdateResponseEnvelope struct { - Errors []GatewayConfigurationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayConfigurationUpdateResponseEnvelopeMessages `json:"messages,required"` - // account settings. - Result GatewayConfigurationUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success GatewayConfigurationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON gatewayConfigurationUpdateResponseEnvelopeJSON `json:"-"` -} - -// gatewayConfigurationUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [GatewayConfigurationUpdateResponseEnvelope] -type gatewayConfigurationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type GatewayConfigurationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayConfigurationUpdateResponseEnvelopeErrorsJSON `json:"-"` + Enabled bool `json:"enabled"` + JSON protocolDetectionJSON `json:"-"` } -// gatewayConfigurationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [GatewayConfigurationUpdateResponseEnvelopeErrors] -type gatewayConfigurationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field +// protocolDetectionJSON contains the JSON metadata for the struct +// [ProtocolDetection] +type protocolDetectionJSON struct { + Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { +func (r *ProtocolDetection) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { +func (r protocolDetectionJSON) RawJSON() string { return r.raw } -type GatewayConfigurationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayConfigurationUpdateResponseEnvelopeMessagesJSON `json:"-"` +// Protocol Detection settings. +type ProtocolDetectionParam struct { + // Enable detecting protocol on initial bytes of client traffic. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r ProtocolDetectionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// TLS interception settings. +type TLSSettings struct { + // Enable inspecting encrypted HTTP traffic. + Enabled bool `json:"enabled"` + JSON tlsSettingsJSON `json:"-"` } -// gatewayConfigurationUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [GatewayConfigurationUpdateResponseEnvelopeMessages] -type gatewayConfigurationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field +// tlsSettingsJSON contains the JSON metadata for the struct [TLSSettings] +type tlsSettingsJSON struct { + Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayConfigurationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *TLSSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayConfigurationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { +func (r tlsSettingsJSON) RawJSON() string { return r.raw } -// Whether the API call was successful -type GatewayConfigurationUpdateResponseEnvelopeSuccess bool - -const ( - GatewayConfigurationUpdateResponseEnvelopeSuccessTrue GatewayConfigurationUpdateResponseEnvelopeSuccess = true -) - -func (r GatewayConfigurationUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case GatewayConfigurationUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type GatewayConfigurationEditParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // account settings. - Settings param.Field[GatewayConfigurationEditParamsSettings] `json:"settings"` +// TLS interception settings. +type TLSSettingsParam struct { + // Enable inspecting encrypted HTTP traffic. + Enabled param.Field[bool] `json:"enabled"` } -func (r GatewayConfigurationEditParams) MarshalJSON() (data []byte, err error) { +func (r TLSSettingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // account settings. -type GatewayConfigurationEditParamsSettings struct { - // Activity log settings. - ActivityLog param.Field[GatewayConfigurationEditParamsSettingsActivityLog] `json:"activity_log"` - // Anti-virus settings. - Antivirus param.Field[GatewayConfigurationEditParamsSettingsAntivirus] `json:"antivirus"` - // Block page layout settings. - BlockPage param.Field[GatewayConfigurationEditParamsSettingsBlockPage] `json:"block_page"` - // DLP body scanning settings. - BodyScanning param.Field[GatewayConfigurationEditParamsSettingsBodyScanning] `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation param.Field[GatewayConfigurationEditParamsSettingsBrowserIsolation] `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate param.Field[GatewayConfigurationEditParamsSettingsCustomCertificate] `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching param.Field[GatewayConfigurationEditParamsSettingsExtendedEmailMatching] `json:"extended_email_matching"` - // FIPS settings. - Fips param.Field[GatewayConfigurationEditParamsSettingsFips] `json:"fips"` - // Protocol Detection settings. - ProtocolDetection param.Field[GatewayConfigurationEditParamsSettingsProtocolDetection] `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt param.Field[GatewayConfigurationEditParamsSettingsTLSDecrypt] `json:"tls_decrypt"` +type GatewayConfigurationUpdateResponse struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // account settings. + Settings GatewayConfigurationSettings `json:"settings"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationUpdateResponseJSON `json:"-"` } -func (r GatewayConfigurationEditParamsSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// gatewayConfigurationUpdateResponseJSON contains the JSON metadata for the struct +// [GatewayConfigurationUpdateResponse] +type gatewayConfigurationUpdateResponseJSON struct { + CreatedAt apijson.Field + Settings apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Activity log settings. -type GatewayConfigurationEditParamsSettingsActivityLog struct { - // Enable activity logging. - Enabled param.Field[bool] `json:"enabled"` +func (r *GatewayConfigurationUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r GatewayConfigurationEditParamsSettingsActivityLog) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r gatewayConfigurationUpdateResponseJSON) RawJSON() string { + return r.raw } -// Anti-virus settings. -type GatewayConfigurationEditParamsSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase param.Field[bool] `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase param.Field[bool] `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed param.Field[bool] `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings param.Field[GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings] `json:"notification_settings"` +// account settings. +type GatewayConfigurationEditResponse struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // account settings. + Settings GatewayConfigurationSettings `json:"settings"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationEditResponseJSON `json:"-"` } -func (r GatewayConfigurationEditParamsSettingsAntivirus) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// gatewayConfigurationEditResponseJSON contains the JSON metadata for the struct +// [GatewayConfigurationEditResponse] +type gatewayConfigurationEditResponseJSON struct { + CreatedAt apijson.Field + Settings apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// Configure a message to display on the user's device when an antivirus search is -// performed. -type GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled param.Field[bool] `json:"enabled"` - // Customize the message shown in the notification. - Msg param.Field[string] `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL param.Field[string] `json:"support_url"` +func (r *GatewayConfigurationEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r gatewayConfigurationEditResponseJSON) RawJSON() string { + return r.raw } -// Block page layout settings. -type GatewayConfigurationEditParamsSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor param.Field[string] `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled param.Field[bool] `json:"enabled"` - // Block page footer text. - FooterText param.Field[string] `json:"footer_text"` - // Block page header text. - HeaderText param.Field[string] `json:"header_text"` - // Full URL to the logo file. - LogoPath param.Field[string] `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress param.Field[string] `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject param.Field[string] `json:"mailto_subject"` - // Block page title. - Name param.Field[string] `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter param.Field[bool] `json:"suppress_footer"` +// account settings. +type GatewayConfigurationGetResponse struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // account settings. + Settings GatewayConfigurationSettings `json:"settings"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationGetResponseJSON `json:"-"` } -func (r GatewayConfigurationEditParamsSettingsBlockPage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// gatewayConfigurationGetResponseJSON contains the JSON metadata for the struct +// [GatewayConfigurationGetResponse] +type gatewayConfigurationGetResponseJSON struct { + CreatedAt apijson.Field + Settings apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// DLP body scanning settings. -type GatewayConfigurationEditParamsSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode param.Field[string] `json:"inspection_mode"` +func (r *GatewayConfigurationGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r GatewayConfigurationEditParamsSettingsBodyScanning) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r gatewayConfigurationGetResponseJSON) RawJSON() string { + return r.raw } -// Browser isolation settings. -type GatewayConfigurationEditParamsSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled param.Field[bool] `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled param.Field[bool] `json:"url_browser_isolation_enabled"` +type GatewayConfigurationUpdateParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // account settings. + Settings param.Field[GatewayConfigurationSettingsParam] `json:"settings"` } -func (r GatewayConfigurationEditParamsSettingsBrowserIsolation) MarshalJSON() (data []byte, err error) { +func (r GatewayConfigurationUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Custom certificate settings for BYO-PKI. -type GatewayConfigurationEditParamsSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled param.Field[bool] `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID param.Field[string] `json:"id"` -} - -func (r GatewayConfigurationEditParamsSettingsCustomCertificate) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type GatewayConfigurationUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + // account settings. + Result GatewayConfigurationUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayConfigurationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayConfigurationUpdateResponseEnvelopeJSON `json:"-"` } -// Extended e-mail matching settings. -type GatewayConfigurationEditParamsSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled param.Field[bool] `json:"enabled"` +// gatewayConfigurationUpdateResponseEnvelopeJSON contains the JSON metadata for +// the struct [GatewayConfigurationUpdateResponseEnvelope] +type gatewayConfigurationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r GatewayConfigurationEditParamsSettingsExtendedEmailMatching) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *GatewayConfigurationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// FIPS settings. -type GatewayConfigurationEditParamsSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS param.Field[bool] `json:"tls"` +func (r gatewayConfigurationUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw } -func (r GatewayConfigurationEditParamsSettingsFips) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} +// Whether the API call was successful +type GatewayConfigurationUpdateResponseEnvelopeSuccess bool -// Protocol Detection settings. -type GatewayConfigurationEditParamsSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled param.Field[bool] `json:"enabled"` -} +const ( + GatewayConfigurationUpdateResponseEnvelopeSuccessTrue GatewayConfigurationUpdateResponseEnvelopeSuccess = true +) -func (r GatewayConfigurationEditParamsSettingsProtocolDetection) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r GatewayConfigurationUpdateResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case GatewayConfigurationUpdateResponseEnvelopeSuccessTrue: + return true + } + return false } -// TLS interception settings. -type GatewayConfigurationEditParamsSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled param.Field[bool] `json:"enabled"` +type GatewayConfigurationEditParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // account settings. + Settings param.Field[GatewayConfigurationSettingsParam] `json:"settings"` } -func (r GatewayConfigurationEditParamsSettingsTLSDecrypt) MarshalJSON() (data []byte, err error) { +func (r GatewayConfigurationEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type GatewayConfigurationEditResponseEnvelope struct { - Errors []GatewayConfigurationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayConfigurationEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // account settings. Result GatewayConfigurationEditResponse `json:"result,required"` // Whether the API call was successful @@ -1725,52 +777,6 @@ func (r gatewayConfigurationEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayConfigurationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayConfigurationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayConfigurationEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [GatewayConfigurationEditResponseEnvelopeErrors] -type gatewayConfigurationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayConfigurationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayConfigurationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayConfigurationEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [GatewayConfigurationEditResponseEnvelopeMessages] -type gatewayConfigurationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayConfigurationEditResponseEnvelopeSuccess bool @@ -1791,8 +797,8 @@ type GatewayConfigurationGetParams struct { } type GatewayConfigurationGetResponseEnvelope struct { - Errors []GatewayConfigurationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayConfigurationGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // account settings. Result GatewayConfigurationGetResponse `json:"result,required"` // Whether the API call was successful @@ -1819,52 +825,6 @@ func (r gatewayConfigurationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayConfigurationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayConfigurationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayConfigurationGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [GatewayConfigurationGetResponseEnvelopeErrors] -type gatewayConfigurationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayConfigurationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayConfigurationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayConfigurationGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [GatewayConfigurationGetResponseEnvelopeMessages] -type gatewayConfigurationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayConfigurationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayConfigurationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayConfigurationGetResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewayconfiguration_test.go b/zero_trust/gatewayconfiguration_test.go index 6e39d2fab6d..0d4e17341fc 100644 --- a/zero_trust/gatewayconfiguration_test.go +++ b/zero_trust/gatewayconfiguration_test.go @@ -30,21 +30,21 @@ func TestGatewayConfigurationUpdateWithOptionalParams(t *testing.T) { ) _, err := client.ZeroTrust.Gateway.Configurations.Update(context.TODO(), zero_trust.GatewayConfigurationUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Settings: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettings{ - ActivityLog: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsActivityLog{ + Settings: cloudflare.F(zero_trust.GatewayConfigurationSettingsParam{ + ActivityLog: cloudflare.F(zero_trust.ActivityLogSettingsParam{ Enabled: cloudflare.F(true), }), - Antivirus: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsAntivirus{ + Antivirus: cloudflare.F(zero_trust.AntiVirusSettingsParam{ EnabledDownloadPhase: cloudflare.F(false), EnabledUploadPhase: cloudflare.F(false), FailClosed: cloudflare.F(false), - NotificationSettings: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings{ + NotificationSettings: cloudflare.F(zero_trust.NotificationSettingsParam{ Enabled: cloudflare.F(true), Msg: cloudflare.F("string"), SupportURL: cloudflare.F("string"), }), }), - BlockPage: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsBlockPage{ + BlockPage: cloudflare.F(zero_trust.BlockPageSettingsParam{ BackgroundColor: cloudflare.F("string"), Enabled: cloudflare.F(true), FooterText: cloudflare.F("--footer--"), @@ -55,27 +55,27 @@ func TestGatewayConfigurationUpdateWithOptionalParams(t *testing.T) { Name: cloudflare.F("Cloudflare"), SuppressFooter: cloudflare.F(false), }), - BodyScanning: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsBodyScanning{ + BodyScanning: cloudflare.F(zero_trust.BodyScanningSettingsParam{ InspectionMode: cloudflare.F("deep"), }), - BrowserIsolation: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsBrowserIsolation{ + BrowserIsolation: cloudflare.F(zero_trust.BrowserIsolationSettingsParam{ NonIdentityEnabled: cloudflare.F(true), URLBrowserIsolationEnabled: cloudflare.F(true), }), - CustomCertificate: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsCustomCertificate{ + CustomCertificate: cloudflare.F(zero_trust.CustomCertificateSettingsParam{ Enabled: cloudflare.F(true), ID: cloudflare.F("d1b364c5-1311-466e-a194-f0e943e0799f"), }), - ExtendedEmailMatching: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching{ + ExtendedEmailMatching: cloudflare.F(zero_trust.ExtendedEmailMatchingParam{ Enabled: cloudflare.F(true), }), - Fips: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsFips{ + Fips: cloudflare.F(zero_trust.FipsSettingsParam{ TLS: cloudflare.F(true), }), - ProtocolDetection: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsProtocolDetection{ + ProtocolDetection: cloudflare.F(zero_trust.ProtocolDetectionParam{ Enabled: cloudflare.F(true), }), - TLSDecrypt: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsTLSDecrypt{ + TLSDecrypt: cloudflare.F(zero_trust.TLSSettingsParam{ Enabled: cloudflare.F(true), }), }), @@ -105,21 +105,21 @@ func TestGatewayConfigurationEditWithOptionalParams(t *testing.T) { ) _, err := client.ZeroTrust.Gateway.Configurations.Edit(context.TODO(), zero_trust.GatewayConfigurationEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Settings: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettings{ - ActivityLog: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsActivityLog{ + Settings: cloudflare.F(zero_trust.GatewayConfigurationSettingsParam{ + ActivityLog: cloudflare.F(zero_trust.ActivityLogSettingsParam{ Enabled: cloudflare.F(true), }), - Antivirus: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsAntivirus{ + Antivirus: cloudflare.F(zero_trust.AntiVirusSettingsParam{ EnabledDownloadPhase: cloudflare.F(false), EnabledUploadPhase: cloudflare.F(false), FailClosed: cloudflare.F(false), - NotificationSettings: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings{ + NotificationSettings: cloudflare.F(zero_trust.NotificationSettingsParam{ Enabled: cloudflare.F(true), Msg: cloudflare.F("string"), SupportURL: cloudflare.F("string"), }), }), - BlockPage: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsBlockPage{ + BlockPage: cloudflare.F(zero_trust.BlockPageSettingsParam{ BackgroundColor: cloudflare.F("string"), Enabled: cloudflare.F(true), FooterText: cloudflare.F("--footer--"), @@ -130,27 +130,27 @@ func TestGatewayConfigurationEditWithOptionalParams(t *testing.T) { Name: cloudflare.F("Cloudflare"), SuppressFooter: cloudflare.F(false), }), - BodyScanning: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsBodyScanning{ + BodyScanning: cloudflare.F(zero_trust.BodyScanningSettingsParam{ InspectionMode: cloudflare.F("deep"), }), - BrowserIsolation: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsBrowserIsolation{ + BrowserIsolation: cloudflare.F(zero_trust.BrowserIsolationSettingsParam{ NonIdentityEnabled: cloudflare.F(true), URLBrowserIsolationEnabled: cloudflare.F(true), }), - CustomCertificate: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsCustomCertificate{ + CustomCertificate: cloudflare.F(zero_trust.CustomCertificateSettingsParam{ Enabled: cloudflare.F(true), ID: cloudflare.F("d1b364c5-1311-466e-a194-f0e943e0799f"), }), - ExtendedEmailMatching: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsExtendedEmailMatching{ + ExtendedEmailMatching: cloudflare.F(zero_trust.ExtendedEmailMatchingParam{ Enabled: cloudflare.F(true), }), - Fips: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsFips{ + Fips: cloudflare.F(zero_trust.FipsSettingsParam{ TLS: cloudflare.F(true), }), - ProtocolDetection: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsProtocolDetection{ + ProtocolDetection: cloudflare.F(zero_trust.ProtocolDetectionParam{ Enabled: cloudflare.F(true), }), - TLSDecrypt: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsTLSDecrypt{ + TLSDecrypt: cloudflare.F(zero_trust.TLSSettingsParam{ Enabled: cloudflare.F(true), }), }), diff --git a/zero_trust/gatewaylist.go b/zero_trust/gatewaylist.go index 01cb0ba28d6..fa1205d955e 100644 --- a/zero_trust/gatewaylist.go +++ b/zero_trust/gatewaylist.go @@ -52,7 +52,7 @@ func (r *GatewayListService) New(ctx context.Context, params GatewayListNewParam } // Updates a configured Zero Trust list. -func (r *GatewayListService) Update(ctx context.Context, listID string, params GatewayListUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLists, err error) { +func (r *GatewayListService) Update(ctx context.Context, listID string, params GatewayListUpdateParams, opts ...option.RequestOption) (res *GatewayList, err error) { opts = append(r.Options[:], opts...) var env GatewayListUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/lists/%s", params.AccountID, listID) @@ -65,7 +65,7 @@ func (r *GatewayListService) Update(ctx context.Context, listID string, params G } // Fetches all Zero Trust lists for an account. -func (r *GatewayListService) List(ctx context.Context, query GatewayListListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGatewayLists], err error) { +func (r *GatewayListService) List(ctx context.Context, query GatewayListListParams, opts ...option.RequestOption) (res *pagination.SinglePage[GatewayList], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -83,15 +83,15 @@ func (r *GatewayListService) List(ctx context.Context, query GatewayListListPara } // Fetches all Zero Trust lists for an account. -func (r *GatewayListService) ListAutoPaging(ctx context.Context, query GatewayListListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGatewayLists] { +func (r *GatewayListService) ListAutoPaging(ctx context.Context, query GatewayListListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[GatewayList] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a Zero Trust list. -func (r *GatewayListService) Delete(ctx context.Context, listID string, body GatewayListDeleteParams, opts ...option.RequestOption) (res *GatewayListDeleteResponse, err error) { +func (r *GatewayListService) Delete(ctx context.Context, listID string, params GatewayListDeleteParams, opts ...option.RequestOption) (res *GatewayListDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env GatewayListDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/gateway/lists/%s", body.AccountID, listID) + path := fmt.Sprintf("accounts/%s/gateway/lists/%s", params.AccountID, listID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -101,7 +101,7 @@ func (r *GatewayListService) Delete(ctx context.Context, listID string, body Gat } // Appends or removes an item from a configured Zero Trust list. -func (r *GatewayListService) Edit(ctx context.Context, listID string, params GatewayListEditParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLists, err error) { +func (r *GatewayListService) Edit(ctx context.Context, listID string, params GatewayListEditParams, opts ...option.RequestOption) (res *GatewayList, err error) { opts = append(r.Options[:], opts...) var env GatewayListEditResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/lists/%s", params.AccountID, listID) @@ -114,7 +114,7 @@ func (r *GatewayListService) Edit(ctx context.Context, listID string, params Gat } // Fetches a single Zero Trust list. -func (r *GatewayListService) Get(ctx context.Context, listID string, query GatewayListGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLists, err error) { +func (r *GatewayListService) Get(ctx context.Context, listID string, query GatewayListGetParams, opts ...option.RequestOption) (res *GatewayList, err error) { opts = append(r.Options[:], opts...) var env GatewayListGetResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/lists/%s", query.AccountID, listID) @@ -126,7 +126,39 @@ func (r *GatewayListService) Get(ctx context.Context, listID string, query Gatew return } -type ZeroTrustGatewayLists struct { +type GatewayItem struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The value of the item in a list. + Value string `json:"value"` + JSON gatewayItemJSON `json:"-"` +} + +// gatewayItemJSON contains the JSON metadata for the struct [GatewayItem] +type gatewayItemJSON struct { + CreatedAt apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayItemJSON) RawJSON() string { + return r.raw +} + +type GatewayItemParam struct { + // The value of the item in a list. + Value param.Field[string] `json:"value"` +} + +func (r GatewayItemParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayList struct { // API Resource UUID tag. ID string `json:"id"` // The number of items in the list. @@ -137,14 +169,13 @@ type ZeroTrustGatewayLists struct { // The name of the list. Name string `json:"name"` // The type of list. - Type ZeroTrustGatewayListsType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayListsJSON `json:"-"` + Type GatewayListType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayListJSON `json:"-"` } -// zeroTrustGatewayListsJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayLists] -type zeroTrustGatewayListsJSON struct { +// gatewayListJSON contains the JSON metadata for the struct [GatewayList] +type gatewayListJSON struct { ID apijson.Field Count apijson.Field CreatedAt apijson.Field @@ -156,28 +187,28 @@ type zeroTrustGatewayListsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayLists) UnmarshalJSON(data []byte) (err error) { +func (r *GatewayList) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayListsJSON) RawJSON() string { +func (r gatewayListJSON) RawJSON() string { return r.raw } // The type of list. -type ZeroTrustGatewayListsType string +type GatewayListType string const ( - ZeroTrustGatewayListsTypeSerial ZeroTrustGatewayListsType = "SERIAL" - ZeroTrustGatewayListsTypeURL ZeroTrustGatewayListsType = "URL" - ZeroTrustGatewayListsTypeDomain ZeroTrustGatewayListsType = "DOMAIN" - ZeroTrustGatewayListsTypeEmail ZeroTrustGatewayListsType = "EMAIL" - ZeroTrustGatewayListsTypeIP ZeroTrustGatewayListsType = "IP" + GatewayListTypeSerial GatewayListType = "SERIAL" + GatewayListTypeURL GatewayListType = "URL" + GatewayListTypeDomain GatewayListType = "DOMAIN" + GatewayListTypeEmail GatewayListType = "EMAIL" + GatewayListTypeIP GatewayListType = "IP" ) -func (r ZeroTrustGatewayListsType) IsKnown() bool { +func (r GatewayListType) IsKnown() bool { switch r { - case ZeroTrustGatewayListsTypeSerial, ZeroTrustGatewayListsTypeURL, ZeroTrustGatewayListsTypeDomain, ZeroTrustGatewayListsTypeEmail, ZeroTrustGatewayListsTypeIP: + case GatewayListTypeSerial, GatewayListTypeURL, GatewayListTypeDomain, GatewayListTypeEmail, GatewayListTypeIP: return true } return false @@ -190,7 +221,7 @@ type GatewayListNewResponse struct { // The description of the list. Description string `json:"description"` // The items in the list. - Items []GatewayListNewResponseItem `json:"items"` + Items []GatewayItem `json:"items"` // The name of the list. Name string `json:"name"` // The type of list. @@ -221,30 +252,6 @@ func (r gatewayListNewResponseJSON) RawJSON() string { return r.raw } -type GatewayListNewResponseItem struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The value of the item in a list. - Value string `json:"value"` - JSON gatewayListNewResponseItemJSON `json:"-"` -} - -// gatewayListNewResponseItemJSON contains the JSON metadata for the struct -// [GatewayListNewResponseItem] -type gatewayListNewResponseItemJSON struct { - CreatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListNewResponseItem) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListNewResponseItemJSON) RawJSON() string { - return r.raw -} - // The type of list. type GatewayListNewResponseType string @@ -266,13 +273,13 @@ func (r GatewayListNewResponseType) IsKnown() bool { // Union satisfied by [zero_trust.GatewayListDeleteResponseUnknown] or // [shared.UnionString]. -type GatewayListDeleteResponse interface { - ImplementsZeroTrustGatewayListDeleteResponse() +type GatewayListDeleteResponseUnion interface { + ImplementsZeroTrustGatewayListDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*GatewayListDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*GatewayListDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -290,7 +297,7 @@ type GatewayListNewParams struct { // The description of the list. Description param.Field[string] `json:"description"` // The items in the list. - Items param.Field[[]GatewayListNewParamsItem] `json:"items"` + Items param.Field[[]GatewayItemParam] `json:"items"` } func (r GatewayListNewParams) MarshalJSON() (data []byte, err error) { @@ -316,19 +323,10 @@ func (r GatewayListNewParamsType) IsKnown() bool { return false } -type GatewayListNewParamsItem struct { - // The value of the item in a list. - Value param.Field[string] `json:"value"` -} - -func (r GatewayListNewParamsItem) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type GatewayListNewResponseEnvelope struct { - Errors []GatewayListNewResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayListNewResponseEnvelopeMessages `json:"messages,required"` - Result GatewayListNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayListNewResponse `json:"result,required"` // Whether the API call was successful Success GatewayListNewResponseEnvelopeSuccess `json:"success,required"` JSON gatewayListNewResponseEnvelopeJSON `json:"-"` @@ -353,52 +351,6 @@ func (r gatewayListNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayListNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayListNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayListNewResponseEnvelopeErrors] -type gatewayListNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayListNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayListNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayListNewResponseEnvelopeMessages] -type gatewayListNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayListNewResponseEnvelopeSuccess bool @@ -427,9 +379,9 @@ func (r GatewayListUpdateParams) MarshalJSON() (data []byte, err error) { } type GatewayListUpdateResponseEnvelope struct { - Errors []GatewayListUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayListUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLists `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayList `json:"result,required"` // Whether the API call was successful Success GatewayListUpdateResponseEnvelopeSuccess `json:"success,required"` JSON gatewayListUpdateResponseEnvelopeJSON `json:"-"` @@ -454,52 +406,6 @@ func (r gatewayListUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayListUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayListUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayListUpdateResponseEnvelopeErrors] -type gatewayListUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayListUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayListUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayListUpdateResponseEnvelopeMessages] -type gatewayListUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayListUpdateResponseEnvelopeSuccess bool @@ -521,12 +427,17 @@ type GatewayListListParams struct { type GatewayListDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r GatewayListDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type GatewayListDeleteResponseEnvelope struct { - Errors []GatewayListDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayListDeleteResponseEnvelopeMessages `json:"messages,required"` - Result GatewayListDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayListDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success GatewayListDeleteResponseEnvelopeSuccess `json:"success,required"` JSON gatewayListDeleteResponseEnvelopeJSON `json:"-"` @@ -551,52 +462,6 @@ func (r gatewayListDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayListDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayListDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayListDeleteResponseEnvelopeErrors] -type gatewayListDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayListDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayListDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayListDeleteResponseEnvelopeMessages] -type gatewayListDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayListDeleteResponseEnvelopeSuccess bool @@ -615,7 +480,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[[]GatewayListEditParamsAppend] `json:"append"` + Append param.Field[[]GatewayItemParam] `json:"append"` // A list of the item values you want to remove. Remove param.Field[[]string] `json:"remove"` } @@ -624,19 +489,10 @@ func (r GatewayListEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type GatewayListEditParamsAppend struct { - // The value of the item in a list. - Value param.Field[string] `json:"value"` -} - -func (r GatewayListEditParamsAppend) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type GatewayListEditResponseEnvelope struct { - Errors []GatewayListEditResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayListEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLists `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayList `json:"result,required"` // Whether the API call was successful Success GatewayListEditResponseEnvelopeSuccess `json:"success,required"` JSON gatewayListEditResponseEnvelopeJSON `json:"-"` @@ -661,52 +517,6 @@ func (r gatewayListEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayListEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayListEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayListEditResponseEnvelopeErrors] -type gatewayListEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayListEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayListEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayListEditResponseEnvelopeMessages] -type gatewayListEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayListEditResponseEnvelopeSuccess bool @@ -727,9 +537,9 @@ type GatewayListGetParams struct { } type GatewayListGetResponseEnvelope struct { - Errors []GatewayListGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayListGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLists `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayList `json:"result,required"` // Whether the API call was successful Success GatewayListGetResponseEnvelopeSuccess `json:"success,required"` JSON gatewayListGetResponseEnvelopeJSON `json:"-"` @@ -754,52 +564,6 @@ func (r gatewayListGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayListGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayListGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayListGetResponseEnvelopeErrors] -type gatewayListGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayListGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayListGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayListGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayListGetResponseEnvelopeMessages] -type gatewayListGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayListGetResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewaylist_test.go b/zero_trust/gatewaylist_test.go index d8f07064e6b..3dc8766ef9d 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.GatewayListNewParamsItem{{ + Items: cloudflare.F([]zero_trust.GatewayItemParam{{ Value: cloudflare.F("8GE8721REF"), }, { Value: cloudflare.F("8GE8721REF"), @@ -127,6 +127,7 @@ func TestGatewayListDelete(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.GatewayListDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -157,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.GatewayListEditParamsAppend{{ + Append: cloudflare.F([]zero_trust.GatewayItemParam{{ Value: cloudflare.F("8GE8721REF"), }, { Value: cloudflare.F("8GE8721REF"), diff --git a/zero_trust/gatewaylistitem.go b/zero_trust/gatewaylistitem.go index 29afb44940e..93aa8795e6e 100644 --- a/zero_trust/gatewaylistitem.go +++ b/zero_trust/gatewaylistitem.go @@ -6,9 +6,7 @@ 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" @@ -34,7 +32,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[[]GatewayListItemListResponse], err error) { +func (r *GatewayListItemService) List(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) (res *pagination.SinglePage[[]GatewayItem], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -52,34 +50,10 @@ 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[[]GatewayListItemListResponse] { +func (r *GatewayListItemService) ListAutoPaging(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[[]GatewayItem] { return pagination.NewSinglePageAutoPager(r.List(ctx, listID, query, opts...)) } -type GatewayListItemListResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The value of the item in a list. - Value string `json:"value"` - JSON gatewayListItemListResponseJSON `json:"-"` -} - -// gatewayListItemListResponseJSON contains the JSON metadata for the struct -// [GatewayListItemListResponse] -type gatewayListItemListResponseJSON struct { - CreatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayListItemListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayListItemListResponseJSON) RawJSON() string { - return r.raw -} - type GatewayListItemListParams struct { AccountID param.Field[string] `path:"account_id,required"` } diff --git a/zero_trust/gatewaylocation.go b/zero_trust/gatewaylocation.go index 5784d000d12..19a458cb651 100644 --- a/zero_trust/gatewaylocation.go +++ b/zero_trust/gatewaylocation.go @@ -37,7 +37,7 @@ func NewGatewayLocationService(opts ...option.RequestOption) (r *GatewayLocation } // Creates a new Zero Trust Gateway location. -func (r *GatewayLocationService) New(ctx context.Context, params GatewayLocationNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocations, err error) { +func (r *GatewayLocationService) New(ctx context.Context, params GatewayLocationNewParams, opts ...option.RequestOption) (res *Location, err error) { opts = append(r.Options[:], opts...) var env GatewayLocationNewResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/locations", params.AccountID) @@ -50,7 +50,7 @@ func (r *GatewayLocationService) New(ctx context.Context, params GatewayLocation } // Updates a configured Zero Trust Gateway location. -func (r *GatewayLocationService) Update(ctx context.Context, locationID string, params GatewayLocationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocations, err error) { +func (r *GatewayLocationService) Update(ctx context.Context, locationID string, params GatewayLocationUpdateParams, opts ...option.RequestOption) (res *Location, err error) { opts = append(r.Options[:], opts...) var env GatewayLocationUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/locations/%s", params.AccountID, locationID) @@ -63,7 +63,7 @@ func (r *GatewayLocationService) Update(ctx context.Context, locationID string, } // Fetches Zero Trust Gateway locations for an account. -func (r *GatewayLocationService) List(ctx context.Context, query GatewayLocationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGatewayLocations], err error) { +func (r *GatewayLocationService) List(ctx context.Context, query GatewayLocationListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Location], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -81,15 +81,15 @@ func (r *GatewayLocationService) List(ctx context.Context, query GatewayLocation } // Fetches Zero Trust Gateway locations for an account. -func (r *GatewayLocationService) ListAutoPaging(ctx context.Context, query GatewayLocationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGatewayLocations] { +func (r *GatewayLocationService) ListAutoPaging(ctx context.Context, query GatewayLocationListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Location] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a configured Zero Trust Gateway location. -func (r *GatewayLocationService) Delete(ctx context.Context, locationID string, body GatewayLocationDeleteParams, opts ...option.RequestOption) (res *GatewayLocationDeleteResponse, err error) { +func (r *GatewayLocationService) Delete(ctx context.Context, locationID string, params GatewayLocationDeleteParams, opts ...option.RequestOption) (res *GatewayLocationDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env GatewayLocationDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/gateway/locations/%s", body.AccountID, locationID) + path := fmt.Sprintf("accounts/%s/gateway/locations/%s", params.AccountID, locationID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -99,7 +99,7 @@ func (r *GatewayLocationService) Delete(ctx context.Context, locationID string, } // Fetches a single Zero Trust Gateway location. -func (r *GatewayLocationService) Get(ctx context.Context, locationID string, query GatewayLocationGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocations, err error) { +func (r *GatewayLocationService) Get(ctx context.Context, locationID string, query GatewayLocationGetParams, opts ...option.RequestOption) (res *Location, err error) { opts = append(r.Options[:], opts...) var env GatewayLocationGetResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/locations/%s", query.AccountID, locationID) @@ -111,7 +111,7 @@ func (r *GatewayLocationService) Get(ctx context.Context, locationID string, que return } -type ZeroTrustGatewayLocations struct { +type Location struct { ID string `json:"id"` // True if the location is the default location. ClientDefault bool `json:"client_default"` @@ -128,14 +128,13 @@ type ZeroTrustGatewayLocations struct { // The name of the location. Name string `json:"name"` // A list of network ranges that requests from this location would originate from. - Networks []ZeroTrustGatewayLocationsNetwork `json:"networks"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayLocationsJSON `json:"-"` + Networks []LocationNetwork `json:"networks"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON locationJSON `json:"-"` } -// zeroTrustGatewayLocationsJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayLocations] -type zeroTrustGatewayLocationsJSON struct { +// locationJSON contains the JSON metadata for the struct [Location] +type locationJSON struct { ID apijson.Field ClientDefault apijson.Field CreatedAt apijson.Field @@ -149,45 +148,53 @@ type zeroTrustGatewayLocationsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayLocations) UnmarshalJSON(data []byte) (err error) { +func (r *Location) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayLocationsJSON) RawJSON() string { +func (r locationJSON) RawJSON() string { return r.raw } -type ZeroTrustGatewayLocationsNetwork struct { +type LocationNetwork struct { // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network string `json:"network,required"` - JSON zeroTrustGatewayLocationsNetworkJSON `json:"-"` + Network string `json:"network,required"` + JSON locationNetworkJSON `json:"-"` } -// zeroTrustGatewayLocationsNetworkJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayLocationsNetwork] -type zeroTrustGatewayLocationsNetworkJSON struct { +// locationNetworkJSON contains the JSON metadata for the struct [LocationNetwork] +type locationNetworkJSON struct { Network apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayLocationsNetwork) UnmarshalJSON(data []byte) (err error) { +func (r *LocationNetwork) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayLocationsNetworkJSON) RawJSON() string { +func (r locationNetworkJSON) RawJSON() string { return r.raw } +type LocationNetworkParam struct { + // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. + Network param.Field[string] `json:"network,required"` +} + +func (r LocationNetworkParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + // Union satisfied by [zero_trust.GatewayLocationDeleteResponseUnknown] or // [shared.UnionString]. -type GatewayLocationDeleteResponse interface { - ImplementsZeroTrustGatewayLocationDeleteResponse() +type GatewayLocationDeleteResponseUnion interface { + ImplementsZeroTrustGatewayLocationDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*GatewayLocationDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*GatewayLocationDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -205,26 +212,17 @@ type GatewayLocationNewParams struct { // True if the location needs to resolve EDNS queries. EcsSupport param.Field[bool] `json:"ecs_support"` // A list of network ranges that requests from this location would originate from. - Networks param.Field[[]GatewayLocationNewParamsNetwork] `json:"networks"` + Networks param.Field[[]LocationNetworkParam] `json:"networks"` } func (r GatewayLocationNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type GatewayLocationNewParamsNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network param.Field[string] `json:"network,required"` -} - -func (r GatewayLocationNewParamsNetwork) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type GatewayLocationNewResponseEnvelope struct { - Errors []GatewayLocationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayLocationNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLocations `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Location `json:"result,required"` // Whether the API call was successful Success GatewayLocationNewResponseEnvelopeSuccess `json:"success,required"` JSON gatewayLocationNewResponseEnvelopeJSON `json:"-"` @@ -249,52 +247,6 @@ func (r gatewayLocationNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayLocationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayLocationNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayLocationNewResponseEnvelopeErrors] -type gatewayLocationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayLocationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayLocationNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [GatewayLocationNewResponseEnvelopeMessages] -type gatewayLocationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayLocationNewResponseEnvelopeSuccess bool @@ -319,26 +271,17 @@ type GatewayLocationUpdateParams struct { // True if the location needs to resolve EDNS queries. EcsSupport param.Field[bool] `json:"ecs_support"` // A list of network ranges that requests from this location would originate from. - Networks param.Field[[]GatewayLocationUpdateParamsNetwork] `json:"networks"` + Networks param.Field[[]LocationNetworkParam] `json:"networks"` } func (r GatewayLocationUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type GatewayLocationUpdateParamsNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network param.Field[string] `json:"network,required"` -} - -func (r GatewayLocationUpdateParamsNetwork) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type GatewayLocationUpdateResponseEnvelope struct { - Errors []GatewayLocationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayLocationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLocations `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Location `json:"result,required"` // Whether the API call was successful Success GatewayLocationUpdateResponseEnvelopeSuccess `json:"success,required"` JSON gatewayLocationUpdateResponseEnvelopeJSON `json:"-"` @@ -363,52 +306,6 @@ func (r gatewayLocationUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayLocationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayLocationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [GatewayLocationUpdateResponseEnvelopeErrors] -type gatewayLocationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayLocationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayLocationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [GatewayLocationUpdateResponseEnvelopeMessages] -type gatewayLocationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayLocationUpdateResponseEnvelopeSuccess bool @@ -430,12 +327,17 @@ type GatewayLocationListParams struct { type GatewayLocationDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r GatewayLocationDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type GatewayLocationDeleteResponseEnvelope struct { - Errors []GatewayLocationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayLocationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result GatewayLocationDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayLocationDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success GatewayLocationDeleteResponseEnvelopeSuccess `json:"success,required"` JSON gatewayLocationDeleteResponseEnvelopeJSON `json:"-"` @@ -460,52 +362,6 @@ func (r gatewayLocationDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayLocationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayLocationDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [GatewayLocationDeleteResponseEnvelopeErrors] -type gatewayLocationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayLocationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayLocationDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [GatewayLocationDeleteResponseEnvelopeMessages] -type gatewayLocationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayLocationDeleteResponseEnvelopeSuccess bool @@ -526,9 +382,9 @@ type GatewayLocationGetParams struct { } type GatewayLocationGetResponseEnvelope struct { - Errors []GatewayLocationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayLocationGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLocations `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Location `json:"result,required"` // Whether the API call was successful Success GatewayLocationGetResponseEnvelopeSuccess `json:"success,required"` JSON gatewayLocationGetResponseEnvelopeJSON `json:"-"` @@ -553,52 +409,6 @@ func (r gatewayLocationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayLocationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayLocationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayLocationGetResponseEnvelopeErrors] -type gatewayLocationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayLocationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLocationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayLocationGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [GatewayLocationGetResponseEnvelopeMessages] -type gatewayLocationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLocationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLocationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayLocationGetResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewaylocation_test.go b/zero_trust/gatewaylocation_test.go index dd861983105..e0b1ef6b2da 100644 --- a/zero_trust/gatewaylocation_test.go +++ b/zero_trust/gatewaylocation_test.go @@ -33,7 +33,7 @@ func TestGatewayLocationNewWithOptionalParams(t *testing.T) { Name: cloudflare.F("Austin Office Location"), ClientDefault: cloudflare.F(false), EcsSupport: cloudflare.F(false), - Networks: cloudflare.F([]zero_trust.GatewayLocationNewParamsNetwork{{ + Networks: cloudflare.F([]zero_trust.LocationNetworkParam{{ Network: cloudflare.F("192.0.2.1/32"), }, { Network: cloudflare.F("192.0.2.1/32"), @@ -72,7 +72,7 @@ func TestGatewayLocationUpdateWithOptionalParams(t *testing.T) { Name: cloudflare.F("Austin Office Location"), ClientDefault: cloudflare.F(false), EcsSupport: cloudflare.F(false), - Networks: cloudflare.F([]zero_trust.GatewayLocationUpdateParamsNetwork{{ + Networks: cloudflare.F([]zero_trust.LocationNetworkParam{{ Network: cloudflare.F("192.0.2.1/32"), }, { Network: cloudflare.F("192.0.2.1/32"), @@ -135,6 +135,7 @@ func TestGatewayLocationDelete(t *testing.T) { "ed35569b41ce4d1facfe683550f54086", zero_trust.GatewayLocationDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/gatewaylogging.go b/zero_trust/gatewaylogging.go index c26a14cde65..1957ae2ffa8 100644 --- a/zero_trust/gatewaylogging.go +++ b/zero_trust/gatewaylogging.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewGatewayLoggingService(opts ...option.RequestOption) (r *GatewayLoggingSe } // Updates logging settings for the current Zero Trust account. -func (r *GatewayLoggingService) Update(ctx context.Context, params GatewayLoggingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayGatewayAccountLoggingSettings, err error) { +func (r *GatewayLoggingService) Update(ctx context.Context, params GatewayLoggingUpdateParams, opts ...option.RequestOption) (res *LoggingSetting, err error) { opts = append(r.Options[:], opts...) var env GatewayLoggingUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/logging", params.AccountID) @@ -45,7 +46,7 @@ func (r *GatewayLoggingService) Update(ctx context.Context, params GatewayLoggin } // Fetches the current logging settings for Zero Trust account. -func (r *GatewayLoggingService) Get(ctx context.Context, query GatewayLoggingGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayGatewayAccountLoggingSettings, err error) { +func (r *GatewayLoggingService) Get(ctx context.Context, query GatewayLoggingGetParams, opts ...option.RequestOption) (res *LoggingSetting, err error) { opts = append(r.Options[:], opts...) var env GatewayLoggingGetResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/logging", query.AccountID) @@ -57,47 +58,45 @@ func (r *GatewayLoggingService) Get(ctx context.Context, query GatewayLoggingGet return } -type ZeroTrustGatewayGatewayAccountLoggingSettings struct { +type LoggingSetting struct { // Redact personally identifiable information from activity logging (PII fields // are: source IP, user email, user ID, device ID, URL, referrer, user agent). RedactPii bool `json:"redact_pii"` // Logging settings by rule type. - SettingsByRuleType ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType `json:"settings_by_rule_type"` - JSON zeroTrustGatewayGatewayAccountLoggingSettingsJSON `json:"-"` + SettingsByRuleType LoggingSettingSettingsByRuleType `json:"settings_by_rule_type"` + JSON loggingSettingJSON `json:"-"` } -// zeroTrustGatewayGatewayAccountLoggingSettingsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayGatewayAccountLoggingSettings] -type zeroTrustGatewayGatewayAccountLoggingSettingsJSON struct { +// loggingSettingJSON contains the JSON metadata for the struct [LoggingSetting] +type loggingSettingJSON struct { RedactPii apijson.Field SettingsByRuleType apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayGatewayAccountLoggingSettings) UnmarshalJSON(data []byte) (err error) { +func (r *LoggingSetting) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayGatewayAccountLoggingSettingsJSON) RawJSON() string { +func (r loggingSettingJSON) RawJSON() string { return r.raw } // Logging settings by rule type. -type ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType struct { +type LoggingSettingSettingsByRuleType struct { // Logging settings for DNS firewall. DNS interface{} `json:"dns"` // Logging settings for HTTP/HTTPS firewall. HTTP interface{} `json:"http"` // Logging settings for Network firewall. - L4 interface{} `json:"l4"` - JSON zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON `json:"-"` + L4 interface{} `json:"l4"` + JSON loggingSettingSettingsByRuleTypeJSON `json:"-"` } -// zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType] -type zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON struct { +// loggingSettingSettingsByRuleTypeJSON contains the JSON metadata for the struct +// [LoggingSettingSettingsByRuleType] +type loggingSettingSettingsByRuleTypeJSON struct { DNS apijson.Field HTTP apijson.Field L4 apijson.Field @@ -105,29 +104,28 @@ type zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON struct ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType) UnmarshalJSON(data []byte) (err error) { +func (r *LoggingSettingSettingsByRuleType) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON) RawJSON() string { +func (r loggingSettingSettingsByRuleTypeJSON) RawJSON() string { return r.raw } -type GatewayLoggingUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` +type LoggingSettingParam struct { // Redact personally identifiable information from activity logging (PII fields // are: source IP, user email, user ID, device ID, URL, referrer, user agent). RedactPii param.Field[bool] `json:"redact_pii"` // Logging settings by rule type. - SettingsByRuleType param.Field[GatewayLoggingUpdateParamsSettingsByRuleType] `json:"settings_by_rule_type"` + SettingsByRuleType param.Field[LoggingSettingSettingsByRuleTypeParam] `json:"settings_by_rule_type"` } -func (r GatewayLoggingUpdateParams) MarshalJSON() (data []byte, err error) { +func (r LoggingSettingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Logging settings by rule type. -type GatewayLoggingUpdateParamsSettingsByRuleType struct { +type LoggingSettingSettingsByRuleTypeParam struct { // Logging settings for DNS firewall. DNS param.Field[interface{}] `json:"dns"` // Logging settings for HTTP/HTTPS firewall. @@ -136,14 +134,23 @@ type GatewayLoggingUpdateParamsSettingsByRuleType struct { L4 param.Field[interface{}] `json:"l4"` } -func (r GatewayLoggingUpdateParamsSettingsByRuleType) MarshalJSON() (data []byte, err error) { +func (r LoggingSettingSettingsByRuleTypeParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +type GatewayLoggingUpdateParams struct { + AccountID param.Field[string] `path:"account_id,required"` + LoggingSetting LoggingSettingParam `json:"logging_setting,required"` +} + +func (r GatewayLoggingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.LoggingSetting) +} + type GatewayLoggingUpdateResponseEnvelope struct { - Errors []GatewayLoggingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayLoggingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayGatewayAccountLoggingSettings `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LoggingSetting `json:"result,required"` // Whether the API call was successful Success GatewayLoggingUpdateResponseEnvelopeSuccess `json:"success,required"` JSON gatewayLoggingUpdateResponseEnvelopeJSON `json:"-"` @@ -168,52 +175,6 @@ func (r gatewayLoggingUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayLoggingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLoggingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayLoggingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [GatewayLoggingUpdateResponseEnvelopeErrors] -type gatewayLoggingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLoggingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLoggingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayLoggingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLoggingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayLoggingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [GatewayLoggingUpdateResponseEnvelopeMessages] -type gatewayLoggingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLoggingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLoggingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayLoggingUpdateResponseEnvelopeSuccess bool @@ -234,9 +195,9 @@ type GatewayLoggingGetParams struct { } type GatewayLoggingGetResponseEnvelope struct { - Errors []GatewayLoggingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayLoggingGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayGatewayAccountLoggingSettings `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result LoggingSetting `json:"result,required"` // Whether the API call was successful Success GatewayLoggingGetResponseEnvelopeSuccess `json:"success,required"` JSON gatewayLoggingGetResponseEnvelopeJSON `json:"-"` @@ -261,52 +222,6 @@ func (r gatewayLoggingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayLoggingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLoggingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayLoggingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayLoggingGetResponseEnvelopeErrors] -type gatewayLoggingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLoggingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLoggingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayLoggingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayLoggingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayLoggingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayLoggingGetResponseEnvelopeMessages] -type gatewayLoggingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayLoggingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayLoggingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayLoggingGetResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewaylogging_test.go b/zero_trust/gatewaylogging_test.go index 521341fdfdc..f22907d333a 100644 --- a/zero_trust/gatewaylogging_test.go +++ b/zero_trust/gatewaylogging_test.go @@ -30,12 +30,14 @@ func TestGatewayLoggingUpdateWithOptionalParams(t *testing.T) { ) _, err := client.ZeroTrust.Gateway.Logging.Update(context.TODO(), zero_trust.GatewayLoggingUpdateParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - RedactPii: cloudflare.F(true), - SettingsByRuleType: cloudflare.F(zero_trust.GatewayLoggingUpdateParamsSettingsByRuleType{ - DNS: cloudflare.F[any](map[string]interface{}{}), - HTTP: cloudflare.F[any](map[string]interface{}{}), - L4: cloudflare.F[any](map[string]interface{}{}), - }), + LoggingSetting: zero_trust.LoggingSettingParam{ + RedactPii: cloudflare.F(true), + SettingsByRuleType: cloudflare.F(zero_trust.LoggingSettingSettingsByRuleTypeParam{ + DNS: cloudflare.F[any](map[string]interface{}{}), + HTTP: cloudflare.F[any](map[string]interface{}{}), + L4: cloudflare.F[any](map[string]interface{}{}), + }), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/zero_trust/gatewayproxyendpoint.go b/zero_trust/gatewayproxyendpoint.go index 42d68c6aaa5..46e21e372af 100644 --- a/zero_trust/gatewayproxyendpoint.go +++ b/zero_trust/gatewayproxyendpoint.go @@ -37,7 +37,7 @@ func NewGatewayProxyEndpointService(opts ...option.RequestOption) (r *GatewayPro } // Creates a new Zero Trust Gateway proxy endpoint. -func (r *GatewayProxyEndpointService) New(ctx context.Context, params GatewayProxyEndpointNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpoints, err error) { +func (r *GatewayProxyEndpointService) New(ctx context.Context, params GatewayProxyEndpointNewParams, opts ...option.RequestOption) (res *ProxyEndpoint, err error) { opts = append(r.Options[:], opts...) var env GatewayProxyEndpointNewResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/proxy_endpoints", params.AccountID) @@ -50,7 +50,7 @@ func (r *GatewayProxyEndpointService) New(ctx context.Context, params GatewayPro } // Fetches a single Zero Trust Gateway proxy endpoint. -func (r *GatewayProxyEndpointService) List(ctx context.Context, query GatewayProxyEndpointListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGatewayProxyEndpoints], err error) { +func (r *GatewayProxyEndpointService) List(ctx context.Context, query GatewayProxyEndpointListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ProxyEndpoint], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -68,15 +68,15 @@ func (r *GatewayProxyEndpointService) List(ctx context.Context, query GatewayPro } // Fetches a single Zero Trust Gateway proxy endpoint. -func (r *GatewayProxyEndpointService) ListAutoPaging(ctx context.Context, query GatewayProxyEndpointListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGatewayProxyEndpoints] { +func (r *GatewayProxyEndpointService) ListAutoPaging(ctx context.Context, query GatewayProxyEndpointListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ProxyEndpoint] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a configured Zero Trust Gateway proxy endpoint. -func (r *GatewayProxyEndpointService) Delete(ctx context.Context, proxyEndpointID string, body GatewayProxyEndpointDeleteParams, opts ...option.RequestOption) (res *GatewayProxyEndpointDeleteResponse, err error) { +func (r *GatewayProxyEndpointService) Delete(ctx context.Context, proxyEndpointID string, params GatewayProxyEndpointDeleteParams, opts ...option.RequestOption) (res *GatewayProxyEndpointDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env GatewayProxyEndpointDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/gateway/proxy_endpoints/%s", body.AccountID, proxyEndpointID) + path := fmt.Sprintf("accounts/%s/gateway/proxy_endpoints/%s", params.AccountID, proxyEndpointID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -86,7 +86,7 @@ func (r *GatewayProxyEndpointService) Delete(ctx context.Context, proxyEndpointI } // Updates a configured Zero Trust Gateway proxy endpoint. -func (r *GatewayProxyEndpointService) Edit(ctx context.Context, proxyEndpointID string, params GatewayProxyEndpointEditParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpoints, err error) { +func (r *GatewayProxyEndpointService) Edit(ctx context.Context, proxyEndpointID string, params GatewayProxyEndpointEditParams, opts ...option.RequestOption) (res *ProxyEndpoint, err error) { opts = append(r.Options[:], opts...) var env GatewayProxyEndpointEditResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/proxy_endpoints/%s", params.AccountID, proxyEndpointID) @@ -99,7 +99,7 @@ func (r *GatewayProxyEndpointService) Edit(ctx context.Context, proxyEndpointID } // Fetches all Zero Trust Gateway proxy endpoints for an account. -func (r *GatewayProxyEndpointService) Get(ctx context.Context, proxyEndpointID string, query GatewayProxyEndpointGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpoints, err error) { +func (r *GatewayProxyEndpointService) Get(ctx context.Context, proxyEndpointID string, query GatewayProxyEndpointGetParams, opts ...option.RequestOption) (res *ProxyEndpoint, err error) { opts = append(r.Options[:], opts...) var env GatewayProxyEndpointGetResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/proxy_endpoints/%s", query.AccountID, proxyEndpointID) @@ -111,22 +111,25 @@ func (r *GatewayProxyEndpointService) Get(ctx context.Context, proxyEndpointID s return } -type ZeroTrustGatewayProxyEndpoints struct { +type GatewayIPs = 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 []string `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. - Subdomain string `json:"subdomain"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayProxyEndpointsJSON `json:"-"` + Subdomain string `json:"subdomain"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON proxyEndpointJSON `json:"-"` } -// zeroTrustGatewayProxyEndpointsJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayProxyEndpoints] -type zeroTrustGatewayProxyEndpointsJSON struct { +// proxyEndpointJSON contains the JSON metadata for the struct [ProxyEndpoint] +type proxyEndpointJSON struct { ID apijson.Field CreatedAt apijson.Field IPs apijson.Field @@ -137,23 +140,23 @@ type zeroTrustGatewayProxyEndpointsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayProxyEndpoints) UnmarshalJSON(data []byte) (err error) { +func (r *ProxyEndpoint) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayProxyEndpointsJSON) RawJSON() string { +func (r proxyEndpointJSON) RawJSON() string { return r.raw } // Union satisfied by [zero_trust.GatewayProxyEndpointDeleteResponseUnknown] or // [shared.UnionString]. -type GatewayProxyEndpointDeleteResponse interface { - ImplementsZeroTrustGatewayProxyEndpointDeleteResponse() +type GatewayProxyEndpointDeleteResponseUnion interface { + ImplementsZeroTrustGatewayProxyEndpointDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*GatewayProxyEndpointDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*GatewayProxyEndpointDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -165,11 +168,9 @@ func init() { type GatewayProxyEndpointNewParams struct { AccountID param.Field[string] `path:"account_id,required"` // A list of CIDRs to restrict ingress connections. - IPs param.Field[[]string] `json:"ips,required"` + IPs param.Field[[]GatewayIPsParam] `json:"ips,required"` // The name of the proxy endpoint. Name param.Field[string] `json:"name,required"` - // The subdomain to be used as the destination in the proxy client. - Subdomain param.Field[string] `json:"subdomain"` } func (r GatewayProxyEndpointNewParams) MarshalJSON() (data []byte, err error) { @@ -177,9 +178,9 @@ func (r GatewayProxyEndpointNewParams) MarshalJSON() (data []byte, err error) { } type GatewayProxyEndpointNewResponseEnvelope struct { - Errors []GatewayProxyEndpointNewResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayProxyEndpointNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayProxyEndpoints `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProxyEndpoint `json:"result,required"` // Whether the API call was successful Success GatewayProxyEndpointNewResponseEnvelopeSuccess `json:"success,required"` JSON gatewayProxyEndpointNewResponseEnvelopeJSON `json:"-"` @@ -204,52 +205,6 @@ func (r gatewayProxyEndpointNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayProxyEndpointNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayProxyEndpointNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [GatewayProxyEndpointNewResponseEnvelopeErrors] -type gatewayProxyEndpointNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayProxyEndpointNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayProxyEndpointNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [GatewayProxyEndpointNewResponseEnvelopeMessages] -type gatewayProxyEndpointNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayProxyEndpointNewResponseEnvelopeSuccess bool @@ -271,12 +226,17 @@ type GatewayProxyEndpointListParams struct { type GatewayProxyEndpointDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r GatewayProxyEndpointDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type GatewayProxyEndpointDeleteResponseEnvelope struct { - Errors []GatewayProxyEndpointDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayProxyEndpointDeleteResponseEnvelopeMessages `json:"messages,required"` - Result GatewayProxyEndpointDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayProxyEndpointDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success GatewayProxyEndpointDeleteResponseEnvelopeSuccess `json:"success,required"` JSON gatewayProxyEndpointDeleteResponseEnvelopeJSON `json:"-"` @@ -301,52 +261,6 @@ func (r gatewayProxyEndpointDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayProxyEndpointDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [GatewayProxyEndpointDeleteResponseEnvelopeErrors] -type gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayProxyEndpointDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [GatewayProxyEndpointDeleteResponseEnvelopeMessages] -type gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayProxyEndpointDeleteResponseEnvelopeSuccess bool @@ -365,11 +279,9 @@ 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[[]string] `json:"ips"` + IPs param.Field[[]GatewayIPsParam] `json:"ips"` // The name of the proxy endpoint. Name param.Field[string] `json:"name"` - // The subdomain to be used as the destination in the proxy client. - Subdomain param.Field[string] `json:"subdomain"` } func (r GatewayProxyEndpointEditParams) MarshalJSON() (data []byte, err error) { @@ -377,9 +289,9 @@ func (r GatewayProxyEndpointEditParams) MarshalJSON() (data []byte, err error) { } type GatewayProxyEndpointEditResponseEnvelope struct { - Errors []GatewayProxyEndpointEditResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayProxyEndpointEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayProxyEndpoints `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProxyEndpoint `json:"result,required"` // Whether the API call was successful Success GatewayProxyEndpointEditResponseEnvelopeSuccess `json:"success,required"` JSON gatewayProxyEndpointEditResponseEnvelopeJSON `json:"-"` @@ -404,52 +316,6 @@ func (r gatewayProxyEndpointEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayProxyEndpointEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayProxyEndpointEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [GatewayProxyEndpointEditResponseEnvelopeErrors] -type gatewayProxyEndpointEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayProxyEndpointEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayProxyEndpointEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [GatewayProxyEndpointEditResponseEnvelopeMessages] -type gatewayProxyEndpointEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayProxyEndpointEditResponseEnvelopeSuccess bool @@ -470,9 +336,9 @@ type GatewayProxyEndpointGetParams struct { } type GatewayProxyEndpointGetResponseEnvelope struct { - Errors []GatewayProxyEndpointGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayProxyEndpointGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayProxyEndpoints `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ProxyEndpoint `json:"result,required"` // Whether the API call was successful Success GatewayProxyEndpointGetResponseEnvelopeSuccess `json:"success,required"` JSON gatewayProxyEndpointGetResponseEnvelopeJSON `json:"-"` @@ -497,52 +363,6 @@ func (r gatewayProxyEndpointGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayProxyEndpointGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayProxyEndpointGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [GatewayProxyEndpointGetResponseEnvelopeErrors] -type gatewayProxyEndpointGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayProxyEndpointGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayProxyEndpointGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayProxyEndpointGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [GatewayProxyEndpointGetResponseEnvelopeMessages] -type gatewayProxyEndpointGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayProxyEndpointGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayProxyEndpointGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayProxyEndpointGetResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewayproxyendpoint_test.go b/zero_trust/gatewayproxyendpoint_test.go index 5e974cc53cf..f522e8ef5a5 100644 --- a/zero_trust/gatewayproxyendpoint_test.go +++ b/zero_trust/gatewayproxyendpoint_test.go @@ -14,7 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/zero_trust" ) -func TestGatewayProxyEndpointNewWithOptionalParams(t *testing.T) { +func TestGatewayProxyEndpointNew(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 { @@ -30,9 +30,8 @@ func TestGatewayProxyEndpointNewWithOptionalParams(t *testing.T) { ) _, err := client.ZeroTrust.Gateway.ProxyEndpoints.New(context.TODO(), zero_trust.GatewayProxyEndpointNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IPs: cloudflare.F([]string{"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"), - Subdomain: cloudflare.F("oli3n9zkz5.proxy.cloudflare-gateway.com"), }) if err != nil { var apierr *cloudflare.Error @@ -88,6 +87,7 @@ func TestGatewayProxyEndpointDelete(t *testing.T) { "ed35569b41ce4d1facfe683550f54086", zero_trust.GatewayProxyEndpointDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { @@ -118,9 +118,8 @@ func TestGatewayProxyEndpointEditWithOptionalParams(t *testing.T) { "ed35569b41ce4d1facfe683550f54086", zero_trust.GatewayProxyEndpointEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IPs: cloudflare.F([]string{"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"), - Subdomain: cloudflare.F("oli3n9zkz5.proxy.cloudflare-gateway.com"), }, ) if err != nil { diff --git a/zero_trust/gatewayrule.go b/zero_trust/gatewayrule.go index 97c34920af8..1832d5f4cfe 100644 --- a/zero_trust/gatewayrule.go +++ b/zero_trust/gatewayrule.go @@ -37,7 +37,7 @@ func NewGatewayRuleService(opts ...option.RequestOption) (r *GatewayRuleService) } // Creates a new Zero Trust Gateway rule. -func (r *GatewayRuleService) New(ctx context.Context, params GatewayRuleNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRules, err error) { +func (r *GatewayRuleService) New(ctx context.Context, params GatewayRuleNewParams, opts ...option.RequestOption) (res *GatewayRule, err error) { opts = append(r.Options[:], opts...) var env GatewayRuleNewResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/rules", params.AccountID) @@ -50,7 +50,7 @@ func (r *GatewayRuleService) New(ctx context.Context, params GatewayRuleNewParam } // Updates a configured Zero Trust Gateway rule. -func (r *GatewayRuleService) Update(ctx context.Context, ruleID string, params GatewayRuleUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRules, err error) { +func (r *GatewayRuleService) Update(ctx context.Context, ruleID string, params GatewayRuleUpdateParams, opts ...option.RequestOption) (res *GatewayRule, err error) { opts = append(r.Options[:], opts...) var env GatewayRuleUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/rules/%s", params.AccountID, ruleID) @@ -63,7 +63,7 @@ func (r *GatewayRuleService) Update(ctx context.Context, ruleID string, params G } // Fetches the Zero Trust Gateway rules for an account. -func (r *GatewayRuleService) List(ctx context.Context, query GatewayRuleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[ZeroTrustGatewayRules], err error) { +func (r *GatewayRuleService) List(ctx context.Context, query GatewayRuleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[GatewayRule], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -81,15 +81,15 @@ func (r *GatewayRuleService) List(ctx context.Context, query GatewayRuleListPara } // Fetches the Zero Trust Gateway rules for an account. -func (r *GatewayRuleService) ListAutoPaging(ctx context.Context, query GatewayRuleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[ZeroTrustGatewayRules] { +func (r *GatewayRuleService) ListAutoPaging(ctx context.Context, query GatewayRuleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[GatewayRule] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } // Deletes a Zero Trust Gateway rule. -func (r *GatewayRuleService) Delete(ctx context.Context, ruleID string, body GatewayRuleDeleteParams, opts ...option.RequestOption) (res *GatewayRuleDeleteResponse, err error) { +func (r *GatewayRuleService) Delete(ctx context.Context, ruleID string, params GatewayRuleDeleteParams, opts ...option.RequestOption) (res *GatewayRuleDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env GatewayRuleDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/gateway/rules/%s", body.AccountID, ruleID) + path := fmt.Sprintf("accounts/%s/gateway/rules/%s", params.AccountID, ruleID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -99,7 +99,7 @@ func (r *GatewayRuleService) Delete(ctx context.Context, ruleID string, body Gat } // Fetches a single Zero Trust Gateway rule. -func (r *GatewayRuleService) Get(ctx context.Context, ruleID string, query GatewayRuleGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRules, err error) { +func (r *GatewayRuleService) Get(ctx context.Context, ruleID string, query GatewayRuleGetParams, opts ...option.RequestOption) (res *GatewayRule, err error) { opts = append(r.Options[:], opts...) var env GatewayRuleGetResponseEnvelope path := fmt.Sprintf("accounts/%s/gateway/rules/%s", query.AccountID, ruleID) @@ -111,13 +111,131 @@ func (r *GatewayRuleService) Get(ctx context.Context, ruleID string, query Gatew return } -type ZeroTrustGatewayRules struct { +type DNSResolverSettingsV4 struct { + // IPv4 address of upstream resolver. + IP string `json:"ip,required"` + // A port number to use for upstream resolver. Defaults to 53 if unspecified. + Port int64 `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork bool `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID string `json:"vnet_id"` + JSON dnsResolverSettingsV4JSON `json:"-"` +} + +// dnsResolverSettingsV4JSON contains the JSON metadata for the struct +// [DNSResolverSettingsV4] +type dnsResolverSettingsV4JSON struct { + IP apijson.Field + Port apijson.Field + RouteThroughPrivateNetwork apijson.Field + VnetID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSResolverSettingsV4) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsResolverSettingsV4JSON) RawJSON() string { + return r.raw +} + +type DNSResolverSettingsV4Param struct { + // IPv4 address of upstream resolver. + IP param.Field[string] `json:"ip,required"` + // A port number to use for upstream resolver. Defaults to 53 if unspecified. + Port param.Field[int64] `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID param.Field[string] `json:"vnet_id"` +} + +func (r DNSResolverSettingsV4Param) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DNSResolverSettingsV6 struct { + // IPv6 address of upstream resolver. + IP string `json:"ip,required"` + // A port number to use for upstream resolver. Defaults to 53 if unspecified. + Port int64 `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork bool `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID string `json:"vnet_id"` + JSON dnsResolverSettingsV6JSON `json:"-"` +} + +// dnsResolverSettingsV6JSON contains the JSON metadata for the struct +// [DNSResolverSettingsV6] +type dnsResolverSettingsV6JSON struct { + IP apijson.Field + Port apijson.Field + RouteThroughPrivateNetwork apijson.Field + VnetID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSResolverSettingsV6) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsResolverSettingsV6JSON) RawJSON() string { + return r.raw +} + +type DNSResolverSettingsV6Param struct { + // IPv6 address of upstream resolver. + IP param.Field[string] `json:"ip,required"` + // A port number to use for upstream resolver. Defaults to 53 if unspecified. + Port param.Field[int64] `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID param.Field[string] `json:"vnet_id"` +} + +func (r DNSResolverSettingsV6Param) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol or layer to use. +type GatewayFilter string + +const ( + GatewayFilterHTTP GatewayFilter = "http" + GatewayFilterDNS GatewayFilter = "dns" + GatewayFilterL4 GatewayFilter = "l4" + GatewayFilterEgress GatewayFilter = "egress" +) + +func (r GatewayFilter) IsKnown() bool { + switch r { + case GatewayFilterHTTP, GatewayFilterDNS, GatewayFilterL4, GatewayFilterEgress: + return true + } + return false +} + +type GatewayRule struct { // The API resource UUID. ID string `json:"id"` // The action to preform when the associated traffic, identity, and device posture // expressions are either absent or evaluate to `true`. - Action ZeroTrustGatewayRulesAction `json:"action"` - CreatedAt time.Time `json:"created_at" format:"date-time"` + Action GatewayRuleAction `json:"action"` + CreatedAt time.Time `json:"created_at" format:"date-time"` // Date of deletion, if any. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` // The description of the rule. @@ -128,7 +246,7 @@ type ZeroTrustGatewayRules struct { Enabled bool `json:"enabled"` // The protocol or layer to evaluate the traffic, identity, and device posture // expressions. - Filters []ZeroTrustGatewayRulesFilter `json:"filters"` + Filters []GatewayFilter `json:"filters"` // The wirefilter expression used for identity matching. Identity string `json:"identity"` // The name of the rule. @@ -138,19 +256,18 @@ type ZeroTrustGatewayRules struct { // ascending order of this value. Precedence int64 `json:"precedence"` // Additional settings that modify the rule's action. - RuleSettings ZeroTrustGatewayRulesRuleSettings `json:"rule_settings"` + RuleSettings RuleSetting `json:"rule_settings"` // The schedule for activating DNS policies. This does not apply to HTTP or network // policies. - Schedule ZeroTrustGatewayRulesSchedule `json:"schedule"` + Schedule Schedule `json:"schedule"` // The wirefilter expression used for traffic matching. - Traffic string `json:"traffic"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayRulesJSON `json:"-"` + Traffic string `json:"traffic"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayRuleJSON `json:"-"` } -// zeroTrustGatewayRulesJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayRules] -type zeroTrustGatewayRulesJSON struct { +// gatewayRuleJSON contains the JSON metadata for the struct [GatewayRule] +type gatewayRuleJSON struct { ID apijson.Field Action apijson.Field CreatedAt apijson.Field @@ -170,72 +287,55 @@ type zeroTrustGatewayRulesJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRules) UnmarshalJSON(data []byte) (err error) { +func (r *GatewayRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesJSON) RawJSON() string { +func (r gatewayRuleJSON) RawJSON() string { return r.raw } // The action to preform when the associated traffic, identity, and device posture // expressions are either absent or evaluate to `true`. -type ZeroTrustGatewayRulesAction string - -const ( - ZeroTrustGatewayRulesActionOn ZeroTrustGatewayRulesAction = "on" - ZeroTrustGatewayRulesActionOff ZeroTrustGatewayRulesAction = "off" - ZeroTrustGatewayRulesActionAllow ZeroTrustGatewayRulesAction = "allow" - ZeroTrustGatewayRulesActionBlock ZeroTrustGatewayRulesAction = "block" - ZeroTrustGatewayRulesActionScan ZeroTrustGatewayRulesAction = "scan" - ZeroTrustGatewayRulesActionNoscan ZeroTrustGatewayRulesAction = "noscan" - ZeroTrustGatewayRulesActionSafesearch ZeroTrustGatewayRulesAction = "safesearch" - ZeroTrustGatewayRulesActionYtrestricted ZeroTrustGatewayRulesAction = "ytrestricted" - ZeroTrustGatewayRulesActionIsolate ZeroTrustGatewayRulesAction = "isolate" - ZeroTrustGatewayRulesActionNoisolate ZeroTrustGatewayRulesAction = "noisolate" - ZeroTrustGatewayRulesActionOverride ZeroTrustGatewayRulesAction = "override" - ZeroTrustGatewayRulesActionL4Override ZeroTrustGatewayRulesAction = "l4_override" - ZeroTrustGatewayRulesActionEgress ZeroTrustGatewayRulesAction = "egress" - ZeroTrustGatewayRulesActionAuditSSH ZeroTrustGatewayRulesAction = "audit_ssh" -) - -func (r ZeroTrustGatewayRulesAction) IsKnown() bool { - switch r { - case ZeroTrustGatewayRulesActionOn, ZeroTrustGatewayRulesActionOff, ZeroTrustGatewayRulesActionAllow, ZeroTrustGatewayRulesActionBlock, ZeroTrustGatewayRulesActionScan, ZeroTrustGatewayRulesActionNoscan, ZeroTrustGatewayRulesActionSafesearch, ZeroTrustGatewayRulesActionYtrestricted, ZeroTrustGatewayRulesActionIsolate, ZeroTrustGatewayRulesActionNoisolate, ZeroTrustGatewayRulesActionOverride, ZeroTrustGatewayRulesActionL4Override, ZeroTrustGatewayRulesActionEgress, ZeroTrustGatewayRulesActionAuditSSH: - return true - } - return false -} - -// The protocol or layer to use. -type ZeroTrustGatewayRulesFilter string +type GatewayRuleAction string const ( - ZeroTrustGatewayRulesFilterHTTP ZeroTrustGatewayRulesFilter = "http" - ZeroTrustGatewayRulesFilterDNS ZeroTrustGatewayRulesFilter = "dns" - ZeroTrustGatewayRulesFilterL4 ZeroTrustGatewayRulesFilter = "l4" - ZeroTrustGatewayRulesFilterEgress ZeroTrustGatewayRulesFilter = "egress" + GatewayRuleActionOn GatewayRuleAction = "on" + GatewayRuleActionOff GatewayRuleAction = "off" + GatewayRuleActionAllow GatewayRuleAction = "allow" + GatewayRuleActionBlock GatewayRuleAction = "block" + GatewayRuleActionScan GatewayRuleAction = "scan" + GatewayRuleActionNoscan GatewayRuleAction = "noscan" + GatewayRuleActionSafesearch GatewayRuleAction = "safesearch" + GatewayRuleActionYtrestricted GatewayRuleAction = "ytrestricted" + GatewayRuleActionIsolate GatewayRuleAction = "isolate" + GatewayRuleActionNoisolate GatewayRuleAction = "noisolate" + GatewayRuleActionOverride GatewayRuleAction = "override" + GatewayRuleActionL4Override GatewayRuleAction = "l4_override" + GatewayRuleActionEgress GatewayRuleAction = "egress" + GatewayRuleActionAuditSSH GatewayRuleAction = "audit_ssh" + GatewayRuleActionResolve GatewayRuleAction = "resolve" ) -func (r ZeroTrustGatewayRulesFilter) IsKnown() bool { +func (r GatewayRuleAction) IsKnown() bool { switch r { - case ZeroTrustGatewayRulesFilterHTTP, ZeroTrustGatewayRulesFilterDNS, ZeroTrustGatewayRulesFilterL4, ZeroTrustGatewayRulesFilterEgress: + case GatewayRuleActionOn, GatewayRuleActionOff, GatewayRuleActionAllow, GatewayRuleActionBlock, GatewayRuleActionScan, GatewayRuleActionNoscan, GatewayRuleActionSafesearch, GatewayRuleActionYtrestricted, GatewayRuleActionIsolate, GatewayRuleActionNoisolate, GatewayRuleActionOverride, GatewayRuleActionL4Override, GatewayRuleActionEgress, GatewayRuleActionAuditSSH, GatewayRuleActionResolve: return true } return false } // Additional settings that modify the rule's action. -type ZeroTrustGatewayRulesRuleSettings struct { +type RuleSetting struct { // Add custom headers to allowed requests, in the form of key-value pairs. Keys are // header names, pointing to an array with its header value(s). AddHeaders interface{} `json:"add_headers"` // Set by parent MSP accounts to enable their children to bypass this rule. AllowChildBypass bool `json:"allow_child_bypass"` // Settings for the Audit SSH action. - AuditSSH ZeroTrustGatewayRulesRuleSettingsAuditSSH `json:"audit_ssh"` + AuditSSH RuleSettingAuditSSH `json:"audit_ssh"` // Configure how browser isolation behaves. - BisoAdminControls ZeroTrustGatewayRulesRuleSettingsBisoAdminControls `json:"biso_admin_controls"` + BisoAdminControls RuleSettingBisoAdminControls `json:"biso_admin_controls"` // Enable the custom block page. BlockPageEnabled bool `json:"block_page_enabled"` // The text describing why this block occurred, displayed on the custom block page @@ -244,15 +344,16 @@ type ZeroTrustGatewayRulesRuleSettings struct { // Set by children MSP accounts to bypass their parent's rules. BypassParentRule bool `json:"bypass_parent_rule"` // Configure how session check behaves. - CheckSession ZeroTrustGatewayRulesRuleSettingsCheckSession `json:"check_session"` + CheckSession RuleSettingCheckSession `json:"check_session"` // Add your own custom resolvers to route queries that match the resolver policy. // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers ZeroTrustGatewayRulesRuleSettingsDNSResolvers `json:"dns_resolvers"` + // route to the address closest to their origin. Only valid when a rule's action is + // set to 'resolve'. + DNSResolvers RuleSettingDNSResolvers `json:"dns_resolvers"` // Configure how Gateway Proxy traffic egresses. You can enable this setting for // rules with Egress actions and filters, or omit it to indicate local egress via // WARP IPs. - Egress ZeroTrustGatewayRulesRuleSettingsEgress `json:"egress"` + Egress RuleSettingEgress `json:"egress"` // INSECURE - disable DNSSEC validation (for Allow actions). InsecureDisableDNSSECValidation bool `json:"insecure_disable_dnssec_validation"` // Set to true to enable IPs in DNS resolver category blocks. By default categories @@ -262,27 +363,27 @@ type ZeroTrustGatewayRulesRuleSettings struct { // indicator feeds only block based on domain names. IPIndicatorFeeds bool `json:"ip_indicator_feeds"` // Send matching traffic to the supplied destination IP address and port. - L4override ZeroTrustGatewayRulesRuleSettingsL4override `json:"l4override"` + L4override RuleSettingL4override `json:"l4override"` // Configure a notification to display on the user's device when this rule is // matched. - NotificationSettings ZeroTrustGatewayRulesRuleSettingsNotificationSettings `json:"notification_settings"` + NotificationSettings RuleSettingNotificationSettings `json:"notification_settings"` // Override matching DNS queries with a hostname. OverrideHost string `json:"override_host"` // Override matching DNS queries with an IP or set of IPs. OverrideIPs []string `json:"override_ips"` // Configure DLP payload logging. - PayloadLog ZeroTrustGatewayRulesRuleSettingsPayloadLog `json:"payload_log"` + PayloadLog RuleSettingPayloadLog `json:"payload_log"` // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. + // resolver. Cannot be set when dns_resolvers are specified. Only valid when a + // rule's action is set to 'resolve'. ResolveDNSThroughCloudflare bool `json:"resolve_dns_through_cloudflare"` // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCERT ZeroTrustGatewayRulesRuleSettingsUntrustedCERT `json:"untrusted_cert"` - JSON zeroTrustGatewayRulesRuleSettingsJSON `json:"-"` + UntrustedCERT RuleSettingUntrustedCERT `json:"untrusted_cert"` + JSON ruleSettingJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayRulesRuleSettings] -type zeroTrustGatewayRulesRuleSettingsJSON struct { +// ruleSettingJSON contains the JSON metadata for the struct [RuleSetting] +type ruleSettingJSON struct { AddHeaders apijson.Field AllowChildBypass apijson.Field AuditSSH apijson.Field @@ -307,39 +408,39 @@ type zeroTrustGatewayRulesRuleSettingsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettings) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSetting) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsJSON) RawJSON() string { +func (r ruleSettingJSON) RawJSON() string { return r.raw } // Settings for the Audit SSH action. -type ZeroTrustGatewayRulesRuleSettingsAuditSSH struct { +type RuleSettingAuditSSH struct { // Enable to turn on SSH command logging. - CommandLogging bool `json:"command_logging"` - JSON zeroTrustGatewayRulesRuleSettingsAuditSSHJSON `json:"-"` + CommandLogging bool `json:"command_logging"` + JSON ruleSettingAuditSSHJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsAuditSSHJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRulesRuleSettingsAuditSSH] -type zeroTrustGatewayRulesRuleSettingsAuditSSHJSON struct { +// ruleSettingAuditSSHJSON contains the JSON metadata for the struct +// [RuleSettingAuditSSH] +type ruleSettingAuditSSHJSON struct { CommandLogging apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsAuditSSH) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingAuditSSH) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsAuditSSHJSON) RawJSON() string { +func (r ruleSettingAuditSSHJSON) RawJSON() string { return r.raw } // Configure how browser isolation behaves. -type ZeroTrustGatewayRulesRuleSettingsBisoAdminControls struct { +type RuleSettingBisoAdminControls struct { // Set to true to enable copy-pasting. Dcp bool `json:"dcp"` // Set to true to enable downloading. @@ -349,13 +450,13 @@ type ZeroTrustGatewayRulesRuleSettingsBisoAdminControls struct { // Set to true to enable printing. Dp bool `json:"dp"` // Set to true to enable uploading. - Du bool `json:"du"` - JSON zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON `json:"-"` + Du bool `json:"du"` + JSON ruleSettingBisoAdminControlsJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRulesRuleSettingsBisoAdminControls] -type zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON struct { +// ruleSettingBisoAdminControlsJSON contains the JSON metadata for the struct +// [RuleSettingBisoAdminControls] +type ruleSettingBisoAdminControlsJSON struct { Dcp apijson.Field Dd apijson.Field Dk apijson.Field @@ -365,136 +466,71 @@ type zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsBisoAdminControls) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingBisoAdminControls) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON) RawJSON() string { +func (r ruleSettingBisoAdminControlsJSON) RawJSON() string { return r.raw } // Configure how session check behaves. -type ZeroTrustGatewayRulesRuleSettingsCheckSession struct { +type RuleSettingCheckSession struct { // Configure how fresh the session needs to be to be considered valid. Duration string `json:"duration"` // Set to true to enable session enforcement. - Enforce bool `json:"enforce"` - JSON zeroTrustGatewayRulesRuleSettingsCheckSessionJSON `json:"-"` + Enforce bool `json:"enforce"` + JSON ruleSettingCheckSessionJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsCheckSessionJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRulesRuleSettingsCheckSession] -type zeroTrustGatewayRulesRuleSettingsCheckSessionJSON struct { +// ruleSettingCheckSessionJSON contains the JSON metadata for the struct +// [RuleSettingCheckSession] +type ruleSettingCheckSessionJSON struct { Duration apijson.Field Enforce apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsCheckSession) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingCheckSession) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsCheckSessionJSON) RawJSON() string { +func (r ruleSettingCheckSessionJSON) RawJSON() string { return r.raw } // Add your own custom resolvers to route queries that match the resolver policy. // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type ZeroTrustGatewayRulesRuleSettingsDNSResolvers struct { - IPV4 []ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4 `json:"ipv4"` - IPV6 []ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6 `json:"ipv6"` - JSON zeroTrustGatewayRulesRuleSettingsDNSResolversJSON `json:"-"` +// route to the address closest to their origin. Only valid when a rule's action is +// set to 'resolve'. +type RuleSettingDNSResolvers struct { + IPV4 []DNSResolverSettingsV4 `json:"ipv4"` + IPV6 []DNSResolverSettingsV6 `json:"ipv6"` + JSON ruleSettingDNSResolversJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsDNSResolversJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRulesRuleSettingsDNSResolvers] -type zeroTrustGatewayRulesRuleSettingsDNSResolversJSON struct { +// ruleSettingDNSResolversJSON contains the JSON metadata for the struct +// [RuleSettingDNSResolvers] +type ruleSettingDNSResolversJSON struct { IPV4 apijson.Field IPV6 apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsDNSResolvers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRulesRuleSettingsDNSResolversJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON `json:"-"` -} - -// zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4] -type zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON `json:"-"` -} - -// zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6] -type zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingDNSResolvers) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON) RawJSON() string { +func (r ruleSettingDNSResolversJSON) RawJSON() string { return r.raw } // Configure how Gateway Proxy traffic egresses. You can enable this setting for // rules with Egress actions and filters, or omit it to indicate local egress via // WARP IPs. -type ZeroTrustGatewayRulesRuleSettingsEgress struct { +type RuleSettingEgress struct { // The IPv4 address to be used for egress. IPV4 string `json:"ipv4"` // The fallback IPv4 address to be used for egress in the event of an error @@ -502,13 +538,13 @@ type ZeroTrustGatewayRulesRuleSettingsEgress struct { // WARP IPs. IPV4Fallback string `json:"ipv4_fallback"` // The IPv6 range to be used for egress. - IPV6 string `json:"ipv6"` - JSON zeroTrustGatewayRulesRuleSettingsEgressJSON `json:"-"` + IPV6 string `json:"ipv6"` + JSON ruleSettingEgressJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsEgressJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRulesRuleSettingsEgress] -type zeroTrustGatewayRulesRuleSettingsEgressJSON struct { +// ruleSettingEgressJSON contains the JSON metadata for the struct +// [RuleSettingEgress] +type ruleSettingEgressJSON struct { IPV4 apijson.Field IPV4Fallback apijson.Field IPV6 apijson.Field @@ -516,56 +552,56 @@ type zeroTrustGatewayRulesRuleSettingsEgressJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsEgress) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingEgress) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsEgressJSON) RawJSON() string { +func (r ruleSettingEgressJSON) RawJSON() string { return r.raw } // Send matching traffic to the supplied destination IP address and port. -type ZeroTrustGatewayRulesRuleSettingsL4override struct { +type RuleSettingL4override struct { // IPv4 or IPv6 address. IP string `json:"ip"` // A port number to use for TCP/UDP overrides. - Port int64 `json:"port"` - JSON zeroTrustGatewayRulesRuleSettingsL4overrideJSON `json:"-"` + Port int64 `json:"port"` + JSON ruleSettingL4overrideJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsL4overrideJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRulesRuleSettingsL4override] -type zeroTrustGatewayRulesRuleSettingsL4overrideJSON struct { +// ruleSettingL4overrideJSON contains the JSON metadata for the struct +// [RuleSettingL4override] +type ruleSettingL4overrideJSON struct { IP apijson.Field Port apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsL4override) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingL4override) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsL4overrideJSON) RawJSON() string { +func (r ruleSettingL4overrideJSON) RawJSON() string { return r.raw } // Configure a notification to display on the user's device when this rule is // matched. -type ZeroTrustGatewayRulesRuleSettingsNotificationSettings struct { +type RuleSettingNotificationSettings struct { // Set notification on Enabled bool `json:"enabled"` // Customize the message shown in the notification. Msg string `json:"msg"` // Optional URL to direct users to additional information. If not set, the // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON `json:"-"` + SupportURL string `json:"support_url"` + JSON ruleSettingNotificationSettingsJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRulesRuleSettingsNotificationSettings] -type zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON struct { +// ruleSettingNotificationSettingsJSON contains the JSON metadata for the struct +// [RuleSettingNotificationSettings] +type ruleSettingNotificationSettingsJSON struct { Enabled apijson.Field Msg apijson.Field SupportURL apijson.Field @@ -573,391 +609,196 @@ type zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsNotificationSettings) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingNotificationSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON) RawJSON() string { +func (r ruleSettingNotificationSettingsJSON) RawJSON() string { return r.raw } // Configure DLP payload logging. -type ZeroTrustGatewayRulesRuleSettingsPayloadLog struct { +type RuleSettingPayloadLog struct { // Set to true to enable DLP payload logging for this rule. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayRulesRuleSettingsPayloadLogJSON `json:"-"` + Enabled bool `json:"enabled"` + JSON ruleSettingPayloadLogJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsPayloadLogJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRulesRuleSettingsPayloadLog] -type zeroTrustGatewayRulesRuleSettingsPayloadLogJSON struct { +// ruleSettingPayloadLogJSON contains the JSON metadata for the struct +// [RuleSettingPayloadLog] +type ruleSettingPayloadLogJSON struct { Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsPayloadLog) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingPayloadLog) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsPayloadLogJSON) RawJSON() string { +func (r ruleSettingPayloadLogJSON) RawJSON() string { return r.raw } // Configure behavior when an upstream cert is invalid or an SSL error occurs. -type ZeroTrustGatewayRulesRuleSettingsUntrustedCERT struct { +type RuleSettingUntrustedCERT struct { // The action performed when an untrusted certificate is seen. The default action // is an error with HTTP code 526. - Action ZeroTrustGatewayRulesRuleSettingsUntrustedCERTAction `json:"action"` - JSON zeroTrustGatewayRulesRuleSettingsUntrustedCERTJSON `json:"-"` + Action RuleSettingUntrustedCERTAction `json:"action"` + JSON ruleSettingUntrustedCERTJSON `json:"-"` } -// zeroTrustGatewayRulesRuleSettingsUntrustedCERTJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRulesRuleSettingsUntrustedCERT] -type zeroTrustGatewayRulesRuleSettingsUntrustedCERTJSON struct { +// ruleSettingUntrustedCERTJSON contains the JSON metadata for the struct +// [RuleSettingUntrustedCERT] +type ruleSettingUntrustedCERTJSON struct { Action apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustGatewayRulesRuleSettingsUntrustedCERT) UnmarshalJSON(data []byte) (err error) { +func (r *RuleSettingUntrustedCERT) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustGatewayRulesRuleSettingsUntrustedCERTJSON) RawJSON() string { +func (r ruleSettingUntrustedCERTJSON) RawJSON() string { return r.raw } // The action performed when an untrusted certificate is seen. The default action // is an error with HTTP code 526. -type ZeroTrustGatewayRulesRuleSettingsUntrustedCERTAction string +type RuleSettingUntrustedCERTAction string const ( - ZeroTrustGatewayRulesRuleSettingsUntrustedCERTActionPassThrough ZeroTrustGatewayRulesRuleSettingsUntrustedCERTAction = "pass_through" - ZeroTrustGatewayRulesRuleSettingsUntrustedCERTActionBlock ZeroTrustGatewayRulesRuleSettingsUntrustedCERTAction = "block" - ZeroTrustGatewayRulesRuleSettingsUntrustedCERTActionError ZeroTrustGatewayRulesRuleSettingsUntrustedCERTAction = "error" + RuleSettingUntrustedCERTActionPassThrough RuleSettingUntrustedCERTAction = "pass_through" + RuleSettingUntrustedCERTActionBlock RuleSettingUntrustedCERTAction = "block" + RuleSettingUntrustedCERTActionError RuleSettingUntrustedCERTAction = "error" ) -func (r ZeroTrustGatewayRulesRuleSettingsUntrustedCERTAction) IsKnown() bool { +func (r RuleSettingUntrustedCERTAction) IsKnown() bool { switch r { - case ZeroTrustGatewayRulesRuleSettingsUntrustedCERTActionPassThrough, ZeroTrustGatewayRulesRuleSettingsUntrustedCERTActionBlock, ZeroTrustGatewayRulesRuleSettingsUntrustedCERTActionError: + case RuleSettingUntrustedCERTActionPassThrough, RuleSettingUntrustedCERTActionBlock, RuleSettingUntrustedCERTActionError: return true } return false } -// The schedule for activating DNS policies. This does not apply to HTTP or network -// policies. -type ZeroTrustGatewayRulesSchedule struct { - // The time intervals when the rule will be active on Fridays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Fridays. - Fri string `json:"fri"` - // The time intervals when the rule will be active on Mondays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Mondays. - Mon string `json:"mon"` - // The time intervals when the rule will be active on Saturdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Saturdays. - Sat string `json:"sat"` - // The time intervals when the rule will be active on Sundays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Sundays. - Sun string `json:"sun"` - // The time intervals when the rule will be active on Thursdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Thursdays. - Thu string `json:"thu"` - // The time zone the rule will be evaluated against. If a - // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - // is provided, Gateway will always use the current time at that time zone. If this - // parameter is omitted, then Gateway will use the time zone inferred from the - // user's source IP to evaluate the rule. If Gateway cannot determine the time zone - // from the IP, we will fall back to the time zone of the user's connected data - // center. - TimeZone string `json:"time_zone"` - // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue string `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed string `json:"wed"` - JSON zeroTrustGatewayRulesScheduleJSON `json:"-"` +// Additional settings that modify the rule's action. +type RuleSettingParam struct { + // Add custom headers to allowed requests, in the form of key-value pairs. Keys are + // header names, pointing to an array with its header value(s). + AddHeaders param.Field[interface{}] `json:"add_headers"` + // Set by parent MSP accounts to enable their children to bypass this rule. + AllowChildBypass param.Field[bool] `json:"allow_child_bypass"` + // Settings for the Audit SSH action. + AuditSSH param.Field[RuleSettingAuditSSHParam] `json:"audit_ssh"` + // Configure how browser isolation behaves. + BisoAdminControls param.Field[RuleSettingBisoAdminControlsParam] `json:"biso_admin_controls"` + // Enable the custom block page. + BlockPageEnabled param.Field[bool] `json:"block_page_enabled"` + // The text describing why this block occurred, displayed on the custom block page + // (if enabled). + BlockReason param.Field[string] `json:"block_reason"` + // Set by children MSP accounts to bypass their parent's rules. + BypassParentRule param.Field[bool] `json:"bypass_parent_rule"` + // Configure how session check behaves. + CheckSession param.Field[RuleSettingCheckSessionParam] `json:"check_session"` + // Add your own custom resolvers to route queries that match the resolver policy. + // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will + // route to the address closest to their origin. Only valid when a rule's action is + // set to 'resolve'. + DNSResolvers param.Field[RuleSettingDNSResolversParam] `json:"dns_resolvers"` + // Configure how Gateway Proxy traffic egresses. You can enable this setting for + // rules with Egress actions and filters, or omit it to indicate local egress via + // WARP IPs. + Egress param.Field[RuleSettingEgressParam] `json:"egress"` + // INSECURE - disable DNSSEC validation (for Allow actions). + InsecureDisableDNSSECValidation param.Field[bool] `json:"insecure_disable_dnssec_validation"` + // Set to true to enable IPs in DNS resolver category blocks. By default categories + // only block based on domain names. + IPCategories param.Field[bool] `json:"ip_categories"` + // Set to true to include IPs in DNS resolver indicator feed blocks. By default + // indicator feeds only block based on domain names. + IPIndicatorFeeds param.Field[bool] `json:"ip_indicator_feeds"` + // Send matching traffic to the supplied destination IP address and port. + L4override param.Field[RuleSettingL4overrideParam] `json:"l4override"` + // Configure a notification to display on the user's device when this rule is + // matched. + NotificationSettings param.Field[RuleSettingNotificationSettingsParam] `json:"notification_settings"` + // Override matching DNS queries with a hostname. + OverrideHost param.Field[string] `json:"override_host"` + // Override matching DNS queries with an IP or set of IPs. + OverrideIPs param.Field[[]string] `json:"override_ips"` + // Configure DLP payload logging. + PayloadLog param.Field[RuleSettingPayloadLogParam] `json:"payload_log"` + // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS + // resolver. Cannot be set when dns_resolvers are specified. Only valid when a + // rule's action is set to 'resolve'. + ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"` + // Configure behavior when an upstream cert is invalid or an SSL error occurs. + UntrustedCERT param.Field[RuleSettingUntrustedCERTParam] `json:"untrusted_cert"` } -// zeroTrustGatewayRulesScheduleJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayRulesSchedule] -type zeroTrustGatewayRulesScheduleJSON struct { - Fri apijson.Field - Mon apijson.Field - Sat apijson.Field - Sun apijson.Field - Thu apijson.Field - TimeZone apijson.Field - Tue apijson.Field - Wed apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r RuleSettingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *ZeroTrustGatewayRulesSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Settings for the Audit SSH action. +type RuleSettingAuditSSHParam struct { + // Enable to turn on SSH command logging. + CommandLogging param.Field[bool] `json:"command_logging"` } -func (r zeroTrustGatewayRulesScheduleJSON) RawJSON() string { - return r.raw +func (r RuleSettingAuditSSHParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// Union satisfied by [zero_trust.GatewayRuleDeleteResponseUnknown] or -// [shared.UnionString]. -type GatewayRuleDeleteResponse interface { - ImplementsZeroTrustGatewayRuleDeleteResponse() +// Configure how browser isolation behaves. +type RuleSettingBisoAdminControlsParam struct { + // Set to true to enable copy-pasting. + Dcp param.Field[bool] `json:"dcp"` + // Set to true to enable downloading. + Dd param.Field[bool] `json:"dd"` + // Set to true to enable keyboard usage. + Dk param.Field[bool] `json:"dk"` + // Set to true to enable printing. + Dp param.Field[bool] `json:"dp"` + // Set to true to enable uploading. + Du param.Field[bool] `json:"du"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*GatewayRuleDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type GatewayRuleNewParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action param.Field[GatewayRuleNewParamsAction] `json:"action,required"` - // The name of the rule. - Name param.Field[string] `json:"name,required"` - // The description of the rule. - Description param.Field[string] `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture param.Field[string] `json:"device_posture"` - // True if the rule is enabled. - Enabled param.Field[bool] `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters param.Field[[]GatewayRuleNewParamsFilter] `json:"filters"` - // The wirefilter expression used for identity matching. - Identity param.Field[string] `json:"identity"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence param.Field[int64] `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings param.Field[GatewayRuleNewParamsRuleSettings] `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule param.Field[GatewayRuleNewParamsSchedule] `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic param.Field[string] `json:"traffic"` -} - -func (r GatewayRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type GatewayRuleNewParamsAction string - -const ( - GatewayRuleNewParamsActionOn GatewayRuleNewParamsAction = "on" - GatewayRuleNewParamsActionOff GatewayRuleNewParamsAction = "off" - GatewayRuleNewParamsActionAllow GatewayRuleNewParamsAction = "allow" - GatewayRuleNewParamsActionBlock GatewayRuleNewParamsAction = "block" - GatewayRuleNewParamsActionScan GatewayRuleNewParamsAction = "scan" - GatewayRuleNewParamsActionNoscan GatewayRuleNewParamsAction = "noscan" - GatewayRuleNewParamsActionSafesearch GatewayRuleNewParamsAction = "safesearch" - GatewayRuleNewParamsActionYtrestricted GatewayRuleNewParamsAction = "ytrestricted" - GatewayRuleNewParamsActionIsolate GatewayRuleNewParamsAction = "isolate" - GatewayRuleNewParamsActionNoisolate GatewayRuleNewParamsAction = "noisolate" - GatewayRuleNewParamsActionOverride GatewayRuleNewParamsAction = "override" - GatewayRuleNewParamsActionL4Override GatewayRuleNewParamsAction = "l4_override" - GatewayRuleNewParamsActionEgress GatewayRuleNewParamsAction = "egress" - GatewayRuleNewParamsActionAuditSSH GatewayRuleNewParamsAction = "audit_ssh" -) - -func (r GatewayRuleNewParamsAction) IsKnown() bool { - switch r { - case GatewayRuleNewParamsActionOn, GatewayRuleNewParamsActionOff, GatewayRuleNewParamsActionAllow, GatewayRuleNewParamsActionBlock, GatewayRuleNewParamsActionScan, GatewayRuleNewParamsActionNoscan, GatewayRuleNewParamsActionSafesearch, GatewayRuleNewParamsActionYtrestricted, GatewayRuleNewParamsActionIsolate, GatewayRuleNewParamsActionNoisolate, GatewayRuleNewParamsActionOverride, GatewayRuleNewParamsActionL4Override, GatewayRuleNewParamsActionEgress, GatewayRuleNewParamsActionAuditSSH: - return true - } - return false -} - -// The protocol or layer to use. -type GatewayRuleNewParamsFilter string - -const ( - GatewayRuleNewParamsFilterHTTP GatewayRuleNewParamsFilter = "http" - GatewayRuleNewParamsFilterDNS GatewayRuleNewParamsFilter = "dns" - GatewayRuleNewParamsFilterL4 GatewayRuleNewParamsFilter = "l4" - GatewayRuleNewParamsFilterEgress GatewayRuleNewParamsFilter = "egress" -) - -func (r GatewayRuleNewParamsFilter) IsKnown() bool { - switch r { - case GatewayRuleNewParamsFilterHTTP, GatewayRuleNewParamsFilterDNS, GatewayRuleNewParamsFilterL4, GatewayRuleNewParamsFilterEgress: - return true - } - return false -} - -// Additional settings that modify the rule's action. -type GatewayRuleNewParamsRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders param.Field[interface{}] `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass param.Field[bool] `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH param.Field[GatewayRuleNewParamsRuleSettingsAuditSSH] `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls param.Field[GatewayRuleNewParamsRuleSettingsBisoAdminControls] `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled param.Field[bool] `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason param.Field[string] `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule param.Field[bool] `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession param.Field[GatewayRuleNewParamsRuleSettingsCheckSession] `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers param.Field[GatewayRuleNewParamsRuleSettingsDNSResolvers] `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress param.Field[GatewayRuleNewParamsRuleSettingsEgress] `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation param.Field[bool] `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories param.Field[bool] `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds param.Field[bool] `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override param.Field[GatewayRuleNewParamsRuleSettingsL4override] `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings param.Field[GatewayRuleNewParamsRuleSettingsNotificationSettings] `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost param.Field[string] `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs param.Field[[]string] `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog param.Field[GatewayRuleNewParamsRuleSettingsPayloadLog] `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCERT param.Field[GatewayRuleNewParamsRuleSettingsUntrustedCERT] `json:"untrusted_cert"` -} - -func (r GatewayRuleNewParamsRuleSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Settings for the Audit SSH action. -type GatewayRuleNewParamsRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging param.Field[bool] `json:"command_logging"` -} - -func (r GatewayRuleNewParamsRuleSettingsAuditSSH) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how browser isolation behaves. -type GatewayRuleNewParamsRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp param.Field[bool] `json:"dcp"` - // Set to true to enable downloading. - Dd param.Field[bool] `json:"dd"` - // Set to true to enable keyboard usage. - Dk param.Field[bool] `json:"dk"` - // Set to true to enable printing. - Dp param.Field[bool] `json:"dp"` - // Set to true to enable uploading. - Du param.Field[bool] `json:"du"` -} - -func (r GatewayRuleNewParamsRuleSettingsBisoAdminControls) MarshalJSON() (data []byte, err error) { +func (r RuleSettingBisoAdminControlsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configure how session check behaves. -type GatewayRuleNewParamsRuleSettingsCheckSession struct { +type RuleSettingCheckSessionParam struct { // Configure how fresh the session needs to be to be considered valid. Duration param.Field[string] `json:"duration"` // Set to true to enable session enforcement. Enforce param.Field[bool] `json:"enforce"` } -func (r GatewayRuleNewParamsRuleSettingsCheckSession) MarshalJSON() (data []byte, err error) { +func (r RuleSettingCheckSessionParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Add your own custom resolvers to route queries that match the resolver policy. // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type GatewayRuleNewParamsRuleSettingsDNSResolvers struct { - IPV4 param.Field[[]GatewayRuleNewParamsRuleSettingsDNSResolversIPV4] `json:"ipv4"` - IPV6 param.Field[[]GatewayRuleNewParamsRuleSettingsDNSResolversIPV6] `json:"ipv6"` -} - -func (r GatewayRuleNewParamsRuleSettingsDNSResolvers) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type GatewayRuleNewParamsRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r GatewayRuleNewParamsRuleSettingsDNSResolversIPV4) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// route to the address closest to their origin. Only valid when a rule's action is +// set to 'resolve'. +type RuleSettingDNSResolversParam struct { + IPV4 param.Field[[]DNSResolverSettingsV4Param] `json:"ipv4"` + IPV6 param.Field[[]DNSResolverSettingsV6Param] `json:"ipv6"` } -type GatewayRuleNewParamsRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r GatewayRuleNewParamsRuleSettingsDNSResolversIPV6) MarshalJSON() (data []byte, err error) { +func (r RuleSettingDNSResolversParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configure how Gateway Proxy traffic egresses. You can enable this setting for // rules with Egress actions and filters, or omit it to indicate local egress via // WARP IPs. -type GatewayRuleNewParamsRuleSettingsEgress struct { +type RuleSettingEgressParam struct { // The IPv4 address to be used for egress. IPV4 param.Field[string] `json:"ipv4"` // The fallback IPv4 address to be used for egress in the event of an error @@ -968,25 +809,25 @@ type GatewayRuleNewParamsRuleSettingsEgress struct { IPV6 param.Field[string] `json:"ipv6"` } -func (r GatewayRuleNewParamsRuleSettingsEgress) MarshalJSON() (data []byte, err error) { +func (r RuleSettingEgressParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Send matching traffic to the supplied destination IP address and port. -type GatewayRuleNewParamsRuleSettingsL4override struct { +type RuleSettingL4overrideParam struct { // IPv4 or IPv6 address. IP param.Field[string] `json:"ip"` // A port number to use for TCP/UDP overrides. Port param.Field[int64] `json:"port"` } -func (r GatewayRuleNewParamsRuleSettingsL4override) MarshalJSON() (data []byte, err error) { +func (r RuleSettingL4overrideParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configure a notification to display on the user's device when this rule is // matched. -type GatewayRuleNewParamsRuleSettingsNotificationSettings struct { +type RuleSettingNotificationSettingsParam struct { // Set notification on Enabled param.Field[bool] `json:"enabled"` // Customize the message shown in the notification. @@ -996,72 +837,54 @@ type GatewayRuleNewParamsRuleSettingsNotificationSettings struct { SupportURL param.Field[string] `json:"support_url"` } -func (r GatewayRuleNewParamsRuleSettingsNotificationSettings) MarshalJSON() (data []byte, err error) { +func (r RuleSettingNotificationSettingsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configure DLP payload logging. -type GatewayRuleNewParamsRuleSettingsPayloadLog struct { +type RuleSettingPayloadLogParam struct { // Set to true to enable DLP payload logging for this rule. Enabled param.Field[bool] `json:"enabled"` } -func (r GatewayRuleNewParamsRuleSettingsPayloadLog) MarshalJSON() (data []byte, err error) { +func (r RuleSettingPayloadLogParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // Configure behavior when an upstream cert is invalid or an SSL error occurs. -type GatewayRuleNewParamsRuleSettingsUntrustedCERT struct { +type RuleSettingUntrustedCERTParam struct { // The action performed when an untrusted certificate is seen. The default action // is an error with HTTP code 526. - Action param.Field[GatewayRuleNewParamsRuleSettingsUntrustedCERTAction] `json:"action"` + Action param.Field[RuleSettingUntrustedCERTAction] `json:"action"` } -func (r GatewayRuleNewParamsRuleSettingsUntrustedCERT) MarshalJSON() (data []byte, err error) { +func (r RuleSettingUntrustedCERTParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type GatewayRuleNewParamsRuleSettingsUntrustedCERTAction string - -const ( - GatewayRuleNewParamsRuleSettingsUntrustedCERTActionPassThrough GatewayRuleNewParamsRuleSettingsUntrustedCERTAction = "pass_through" - GatewayRuleNewParamsRuleSettingsUntrustedCERTActionBlock GatewayRuleNewParamsRuleSettingsUntrustedCERTAction = "block" - GatewayRuleNewParamsRuleSettingsUntrustedCERTActionError GatewayRuleNewParamsRuleSettingsUntrustedCERTAction = "error" -) - -func (r GatewayRuleNewParamsRuleSettingsUntrustedCERTAction) IsKnown() bool { - switch r { - case GatewayRuleNewParamsRuleSettingsUntrustedCERTActionPassThrough, GatewayRuleNewParamsRuleSettingsUntrustedCERTActionBlock, GatewayRuleNewParamsRuleSettingsUntrustedCERTActionError: - return true - } - return false -} - // The schedule for activating DNS policies. This does not apply to HTTP or network // policies. -type GatewayRuleNewParamsSchedule struct { +type Schedule struct { // The time intervals when the rule will be active on Fridays, in increasing order // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on // Fridays. - Fri param.Field[string] `json:"fri"` + Fri string `json:"fri"` // The time intervals when the rule will be active on Mondays, in increasing order // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on // Mondays. - Mon param.Field[string] `json:"mon"` + Mon string `json:"mon"` // The time intervals when the rule will be active on Saturdays, in increasing // order from 00:00-24:00. If this parameter is omitted, the rule will be // deactivated on Saturdays. - Sat param.Field[string] `json:"sat"` + Sat string `json:"sat"` // The time intervals when the rule will be active on Sundays, in increasing order // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on // Sundays. - Sun param.Field[string] `json:"sun"` + Sun string `json:"sun"` // The time intervals when the rule will be active on Thursdays, in increasing // order from 00:00-24:00. If this parameter is omitted, the rule will be // deactivated on Thursdays. - Thu param.Field[string] `json:"thu"` + Thu string `json:"thu"` // The time zone the rule will be evaluated against. If a // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) // is provided, Gateway will always use the current time at that time zone. If this @@ -1069,424 +892,43 @@ type GatewayRuleNewParamsSchedule struct { // user's source IP to evaluate the rule. If Gateway cannot determine the time zone // from the IP, we will fall back to the time zone of the user's connected data // center. - TimeZone param.Field[string] `json:"time_zone"` + TimeZone string `json:"time_zone"` // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue param.Field[string] `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed param.Field[string] `json:"wed"` -} - -func (r GatewayRuleNewParamsSchedule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type GatewayRuleNewResponseEnvelope struct { - Errors []GatewayRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayRules `json:"result,required"` - // Whether the API call was successful - Success GatewayRuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON gatewayRuleNewResponseEnvelopeJSON `json:"-"` -} - -// gatewayRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [GatewayRuleNewResponseEnvelope] -type gatewayRuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type GatewayRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayRuleNewResponseEnvelopeErrors] -type gatewayRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayRuleNewResponseEnvelopeMessages] -type gatewayRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type GatewayRuleNewResponseEnvelopeSuccess bool - -const ( - GatewayRuleNewResponseEnvelopeSuccessTrue GatewayRuleNewResponseEnvelopeSuccess = true -) - -func (r GatewayRuleNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case GatewayRuleNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type GatewayRuleUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action param.Field[GatewayRuleUpdateParamsAction] `json:"action,required"` - // The name of the rule. - Name param.Field[string] `json:"name,required"` - // The description of the rule. - Description param.Field[string] `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture param.Field[string] `json:"device_posture"` - // True if the rule is enabled. - Enabled param.Field[bool] `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters param.Field[[]GatewayRuleUpdateParamsFilter] `json:"filters"` - // The wirefilter expression used for identity matching. - Identity param.Field[string] `json:"identity"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence param.Field[int64] `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings param.Field[GatewayRuleUpdateParamsRuleSettings] `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule param.Field[GatewayRuleUpdateParamsSchedule] `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic param.Field[string] `json:"traffic"` -} - -func (r GatewayRuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type GatewayRuleUpdateParamsAction string - -const ( - GatewayRuleUpdateParamsActionOn GatewayRuleUpdateParamsAction = "on" - GatewayRuleUpdateParamsActionOff GatewayRuleUpdateParamsAction = "off" - GatewayRuleUpdateParamsActionAllow GatewayRuleUpdateParamsAction = "allow" - GatewayRuleUpdateParamsActionBlock GatewayRuleUpdateParamsAction = "block" - GatewayRuleUpdateParamsActionScan GatewayRuleUpdateParamsAction = "scan" - GatewayRuleUpdateParamsActionNoscan GatewayRuleUpdateParamsAction = "noscan" - GatewayRuleUpdateParamsActionSafesearch GatewayRuleUpdateParamsAction = "safesearch" - GatewayRuleUpdateParamsActionYtrestricted GatewayRuleUpdateParamsAction = "ytrestricted" - GatewayRuleUpdateParamsActionIsolate GatewayRuleUpdateParamsAction = "isolate" - GatewayRuleUpdateParamsActionNoisolate GatewayRuleUpdateParamsAction = "noisolate" - GatewayRuleUpdateParamsActionOverride GatewayRuleUpdateParamsAction = "override" - GatewayRuleUpdateParamsActionL4Override GatewayRuleUpdateParamsAction = "l4_override" - GatewayRuleUpdateParamsActionEgress GatewayRuleUpdateParamsAction = "egress" - GatewayRuleUpdateParamsActionAuditSSH GatewayRuleUpdateParamsAction = "audit_ssh" -) - -func (r GatewayRuleUpdateParamsAction) IsKnown() bool { - switch r { - case GatewayRuleUpdateParamsActionOn, GatewayRuleUpdateParamsActionOff, GatewayRuleUpdateParamsActionAllow, GatewayRuleUpdateParamsActionBlock, GatewayRuleUpdateParamsActionScan, GatewayRuleUpdateParamsActionNoscan, GatewayRuleUpdateParamsActionSafesearch, GatewayRuleUpdateParamsActionYtrestricted, GatewayRuleUpdateParamsActionIsolate, GatewayRuleUpdateParamsActionNoisolate, GatewayRuleUpdateParamsActionOverride, GatewayRuleUpdateParamsActionL4Override, GatewayRuleUpdateParamsActionEgress, GatewayRuleUpdateParamsActionAuditSSH: - return true - } - return false -} - -// The protocol or layer to use. -type GatewayRuleUpdateParamsFilter string - -const ( - GatewayRuleUpdateParamsFilterHTTP GatewayRuleUpdateParamsFilter = "http" - GatewayRuleUpdateParamsFilterDNS GatewayRuleUpdateParamsFilter = "dns" - GatewayRuleUpdateParamsFilterL4 GatewayRuleUpdateParamsFilter = "l4" - GatewayRuleUpdateParamsFilterEgress GatewayRuleUpdateParamsFilter = "egress" -) - -func (r GatewayRuleUpdateParamsFilter) IsKnown() bool { - switch r { - case GatewayRuleUpdateParamsFilterHTTP, GatewayRuleUpdateParamsFilterDNS, GatewayRuleUpdateParamsFilterL4, GatewayRuleUpdateParamsFilterEgress: - return true - } - return false -} - -// Additional settings that modify the rule's action. -type GatewayRuleUpdateParamsRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders param.Field[interface{}] `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass param.Field[bool] `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH param.Field[GatewayRuleUpdateParamsRuleSettingsAuditSSH] `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls param.Field[GatewayRuleUpdateParamsRuleSettingsBisoAdminControls] `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled param.Field[bool] `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason param.Field[string] `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule param.Field[bool] `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession param.Field[GatewayRuleUpdateParamsRuleSettingsCheckSession] `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers param.Field[GatewayRuleUpdateParamsRuleSettingsDNSResolvers] `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress param.Field[GatewayRuleUpdateParamsRuleSettingsEgress] `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation param.Field[bool] `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories param.Field[bool] `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds param.Field[bool] `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override param.Field[GatewayRuleUpdateParamsRuleSettingsL4override] `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings param.Field[GatewayRuleUpdateParamsRuleSettingsNotificationSettings] `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost param.Field[string] `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs param.Field[[]string] `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog param.Field[GatewayRuleUpdateParamsRuleSettingsPayloadLog] `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCERT param.Field[GatewayRuleUpdateParamsRuleSettingsUntrustedCERT] `json:"untrusted_cert"` -} - -func (r GatewayRuleUpdateParamsRuleSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Settings for the Audit SSH action. -type GatewayRuleUpdateParamsRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging param.Field[bool] `json:"command_logging"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsAuditSSH) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how browser isolation behaves. -type GatewayRuleUpdateParamsRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp param.Field[bool] `json:"dcp"` - // Set to true to enable downloading. - Dd param.Field[bool] `json:"dd"` - // Set to true to enable keyboard usage. - Dk param.Field[bool] `json:"dk"` - // Set to true to enable printing. - Dp param.Field[bool] `json:"dp"` - // Set to true to enable uploading. - Du param.Field[bool] `json:"du"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsBisoAdminControls) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how session check behaves. -type GatewayRuleUpdateParamsRuleSettingsCheckSession struct { - // Configure how fresh the session needs to be to be considered valid. - Duration param.Field[string] `json:"duration"` - // Set to true to enable session enforcement. - Enforce param.Field[bool] `json:"enforce"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsCheckSession) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Add your own custom resolvers to route queries that match the resolver policy. -// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type GatewayRuleUpdateParamsRuleSettingsDNSResolvers struct { - IPV4 param.Field[[]GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4] `json:"ipv4"` - IPV6 param.Field[[]GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6] `json:"ipv6"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsDNSResolvers) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how Gateway Proxy traffic egresses. You can enable this setting for -// rules with Egress actions and filters, or omit it to indicate local egress via -// WARP IPs. -type GatewayRuleUpdateParamsRuleSettingsEgress struct { - // The IPv4 address to be used for egress. - IPV4 param.Field[string] `json:"ipv4"` - // The fallback IPv4 address to be used for egress in the event of an error - // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via - // WARP IPs. - IPV4Fallback param.Field[string] `json:"ipv4_fallback"` - // The IPv6 range to be used for egress. - IPV6 param.Field[string] `json:"ipv6"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsEgress) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Send matching traffic to the supplied destination IP address and port. -type GatewayRuleUpdateParamsRuleSettingsL4override struct { - // IPv4 or IPv6 address. - IP param.Field[string] `json:"ip"` - // A port number to use for TCP/UDP overrides. - Port param.Field[int64] `json:"port"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsL4override) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure a notification to display on the user's device when this rule is -// matched. -type GatewayRuleUpdateParamsRuleSettingsNotificationSettings struct { - // Set notification on - Enabled param.Field[bool] `json:"enabled"` - // Customize the message shown in the notification. - Msg param.Field[string] `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL param.Field[string] `json:"support_url"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsNotificationSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure DLP payload logging. -type GatewayRuleUpdateParamsRuleSettingsPayloadLog struct { - // Set to true to enable DLP payload logging for this rule. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r GatewayRuleUpdateParamsRuleSettingsPayloadLog) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Tuesdays. + Tue string `json:"tue"` + // The time intervals when the rule will be active on Wednesdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Wednesdays. + Wed string `json:"wed"` + JSON scheduleJSON `json:"-"` } -// Configure behavior when an upstream cert is invalid or an SSL error occurs. -type GatewayRuleUpdateParamsRuleSettingsUntrustedCERT struct { - // The action performed when an untrusted certificate is seen. The default action - // is an error with HTTP code 526. - Action param.Field[GatewayRuleUpdateParamsRuleSettingsUntrustedCERTAction] `json:"action"` +// scheduleJSON contains the JSON metadata for the struct [Schedule] +type scheduleJSON struct { + Fri apijson.Field + Mon apijson.Field + Sat apijson.Field + Sun apijson.Field + Thu apijson.Field + TimeZone apijson.Field + Tue apijson.Field + Wed apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r GatewayRuleUpdateParamsRuleSettingsUntrustedCERT) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *Schedule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type GatewayRuleUpdateParamsRuleSettingsUntrustedCERTAction string - -const ( - GatewayRuleUpdateParamsRuleSettingsUntrustedCERTActionPassThrough GatewayRuleUpdateParamsRuleSettingsUntrustedCERTAction = "pass_through" - GatewayRuleUpdateParamsRuleSettingsUntrustedCERTActionBlock GatewayRuleUpdateParamsRuleSettingsUntrustedCERTAction = "block" - GatewayRuleUpdateParamsRuleSettingsUntrustedCERTActionError GatewayRuleUpdateParamsRuleSettingsUntrustedCERTAction = "error" -) - -func (r GatewayRuleUpdateParamsRuleSettingsUntrustedCERTAction) IsKnown() bool { - switch r { - case GatewayRuleUpdateParamsRuleSettingsUntrustedCERTActionPassThrough, GatewayRuleUpdateParamsRuleSettingsUntrustedCERTActionBlock, GatewayRuleUpdateParamsRuleSettingsUntrustedCERTActionError: - return true - } - return false +func (r scheduleJSON) RawJSON() string { + return r.raw } // The schedule for activating DNS policies. This does not apply to HTTP or network // policies. -type GatewayRuleUpdateParamsSchedule struct { +type ScheduleParam struct { // The time intervals when the rule will be active on Fridays, in increasing order // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on // Fridays. @@ -1525,22 +967,104 @@ type GatewayRuleUpdateParamsSchedule struct { Wed param.Field[string] `json:"wed"` } -func (r GatewayRuleUpdateParamsSchedule) MarshalJSON() (data []byte, err error) { +func (r ScheduleParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type GatewayRuleUpdateResponseEnvelope struct { - Errors []GatewayRuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayRuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayRules `json:"result,required"` +// Union satisfied by [zero_trust.GatewayRuleDeleteResponseUnknown] or +// [shared.UnionString]. +type GatewayRuleDeleteResponseUnion interface { + ImplementsZeroTrustGatewayRuleDeleteResponseUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*GatewayRuleDeleteResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type GatewayRuleNewParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // The action to preform when the associated traffic, identity, and device posture + // expressions are either absent or evaluate to `true`. + Action param.Field[GatewayRuleNewParamsAction] `json:"action,required"` + // The name of the rule. + Name param.Field[string] `json:"name,required"` + // The description of the rule. + Description param.Field[string] `json:"description"` + // The wirefilter expression used for device posture check matching. + DevicePosture param.Field[string] `json:"device_posture"` + // True if the rule is enabled. + Enabled param.Field[bool] `json:"enabled"` + // The protocol or layer to evaluate the traffic, identity, and device posture + // expressions. + Filters param.Field[[]GatewayFilter] `json:"filters"` + // The wirefilter expression used for identity matching. + Identity param.Field[string] `json:"identity"` + // Precedence sets the order of your rules. Lower values indicate higher + // precedence. At each processing phase, applicable rules are evaluated in + // ascending order of this value. + Precedence param.Field[int64] `json:"precedence"` + // Additional settings that modify the rule's action. + RuleSettings param.Field[RuleSettingParam] `json:"rule_settings"` + // The schedule for activating DNS policies. This does not apply to HTTP or network + // policies. + Schedule param.Field[ScheduleParam] `json:"schedule"` + // The wirefilter expression used for traffic matching. + Traffic param.Field[string] `json:"traffic"` +} + +func (r GatewayRuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to preform when the associated traffic, identity, and device posture +// expressions are either absent or evaluate to `true`. +type GatewayRuleNewParamsAction string + +const ( + GatewayRuleNewParamsActionOn GatewayRuleNewParamsAction = "on" + GatewayRuleNewParamsActionOff GatewayRuleNewParamsAction = "off" + GatewayRuleNewParamsActionAllow GatewayRuleNewParamsAction = "allow" + GatewayRuleNewParamsActionBlock GatewayRuleNewParamsAction = "block" + GatewayRuleNewParamsActionScan GatewayRuleNewParamsAction = "scan" + GatewayRuleNewParamsActionNoscan GatewayRuleNewParamsAction = "noscan" + GatewayRuleNewParamsActionSafesearch GatewayRuleNewParamsAction = "safesearch" + GatewayRuleNewParamsActionYtrestricted GatewayRuleNewParamsAction = "ytrestricted" + GatewayRuleNewParamsActionIsolate GatewayRuleNewParamsAction = "isolate" + GatewayRuleNewParamsActionNoisolate GatewayRuleNewParamsAction = "noisolate" + GatewayRuleNewParamsActionOverride GatewayRuleNewParamsAction = "override" + GatewayRuleNewParamsActionL4Override GatewayRuleNewParamsAction = "l4_override" + GatewayRuleNewParamsActionEgress GatewayRuleNewParamsAction = "egress" + GatewayRuleNewParamsActionAuditSSH GatewayRuleNewParamsAction = "audit_ssh" + GatewayRuleNewParamsActionResolve GatewayRuleNewParamsAction = "resolve" +) + +func (r GatewayRuleNewParamsAction) IsKnown() bool { + switch r { + case GatewayRuleNewParamsActionOn, GatewayRuleNewParamsActionOff, GatewayRuleNewParamsActionAllow, GatewayRuleNewParamsActionBlock, GatewayRuleNewParamsActionScan, GatewayRuleNewParamsActionNoscan, GatewayRuleNewParamsActionSafesearch, GatewayRuleNewParamsActionYtrestricted, GatewayRuleNewParamsActionIsolate, GatewayRuleNewParamsActionNoisolate, GatewayRuleNewParamsActionOverride, GatewayRuleNewParamsActionL4Override, GatewayRuleNewParamsActionEgress, GatewayRuleNewParamsActionAuditSSH, GatewayRuleNewParamsActionResolve: + return true + } + return false +} + +type GatewayRuleNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayRule `json:"result,required"` // Whether the API call was successful - Success GatewayRuleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON gatewayRuleUpdateResponseEnvelopeJSON `json:"-"` + Success GatewayRuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayRuleNewResponseEnvelopeJSON `json:"-"` } -// gatewayRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [GatewayRuleUpdateResponseEnvelope] -type gatewayRuleUpdateResponseEnvelopeJSON struct { +// gatewayRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayRuleNewResponseEnvelope] +type gatewayRuleNewResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field Result apijson.Field @@ -1549,57 +1073,119 @@ type gatewayRuleUpdateResponseEnvelopeJSON struct { ExtraFields map[string]apijson.Field } -func (r *GatewayRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { +func (r *GatewayRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayRuleUpdateResponseEnvelopeJSON) RawJSON() string { +func (r gatewayRuleNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayRuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` +// Whether the API call was successful +type GatewayRuleNewResponseEnvelopeSuccess bool + +const ( + GatewayRuleNewResponseEnvelopeSuccessTrue GatewayRuleNewResponseEnvelopeSuccess = true +) + +func (r GatewayRuleNewResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case GatewayRuleNewResponseEnvelopeSuccessTrue: + return true + } + return false } -// gatewayRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayRuleUpdateResponseEnvelopeErrors] -type gatewayRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +type GatewayRuleUpdateParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // The action to preform when the associated traffic, identity, and device posture + // expressions are either absent or evaluate to `true`. + Action param.Field[GatewayRuleUpdateParamsAction] `json:"action,required"` + // The name of the rule. + Name param.Field[string] `json:"name,required"` + // The description of the rule. + Description param.Field[string] `json:"description"` + // The wirefilter expression used for device posture check matching. + DevicePosture param.Field[string] `json:"device_posture"` + // True if the rule is enabled. + Enabled param.Field[bool] `json:"enabled"` + // The protocol or layer to evaluate the traffic, identity, and device posture + // expressions. + Filters param.Field[[]GatewayFilter] `json:"filters"` + // The wirefilter expression used for identity matching. + Identity param.Field[string] `json:"identity"` + // Precedence sets the order of your rules. Lower values indicate higher + // precedence. At each processing phase, applicable rules are evaluated in + // ascending order of this value. + Precedence param.Field[int64] `json:"precedence"` + // Additional settings that modify the rule's action. + RuleSettings param.Field[RuleSettingParam] `json:"rule_settings"` + // The schedule for activating DNS policies. This does not apply to HTTP or network + // policies. + Schedule param.Field[ScheduleParam] `json:"schedule"` + // The wirefilter expression used for traffic matching. + Traffic param.Field[string] `json:"traffic"` } -func (r *GatewayRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r GatewayRuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r gatewayRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw +// The action to preform when the associated traffic, identity, and device posture +// expressions are either absent or evaluate to `true`. +type GatewayRuleUpdateParamsAction string + +const ( + GatewayRuleUpdateParamsActionOn GatewayRuleUpdateParamsAction = "on" + GatewayRuleUpdateParamsActionOff GatewayRuleUpdateParamsAction = "off" + GatewayRuleUpdateParamsActionAllow GatewayRuleUpdateParamsAction = "allow" + GatewayRuleUpdateParamsActionBlock GatewayRuleUpdateParamsAction = "block" + GatewayRuleUpdateParamsActionScan GatewayRuleUpdateParamsAction = "scan" + GatewayRuleUpdateParamsActionNoscan GatewayRuleUpdateParamsAction = "noscan" + GatewayRuleUpdateParamsActionSafesearch GatewayRuleUpdateParamsAction = "safesearch" + GatewayRuleUpdateParamsActionYtrestricted GatewayRuleUpdateParamsAction = "ytrestricted" + GatewayRuleUpdateParamsActionIsolate GatewayRuleUpdateParamsAction = "isolate" + GatewayRuleUpdateParamsActionNoisolate GatewayRuleUpdateParamsAction = "noisolate" + GatewayRuleUpdateParamsActionOverride GatewayRuleUpdateParamsAction = "override" + GatewayRuleUpdateParamsActionL4Override GatewayRuleUpdateParamsAction = "l4_override" + GatewayRuleUpdateParamsActionEgress GatewayRuleUpdateParamsAction = "egress" + GatewayRuleUpdateParamsActionAuditSSH GatewayRuleUpdateParamsAction = "audit_ssh" + GatewayRuleUpdateParamsActionResolve GatewayRuleUpdateParamsAction = "resolve" +) + +func (r GatewayRuleUpdateParamsAction) IsKnown() bool { + switch r { + case GatewayRuleUpdateParamsActionOn, GatewayRuleUpdateParamsActionOff, GatewayRuleUpdateParamsActionAllow, GatewayRuleUpdateParamsActionBlock, GatewayRuleUpdateParamsActionScan, GatewayRuleUpdateParamsActionNoscan, GatewayRuleUpdateParamsActionSafesearch, GatewayRuleUpdateParamsActionYtrestricted, GatewayRuleUpdateParamsActionIsolate, GatewayRuleUpdateParamsActionNoisolate, GatewayRuleUpdateParamsActionOverride, GatewayRuleUpdateParamsActionL4Override, GatewayRuleUpdateParamsActionEgress, GatewayRuleUpdateParamsActionAuditSSH, GatewayRuleUpdateParamsActionResolve: + return true + } + return false } -type GatewayRuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` +type GatewayRuleUpdateResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayRule `json:"result,required"` + // Whether the API call was successful + Success GatewayRuleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayRuleUpdateResponseEnvelopeJSON `json:"-"` } -// gatewayRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayRuleUpdateResponseEnvelopeMessages] -type gatewayRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field +// gatewayRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayRuleUpdateResponseEnvelope] +type gatewayRuleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *GatewayRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { +func (r *GatewayRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r gatewayRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { +func (r gatewayRuleUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } @@ -1624,12 +1210,17 @@ type GatewayRuleListParams struct { type GatewayRuleDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r GatewayRuleDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type GatewayRuleDeleteResponseEnvelope struct { - Errors []GatewayRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result GatewayRuleDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayRuleDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success GatewayRuleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON gatewayRuleDeleteResponseEnvelopeJSON `json:"-"` @@ -1654,52 +1245,6 @@ func (r gatewayRuleDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayRuleDeleteResponseEnvelopeErrors] -type gatewayRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayRuleDeleteResponseEnvelopeMessages] -type gatewayRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayRuleDeleteResponseEnvelopeSuccess bool @@ -1720,9 +1265,9 @@ type GatewayRuleGetParams struct { } type GatewayRuleGetResponseEnvelope struct { - Errors []GatewayRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []GatewayRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayRules `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result GatewayRule `json:"result,required"` // Whether the API call was successful Success GatewayRuleGetResponseEnvelopeSuccess `json:"success,required"` JSON gatewayRuleGetResponseEnvelopeJSON `json:"-"` @@ -1747,52 +1292,6 @@ func (r gatewayRuleGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type GatewayRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// gatewayRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [GatewayRuleGetResponseEnvelopeErrors] -type gatewayRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type GatewayRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON gatewayRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// gatewayRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [GatewayRuleGetResponseEnvelopeMessages] -type gatewayRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *GatewayRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r gatewayRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type GatewayRuleGetResponseEnvelopeSuccess bool diff --git a/zero_trust/gatewayrule_test.go b/zero_trust/gatewayrule_test.go index a1a16f1d0a3..1b39f4bbb96 100644 --- a/zero_trust/gatewayrule_test.go +++ b/zero_trust/gatewayrule_test.go @@ -35,10 +35,10 @@ func TestGatewayRuleNewWithOptionalParams(t *testing.T) { Description: cloudflare.F("Block bad websites based on their host name."), DevicePosture: cloudflare.F("any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})"), Enabled: cloudflare.F(true), - Filters: cloudflare.F([]zero_trust.GatewayRuleNewParamsFilter{zero_trust.GatewayRuleNewParamsFilterHTTP}), + Filters: cloudflare.F([]zero_trust.GatewayFilter{zero_trust.GatewayFilterHTTP}), Identity: cloudflare.F("any(identity.groups.name[*] in {\"finance\"})"), Precedence: cloudflare.F(int64(0)), - RuleSettings: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettings{ + RuleSettings: cloudflare.F(zero_trust.RuleSettingParam{ AddHeaders: cloudflare.F[any](map[string]interface{}{ "My-Next-Header": map[string]interface{}{ "0": "foo", @@ -49,10 +49,10 @@ func TestGatewayRuleNewWithOptionalParams(t *testing.T) { }, }), AllowChildBypass: cloudflare.F(false), - AuditSSH: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsAuditSSH{ + AuditSSH: cloudflare.F(zero_trust.RuleSettingAuditSSHParam{ CommandLogging: cloudflare.F(false), }), - BisoAdminControls: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsBisoAdminControls{ + BisoAdminControls: cloudflare.F(zero_trust.RuleSettingBisoAdminControlsParam{ Dcp: cloudflare.F(false), Dd: cloudflare.F(false), Dk: cloudflare.F(false), @@ -62,45 +62,45 @@ func TestGatewayRuleNewWithOptionalParams(t *testing.T) { BlockPageEnabled: cloudflare.F(true), BlockReason: cloudflare.F("This website is a security risk"), BypassParentRule: cloudflare.F(false), - CheckSession: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsCheckSession{ + CheckSession: cloudflare.F(zero_trust.RuleSettingCheckSessionParam{ Duration: cloudflare.F("300s"), Enforce: cloudflare.F(true), }), - DNSResolvers: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsDNSResolvers{ - IPV4: cloudflare.F([]zero_trust.GatewayRuleNewParamsRuleSettingsDNSResolversIPV4{{ - IP: cloudflare.F("2001:DB8::/64"), + DNSResolvers: cloudflare.F(zero_trust.RuleSettingDNSResolversParam{ + IPV4: cloudflare.F([]zero_trust.DNSResolverSettingsV4Param{{ + IP: cloudflare.F("2.2.2.2"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2.2.2.2"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2.2.2.2"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }}), - IPV6: cloudflare.F([]zero_trust.GatewayRuleNewParamsRuleSettingsDNSResolversIPV6{{ - IP: cloudflare.F("2001:DB8::/64"), + IPV6: cloudflare.F([]zero_trust.DNSResolverSettingsV6Param{{ + IP: cloudflare.F("2001:DB8::"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2001:DB8::"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2001:DB8::"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }}), }), - Egress: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsEgress{ + Egress: cloudflare.F(zero_trust.RuleSettingEgressParam{ IPV4: cloudflare.F("192.0.2.2"), IPV4Fallback: cloudflare.F("192.0.2.3"), IPV6: cloudflare.F("2001:DB8::/64"), @@ -108,26 +108,26 @@ func TestGatewayRuleNewWithOptionalParams(t *testing.T) { InsecureDisableDNSSECValidation: cloudflare.F(false), IPCategories: cloudflare.F(true), IPIndicatorFeeds: cloudflare.F(true), - L4override: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsL4override{ + L4override: cloudflare.F(zero_trust.RuleSettingL4overrideParam{ IP: cloudflare.F("1.1.1.1"), Port: cloudflare.F(int64(0)), }), - NotificationSettings: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsNotificationSettings{ + NotificationSettings: cloudflare.F(zero_trust.RuleSettingNotificationSettingsParam{ Enabled: cloudflare.F(true), Msg: cloudflare.F("string"), SupportURL: cloudflare.F("string"), }), OverrideHost: cloudflare.F("example.com"), OverrideIPs: cloudflare.F([]string{"1.1.1.1", "2.2.2.2"}), - PayloadLog: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsPayloadLog{ + PayloadLog: cloudflare.F(zero_trust.RuleSettingPayloadLogParam{ Enabled: cloudflare.F(true), }), ResolveDNSThroughCloudflare: cloudflare.F(true), - UntrustedCERT: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsUntrustedCERT{ - Action: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsUntrustedCERTActionError), + UntrustedCERT: cloudflare.F(zero_trust.RuleSettingUntrustedCERTParam{ + Action: cloudflare.F(zero_trust.RuleSettingUntrustedCERTActionError), }), }), - Schedule: cloudflare.F(zero_trust.GatewayRuleNewParamsSchedule{ + Schedule: cloudflare.F(zero_trust.ScheduleParam{ Fri: cloudflare.F("08:00-12:30,13:30-17:00"), Mon: cloudflare.F("08:00-12:30,13:30-17:00"), Sat: cloudflare.F("08:00-12:30,13:30-17:00"), @@ -172,10 +172,10 @@ func TestGatewayRuleUpdateWithOptionalParams(t *testing.T) { Description: cloudflare.F("Block bad websites based on their host name."), DevicePosture: cloudflare.F("any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})"), Enabled: cloudflare.F(true), - Filters: cloudflare.F([]zero_trust.GatewayRuleUpdateParamsFilter{zero_trust.GatewayRuleUpdateParamsFilterHTTP}), + Filters: cloudflare.F([]zero_trust.GatewayFilter{zero_trust.GatewayFilterHTTP}), Identity: cloudflare.F("any(identity.groups.name[*] in {\"finance\"})"), Precedence: cloudflare.F(int64(0)), - RuleSettings: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettings{ + RuleSettings: cloudflare.F(zero_trust.RuleSettingParam{ AddHeaders: cloudflare.F[any](map[string]interface{}{ "My-Next-Header": map[string]interface{}{ "0": "foo", @@ -186,10 +186,10 @@ func TestGatewayRuleUpdateWithOptionalParams(t *testing.T) { }, }), AllowChildBypass: cloudflare.F(false), - AuditSSH: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsAuditSSH{ + AuditSSH: cloudflare.F(zero_trust.RuleSettingAuditSSHParam{ CommandLogging: cloudflare.F(false), }), - BisoAdminControls: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsBisoAdminControls{ + BisoAdminControls: cloudflare.F(zero_trust.RuleSettingBisoAdminControlsParam{ Dcp: cloudflare.F(false), Dd: cloudflare.F(false), Dk: cloudflare.F(false), @@ -199,45 +199,45 @@ func TestGatewayRuleUpdateWithOptionalParams(t *testing.T) { BlockPageEnabled: cloudflare.F(true), BlockReason: cloudflare.F("This website is a security risk"), BypassParentRule: cloudflare.F(false), - CheckSession: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsCheckSession{ + CheckSession: cloudflare.F(zero_trust.RuleSettingCheckSessionParam{ Duration: cloudflare.F("300s"), Enforce: cloudflare.F(true), }), - DNSResolvers: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsDNSResolvers{ - IPV4: cloudflare.F([]zero_trust.GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4{{ - IP: cloudflare.F("2001:DB8::/64"), + DNSResolvers: cloudflare.F(zero_trust.RuleSettingDNSResolversParam{ + IPV4: cloudflare.F([]zero_trust.DNSResolverSettingsV4Param{{ + IP: cloudflare.F("2.2.2.2"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2.2.2.2"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2.2.2.2"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }}), - IPV6: cloudflare.F([]zero_trust.GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6{{ - IP: cloudflare.F("2001:DB8::/64"), + IPV6: cloudflare.F([]zero_trust.DNSResolverSettingsV6Param{{ + IP: cloudflare.F("2001:DB8::"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2001:DB8::"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }, { - IP: cloudflare.F("2001:DB8::/64"), + IP: cloudflare.F("2001:DB8::"), Port: cloudflare.F(int64(5053)), RouteThroughPrivateNetwork: cloudflare.F(true), VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), }}), }), - Egress: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsEgress{ + Egress: cloudflare.F(zero_trust.RuleSettingEgressParam{ IPV4: cloudflare.F("192.0.2.2"), IPV4Fallback: cloudflare.F("192.0.2.3"), IPV6: cloudflare.F("2001:DB8::/64"), @@ -245,26 +245,26 @@ func TestGatewayRuleUpdateWithOptionalParams(t *testing.T) { InsecureDisableDNSSECValidation: cloudflare.F(false), IPCategories: cloudflare.F(true), IPIndicatorFeeds: cloudflare.F(true), - L4override: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsL4override{ + L4override: cloudflare.F(zero_trust.RuleSettingL4overrideParam{ IP: cloudflare.F("1.1.1.1"), Port: cloudflare.F(int64(0)), }), - NotificationSettings: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsNotificationSettings{ + NotificationSettings: cloudflare.F(zero_trust.RuleSettingNotificationSettingsParam{ Enabled: cloudflare.F(true), Msg: cloudflare.F("string"), SupportURL: cloudflare.F("string"), }), OverrideHost: cloudflare.F("example.com"), OverrideIPs: cloudflare.F([]string{"1.1.1.1", "2.2.2.2"}), - PayloadLog: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsPayloadLog{ + PayloadLog: cloudflare.F(zero_trust.RuleSettingPayloadLogParam{ Enabled: cloudflare.F(true), }), ResolveDNSThroughCloudflare: cloudflare.F(true), - UntrustedCERT: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsUntrustedCERT{ - Action: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsUntrustedCERTActionError), + UntrustedCERT: cloudflare.F(zero_trust.RuleSettingUntrustedCERTParam{ + Action: cloudflare.F(zero_trust.RuleSettingUntrustedCERTActionError), }), }), - Schedule: cloudflare.F(zero_trust.GatewayRuleUpdateParamsSchedule{ + Schedule: cloudflare.F(zero_trust.ScheduleParam{ Fri: cloudflare.F("08:00-12:30,13:30-17:00"), Mon: cloudflare.F("08:00-12:30,13:30-17:00"), Sat: cloudflare.F("08:00-12:30,13:30-17:00"), @@ -331,6 +331,7 @@ func TestGatewayRuleDelete(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.GatewayRuleDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/identityprovider.go b/zero_trust/identityprovider.go index 494983ae0d7..058246c1a11 100644 --- a/zero_trust/identityprovider.go +++ b/zero_trust/identityprovider.go @@ -12,6 +12,7 @@ import ( "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" ) @@ -35,17 +36,17 @@ func NewIdentityProviderService(opts ...option.RequestOption) (r *IdentityProvid } // Adds a new identity provider to Access. -func (r *IdentityProviderService) New(ctx context.Context, params IdentityProviderNewParams, opts ...option.RequestOption) (res *ZeroTrustIdentityProviders, err error) { +func (r *IdentityProviderService) New(ctx context.Context, params IdentityProviderNewParams, opts ...option.RequestOption) (res *IdentityProvider, err error) { opts = append(r.Options[:], opts...) var env IdentityProviderNewResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if params.getAccountID().Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = params.getAccountID() + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = params.getZoneID() + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/access/identity_providers", accountOrZone, accountOrZoneID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) @@ -57,17 +58,17 @@ func (r *IdentityProviderService) New(ctx context.Context, params IdentityProvid } // Updates a configured identity provider. -func (r *IdentityProviderService) Update(ctx context.Context, uuid string, params IdentityProviderUpdateParams, opts ...option.RequestOption) (res *ZeroTrustIdentityProviders, err error) { +func (r *IdentityProviderService) Update(ctx context.Context, uuid string, params IdentityProviderUpdateParams, opts ...option.RequestOption) (res *IdentityProvider, err error) { opts = append(r.Options[:], opts...) var env IdentityProviderUpdateResponseEnvelope var accountOrZone string var accountOrZoneID param.Field[string] - if params.getAccountID().Present { + if params.AccountID.Present { accountOrZone = "accounts" - accountOrZoneID = params.getAccountID() + accountOrZoneID = params.AccountID } else { accountOrZone = "zones" - accountOrZoneID = params.getZoneID() + accountOrZoneID = params.ZoneID } path := fmt.Sprintf("%s/%s/access/identity_providers/%s", accountOrZone, accountOrZoneID, uuid) err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) @@ -133,7 +134,7 @@ func (r *IdentityProviderService) Delete(ctx context.Context, uuid string, body } // Fetches a configured identity provider. -func (r *IdentityProviderService) Get(ctx context.Context, uuid string, query IdentityProviderGetParams, opts ...option.RequestOption) (res *ZeroTrustIdentityProviders, err error) { +func (r *IdentityProviderService) Get(ctx context.Context, uuid string, query IdentityProviderGetParams, opts ...option.RequestOption) (res *IdentityProvider, err error) { opts = append(r.Options[:], opts...) var env IdentityProviderGetResponseEnvelope var accountOrZone string @@ -154,109 +155,27 @@ func (r *IdentityProviderService) Get(ctx context.Context, uuid string, query Id return } -// Union satisfied by [zero_trust.ZeroTrustIdentityProvidersAccessAzureAd], -// [zero_trust.ZeroTrustIdentityProvidersAccessCentrify], -// [zero_trust.ZeroTrustIdentityProvidersAccessFacebook], -// [zero_trust.ZeroTrustIdentityProvidersAccessGitHub], -// [zero_trust.ZeroTrustIdentityProvidersAccessGoogle], -// [zero_trust.ZeroTrustIdentityProvidersAccessGoogleApps], -// [zero_trust.ZeroTrustIdentityProvidersAccessLinkedin], -// [zero_trust.ZeroTrustIdentityProvidersAccessOidc], -// [zero_trust.ZeroTrustIdentityProvidersAccessOkta], -// [zero_trust.ZeroTrustIdentityProvidersAccessOnelogin], -// [zero_trust.ZeroTrustIdentityProvidersAccessPingone], -// [zero_trust.ZeroTrustIdentityProvidersAccessSaml], -// [zero_trust.ZeroTrustIdentityProvidersAccessYandex] or -// [zero_trust.ZeroTrustIdentityProvidersAccessOnetimepin]. -type ZeroTrustIdentityProviders interface { - implementsZeroTrustZeroTrustIdentityProviders() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustIdentityProviders)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessAzureAd{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessCentrify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessFacebook{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessGitHub{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessGoogle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessGoogleApps{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessLinkedin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessOidc{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessOkta{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessOnelogin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessPingone{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessSaml{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessYandex{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProvidersAccessOnetimepin{}), - }, - ) -} - -type ZeroTrustIdentityProvidersAccessAzureAd struct { +type AzureAD struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessAzureAdConfig `json:"config,required"` + Config AzureADConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessAzureAdType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessAzureAdScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessAzureAdJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON azureADJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessAzureAdJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessAzureAd] -type zeroTrustIdentityProvidersAccessAzureAdJSON struct { +// azureADJSON contains the JSON metadata for the struct [AzureAD] +type azureADJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -266,20 +185,22 @@ type zeroTrustIdentityProvidersAccessAzureAdJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessAzureAd) UnmarshalJSON(data []byte) (err error) { +func (r *AzureAD) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessAzureAdJSON) RawJSON() string { +func (r azureADJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessAzureAd) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r AzureAD) implementsZeroTrustIdentityProvider() {} + +func (r AzureAD) implementsZeroTrustIdentityProviderListResponse() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessAzureAdConfig struct { +type AzureADConfig struct { // Custom claims Claims []string `json:"claims"` // Your OAuth Client ID @@ -300,15 +221,14 @@ type ZeroTrustIdentityProvidersAccessAzureAdConfig struct { // error. prompt=select_account interrupts single sign-on providing account // selection experience listing all the accounts either in session or any // remembered account or an option to choose to use a different account altogether. - Prompt ZeroTrustIdentityProvidersAccessAzureAdConfigPrompt `json:"prompt"` + Prompt AzureADConfigPrompt `json:"prompt"` // Should Cloudflare try to load groups from your account - SupportGroups bool `json:"support_groups"` - JSON zeroTrustIdentityProvidersAccessAzureAdConfigJSON `json:"-"` + SupportGroups bool `json:"support_groups"` + JSON azureADConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessAzureAdConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessAzureAdConfig] -type zeroTrustIdentityProvidersAccessAzureAdConfigJSON struct { +// azureADConfigJSON contains the JSON metadata for the struct [AzureADConfig] +type azureADConfigJSON struct { Claims apijson.Field ClientID apijson.Field ClientSecret apijson.Field @@ -321,11 +241,11 @@ type zeroTrustIdentityProvidersAccessAzureAdConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { +func (r *AzureADConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessAzureAdConfigJSON) RawJSON() string { +func (r azureADConfigJSON) RawJSON() string { return r.raw } @@ -337,117 +257,261 @@ func (r zeroTrustIdentityProvidersAccessAzureAdConfigJSON) RawJSON() string { // error. prompt=select_account interrupts single sign-on providing account // selection experience listing all the accounts either in session or any // remembered account or an option to choose to use a different account altogether. -type ZeroTrustIdentityProvidersAccessAzureAdConfigPrompt string +type AzureADConfigPrompt string const ( - ZeroTrustIdentityProvidersAccessAzureAdConfigPromptLogin ZeroTrustIdentityProvidersAccessAzureAdConfigPrompt = "login" - ZeroTrustIdentityProvidersAccessAzureAdConfigPromptSelectAccount ZeroTrustIdentityProvidersAccessAzureAdConfigPrompt = "select_account" - ZeroTrustIdentityProvidersAccessAzureAdConfigPromptNone ZeroTrustIdentityProvidersAccessAzureAdConfigPrompt = "none" + AzureADConfigPromptLogin AzureADConfigPrompt = "login" + AzureADConfigPromptSelectAccount AzureADConfigPrompt = "select_account" + AzureADConfigPromptNone AzureADConfigPrompt = "none" ) -func (r ZeroTrustIdentityProvidersAccessAzureAdConfigPrompt) IsKnown() bool { +func (r AzureADConfigPrompt) IsKnown() bool { switch r { - case ZeroTrustIdentityProvidersAccessAzureAdConfigPromptLogin, ZeroTrustIdentityProvidersAccessAzureAdConfigPromptSelectAccount, ZeroTrustIdentityProvidersAccessAzureAdConfigPromptNone: + case AzureADConfigPromptLogin, AzureADConfigPromptSelectAccount, AzureADConfigPromptNone: return true } return false } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessAzureAdType string +type AzureADParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[AzureADConfigParam] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` +} -const ( - ZeroTrustIdentityProvidersAccessAzureAdTypeOnetimepin ZeroTrustIdentityProvidersAccessAzureAdType = "onetimepin" - ZeroTrustIdentityProvidersAccessAzureAdTypeAzureAd ZeroTrustIdentityProvidersAccessAzureAdType = "azureAD" - ZeroTrustIdentityProvidersAccessAzureAdTypeSaml ZeroTrustIdentityProvidersAccessAzureAdType = "saml" - ZeroTrustIdentityProvidersAccessAzureAdTypeCentrify ZeroTrustIdentityProvidersAccessAzureAdType = "centrify" - ZeroTrustIdentityProvidersAccessAzureAdTypeFacebook ZeroTrustIdentityProvidersAccessAzureAdType = "facebook" - ZeroTrustIdentityProvidersAccessAzureAdTypeGitHub ZeroTrustIdentityProvidersAccessAzureAdType = "github" - ZeroTrustIdentityProvidersAccessAzureAdTypeGoogleApps ZeroTrustIdentityProvidersAccessAzureAdType = "google-apps" - ZeroTrustIdentityProvidersAccessAzureAdTypeGoogle ZeroTrustIdentityProvidersAccessAzureAdType = "google" - ZeroTrustIdentityProvidersAccessAzureAdTypeLinkedin ZeroTrustIdentityProvidersAccessAzureAdType = "linkedin" - ZeroTrustIdentityProvidersAccessAzureAdTypeOidc ZeroTrustIdentityProvidersAccessAzureAdType = "oidc" - ZeroTrustIdentityProvidersAccessAzureAdTypeOkta ZeroTrustIdentityProvidersAccessAzureAdType = "okta" - ZeroTrustIdentityProvidersAccessAzureAdTypeOnelogin ZeroTrustIdentityProvidersAccessAzureAdType = "onelogin" - ZeroTrustIdentityProvidersAccessAzureAdTypePingone ZeroTrustIdentityProvidersAccessAzureAdType = "pingone" - ZeroTrustIdentityProvidersAccessAzureAdTypeYandex ZeroTrustIdentityProvidersAccessAzureAdType = "yandex" -) +func (r AzureADParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} -func (r ZeroTrustIdentityProvidersAccessAzureAdType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessAzureAdTypeOnetimepin, ZeroTrustIdentityProvidersAccessAzureAdTypeAzureAd, ZeroTrustIdentityProvidersAccessAzureAdTypeSaml, ZeroTrustIdentityProvidersAccessAzureAdTypeCentrify, ZeroTrustIdentityProvidersAccessAzureAdTypeFacebook, ZeroTrustIdentityProvidersAccessAzureAdTypeGitHub, ZeroTrustIdentityProvidersAccessAzureAdTypeGoogleApps, ZeroTrustIdentityProvidersAccessAzureAdTypeGoogle, ZeroTrustIdentityProvidersAccessAzureAdTypeLinkedin, ZeroTrustIdentityProvidersAccessAzureAdTypeOidc, ZeroTrustIdentityProvidersAccessAzureAdTypeOkta, ZeroTrustIdentityProvidersAccessAzureAdTypeOnelogin, ZeroTrustIdentityProvidersAccessAzureAdTypePingone, ZeroTrustIdentityProvidersAccessAzureAdTypeYandex: - return true - } - return false +func (r AzureADParam) implementsZeroTrustIdentityProviderUnionParam() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AzureADConfigParam struct { + // Custom claims + Claims param.Field[[]string] `json:"claims"` + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` + // Should Cloudflare try to load authentication contexts from your account + ConditionalAccessEnabled param.Field[bool] `json:"conditional_access_enabled"` + // Your Azure directory uuid + DirectoryID param.Field[string] `json:"directory_id"` + // The claim name for email in the id_token response. + EmailClaimName param.Field[string] `json:"email_claim_name"` + // Indicates the type of user interaction that is required. prompt=login forces the + // user to enter their credentials on that request, negating single-sign on. + // prompt=none is the opposite. It ensures that the user isn't presented with any + // interactive prompt. If the request can't be completed silently by using + // single-sign on, the Microsoft identity platform returns an interaction_required + // error. prompt=select_account interrupts single sign-on providing account + // selection experience listing all the accounts either in session or any + // remembered account or an option to choose to use a different account altogether. + Prompt param.Field[AzureADConfigPrompt] `json:"prompt"` + // Should Cloudflare try to load groups from your account + SupportGroups param.Field[bool] `json:"support_groups"` } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessAzureAdScimConfigJSON `json:"-"` +func (r AzureADConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// zeroTrustIdentityProvidersAccessAzureAdScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessAzureAdScimConfig] -type zeroTrustIdentityProvidersAccessAzureAdScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +type GenericOAuthConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON genericOAuthConfigJSON `json:"-"` } -func (r *ZeroTrustIdentityProvidersAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { +// genericOAuthConfigJSON contains the JSON metadata for the struct +// [GenericOAuthConfig] +type genericOAuthConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GenericOAuthConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessAzureAdScimConfigJSON) RawJSON() string { +func (r genericOAuthConfigJSON) RawJSON() string { + return r.raw +} + +type GenericOAuthConfigParam struct { + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` +} + +func (r GenericOAuthConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProvider struct { + Config interface{} `json:"config"` + // UUID + ID string `json:"id"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + JSON identityProviderJSON `json:"-"` + union IdentityProviderUnion +} + +// identityProviderJSON contains the JSON metadata for the struct +// [IdentityProvider] +type identityProviderJSON struct { + Config apijson.Field + ID apijson.Field + Name apijson.Field + ScimConfig apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r identityProviderJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessCentrify struct { +func (r *IdentityProvider) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +func (r IdentityProvider) AsUnion() IdentityProviderUnion { + return r.union +} + +// Union satisfied by [zero_trust.AzureAD], +// [zero_trust.IdentityProviderAccessCentrify], +// [zero_trust.IdentityProviderAccessFacebook], +// [zero_trust.IdentityProviderAccessGitHub], +// [zero_trust.IdentityProviderAccessGoogle], +// [zero_trust.IdentityProviderAccessGoogleApps], +// [zero_trust.IdentityProviderAccessLinkedin], +// [zero_trust.IdentityProviderAccessOIDC], +// [zero_trust.IdentityProviderAccessOkta], +// [zero_trust.IdentityProviderAccessOnelogin], +// [zero_trust.IdentityProviderAccessPingone], +// [zero_trust.IdentityProviderAccessSAML], +// [zero_trust.IdentityProviderAccessYandex] or +// [zero_trust.IdentityProviderAccessOnetimepin]. +type IdentityProviderUnion interface { + implementsZeroTrustIdentityProvider() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*IdentityProviderUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AzureAD{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessCentrify{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessFacebook{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessGitHub{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessGoogle{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessGoogleApps{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessLinkedin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessOIDC{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessOkta{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessOnelogin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessPingone{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessSAML{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessYandex{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderAccessOnetimepin{}), + }, + ) +} + +type IdentityProviderAccessCentrify struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessCentrifyConfig `json:"config,required"` + Config IdentityProviderAccessCentrifyConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessCentrifyType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessCentrifyScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessCentrifyJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessCentrifyJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessCentrifyJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessCentrify] -type zeroTrustIdentityProvidersAccessCentrifyJSON struct { +// identityProviderAccessCentrifyJSON contains the JSON metadata for the struct +// [IdentityProviderAccessCentrify] +type identityProviderAccessCentrifyJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -457,20 +521,20 @@ type zeroTrustIdentityProvidersAccessCentrifyJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessCentrify) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessCentrify) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessCentrifyJSON) RawJSON() string { +func (r identityProviderAccessCentrifyJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessCentrify) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessCentrify) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessCentrifyConfig struct { +type IdentityProviderAccessCentrifyConfig struct { // Your centrify account url CentrifyAccount string `json:"centrify_account"` // Your centrify app id @@ -482,13 +546,13 @@ type ZeroTrustIdentityProvidersAccessCentrifyConfig struct { // Your OAuth Client Secret ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProvidersAccessCentrifyConfigJSON `json:"-"` + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderAccessCentrifyConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessCentrifyConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessCentrifyConfig] -type zeroTrustIdentityProvidersAccessCentrifyConfigJSON struct { +// identityProviderAccessCentrifyConfigJSON contains the JSON metadata for the +// struct [IdentityProviderAccessCentrifyConfig] +type identityProviderAccessCentrifyConfigJSON struct { CentrifyAccount apijson.Field CentrifyAppID apijson.Field Claims apijson.Field @@ -499,109 +563,118 @@ type zeroTrustIdentityProvidersAccessCentrifyConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessCentrifyConfigJSON) RawJSON() string { +func (r identityProviderAccessCentrifyConfigJSON) RawJSON() string { return r.raw } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessCentrifyType string +type IdentityProviderAccessFacebook struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config GenericOAuthConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessFacebookJSON `json:"-"` +} -const ( - ZeroTrustIdentityProvidersAccessCentrifyTypeOnetimepin ZeroTrustIdentityProvidersAccessCentrifyType = "onetimepin" - ZeroTrustIdentityProvidersAccessCentrifyTypeAzureAd ZeroTrustIdentityProvidersAccessCentrifyType = "azureAD" - ZeroTrustIdentityProvidersAccessCentrifyTypeSaml ZeroTrustIdentityProvidersAccessCentrifyType = "saml" - ZeroTrustIdentityProvidersAccessCentrifyTypeCentrify ZeroTrustIdentityProvidersAccessCentrifyType = "centrify" - ZeroTrustIdentityProvidersAccessCentrifyTypeFacebook ZeroTrustIdentityProvidersAccessCentrifyType = "facebook" - ZeroTrustIdentityProvidersAccessCentrifyTypeGitHub ZeroTrustIdentityProvidersAccessCentrifyType = "github" - ZeroTrustIdentityProvidersAccessCentrifyTypeGoogleApps ZeroTrustIdentityProvidersAccessCentrifyType = "google-apps" - ZeroTrustIdentityProvidersAccessCentrifyTypeGoogle ZeroTrustIdentityProvidersAccessCentrifyType = "google" - ZeroTrustIdentityProvidersAccessCentrifyTypeLinkedin ZeroTrustIdentityProvidersAccessCentrifyType = "linkedin" - ZeroTrustIdentityProvidersAccessCentrifyTypeOidc ZeroTrustIdentityProvidersAccessCentrifyType = "oidc" - ZeroTrustIdentityProvidersAccessCentrifyTypeOkta ZeroTrustIdentityProvidersAccessCentrifyType = "okta" - ZeroTrustIdentityProvidersAccessCentrifyTypeOnelogin ZeroTrustIdentityProvidersAccessCentrifyType = "onelogin" - ZeroTrustIdentityProvidersAccessCentrifyTypePingone ZeroTrustIdentityProvidersAccessCentrifyType = "pingone" - ZeroTrustIdentityProvidersAccessCentrifyTypeYandex ZeroTrustIdentityProvidersAccessCentrifyType = "yandex" -) +// identityProviderAccessFacebookJSON contains the JSON metadata for the struct +// [IdentityProviderAccessFacebook] +type identityProviderAccessFacebookJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -func (r ZeroTrustIdentityProvidersAccessCentrifyType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessCentrifyTypeOnetimepin, ZeroTrustIdentityProvidersAccessCentrifyTypeAzureAd, ZeroTrustIdentityProvidersAccessCentrifyTypeSaml, ZeroTrustIdentityProvidersAccessCentrifyTypeCentrify, ZeroTrustIdentityProvidersAccessCentrifyTypeFacebook, ZeroTrustIdentityProvidersAccessCentrifyTypeGitHub, ZeroTrustIdentityProvidersAccessCentrifyTypeGoogleApps, ZeroTrustIdentityProvidersAccessCentrifyTypeGoogle, ZeroTrustIdentityProvidersAccessCentrifyTypeLinkedin, ZeroTrustIdentityProvidersAccessCentrifyTypeOidc, ZeroTrustIdentityProvidersAccessCentrifyTypeOkta, ZeroTrustIdentityProvidersAccessCentrifyTypeOnelogin, ZeroTrustIdentityProvidersAccessCentrifyTypePingone, ZeroTrustIdentityProvidersAccessCentrifyTypeYandex: - return true - } - return false +func (r *IdentityProviderAccessFacebook) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessCentrifyScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessCentrifyScimConfigJSON `json:"-"` +func (r identityProviderAccessFacebookJSON) RawJSON() string { + return r.raw } -// zeroTrustIdentityProvidersAccessCentrifyScimConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProvidersAccessCentrifyScimConfig] -type zeroTrustIdentityProvidersAccessCentrifyScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r IdentityProviderAccessFacebook) implementsZeroTrustIdentityProvider() {} + +type IdentityProviderAccessGitHub struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config GenericOAuthConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessGitHubJSON `json:"-"` +} + +// identityProviderAccessGitHubJSON contains the JSON metadata for the struct +// [IdentityProviderAccessGitHub] +type identityProviderAccessGitHubJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessGitHub) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessCentrifyScimConfigJSON) RawJSON() string { +func (r identityProviderAccessGitHubJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessFacebook struct { +func (r IdentityProviderAccessGitHub) implementsZeroTrustIdentityProvider() {} + +type IdentityProviderAccessGoogle struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessFacebookConfig `json:"config,required"` + Config IdentityProviderAccessGoogleConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessFacebookType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessFacebookScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessFacebookJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessGoogleJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessFacebookJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessFacebook] -type zeroTrustIdentityProvidersAccessFacebookJSON struct { +// identityProviderAccessGoogleJSON contains the JSON metadata for the struct +// [IdentityProviderAccessGoogle] +type identityProviderAccessGoogleJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -611,139 +684,72 @@ type zeroTrustIdentityProvidersAccessFacebookJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessFacebook) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessGoogle) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessFacebookJSON) RawJSON() string { +func (r identityProviderAccessGoogleJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessFacebook) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessGoogle) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessFacebookConfig struct { +type IdentityProviderAccessGoogleConfig struct { + // Custom claims + Claims []string `json:"claims"` // Your OAuth Client ID ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProvidersAccessFacebookConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessFacebookConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessFacebookConfig] -type zeroTrustIdentityProvidersAccessFacebookConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessFacebookConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessFacebookType string - -const ( - ZeroTrustIdentityProvidersAccessFacebookTypeOnetimepin ZeroTrustIdentityProvidersAccessFacebookType = "onetimepin" - ZeroTrustIdentityProvidersAccessFacebookTypeAzureAd ZeroTrustIdentityProvidersAccessFacebookType = "azureAD" - ZeroTrustIdentityProvidersAccessFacebookTypeSaml ZeroTrustIdentityProvidersAccessFacebookType = "saml" - ZeroTrustIdentityProvidersAccessFacebookTypeCentrify ZeroTrustIdentityProvidersAccessFacebookType = "centrify" - ZeroTrustIdentityProvidersAccessFacebookTypeFacebook ZeroTrustIdentityProvidersAccessFacebookType = "facebook" - ZeroTrustIdentityProvidersAccessFacebookTypeGitHub ZeroTrustIdentityProvidersAccessFacebookType = "github" - ZeroTrustIdentityProvidersAccessFacebookTypeGoogleApps ZeroTrustIdentityProvidersAccessFacebookType = "google-apps" - ZeroTrustIdentityProvidersAccessFacebookTypeGoogle ZeroTrustIdentityProvidersAccessFacebookType = "google" - ZeroTrustIdentityProvidersAccessFacebookTypeLinkedin ZeroTrustIdentityProvidersAccessFacebookType = "linkedin" - ZeroTrustIdentityProvidersAccessFacebookTypeOidc ZeroTrustIdentityProvidersAccessFacebookType = "oidc" - ZeroTrustIdentityProvidersAccessFacebookTypeOkta ZeroTrustIdentityProvidersAccessFacebookType = "okta" - ZeroTrustIdentityProvidersAccessFacebookTypeOnelogin ZeroTrustIdentityProvidersAccessFacebookType = "onelogin" - ZeroTrustIdentityProvidersAccessFacebookTypePingone ZeroTrustIdentityProvidersAccessFacebookType = "pingone" - ZeroTrustIdentityProvidersAccessFacebookTypeYandex ZeroTrustIdentityProvidersAccessFacebookType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessFacebookType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessFacebookTypeOnetimepin, ZeroTrustIdentityProvidersAccessFacebookTypeAzureAd, ZeroTrustIdentityProvidersAccessFacebookTypeSaml, ZeroTrustIdentityProvidersAccessFacebookTypeCentrify, ZeroTrustIdentityProvidersAccessFacebookTypeFacebook, ZeroTrustIdentityProvidersAccessFacebookTypeGitHub, ZeroTrustIdentityProvidersAccessFacebookTypeGoogleApps, ZeroTrustIdentityProvidersAccessFacebookTypeGoogle, ZeroTrustIdentityProvidersAccessFacebookTypeLinkedin, ZeroTrustIdentityProvidersAccessFacebookTypeOidc, ZeroTrustIdentityProvidersAccessFacebookTypeOkta, ZeroTrustIdentityProvidersAccessFacebookTypeOnelogin, ZeroTrustIdentityProvidersAccessFacebookTypePingone, ZeroTrustIdentityProvidersAccessFacebookTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessFacebookScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessFacebookScimConfigJSON `json:"-"` + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderAccessGoogleConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessFacebookScimConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProvidersAccessFacebookScimConfig] -type zeroTrustIdentityProvidersAccessFacebookScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +// identityProviderAccessGoogleConfigJSON contains the JSON metadata for the struct +// [IdentityProviderAccessGoogleConfig] +type identityProviderAccessGoogleConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessFacebookScimConfigJSON) RawJSON() string { +func (r identityProviderAccessGoogleConfigJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessGitHub struct { +type IdentityProviderAccessGoogleApps struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessGitHubConfig `json:"config,required"` + Config IdentityProviderAccessGoogleAppsConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessGitHubType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessGitHubScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessGitHubJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessGoogleAppsJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessGitHubJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessGitHub] -type zeroTrustIdentityProvidersAccessGitHubJSON struct { +// identityProviderAccessGoogleAppsJSON contains the JSON metadata for the struct +// [IdentityProviderAccessGoogleApps] +type identityProviderAccessGoogleAppsJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -753,139 +759,116 @@ type zeroTrustIdentityProvidersAccessGitHubJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessGitHub) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessGitHubJSON) RawJSON() string { +func (r identityProviderAccessGoogleAppsJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessGitHub) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessGoogleApps) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessGitHubConfig struct { +type IdentityProviderAccessGoogleAppsConfig struct { + // Your companies TLD + AppsDomain string `json:"apps_domain"` + // Custom claims + Claims []string `json:"claims"` // Your OAuth Client ID ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProvidersAccessGitHubConfigJSON `json:"-"` + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderAccessGoogleAppsConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessGitHubConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessGitHubConfig] -type zeroTrustIdentityProvidersAccessGitHubConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field +// identityProviderAccessGoogleAppsConfigJSON contains the JSON metadata for the +// struct [IdentityProviderAccessGoogleAppsConfig] +type identityProviderAccessGoogleAppsConfigJSON struct { + AppsDomain apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessGitHubConfigJSON) RawJSON() string { +func (r identityProviderAccessGoogleAppsConfigJSON) RawJSON() string { return r.raw } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessGitHubType string - -const ( - ZeroTrustIdentityProvidersAccessGitHubTypeOnetimepin ZeroTrustIdentityProvidersAccessGitHubType = "onetimepin" - ZeroTrustIdentityProvidersAccessGitHubTypeAzureAd ZeroTrustIdentityProvidersAccessGitHubType = "azureAD" - ZeroTrustIdentityProvidersAccessGitHubTypeSaml ZeroTrustIdentityProvidersAccessGitHubType = "saml" - ZeroTrustIdentityProvidersAccessGitHubTypeCentrify ZeroTrustIdentityProvidersAccessGitHubType = "centrify" - ZeroTrustIdentityProvidersAccessGitHubTypeFacebook ZeroTrustIdentityProvidersAccessGitHubType = "facebook" - ZeroTrustIdentityProvidersAccessGitHubTypeGitHub ZeroTrustIdentityProvidersAccessGitHubType = "github" - ZeroTrustIdentityProvidersAccessGitHubTypeGoogleApps ZeroTrustIdentityProvidersAccessGitHubType = "google-apps" - ZeroTrustIdentityProvidersAccessGitHubTypeGoogle ZeroTrustIdentityProvidersAccessGitHubType = "google" - ZeroTrustIdentityProvidersAccessGitHubTypeLinkedin ZeroTrustIdentityProvidersAccessGitHubType = "linkedin" - ZeroTrustIdentityProvidersAccessGitHubTypeOidc ZeroTrustIdentityProvidersAccessGitHubType = "oidc" - ZeroTrustIdentityProvidersAccessGitHubTypeOkta ZeroTrustIdentityProvidersAccessGitHubType = "okta" - ZeroTrustIdentityProvidersAccessGitHubTypeOnelogin ZeroTrustIdentityProvidersAccessGitHubType = "onelogin" - ZeroTrustIdentityProvidersAccessGitHubTypePingone ZeroTrustIdentityProvidersAccessGitHubType = "pingone" - ZeroTrustIdentityProvidersAccessGitHubTypeYandex ZeroTrustIdentityProvidersAccessGitHubType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessGitHubType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessGitHubTypeOnetimepin, ZeroTrustIdentityProvidersAccessGitHubTypeAzureAd, ZeroTrustIdentityProvidersAccessGitHubTypeSaml, ZeroTrustIdentityProvidersAccessGitHubTypeCentrify, ZeroTrustIdentityProvidersAccessGitHubTypeFacebook, ZeroTrustIdentityProvidersAccessGitHubTypeGitHub, ZeroTrustIdentityProvidersAccessGitHubTypeGoogleApps, ZeroTrustIdentityProvidersAccessGitHubTypeGoogle, ZeroTrustIdentityProvidersAccessGitHubTypeLinkedin, ZeroTrustIdentityProvidersAccessGitHubTypeOidc, ZeroTrustIdentityProvidersAccessGitHubTypeOkta, ZeroTrustIdentityProvidersAccessGitHubTypeOnelogin, ZeroTrustIdentityProvidersAccessGitHubTypePingone, ZeroTrustIdentityProvidersAccessGitHubTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessGitHubScimConfigJSON `json:"-"` +type IdentityProviderAccessLinkedin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config GenericOAuthConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessLinkedinJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessGitHubScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessGitHubScimConfig] -type zeroTrustIdentityProvidersAccessGitHubScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +// identityProviderAccessLinkedinJSON contains the JSON metadata for the struct +// [IdentityProviderAccessLinkedin] +type identityProviderAccessLinkedinJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessLinkedin) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessGitHubScimConfigJSON) RawJSON() string { +func (r identityProviderAccessLinkedinJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessGoogle struct { +func (r IdentityProviderAccessLinkedin) implementsZeroTrustIdentityProvider() {} + +type IdentityProviderAccessOIDC struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessGoogleConfig `json:"config,required"` + Config IdentityProviderAccessOIDCConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessGoogleType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessGoogleScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessGoogleJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessOIDCJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessGoogleJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessGoogle] -type zeroTrustIdentityProvidersAccessGoogleJSON struct { +// identityProviderAccessOIDCJSON contains the JSON metadata for the struct +// [IdentityProviderAccessOIDC] +type identityProviderAccessOIDCJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -895,20 +878,24 @@ type zeroTrustIdentityProvidersAccessGoogleJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessGoogle) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessOIDC) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessGoogleJSON) RawJSON() string { +func (r identityProviderAccessOIDCJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessGoogle) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessOIDC) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessGoogleConfig struct { +type IdentityProviderAccessOIDCConfig struct { + // The authorization_endpoint URL of your IdP + AuthURL string `json:"auth_url"` + // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens + CERTsURL string `json:"certs_url"` // Custom claims Claims []string `json:"claims"` // Your OAuth Client ID @@ -916,124 +903,59 @@ type ZeroTrustIdentityProvidersAccessGoogleConfig struct { // Your OAuth Client Secret ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProvidersAccessGoogleConfigJSON `json:"-"` + EmailClaimName string `json:"email_claim_name"` + // OAuth scopes + Scopes []string `json:"scopes"` + // The token_endpoint URL of your IdP + TokenURL string `json:"token_url"` + JSON identityProviderAccessOIDCConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessGoogleConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessGoogleConfig] -type zeroTrustIdentityProvidersAccessGoogleConfigJSON struct { +// identityProviderAccessOIDCConfigJSON contains the JSON metadata for the struct +// [IdentityProviderAccessOIDCConfig] +type identityProviderAccessOIDCConfigJSON struct { + AuthURL apijson.Field + CERTsURL apijson.Field Claims apijson.Field ClientID apijson.Field ClientSecret apijson.Field EmailClaimName apijson.Field + Scopes apijson.Field + TokenURL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessGoogleConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessGoogleType string - -const ( - ZeroTrustIdentityProvidersAccessGoogleTypeOnetimepin ZeroTrustIdentityProvidersAccessGoogleType = "onetimepin" - ZeroTrustIdentityProvidersAccessGoogleTypeAzureAd ZeroTrustIdentityProvidersAccessGoogleType = "azureAD" - ZeroTrustIdentityProvidersAccessGoogleTypeSaml ZeroTrustIdentityProvidersAccessGoogleType = "saml" - ZeroTrustIdentityProvidersAccessGoogleTypeCentrify ZeroTrustIdentityProvidersAccessGoogleType = "centrify" - ZeroTrustIdentityProvidersAccessGoogleTypeFacebook ZeroTrustIdentityProvidersAccessGoogleType = "facebook" - ZeroTrustIdentityProvidersAccessGoogleTypeGitHub ZeroTrustIdentityProvidersAccessGoogleType = "github" - ZeroTrustIdentityProvidersAccessGoogleTypeGoogleApps ZeroTrustIdentityProvidersAccessGoogleType = "google-apps" - ZeroTrustIdentityProvidersAccessGoogleTypeGoogle ZeroTrustIdentityProvidersAccessGoogleType = "google" - ZeroTrustIdentityProvidersAccessGoogleTypeLinkedin ZeroTrustIdentityProvidersAccessGoogleType = "linkedin" - ZeroTrustIdentityProvidersAccessGoogleTypeOidc ZeroTrustIdentityProvidersAccessGoogleType = "oidc" - ZeroTrustIdentityProvidersAccessGoogleTypeOkta ZeroTrustIdentityProvidersAccessGoogleType = "okta" - ZeroTrustIdentityProvidersAccessGoogleTypeOnelogin ZeroTrustIdentityProvidersAccessGoogleType = "onelogin" - ZeroTrustIdentityProvidersAccessGoogleTypePingone ZeroTrustIdentityProvidersAccessGoogleType = "pingone" - ZeroTrustIdentityProvidersAccessGoogleTypeYandex ZeroTrustIdentityProvidersAccessGoogleType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessGoogleType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessGoogleTypeOnetimepin, ZeroTrustIdentityProvidersAccessGoogleTypeAzureAd, ZeroTrustIdentityProvidersAccessGoogleTypeSaml, ZeroTrustIdentityProvidersAccessGoogleTypeCentrify, ZeroTrustIdentityProvidersAccessGoogleTypeFacebook, ZeroTrustIdentityProvidersAccessGoogleTypeGitHub, ZeroTrustIdentityProvidersAccessGoogleTypeGoogleApps, ZeroTrustIdentityProvidersAccessGoogleTypeGoogle, ZeroTrustIdentityProvidersAccessGoogleTypeLinkedin, ZeroTrustIdentityProvidersAccessGoogleTypeOidc, ZeroTrustIdentityProvidersAccessGoogleTypeOkta, ZeroTrustIdentityProvidersAccessGoogleTypeOnelogin, ZeroTrustIdentityProvidersAccessGoogleTypePingone, ZeroTrustIdentityProvidersAccessGoogleTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessGoogleScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessGoogleScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessGoogleScimConfig] -type zeroTrustIdentityProvidersAccessGoogleScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessOIDCConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessGoogleScimConfigJSON) RawJSON() string { +func (r identityProviderAccessOIDCConfigJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessGoogleApps struct { +type IdentityProviderAccessOkta struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessGoogleAppsConfig `json:"config,required"` + Config IdentityProviderAccessOktaConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessGoogleAppsType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessGoogleAppsScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessGoogleAppsJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessOktaJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessGoogleAppsJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessGoogleApps] -type zeroTrustIdentityProvidersAccessGoogleAppsJSON struct { +// identityProviderAccessOktaJSON contains the JSON metadata for the struct +// [IdentityProviderAccessOkta] +type identityProviderAccessOktaJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -1043,22 +965,22 @@ type zeroTrustIdentityProvidersAccessGoogleAppsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessOkta) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessGoogleAppsJSON) RawJSON() string { +func (r identityProviderAccessOktaJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessGoogleApps) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessOkta) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain string `json:"apps_domain"` +type IdentityProviderAccessOktaConfig struct { + // Your okta authorization server id + AuthorizationServerID string `json:"authorization_server_id"` // Custom claims Claims []string `json:"claims"` // Your OAuth Client ID @@ -1066,125 +988,55 @@ type ZeroTrustIdentityProvidersAccessGoogleAppsConfig struct { // Your OAuth Client Secret ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProvidersAccessGoogleAppsConfigJSON `json:"-"` + EmailClaimName string `json:"email_claim_name"` + // Your okta account url + OktaAccount string `json:"okta_account"` + JSON identityProviderAccessOktaConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessGoogleAppsConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessGoogleAppsConfig] -type zeroTrustIdentityProvidersAccessGoogleAppsConfigJSON struct { - AppsDomain apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessGoogleAppsConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessGoogleAppsType string - -const ( - ZeroTrustIdentityProvidersAccessGoogleAppsTypeOnetimepin ZeroTrustIdentityProvidersAccessGoogleAppsType = "onetimepin" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeAzureAd ZeroTrustIdentityProvidersAccessGoogleAppsType = "azureAD" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeSaml ZeroTrustIdentityProvidersAccessGoogleAppsType = "saml" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeCentrify ZeroTrustIdentityProvidersAccessGoogleAppsType = "centrify" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeFacebook ZeroTrustIdentityProvidersAccessGoogleAppsType = "facebook" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeGitHub ZeroTrustIdentityProvidersAccessGoogleAppsType = "github" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeGoogleApps ZeroTrustIdentityProvidersAccessGoogleAppsType = "google-apps" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeGoogle ZeroTrustIdentityProvidersAccessGoogleAppsType = "google" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeLinkedin ZeroTrustIdentityProvidersAccessGoogleAppsType = "linkedin" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeOidc ZeroTrustIdentityProvidersAccessGoogleAppsType = "oidc" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeOkta ZeroTrustIdentityProvidersAccessGoogleAppsType = "okta" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeOnelogin ZeroTrustIdentityProvidersAccessGoogleAppsType = "onelogin" - ZeroTrustIdentityProvidersAccessGoogleAppsTypePingone ZeroTrustIdentityProvidersAccessGoogleAppsType = "pingone" - ZeroTrustIdentityProvidersAccessGoogleAppsTypeYandex ZeroTrustIdentityProvidersAccessGoogleAppsType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessGoogleAppsType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessGoogleAppsTypeOnetimepin, ZeroTrustIdentityProvidersAccessGoogleAppsTypeAzureAd, ZeroTrustIdentityProvidersAccessGoogleAppsTypeSaml, ZeroTrustIdentityProvidersAccessGoogleAppsTypeCentrify, ZeroTrustIdentityProvidersAccessGoogleAppsTypeFacebook, ZeroTrustIdentityProvidersAccessGoogleAppsTypeGitHub, ZeroTrustIdentityProvidersAccessGoogleAppsTypeGoogleApps, ZeroTrustIdentityProvidersAccessGoogleAppsTypeGoogle, ZeroTrustIdentityProvidersAccessGoogleAppsTypeLinkedin, ZeroTrustIdentityProvidersAccessGoogleAppsTypeOidc, ZeroTrustIdentityProvidersAccessGoogleAppsTypeOkta, ZeroTrustIdentityProvidersAccessGoogleAppsTypeOnelogin, ZeroTrustIdentityProvidersAccessGoogleAppsTypePingone, ZeroTrustIdentityProvidersAccessGoogleAppsTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessGoogleAppsScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessGoogleAppsScimConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProvidersAccessGoogleAppsScimConfig] -type zeroTrustIdentityProvidersAccessGoogleAppsScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +// identityProviderAccessOktaConfigJSON contains the JSON metadata for the struct +// [IdentityProviderAccessOktaConfig] +type identityProviderAccessOktaConfigJSON struct { + AuthorizationServerID apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OktaAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessGoogleAppsScimConfigJSON) RawJSON() string { +func (r identityProviderAccessOktaConfigJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessLinkedin struct { +type IdentityProviderAccessOnelogin struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessLinkedinConfig `json:"config,required"` + Config IdentityProviderAccessOneloginConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessLinkedinType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessLinkedinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessLinkedinJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessOneloginJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessLinkedinJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessLinkedin] -type zeroTrustIdentityProvidersAccessLinkedinJSON struct { +// identityProviderAccessOneloginJSON contains the JSON metadata for the struct +// [IdentityProviderAccessOnelogin] +type identityProviderAccessOneloginJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -1194,139 +1046,75 @@ type zeroTrustIdentityProvidersAccessLinkedinJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessLinkedin) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessOnelogin) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessLinkedinJSON) RawJSON() string { +func (r identityProviderAccessOneloginJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessLinkedin) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessOnelogin) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessLinkedinConfig struct { +type IdentityProviderAccessOneloginConfig struct { + // Custom claims + Claims []string `json:"claims"` // Your OAuth Client ID ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProvidersAccessLinkedinConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessLinkedinConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessLinkedinConfig] -type zeroTrustIdentityProvidersAccessLinkedinConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessLinkedinConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessLinkedinType string - -const ( - ZeroTrustIdentityProvidersAccessLinkedinTypeOnetimepin ZeroTrustIdentityProvidersAccessLinkedinType = "onetimepin" - ZeroTrustIdentityProvidersAccessLinkedinTypeAzureAd ZeroTrustIdentityProvidersAccessLinkedinType = "azureAD" - ZeroTrustIdentityProvidersAccessLinkedinTypeSaml ZeroTrustIdentityProvidersAccessLinkedinType = "saml" - ZeroTrustIdentityProvidersAccessLinkedinTypeCentrify ZeroTrustIdentityProvidersAccessLinkedinType = "centrify" - ZeroTrustIdentityProvidersAccessLinkedinTypeFacebook ZeroTrustIdentityProvidersAccessLinkedinType = "facebook" - ZeroTrustIdentityProvidersAccessLinkedinTypeGitHub ZeroTrustIdentityProvidersAccessLinkedinType = "github" - ZeroTrustIdentityProvidersAccessLinkedinTypeGoogleApps ZeroTrustIdentityProvidersAccessLinkedinType = "google-apps" - ZeroTrustIdentityProvidersAccessLinkedinTypeGoogle ZeroTrustIdentityProvidersAccessLinkedinType = "google" - ZeroTrustIdentityProvidersAccessLinkedinTypeLinkedin ZeroTrustIdentityProvidersAccessLinkedinType = "linkedin" - ZeroTrustIdentityProvidersAccessLinkedinTypeOidc ZeroTrustIdentityProvidersAccessLinkedinType = "oidc" - ZeroTrustIdentityProvidersAccessLinkedinTypeOkta ZeroTrustIdentityProvidersAccessLinkedinType = "okta" - ZeroTrustIdentityProvidersAccessLinkedinTypeOnelogin ZeroTrustIdentityProvidersAccessLinkedinType = "onelogin" - ZeroTrustIdentityProvidersAccessLinkedinTypePingone ZeroTrustIdentityProvidersAccessLinkedinType = "pingone" - ZeroTrustIdentityProvidersAccessLinkedinTypeYandex ZeroTrustIdentityProvidersAccessLinkedinType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessLinkedinType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessLinkedinTypeOnetimepin, ZeroTrustIdentityProvidersAccessLinkedinTypeAzureAd, ZeroTrustIdentityProvidersAccessLinkedinTypeSaml, ZeroTrustIdentityProvidersAccessLinkedinTypeCentrify, ZeroTrustIdentityProvidersAccessLinkedinTypeFacebook, ZeroTrustIdentityProvidersAccessLinkedinTypeGitHub, ZeroTrustIdentityProvidersAccessLinkedinTypeGoogleApps, ZeroTrustIdentityProvidersAccessLinkedinTypeGoogle, ZeroTrustIdentityProvidersAccessLinkedinTypeLinkedin, ZeroTrustIdentityProvidersAccessLinkedinTypeOidc, ZeroTrustIdentityProvidersAccessLinkedinTypeOkta, ZeroTrustIdentityProvidersAccessLinkedinTypeOnelogin, ZeroTrustIdentityProvidersAccessLinkedinTypePingone, ZeroTrustIdentityProvidersAccessLinkedinTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessLinkedinScimConfigJSON `json:"-"` + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Your OneLogin account url + OneloginAccount string `json:"onelogin_account"` + JSON identityProviderAccessOneloginConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessLinkedinScimConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProvidersAccessLinkedinScimConfig] -type zeroTrustIdentityProvidersAccessLinkedinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +// identityProviderAccessOneloginConfigJSON contains the JSON metadata for the +// struct [IdentityProviderAccessOneloginConfig] +type identityProviderAccessOneloginConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OneloginAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessLinkedinScimConfigJSON) RawJSON() string { +func (r identityProviderAccessOneloginConfigJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessOidc struct { +type IdentityProviderAccessPingone struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessOidcConfig `json:"config,required"` + Config IdentityProviderAccessPingoneConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessOidcType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessOidcScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessOidcJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessPingoneJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessOidcJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessOidc] -type zeroTrustIdentityProvidersAccessOidcJSON struct { +// identityProviderAccessPingoneJSON contains the JSON metadata for the struct +// [IdentityProviderAccessPingone] +type identityProviderAccessPingoneJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -1336,24 +1124,20 @@ type zeroTrustIdentityProvidersAccessOidcJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessOidc) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessPingone) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessOidcJSON) RawJSON() string { +func (r identityProviderAccessPingoneJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessOidc) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessPingone) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessOidcConfig struct { - // The authorization_endpoint URL of your IdP - AuthURL string `json:"auth_url"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CERTsURL string `json:"certs_url"` +type IdentityProviderAccessPingoneConfig struct { // Custom claims Claims []string `json:"claims"` // Your OAuth Client ID @@ -1362,131 +1146,53 @@ type ZeroTrustIdentityProvidersAccessOidcConfig struct { ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. EmailClaimName string `json:"email_claim_name"` - // OAuth scopes - Scopes []string `json:"scopes"` - // The token_endpoint URL of your IdP - TokenURL string `json:"token_url"` - JSON zeroTrustIdentityProvidersAccessOidcConfigJSON `json:"-"` + // Your PingOne environment identifier + PingEnvID string `json:"ping_env_id"` + JSON identityProviderAccessPingoneConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessOidcConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessOidcConfig] -type zeroTrustIdentityProvidersAccessOidcConfigJSON struct { - AuthURL apijson.Field - CERTsURL apijson.Field +// identityProviderAccessPingoneConfigJSON contains the JSON metadata for the +// struct [IdentityProviderAccessPingoneConfig] +type identityProviderAccessPingoneConfigJSON struct { Claims apijson.Field ClientID apijson.Field ClientSecret apijson.Field EmailClaimName apijson.Field - Scopes apijson.Field - TokenURL apijson.Field + PingEnvID apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessOidcConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessOidcType string - -const ( - ZeroTrustIdentityProvidersAccessOidcTypeOnetimepin ZeroTrustIdentityProvidersAccessOidcType = "onetimepin" - ZeroTrustIdentityProvidersAccessOidcTypeAzureAd ZeroTrustIdentityProvidersAccessOidcType = "azureAD" - ZeroTrustIdentityProvidersAccessOidcTypeSaml ZeroTrustIdentityProvidersAccessOidcType = "saml" - ZeroTrustIdentityProvidersAccessOidcTypeCentrify ZeroTrustIdentityProvidersAccessOidcType = "centrify" - ZeroTrustIdentityProvidersAccessOidcTypeFacebook ZeroTrustIdentityProvidersAccessOidcType = "facebook" - ZeroTrustIdentityProvidersAccessOidcTypeGitHub ZeroTrustIdentityProvidersAccessOidcType = "github" - ZeroTrustIdentityProvidersAccessOidcTypeGoogleApps ZeroTrustIdentityProvidersAccessOidcType = "google-apps" - ZeroTrustIdentityProvidersAccessOidcTypeGoogle ZeroTrustIdentityProvidersAccessOidcType = "google" - ZeroTrustIdentityProvidersAccessOidcTypeLinkedin ZeroTrustIdentityProvidersAccessOidcType = "linkedin" - ZeroTrustIdentityProvidersAccessOidcTypeOidc ZeroTrustIdentityProvidersAccessOidcType = "oidc" - ZeroTrustIdentityProvidersAccessOidcTypeOkta ZeroTrustIdentityProvidersAccessOidcType = "okta" - ZeroTrustIdentityProvidersAccessOidcTypeOnelogin ZeroTrustIdentityProvidersAccessOidcType = "onelogin" - ZeroTrustIdentityProvidersAccessOidcTypePingone ZeroTrustIdentityProvidersAccessOidcType = "pingone" - ZeroTrustIdentityProvidersAccessOidcTypeYandex ZeroTrustIdentityProvidersAccessOidcType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessOidcType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessOidcTypeOnetimepin, ZeroTrustIdentityProvidersAccessOidcTypeAzureAd, ZeroTrustIdentityProvidersAccessOidcTypeSaml, ZeroTrustIdentityProvidersAccessOidcTypeCentrify, ZeroTrustIdentityProvidersAccessOidcTypeFacebook, ZeroTrustIdentityProvidersAccessOidcTypeGitHub, ZeroTrustIdentityProvidersAccessOidcTypeGoogleApps, ZeroTrustIdentityProvidersAccessOidcTypeGoogle, ZeroTrustIdentityProvidersAccessOidcTypeLinkedin, ZeroTrustIdentityProvidersAccessOidcTypeOidc, ZeroTrustIdentityProvidersAccessOidcTypeOkta, ZeroTrustIdentityProvidersAccessOidcTypeOnelogin, ZeroTrustIdentityProvidersAccessOidcTypePingone, ZeroTrustIdentityProvidersAccessOidcTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessOidcScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessOidcScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessOidcScimConfig] -type zeroTrustIdentityProvidersAccessOidcScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessOidcScimConfigJSON) RawJSON() string { +func (r identityProviderAccessPingoneConfigJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessOkta struct { +type IdentityProviderAccessSAML struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessOktaConfig `json:"config,required"` + Config IdentityProviderAccessSAMLConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessOktaType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessOktaScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessOktaJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessSAMLJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessOktaJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessOkta] -type zeroTrustIdentityProvidersAccessOktaJSON struct { +// identityProviderAccessSAMLJSON contains the JSON metadata for the struct +// [IdentityProviderAccessSAML] +type identityProviderAccessSAMLJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -1496,151 +1202,109 @@ type zeroTrustIdentityProvidersAccessOktaJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessOkta) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessSAML) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessOktaJSON) RawJSON() string { +func (r identityProviderAccessSAMLJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessOkta) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessSAML) implementsZeroTrustIdentityProvider() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessOktaConfig struct { - // Your okta authorization server id - AuthorizationServerID string `json:"authorization_server_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your okta account url - OktaAccount string `json:"okta_account"` - JSON zeroTrustIdentityProvidersAccessOktaConfigJSON `json:"-"` +type IdentityProviderAccessSAMLConfig struct { + // A list of SAML attribute names that will be added to your signed JWT token and + // can be used in SAML policy rules. + Attributes []string `json:"attributes"` + // The attribute name for email in the SAML response. + EmailAttributeName string `json:"email_attribute_name"` + // Add a list of attribute names that will be returned in the response header from + // the Access callback. + HeaderAttributes []IdentityProviderAccessSAMLConfigHeaderAttribute `json:"header_attributes"` + // X509 certificate to verify the signature in the SAML authentication response + IDPPublicCERTs []string `json:"idp_public_certs"` + // IdP Entity ID or Issuer URL + IssuerURL string `json:"issuer_url"` + // Sign the SAML authentication request with Access credentials. To verify the + // signature, use the public key from the Access certs endpoints. + SignRequest bool `json:"sign_request"` + // URL to send the SAML authentication requests to + SSOTargetURL string `json:"sso_target_url"` + JSON identityProviderAccessSAMLConfigJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessOktaConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessOktaConfig] -type zeroTrustIdentityProvidersAccessOktaConfigJSON struct { - AuthorizationServerID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OktaAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field +// identityProviderAccessSAMLConfigJSON contains the JSON metadata for the struct +// [IdentityProviderAccessSAMLConfig] +type identityProviderAccessSAMLConfigJSON struct { + Attributes apijson.Field + EmailAttributeName apijson.Field + HeaderAttributes apijson.Field + IDPPublicCERTs apijson.Field + IssuerURL apijson.Field + SignRequest apijson.Field + SSOTargetURL apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessSAMLConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessOktaConfigJSON) RawJSON() string { +func (r identityProviderAccessSAMLConfigJSON) RawJSON() string { return r.raw } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessOktaType string +type IdentityProviderAccessSAMLConfigHeaderAttribute struct { + // attribute name from the IDP + AttributeName string `json:"attribute_name"` + // header that will be added on the request to the origin + HeaderName string `json:"header_name"` + JSON identityProviderAccessSAMLConfigHeaderAttributeJSON `json:"-"` +} -const ( - ZeroTrustIdentityProvidersAccessOktaTypeOnetimepin ZeroTrustIdentityProvidersAccessOktaType = "onetimepin" - ZeroTrustIdentityProvidersAccessOktaTypeAzureAd ZeroTrustIdentityProvidersAccessOktaType = "azureAD" - ZeroTrustIdentityProvidersAccessOktaTypeSaml ZeroTrustIdentityProvidersAccessOktaType = "saml" - ZeroTrustIdentityProvidersAccessOktaTypeCentrify ZeroTrustIdentityProvidersAccessOktaType = "centrify" - ZeroTrustIdentityProvidersAccessOktaTypeFacebook ZeroTrustIdentityProvidersAccessOktaType = "facebook" - ZeroTrustIdentityProvidersAccessOktaTypeGitHub ZeroTrustIdentityProvidersAccessOktaType = "github" - ZeroTrustIdentityProvidersAccessOktaTypeGoogleApps ZeroTrustIdentityProvidersAccessOktaType = "google-apps" - ZeroTrustIdentityProvidersAccessOktaTypeGoogle ZeroTrustIdentityProvidersAccessOktaType = "google" - ZeroTrustIdentityProvidersAccessOktaTypeLinkedin ZeroTrustIdentityProvidersAccessOktaType = "linkedin" - ZeroTrustIdentityProvidersAccessOktaTypeOidc ZeroTrustIdentityProvidersAccessOktaType = "oidc" - ZeroTrustIdentityProvidersAccessOktaTypeOkta ZeroTrustIdentityProvidersAccessOktaType = "okta" - ZeroTrustIdentityProvidersAccessOktaTypeOnelogin ZeroTrustIdentityProvidersAccessOktaType = "onelogin" - ZeroTrustIdentityProvidersAccessOktaTypePingone ZeroTrustIdentityProvidersAccessOktaType = "pingone" - ZeroTrustIdentityProvidersAccessOktaTypeYandex ZeroTrustIdentityProvidersAccessOktaType = "yandex" -) +// identityProviderAccessSAMLConfigHeaderAttributeJSON contains the JSON metadata +// for the struct [IdentityProviderAccessSAMLConfigHeaderAttribute] +type identityProviderAccessSAMLConfigHeaderAttributeJSON struct { + AttributeName apijson.Field + HeaderName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} -func (r ZeroTrustIdentityProvidersAccessOktaType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessOktaTypeOnetimepin, ZeroTrustIdentityProvidersAccessOktaTypeAzureAd, ZeroTrustIdentityProvidersAccessOktaTypeSaml, ZeroTrustIdentityProvidersAccessOktaTypeCentrify, ZeroTrustIdentityProvidersAccessOktaTypeFacebook, ZeroTrustIdentityProvidersAccessOktaTypeGitHub, ZeroTrustIdentityProvidersAccessOktaTypeGoogleApps, ZeroTrustIdentityProvidersAccessOktaTypeGoogle, ZeroTrustIdentityProvidersAccessOktaTypeLinkedin, ZeroTrustIdentityProvidersAccessOktaTypeOidc, ZeroTrustIdentityProvidersAccessOktaTypeOkta, ZeroTrustIdentityProvidersAccessOktaTypeOnelogin, ZeroTrustIdentityProvidersAccessOktaTypePingone, ZeroTrustIdentityProvidersAccessOktaTypeYandex: - return true - } - return false +func (r *IdentityProviderAccessSAMLConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessOktaScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessOktaScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessOktaScimConfig] -type zeroTrustIdentityProvidersAccessOktaScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessOktaScimConfigJSON) RawJSON() string { +func (r identityProviderAccessSAMLConfigHeaderAttributeJSON) RawJSON() string { return r.raw } -type ZeroTrustIdentityProvidersAccessOnelogin struct { +type IdentityProviderAccessYandex struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessOneloginConfig `json:"config,required"` + Config GenericOAuthConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessOneloginType `json:"type,required"` + Type IdentityProviderType `json:"type,required"` // UUID ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessOneloginScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessOneloginJSON `json:"-"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessYandexJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessOneloginJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessOnelogin] -type zeroTrustIdentityProvidersAccessOneloginJSON struct { +// identityProviderAccessYandexJSON contains the JSON metadata for the struct +// [IdentityProviderAccessYandex] +type identityProviderAccessYandexJSON struct { Config apijson.Field Name apijson.Field Type apijson.Field @@ -1650,4046 +1314,250 @@ type zeroTrustIdentityProvidersAccessOneloginJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessOnelogin) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessYandex) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessOneloginJSON) RawJSON() string { +func (r identityProviderAccessYandexJSON) RawJSON() string { return r.raw } -func (r ZeroTrustIdentityProvidersAccessOnelogin) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessYandex) implementsZeroTrustIdentityProvider() {} -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessOneloginConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your OneLogin account url - OneloginAccount string `json:"onelogin_account"` - JSON zeroTrustIdentityProvidersAccessOneloginConfigJSON `json:"-"` +type IdentityProviderAccessOnetimepin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config interface{} `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderAccessOnetimepinJSON `json:"-"` } -// zeroTrustIdentityProvidersAccessOneloginConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessOneloginConfig] -type zeroTrustIdentityProvidersAccessOneloginConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OneloginAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field +// identityProviderAccessOnetimepinJSON contains the JSON metadata for the struct +// [IdentityProviderAccessOnetimepin] +type identityProviderAccessOnetimepinJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *ZeroTrustIdentityProvidersAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { +func (r *IdentityProviderAccessOnetimepin) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustIdentityProvidersAccessOneloginConfigJSON) RawJSON() string { +func (r identityProviderAccessOnetimepinJSON) RawJSON() string { return r.raw } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessOneloginType string - -const ( - ZeroTrustIdentityProvidersAccessOneloginTypeOnetimepin ZeroTrustIdentityProvidersAccessOneloginType = "onetimepin" - ZeroTrustIdentityProvidersAccessOneloginTypeAzureAd ZeroTrustIdentityProvidersAccessOneloginType = "azureAD" - ZeroTrustIdentityProvidersAccessOneloginTypeSaml ZeroTrustIdentityProvidersAccessOneloginType = "saml" - ZeroTrustIdentityProvidersAccessOneloginTypeCentrify ZeroTrustIdentityProvidersAccessOneloginType = "centrify" - ZeroTrustIdentityProvidersAccessOneloginTypeFacebook ZeroTrustIdentityProvidersAccessOneloginType = "facebook" - ZeroTrustIdentityProvidersAccessOneloginTypeGitHub ZeroTrustIdentityProvidersAccessOneloginType = "github" - ZeroTrustIdentityProvidersAccessOneloginTypeGoogleApps ZeroTrustIdentityProvidersAccessOneloginType = "google-apps" - ZeroTrustIdentityProvidersAccessOneloginTypeGoogle ZeroTrustIdentityProvidersAccessOneloginType = "google" - ZeroTrustIdentityProvidersAccessOneloginTypeLinkedin ZeroTrustIdentityProvidersAccessOneloginType = "linkedin" - ZeroTrustIdentityProvidersAccessOneloginTypeOidc ZeroTrustIdentityProvidersAccessOneloginType = "oidc" - ZeroTrustIdentityProvidersAccessOneloginTypeOkta ZeroTrustIdentityProvidersAccessOneloginType = "okta" - ZeroTrustIdentityProvidersAccessOneloginTypeOnelogin ZeroTrustIdentityProvidersAccessOneloginType = "onelogin" - ZeroTrustIdentityProvidersAccessOneloginTypePingone ZeroTrustIdentityProvidersAccessOneloginType = "pingone" - ZeroTrustIdentityProvidersAccessOneloginTypeYandex ZeroTrustIdentityProvidersAccessOneloginType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessOneloginType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessOneloginTypeOnetimepin, ZeroTrustIdentityProvidersAccessOneloginTypeAzureAd, ZeroTrustIdentityProvidersAccessOneloginTypeSaml, ZeroTrustIdentityProvidersAccessOneloginTypeCentrify, ZeroTrustIdentityProvidersAccessOneloginTypeFacebook, ZeroTrustIdentityProvidersAccessOneloginTypeGitHub, ZeroTrustIdentityProvidersAccessOneloginTypeGoogleApps, ZeroTrustIdentityProvidersAccessOneloginTypeGoogle, ZeroTrustIdentityProvidersAccessOneloginTypeLinkedin, ZeroTrustIdentityProvidersAccessOneloginTypeOidc, ZeroTrustIdentityProvidersAccessOneloginTypeOkta, ZeroTrustIdentityProvidersAccessOneloginTypeOnelogin, ZeroTrustIdentityProvidersAccessOneloginTypePingone, ZeroTrustIdentityProvidersAccessOneloginTypeYandex: - return true - } - return false -} +func (r IdentityProviderAccessOnetimepin) implementsZeroTrustIdentityProvider() {} -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessOneloginScimConfigJSON `json:"-"` +type IdentityProviderParam struct { + Config param.Field[interface{}] `json:"config"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` } -// zeroTrustIdentityProvidersAccessOneloginScimConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProvidersAccessOneloginScimConfig] -type zeroTrustIdentityProvidersAccessOneloginScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r IdentityProviderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *ZeroTrustIdentityProvidersAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +func (r IdentityProviderParam) implementsZeroTrustIdentityProviderUnionParam() {} -func (r zeroTrustIdentityProvidersAccessOneloginScimConfigJSON) RawJSON() string { - return r.raw +// Satisfied by [zero_trust.AzureADParam], +// [zero_trust.IdentityProviderAccessCentrifyParam], +// [zero_trust.IdentityProviderAccessFacebookParam], +// [zero_trust.IdentityProviderAccessGitHubParam], +// [zero_trust.IdentityProviderAccessGoogleParam], +// [zero_trust.IdentityProviderAccessGoogleAppsParam], +// [zero_trust.IdentityProviderAccessLinkedinParam], +// [zero_trust.IdentityProviderAccessOIDCParam], +// [zero_trust.IdentityProviderAccessOktaParam], +// [zero_trust.IdentityProviderAccessOneloginParam], +// [zero_trust.IdentityProviderAccessPingoneParam], +// [zero_trust.IdentityProviderAccessSAMLParam], +// [zero_trust.IdentityProviderAccessYandexParam], +// [zero_trust.IdentityProviderAccessOnetimepinParam], [IdentityProviderParam]. +type IdentityProviderUnionParam interface { + implementsZeroTrustIdentityProviderUnionParam() } -type ZeroTrustIdentityProvidersAccessPingone struct { +type IdentityProviderAccessCentrifyParam struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessPingoneConfig `json:"config,required"` + Config param.Field[IdentityProviderAccessCentrifyConfigParam] `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` + Name param.Field[string] `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessPingoneType `json:"type,required"` - // UUID - ID string `json:"id"` + Type param.Field[IdentityProviderType] `json:"type,required"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessPingoneScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessPingoneJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessPingoneJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessPingone] -type zeroTrustIdentityProvidersAccessPingoneJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessPingone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r zeroTrustIdentityProvidersAccessPingoneJSON) RawJSON() string { - return r.raw +func (r IdentityProviderAccessCentrifyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r ZeroTrustIdentityProvidersAccessPingone) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessCentrifyParam) implementsZeroTrustIdentityProviderUnionParam() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessPingoneConfig struct { +type IdentityProviderAccessCentrifyConfigParam struct { + // Your centrify account url + CentrifyAccount param.Field[string] `json:"centrify_account"` + // Your centrify app id + CentrifyAppID param.Field[string] `json:"centrify_app_id"` // Custom claims - Claims []string `json:"claims"` + Claims param.Field[[]string] `json:"claims"` // Your OAuth Client ID - ClientID string `json:"client_id"` + ClientID param.Field[string] `json:"client_id"` // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` + ClientSecret param.Field[string] `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your PingOne environment identifier - PingEnvID string `json:"ping_env_id"` - JSON zeroTrustIdentityProvidersAccessPingoneConfigJSON `json:"-"` + EmailClaimName param.Field[string] `json:"email_claim_name"` } -// zeroTrustIdentityProvidersAccessPingoneConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessPingoneConfig] -type zeroTrustIdentityProvidersAccessPingoneConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - PingEnvID apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r IdentityProviderAccessCentrifyConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *ZeroTrustIdentityProvidersAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type IdentityProviderAccessFacebookParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[GenericOAuthConfigParam] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r zeroTrustIdentityProvidersAccessPingoneConfigJSON) RawJSON() string { - return r.raw +func (r IdentityProviderAccessFacebookParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessPingoneType string +func (r IdentityProviderAccessFacebookParam) implementsZeroTrustIdentityProviderUnionParam() {} -const ( - ZeroTrustIdentityProvidersAccessPingoneTypeOnetimepin ZeroTrustIdentityProvidersAccessPingoneType = "onetimepin" - ZeroTrustIdentityProvidersAccessPingoneTypeAzureAd ZeroTrustIdentityProvidersAccessPingoneType = "azureAD" - ZeroTrustIdentityProvidersAccessPingoneTypeSaml ZeroTrustIdentityProvidersAccessPingoneType = "saml" - ZeroTrustIdentityProvidersAccessPingoneTypeCentrify ZeroTrustIdentityProvidersAccessPingoneType = "centrify" - ZeroTrustIdentityProvidersAccessPingoneTypeFacebook ZeroTrustIdentityProvidersAccessPingoneType = "facebook" - ZeroTrustIdentityProvidersAccessPingoneTypeGitHub ZeroTrustIdentityProvidersAccessPingoneType = "github" - ZeroTrustIdentityProvidersAccessPingoneTypeGoogleApps ZeroTrustIdentityProvidersAccessPingoneType = "google-apps" - ZeroTrustIdentityProvidersAccessPingoneTypeGoogle ZeroTrustIdentityProvidersAccessPingoneType = "google" - ZeroTrustIdentityProvidersAccessPingoneTypeLinkedin ZeroTrustIdentityProvidersAccessPingoneType = "linkedin" - ZeroTrustIdentityProvidersAccessPingoneTypeOidc ZeroTrustIdentityProvidersAccessPingoneType = "oidc" - ZeroTrustIdentityProvidersAccessPingoneTypeOkta ZeroTrustIdentityProvidersAccessPingoneType = "okta" - ZeroTrustIdentityProvidersAccessPingoneTypeOnelogin ZeroTrustIdentityProvidersAccessPingoneType = "onelogin" - ZeroTrustIdentityProvidersAccessPingoneTypePingone ZeroTrustIdentityProvidersAccessPingoneType = "pingone" - ZeroTrustIdentityProvidersAccessPingoneTypeYandex ZeroTrustIdentityProvidersAccessPingoneType = "yandex" -) +type IdentityProviderAccessGitHubParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[GenericOAuthConfigParam] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` +} -func (r ZeroTrustIdentityProvidersAccessPingoneType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessPingoneTypeOnetimepin, ZeroTrustIdentityProvidersAccessPingoneTypeAzureAd, ZeroTrustIdentityProvidersAccessPingoneTypeSaml, ZeroTrustIdentityProvidersAccessPingoneTypeCentrify, ZeroTrustIdentityProvidersAccessPingoneTypeFacebook, ZeroTrustIdentityProvidersAccessPingoneTypeGitHub, ZeroTrustIdentityProvidersAccessPingoneTypeGoogleApps, ZeroTrustIdentityProvidersAccessPingoneTypeGoogle, ZeroTrustIdentityProvidersAccessPingoneTypeLinkedin, ZeroTrustIdentityProvidersAccessPingoneTypeOidc, ZeroTrustIdentityProvidersAccessPingoneTypeOkta, ZeroTrustIdentityProvidersAccessPingoneTypeOnelogin, ZeroTrustIdentityProvidersAccessPingoneTypePingone, ZeroTrustIdentityProvidersAccessPingoneTypeYandex: - return true - } - return false +func (r IdentityProviderAccessGitHubParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessPingoneScimConfigJSON `json:"-"` +func (r IdentityProviderAccessGitHubParam) implementsZeroTrustIdentityProviderUnionParam() {} + +type IdentityProviderAccessGoogleParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[IdentityProviderAccessGoogleConfigParam] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -// zeroTrustIdentityProvidersAccessPingoneScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessPingoneScimConfig] -type zeroTrustIdentityProvidersAccessPingoneScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r IdentityProviderAccessGoogleParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *ZeroTrustIdentityProvidersAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r IdentityProviderAccessGoogleParam) implementsZeroTrustIdentityProviderUnionParam() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderAccessGoogleConfigParam struct { + // Custom claims + Claims param.Field[[]string] `json:"claims"` + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName param.Field[string] `json:"email_claim_name"` } -func (r zeroTrustIdentityProvidersAccessPingoneScimConfigJSON) RawJSON() string { - return r.raw +func (r IdentityProviderAccessGoogleConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type ZeroTrustIdentityProvidersAccessSaml struct { +type IdentityProviderAccessGoogleAppsParam struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessSamlConfig `json:"config,required"` + Config param.Field[IdentityProviderAccessGoogleAppsConfigParam] `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` + Name param.Field[string] `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessSamlType `json:"type,required"` - // UUID - ID string `json:"id"` + Type param.Field[IdentityProviderType] `json:"type,required"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessSamlScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessSamlJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessSamlJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessSaml] -type zeroTrustIdentityProvidersAccessSamlJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r zeroTrustIdentityProvidersAccessSamlJSON) RawJSON() string { - return r.raw +func (r IdentityProviderAccessGoogleAppsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r ZeroTrustIdentityProvidersAccessSaml) implementsZeroTrustZeroTrustIdentityProviders() {} +func (r IdentityProviderAccessGoogleAppsParam) implementsZeroTrustIdentityProviderUnionParam() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessSamlConfig struct { - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes []string `json:"attributes"` - // The attribute name for email in the SAML response. - EmailAttributeName string `json:"email_attribute_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes []ZeroTrustIdentityProvidersAccessSamlConfigHeaderAttribute `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IDPPublicCERTs []string `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL string `json:"issuer_url"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest bool `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL string `json:"sso_target_url"` - JSON zeroTrustIdentityProvidersAccessSamlConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessSamlConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessSamlConfig] -type zeroTrustIdentityProvidersAccessSamlConfigJSON struct { - Attributes apijson.Field - EmailAttributeName apijson.Field - HeaderAttributes apijson.Field - IDPPublicCERTs apijson.Field - IssuerURL apijson.Field - SignRequest apijson.Field - SSOTargetURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessSamlConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProvidersAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName string `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName string `json:"header_name"` - JSON zeroTrustIdentityProvidersAccessSamlConfigHeaderAttributeJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessSamlConfigHeaderAttributeJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProvidersAccessSamlConfigHeaderAttribute] -type zeroTrustIdentityProvidersAccessSamlConfigHeaderAttributeJSON struct { - AttributeName apijson.Field - HeaderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessSamlConfigHeaderAttributeJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessSamlType string - -const ( - ZeroTrustIdentityProvidersAccessSamlTypeOnetimepin ZeroTrustIdentityProvidersAccessSamlType = "onetimepin" - ZeroTrustIdentityProvidersAccessSamlTypeAzureAd ZeroTrustIdentityProvidersAccessSamlType = "azureAD" - ZeroTrustIdentityProvidersAccessSamlTypeSaml ZeroTrustIdentityProvidersAccessSamlType = "saml" - ZeroTrustIdentityProvidersAccessSamlTypeCentrify ZeroTrustIdentityProvidersAccessSamlType = "centrify" - ZeroTrustIdentityProvidersAccessSamlTypeFacebook ZeroTrustIdentityProvidersAccessSamlType = "facebook" - ZeroTrustIdentityProvidersAccessSamlTypeGitHub ZeroTrustIdentityProvidersAccessSamlType = "github" - ZeroTrustIdentityProvidersAccessSamlTypeGoogleApps ZeroTrustIdentityProvidersAccessSamlType = "google-apps" - ZeroTrustIdentityProvidersAccessSamlTypeGoogle ZeroTrustIdentityProvidersAccessSamlType = "google" - ZeroTrustIdentityProvidersAccessSamlTypeLinkedin ZeroTrustIdentityProvidersAccessSamlType = "linkedin" - ZeroTrustIdentityProvidersAccessSamlTypeOidc ZeroTrustIdentityProvidersAccessSamlType = "oidc" - ZeroTrustIdentityProvidersAccessSamlTypeOkta ZeroTrustIdentityProvidersAccessSamlType = "okta" - ZeroTrustIdentityProvidersAccessSamlTypeOnelogin ZeroTrustIdentityProvidersAccessSamlType = "onelogin" - ZeroTrustIdentityProvidersAccessSamlTypePingone ZeroTrustIdentityProvidersAccessSamlType = "pingone" - ZeroTrustIdentityProvidersAccessSamlTypeYandex ZeroTrustIdentityProvidersAccessSamlType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessSamlType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessSamlTypeOnetimepin, ZeroTrustIdentityProvidersAccessSamlTypeAzureAd, ZeroTrustIdentityProvidersAccessSamlTypeSaml, ZeroTrustIdentityProvidersAccessSamlTypeCentrify, ZeroTrustIdentityProvidersAccessSamlTypeFacebook, ZeroTrustIdentityProvidersAccessSamlTypeGitHub, ZeroTrustIdentityProvidersAccessSamlTypeGoogleApps, ZeroTrustIdentityProvidersAccessSamlTypeGoogle, ZeroTrustIdentityProvidersAccessSamlTypeLinkedin, ZeroTrustIdentityProvidersAccessSamlTypeOidc, ZeroTrustIdentityProvidersAccessSamlTypeOkta, ZeroTrustIdentityProvidersAccessSamlTypeOnelogin, ZeroTrustIdentityProvidersAccessSamlTypePingone, ZeroTrustIdentityProvidersAccessSamlTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessSamlScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessSamlScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessSamlScimConfig] -type zeroTrustIdentityProvidersAccessSamlScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessSamlScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProvidersAccessYandex struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProvidersAccessYandexConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessYandexType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessYandexScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessYandexJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessYandexJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProvidersAccessYandex] -type zeroTrustIdentityProvidersAccessYandexJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessYandex) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessYandexJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProvidersAccessYandex) implementsZeroTrustZeroTrustIdentityProviders() {} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessYandexConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProvidersAccessYandexConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessYandexConfigJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessYandexConfig] -type zeroTrustIdentityProvidersAccessYandexConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessYandexConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessYandexType string - -const ( - ZeroTrustIdentityProvidersAccessYandexTypeOnetimepin ZeroTrustIdentityProvidersAccessYandexType = "onetimepin" - ZeroTrustIdentityProvidersAccessYandexTypeAzureAd ZeroTrustIdentityProvidersAccessYandexType = "azureAD" - ZeroTrustIdentityProvidersAccessYandexTypeSaml ZeroTrustIdentityProvidersAccessYandexType = "saml" - ZeroTrustIdentityProvidersAccessYandexTypeCentrify ZeroTrustIdentityProvidersAccessYandexType = "centrify" - ZeroTrustIdentityProvidersAccessYandexTypeFacebook ZeroTrustIdentityProvidersAccessYandexType = "facebook" - ZeroTrustIdentityProvidersAccessYandexTypeGitHub ZeroTrustIdentityProvidersAccessYandexType = "github" - ZeroTrustIdentityProvidersAccessYandexTypeGoogleApps ZeroTrustIdentityProvidersAccessYandexType = "google-apps" - ZeroTrustIdentityProvidersAccessYandexTypeGoogle ZeroTrustIdentityProvidersAccessYandexType = "google" - ZeroTrustIdentityProvidersAccessYandexTypeLinkedin ZeroTrustIdentityProvidersAccessYandexType = "linkedin" - ZeroTrustIdentityProvidersAccessYandexTypeOidc ZeroTrustIdentityProvidersAccessYandexType = "oidc" - ZeroTrustIdentityProvidersAccessYandexTypeOkta ZeroTrustIdentityProvidersAccessYandexType = "okta" - ZeroTrustIdentityProvidersAccessYandexTypeOnelogin ZeroTrustIdentityProvidersAccessYandexType = "onelogin" - ZeroTrustIdentityProvidersAccessYandexTypePingone ZeroTrustIdentityProvidersAccessYandexType = "pingone" - ZeroTrustIdentityProvidersAccessYandexTypeYandex ZeroTrustIdentityProvidersAccessYandexType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessYandexType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessYandexTypeOnetimepin, ZeroTrustIdentityProvidersAccessYandexTypeAzureAd, ZeroTrustIdentityProvidersAccessYandexTypeSaml, ZeroTrustIdentityProvidersAccessYandexTypeCentrify, ZeroTrustIdentityProvidersAccessYandexTypeFacebook, ZeroTrustIdentityProvidersAccessYandexTypeGitHub, ZeroTrustIdentityProvidersAccessYandexTypeGoogleApps, ZeroTrustIdentityProvidersAccessYandexTypeGoogle, ZeroTrustIdentityProvidersAccessYandexTypeLinkedin, ZeroTrustIdentityProvidersAccessYandexTypeOidc, ZeroTrustIdentityProvidersAccessYandexTypeOkta, ZeroTrustIdentityProvidersAccessYandexTypeOnelogin, ZeroTrustIdentityProvidersAccessYandexTypePingone, ZeroTrustIdentityProvidersAccessYandexTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessYandexScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessYandexScimConfigJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProvidersAccessYandexScimConfig] -type zeroTrustIdentityProvidersAccessYandexScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessYandexScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProvidersAccessOnetimepin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config interface{} `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProvidersAccessOnetimepinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProvidersAccessOnetimepinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProvidersAccessOnetimepinJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessOnetimepinJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProvidersAccessOnetimepin] -type zeroTrustIdentityProvidersAccessOnetimepinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessOnetimepin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessOnetimepinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProvidersAccessOnetimepin) implementsZeroTrustZeroTrustIdentityProviders() {} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProvidersAccessOnetimepinType string - -const ( - ZeroTrustIdentityProvidersAccessOnetimepinTypeOnetimepin ZeroTrustIdentityProvidersAccessOnetimepinType = "onetimepin" - ZeroTrustIdentityProvidersAccessOnetimepinTypeAzureAd ZeroTrustIdentityProvidersAccessOnetimepinType = "azureAD" - ZeroTrustIdentityProvidersAccessOnetimepinTypeSaml ZeroTrustIdentityProvidersAccessOnetimepinType = "saml" - ZeroTrustIdentityProvidersAccessOnetimepinTypeCentrify ZeroTrustIdentityProvidersAccessOnetimepinType = "centrify" - ZeroTrustIdentityProvidersAccessOnetimepinTypeFacebook ZeroTrustIdentityProvidersAccessOnetimepinType = "facebook" - ZeroTrustIdentityProvidersAccessOnetimepinTypeGitHub ZeroTrustIdentityProvidersAccessOnetimepinType = "github" - ZeroTrustIdentityProvidersAccessOnetimepinTypeGoogleApps ZeroTrustIdentityProvidersAccessOnetimepinType = "google-apps" - ZeroTrustIdentityProvidersAccessOnetimepinTypeGoogle ZeroTrustIdentityProvidersAccessOnetimepinType = "google" - ZeroTrustIdentityProvidersAccessOnetimepinTypeLinkedin ZeroTrustIdentityProvidersAccessOnetimepinType = "linkedin" - ZeroTrustIdentityProvidersAccessOnetimepinTypeOidc ZeroTrustIdentityProvidersAccessOnetimepinType = "oidc" - ZeroTrustIdentityProvidersAccessOnetimepinTypeOkta ZeroTrustIdentityProvidersAccessOnetimepinType = "okta" - ZeroTrustIdentityProvidersAccessOnetimepinTypeOnelogin ZeroTrustIdentityProvidersAccessOnetimepinType = "onelogin" - ZeroTrustIdentityProvidersAccessOnetimepinTypePingone ZeroTrustIdentityProvidersAccessOnetimepinType = "pingone" - ZeroTrustIdentityProvidersAccessOnetimepinTypeYandex ZeroTrustIdentityProvidersAccessOnetimepinType = "yandex" -) - -func (r ZeroTrustIdentityProvidersAccessOnetimepinType) IsKnown() bool { - switch r { - case ZeroTrustIdentityProvidersAccessOnetimepinTypeOnetimepin, ZeroTrustIdentityProvidersAccessOnetimepinTypeAzureAd, ZeroTrustIdentityProvidersAccessOnetimepinTypeSaml, ZeroTrustIdentityProvidersAccessOnetimepinTypeCentrify, ZeroTrustIdentityProvidersAccessOnetimepinTypeFacebook, ZeroTrustIdentityProvidersAccessOnetimepinTypeGitHub, ZeroTrustIdentityProvidersAccessOnetimepinTypeGoogleApps, ZeroTrustIdentityProvidersAccessOnetimepinTypeGoogle, ZeroTrustIdentityProvidersAccessOnetimepinTypeLinkedin, ZeroTrustIdentityProvidersAccessOnetimepinTypeOidc, ZeroTrustIdentityProvidersAccessOnetimepinTypeOkta, ZeroTrustIdentityProvidersAccessOnetimepinTypeOnelogin, ZeroTrustIdentityProvidersAccessOnetimepinTypePingone, ZeroTrustIdentityProvidersAccessOnetimepinTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProvidersAccessOnetimepinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProvidersAccessOnetimepinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProvidersAccessOnetimepinScimConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProvidersAccessOnetimepinScimConfig] -type zeroTrustIdentityProvidersAccessOnetimepinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProvidersAccessOnetimepinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProvidersAccessOnetimepinScimConfigJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [zero_trust.IdentityProviderListResponseAccessAzureAd], -// [zero_trust.IdentityProviderListResponseAccessCentrify], -// [zero_trust.IdentityProviderListResponseAccessFacebook], -// [zero_trust.IdentityProviderListResponseAccessGitHub], -// [zero_trust.IdentityProviderListResponseAccessGoogle], -// [zero_trust.IdentityProviderListResponseAccessGoogleApps], -// [zero_trust.IdentityProviderListResponseAccessLinkedin], -// [zero_trust.IdentityProviderListResponseAccessOidc], -// [zero_trust.IdentityProviderListResponseAccessOkta], -// [zero_trust.IdentityProviderListResponseAccessOnelogin], -// [zero_trust.IdentityProviderListResponseAccessPingone], -// [zero_trust.IdentityProviderListResponseAccessSaml] or -// [zero_trust.IdentityProviderListResponseAccessYandex]. -type IdentityProviderListResponse interface { - implementsZeroTrustIdentityProviderListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*IdentityProviderListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessAzureAd{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessCentrify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessFacebook{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessGitHub{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessGoogle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessGoogleApps{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessLinkedin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessOidc{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessOkta{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessOnelogin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessPingone{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessSaml{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IdentityProviderListResponseAccessYandex{}), - }, - ) -} - -type IdentityProviderListResponseAccessAzureAd struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessAzureAdConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessAzureAdType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessAzureAdScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessAzureAdJSON `json:"-"` -} - -// identityProviderListResponseAccessAzureAdJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessAzureAd] -type identityProviderListResponseAccessAzureAdJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessAzureAdJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessAzureAd) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessAzureAdConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled bool `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID string `json:"directory_id"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Indicates the type of user interaction that is required. prompt=login forces the - // user to enter their credentials on that request, negating single-sign on. - // prompt=none is the opposite. It ensures that the user isn't presented with any - // interactive prompt. If the request can't be completed silently by using - // single-sign on, the Microsoft identity platform returns an interaction_required - // error. prompt=select_account interrupts single sign-on providing account - // selection experience listing all the accounts either in session or any - // remembered account or an option to choose to use a different account altogether. - Prompt IdentityProviderListResponseAccessAzureAdConfigPrompt `json:"prompt"` - // Should Cloudflare try to load groups from your account - SupportGroups bool `json:"support_groups"` - JSON identityProviderListResponseAccessAzureAdConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessAzureAdConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessAzureAdConfig] -type identityProviderListResponseAccessAzureAdConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - ConditionalAccessEnabled apijson.Field - DirectoryID apijson.Field - EmailClaimName apijson.Field - Prompt apijson.Field - SupportGroups apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessAzureAdConfigJSON) RawJSON() string { - return r.raw -} - -// Indicates the type of user interaction that is required. prompt=login forces the -// user to enter their credentials on that request, negating single-sign on. -// prompt=none is the opposite. It ensures that the user isn't presented with any -// interactive prompt. If the request can't be completed silently by using -// single-sign on, the Microsoft identity platform returns an interaction_required -// error. prompt=select_account interrupts single sign-on providing account -// selection experience listing all the accounts either in session or any -// remembered account or an option to choose to use a different account altogether. -type IdentityProviderListResponseAccessAzureAdConfigPrompt string - -const ( - IdentityProviderListResponseAccessAzureAdConfigPromptLogin IdentityProviderListResponseAccessAzureAdConfigPrompt = "login" - IdentityProviderListResponseAccessAzureAdConfigPromptSelectAccount IdentityProviderListResponseAccessAzureAdConfigPrompt = "select_account" - IdentityProviderListResponseAccessAzureAdConfigPromptNone IdentityProviderListResponseAccessAzureAdConfigPrompt = "none" -) - -func (r IdentityProviderListResponseAccessAzureAdConfigPrompt) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessAzureAdConfigPromptLogin, IdentityProviderListResponseAccessAzureAdConfigPromptSelectAccount, IdentityProviderListResponseAccessAzureAdConfigPromptNone: - return true - } - return false -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessAzureAdType string - -const ( - IdentityProviderListResponseAccessAzureAdTypeOnetimepin IdentityProviderListResponseAccessAzureAdType = "onetimepin" - IdentityProviderListResponseAccessAzureAdTypeAzureAd IdentityProviderListResponseAccessAzureAdType = "azureAD" - IdentityProviderListResponseAccessAzureAdTypeSaml IdentityProviderListResponseAccessAzureAdType = "saml" - IdentityProviderListResponseAccessAzureAdTypeCentrify IdentityProviderListResponseAccessAzureAdType = "centrify" - IdentityProviderListResponseAccessAzureAdTypeFacebook IdentityProviderListResponseAccessAzureAdType = "facebook" - IdentityProviderListResponseAccessAzureAdTypeGitHub IdentityProviderListResponseAccessAzureAdType = "github" - IdentityProviderListResponseAccessAzureAdTypeGoogleApps IdentityProviderListResponseAccessAzureAdType = "google-apps" - IdentityProviderListResponseAccessAzureAdTypeGoogle IdentityProviderListResponseAccessAzureAdType = "google" - IdentityProviderListResponseAccessAzureAdTypeLinkedin IdentityProviderListResponseAccessAzureAdType = "linkedin" - IdentityProviderListResponseAccessAzureAdTypeOidc IdentityProviderListResponseAccessAzureAdType = "oidc" - IdentityProviderListResponseAccessAzureAdTypeOkta IdentityProviderListResponseAccessAzureAdType = "okta" - IdentityProviderListResponseAccessAzureAdTypeOnelogin IdentityProviderListResponseAccessAzureAdType = "onelogin" - IdentityProviderListResponseAccessAzureAdTypePingone IdentityProviderListResponseAccessAzureAdType = "pingone" - IdentityProviderListResponseAccessAzureAdTypeYandex IdentityProviderListResponseAccessAzureAdType = "yandex" -) - -func (r IdentityProviderListResponseAccessAzureAdType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessAzureAdTypeOnetimepin, IdentityProviderListResponseAccessAzureAdTypeAzureAd, IdentityProviderListResponseAccessAzureAdTypeSaml, IdentityProviderListResponseAccessAzureAdTypeCentrify, IdentityProviderListResponseAccessAzureAdTypeFacebook, IdentityProviderListResponseAccessAzureAdTypeGitHub, IdentityProviderListResponseAccessAzureAdTypeGoogleApps, IdentityProviderListResponseAccessAzureAdTypeGoogle, IdentityProviderListResponseAccessAzureAdTypeLinkedin, IdentityProviderListResponseAccessAzureAdTypeOidc, IdentityProviderListResponseAccessAzureAdTypeOkta, IdentityProviderListResponseAccessAzureAdTypeOnelogin, IdentityProviderListResponseAccessAzureAdTypePingone, IdentityProviderListResponseAccessAzureAdTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessAzureAdScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessAzureAdScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessAzureAdScimConfig] -type identityProviderListResponseAccessAzureAdScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessAzureAdScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessCentrify struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessCentrifyConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessCentrifyType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessCentrifyScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessCentrifyJSON `json:"-"` -} - -// identityProviderListResponseAccessCentrifyJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessCentrify] -type identityProviderListResponseAccessCentrifyJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessCentrify) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessCentrifyJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessCentrify) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessCentrifyConfig struct { - // Your centrify account url - CentrifyAccount string `json:"centrify_account"` - // Your centrify app id - CentrifyAppID string `json:"centrify_app_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON identityProviderListResponseAccessCentrifyConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessCentrifyConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessCentrifyConfig] -type identityProviderListResponseAccessCentrifyConfigJSON struct { - CentrifyAccount apijson.Field - CentrifyAppID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessCentrifyConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessCentrifyType string - -const ( - IdentityProviderListResponseAccessCentrifyTypeOnetimepin IdentityProviderListResponseAccessCentrifyType = "onetimepin" - IdentityProviderListResponseAccessCentrifyTypeAzureAd IdentityProviderListResponseAccessCentrifyType = "azureAD" - IdentityProviderListResponseAccessCentrifyTypeSaml IdentityProviderListResponseAccessCentrifyType = "saml" - IdentityProviderListResponseAccessCentrifyTypeCentrify IdentityProviderListResponseAccessCentrifyType = "centrify" - IdentityProviderListResponseAccessCentrifyTypeFacebook IdentityProviderListResponseAccessCentrifyType = "facebook" - IdentityProviderListResponseAccessCentrifyTypeGitHub IdentityProviderListResponseAccessCentrifyType = "github" - IdentityProviderListResponseAccessCentrifyTypeGoogleApps IdentityProviderListResponseAccessCentrifyType = "google-apps" - IdentityProviderListResponseAccessCentrifyTypeGoogle IdentityProviderListResponseAccessCentrifyType = "google" - IdentityProviderListResponseAccessCentrifyTypeLinkedin IdentityProviderListResponseAccessCentrifyType = "linkedin" - IdentityProviderListResponseAccessCentrifyTypeOidc IdentityProviderListResponseAccessCentrifyType = "oidc" - IdentityProviderListResponseAccessCentrifyTypeOkta IdentityProviderListResponseAccessCentrifyType = "okta" - IdentityProviderListResponseAccessCentrifyTypeOnelogin IdentityProviderListResponseAccessCentrifyType = "onelogin" - IdentityProviderListResponseAccessCentrifyTypePingone IdentityProviderListResponseAccessCentrifyType = "pingone" - IdentityProviderListResponseAccessCentrifyTypeYandex IdentityProviderListResponseAccessCentrifyType = "yandex" -) - -func (r IdentityProviderListResponseAccessCentrifyType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessCentrifyTypeOnetimepin, IdentityProviderListResponseAccessCentrifyTypeAzureAd, IdentityProviderListResponseAccessCentrifyTypeSaml, IdentityProviderListResponseAccessCentrifyTypeCentrify, IdentityProviderListResponseAccessCentrifyTypeFacebook, IdentityProviderListResponseAccessCentrifyTypeGitHub, IdentityProviderListResponseAccessCentrifyTypeGoogleApps, IdentityProviderListResponseAccessCentrifyTypeGoogle, IdentityProviderListResponseAccessCentrifyTypeLinkedin, IdentityProviderListResponseAccessCentrifyTypeOidc, IdentityProviderListResponseAccessCentrifyTypeOkta, IdentityProviderListResponseAccessCentrifyTypeOnelogin, IdentityProviderListResponseAccessCentrifyTypePingone, IdentityProviderListResponseAccessCentrifyTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessCentrifyScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessCentrifyScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessCentrifyScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessCentrifyScimConfig] -type identityProviderListResponseAccessCentrifyScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessCentrifyScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessFacebook struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessFacebookConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessFacebookType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessFacebookScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessFacebookJSON `json:"-"` -} - -// identityProviderListResponseAccessFacebookJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessFacebook] -type identityProviderListResponseAccessFacebookJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessFacebook) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessFacebookJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessFacebook) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessFacebookConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON identityProviderListResponseAccessFacebookConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessFacebookConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessFacebookConfig] -type identityProviderListResponseAccessFacebookConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessFacebookConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessFacebookType string - -const ( - IdentityProviderListResponseAccessFacebookTypeOnetimepin IdentityProviderListResponseAccessFacebookType = "onetimepin" - IdentityProviderListResponseAccessFacebookTypeAzureAd IdentityProviderListResponseAccessFacebookType = "azureAD" - IdentityProviderListResponseAccessFacebookTypeSaml IdentityProviderListResponseAccessFacebookType = "saml" - IdentityProviderListResponseAccessFacebookTypeCentrify IdentityProviderListResponseAccessFacebookType = "centrify" - IdentityProviderListResponseAccessFacebookTypeFacebook IdentityProviderListResponseAccessFacebookType = "facebook" - IdentityProviderListResponseAccessFacebookTypeGitHub IdentityProviderListResponseAccessFacebookType = "github" - IdentityProviderListResponseAccessFacebookTypeGoogleApps IdentityProviderListResponseAccessFacebookType = "google-apps" - IdentityProviderListResponseAccessFacebookTypeGoogle IdentityProviderListResponseAccessFacebookType = "google" - IdentityProviderListResponseAccessFacebookTypeLinkedin IdentityProviderListResponseAccessFacebookType = "linkedin" - IdentityProviderListResponseAccessFacebookTypeOidc IdentityProviderListResponseAccessFacebookType = "oidc" - IdentityProviderListResponseAccessFacebookTypeOkta IdentityProviderListResponseAccessFacebookType = "okta" - IdentityProviderListResponseAccessFacebookTypeOnelogin IdentityProviderListResponseAccessFacebookType = "onelogin" - IdentityProviderListResponseAccessFacebookTypePingone IdentityProviderListResponseAccessFacebookType = "pingone" - IdentityProviderListResponseAccessFacebookTypeYandex IdentityProviderListResponseAccessFacebookType = "yandex" -) - -func (r IdentityProviderListResponseAccessFacebookType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessFacebookTypeOnetimepin, IdentityProviderListResponseAccessFacebookTypeAzureAd, IdentityProviderListResponseAccessFacebookTypeSaml, IdentityProviderListResponseAccessFacebookTypeCentrify, IdentityProviderListResponseAccessFacebookTypeFacebook, IdentityProviderListResponseAccessFacebookTypeGitHub, IdentityProviderListResponseAccessFacebookTypeGoogleApps, IdentityProviderListResponseAccessFacebookTypeGoogle, IdentityProviderListResponseAccessFacebookTypeLinkedin, IdentityProviderListResponseAccessFacebookTypeOidc, IdentityProviderListResponseAccessFacebookTypeOkta, IdentityProviderListResponseAccessFacebookTypeOnelogin, IdentityProviderListResponseAccessFacebookTypePingone, IdentityProviderListResponseAccessFacebookTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessFacebookScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessFacebookScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessFacebookScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessFacebookScimConfig] -type identityProviderListResponseAccessFacebookScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessFacebookScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessGitHub struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessGitHubConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessGitHubType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessGitHubScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessGitHubJSON `json:"-"` -} - -// identityProviderListResponseAccessGitHubJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessGitHub] -type identityProviderListResponseAccessGitHubJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGitHub) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGitHubJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessGitHub) implementsZeroTrustIdentityProviderListResponse() {} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessGitHubConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON identityProviderListResponseAccessGitHubConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessGitHubConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessGitHubConfig] -type identityProviderListResponseAccessGitHubConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGitHubConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessGitHubType string - -const ( - IdentityProviderListResponseAccessGitHubTypeOnetimepin IdentityProviderListResponseAccessGitHubType = "onetimepin" - IdentityProviderListResponseAccessGitHubTypeAzureAd IdentityProviderListResponseAccessGitHubType = "azureAD" - IdentityProviderListResponseAccessGitHubTypeSaml IdentityProviderListResponseAccessGitHubType = "saml" - IdentityProviderListResponseAccessGitHubTypeCentrify IdentityProviderListResponseAccessGitHubType = "centrify" - IdentityProviderListResponseAccessGitHubTypeFacebook IdentityProviderListResponseAccessGitHubType = "facebook" - IdentityProviderListResponseAccessGitHubTypeGitHub IdentityProviderListResponseAccessGitHubType = "github" - IdentityProviderListResponseAccessGitHubTypeGoogleApps IdentityProviderListResponseAccessGitHubType = "google-apps" - IdentityProviderListResponseAccessGitHubTypeGoogle IdentityProviderListResponseAccessGitHubType = "google" - IdentityProviderListResponseAccessGitHubTypeLinkedin IdentityProviderListResponseAccessGitHubType = "linkedin" - IdentityProviderListResponseAccessGitHubTypeOidc IdentityProviderListResponseAccessGitHubType = "oidc" - IdentityProviderListResponseAccessGitHubTypeOkta IdentityProviderListResponseAccessGitHubType = "okta" - IdentityProviderListResponseAccessGitHubTypeOnelogin IdentityProviderListResponseAccessGitHubType = "onelogin" - IdentityProviderListResponseAccessGitHubTypePingone IdentityProviderListResponseAccessGitHubType = "pingone" - IdentityProviderListResponseAccessGitHubTypeYandex IdentityProviderListResponseAccessGitHubType = "yandex" -) - -func (r IdentityProviderListResponseAccessGitHubType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessGitHubTypeOnetimepin, IdentityProviderListResponseAccessGitHubTypeAzureAd, IdentityProviderListResponseAccessGitHubTypeSaml, IdentityProviderListResponseAccessGitHubTypeCentrify, IdentityProviderListResponseAccessGitHubTypeFacebook, IdentityProviderListResponseAccessGitHubTypeGitHub, IdentityProviderListResponseAccessGitHubTypeGoogleApps, IdentityProviderListResponseAccessGitHubTypeGoogle, IdentityProviderListResponseAccessGitHubTypeLinkedin, IdentityProviderListResponseAccessGitHubTypeOidc, IdentityProviderListResponseAccessGitHubTypeOkta, IdentityProviderListResponseAccessGitHubTypeOnelogin, IdentityProviderListResponseAccessGitHubTypePingone, IdentityProviderListResponseAccessGitHubTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessGitHubScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessGitHubScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessGitHubScimConfig] -type identityProviderListResponseAccessGitHubScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGitHubScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessGoogle struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessGoogleConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessGoogleType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessGoogleScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessGoogleJSON `json:"-"` -} - -// identityProviderListResponseAccessGoogleJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessGoogle] -type identityProviderListResponseAccessGoogleJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGoogle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGoogleJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessGoogle) implementsZeroTrustIdentityProviderListResponse() {} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessGoogleConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON identityProviderListResponseAccessGoogleConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessGoogleConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessGoogleConfig] -type identityProviderListResponseAccessGoogleConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGoogleConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessGoogleType string - -const ( - IdentityProviderListResponseAccessGoogleTypeOnetimepin IdentityProviderListResponseAccessGoogleType = "onetimepin" - IdentityProviderListResponseAccessGoogleTypeAzureAd IdentityProviderListResponseAccessGoogleType = "azureAD" - IdentityProviderListResponseAccessGoogleTypeSaml IdentityProviderListResponseAccessGoogleType = "saml" - IdentityProviderListResponseAccessGoogleTypeCentrify IdentityProviderListResponseAccessGoogleType = "centrify" - IdentityProviderListResponseAccessGoogleTypeFacebook IdentityProviderListResponseAccessGoogleType = "facebook" - IdentityProviderListResponseAccessGoogleTypeGitHub IdentityProviderListResponseAccessGoogleType = "github" - IdentityProviderListResponseAccessGoogleTypeGoogleApps IdentityProviderListResponseAccessGoogleType = "google-apps" - IdentityProviderListResponseAccessGoogleTypeGoogle IdentityProviderListResponseAccessGoogleType = "google" - IdentityProviderListResponseAccessGoogleTypeLinkedin IdentityProviderListResponseAccessGoogleType = "linkedin" - IdentityProviderListResponseAccessGoogleTypeOidc IdentityProviderListResponseAccessGoogleType = "oidc" - IdentityProviderListResponseAccessGoogleTypeOkta IdentityProviderListResponseAccessGoogleType = "okta" - IdentityProviderListResponseAccessGoogleTypeOnelogin IdentityProviderListResponseAccessGoogleType = "onelogin" - IdentityProviderListResponseAccessGoogleTypePingone IdentityProviderListResponseAccessGoogleType = "pingone" - IdentityProviderListResponseAccessGoogleTypeYandex IdentityProviderListResponseAccessGoogleType = "yandex" -) - -func (r IdentityProviderListResponseAccessGoogleType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessGoogleTypeOnetimepin, IdentityProviderListResponseAccessGoogleTypeAzureAd, IdentityProviderListResponseAccessGoogleTypeSaml, IdentityProviderListResponseAccessGoogleTypeCentrify, IdentityProviderListResponseAccessGoogleTypeFacebook, IdentityProviderListResponseAccessGoogleTypeGitHub, IdentityProviderListResponseAccessGoogleTypeGoogleApps, IdentityProviderListResponseAccessGoogleTypeGoogle, IdentityProviderListResponseAccessGoogleTypeLinkedin, IdentityProviderListResponseAccessGoogleTypeOidc, IdentityProviderListResponseAccessGoogleTypeOkta, IdentityProviderListResponseAccessGoogleTypeOnelogin, IdentityProviderListResponseAccessGoogleTypePingone, IdentityProviderListResponseAccessGoogleTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessGoogleScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessGoogleScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessGoogleScimConfig] -type identityProviderListResponseAccessGoogleScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGoogleScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessGoogleApps struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessGoogleAppsConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessGoogleAppsType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessGoogleAppsScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessGoogleAppsJSON `json:"-"` -} - -// identityProviderListResponseAccessGoogleAppsJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessGoogleApps] -type identityProviderListResponseAccessGoogleAppsJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGoogleAppsJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessGoogleApps) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain string `json:"apps_domain"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON identityProviderListResponseAccessGoogleAppsConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessGoogleAppsConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessGoogleAppsConfig] -type identityProviderListResponseAccessGoogleAppsConfigJSON struct { - AppsDomain apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGoogleAppsConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessGoogleAppsType string - -const ( - IdentityProviderListResponseAccessGoogleAppsTypeOnetimepin IdentityProviderListResponseAccessGoogleAppsType = "onetimepin" - IdentityProviderListResponseAccessGoogleAppsTypeAzureAd IdentityProviderListResponseAccessGoogleAppsType = "azureAD" - IdentityProviderListResponseAccessGoogleAppsTypeSaml IdentityProviderListResponseAccessGoogleAppsType = "saml" - IdentityProviderListResponseAccessGoogleAppsTypeCentrify IdentityProviderListResponseAccessGoogleAppsType = "centrify" - IdentityProviderListResponseAccessGoogleAppsTypeFacebook IdentityProviderListResponseAccessGoogleAppsType = "facebook" - IdentityProviderListResponseAccessGoogleAppsTypeGitHub IdentityProviderListResponseAccessGoogleAppsType = "github" - IdentityProviderListResponseAccessGoogleAppsTypeGoogleApps IdentityProviderListResponseAccessGoogleAppsType = "google-apps" - IdentityProviderListResponseAccessGoogleAppsTypeGoogle IdentityProviderListResponseAccessGoogleAppsType = "google" - IdentityProviderListResponseAccessGoogleAppsTypeLinkedin IdentityProviderListResponseAccessGoogleAppsType = "linkedin" - IdentityProviderListResponseAccessGoogleAppsTypeOidc IdentityProviderListResponseAccessGoogleAppsType = "oidc" - IdentityProviderListResponseAccessGoogleAppsTypeOkta IdentityProviderListResponseAccessGoogleAppsType = "okta" - IdentityProviderListResponseAccessGoogleAppsTypeOnelogin IdentityProviderListResponseAccessGoogleAppsType = "onelogin" - IdentityProviderListResponseAccessGoogleAppsTypePingone IdentityProviderListResponseAccessGoogleAppsType = "pingone" - IdentityProviderListResponseAccessGoogleAppsTypeYandex IdentityProviderListResponseAccessGoogleAppsType = "yandex" -) - -func (r IdentityProviderListResponseAccessGoogleAppsType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessGoogleAppsTypeOnetimepin, IdentityProviderListResponseAccessGoogleAppsTypeAzureAd, IdentityProviderListResponseAccessGoogleAppsTypeSaml, IdentityProviderListResponseAccessGoogleAppsTypeCentrify, IdentityProviderListResponseAccessGoogleAppsTypeFacebook, IdentityProviderListResponseAccessGoogleAppsTypeGitHub, IdentityProviderListResponseAccessGoogleAppsTypeGoogleApps, IdentityProviderListResponseAccessGoogleAppsTypeGoogle, IdentityProviderListResponseAccessGoogleAppsTypeLinkedin, IdentityProviderListResponseAccessGoogleAppsTypeOidc, IdentityProviderListResponseAccessGoogleAppsTypeOkta, IdentityProviderListResponseAccessGoogleAppsTypeOnelogin, IdentityProviderListResponseAccessGoogleAppsTypePingone, IdentityProviderListResponseAccessGoogleAppsTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessGoogleAppsScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessGoogleAppsScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessGoogleAppsScimConfig] -type identityProviderListResponseAccessGoogleAppsScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessGoogleAppsScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessLinkedin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessLinkedinConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessLinkedinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessLinkedinScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessLinkedinJSON `json:"-"` -} - -// identityProviderListResponseAccessLinkedinJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessLinkedin] -type identityProviderListResponseAccessLinkedinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessLinkedin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessLinkedinJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessLinkedin) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessLinkedinConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON identityProviderListResponseAccessLinkedinConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessLinkedinConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessLinkedinConfig] -type identityProviderListResponseAccessLinkedinConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessLinkedinConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessLinkedinType string - -const ( - IdentityProviderListResponseAccessLinkedinTypeOnetimepin IdentityProviderListResponseAccessLinkedinType = "onetimepin" - IdentityProviderListResponseAccessLinkedinTypeAzureAd IdentityProviderListResponseAccessLinkedinType = "azureAD" - IdentityProviderListResponseAccessLinkedinTypeSaml IdentityProviderListResponseAccessLinkedinType = "saml" - IdentityProviderListResponseAccessLinkedinTypeCentrify IdentityProviderListResponseAccessLinkedinType = "centrify" - IdentityProviderListResponseAccessLinkedinTypeFacebook IdentityProviderListResponseAccessLinkedinType = "facebook" - IdentityProviderListResponseAccessLinkedinTypeGitHub IdentityProviderListResponseAccessLinkedinType = "github" - IdentityProviderListResponseAccessLinkedinTypeGoogleApps IdentityProviderListResponseAccessLinkedinType = "google-apps" - IdentityProviderListResponseAccessLinkedinTypeGoogle IdentityProviderListResponseAccessLinkedinType = "google" - IdentityProviderListResponseAccessLinkedinTypeLinkedin IdentityProviderListResponseAccessLinkedinType = "linkedin" - IdentityProviderListResponseAccessLinkedinTypeOidc IdentityProviderListResponseAccessLinkedinType = "oidc" - IdentityProviderListResponseAccessLinkedinTypeOkta IdentityProviderListResponseAccessLinkedinType = "okta" - IdentityProviderListResponseAccessLinkedinTypeOnelogin IdentityProviderListResponseAccessLinkedinType = "onelogin" - IdentityProviderListResponseAccessLinkedinTypePingone IdentityProviderListResponseAccessLinkedinType = "pingone" - IdentityProviderListResponseAccessLinkedinTypeYandex IdentityProviderListResponseAccessLinkedinType = "yandex" -) - -func (r IdentityProviderListResponseAccessLinkedinType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessLinkedinTypeOnetimepin, IdentityProviderListResponseAccessLinkedinTypeAzureAd, IdentityProviderListResponseAccessLinkedinTypeSaml, IdentityProviderListResponseAccessLinkedinTypeCentrify, IdentityProviderListResponseAccessLinkedinTypeFacebook, IdentityProviderListResponseAccessLinkedinTypeGitHub, IdentityProviderListResponseAccessLinkedinTypeGoogleApps, IdentityProviderListResponseAccessLinkedinTypeGoogle, IdentityProviderListResponseAccessLinkedinTypeLinkedin, IdentityProviderListResponseAccessLinkedinTypeOidc, IdentityProviderListResponseAccessLinkedinTypeOkta, IdentityProviderListResponseAccessLinkedinTypeOnelogin, IdentityProviderListResponseAccessLinkedinTypePingone, IdentityProviderListResponseAccessLinkedinTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessLinkedinScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessLinkedinScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessLinkedinScimConfig] -type identityProviderListResponseAccessLinkedinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessLinkedinScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessOidc struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessOidcConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessOidcType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessOidcScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessOidcJSON `json:"-"` -} - -// identityProviderListResponseAccessOidcJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessOidc] -type identityProviderListResponseAccessOidcJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOidc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOidcJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessOidc) implementsZeroTrustIdentityProviderListResponse() {} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessOidcConfig struct { - // The authorization_endpoint URL of your IdP - AuthURL string `json:"auth_url"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CERTsURL string `json:"certs_url"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // OAuth scopes - Scopes []string `json:"scopes"` - // The token_endpoint URL of your IdP - TokenURL string `json:"token_url"` - JSON identityProviderListResponseAccessOidcConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessOidcConfigJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessOidcConfig] -type identityProviderListResponseAccessOidcConfigJSON struct { - AuthURL apijson.Field - CERTsURL apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - Scopes apijson.Field - TokenURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOidcConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessOidcType string - -const ( - IdentityProviderListResponseAccessOidcTypeOnetimepin IdentityProviderListResponseAccessOidcType = "onetimepin" - IdentityProviderListResponseAccessOidcTypeAzureAd IdentityProviderListResponseAccessOidcType = "azureAD" - IdentityProviderListResponseAccessOidcTypeSaml IdentityProviderListResponseAccessOidcType = "saml" - IdentityProviderListResponseAccessOidcTypeCentrify IdentityProviderListResponseAccessOidcType = "centrify" - IdentityProviderListResponseAccessOidcTypeFacebook IdentityProviderListResponseAccessOidcType = "facebook" - IdentityProviderListResponseAccessOidcTypeGitHub IdentityProviderListResponseAccessOidcType = "github" - IdentityProviderListResponseAccessOidcTypeGoogleApps IdentityProviderListResponseAccessOidcType = "google-apps" - IdentityProviderListResponseAccessOidcTypeGoogle IdentityProviderListResponseAccessOidcType = "google" - IdentityProviderListResponseAccessOidcTypeLinkedin IdentityProviderListResponseAccessOidcType = "linkedin" - IdentityProviderListResponseAccessOidcTypeOidc IdentityProviderListResponseAccessOidcType = "oidc" - IdentityProviderListResponseAccessOidcTypeOkta IdentityProviderListResponseAccessOidcType = "okta" - IdentityProviderListResponseAccessOidcTypeOnelogin IdentityProviderListResponseAccessOidcType = "onelogin" - IdentityProviderListResponseAccessOidcTypePingone IdentityProviderListResponseAccessOidcType = "pingone" - IdentityProviderListResponseAccessOidcTypeYandex IdentityProviderListResponseAccessOidcType = "yandex" -) - -func (r IdentityProviderListResponseAccessOidcType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessOidcTypeOnetimepin, IdentityProviderListResponseAccessOidcTypeAzureAd, IdentityProviderListResponseAccessOidcTypeSaml, IdentityProviderListResponseAccessOidcTypeCentrify, IdentityProviderListResponseAccessOidcTypeFacebook, IdentityProviderListResponseAccessOidcTypeGitHub, IdentityProviderListResponseAccessOidcTypeGoogleApps, IdentityProviderListResponseAccessOidcTypeGoogle, IdentityProviderListResponseAccessOidcTypeLinkedin, IdentityProviderListResponseAccessOidcTypeOidc, IdentityProviderListResponseAccessOidcTypeOkta, IdentityProviderListResponseAccessOidcTypeOnelogin, IdentityProviderListResponseAccessOidcTypePingone, IdentityProviderListResponseAccessOidcTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessOidcScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessOidcScimConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessOidcScimConfig] -type identityProviderListResponseAccessOidcScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOidcScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessOkta struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessOktaConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessOktaType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessOktaScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessOktaJSON `json:"-"` -} - -// identityProviderListResponseAccessOktaJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessOkta] -type identityProviderListResponseAccessOktaJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOktaJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessOkta) implementsZeroTrustIdentityProviderListResponse() {} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessOktaConfig struct { - // Your okta authorization server id - AuthorizationServerID string `json:"authorization_server_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your okta account url - OktaAccount string `json:"okta_account"` - JSON identityProviderListResponseAccessOktaConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessOktaConfigJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessOktaConfig] -type identityProviderListResponseAccessOktaConfigJSON struct { - AuthorizationServerID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OktaAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOktaConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessOktaType string - -const ( - IdentityProviderListResponseAccessOktaTypeOnetimepin IdentityProviderListResponseAccessOktaType = "onetimepin" - IdentityProviderListResponseAccessOktaTypeAzureAd IdentityProviderListResponseAccessOktaType = "azureAD" - IdentityProviderListResponseAccessOktaTypeSaml IdentityProviderListResponseAccessOktaType = "saml" - IdentityProviderListResponseAccessOktaTypeCentrify IdentityProviderListResponseAccessOktaType = "centrify" - IdentityProviderListResponseAccessOktaTypeFacebook IdentityProviderListResponseAccessOktaType = "facebook" - IdentityProviderListResponseAccessOktaTypeGitHub IdentityProviderListResponseAccessOktaType = "github" - IdentityProviderListResponseAccessOktaTypeGoogleApps IdentityProviderListResponseAccessOktaType = "google-apps" - IdentityProviderListResponseAccessOktaTypeGoogle IdentityProviderListResponseAccessOktaType = "google" - IdentityProviderListResponseAccessOktaTypeLinkedin IdentityProviderListResponseAccessOktaType = "linkedin" - IdentityProviderListResponseAccessOktaTypeOidc IdentityProviderListResponseAccessOktaType = "oidc" - IdentityProviderListResponseAccessOktaTypeOkta IdentityProviderListResponseAccessOktaType = "okta" - IdentityProviderListResponseAccessOktaTypeOnelogin IdentityProviderListResponseAccessOktaType = "onelogin" - IdentityProviderListResponseAccessOktaTypePingone IdentityProviderListResponseAccessOktaType = "pingone" - IdentityProviderListResponseAccessOktaTypeYandex IdentityProviderListResponseAccessOktaType = "yandex" -) - -func (r IdentityProviderListResponseAccessOktaType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessOktaTypeOnetimepin, IdentityProviderListResponseAccessOktaTypeAzureAd, IdentityProviderListResponseAccessOktaTypeSaml, IdentityProviderListResponseAccessOktaTypeCentrify, IdentityProviderListResponseAccessOktaTypeFacebook, IdentityProviderListResponseAccessOktaTypeGitHub, IdentityProviderListResponseAccessOktaTypeGoogleApps, IdentityProviderListResponseAccessOktaTypeGoogle, IdentityProviderListResponseAccessOktaTypeLinkedin, IdentityProviderListResponseAccessOktaTypeOidc, IdentityProviderListResponseAccessOktaTypeOkta, IdentityProviderListResponseAccessOktaTypeOnelogin, IdentityProviderListResponseAccessOktaTypePingone, IdentityProviderListResponseAccessOktaTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessOktaScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessOktaScimConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessOktaScimConfig] -type identityProviderListResponseAccessOktaScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOktaScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessOnelogin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessOneloginConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessOneloginType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessOneloginScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessOneloginJSON `json:"-"` -} - -// identityProviderListResponseAccessOneloginJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessOnelogin] -type identityProviderListResponseAccessOneloginJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOnelogin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOneloginJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessOnelogin) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessOneloginConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your OneLogin account url - OneloginAccount string `json:"onelogin_account"` - JSON identityProviderListResponseAccessOneloginConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessOneloginConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessOneloginConfig] -type identityProviderListResponseAccessOneloginConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OneloginAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOneloginConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessOneloginType string - -const ( - IdentityProviderListResponseAccessOneloginTypeOnetimepin IdentityProviderListResponseAccessOneloginType = "onetimepin" - IdentityProviderListResponseAccessOneloginTypeAzureAd IdentityProviderListResponseAccessOneloginType = "azureAD" - IdentityProviderListResponseAccessOneloginTypeSaml IdentityProviderListResponseAccessOneloginType = "saml" - IdentityProviderListResponseAccessOneloginTypeCentrify IdentityProviderListResponseAccessOneloginType = "centrify" - IdentityProviderListResponseAccessOneloginTypeFacebook IdentityProviderListResponseAccessOneloginType = "facebook" - IdentityProviderListResponseAccessOneloginTypeGitHub IdentityProviderListResponseAccessOneloginType = "github" - IdentityProviderListResponseAccessOneloginTypeGoogleApps IdentityProviderListResponseAccessOneloginType = "google-apps" - IdentityProviderListResponseAccessOneloginTypeGoogle IdentityProviderListResponseAccessOneloginType = "google" - IdentityProviderListResponseAccessOneloginTypeLinkedin IdentityProviderListResponseAccessOneloginType = "linkedin" - IdentityProviderListResponseAccessOneloginTypeOidc IdentityProviderListResponseAccessOneloginType = "oidc" - IdentityProviderListResponseAccessOneloginTypeOkta IdentityProviderListResponseAccessOneloginType = "okta" - IdentityProviderListResponseAccessOneloginTypeOnelogin IdentityProviderListResponseAccessOneloginType = "onelogin" - IdentityProviderListResponseAccessOneloginTypePingone IdentityProviderListResponseAccessOneloginType = "pingone" - IdentityProviderListResponseAccessOneloginTypeYandex IdentityProviderListResponseAccessOneloginType = "yandex" -) - -func (r IdentityProviderListResponseAccessOneloginType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessOneloginTypeOnetimepin, IdentityProviderListResponseAccessOneloginTypeAzureAd, IdentityProviderListResponseAccessOneloginTypeSaml, IdentityProviderListResponseAccessOneloginTypeCentrify, IdentityProviderListResponseAccessOneloginTypeFacebook, IdentityProviderListResponseAccessOneloginTypeGitHub, IdentityProviderListResponseAccessOneloginTypeGoogleApps, IdentityProviderListResponseAccessOneloginTypeGoogle, IdentityProviderListResponseAccessOneloginTypeLinkedin, IdentityProviderListResponseAccessOneloginTypeOidc, IdentityProviderListResponseAccessOneloginTypeOkta, IdentityProviderListResponseAccessOneloginTypeOnelogin, IdentityProviderListResponseAccessOneloginTypePingone, IdentityProviderListResponseAccessOneloginTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessOneloginScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessOneloginScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessOneloginScimConfig] -type identityProviderListResponseAccessOneloginScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessOneloginScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessPingone struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessPingoneConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessPingoneType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessPingoneScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessPingoneJSON `json:"-"` -} - -// identityProviderListResponseAccessPingoneJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessPingone] -type identityProviderListResponseAccessPingoneJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessPingone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessPingoneJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessPingone) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessPingoneConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your PingOne environment identifier - PingEnvID string `json:"ping_env_id"` - JSON identityProviderListResponseAccessPingoneConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessPingoneConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessPingoneConfig] -type identityProviderListResponseAccessPingoneConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - PingEnvID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessPingoneConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessPingoneType string - -const ( - IdentityProviderListResponseAccessPingoneTypeOnetimepin IdentityProviderListResponseAccessPingoneType = "onetimepin" - IdentityProviderListResponseAccessPingoneTypeAzureAd IdentityProviderListResponseAccessPingoneType = "azureAD" - IdentityProviderListResponseAccessPingoneTypeSaml IdentityProviderListResponseAccessPingoneType = "saml" - IdentityProviderListResponseAccessPingoneTypeCentrify IdentityProviderListResponseAccessPingoneType = "centrify" - IdentityProviderListResponseAccessPingoneTypeFacebook IdentityProviderListResponseAccessPingoneType = "facebook" - IdentityProviderListResponseAccessPingoneTypeGitHub IdentityProviderListResponseAccessPingoneType = "github" - IdentityProviderListResponseAccessPingoneTypeGoogleApps IdentityProviderListResponseAccessPingoneType = "google-apps" - IdentityProviderListResponseAccessPingoneTypeGoogle IdentityProviderListResponseAccessPingoneType = "google" - IdentityProviderListResponseAccessPingoneTypeLinkedin IdentityProviderListResponseAccessPingoneType = "linkedin" - IdentityProviderListResponseAccessPingoneTypeOidc IdentityProviderListResponseAccessPingoneType = "oidc" - IdentityProviderListResponseAccessPingoneTypeOkta IdentityProviderListResponseAccessPingoneType = "okta" - IdentityProviderListResponseAccessPingoneTypeOnelogin IdentityProviderListResponseAccessPingoneType = "onelogin" - IdentityProviderListResponseAccessPingoneTypePingone IdentityProviderListResponseAccessPingoneType = "pingone" - IdentityProviderListResponseAccessPingoneTypeYandex IdentityProviderListResponseAccessPingoneType = "yandex" -) - -func (r IdentityProviderListResponseAccessPingoneType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessPingoneTypeOnetimepin, IdentityProviderListResponseAccessPingoneTypeAzureAd, IdentityProviderListResponseAccessPingoneTypeSaml, IdentityProviderListResponseAccessPingoneTypeCentrify, IdentityProviderListResponseAccessPingoneTypeFacebook, IdentityProviderListResponseAccessPingoneTypeGitHub, IdentityProviderListResponseAccessPingoneTypeGoogleApps, IdentityProviderListResponseAccessPingoneTypeGoogle, IdentityProviderListResponseAccessPingoneTypeLinkedin, IdentityProviderListResponseAccessPingoneTypeOidc, IdentityProviderListResponseAccessPingoneTypeOkta, IdentityProviderListResponseAccessPingoneTypeOnelogin, IdentityProviderListResponseAccessPingoneTypePingone, IdentityProviderListResponseAccessPingoneTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessPingoneScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessPingoneScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessPingoneScimConfig] -type identityProviderListResponseAccessPingoneScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessPingoneScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessSaml struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessSamlConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessSamlType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessSamlScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessSamlJSON `json:"-"` -} - -// identityProviderListResponseAccessSamlJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessSaml] -type identityProviderListResponseAccessSamlJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessSamlJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessSaml) implementsZeroTrustIdentityProviderListResponse() {} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessSamlConfig struct { - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes []string `json:"attributes"` - // The attribute name for email in the SAML response. - EmailAttributeName string `json:"email_attribute_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes []IdentityProviderListResponseAccessSamlConfigHeaderAttribute `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IDPPublicCERTs []string `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL string `json:"issuer_url"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest bool `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL string `json:"sso_target_url"` - JSON identityProviderListResponseAccessSamlConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessSamlConfigJSON contains the JSON metadata for -// the struct [IdentityProviderListResponseAccessSamlConfig] -type identityProviderListResponseAccessSamlConfigJSON struct { - Attributes apijson.Field - EmailAttributeName apijson.Field - HeaderAttributes apijson.Field - IDPPublicCERTs apijson.Field - IssuerURL apijson.Field - SignRequest apijson.Field - SSOTargetURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessSamlConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName string `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName string `json:"header_name"` - JSON identityProviderListResponseAccessSamlConfigHeaderAttributeJSON `json:"-"` -} - -// identityProviderListResponseAccessSamlConfigHeaderAttributeJSON contains the -// JSON metadata for the struct -// [IdentityProviderListResponseAccessSamlConfigHeaderAttribute] -type identityProviderListResponseAccessSamlConfigHeaderAttributeJSON struct { - AttributeName apijson.Field - HeaderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessSamlConfigHeaderAttributeJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessSamlType string - -const ( - IdentityProviderListResponseAccessSamlTypeOnetimepin IdentityProviderListResponseAccessSamlType = "onetimepin" - IdentityProviderListResponseAccessSamlTypeAzureAd IdentityProviderListResponseAccessSamlType = "azureAD" - IdentityProviderListResponseAccessSamlTypeSaml IdentityProviderListResponseAccessSamlType = "saml" - IdentityProviderListResponseAccessSamlTypeCentrify IdentityProviderListResponseAccessSamlType = "centrify" - IdentityProviderListResponseAccessSamlTypeFacebook IdentityProviderListResponseAccessSamlType = "facebook" - IdentityProviderListResponseAccessSamlTypeGitHub IdentityProviderListResponseAccessSamlType = "github" - IdentityProviderListResponseAccessSamlTypeGoogleApps IdentityProviderListResponseAccessSamlType = "google-apps" - IdentityProviderListResponseAccessSamlTypeGoogle IdentityProviderListResponseAccessSamlType = "google" - IdentityProviderListResponseAccessSamlTypeLinkedin IdentityProviderListResponseAccessSamlType = "linkedin" - IdentityProviderListResponseAccessSamlTypeOidc IdentityProviderListResponseAccessSamlType = "oidc" - IdentityProviderListResponseAccessSamlTypeOkta IdentityProviderListResponseAccessSamlType = "okta" - IdentityProviderListResponseAccessSamlTypeOnelogin IdentityProviderListResponseAccessSamlType = "onelogin" - IdentityProviderListResponseAccessSamlTypePingone IdentityProviderListResponseAccessSamlType = "pingone" - IdentityProviderListResponseAccessSamlTypeYandex IdentityProviderListResponseAccessSamlType = "yandex" -) - -func (r IdentityProviderListResponseAccessSamlType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessSamlTypeOnetimepin, IdentityProviderListResponseAccessSamlTypeAzureAd, IdentityProviderListResponseAccessSamlTypeSaml, IdentityProviderListResponseAccessSamlTypeCentrify, IdentityProviderListResponseAccessSamlTypeFacebook, IdentityProviderListResponseAccessSamlTypeGitHub, IdentityProviderListResponseAccessSamlTypeGoogleApps, IdentityProviderListResponseAccessSamlTypeGoogle, IdentityProviderListResponseAccessSamlTypeLinkedin, IdentityProviderListResponseAccessSamlTypeOidc, IdentityProviderListResponseAccessSamlTypeOkta, IdentityProviderListResponseAccessSamlTypeOnelogin, IdentityProviderListResponseAccessSamlTypePingone, IdentityProviderListResponseAccessSamlTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessSamlScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessSamlScimConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessSamlScimConfig] -type identityProviderListResponseAccessSamlScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessSamlScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderListResponseAccessYandex struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config IdentityProviderListResponseAccessYandexConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type IdentityProviderListResponseAccessYandexType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig IdentityProviderListResponseAccessYandexScimConfig `json:"scim_config"` - JSON identityProviderListResponseAccessYandexJSON `json:"-"` -} - -// identityProviderListResponseAccessYandexJSON contains the JSON metadata for the -// struct [IdentityProviderListResponseAccessYandex] -type identityProviderListResponseAccessYandexJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessYandex) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessYandexJSON) RawJSON() string { - return r.raw -} - -func (r IdentityProviderListResponseAccessYandex) implementsZeroTrustIdentityProviderListResponse() {} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessYandexConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON identityProviderListResponseAccessYandexConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessYandexConfigJSON contains the JSON metadata -// for the struct [IdentityProviderListResponseAccessYandexConfig] -type identityProviderListResponseAccessYandexConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessYandexConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderListResponseAccessYandexType string - -const ( - IdentityProviderListResponseAccessYandexTypeOnetimepin IdentityProviderListResponseAccessYandexType = "onetimepin" - IdentityProviderListResponseAccessYandexTypeAzureAd IdentityProviderListResponseAccessYandexType = "azureAD" - IdentityProviderListResponseAccessYandexTypeSaml IdentityProviderListResponseAccessYandexType = "saml" - IdentityProviderListResponseAccessYandexTypeCentrify IdentityProviderListResponseAccessYandexType = "centrify" - IdentityProviderListResponseAccessYandexTypeFacebook IdentityProviderListResponseAccessYandexType = "facebook" - IdentityProviderListResponseAccessYandexTypeGitHub IdentityProviderListResponseAccessYandexType = "github" - IdentityProviderListResponseAccessYandexTypeGoogleApps IdentityProviderListResponseAccessYandexType = "google-apps" - IdentityProviderListResponseAccessYandexTypeGoogle IdentityProviderListResponseAccessYandexType = "google" - IdentityProviderListResponseAccessYandexTypeLinkedin IdentityProviderListResponseAccessYandexType = "linkedin" - IdentityProviderListResponseAccessYandexTypeOidc IdentityProviderListResponseAccessYandexType = "oidc" - IdentityProviderListResponseAccessYandexTypeOkta IdentityProviderListResponseAccessYandexType = "okta" - IdentityProviderListResponseAccessYandexTypeOnelogin IdentityProviderListResponseAccessYandexType = "onelogin" - IdentityProviderListResponseAccessYandexTypePingone IdentityProviderListResponseAccessYandexType = "pingone" - IdentityProviderListResponseAccessYandexTypeYandex IdentityProviderListResponseAccessYandexType = "yandex" -) - -func (r IdentityProviderListResponseAccessYandexType) IsKnown() bool { - switch r { - case IdentityProviderListResponseAccessYandexTypeOnetimepin, IdentityProviderListResponseAccessYandexTypeAzureAd, IdentityProviderListResponseAccessYandexTypeSaml, IdentityProviderListResponseAccessYandexTypeCentrify, IdentityProviderListResponseAccessYandexTypeFacebook, IdentityProviderListResponseAccessYandexTypeGitHub, IdentityProviderListResponseAccessYandexTypeGoogleApps, IdentityProviderListResponseAccessYandexTypeGoogle, IdentityProviderListResponseAccessYandexTypeLinkedin, IdentityProviderListResponseAccessYandexTypeOidc, IdentityProviderListResponseAccessYandexTypeOkta, IdentityProviderListResponseAccessYandexTypeOnelogin, IdentityProviderListResponseAccessYandexTypePingone, IdentityProviderListResponseAccessYandexTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderListResponseAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON identityProviderListResponseAccessYandexScimConfigJSON `json:"-"` -} - -// identityProviderListResponseAccessYandexScimConfigJSON contains the JSON -// metadata for the struct [IdentityProviderListResponseAccessYandexScimConfig] -type identityProviderListResponseAccessYandexScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderListResponseAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderListResponseAccessYandexScimConfigJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON identityProviderDeleteResponseJSON `json:"-"` -} - -// identityProviderDeleteResponseJSON contains the JSON metadata for the struct -// [IdentityProviderDeleteResponse] -type identityProviderDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// This interface is a union satisfied by one of the following: -// [IdentityProviderNewParamsAccessAzureAd], -// [IdentityProviderNewParamsAccessCentrify], -// [IdentityProviderNewParamsAccessFacebook], -// [IdentityProviderNewParamsAccessGitHub], -// [IdentityProviderNewParamsAccessGoogle], -// [IdentityProviderNewParamsAccessGoogleApps], -// [IdentityProviderNewParamsAccessLinkedin], -// [IdentityProviderNewParamsAccessOidc], [IdentityProviderNewParamsAccessOkta], -// [IdentityProviderNewParamsAccessOnelogin], -// [IdentityProviderNewParamsAccessPingone], [IdentityProviderNewParamsAccessSaml], -// [IdentityProviderNewParamsAccessYandex], -// [IdentityProviderNewParamsAccessOnetimepin]. -type IdentityProviderNewParams interface { - ImplementsIdentityProviderNewParams() - - getAccountID() param.Field[string] - - getZoneID() param.Field[string] -} - -type IdentityProviderNewParamsAccessAzureAd struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessAzureAdConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessAzureAdType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessAzureAdScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessAzureAd) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessAzureAd) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessAzureAd) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessAzureAdConfig struct { - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled param.Field[bool] `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID param.Field[string] `json:"directory_id"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` - // Indicates the type of user interaction that is required. prompt=login forces the - // user to enter their credentials on that request, negating single-sign on. - // prompt=none is the opposite. It ensures that the user isn't presented with any - // interactive prompt. If the request can't be completed silently by using - // single-sign on, the Microsoft identity platform returns an interaction_required - // error. prompt=select_account interrupts single sign-on providing account - // selection experience listing all the accounts either in session or any - // remembered account or an option to choose to use a different account altogether. - Prompt param.Field[IdentityProviderNewParamsAccessAzureAdConfigPrompt] `json:"prompt"` - // Should Cloudflare try to load groups from your account - SupportGroups param.Field[bool] `json:"support_groups"` -} - -func (r IdentityProviderNewParamsAccessAzureAdConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Indicates the type of user interaction that is required. prompt=login forces the -// user to enter their credentials on that request, negating single-sign on. -// prompt=none is the opposite. It ensures that the user isn't presented with any -// interactive prompt. If the request can't be completed silently by using -// single-sign on, the Microsoft identity platform returns an interaction_required -// error. prompt=select_account interrupts single sign-on providing account -// selection experience listing all the accounts either in session or any -// remembered account or an option to choose to use a different account altogether. -type IdentityProviderNewParamsAccessAzureAdConfigPrompt string - -const ( - IdentityProviderNewParamsAccessAzureAdConfigPromptLogin IdentityProviderNewParamsAccessAzureAdConfigPrompt = "login" - IdentityProviderNewParamsAccessAzureAdConfigPromptSelectAccount IdentityProviderNewParamsAccessAzureAdConfigPrompt = "select_account" - IdentityProviderNewParamsAccessAzureAdConfigPromptNone IdentityProviderNewParamsAccessAzureAdConfigPrompt = "none" -) - -func (r IdentityProviderNewParamsAccessAzureAdConfigPrompt) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessAzureAdConfigPromptLogin, IdentityProviderNewParamsAccessAzureAdConfigPromptSelectAccount, IdentityProviderNewParamsAccessAzureAdConfigPromptNone: - return true - } - return false -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessAzureAdType string - -const ( - IdentityProviderNewParamsAccessAzureAdTypeOnetimepin IdentityProviderNewParamsAccessAzureAdType = "onetimepin" - IdentityProviderNewParamsAccessAzureAdTypeAzureAd IdentityProviderNewParamsAccessAzureAdType = "azureAD" - IdentityProviderNewParamsAccessAzureAdTypeSaml IdentityProviderNewParamsAccessAzureAdType = "saml" - IdentityProviderNewParamsAccessAzureAdTypeCentrify IdentityProviderNewParamsAccessAzureAdType = "centrify" - IdentityProviderNewParamsAccessAzureAdTypeFacebook IdentityProviderNewParamsAccessAzureAdType = "facebook" - IdentityProviderNewParamsAccessAzureAdTypeGitHub IdentityProviderNewParamsAccessAzureAdType = "github" - IdentityProviderNewParamsAccessAzureAdTypeGoogleApps IdentityProviderNewParamsAccessAzureAdType = "google-apps" - IdentityProviderNewParamsAccessAzureAdTypeGoogle IdentityProviderNewParamsAccessAzureAdType = "google" - IdentityProviderNewParamsAccessAzureAdTypeLinkedin IdentityProviderNewParamsAccessAzureAdType = "linkedin" - IdentityProviderNewParamsAccessAzureAdTypeOidc IdentityProviderNewParamsAccessAzureAdType = "oidc" - IdentityProviderNewParamsAccessAzureAdTypeOkta IdentityProviderNewParamsAccessAzureAdType = "okta" - IdentityProviderNewParamsAccessAzureAdTypeOnelogin IdentityProviderNewParamsAccessAzureAdType = "onelogin" - IdentityProviderNewParamsAccessAzureAdTypePingone IdentityProviderNewParamsAccessAzureAdType = "pingone" - IdentityProviderNewParamsAccessAzureAdTypeYandex IdentityProviderNewParamsAccessAzureAdType = "yandex" -) - -func (r IdentityProviderNewParamsAccessAzureAdType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessAzureAdTypeOnetimepin, IdentityProviderNewParamsAccessAzureAdTypeAzureAd, IdentityProviderNewParamsAccessAzureAdTypeSaml, IdentityProviderNewParamsAccessAzureAdTypeCentrify, IdentityProviderNewParamsAccessAzureAdTypeFacebook, IdentityProviderNewParamsAccessAzureAdTypeGitHub, IdentityProviderNewParamsAccessAzureAdTypeGoogleApps, IdentityProviderNewParamsAccessAzureAdTypeGoogle, IdentityProviderNewParamsAccessAzureAdTypeLinkedin, IdentityProviderNewParamsAccessAzureAdTypeOidc, IdentityProviderNewParamsAccessAzureAdTypeOkta, IdentityProviderNewParamsAccessAzureAdTypeOnelogin, IdentityProviderNewParamsAccessAzureAdTypePingone, IdentityProviderNewParamsAccessAzureAdTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessAzureAdScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessCentrify struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessCentrifyConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessCentrifyType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessCentrifyScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessCentrify) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessCentrify) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessCentrify) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessCentrify) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessCentrifyConfig struct { - // Your centrify account url - CentrifyAccount param.Field[string] `json:"centrify_account"` - // Your centrify app id - CentrifyAppID param.Field[string] `json:"centrify_app_id"` - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` -} - -func (r IdentityProviderNewParamsAccessCentrifyConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessCentrifyType string - -const ( - IdentityProviderNewParamsAccessCentrifyTypeOnetimepin IdentityProviderNewParamsAccessCentrifyType = "onetimepin" - IdentityProviderNewParamsAccessCentrifyTypeAzureAd IdentityProviderNewParamsAccessCentrifyType = "azureAD" - IdentityProviderNewParamsAccessCentrifyTypeSaml IdentityProviderNewParamsAccessCentrifyType = "saml" - IdentityProviderNewParamsAccessCentrifyTypeCentrify IdentityProviderNewParamsAccessCentrifyType = "centrify" - IdentityProviderNewParamsAccessCentrifyTypeFacebook IdentityProviderNewParamsAccessCentrifyType = "facebook" - IdentityProviderNewParamsAccessCentrifyTypeGitHub IdentityProviderNewParamsAccessCentrifyType = "github" - IdentityProviderNewParamsAccessCentrifyTypeGoogleApps IdentityProviderNewParamsAccessCentrifyType = "google-apps" - IdentityProviderNewParamsAccessCentrifyTypeGoogle IdentityProviderNewParamsAccessCentrifyType = "google" - IdentityProviderNewParamsAccessCentrifyTypeLinkedin IdentityProviderNewParamsAccessCentrifyType = "linkedin" - IdentityProviderNewParamsAccessCentrifyTypeOidc IdentityProviderNewParamsAccessCentrifyType = "oidc" - IdentityProviderNewParamsAccessCentrifyTypeOkta IdentityProviderNewParamsAccessCentrifyType = "okta" - IdentityProviderNewParamsAccessCentrifyTypeOnelogin IdentityProviderNewParamsAccessCentrifyType = "onelogin" - IdentityProviderNewParamsAccessCentrifyTypePingone IdentityProviderNewParamsAccessCentrifyType = "pingone" - IdentityProviderNewParamsAccessCentrifyTypeYandex IdentityProviderNewParamsAccessCentrifyType = "yandex" -) - -func (r IdentityProviderNewParamsAccessCentrifyType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessCentrifyTypeOnetimepin, IdentityProviderNewParamsAccessCentrifyTypeAzureAd, IdentityProviderNewParamsAccessCentrifyTypeSaml, IdentityProviderNewParamsAccessCentrifyTypeCentrify, IdentityProviderNewParamsAccessCentrifyTypeFacebook, IdentityProviderNewParamsAccessCentrifyTypeGitHub, IdentityProviderNewParamsAccessCentrifyTypeGoogleApps, IdentityProviderNewParamsAccessCentrifyTypeGoogle, IdentityProviderNewParamsAccessCentrifyTypeLinkedin, IdentityProviderNewParamsAccessCentrifyTypeOidc, IdentityProviderNewParamsAccessCentrifyTypeOkta, IdentityProviderNewParamsAccessCentrifyTypeOnelogin, IdentityProviderNewParamsAccessCentrifyTypePingone, IdentityProviderNewParamsAccessCentrifyTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessCentrifyScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessCentrifyScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessFacebook struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessFacebookConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessFacebookType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessFacebookScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessFacebook) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessFacebook) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessFacebook) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessFacebook) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessFacebookConfig struct { - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` -} - -func (r IdentityProviderNewParamsAccessFacebookConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessFacebookType string - -const ( - IdentityProviderNewParamsAccessFacebookTypeOnetimepin IdentityProviderNewParamsAccessFacebookType = "onetimepin" - IdentityProviderNewParamsAccessFacebookTypeAzureAd IdentityProviderNewParamsAccessFacebookType = "azureAD" - IdentityProviderNewParamsAccessFacebookTypeSaml IdentityProviderNewParamsAccessFacebookType = "saml" - IdentityProviderNewParamsAccessFacebookTypeCentrify IdentityProviderNewParamsAccessFacebookType = "centrify" - IdentityProviderNewParamsAccessFacebookTypeFacebook IdentityProviderNewParamsAccessFacebookType = "facebook" - IdentityProviderNewParamsAccessFacebookTypeGitHub IdentityProviderNewParamsAccessFacebookType = "github" - IdentityProviderNewParamsAccessFacebookTypeGoogleApps IdentityProviderNewParamsAccessFacebookType = "google-apps" - IdentityProviderNewParamsAccessFacebookTypeGoogle IdentityProviderNewParamsAccessFacebookType = "google" - IdentityProviderNewParamsAccessFacebookTypeLinkedin IdentityProviderNewParamsAccessFacebookType = "linkedin" - IdentityProviderNewParamsAccessFacebookTypeOidc IdentityProviderNewParamsAccessFacebookType = "oidc" - IdentityProviderNewParamsAccessFacebookTypeOkta IdentityProviderNewParamsAccessFacebookType = "okta" - IdentityProviderNewParamsAccessFacebookTypeOnelogin IdentityProviderNewParamsAccessFacebookType = "onelogin" - IdentityProviderNewParamsAccessFacebookTypePingone IdentityProviderNewParamsAccessFacebookType = "pingone" - IdentityProviderNewParamsAccessFacebookTypeYandex IdentityProviderNewParamsAccessFacebookType = "yandex" -) - -func (r IdentityProviderNewParamsAccessFacebookType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessFacebookTypeOnetimepin, IdentityProviderNewParamsAccessFacebookTypeAzureAd, IdentityProviderNewParamsAccessFacebookTypeSaml, IdentityProviderNewParamsAccessFacebookTypeCentrify, IdentityProviderNewParamsAccessFacebookTypeFacebook, IdentityProviderNewParamsAccessFacebookTypeGitHub, IdentityProviderNewParamsAccessFacebookTypeGoogleApps, IdentityProviderNewParamsAccessFacebookTypeGoogle, IdentityProviderNewParamsAccessFacebookTypeLinkedin, IdentityProviderNewParamsAccessFacebookTypeOidc, IdentityProviderNewParamsAccessFacebookTypeOkta, IdentityProviderNewParamsAccessFacebookTypeOnelogin, IdentityProviderNewParamsAccessFacebookTypePingone, IdentityProviderNewParamsAccessFacebookTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessFacebookScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessFacebookScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessGitHub struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessGitHubConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessGitHubType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessGitHubScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessGitHub) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessGitHub) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessGitHub) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessGitHub) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessGitHubConfig struct { - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` -} - -func (r IdentityProviderNewParamsAccessGitHubConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessGitHubType string - -const ( - IdentityProviderNewParamsAccessGitHubTypeOnetimepin IdentityProviderNewParamsAccessGitHubType = "onetimepin" - IdentityProviderNewParamsAccessGitHubTypeAzureAd IdentityProviderNewParamsAccessGitHubType = "azureAD" - IdentityProviderNewParamsAccessGitHubTypeSaml IdentityProviderNewParamsAccessGitHubType = "saml" - IdentityProviderNewParamsAccessGitHubTypeCentrify IdentityProviderNewParamsAccessGitHubType = "centrify" - IdentityProviderNewParamsAccessGitHubTypeFacebook IdentityProviderNewParamsAccessGitHubType = "facebook" - IdentityProviderNewParamsAccessGitHubTypeGitHub IdentityProviderNewParamsAccessGitHubType = "github" - IdentityProviderNewParamsAccessGitHubTypeGoogleApps IdentityProviderNewParamsAccessGitHubType = "google-apps" - IdentityProviderNewParamsAccessGitHubTypeGoogle IdentityProviderNewParamsAccessGitHubType = "google" - IdentityProviderNewParamsAccessGitHubTypeLinkedin IdentityProviderNewParamsAccessGitHubType = "linkedin" - IdentityProviderNewParamsAccessGitHubTypeOidc IdentityProviderNewParamsAccessGitHubType = "oidc" - IdentityProviderNewParamsAccessGitHubTypeOkta IdentityProviderNewParamsAccessGitHubType = "okta" - IdentityProviderNewParamsAccessGitHubTypeOnelogin IdentityProviderNewParamsAccessGitHubType = "onelogin" - IdentityProviderNewParamsAccessGitHubTypePingone IdentityProviderNewParamsAccessGitHubType = "pingone" - IdentityProviderNewParamsAccessGitHubTypeYandex IdentityProviderNewParamsAccessGitHubType = "yandex" -) - -func (r IdentityProviderNewParamsAccessGitHubType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessGitHubTypeOnetimepin, IdentityProviderNewParamsAccessGitHubTypeAzureAd, IdentityProviderNewParamsAccessGitHubTypeSaml, IdentityProviderNewParamsAccessGitHubTypeCentrify, IdentityProviderNewParamsAccessGitHubTypeFacebook, IdentityProviderNewParamsAccessGitHubTypeGitHub, IdentityProviderNewParamsAccessGitHubTypeGoogleApps, IdentityProviderNewParamsAccessGitHubTypeGoogle, IdentityProviderNewParamsAccessGitHubTypeLinkedin, IdentityProviderNewParamsAccessGitHubTypeOidc, IdentityProviderNewParamsAccessGitHubTypeOkta, IdentityProviderNewParamsAccessGitHubTypeOnelogin, IdentityProviderNewParamsAccessGitHubTypePingone, IdentityProviderNewParamsAccessGitHubTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessGitHubScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessGoogle struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessGoogleConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessGoogleType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessGoogleScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessGoogle) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessGoogle) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessGoogle) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessGoogle) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessGoogleConfig struct { - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` -} - -func (r IdentityProviderNewParamsAccessGoogleConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessGoogleType string - -const ( - IdentityProviderNewParamsAccessGoogleTypeOnetimepin IdentityProviderNewParamsAccessGoogleType = "onetimepin" - IdentityProviderNewParamsAccessGoogleTypeAzureAd IdentityProviderNewParamsAccessGoogleType = "azureAD" - IdentityProviderNewParamsAccessGoogleTypeSaml IdentityProviderNewParamsAccessGoogleType = "saml" - IdentityProviderNewParamsAccessGoogleTypeCentrify IdentityProviderNewParamsAccessGoogleType = "centrify" - IdentityProviderNewParamsAccessGoogleTypeFacebook IdentityProviderNewParamsAccessGoogleType = "facebook" - IdentityProviderNewParamsAccessGoogleTypeGitHub IdentityProviderNewParamsAccessGoogleType = "github" - IdentityProviderNewParamsAccessGoogleTypeGoogleApps IdentityProviderNewParamsAccessGoogleType = "google-apps" - IdentityProviderNewParamsAccessGoogleTypeGoogle IdentityProviderNewParamsAccessGoogleType = "google" - IdentityProviderNewParamsAccessGoogleTypeLinkedin IdentityProviderNewParamsAccessGoogleType = "linkedin" - IdentityProviderNewParamsAccessGoogleTypeOidc IdentityProviderNewParamsAccessGoogleType = "oidc" - IdentityProviderNewParamsAccessGoogleTypeOkta IdentityProviderNewParamsAccessGoogleType = "okta" - IdentityProviderNewParamsAccessGoogleTypeOnelogin IdentityProviderNewParamsAccessGoogleType = "onelogin" - IdentityProviderNewParamsAccessGoogleTypePingone IdentityProviderNewParamsAccessGoogleType = "pingone" - IdentityProviderNewParamsAccessGoogleTypeYandex IdentityProviderNewParamsAccessGoogleType = "yandex" -) - -func (r IdentityProviderNewParamsAccessGoogleType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessGoogleTypeOnetimepin, IdentityProviderNewParamsAccessGoogleTypeAzureAd, IdentityProviderNewParamsAccessGoogleTypeSaml, IdentityProviderNewParamsAccessGoogleTypeCentrify, IdentityProviderNewParamsAccessGoogleTypeFacebook, IdentityProviderNewParamsAccessGoogleTypeGitHub, IdentityProviderNewParamsAccessGoogleTypeGoogleApps, IdentityProviderNewParamsAccessGoogleTypeGoogle, IdentityProviderNewParamsAccessGoogleTypeLinkedin, IdentityProviderNewParamsAccessGoogleTypeOidc, IdentityProviderNewParamsAccessGoogleTypeOkta, IdentityProviderNewParamsAccessGoogleTypeOnelogin, IdentityProviderNewParamsAccessGoogleTypePingone, IdentityProviderNewParamsAccessGoogleTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessGoogleScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessGoogleApps struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessGoogleAppsConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessGoogleAppsType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessGoogleAppsScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessGoogleApps) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessGoogleApps) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessGoogleApps) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessGoogleApps) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain param.Field[string] `json:"apps_domain"` - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` -} - -func (r IdentityProviderNewParamsAccessGoogleAppsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessGoogleAppsType string - -const ( - IdentityProviderNewParamsAccessGoogleAppsTypeOnetimepin IdentityProviderNewParamsAccessGoogleAppsType = "onetimepin" - IdentityProviderNewParamsAccessGoogleAppsTypeAzureAd IdentityProviderNewParamsAccessGoogleAppsType = "azureAD" - IdentityProviderNewParamsAccessGoogleAppsTypeSaml IdentityProviderNewParamsAccessGoogleAppsType = "saml" - IdentityProviderNewParamsAccessGoogleAppsTypeCentrify IdentityProviderNewParamsAccessGoogleAppsType = "centrify" - IdentityProviderNewParamsAccessGoogleAppsTypeFacebook IdentityProviderNewParamsAccessGoogleAppsType = "facebook" - IdentityProviderNewParamsAccessGoogleAppsTypeGitHub IdentityProviderNewParamsAccessGoogleAppsType = "github" - IdentityProviderNewParamsAccessGoogleAppsTypeGoogleApps IdentityProviderNewParamsAccessGoogleAppsType = "google-apps" - IdentityProviderNewParamsAccessGoogleAppsTypeGoogle IdentityProviderNewParamsAccessGoogleAppsType = "google" - IdentityProviderNewParamsAccessGoogleAppsTypeLinkedin IdentityProviderNewParamsAccessGoogleAppsType = "linkedin" - IdentityProviderNewParamsAccessGoogleAppsTypeOidc IdentityProviderNewParamsAccessGoogleAppsType = "oidc" - IdentityProviderNewParamsAccessGoogleAppsTypeOkta IdentityProviderNewParamsAccessGoogleAppsType = "okta" - IdentityProviderNewParamsAccessGoogleAppsTypeOnelogin IdentityProviderNewParamsAccessGoogleAppsType = "onelogin" - IdentityProviderNewParamsAccessGoogleAppsTypePingone IdentityProviderNewParamsAccessGoogleAppsType = "pingone" - IdentityProviderNewParamsAccessGoogleAppsTypeYandex IdentityProviderNewParamsAccessGoogleAppsType = "yandex" -) - -func (r IdentityProviderNewParamsAccessGoogleAppsType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessGoogleAppsTypeOnetimepin, IdentityProviderNewParamsAccessGoogleAppsTypeAzureAd, IdentityProviderNewParamsAccessGoogleAppsTypeSaml, IdentityProviderNewParamsAccessGoogleAppsTypeCentrify, IdentityProviderNewParamsAccessGoogleAppsTypeFacebook, IdentityProviderNewParamsAccessGoogleAppsTypeGitHub, IdentityProviderNewParamsAccessGoogleAppsTypeGoogleApps, IdentityProviderNewParamsAccessGoogleAppsTypeGoogle, IdentityProviderNewParamsAccessGoogleAppsTypeLinkedin, IdentityProviderNewParamsAccessGoogleAppsTypeOidc, IdentityProviderNewParamsAccessGoogleAppsTypeOkta, IdentityProviderNewParamsAccessGoogleAppsTypeOnelogin, IdentityProviderNewParamsAccessGoogleAppsTypePingone, IdentityProviderNewParamsAccessGoogleAppsTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessGoogleAppsScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessLinkedin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessLinkedinConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessLinkedinType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessLinkedinScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessLinkedin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessLinkedin) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessLinkedin) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessLinkedin) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessLinkedinConfig struct { - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` -} - -func (r IdentityProviderNewParamsAccessLinkedinConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessLinkedinType string - -const ( - IdentityProviderNewParamsAccessLinkedinTypeOnetimepin IdentityProviderNewParamsAccessLinkedinType = "onetimepin" - IdentityProviderNewParamsAccessLinkedinTypeAzureAd IdentityProviderNewParamsAccessLinkedinType = "azureAD" - IdentityProviderNewParamsAccessLinkedinTypeSaml IdentityProviderNewParamsAccessLinkedinType = "saml" - IdentityProviderNewParamsAccessLinkedinTypeCentrify IdentityProviderNewParamsAccessLinkedinType = "centrify" - IdentityProviderNewParamsAccessLinkedinTypeFacebook IdentityProviderNewParamsAccessLinkedinType = "facebook" - IdentityProviderNewParamsAccessLinkedinTypeGitHub IdentityProviderNewParamsAccessLinkedinType = "github" - IdentityProviderNewParamsAccessLinkedinTypeGoogleApps IdentityProviderNewParamsAccessLinkedinType = "google-apps" - IdentityProviderNewParamsAccessLinkedinTypeGoogle IdentityProviderNewParamsAccessLinkedinType = "google" - IdentityProviderNewParamsAccessLinkedinTypeLinkedin IdentityProviderNewParamsAccessLinkedinType = "linkedin" - IdentityProviderNewParamsAccessLinkedinTypeOidc IdentityProviderNewParamsAccessLinkedinType = "oidc" - IdentityProviderNewParamsAccessLinkedinTypeOkta IdentityProviderNewParamsAccessLinkedinType = "okta" - IdentityProviderNewParamsAccessLinkedinTypeOnelogin IdentityProviderNewParamsAccessLinkedinType = "onelogin" - IdentityProviderNewParamsAccessLinkedinTypePingone IdentityProviderNewParamsAccessLinkedinType = "pingone" - IdentityProviderNewParamsAccessLinkedinTypeYandex IdentityProviderNewParamsAccessLinkedinType = "yandex" -) - -func (r IdentityProviderNewParamsAccessLinkedinType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessLinkedinTypeOnetimepin, IdentityProviderNewParamsAccessLinkedinTypeAzureAd, IdentityProviderNewParamsAccessLinkedinTypeSaml, IdentityProviderNewParamsAccessLinkedinTypeCentrify, IdentityProviderNewParamsAccessLinkedinTypeFacebook, IdentityProviderNewParamsAccessLinkedinTypeGitHub, IdentityProviderNewParamsAccessLinkedinTypeGoogleApps, IdentityProviderNewParamsAccessLinkedinTypeGoogle, IdentityProviderNewParamsAccessLinkedinTypeLinkedin, IdentityProviderNewParamsAccessLinkedinTypeOidc, IdentityProviderNewParamsAccessLinkedinTypeOkta, IdentityProviderNewParamsAccessLinkedinTypeOnelogin, IdentityProviderNewParamsAccessLinkedinTypePingone, IdentityProviderNewParamsAccessLinkedinTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessLinkedinScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessOidc struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessOidcConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessOidcType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessOidcScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessOidc) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessOidc) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessOidc) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessOidc) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessOidcConfig struct { - // The authorization_endpoint URL of your IdP - AuthURL param.Field[string] `json:"auth_url"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CERTsURL param.Field[string] `json:"certs_url"` - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` - // OAuth scopes - Scopes param.Field[[]string] `json:"scopes"` - // The token_endpoint URL of your IdP - TokenURL param.Field[string] `json:"token_url"` -} - -func (r IdentityProviderNewParamsAccessOidcConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessOidcType string - -const ( - IdentityProviderNewParamsAccessOidcTypeOnetimepin IdentityProviderNewParamsAccessOidcType = "onetimepin" - IdentityProviderNewParamsAccessOidcTypeAzureAd IdentityProviderNewParamsAccessOidcType = "azureAD" - IdentityProviderNewParamsAccessOidcTypeSaml IdentityProviderNewParamsAccessOidcType = "saml" - IdentityProviderNewParamsAccessOidcTypeCentrify IdentityProviderNewParamsAccessOidcType = "centrify" - IdentityProviderNewParamsAccessOidcTypeFacebook IdentityProviderNewParamsAccessOidcType = "facebook" - IdentityProviderNewParamsAccessOidcTypeGitHub IdentityProviderNewParamsAccessOidcType = "github" - IdentityProviderNewParamsAccessOidcTypeGoogleApps IdentityProviderNewParamsAccessOidcType = "google-apps" - IdentityProviderNewParamsAccessOidcTypeGoogle IdentityProviderNewParamsAccessOidcType = "google" - IdentityProviderNewParamsAccessOidcTypeLinkedin IdentityProviderNewParamsAccessOidcType = "linkedin" - IdentityProviderNewParamsAccessOidcTypeOidc IdentityProviderNewParamsAccessOidcType = "oidc" - IdentityProviderNewParamsAccessOidcTypeOkta IdentityProviderNewParamsAccessOidcType = "okta" - IdentityProviderNewParamsAccessOidcTypeOnelogin IdentityProviderNewParamsAccessOidcType = "onelogin" - IdentityProviderNewParamsAccessOidcTypePingone IdentityProviderNewParamsAccessOidcType = "pingone" - IdentityProviderNewParamsAccessOidcTypeYandex IdentityProviderNewParamsAccessOidcType = "yandex" -) - -func (r IdentityProviderNewParamsAccessOidcType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessOidcTypeOnetimepin, IdentityProviderNewParamsAccessOidcTypeAzureAd, IdentityProviderNewParamsAccessOidcTypeSaml, IdentityProviderNewParamsAccessOidcTypeCentrify, IdentityProviderNewParamsAccessOidcTypeFacebook, IdentityProviderNewParamsAccessOidcTypeGitHub, IdentityProviderNewParamsAccessOidcTypeGoogleApps, IdentityProviderNewParamsAccessOidcTypeGoogle, IdentityProviderNewParamsAccessOidcTypeLinkedin, IdentityProviderNewParamsAccessOidcTypeOidc, IdentityProviderNewParamsAccessOidcTypeOkta, IdentityProviderNewParamsAccessOidcTypeOnelogin, IdentityProviderNewParamsAccessOidcTypePingone, IdentityProviderNewParamsAccessOidcTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessOidcScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessOkta struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessOktaConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessOktaType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessOktaScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessOkta) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessOkta) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessOkta) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessOktaConfig struct { - // Your okta authorization server id - AuthorizationServerID param.Field[string] `json:"authorization_server_id"` - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` - // Your okta account url - OktaAccount param.Field[string] `json:"okta_account"` -} - -func (r IdentityProviderNewParamsAccessOktaConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessOktaType string - -const ( - IdentityProviderNewParamsAccessOktaTypeOnetimepin IdentityProviderNewParamsAccessOktaType = "onetimepin" - IdentityProviderNewParamsAccessOktaTypeAzureAd IdentityProviderNewParamsAccessOktaType = "azureAD" - IdentityProviderNewParamsAccessOktaTypeSaml IdentityProviderNewParamsAccessOktaType = "saml" - IdentityProviderNewParamsAccessOktaTypeCentrify IdentityProviderNewParamsAccessOktaType = "centrify" - IdentityProviderNewParamsAccessOktaTypeFacebook IdentityProviderNewParamsAccessOktaType = "facebook" - IdentityProviderNewParamsAccessOktaTypeGitHub IdentityProviderNewParamsAccessOktaType = "github" - IdentityProviderNewParamsAccessOktaTypeGoogleApps IdentityProviderNewParamsAccessOktaType = "google-apps" - IdentityProviderNewParamsAccessOktaTypeGoogle IdentityProviderNewParamsAccessOktaType = "google" - IdentityProviderNewParamsAccessOktaTypeLinkedin IdentityProviderNewParamsAccessOktaType = "linkedin" - IdentityProviderNewParamsAccessOktaTypeOidc IdentityProviderNewParamsAccessOktaType = "oidc" - IdentityProviderNewParamsAccessOktaTypeOkta IdentityProviderNewParamsAccessOktaType = "okta" - IdentityProviderNewParamsAccessOktaTypeOnelogin IdentityProviderNewParamsAccessOktaType = "onelogin" - IdentityProviderNewParamsAccessOktaTypePingone IdentityProviderNewParamsAccessOktaType = "pingone" - IdentityProviderNewParamsAccessOktaTypeYandex IdentityProviderNewParamsAccessOktaType = "yandex" -) - -func (r IdentityProviderNewParamsAccessOktaType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessOktaTypeOnetimepin, IdentityProviderNewParamsAccessOktaTypeAzureAd, IdentityProviderNewParamsAccessOktaTypeSaml, IdentityProviderNewParamsAccessOktaTypeCentrify, IdentityProviderNewParamsAccessOktaTypeFacebook, IdentityProviderNewParamsAccessOktaTypeGitHub, IdentityProviderNewParamsAccessOktaTypeGoogleApps, IdentityProviderNewParamsAccessOktaTypeGoogle, IdentityProviderNewParamsAccessOktaTypeLinkedin, IdentityProviderNewParamsAccessOktaTypeOidc, IdentityProviderNewParamsAccessOktaTypeOkta, IdentityProviderNewParamsAccessOktaTypeOnelogin, IdentityProviderNewParamsAccessOktaTypePingone, IdentityProviderNewParamsAccessOktaTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessOktaScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessOnelogin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessOneloginConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessOneloginType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessOneloginScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessOnelogin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessOnelogin) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessOnelogin) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessOnelogin) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessOneloginConfig struct { - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` - // Your OneLogin account url - OneloginAccount param.Field[string] `json:"onelogin_account"` -} - -func (r IdentityProviderNewParamsAccessOneloginConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessOneloginType string - -const ( - IdentityProviderNewParamsAccessOneloginTypeOnetimepin IdentityProviderNewParamsAccessOneloginType = "onetimepin" - IdentityProviderNewParamsAccessOneloginTypeAzureAd IdentityProviderNewParamsAccessOneloginType = "azureAD" - IdentityProviderNewParamsAccessOneloginTypeSaml IdentityProviderNewParamsAccessOneloginType = "saml" - IdentityProviderNewParamsAccessOneloginTypeCentrify IdentityProviderNewParamsAccessOneloginType = "centrify" - IdentityProviderNewParamsAccessOneloginTypeFacebook IdentityProviderNewParamsAccessOneloginType = "facebook" - IdentityProviderNewParamsAccessOneloginTypeGitHub IdentityProviderNewParamsAccessOneloginType = "github" - IdentityProviderNewParamsAccessOneloginTypeGoogleApps IdentityProviderNewParamsAccessOneloginType = "google-apps" - IdentityProviderNewParamsAccessOneloginTypeGoogle IdentityProviderNewParamsAccessOneloginType = "google" - IdentityProviderNewParamsAccessOneloginTypeLinkedin IdentityProviderNewParamsAccessOneloginType = "linkedin" - IdentityProviderNewParamsAccessOneloginTypeOidc IdentityProviderNewParamsAccessOneloginType = "oidc" - IdentityProviderNewParamsAccessOneloginTypeOkta IdentityProviderNewParamsAccessOneloginType = "okta" - IdentityProviderNewParamsAccessOneloginTypeOnelogin IdentityProviderNewParamsAccessOneloginType = "onelogin" - IdentityProviderNewParamsAccessOneloginTypePingone IdentityProviderNewParamsAccessOneloginType = "pingone" - IdentityProviderNewParamsAccessOneloginTypeYandex IdentityProviderNewParamsAccessOneloginType = "yandex" -) - -func (r IdentityProviderNewParamsAccessOneloginType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessOneloginTypeOnetimepin, IdentityProviderNewParamsAccessOneloginTypeAzureAd, IdentityProviderNewParamsAccessOneloginTypeSaml, IdentityProviderNewParamsAccessOneloginTypeCentrify, IdentityProviderNewParamsAccessOneloginTypeFacebook, IdentityProviderNewParamsAccessOneloginTypeGitHub, IdentityProviderNewParamsAccessOneloginTypeGoogleApps, IdentityProviderNewParamsAccessOneloginTypeGoogle, IdentityProviderNewParamsAccessOneloginTypeLinkedin, IdentityProviderNewParamsAccessOneloginTypeOidc, IdentityProviderNewParamsAccessOneloginTypeOkta, IdentityProviderNewParamsAccessOneloginTypeOnelogin, IdentityProviderNewParamsAccessOneloginTypePingone, IdentityProviderNewParamsAccessOneloginTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessOneloginScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessPingone struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessPingoneConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessPingoneType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessPingoneScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessPingone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessPingone) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessPingone) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessPingone) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessPingoneConfig struct { +type IdentityProviderAccessGoogleAppsConfigParam struct { + // Your companies TLD + AppsDomain param.Field[string] `json:"apps_domain"` // Custom claims Claims param.Field[[]string] `json:"claims"` // Your OAuth Client ID @@ -5698,742 +1566,339 @@ type IdentityProviderNewParamsAccessPingoneConfig struct { ClientSecret param.Field[string] `json:"client_secret"` // The claim name for email in the id_token response. EmailClaimName param.Field[string] `json:"email_claim_name"` - // Your PingOne environment identifier - PingEnvID param.Field[string] `json:"ping_env_id"` -} - -func (r IdentityProviderNewParamsAccessPingoneConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessPingoneType string - -const ( - IdentityProviderNewParamsAccessPingoneTypeOnetimepin IdentityProviderNewParamsAccessPingoneType = "onetimepin" - IdentityProviderNewParamsAccessPingoneTypeAzureAd IdentityProviderNewParamsAccessPingoneType = "azureAD" - IdentityProviderNewParamsAccessPingoneTypeSaml IdentityProviderNewParamsAccessPingoneType = "saml" - IdentityProviderNewParamsAccessPingoneTypeCentrify IdentityProviderNewParamsAccessPingoneType = "centrify" - IdentityProviderNewParamsAccessPingoneTypeFacebook IdentityProviderNewParamsAccessPingoneType = "facebook" - IdentityProviderNewParamsAccessPingoneTypeGitHub IdentityProviderNewParamsAccessPingoneType = "github" - IdentityProviderNewParamsAccessPingoneTypeGoogleApps IdentityProviderNewParamsAccessPingoneType = "google-apps" - IdentityProviderNewParamsAccessPingoneTypeGoogle IdentityProviderNewParamsAccessPingoneType = "google" - IdentityProviderNewParamsAccessPingoneTypeLinkedin IdentityProviderNewParamsAccessPingoneType = "linkedin" - IdentityProviderNewParamsAccessPingoneTypeOidc IdentityProviderNewParamsAccessPingoneType = "oidc" - IdentityProviderNewParamsAccessPingoneTypeOkta IdentityProviderNewParamsAccessPingoneType = "okta" - IdentityProviderNewParamsAccessPingoneTypeOnelogin IdentityProviderNewParamsAccessPingoneType = "onelogin" - IdentityProviderNewParamsAccessPingoneTypePingone IdentityProviderNewParamsAccessPingoneType = "pingone" - IdentityProviderNewParamsAccessPingoneTypeYandex IdentityProviderNewParamsAccessPingoneType = "yandex" -) - -func (r IdentityProviderNewParamsAccessPingoneType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessPingoneTypeOnetimepin, IdentityProviderNewParamsAccessPingoneTypeAzureAd, IdentityProviderNewParamsAccessPingoneTypeSaml, IdentityProviderNewParamsAccessPingoneTypeCentrify, IdentityProviderNewParamsAccessPingoneTypeFacebook, IdentityProviderNewParamsAccessPingoneTypeGitHub, IdentityProviderNewParamsAccessPingoneTypeGoogleApps, IdentityProviderNewParamsAccessPingoneTypeGoogle, IdentityProviderNewParamsAccessPingoneTypeLinkedin, IdentityProviderNewParamsAccessPingoneTypeOidc, IdentityProviderNewParamsAccessPingoneTypeOkta, IdentityProviderNewParamsAccessPingoneTypeOnelogin, IdentityProviderNewParamsAccessPingoneTypePingone, IdentityProviderNewParamsAccessPingoneTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessPingoneScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessSaml struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessSamlConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessSamlType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessSamlScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessSaml) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessSaml) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessSaml) ImplementsIdentityProviderNewParams() { - } -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessSamlConfig struct { - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes param.Field[[]string] `json:"attributes"` - // The attribute name for email in the SAML response. - EmailAttributeName param.Field[string] `json:"email_attribute_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes param.Field[[]IdentityProviderNewParamsAccessSamlConfigHeaderAttribute] `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IDPPublicCERTs param.Field[[]string] `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL param.Field[string] `json:"issuer_url"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest param.Field[bool] `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL param.Field[string] `json:"sso_target_url"` -} - -func (r IdentityProviderNewParamsAccessSamlConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderNewParamsAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName param.Field[string] `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName param.Field[string] `json:"header_name"` -} - -func (r IdentityProviderNewParamsAccessSamlConfigHeaderAttribute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessSamlType string - -const ( - IdentityProviderNewParamsAccessSamlTypeOnetimepin IdentityProviderNewParamsAccessSamlType = "onetimepin" - IdentityProviderNewParamsAccessSamlTypeAzureAd IdentityProviderNewParamsAccessSamlType = "azureAD" - IdentityProviderNewParamsAccessSamlTypeSaml IdentityProviderNewParamsAccessSamlType = "saml" - IdentityProviderNewParamsAccessSamlTypeCentrify IdentityProviderNewParamsAccessSamlType = "centrify" - IdentityProviderNewParamsAccessSamlTypeFacebook IdentityProviderNewParamsAccessSamlType = "facebook" - IdentityProviderNewParamsAccessSamlTypeGitHub IdentityProviderNewParamsAccessSamlType = "github" - IdentityProviderNewParamsAccessSamlTypeGoogleApps IdentityProviderNewParamsAccessSamlType = "google-apps" - IdentityProviderNewParamsAccessSamlTypeGoogle IdentityProviderNewParamsAccessSamlType = "google" - IdentityProviderNewParamsAccessSamlTypeLinkedin IdentityProviderNewParamsAccessSamlType = "linkedin" - IdentityProviderNewParamsAccessSamlTypeOidc IdentityProviderNewParamsAccessSamlType = "oidc" - IdentityProviderNewParamsAccessSamlTypeOkta IdentityProviderNewParamsAccessSamlType = "okta" - IdentityProviderNewParamsAccessSamlTypeOnelogin IdentityProviderNewParamsAccessSamlType = "onelogin" - IdentityProviderNewParamsAccessSamlTypePingone IdentityProviderNewParamsAccessSamlType = "pingone" - IdentityProviderNewParamsAccessSamlTypeYandex IdentityProviderNewParamsAccessSamlType = "yandex" -) - -func (r IdentityProviderNewParamsAccessSamlType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessSamlTypeOnetimepin, IdentityProviderNewParamsAccessSamlTypeAzureAd, IdentityProviderNewParamsAccessSamlTypeSaml, IdentityProviderNewParamsAccessSamlTypeCentrify, IdentityProviderNewParamsAccessSamlTypeFacebook, IdentityProviderNewParamsAccessSamlTypeGitHub, IdentityProviderNewParamsAccessSamlTypeGoogleApps, IdentityProviderNewParamsAccessSamlTypeGoogle, IdentityProviderNewParamsAccessSamlTypeLinkedin, IdentityProviderNewParamsAccessSamlTypeOidc, IdentityProviderNewParamsAccessSamlTypeOkta, IdentityProviderNewParamsAccessSamlTypeOnelogin, IdentityProviderNewParamsAccessSamlTypePingone, IdentityProviderNewParamsAccessSamlTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderNewParamsAccessSamlScimConfig) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessGoogleAppsConfigParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type IdentityProviderNewParamsAccessYandex struct { +type IdentityProviderAccessLinkedinParam struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderNewParamsAccessYandexConfig] `json:"config,required"` + Config param.Field[GenericOAuthConfigParam] `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name param.Field[string] `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessYandexType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type param.Field[IdentityProviderType] `json:"type,required"` // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessYandexScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderNewParamsAccessYandex) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderNewParamsAccessYandex) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessYandex) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessYandex) ImplementsIdentityProviderNewParams() { - -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessYandexConfig struct { - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` -} - -func (r IdentityProviderNewParamsAccessYandexConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessYandexType string - -const ( - IdentityProviderNewParamsAccessYandexTypeOnetimepin IdentityProviderNewParamsAccessYandexType = "onetimepin" - IdentityProviderNewParamsAccessYandexTypeAzureAd IdentityProviderNewParamsAccessYandexType = "azureAD" - IdentityProviderNewParamsAccessYandexTypeSaml IdentityProviderNewParamsAccessYandexType = "saml" - IdentityProviderNewParamsAccessYandexTypeCentrify IdentityProviderNewParamsAccessYandexType = "centrify" - IdentityProviderNewParamsAccessYandexTypeFacebook IdentityProviderNewParamsAccessYandexType = "facebook" - IdentityProviderNewParamsAccessYandexTypeGitHub IdentityProviderNewParamsAccessYandexType = "github" - IdentityProviderNewParamsAccessYandexTypeGoogleApps IdentityProviderNewParamsAccessYandexType = "google-apps" - IdentityProviderNewParamsAccessYandexTypeGoogle IdentityProviderNewParamsAccessYandexType = "google" - IdentityProviderNewParamsAccessYandexTypeLinkedin IdentityProviderNewParamsAccessYandexType = "linkedin" - IdentityProviderNewParamsAccessYandexTypeOidc IdentityProviderNewParamsAccessYandexType = "oidc" - IdentityProviderNewParamsAccessYandexTypeOkta IdentityProviderNewParamsAccessYandexType = "okta" - IdentityProviderNewParamsAccessYandexTypeOnelogin IdentityProviderNewParamsAccessYandexType = "onelogin" - IdentityProviderNewParamsAccessYandexTypePingone IdentityProviderNewParamsAccessYandexType = "pingone" - IdentityProviderNewParamsAccessYandexTypeYandex IdentityProviderNewParamsAccessYandexType = "yandex" -) - -func (r IdentityProviderNewParamsAccessYandexType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessYandexTypeOnetimepin, IdentityProviderNewParamsAccessYandexTypeAzureAd, IdentityProviderNewParamsAccessYandexTypeSaml, IdentityProviderNewParamsAccessYandexTypeCentrify, IdentityProviderNewParamsAccessYandexTypeFacebook, IdentityProviderNewParamsAccessYandexTypeGitHub, IdentityProviderNewParamsAccessYandexTypeGoogleApps, IdentityProviderNewParamsAccessYandexTypeGoogle, IdentityProviderNewParamsAccessYandexTypeLinkedin, IdentityProviderNewParamsAccessYandexTypeOidc, IdentityProviderNewParamsAccessYandexTypeOkta, IdentityProviderNewParamsAccessYandexTypeOnelogin, IdentityProviderNewParamsAccessYandexTypePingone, IdentityProviderNewParamsAccessYandexTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r IdentityProviderNewParamsAccessYandexScimConfig) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessLinkedinParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type IdentityProviderNewParamsAccessOnetimepin struct { +func (r IdentityProviderAccessLinkedinParam) implementsZeroTrustIdentityProviderUnionParam() {} + +type IdentityProviderAccessOIDCParam struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[interface{}] `json:"config,required"` + Config param.Field[IdentityProviderAccessOIDCConfigParam] `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name param.Field[string] `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderNewParamsAccessOnetimepinType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type param.Field[IdentityProviderType] `json:"type,required"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderNewParamsAccessOnetimepinScimConfig] `json:"scim_config"` + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r IdentityProviderNewParamsAccessOnetimepin) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessOIDCParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r IdentityProviderNewParamsAccessOnetimepin) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderNewParamsAccessOnetimepin) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderNewParamsAccessOnetimepin) ImplementsIdentityProviderNewParams() { - -} +func (r IdentityProviderAccessOIDCParam) implementsZeroTrustIdentityProviderUnionParam() {} -// The type of identity provider. To determine the value for a specific provider, -// refer to our +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderNewParamsAccessOnetimepinType string - -const ( - IdentityProviderNewParamsAccessOnetimepinTypeOnetimepin IdentityProviderNewParamsAccessOnetimepinType = "onetimepin" - IdentityProviderNewParamsAccessOnetimepinTypeAzureAd IdentityProviderNewParamsAccessOnetimepinType = "azureAD" - IdentityProviderNewParamsAccessOnetimepinTypeSaml IdentityProviderNewParamsAccessOnetimepinType = "saml" - IdentityProviderNewParamsAccessOnetimepinTypeCentrify IdentityProviderNewParamsAccessOnetimepinType = "centrify" - IdentityProviderNewParamsAccessOnetimepinTypeFacebook IdentityProviderNewParamsAccessOnetimepinType = "facebook" - IdentityProviderNewParamsAccessOnetimepinTypeGitHub IdentityProviderNewParamsAccessOnetimepinType = "github" - IdentityProviderNewParamsAccessOnetimepinTypeGoogleApps IdentityProviderNewParamsAccessOnetimepinType = "google-apps" - IdentityProviderNewParamsAccessOnetimepinTypeGoogle IdentityProviderNewParamsAccessOnetimepinType = "google" - IdentityProviderNewParamsAccessOnetimepinTypeLinkedin IdentityProviderNewParamsAccessOnetimepinType = "linkedin" - IdentityProviderNewParamsAccessOnetimepinTypeOidc IdentityProviderNewParamsAccessOnetimepinType = "oidc" - IdentityProviderNewParamsAccessOnetimepinTypeOkta IdentityProviderNewParamsAccessOnetimepinType = "okta" - IdentityProviderNewParamsAccessOnetimepinTypeOnelogin IdentityProviderNewParamsAccessOnetimepinType = "onelogin" - IdentityProviderNewParamsAccessOnetimepinTypePingone IdentityProviderNewParamsAccessOnetimepinType = "pingone" - IdentityProviderNewParamsAccessOnetimepinTypeYandex IdentityProviderNewParamsAccessOnetimepinType = "yandex" -) - -func (r IdentityProviderNewParamsAccessOnetimepinType) IsKnown() bool { - switch r { - case IdentityProviderNewParamsAccessOnetimepinTypeOnetimepin, IdentityProviderNewParamsAccessOnetimepinTypeAzureAd, IdentityProviderNewParamsAccessOnetimepinTypeSaml, IdentityProviderNewParamsAccessOnetimepinTypeCentrify, IdentityProviderNewParamsAccessOnetimepinTypeFacebook, IdentityProviderNewParamsAccessOnetimepinTypeGitHub, IdentityProviderNewParamsAccessOnetimepinTypeGoogleApps, IdentityProviderNewParamsAccessOnetimepinTypeGoogle, IdentityProviderNewParamsAccessOnetimepinTypeLinkedin, IdentityProviderNewParamsAccessOnetimepinTypeOidc, IdentityProviderNewParamsAccessOnetimepinTypeOkta, IdentityProviderNewParamsAccessOnetimepinTypeOnelogin, IdentityProviderNewParamsAccessOnetimepinTypePingone, IdentityProviderNewParamsAccessOnetimepinTypeYandex: - return true - } - return false -} - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderNewParamsAccessOnetimepinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +type IdentityProviderAccessOIDCConfigParam struct { + // The authorization_endpoint URL of your IdP + AuthURL param.Field[string] `json:"auth_url"` + // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens + CERTsURL param.Field[string] `json:"certs_url"` + // Custom claims + Claims param.Field[[]string] `json:"claims"` + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName param.Field[string] `json:"email_claim_name"` + // OAuth scopes + Scopes param.Field[[]string] `json:"scopes"` + // The token_endpoint URL of your IdP + TokenURL param.Field[string] `json:"token_url"` } -func (r IdentityProviderNewParamsAccessOnetimepinScimConfig) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessOIDCConfigParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type IdentityProviderNewResponseEnvelope struct { - Errors []IdentityProviderNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IdentityProviderNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentityProviders `json:"result,required"` - // Whether the API call was successful - Success IdentityProviderNewResponseEnvelopeSuccess `json:"success,required"` - JSON identityProviderNewResponseEnvelopeJSON `json:"-"` -} - -// identityProviderNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [IdentityProviderNewResponseEnvelope] -type identityProviderNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// identityProviderNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IdentityProviderNewResponseEnvelopeErrors] -type identityProviderNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +type IdentityProviderAccessOktaParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[IdentityProviderAccessOktaConfigParam] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r *IdentityProviderNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r IdentityProviderAccessOktaParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r identityProviderNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} +func (r IdentityProviderAccessOktaParam) implementsZeroTrustIdentityProviderUnionParam() {} -type IdentityProviderNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderNewResponseEnvelopeMessagesJSON `json:"-"` +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderAccessOktaConfigParam struct { + // Your okta authorization server id + AuthorizationServerID param.Field[string] `json:"authorization_server_id"` + // Custom claims + Claims param.Field[[]string] `json:"claims"` + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName param.Field[string] `json:"email_claim_name"` + // Your okta account url + OktaAccount param.Field[string] `json:"okta_account"` } -// identityProviderNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [IdentityProviderNewResponseEnvelopeMessages] -type identityProviderNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r IdentityProviderAccessOktaConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *IdentityProviderNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +type IdentityProviderAccessOneloginParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[IdentityProviderAccessOneloginConfigParam] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r identityProviderNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw +func (r IdentityProviderAccessOneloginParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// Whether the API call was successful -type IdentityProviderNewResponseEnvelopeSuccess bool - -const ( - IdentityProviderNewResponseEnvelopeSuccessTrue IdentityProviderNewResponseEnvelopeSuccess = true -) +func (r IdentityProviderAccessOneloginParam) implementsZeroTrustIdentityProviderUnionParam() {} -func (r IdentityProviderNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case IdentityProviderNewResponseEnvelopeSuccessTrue: - return true - } - return false +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderAccessOneloginConfigParam struct { + // Custom claims + Claims param.Field[[]string] `json:"claims"` + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName param.Field[string] `json:"email_claim_name"` + // Your OneLogin account url + OneloginAccount param.Field[string] `json:"onelogin_account"` } -// This interface is a union satisfied by one of the following: -// [IdentityProviderUpdateParamsAccessAzureAd], -// [IdentityProviderUpdateParamsAccessCentrify], -// [IdentityProviderUpdateParamsAccessFacebook], -// [IdentityProviderUpdateParamsAccessGitHub], -// [IdentityProviderUpdateParamsAccessGoogle], -// [IdentityProviderUpdateParamsAccessGoogleApps], -// [IdentityProviderUpdateParamsAccessLinkedin], -// [IdentityProviderUpdateParamsAccessOidc], -// [IdentityProviderUpdateParamsAccessOkta], -// [IdentityProviderUpdateParamsAccessOnelogin], -// [IdentityProviderUpdateParamsAccessPingone], -// [IdentityProviderUpdateParamsAccessSaml], -// [IdentityProviderUpdateParamsAccessYandex], -// [IdentityProviderUpdateParamsAccessOnetimepin]. -type IdentityProviderUpdateParams interface { - ImplementsIdentityProviderUpdateParams() - - getAccountID() param.Field[string] - - getZoneID() param.Field[string] +func (r IdentityProviderAccessOneloginConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type IdentityProviderUpdateParamsAccessAzureAd struct { +type IdentityProviderAccessPingoneParam struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessAzureAdConfig] `json:"config,required"` + Config param.Field[IdentityProviderAccessPingoneConfigParam] `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name param.Field[string] `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessAzureAdType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type param.Field[IdentityProviderType] `json:"type,required"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessAzureAdScimConfig] `json:"scim_config"` + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r IdentityProviderUpdateParamsAccessAzureAd) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessPingoneParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r IdentityProviderUpdateParamsAccessAzureAd) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderUpdateParamsAccessAzureAd) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderUpdateParamsAccessAzureAd) ImplementsIdentityProviderUpdateParams() { - -} +func (r IdentityProviderAccessPingoneParam) implementsZeroTrustIdentityProviderUnionParam() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessAzureAdConfig struct { +type IdentityProviderAccessPingoneConfigParam struct { // Custom claims Claims param.Field[[]string] `json:"claims"` // Your OAuth Client ID ClientID param.Field[string] `json:"client_id"` // Your OAuth Client Secret ClientSecret param.Field[string] `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled param.Field[bool] `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID param.Field[string] `json:"directory_id"` // The claim name for email in the id_token response. EmailClaimName param.Field[string] `json:"email_claim_name"` - // Indicates the type of user interaction that is required. prompt=login forces the - // user to enter their credentials on that request, negating single-sign on. - // prompt=none is the opposite. It ensures that the user isn't presented with any - // interactive prompt. If the request can't be completed silently by using - // single-sign on, the Microsoft identity platform returns an interaction_required - // error. prompt=select_account interrupts single sign-on providing account - // selection experience listing all the accounts either in session or any - // remembered account or an option to choose to use a different account altogether. - Prompt param.Field[IdentityProviderUpdateParamsAccessAzureAdConfigPrompt] `json:"prompt"` - // Should Cloudflare try to load groups from your account - SupportGroups param.Field[bool] `json:"support_groups"` + // Your PingOne environment identifier + PingEnvID param.Field[string] `json:"ping_env_id"` } -func (r IdentityProviderUpdateParamsAccessAzureAdConfig) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessPingoneConfigParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Indicates the type of user interaction that is required. prompt=login forces the -// user to enter their credentials on that request, negating single-sign on. -// prompt=none is the opposite. It ensures that the user isn't presented with any -// interactive prompt. If the request can't be completed silently by using -// single-sign on, the Microsoft identity platform returns an interaction_required -// error. prompt=select_account interrupts single sign-on providing account -// selection experience listing all the accounts either in session or any -// remembered account or an option to choose to use a different account altogether. -type IdentityProviderUpdateParamsAccessAzureAdConfigPrompt string - -const ( - IdentityProviderUpdateParamsAccessAzureAdConfigPromptLogin IdentityProviderUpdateParamsAccessAzureAdConfigPrompt = "login" - IdentityProviderUpdateParamsAccessAzureAdConfigPromptSelectAccount IdentityProviderUpdateParamsAccessAzureAdConfigPrompt = "select_account" - IdentityProviderUpdateParamsAccessAzureAdConfigPromptNone IdentityProviderUpdateParamsAccessAzureAdConfigPrompt = "none" -) - -func (r IdentityProviderUpdateParamsAccessAzureAdConfigPrompt) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessAzureAdConfigPromptLogin, IdentityProviderUpdateParamsAccessAzureAdConfigPromptSelectAccount, IdentityProviderUpdateParamsAccessAzureAdConfigPromptNone: - return true - } - return false +type IdentityProviderAccessSAMLParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[IdentityProviderAccessSAMLConfigParam] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessAzureAdType string - -const ( - IdentityProviderUpdateParamsAccessAzureAdTypeOnetimepin IdentityProviderUpdateParamsAccessAzureAdType = "onetimepin" - IdentityProviderUpdateParamsAccessAzureAdTypeAzureAd IdentityProviderUpdateParamsAccessAzureAdType = "azureAD" - IdentityProviderUpdateParamsAccessAzureAdTypeSaml IdentityProviderUpdateParamsAccessAzureAdType = "saml" - IdentityProviderUpdateParamsAccessAzureAdTypeCentrify IdentityProviderUpdateParamsAccessAzureAdType = "centrify" - IdentityProviderUpdateParamsAccessAzureAdTypeFacebook IdentityProviderUpdateParamsAccessAzureAdType = "facebook" - IdentityProviderUpdateParamsAccessAzureAdTypeGitHub IdentityProviderUpdateParamsAccessAzureAdType = "github" - IdentityProviderUpdateParamsAccessAzureAdTypeGoogleApps IdentityProviderUpdateParamsAccessAzureAdType = "google-apps" - IdentityProviderUpdateParamsAccessAzureAdTypeGoogle IdentityProviderUpdateParamsAccessAzureAdType = "google" - IdentityProviderUpdateParamsAccessAzureAdTypeLinkedin IdentityProviderUpdateParamsAccessAzureAdType = "linkedin" - IdentityProviderUpdateParamsAccessAzureAdTypeOidc IdentityProviderUpdateParamsAccessAzureAdType = "oidc" - IdentityProviderUpdateParamsAccessAzureAdTypeOkta IdentityProviderUpdateParamsAccessAzureAdType = "okta" - IdentityProviderUpdateParamsAccessAzureAdTypeOnelogin IdentityProviderUpdateParamsAccessAzureAdType = "onelogin" - IdentityProviderUpdateParamsAccessAzureAdTypePingone IdentityProviderUpdateParamsAccessAzureAdType = "pingone" - IdentityProviderUpdateParamsAccessAzureAdTypeYandex IdentityProviderUpdateParamsAccessAzureAdType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessAzureAdType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessAzureAdTypeOnetimepin, IdentityProviderUpdateParamsAccessAzureAdTypeAzureAd, IdentityProviderUpdateParamsAccessAzureAdTypeSaml, IdentityProviderUpdateParamsAccessAzureAdTypeCentrify, IdentityProviderUpdateParamsAccessAzureAdTypeFacebook, IdentityProviderUpdateParamsAccessAzureAdTypeGitHub, IdentityProviderUpdateParamsAccessAzureAdTypeGoogleApps, IdentityProviderUpdateParamsAccessAzureAdTypeGoogle, IdentityProviderUpdateParamsAccessAzureAdTypeLinkedin, IdentityProviderUpdateParamsAccessAzureAdTypeOidc, IdentityProviderUpdateParamsAccessAzureAdTypeOkta, IdentityProviderUpdateParamsAccessAzureAdTypeOnelogin, IdentityProviderUpdateParamsAccessAzureAdTypePingone, IdentityProviderUpdateParamsAccessAzureAdTypeYandex: - return true - } - return false +func (r IdentityProviderAccessSAMLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r IdentityProviderAccessSAMLParam) implementsZeroTrustIdentityProviderUnionParam() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderAccessSAMLConfigParam struct { + // A list of SAML attribute names that will be added to your signed JWT token and + // can be used in SAML policy rules. + Attributes param.Field[[]string] `json:"attributes"` + // The attribute name for email in the SAML response. + EmailAttributeName param.Field[string] `json:"email_attribute_name"` + // Add a list of attribute names that will be returned in the response header from + // the Access callback. + HeaderAttributes param.Field[[]IdentityProviderAccessSAMLConfigHeaderAttributeParam] `json:"header_attributes"` + // X509 certificate to verify the signature in the SAML authentication response + IDPPublicCERTs param.Field[[]string] `json:"idp_public_certs"` + // IdP Entity ID or Issuer URL + IssuerURL param.Field[string] `json:"issuer_url"` + // Sign the SAML authentication request with Access credentials. To verify the + // signature, use the public key from the Access certs endpoints. + SignRequest param.Field[bool] `json:"sign_request"` + // URL to send the SAML authentication requests to + SSOTargetURL param.Field[string] `json:"sso_target_url"` +} + +func (r IdentityProviderAccessSAMLConfigParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProviderAccessSAMLConfigHeaderAttributeParam struct { + // attribute name from the IDP + AttributeName param.Field[string] `json:"attribute_name"` + // header that will be added on the request to the origin + HeaderName param.Field[string] `json:"header_name"` } -func (r IdentityProviderUpdateParamsAccessAzureAdScimConfig) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessSAMLConfigHeaderAttributeParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type IdentityProviderUpdateParamsAccessCentrify struct { +type IdentityProviderAccessYandexParam struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessCentrifyConfig] `json:"config,required"` + Config param.Field[GenericOAuthConfigParam] `json:"config,required"` // The name of the identity provider, shown to users on the login page. Name param.Field[string] `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessCentrifyType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type param.Field[IdentityProviderType] `json:"type,required"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessCentrifyScimConfig] `json:"scim_config"` + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -func (r IdentityProviderUpdateParamsAccessCentrify) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessYandexParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r IdentityProviderUpdateParamsAccessCentrify) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderUpdateParamsAccessCentrify) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderUpdateParamsAccessCentrify) ImplementsIdentityProviderUpdateParams() { +func (r IdentityProviderAccessYandexParam) implementsZeroTrustIdentityProviderUnionParam() {} +type IdentityProviderAccessOnetimepinParam struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config param.Field[interface{}] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderType] `json:"type,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig param.Field[ScimConfigParam] `json:"scim_config"` } -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessCentrifyConfig struct { - // Your centrify account url - CentrifyAccount param.Field[string] `json:"centrify_account"` - // Your centrify app id - CentrifyAppID param.Field[string] `json:"centrify_app_id"` - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` -} - -func (r IdentityProviderUpdateParamsAccessCentrifyConfig) MarshalJSON() (data []byte, err error) { +func (r IdentityProviderAccessOnetimepinParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +func (r IdentityProviderAccessOnetimepinParam) implementsZeroTrustIdentityProviderUnionParam() {} + // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessCentrifyType string +type IdentityProviderType string const ( - IdentityProviderUpdateParamsAccessCentrifyTypeOnetimepin IdentityProviderUpdateParamsAccessCentrifyType = "onetimepin" - IdentityProviderUpdateParamsAccessCentrifyTypeAzureAd IdentityProviderUpdateParamsAccessCentrifyType = "azureAD" - IdentityProviderUpdateParamsAccessCentrifyTypeSaml IdentityProviderUpdateParamsAccessCentrifyType = "saml" - IdentityProviderUpdateParamsAccessCentrifyTypeCentrify IdentityProviderUpdateParamsAccessCentrifyType = "centrify" - IdentityProviderUpdateParamsAccessCentrifyTypeFacebook IdentityProviderUpdateParamsAccessCentrifyType = "facebook" - IdentityProviderUpdateParamsAccessCentrifyTypeGitHub IdentityProviderUpdateParamsAccessCentrifyType = "github" - IdentityProviderUpdateParamsAccessCentrifyTypeGoogleApps IdentityProviderUpdateParamsAccessCentrifyType = "google-apps" - IdentityProviderUpdateParamsAccessCentrifyTypeGoogle IdentityProviderUpdateParamsAccessCentrifyType = "google" - IdentityProviderUpdateParamsAccessCentrifyTypeLinkedin IdentityProviderUpdateParamsAccessCentrifyType = "linkedin" - IdentityProviderUpdateParamsAccessCentrifyTypeOidc IdentityProviderUpdateParamsAccessCentrifyType = "oidc" - IdentityProviderUpdateParamsAccessCentrifyTypeOkta IdentityProviderUpdateParamsAccessCentrifyType = "okta" - IdentityProviderUpdateParamsAccessCentrifyTypeOnelogin IdentityProviderUpdateParamsAccessCentrifyType = "onelogin" - IdentityProviderUpdateParamsAccessCentrifyTypePingone IdentityProviderUpdateParamsAccessCentrifyType = "pingone" - IdentityProviderUpdateParamsAccessCentrifyTypeYandex IdentityProviderUpdateParamsAccessCentrifyType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessCentrifyType) IsKnown() bool { + IdentityProviderTypeOnetimepin IdentityProviderType = "onetimepin" + IdentityProviderTypeAzureAD IdentityProviderType = "azureAD" + IdentityProviderTypeSAML IdentityProviderType = "saml" + IdentityProviderTypeCentrify IdentityProviderType = "centrify" + IdentityProviderTypeFacebook IdentityProviderType = "facebook" + IdentityProviderTypeGitHub IdentityProviderType = "github" + IdentityProviderTypeGoogleApps IdentityProviderType = "google-apps" + IdentityProviderTypeGoogle IdentityProviderType = "google" + IdentityProviderTypeLinkedin IdentityProviderType = "linkedin" + IdentityProviderTypeOIDC IdentityProviderType = "oidc" + IdentityProviderTypeOkta IdentityProviderType = "okta" + IdentityProviderTypeOnelogin IdentityProviderType = "onelogin" + IdentityProviderTypePingone IdentityProviderType = "pingone" + IdentityProviderTypeYandex IdentityProviderType = "yandex" +) + +func (r IdentityProviderType) IsKnown() bool { switch r { - case IdentityProviderUpdateParamsAccessCentrifyTypeOnetimepin, IdentityProviderUpdateParamsAccessCentrifyTypeAzureAd, IdentityProviderUpdateParamsAccessCentrifyTypeSaml, IdentityProviderUpdateParamsAccessCentrifyTypeCentrify, IdentityProviderUpdateParamsAccessCentrifyTypeFacebook, IdentityProviderUpdateParamsAccessCentrifyTypeGitHub, IdentityProviderUpdateParamsAccessCentrifyTypeGoogleApps, IdentityProviderUpdateParamsAccessCentrifyTypeGoogle, IdentityProviderUpdateParamsAccessCentrifyTypeLinkedin, IdentityProviderUpdateParamsAccessCentrifyTypeOidc, IdentityProviderUpdateParamsAccessCentrifyTypeOkta, IdentityProviderUpdateParamsAccessCentrifyTypeOnelogin, IdentityProviderUpdateParamsAccessCentrifyTypePingone, IdentityProviderUpdateParamsAccessCentrifyTypeYandex: + case IdentityProviderTypeOnetimepin, IdentityProviderTypeAzureAD, IdentityProviderTypeSAML, IdentityProviderTypeCentrify, IdentityProviderTypeFacebook, IdentityProviderTypeGitHub, IdentityProviderTypeGoogleApps, IdentityProviderTypeGoogle, IdentityProviderTypeLinkedin, IdentityProviderTypeOIDC, IdentityProviderTypeOkta, IdentityProviderTypeOnelogin, IdentityProviderTypePingone, IdentityProviderTypeYandex: return true } return false @@ -6441,113 +1906,49 @@ func (r IdentityProviderUpdateParamsAccessCentrifyType) IsKnown() bool { // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessCentrifyScimConfig struct { +type ScimConfig struct { // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` + Enabled bool `json:"enabled"` // A flag to revoke a user's session in Access and force a reauthentication on the // user's Gateway session when they have been added or removed from a group in the // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` + GroupMemberDeprovision bool `json:"group_member_deprovision"` // A flag to remove a user's seat in Zero Trust when they have been deprovisioned // in the Identity Provider. This cannot be enabled unless user_deprovision is also // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` + SeatDeprovision bool `json:"seat_deprovision"` // A read-only token generated when the SCIM integration is enabled for the first // time. It is redacted on subsequent requests. If you lose this you will need to // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` + Secret string `json:"secret"` // A flag to enable revoking a user's session in Access and Gateway when they have // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r IdentityProviderUpdateParamsAccessCentrifyScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IdentityProviderUpdateParamsAccessFacebook struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessFacebookConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessFacebookType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessFacebookScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderUpdateParamsAccessFacebook) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderUpdateParamsAccessFacebook) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderUpdateParamsAccessFacebook) getZoneID() param.Field[string] { - return r.ZoneID -} - -func (IdentityProviderUpdateParamsAccessFacebook) ImplementsIdentityProviderUpdateParams() { - + UserDeprovision bool `json:"user_deprovision"` + JSON scimConfigJSON `json:"-"` } -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessFacebookConfig struct { - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` +// scimConfigJSON contains the JSON metadata for the struct [ScimConfig] +type scimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessFacebookConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *ScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessFacebookType string - -const ( - IdentityProviderUpdateParamsAccessFacebookTypeOnetimepin IdentityProviderUpdateParamsAccessFacebookType = "onetimepin" - IdentityProviderUpdateParamsAccessFacebookTypeAzureAd IdentityProviderUpdateParamsAccessFacebookType = "azureAD" - IdentityProviderUpdateParamsAccessFacebookTypeSaml IdentityProviderUpdateParamsAccessFacebookType = "saml" - IdentityProviderUpdateParamsAccessFacebookTypeCentrify IdentityProviderUpdateParamsAccessFacebookType = "centrify" - IdentityProviderUpdateParamsAccessFacebookTypeFacebook IdentityProviderUpdateParamsAccessFacebookType = "facebook" - IdentityProviderUpdateParamsAccessFacebookTypeGitHub IdentityProviderUpdateParamsAccessFacebookType = "github" - IdentityProviderUpdateParamsAccessFacebookTypeGoogleApps IdentityProviderUpdateParamsAccessFacebookType = "google-apps" - IdentityProviderUpdateParamsAccessFacebookTypeGoogle IdentityProviderUpdateParamsAccessFacebookType = "google" - IdentityProviderUpdateParamsAccessFacebookTypeLinkedin IdentityProviderUpdateParamsAccessFacebookType = "linkedin" - IdentityProviderUpdateParamsAccessFacebookTypeOidc IdentityProviderUpdateParamsAccessFacebookType = "oidc" - IdentityProviderUpdateParamsAccessFacebookTypeOkta IdentityProviderUpdateParamsAccessFacebookType = "okta" - IdentityProviderUpdateParamsAccessFacebookTypeOnelogin IdentityProviderUpdateParamsAccessFacebookType = "onelogin" - IdentityProviderUpdateParamsAccessFacebookTypePingone IdentityProviderUpdateParamsAccessFacebookType = "pingone" - IdentityProviderUpdateParamsAccessFacebookTypeYandex IdentityProviderUpdateParamsAccessFacebookType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessFacebookType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessFacebookTypeOnetimepin, IdentityProviderUpdateParamsAccessFacebookTypeAzureAd, IdentityProviderUpdateParamsAccessFacebookTypeSaml, IdentityProviderUpdateParamsAccessFacebookTypeCentrify, IdentityProviderUpdateParamsAccessFacebookTypeFacebook, IdentityProviderUpdateParamsAccessFacebookTypeGitHub, IdentityProviderUpdateParamsAccessFacebookTypeGoogleApps, IdentityProviderUpdateParamsAccessFacebookTypeGoogle, IdentityProviderUpdateParamsAccessFacebookTypeLinkedin, IdentityProviderUpdateParamsAccessFacebookTypeOidc, IdentityProviderUpdateParamsAccessFacebookTypeOkta, IdentityProviderUpdateParamsAccessFacebookTypeOnelogin, IdentityProviderUpdateParamsAccessFacebookTypePingone, IdentityProviderUpdateParamsAccessFacebookTypeYandex: - return true - } - return false +func (r scimConfigJSON) RawJSON() string { + return r.raw } // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessFacebookScimConfig struct { +type ScimConfigParam struct { // A flag to enable or disable SCIM for the identity provider. Enabled param.Field[bool] `json:"enabled"` // A flag to revoke a user's session in Access and force a reauthentication on the @@ -6567,1232 +1968,1065 @@ type IdentityProviderUpdateParamsAccessFacebookScimConfig struct { UserDeprovision param.Field[bool] `json:"user_deprovision"` } -func (r IdentityProviderUpdateParamsAccessFacebookScimConfig) MarshalJSON() (data []byte, err error) { +func (r ScimConfigParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type IdentityProviderUpdateParamsAccessGitHub struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessGitHubConfig] `json:"config,required"` +type IdentityProviderListResponse struct { + Config interface{} `json:"config"` + // UUID + ID string `json:"id"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessGitHubType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessGitHubScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderUpdateParamsAccessGitHub) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IdentityProviderUpdateParamsAccessGitHub) getAccountID() param.Field[string] { - return r.AccountID -} - -func (r IdentityProviderUpdateParamsAccessGitHub) getZoneID() param.Field[string] { - return r.ZoneID + Type IdentityProviderType `json:"type,required"` + JSON identityProviderListResponseJSON `json:"-"` + union IdentityProviderListResponseUnion } -func (IdentityProviderUpdateParamsAccessGitHub) ImplementsIdentityProviderUpdateParams() { - +// identityProviderListResponseJSON contains the JSON metadata for the struct +// [IdentityProviderListResponse] +type identityProviderListResponseJSON struct { + Config apijson.Field + ID apijson.Field + Name apijson.Field + ScimConfig apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessGitHubConfig struct { - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` +func (r identityProviderListResponseJSON) RawJSON() string { + return r.raw } -func (r IdentityProviderUpdateParamsAccessGitHubConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *IdentityProviderListResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessGitHubType string - -const ( - IdentityProviderUpdateParamsAccessGitHubTypeOnetimepin IdentityProviderUpdateParamsAccessGitHubType = "onetimepin" - IdentityProviderUpdateParamsAccessGitHubTypeAzureAd IdentityProviderUpdateParamsAccessGitHubType = "azureAD" - IdentityProviderUpdateParamsAccessGitHubTypeSaml IdentityProviderUpdateParamsAccessGitHubType = "saml" - IdentityProviderUpdateParamsAccessGitHubTypeCentrify IdentityProviderUpdateParamsAccessGitHubType = "centrify" - IdentityProviderUpdateParamsAccessGitHubTypeFacebook IdentityProviderUpdateParamsAccessGitHubType = "facebook" - IdentityProviderUpdateParamsAccessGitHubTypeGitHub IdentityProviderUpdateParamsAccessGitHubType = "github" - IdentityProviderUpdateParamsAccessGitHubTypeGoogleApps IdentityProviderUpdateParamsAccessGitHubType = "google-apps" - IdentityProviderUpdateParamsAccessGitHubTypeGoogle IdentityProviderUpdateParamsAccessGitHubType = "google" - IdentityProviderUpdateParamsAccessGitHubTypeLinkedin IdentityProviderUpdateParamsAccessGitHubType = "linkedin" - IdentityProviderUpdateParamsAccessGitHubTypeOidc IdentityProviderUpdateParamsAccessGitHubType = "oidc" - IdentityProviderUpdateParamsAccessGitHubTypeOkta IdentityProviderUpdateParamsAccessGitHubType = "okta" - IdentityProviderUpdateParamsAccessGitHubTypeOnelogin IdentityProviderUpdateParamsAccessGitHubType = "onelogin" - IdentityProviderUpdateParamsAccessGitHubTypePingone IdentityProviderUpdateParamsAccessGitHubType = "pingone" - IdentityProviderUpdateParamsAccessGitHubTypeYandex IdentityProviderUpdateParamsAccessGitHubType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessGitHubType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessGitHubTypeOnetimepin, IdentityProviderUpdateParamsAccessGitHubTypeAzureAd, IdentityProviderUpdateParamsAccessGitHubTypeSaml, IdentityProviderUpdateParamsAccessGitHubTypeCentrify, IdentityProviderUpdateParamsAccessGitHubTypeFacebook, IdentityProviderUpdateParamsAccessGitHubTypeGitHub, IdentityProviderUpdateParamsAccessGitHubTypeGoogleApps, IdentityProviderUpdateParamsAccessGitHubTypeGoogle, IdentityProviderUpdateParamsAccessGitHubTypeLinkedin, IdentityProviderUpdateParamsAccessGitHubTypeOidc, IdentityProviderUpdateParamsAccessGitHubTypeOkta, IdentityProviderUpdateParamsAccessGitHubTypeOnelogin, IdentityProviderUpdateParamsAccessGitHubTypePingone, IdentityProviderUpdateParamsAccessGitHubTypeYandex: - return true - } - return false +func (r IdentityProviderListResponse) AsUnion() IdentityProviderListResponseUnion { + return r.union } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +// Union satisfied by [zero_trust.AzureAD], +// [zero_trust.IdentityProviderListResponseAccessCentrify], +// [zero_trust.IdentityProviderListResponseAccessFacebook], +// [zero_trust.IdentityProviderListResponseAccessGitHub], +// [zero_trust.IdentityProviderListResponseAccessGoogle], +// [zero_trust.IdentityProviderListResponseAccessGoogleApps], +// [zero_trust.IdentityProviderListResponseAccessLinkedin], +// [zero_trust.IdentityProviderListResponseAccessOIDC], +// [zero_trust.IdentityProviderListResponseAccessOkta], +// [zero_trust.IdentityProviderListResponseAccessOnelogin], +// [zero_trust.IdentityProviderListResponseAccessPingone], +// [zero_trust.IdentityProviderListResponseAccessSAML] or +// [zero_trust.IdentityProviderListResponseAccessYandex]. +type IdentityProviderListResponseUnion interface { + implementsZeroTrustIdentityProviderListResponse() } -func (r IdentityProviderUpdateParamsAccessGitHubScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*IdentityProviderListResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AzureAD{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessCentrify{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessFacebook{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessGitHub{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessGoogle{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessGoogleApps{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessLinkedin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessOIDC{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessOkta{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessOnelogin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessPingone{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessSAML{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessYandex{}), + }, + ) } -type IdentityProviderUpdateParamsAccessGoogle struct { +type IdentityProviderListResponseAccessCentrify struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessGoogleConfig] `json:"config,required"` + Config IdentityProviderListResponseAccessCentrifyConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessGoogleType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessGoogleScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessCentrifyJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessGoogle) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessCentrifyJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessCentrify] +type identityProviderListResponseAccessCentrifyJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessGoogle) getAccountID() param.Field[string] { - return r.AccountID +func (r *IdentityProviderListResponseAccessCentrify) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessGoogle) getZoneID() param.Field[string] { - return r.ZoneID +func (r identityProviderListResponseAccessCentrifyJSON) RawJSON() string { + return r.raw } -func (IdentityProviderUpdateParamsAccessGoogle) ImplementsIdentityProviderUpdateParams() { - +func (r IdentityProviderListResponseAccessCentrify) implementsZeroTrustIdentityProviderListResponse() { } // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessGoogleConfig struct { +type IdentityProviderListResponseAccessCentrifyConfig struct { + // Your centrify account url + CentrifyAccount string `json:"centrify_account"` + // Your centrify app id + CentrifyAppID string `json:"centrify_app_id"` // Custom claims - Claims param.Field[[]string] `json:"claims"` + Claims []string `json:"claims"` // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` + ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` + ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderListResponseAccessCentrifyConfigJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessGoogleConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessCentrifyConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessCentrifyConfig] +type identityProviderListResponseAccessCentrifyConfigJSON struct { + CentrifyAccount apijson.Field + CentrifyAppID apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessGoogleType string +func (r *IdentityProviderListResponseAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} -const ( - IdentityProviderUpdateParamsAccessGoogleTypeOnetimepin IdentityProviderUpdateParamsAccessGoogleType = "onetimepin" - IdentityProviderUpdateParamsAccessGoogleTypeAzureAd IdentityProviderUpdateParamsAccessGoogleType = "azureAD" - IdentityProviderUpdateParamsAccessGoogleTypeSaml IdentityProviderUpdateParamsAccessGoogleType = "saml" - IdentityProviderUpdateParamsAccessGoogleTypeCentrify IdentityProviderUpdateParamsAccessGoogleType = "centrify" - IdentityProviderUpdateParamsAccessGoogleTypeFacebook IdentityProviderUpdateParamsAccessGoogleType = "facebook" - IdentityProviderUpdateParamsAccessGoogleTypeGitHub IdentityProviderUpdateParamsAccessGoogleType = "github" - IdentityProviderUpdateParamsAccessGoogleTypeGoogleApps IdentityProviderUpdateParamsAccessGoogleType = "google-apps" - IdentityProviderUpdateParamsAccessGoogleTypeGoogle IdentityProviderUpdateParamsAccessGoogleType = "google" - IdentityProviderUpdateParamsAccessGoogleTypeLinkedin IdentityProviderUpdateParamsAccessGoogleType = "linkedin" - IdentityProviderUpdateParamsAccessGoogleTypeOidc IdentityProviderUpdateParamsAccessGoogleType = "oidc" - IdentityProviderUpdateParamsAccessGoogleTypeOkta IdentityProviderUpdateParamsAccessGoogleType = "okta" - IdentityProviderUpdateParamsAccessGoogleTypeOnelogin IdentityProviderUpdateParamsAccessGoogleType = "onelogin" - IdentityProviderUpdateParamsAccessGoogleTypePingone IdentityProviderUpdateParamsAccessGoogleType = "pingone" - IdentityProviderUpdateParamsAccessGoogleTypeYandex IdentityProviderUpdateParamsAccessGoogleType = "yandex" -) +func (r identityProviderListResponseAccessCentrifyConfigJSON) RawJSON() string { + return r.raw +} -func (r IdentityProviderUpdateParamsAccessGoogleType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessGoogleTypeOnetimepin, IdentityProviderUpdateParamsAccessGoogleTypeAzureAd, IdentityProviderUpdateParamsAccessGoogleTypeSaml, IdentityProviderUpdateParamsAccessGoogleTypeCentrify, IdentityProviderUpdateParamsAccessGoogleTypeFacebook, IdentityProviderUpdateParamsAccessGoogleTypeGitHub, IdentityProviderUpdateParamsAccessGoogleTypeGoogleApps, IdentityProviderUpdateParamsAccessGoogleTypeGoogle, IdentityProviderUpdateParamsAccessGoogleTypeLinkedin, IdentityProviderUpdateParamsAccessGoogleTypeOidc, IdentityProviderUpdateParamsAccessGoogleTypeOkta, IdentityProviderUpdateParamsAccessGoogleTypeOnelogin, IdentityProviderUpdateParamsAccessGoogleTypePingone, IdentityProviderUpdateParamsAccessGoogleTypeYandex: - return true - } - return false +type IdentityProviderListResponseAccessFacebook struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config GenericOAuthConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessFacebookJSON `json:"-"` } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +// identityProviderListResponseAccessFacebookJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessFacebook] +type identityProviderListResponseAccessFacebookJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessGoogleScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *IdentityProviderListResponseAccessFacebook) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessFacebookJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessFacebook) implementsZeroTrustIdentityProviderListResponse() { } -type IdentityProviderUpdateParamsAccessGoogleApps struct { +type IdentityProviderListResponseAccessGitHub struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessGoogleAppsConfig] `json:"config,required"` + Config GenericOAuthConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessGoogleAppsType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessGoogleAppsScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessGitHubJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessGoogleApps) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessGitHubJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessGitHub] +type identityProviderListResponseAccessGitHubJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGitHub) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGitHubJSON) RawJSON() string { + return r.raw } -func (r IdentityProviderUpdateParamsAccessGoogleApps) getAccountID() param.Field[string] { - return r.AccountID +func (r IdentityProviderListResponseAccessGitHub) implementsZeroTrustIdentityProviderListResponse() {} + +type IdentityProviderListResponseAccessGoogle struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessGoogleConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessGoogleJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessGoogleApps) getZoneID() param.Field[string] { - return r.ZoneID +// identityProviderListResponseAccessGoogleJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessGoogle] +type identityProviderListResponseAccessGoogleJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (IdentityProviderUpdateParamsAccessGoogleApps) ImplementsIdentityProviderUpdateParams() { +func (r *IdentityProviderListResponseAccessGoogle) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} +func (r identityProviderListResponseAccessGoogleJSON) RawJSON() string { + return r.raw } +func (r IdentityProviderListResponseAccessGoogle) implementsZeroTrustIdentityProviderListResponse() {} + // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain param.Field[string] `json:"apps_domain"` +type IdentityProviderListResponseAccessGoogleConfig struct { // Custom claims - Claims param.Field[[]string] `json:"claims"` + Claims []string `json:"claims"` // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` + ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` + ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` -} - -func (r IdentityProviderUpdateParamsAccessGoogleAppsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderListResponseAccessGoogleConfigJSON `json:"-"` } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessGoogleAppsType string - -const ( - IdentityProviderUpdateParamsAccessGoogleAppsTypeOnetimepin IdentityProviderUpdateParamsAccessGoogleAppsType = "onetimepin" - IdentityProviderUpdateParamsAccessGoogleAppsTypeAzureAd IdentityProviderUpdateParamsAccessGoogleAppsType = "azureAD" - IdentityProviderUpdateParamsAccessGoogleAppsTypeSaml IdentityProviderUpdateParamsAccessGoogleAppsType = "saml" - IdentityProviderUpdateParamsAccessGoogleAppsTypeCentrify IdentityProviderUpdateParamsAccessGoogleAppsType = "centrify" - IdentityProviderUpdateParamsAccessGoogleAppsTypeFacebook IdentityProviderUpdateParamsAccessGoogleAppsType = "facebook" - IdentityProviderUpdateParamsAccessGoogleAppsTypeGitHub IdentityProviderUpdateParamsAccessGoogleAppsType = "github" - IdentityProviderUpdateParamsAccessGoogleAppsTypeGoogleApps IdentityProviderUpdateParamsAccessGoogleAppsType = "google-apps" - IdentityProviderUpdateParamsAccessGoogleAppsTypeGoogle IdentityProviderUpdateParamsAccessGoogleAppsType = "google" - IdentityProviderUpdateParamsAccessGoogleAppsTypeLinkedin IdentityProviderUpdateParamsAccessGoogleAppsType = "linkedin" - IdentityProviderUpdateParamsAccessGoogleAppsTypeOidc IdentityProviderUpdateParamsAccessGoogleAppsType = "oidc" - IdentityProviderUpdateParamsAccessGoogleAppsTypeOkta IdentityProviderUpdateParamsAccessGoogleAppsType = "okta" - IdentityProviderUpdateParamsAccessGoogleAppsTypeOnelogin IdentityProviderUpdateParamsAccessGoogleAppsType = "onelogin" - IdentityProviderUpdateParamsAccessGoogleAppsTypePingone IdentityProviderUpdateParamsAccessGoogleAppsType = "pingone" - IdentityProviderUpdateParamsAccessGoogleAppsTypeYandex IdentityProviderUpdateParamsAccessGoogleAppsType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessGoogleAppsType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessGoogleAppsTypeOnetimepin, IdentityProviderUpdateParamsAccessGoogleAppsTypeAzureAd, IdentityProviderUpdateParamsAccessGoogleAppsTypeSaml, IdentityProviderUpdateParamsAccessGoogleAppsTypeCentrify, IdentityProviderUpdateParamsAccessGoogleAppsTypeFacebook, IdentityProviderUpdateParamsAccessGoogleAppsTypeGitHub, IdentityProviderUpdateParamsAccessGoogleAppsTypeGoogleApps, IdentityProviderUpdateParamsAccessGoogleAppsTypeGoogle, IdentityProviderUpdateParamsAccessGoogleAppsTypeLinkedin, IdentityProviderUpdateParamsAccessGoogleAppsTypeOidc, IdentityProviderUpdateParamsAccessGoogleAppsTypeOkta, IdentityProviderUpdateParamsAccessGoogleAppsTypeOnelogin, IdentityProviderUpdateParamsAccessGoogleAppsTypePingone, IdentityProviderUpdateParamsAccessGoogleAppsTypeYandex: - return true - } - return false +// identityProviderListResponseAccessGoogleConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessGoogleConfig] +type identityProviderListResponseAccessGoogleConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r *IdentityProviderListResponseAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessGoogleAppsScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r identityProviderListResponseAccessGoogleConfigJSON) RawJSON() string { + return r.raw } -type IdentityProviderUpdateParamsAccessLinkedin struct { +type IdentityProviderListResponseAccessGoogleApps struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessLinkedinConfig] `json:"config,required"` + Config IdentityProviderListResponseAccessGoogleAppsConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessLinkedinType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessLinkedinScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessGoogleAppsJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessLinkedin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessGoogleAppsJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessGoogleApps] +type identityProviderListResponseAccessGoogleAppsJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessLinkedin) getAccountID() param.Field[string] { - return r.AccountID +func (r *IdentityProviderListResponseAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessLinkedin) getZoneID() param.Field[string] { - return r.ZoneID +func (r identityProviderListResponseAccessGoogleAppsJSON) RawJSON() string { + return r.raw } -func (IdentityProviderUpdateParamsAccessLinkedin) ImplementsIdentityProviderUpdateParams() { - +func (r IdentityProviderListResponseAccessGoogleApps) implementsZeroTrustIdentityProviderListResponse() { } // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessLinkedinConfig struct { +type IdentityProviderListResponseAccessGoogleAppsConfig struct { + // Your companies TLD + AppsDomain string `json:"apps_domain"` + // Custom claims + Claims []string `json:"claims"` // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` + ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderListResponseAccessGoogleAppsConfigJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessLinkedinConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessGoogleAppsConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessGoogleAppsConfig] +type identityProviderListResponseAccessGoogleAppsConfigJSON struct { + AppsDomain apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessLinkedinType string +func (r *IdentityProviderListResponseAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} -const ( - IdentityProviderUpdateParamsAccessLinkedinTypeOnetimepin IdentityProviderUpdateParamsAccessLinkedinType = "onetimepin" - IdentityProviderUpdateParamsAccessLinkedinTypeAzureAd IdentityProviderUpdateParamsAccessLinkedinType = "azureAD" - IdentityProviderUpdateParamsAccessLinkedinTypeSaml IdentityProviderUpdateParamsAccessLinkedinType = "saml" - IdentityProviderUpdateParamsAccessLinkedinTypeCentrify IdentityProviderUpdateParamsAccessLinkedinType = "centrify" - IdentityProviderUpdateParamsAccessLinkedinTypeFacebook IdentityProviderUpdateParamsAccessLinkedinType = "facebook" - IdentityProviderUpdateParamsAccessLinkedinTypeGitHub IdentityProviderUpdateParamsAccessLinkedinType = "github" - IdentityProviderUpdateParamsAccessLinkedinTypeGoogleApps IdentityProviderUpdateParamsAccessLinkedinType = "google-apps" - IdentityProviderUpdateParamsAccessLinkedinTypeGoogle IdentityProviderUpdateParamsAccessLinkedinType = "google" - IdentityProviderUpdateParamsAccessLinkedinTypeLinkedin IdentityProviderUpdateParamsAccessLinkedinType = "linkedin" - IdentityProviderUpdateParamsAccessLinkedinTypeOidc IdentityProviderUpdateParamsAccessLinkedinType = "oidc" - IdentityProviderUpdateParamsAccessLinkedinTypeOkta IdentityProviderUpdateParamsAccessLinkedinType = "okta" - IdentityProviderUpdateParamsAccessLinkedinTypeOnelogin IdentityProviderUpdateParamsAccessLinkedinType = "onelogin" - IdentityProviderUpdateParamsAccessLinkedinTypePingone IdentityProviderUpdateParamsAccessLinkedinType = "pingone" - IdentityProviderUpdateParamsAccessLinkedinTypeYandex IdentityProviderUpdateParamsAccessLinkedinType = "yandex" -) +func (r identityProviderListResponseAccessGoogleAppsConfigJSON) RawJSON() string { + return r.raw +} -func (r IdentityProviderUpdateParamsAccessLinkedinType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessLinkedinTypeOnetimepin, IdentityProviderUpdateParamsAccessLinkedinTypeAzureAd, IdentityProviderUpdateParamsAccessLinkedinTypeSaml, IdentityProviderUpdateParamsAccessLinkedinTypeCentrify, IdentityProviderUpdateParamsAccessLinkedinTypeFacebook, IdentityProviderUpdateParamsAccessLinkedinTypeGitHub, IdentityProviderUpdateParamsAccessLinkedinTypeGoogleApps, IdentityProviderUpdateParamsAccessLinkedinTypeGoogle, IdentityProviderUpdateParamsAccessLinkedinTypeLinkedin, IdentityProviderUpdateParamsAccessLinkedinTypeOidc, IdentityProviderUpdateParamsAccessLinkedinTypeOkta, IdentityProviderUpdateParamsAccessLinkedinTypeOnelogin, IdentityProviderUpdateParamsAccessLinkedinTypePingone, IdentityProviderUpdateParamsAccessLinkedinTypeYandex: - return true - } - return false +type IdentityProviderListResponseAccessLinkedin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config GenericOAuthConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessLinkedinJSON `json:"-"` } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +// identityProviderListResponseAccessLinkedinJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessLinkedin] +type identityProviderListResponseAccessLinkedinJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessLinkedinScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *IdentityProviderListResponseAccessLinkedin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessLinkedinJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessLinkedin) implementsZeroTrustIdentityProviderListResponse() { } -type IdentityProviderUpdateParamsAccessOidc struct { +type IdentityProviderListResponseAccessOIDC struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessOidcConfig] `json:"config,required"` + Config IdentityProviderListResponseAccessOIDCConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessOidcType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessOidcScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessOIDCJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessOidc) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessOIDCJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessOIDC] +type identityProviderListResponseAccessOIDCJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessOidc) getAccountID() param.Field[string] { - return r.AccountID +func (r *IdentityProviderListResponseAccessOIDC) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessOidc) getZoneID() param.Field[string] { - return r.ZoneID +func (r identityProviderListResponseAccessOIDCJSON) RawJSON() string { + return r.raw } -func (IdentityProviderUpdateParamsAccessOidc) ImplementsIdentityProviderUpdateParams() { - -} +func (r IdentityProviderListResponseAccessOIDC) implementsZeroTrustIdentityProviderListResponse() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessOidcConfig struct { +type IdentityProviderListResponseAccessOIDCConfig struct { // The authorization_endpoint URL of your IdP - AuthURL param.Field[string] `json:"auth_url"` + AuthURL string `json:"auth_url"` // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CERTsURL param.Field[string] `json:"certs_url"` + CERTsURL string `json:"certs_url"` // Custom claims - Claims param.Field[[]string] `json:"claims"` + Claims []string `json:"claims"` // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` + ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` + ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` + EmailClaimName string `json:"email_claim_name"` // OAuth scopes - Scopes param.Field[[]string] `json:"scopes"` + Scopes []string `json:"scopes"` // The token_endpoint URL of your IdP - TokenURL param.Field[string] `json:"token_url"` -} - -func (r IdentityProviderUpdateParamsAccessOidcConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + TokenURL string `json:"token_url"` + JSON identityProviderListResponseAccessOIDCConfigJSON `json:"-"` } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessOidcType string - -const ( - IdentityProviderUpdateParamsAccessOidcTypeOnetimepin IdentityProviderUpdateParamsAccessOidcType = "onetimepin" - IdentityProviderUpdateParamsAccessOidcTypeAzureAd IdentityProviderUpdateParamsAccessOidcType = "azureAD" - IdentityProviderUpdateParamsAccessOidcTypeSaml IdentityProviderUpdateParamsAccessOidcType = "saml" - IdentityProviderUpdateParamsAccessOidcTypeCentrify IdentityProviderUpdateParamsAccessOidcType = "centrify" - IdentityProviderUpdateParamsAccessOidcTypeFacebook IdentityProviderUpdateParamsAccessOidcType = "facebook" - IdentityProviderUpdateParamsAccessOidcTypeGitHub IdentityProviderUpdateParamsAccessOidcType = "github" - IdentityProviderUpdateParamsAccessOidcTypeGoogleApps IdentityProviderUpdateParamsAccessOidcType = "google-apps" - IdentityProviderUpdateParamsAccessOidcTypeGoogle IdentityProviderUpdateParamsAccessOidcType = "google" - IdentityProviderUpdateParamsAccessOidcTypeLinkedin IdentityProviderUpdateParamsAccessOidcType = "linkedin" - IdentityProviderUpdateParamsAccessOidcTypeOidc IdentityProviderUpdateParamsAccessOidcType = "oidc" - IdentityProviderUpdateParamsAccessOidcTypeOkta IdentityProviderUpdateParamsAccessOidcType = "okta" - IdentityProviderUpdateParamsAccessOidcTypeOnelogin IdentityProviderUpdateParamsAccessOidcType = "onelogin" - IdentityProviderUpdateParamsAccessOidcTypePingone IdentityProviderUpdateParamsAccessOidcType = "pingone" - IdentityProviderUpdateParamsAccessOidcTypeYandex IdentityProviderUpdateParamsAccessOidcType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessOidcType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessOidcTypeOnetimepin, IdentityProviderUpdateParamsAccessOidcTypeAzureAd, IdentityProviderUpdateParamsAccessOidcTypeSaml, IdentityProviderUpdateParamsAccessOidcTypeCentrify, IdentityProviderUpdateParamsAccessOidcTypeFacebook, IdentityProviderUpdateParamsAccessOidcTypeGitHub, IdentityProviderUpdateParamsAccessOidcTypeGoogleApps, IdentityProviderUpdateParamsAccessOidcTypeGoogle, IdentityProviderUpdateParamsAccessOidcTypeLinkedin, IdentityProviderUpdateParamsAccessOidcTypeOidc, IdentityProviderUpdateParamsAccessOidcTypeOkta, IdentityProviderUpdateParamsAccessOidcTypeOnelogin, IdentityProviderUpdateParamsAccessOidcTypePingone, IdentityProviderUpdateParamsAccessOidcTypeYandex: - return true - } - return false +// identityProviderListResponseAccessOIDCConfigJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessOIDCConfig] +type identityProviderListResponseAccessOIDCConfigJSON struct { + AuthURL apijson.Field + CERTsURL apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + Scopes apijson.Field + TokenURL apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r *IdentityProviderListResponseAccessOIDCConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessOidcScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r identityProviderListResponseAccessOIDCConfigJSON) RawJSON() string { + return r.raw } -type IdentityProviderUpdateParamsAccessOkta struct { +type IdentityProviderListResponseAccessOkta struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessOktaConfig] `json:"config,required"` + Config IdentityProviderListResponseAccessOktaConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessOktaType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessOktaScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessOktaJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessOktaJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessOkta] +type identityProviderListResponseAccessOktaJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessOkta) getAccountID() param.Field[string] { - return r.AccountID +func (r *IdentityProviderListResponseAccessOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessOkta) getZoneID() param.Field[string] { - return r.ZoneID +func (r identityProviderListResponseAccessOktaJSON) RawJSON() string { + return r.raw } -func (IdentityProviderUpdateParamsAccessOkta) ImplementsIdentityProviderUpdateParams() { - -} +func (r IdentityProviderListResponseAccessOkta) implementsZeroTrustIdentityProviderListResponse() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessOktaConfig struct { +type IdentityProviderListResponseAccessOktaConfig struct { // Your okta authorization server id - AuthorizationServerID param.Field[string] `json:"authorization_server_id"` + AuthorizationServerID string `json:"authorization_server_id"` // Custom claims - Claims param.Field[[]string] `json:"claims"` + Claims []string `json:"claims"` // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` + ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` + ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` + EmailClaimName string `json:"email_claim_name"` // Your okta account url - OktaAccount param.Field[string] `json:"okta_account"` -} - -func (r IdentityProviderUpdateParamsAccessOktaConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + OktaAccount string `json:"okta_account"` + JSON identityProviderListResponseAccessOktaConfigJSON `json:"-"` } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessOktaType string - -const ( - IdentityProviderUpdateParamsAccessOktaTypeOnetimepin IdentityProviderUpdateParamsAccessOktaType = "onetimepin" - IdentityProviderUpdateParamsAccessOktaTypeAzureAd IdentityProviderUpdateParamsAccessOktaType = "azureAD" - IdentityProviderUpdateParamsAccessOktaTypeSaml IdentityProviderUpdateParamsAccessOktaType = "saml" - IdentityProviderUpdateParamsAccessOktaTypeCentrify IdentityProviderUpdateParamsAccessOktaType = "centrify" - IdentityProviderUpdateParamsAccessOktaTypeFacebook IdentityProviderUpdateParamsAccessOktaType = "facebook" - IdentityProviderUpdateParamsAccessOktaTypeGitHub IdentityProviderUpdateParamsAccessOktaType = "github" - IdentityProviderUpdateParamsAccessOktaTypeGoogleApps IdentityProviderUpdateParamsAccessOktaType = "google-apps" - IdentityProviderUpdateParamsAccessOktaTypeGoogle IdentityProviderUpdateParamsAccessOktaType = "google" - IdentityProviderUpdateParamsAccessOktaTypeLinkedin IdentityProviderUpdateParamsAccessOktaType = "linkedin" - IdentityProviderUpdateParamsAccessOktaTypeOidc IdentityProviderUpdateParamsAccessOktaType = "oidc" - IdentityProviderUpdateParamsAccessOktaTypeOkta IdentityProviderUpdateParamsAccessOktaType = "okta" - IdentityProviderUpdateParamsAccessOktaTypeOnelogin IdentityProviderUpdateParamsAccessOktaType = "onelogin" - IdentityProviderUpdateParamsAccessOktaTypePingone IdentityProviderUpdateParamsAccessOktaType = "pingone" - IdentityProviderUpdateParamsAccessOktaTypeYandex IdentityProviderUpdateParamsAccessOktaType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessOktaType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessOktaTypeOnetimepin, IdentityProviderUpdateParamsAccessOktaTypeAzureAd, IdentityProviderUpdateParamsAccessOktaTypeSaml, IdentityProviderUpdateParamsAccessOktaTypeCentrify, IdentityProviderUpdateParamsAccessOktaTypeFacebook, IdentityProviderUpdateParamsAccessOktaTypeGitHub, IdentityProviderUpdateParamsAccessOktaTypeGoogleApps, IdentityProviderUpdateParamsAccessOktaTypeGoogle, IdentityProviderUpdateParamsAccessOktaTypeLinkedin, IdentityProviderUpdateParamsAccessOktaTypeOidc, IdentityProviderUpdateParamsAccessOktaTypeOkta, IdentityProviderUpdateParamsAccessOktaTypeOnelogin, IdentityProviderUpdateParamsAccessOktaTypePingone, IdentityProviderUpdateParamsAccessOktaTypeYandex: - return true - } - return false +// identityProviderListResponseAccessOktaConfigJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessOktaConfig] +type identityProviderListResponseAccessOktaConfigJSON struct { + AuthorizationServerID apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OktaAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r *IdentityProviderListResponseAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessOktaScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r identityProviderListResponseAccessOktaConfigJSON) RawJSON() string { + return r.raw } -type IdentityProviderUpdateParamsAccessOnelogin struct { +type IdentityProviderListResponseAccessOnelogin struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessOneloginConfig] `json:"config,required"` + Config IdentityProviderListResponseAccessOneloginConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessOneloginType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessOneloginScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessOneloginJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessOnelogin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessOneloginJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessOnelogin] +type identityProviderListResponseAccessOneloginJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessOnelogin) getAccountID() param.Field[string] { - return r.AccountID +func (r *IdentityProviderListResponseAccessOnelogin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessOnelogin) getZoneID() param.Field[string] { - return r.ZoneID +func (r identityProviderListResponseAccessOneloginJSON) RawJSON() string { + return r.raw } -func (IdentityProviderUpdateParamsAccessOnelogin) ImplementsIdentityProviderUpdateParams() { - +func (r IdentityProviderListResponseAccessOnelogin) implementsZeroTrustIdentityProviderListResponse() { } // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessOneloginConfig struct { +type IdentityProviderListResponseAccessOneloginConfig struct { // Custom claims - Claims param.Field[[]string] `json:"claims"` + Claims []string `json:"claims"` // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` + ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` + ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` + EmailClaimName string `json:"email_claim_name"` // Your OneLogin account url - OneloginAccount param.Field[string] `json:"onelogin_account"` -} - -func (r IdentityProviderUpdateParamsAccessOneloginConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + OneloginAccount string `json:"onelogin_account"` + JSON identityProviderListResponseAccessOneloginConfigJSON `json:"-"` } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessOneloginType string - -const ( - IdentityProviderUpdateParamsAccessOneloginTypeOnetimepin IdentityProviderUpdateParamsAccessOneloginType = "onetimepin" - IdentityProviderUpdateParamsAccessOneloginTypeAzureAd IdentityProviderUpdateParamsAccessOneloginType = "azureAD" - IdentityProviderUpdateParamsAccessOneloginTypeSaml IdentityProviderUpdateParamsAccessOneloginType = "saml" - IdentityProviderUpdateParamsAccessOneloginTypeCentrify IdentityProviderUpdateParamsAccessOneloginType = "centrify" - IdentityProviderUpdateParamsAccessOneloginTypeFacebook IdentityProviderUpdateParamsAccessOneloginType = "facebook" - IdentityProviderUpdateParamsAccessOneloginTypeGitHub IdentityProviderUpdateParamsAccessOneloginType = "github" - IdentityProviderUpdateParamsAccessOneloginTypeGoogleApps IdentityProviderUpdateParamsAccessOneloginType = "google-apps" - IdentityProviderUpdateParamsAccessOneloginTypeGoogle IdentityProviderUpdateParamsAccessOneloginType = "google" - IdentityProviderUpdateParamsAccessOneloginTypeLinkedin IdentityProviderUpdateParamsAccessOneloginType = "linkedin" - IdentityProviderUpdateParamsAccessOneloginTypeOidc IdentityProviderUpdateParamsAccessOneloginType = "oidc" - IdentityProviderUpdateParamsAccessOneloginTypeOkta IdentityProviderUpdateParamsAccessOneloginType = "okta" - IdentityProviderUpdateParamsAccessOneloginTypeOnelogin IdentityProviderUpdateParamsAccessOneloginType = "onelogin" - IdentityProviderUpdateParamsAccessOneloginTypePingone IdentityProviderUpdateParamsAccessOneloginType = "pingone" - IdentityProviderUpdateParamsAccessOneloginTypeYandex IdentityProviderUpdateParamsAccessOneloginType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessOneloginType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessOneloginTypeOnetimepin, IdentityProviderUpdateParamsAccessOneloginTypeAzureAd, IdentityProviderUpdateParamsAccessOneloginTypeSaml, IdentityProviderUpdateParamsAccessOneloginTypeCentrify, IdentityProviderUpdateParamsAccessOneloginTypeFacebook, IdentityProviderUpdateParamsAccessOneloginTypeGitHub, IdentityProviderUpdateParamsAccessOneloginTypeGoogleApps, IdentityProviderUpdateParamsAccessOneloginTypeGoogle, IdentityProviderUpdateParamsAccessOneloginTypeLinkedin, IdentityProviderUpdateParamsAccessOneloginTypeOidc, IdentityProviderUpdateParamsAccessOneloginTypeOkta, IdentityProviderUpdateParamsAccessOneloginTypeOnelogin, IdentityProviderUpdateParamsAccessOneloginTypePingone, IdentityProviderUpdateParamsAccessOneloginTypeYandex: - return true - } - return false +// identityProviderListResponseAccessOneloginConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessOneloginConfig] +type identityProviderListResponseAccessOneloginConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OneloginAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r *IdentityProviderListResponseAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessOneloginScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r identityProviderListResponseAccessOneloginConfigJSON) RawJSON() string { + return r.raw } -type IdentityProviderUpdateParamsAccessPingone struct { +type IdentityProviderListResponseAccessPingone struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessPingoneConfig] `json:"config,required"` + Config IdentityProviderListResponseAccessPingoneConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessPingoneType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessPingoneScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessPingoneJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessPingone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessPingoneJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessPingone] +type identityProviderListResponseAccessPingoneJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessPingone) getAccountID() param.Field[string] { - return r.AccountID +func (r *IdentityProviderListResponseAccessPingone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessPingone) getZoneID() param.Field[string] { - return r.ZoneID +func (r identityProviderListResponseAccessPingoneJSON) RawJSON() string { + return r.raw } -func (IdentityProviderUpdateParamsAccessPingone) ImplementsIdentityProviderUpdateParams() { - +func (r IdentityProviderListResponseAccessPingone) implementsZeroTrustIdentityProviderListResponse() { } // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessPingoneConfig struct { +type IdentityProviderListResponseAccessPingoneConfig struct { // Custom claims - Claims param.Field[[]string] `json:"claims"` + Claims []string `json:"claims"` // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` + ClientID string `json:"client_id"` // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` + ClientSecret string `json:"client_secret"` // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` + EmailClaimName string `json:"email_claim_name"` // Your PingOne environment identifier - PingEnvID param.Field[string] `json:"ping_env_id"` -} - -func (r IdentityProviderUpdateParamsAccessPingoneConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + PingEnvID string `json:"ping_env_id"` + JSON identityProviderListResponseAccessPingoneConfigJSON `json:"-"` } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessPingoneType string - -const ( - IdentityProviderUpdateParamsAccessPingoneTypeOnetimepin IdentityProviderUpdateParamsAccessPingoneType = "onetimepin" - IdentityProviderUpdateParamsAccessPingoneTypeAzureAd IdentityProviderUpdateParamsAccessPingoneType = "azureAD" - IdentityProviderUpdateParamsAccessPingoneTypeSaml IdentityProviderUpdateParamsAccessPingoneType = "saml" - IdentityProviderUpdateParamsAccessPingoneTypeCentrify IdentityProviderUpdateParamsAccessPingoneType = "centrify" - IdentityProviderUpdateParamsAccessPingoneTypeFacebook IdentityProviderUpdateParamsAccessPingoneType = "facebook" - IdentityProviderUpdateParamsAccessPingoneTypeGitHub IdentityProviderUpdateParamsAccessPingoneType = "github" - IdentityProviderUpdateParamsAccessPingoneTypeGoogleApps IdentityProviderUpdateParamsAccessPingoneType = "google-apps" - IdentityProviderUpdateParamsAccessPingoneTypeGoogle IdentityProviderUpdateParamsAccessPingoneType = "google" - IdentityProviderUpdateParamsAccessPingoneTypeLinkedin IdentityProviderUpdateParamsAccessPingoneType = "linkedin" - IdentityProviderUpdateParamsAccessPingoneTypeOidc IdentityProviderUpdateParamsAccessPingoneType = "oidc" - IdentityProviderUpdateParamsAccessPingoneTypeOkta IdentityProviderUpdateParamsAccessPingoneType = "okta" - IdentityProviderUpdateParamsAccessPingoneTypeOnelogin IdentityProviderUpdateParamsAccessPingoneType = "onelogin" - IdentityProviderUpdateParamsAccessPingoneTypePingone IdentityProviderUpdateParamsAccessPingoneType = "pingone" - IdentityProviderUpdateParamsAccessPingoneTypeYandex IdentityProviderUpdateParamsAccessPingoneType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessPingoneType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessPingoneTypeOnetimepin, IdentityProviderUpdateParamsAccessPingoneTypeAzureAd, IdentityProviderUpdateParamsAccessPingoneTypeSaml, IdentityProviderUpdateParamsAccessPingoneTypeCentrify, IdentityProviderUpdateParamsAccessPingoneTypeFacebook, IdentityProviderUpdateParamsAccessPingoneTypeGitHub, IdentityProviderUpdateParamsAccessPingoneTypeGoogleApps, IdentityProviderUpdateParamsAccessPingoneTypeGoogle, IdentityProviderUpdateParamsAccessPingoneTypeLinkedin, IdentityProviderUpdateParamsAccessPingoneTypeOidc, IdentityProviderUpdateParamsAccessPingoneTypeOkta, IdentityProviderUpdateParamsAccessPingoneTypeOnelogin, IdentityProviderUpdateParamsAccessPingoneTypePingone, IdentityProviderUpdateParamsAccessPingoneTypeYandex: - return true - } - return false +// identityProviderListResponseAccessPingoneConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessPingoneConfig] +type identityProviderListResponseAccessPingoneConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + PingEnvID apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r *IdentityProviderListResponseAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessPingoneScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r identityProviderListResponseAccessPingoneConfigJSON) RawJSON() string { + return r.raw } -type IdentityProviderUpdateParamsAccessSaml struct { +type IdentityProviderListResponseAccessSAML struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessSamlConfig] `json:"config,required"` + Config IdentityProviderListResponseAccessSAMLConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessSamlType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessSamlScimConfig] `json:"scim_config"` + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessSAMLJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +// identityProviderListResponseAccessSAMLJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessSAML] +type identityProviderListResponseAccessSAMLJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessSaml) getAccountID() param.Field[string] { - return r.AccountID +func (r *IdentityProviderListResponseAccessSAML) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessSaml) getZoneID() param.Field[string] { - return r.ZoneID +func (r identityProviderListResponseAccessSAMLJSON) RawJSON() string { + return r.raw } -func (IdentityProviderUpdateParamsAccessSaml) ImplementsIdentityProviderUpdateParams() { - -} +func (r IdentityProviderListResponseAccessSAML) implementsZeroTrustIdentityProviderListResponse() {} // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessSamlConfig struct { +type IdentityProviderListResponseAccessSAMLConfig struct { // A list of SAML attribute names that will be added to your signed JWT token and // can be used in SAML policy rules. - Attributes param.Field[[]string] `json:"attributes"` + Attributes []string `json:"attributes"` // The attribute name for email in the SAML response. - EmailAttributeName param.Field[string] `json:"email_attribute_name"` + EmailAttributeName string `json:"email_attribute_name"` // Add a list of attribute names that will be returned in the response header from // the Access callback. - HeaderAttributes param.Field[[]IdentityProviderUpdateParamsAccessSamlConfigHeaderAttribute] `json:"header_attributes"` + HeaderAttributes []IdentityProviderListResponseAccessSAMLConfigHeaderAttribute `json:"header_attributes"` // X509 certificate to verify the signature in the SAML authentication response - IDPPublicCERTs param.Field[[]string] `json:"idp_public_certs"` + IDPPublicCERTs []string `json:"idp_public_certs"` // IdP Entity ID or Issuer URL - IssuerURL param.Field[string] `json:"issuer_url"` + IssuerURL string `json:"issuer_url"` // Sign the SAML authentication request with Access credentials. To verify the // signature, use the public key from the Access certs endpoints. - SignRequest param.Field[bool] `json:"sign_request"` + SignRequest bool `json:"sign_request"` // URL to send the SAML authentication requests to - SSOTargetURL param.Field[string] `json:"sso_target_url"` -} - -func (r IdentityProviderUpdateParamsAccessSamlConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + SSOTargetURL string `json:"sso_target_url"` + JSON identityProviderListResponseAccessSAMLConfigJSON `json:"-"` } -type IdentityProviderUpdateParamsAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName param.Field[string] `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName param.Field[string] `json:"header_name"` +// identityProviderListResponseAccessSAMLConfigJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessSAMLConfig] +type identityProviderListResponseAccessSAMLConfigJSON struct { + Attributes apijson.Field + EmailAttributeName apijson.Field + HeaderAttributes apijson.Field + IDPPublicCERTs apijson.Field + IssuerURL apijson.Field + SignRequest apijson.Field + SSOTargetURL apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessSamlConfigHeaderAttribute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r *IdentityProviderListResponseAccessSAMLConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessSamlType string +func (r identityProviderListResponseAccessSAMLConfigJSON) RawJSON() string { + return r.raw +} -const ( - IdentityProviderUpdateParamsAccessSamlTypeOnetimepin IdentityProviderUpdateParamsAccessSamlType = "onetimepin" - IdentityProviderUpdateParamsAccessSamlTypeAzureAd IdentityProviderUpdateParamsAccessSamlType = "azureAD" - IdentityProviderUpdateParamsAccessSamlTypeSaml IdentityProviderUpdateParamsAccessSamlType = "saml" - IdentityProviderUpdateParamsAccessSamlTypeCentrify IdentityProviderUpdateParamsAccessSamlType = "centrify" - IdentityProviderUpdateParamsAccessSamlTypeFacebook IdentityProviderUpdateParamsAccessSamlType = "facebook" - IdentityProviderUpdateParamsAccessSamlTypeGitHub IdentityProviderUpdateParamsAccessSamlType = "github" - IdentityProviderUpdateParamsAccessSamlTypeGoogleApps IdentityProviderUpdateParamsAccessSamlType = "google-apps" - IdentityProviderUpdateParamsAccessSamlTypeGoogle IdentityProviderUpdateParamsAccessSamlType = "google" - IdentityProviderUpdateParamsAccessSamlTypeLinkedin IdentityProviderUpdateParamsAccessSamlType = "linkedin" - IdentityProviderUpdateParamsAccessSamlTypeOidc IdentityProviderUpdateParamsAccessSamlType = "oidc" - IdentityProviderUpdateParamsAccessSamlTypeOkta IdentityProviderUpdateParamsAccessSamlType = "okta" - IdentityProviderUpdateParamsAccessSamlTypeOnelogin IdentityProviderUpdateParamsAccessSamlType = "onelogin" - IdentityProviderUpdateParamsAccessSamlTypePingone IdentityProviderUpdateParamsAccessSamlType = "pingone" - IdentityProviderUpdateParamsAccessSamlTypeYandex IdentityProviderUpdateParamsAccessSamlType = "yandex" -) +type IdentityProviderListResponseAccessSAMLConfigHeaderAttribute struct { + // attribute name from the IDP + AttributeName string `json:"attribute_name"` + // header that will be added on the request to the origin + HeaderName string `json:"header_name"` + JSON identityProviderListResponseAccessSAMLConfigHeaderAttributeJSON `json:"-"` +} -func (r IdentityProviderUpdateParamsAccessSamlType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessSamlTypeOnetimepin, IdentityProviderUpdateParamsAccessSamlTypeAzureAd, IdentityProviderUpdateParamsAccessSamlTypeSaml, IdentityProviderUpdateParamsAccessSamlTypeCentrify, IdentityProviderUpdateParamsAccessSamlTypeFacebook, IdentityProviderUpdateParamsAccessSamlTypeGitHub, IdentityProviderUpdateParamsAccessSamlTypeGoogleApps, IdentityProviderUpdateParamsAccessSamlTypeGoogle, IdentityProviderUpdateParamsAccessSamlTypeLinkedin, IdentityProviderUpdateParamsAccessSamlTypeOidc, IdentityProviderUpdateParamsAccessSamlTypeOkta, IdentityProviderUpdateParamsAccessSamlTypeOnelogin, IdentityProviderUpdateParamsAccessSamlTypePingone, IdentityProviderUpdateParamsAccessSamlTypeYandex: - return true - } - return false +// identityProviderListResponseAccessSAMLConfigHeaderAttributeJSON contains the +// JSON metadata for the struct +// [IdentityProviderListResponseAccessSAMLConfigHeaderAttribute] +type identityProviderListResponseAccessSAMLConfigHeaderAttributeJSON struct { + AttributeName apijson.Field + HeaderName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r *IdentityProviderListResponseAccessSAMLConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessSamlScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r identityProviderListResponseAccessSAMLConfigHeaderAttributeJSON) RawJSON() string { + return r.raw } -type IdentityProviderUpdateParamsAccessYandex struct { +type IdentityProviderListResponseAccessYandex struct { // The configuration parameters for the identity provider. To view the required // parameters for a specific provider, refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[IdentityProviderUpdateParamsAccessYandexConfig] `json:"config,required"` + Config GenericOAuthConfig `json:"config,required"` // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` + Name string `json:"name,required"` // The type of identity provider. To determine the value for a specific provider, // refer to our // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessYandexType] `json:"type,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. - ZoneID param.Field[string] `path:"zone_id"` + Type IdentityProviderType `json:"type,required"` + // UUID + ID string `json:"id"` // The configuration settings for enabling a System for Cross-Domain Identity // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessYandexScimConfig] `json:"scim_config"` -} - -func (r IdentityProviderUpdateParamsAccessYandex) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + ScimConfig ScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessYandexJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessYandex) getAccountID() param.Field[string] { - return r.AccountID +// identityProviderListResponseAccessYandexJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessYandex] +type identityProviderListResponseAccessYandexJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r IdentityProviderUpdateParamsAccessYandex) getZoneID() param.Field[string] { - return r.ZoneID +func (r *IdentityProviderListResponseAccessYandex) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (IdentityProviderUpdateParamsAccessYandex) ImplementsIdentityProviderUpdateParams() { - +func (r identityProviderListResponseAccessYandexJSON) RawJSON() string { + return r.raw } -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessYandexConfig struct { - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` -} +func (r IdentityProviderListResponseAccessYandex) implementsZeroTrustIdentityProviderListResponse() {} -func (r IdentityProviderUpdateParamsAccessYandexConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +type IdentityProviderDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON identityProviderDeleteResponseJSON `json:"-"` } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessYandexType string - -const ( - IdentityProviderUpdateParamsAccessYandexTypeOnetimepin IdentityProviderUpdateParamsAccessYandexType = "onetimepin" - IdentityProviderUpdateParamsAccessYandexTypeAzureAd IdentityProviderUpdateParamsAccessYandexType = "azureAD" - IdentityProviderUpdateParamsAccessYandexTypeSaml IdentityProviderUpdateParamsAccessYandexType = "saml" - IdentityProviderUpdateParamsAccessYandexTypeCentrify IdentityProviderUpdateParamsAccessYandexType = "centrify" - IdentityProviderUpdateParamsAccessYandexTypeFacebook IdentityProviderUpdateParamsAccessYandexType = "facebook" - IdentityProviderUpdateParamsAccessYandexTypeGitHub IdentityProviderUpdateParamsAccessYandexType = "github" - IdentityProviderUpdateParamsAccessYandexTypeGoogleApps IdentityProviderUpdateParamsAccessYandexType = "google-apps" - IdentityProviderUpdateParamsAccessYandexTypeGoogle IdentityProviderUpdateParamsAccessYandexType = "google" - IdentityProviderUpdateParamsAccessYandexTypeLinkedin IdentityProviderUpdateParamsAccessYandexType = "linkedin" - IdentityProviderUpdateParamsAccessYandexTypeOidc IdentityProviderUpdateParamsAccessYandexType = "oidc" - IdentityProviderUpdateParamsAccessYandexTypeOkta IdentityProviderUpdateParamsAccessYandexType = "okta" - IdentityProviderUpdateParamsAccessYandexTypeOnelogin IdentityProviderUpdateParamsAccessYandexType = "onelogin" - IdentityProviderUpdateParamsAccessYandexTypePingone IdentityProviderUpdateParamsAccessYandexType = "pingone" - IdentityProviderUpdateParamsAccessYandexTypeYandex IdentityProviderUpdateParamsAccessYandexType = "yandex" -) - -func (r IdentityProviderUpdateParamsAccessYandexType) IsKnown() bool { - switch r { - case IdentityProviderUpdateParamsAccessYandexTypeOnetimepin, IdentityProviderUpdateParamsAccessYandexTypeAzureAd, IdentityProviderUpdateParamsAccessYandexTypeSaml, IdentityProviderUpdateParamsAccessYandexTypeCentrify, IdentityProviderUpdateParamsAccessYandexTypeFacebook, IdentityProviderUpdateParamsAccessYandexTypeGitHub, IdentityProviderUpdateParamsAccessYandexTypeGoogleApps, IdentityProviderUpdateParamsAccessYandexTypeGoogle, IdentityProviderUpdateParamsAccessYandexTypeLinkedin, IdentityProviderUpdateParamsAccessYandexTypeOidc, IdentityProviderUpdateParamsAccessYandexTypeOkta, IdentityProviderUpdateParamsAccessYandexTypeOnelogin, IdentityProviderUpdateParamsAccessYandexTypePingone, IdentityProviderUpdateParamsAccessYandexTypeYandex: - return true - } - return false +// identityProviderDeleteResponseJSON contains the JSON metadata for the struct +// [IdentityProviderDeleteResponse] +type identityProviderDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +func (r *IdentityProviderDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r IdentityProviderUpdateParamsAccessYandexScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r identityProviderDeleteResponseJSON) RawJSON() string { + return r.raw } -type IdentityProviderUpdateParamsAccessOnetimepin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config param.Field[interface{}] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[IdentityProviderUpdateParamsAccessOnetimepinType] `json:"type,required"` +type IdentityProviderNewParams struct { + IdentityProvider IdentityProviderUnionParam `json:"identity_provider,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. ZoneID param.Field[string] `path:"zone_id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig param.Field[IdentityProviderUpdateParamsAccessOnetimepinScimConfig] `json:"scim_config"` } -func (r IdentityProviderUpdateParamsAccessOnetimepin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r IdentityProviderNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.IdentityProvider) } -func (r IdentityProviderUpdateParamsAccessOnetimepin) getAccountID() param.Field[string] { - return r.AccountID +type IdentityProviderNewResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IdentityProvider `json:"result,required"` + // Whether the API call was successful + Success IdentityProviderNewResponseEnvelopeSuccess `json:"success,required"` + JSON identityProviderNewResponseEnvelopeJSON `json:"-"` } -func (r IdentityProviderUpdateParamsAccessOnetimepin) getZoneID() param.Field[string] { - return r.ZoneID +// identityProviderNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [IdentityProviderNewResponseEnvelope] +type identityProviderNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (IdentityProviderUpdateParamsAccessOnetimepin) ImplementsIdentityProviderUpdateParams() { +func (r *IdentityProviderNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} +func (r identityProviderNewResponseEnvelopeJSON) RawJSON() string { + return r.raw } -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type IdentityProviderUpdateParamsAccessOnetimepinType string +// Whether the API call was successful +type IdentityProviderNewResponseEnvelopeSuccess bool const ( - IdentityProviderUpdateParamsAccessOnetimepinTypeOnetimepin IdentityProviderUpdateParamsAccessOnetimepinType = "onetimepin" - IdentityProviderUpdateParamsAccessOnetimepinTypeAzureAd IdentityProviderUpdateParamsAccessOnetimepinType = "azureAD" - IdentityProviderUpdateParamsAccessOnetimepinTypeSaml IdentityProviderUpdateParamsAccessOnetimepinType = "saml" - IdentityProviderUpdateParamsAccessOnetimepinTypeCentrify IdentityProviderUpdateParamsAccessOnetimepinType = "centrify" - IdentityProviderUpdateParamsAccessOnetimepinTypeFacebook IdentityProviderUpdateParamsAccessOnetimepinType = "facebook" - IdentityProviderUpdateParamsAccessOnetimepinTypeGitHub IdentityProviderUpdateParamsAccessOnetimepinType = "github" - IdentityProviderUpdateParamsAccessOnetimepinTypeGoogleApps IdentityProviderUpdateParamsAccessOnetimepinType = "google-apps" - IdentityProviderUpdateParamsAccessOnetimepinTypeGoogle IdentityProviderUpdateParamsAccessOnetimepinType = "google" - IdentityProviderUpdateParamsAccessOnetimepinTypeLinkedin IdentityProviderUpdateParamsAccessOnetimepinType = "linkedin" - IdentityProviderUpdateParamsAccessOnetimepinTypeOidc IdentityProviderUpdateParamsAccessOnetimepinType = "oidc" - IdentityProviderUpdateParamsAccessOnetimepinTypeOkta IdentityProviderUpdateParamsAccessOnetimepinType = "okta" - IdentityProviderUpdateParamsAccessOnetimepinTypeOnelogin IdentityProviderUpdateParamsAccessOnetimepinType = "onelogin" - IdentityProviderUpdateParamsAccessOnetimepinTypePingone IdentityProviderUpdateParamsAccessOnetimepinType = "pingone" - IdentityProviderUpdateParamsAccessOnetimepinTypeYandex IdentityProviderUpdateParamsAccessOnetimepinType = "yandex" + IdentityProviderNewResponseEnvelopeSuccessTrue IdentityProviderNewResponseEnvelopeSuccess = true ) -func (r IdentityProviderUpdateParamsAccessOnetimepinType) IsKnown() bool { +func (r IdentityProviderNewResponseEnvelopeSuccess) IsKnown() bool { switch r { - case IdentityProviderUpdateParamsAccessOnetimepinTypeOnetimepin, IdentityProviderUpdateParamsAccessOnetimepinTypeAzureAd, IdentityProviderUpdateParamsAccessOnetimepinTypeSaml, IdentityProviderUpdateParamsAccessOnetimepinTypeCentrify, IdentityProviderUpdateParamsAccessOnetimepinTypeFacebook, IdentityProviderUpdateParamsAccessOnetimepinTypeGitHub, IdentityProviderUpdateParamsAccessOnetimepinTypeGoogleApps, IdentityProviderUpdateParamsAccessOnetimepinTypeGoogle, IdentityProviderUpdateParamsAccessOnetimepinTypeLinkedin, IdentityProviderUpdateParamsAccessOnetimepinTypeOidc, IdentityProviderUpdateParamsAccessOnetimepinTypeOkta, IdentityProviderUpdateParamsAccessOnetimepinTypeOnelogin, IdentityProviderUpdateParamsAccessOnetimepinTypePingone, IdentityProviderUpdateParamsAccessOnetimepinTypeYandex: + case IdentityProviderNewResponseEnvelopeSuccessTrue: return true } return false } -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type IdentityProviderUpdateParamsAccessOnetimepinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` +type IdentityProviderUpdateParams struct { + IdentityProvider IdentityProviderUnionParam `json:"identity_provider,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. + ZoneID param.Field[string] `path:"zone_id"` } -func (r IdentityProviderUpdateParamsAccessOnetimepinScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) +func (r IdentityProviderUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.IdentityProvider) } type IdentityProviderUpdateResponseEnvelope struct { - Errors []IdentityProviderUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []IdentityProviderUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentityProviders `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IdentityProvider `json:"result,required"` // Whether the API call was successful Success IdentityProviderUpdateResponseEnvelopeSuccess `json:"success,required"` JSON identityProviderUpdateResponseEnvelopeJSON `json:"-"` @@ -7817,52 +3051,6 @@ func (r identityProviderUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IdentityProviderUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// identityProviderUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [IdentityProviderUpdateResponseEnvelopeErrors] -type identityProviderUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// identityProviderUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [IdentityProviderUpdateResponseEnvelopeMessages] -type identityProviderUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IdentityProviderUpdateResponseEnvelopeSuccess bool @@ -7893,9 +3081,9 @@ type IdentityProviderDeleteParams struct { } type IdentityProviderDeleteResponseEnvelope struct { - Errors []IdentityProviderDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []IdentityProviderDeleteResponseEnvelopeMessages `json:"messages,required"` - Result IdentityProviderDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IdentityProviderDeleteResponse `json:"result,required"` // Whether the API call was successful Success IdentityProviderDeleteResponseEnvelopeSuccess `json:"success,required"` JSON identityProviderDeleteResponseEnvelopeJSON `json:"-"` @@ -7920,52 +3108,6 @@ func (r identityProviderDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IdentityProviderDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// identityProviderDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [IdentityProviderDeleteResponseEnvelopeErrors] -type identityProviderDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// identityProviderDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [IdentityProviderDeleteResponseEnvelopeMessages] -type identityProviderDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IdentityProviderDeleteResponseEnvelopeSuccess bool @@ -7989,9 +3131,9 @@ type IdentityProviderGetParams struct { } type IdentityProviderGetResponseEnvelope struct { - Errors []IdentityProviderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IdentityProviderGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentityProviders `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result IdentityProvider `json:"result,required"` // Whether the API call was successful Success IdentityProviderGetResponseEnvelopeSuccess `json:"success,required"` JSON identityProviderGetResponseEnvelopeJSON `json:"-"` @@ -8016,52 +3158,6 @@ func (r identityProviderGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type IdentityProviderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// identityProviderGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IdentityProviderGetResponseEnvelopeErrors] -type identityProviderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IdentityProviderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON identityProviderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// identityProviderGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [IdentityProviderGetResponseEnvelopeMessages] -type identityProviderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IdentityProviderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r identityProviderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type IdentityProviderGetResponseEnvelopeSuccess bool diff --git a/zero_trust/identityprovider_test.go b/zero_trust/identityprovider_test.go index 23d3ef9623a..9cc3f88cbc1 100644 --- a/zero_trust/identityprovider_test.go +++ b/zero_trust/identityprovider_test.go @@ -28,28 +28,30 @@ func TestIdentityProviderNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.ZeroTrust.IdentityProviders.New(context.TODO(), zero_trust.IdentityProviderNewParamsAccessAzureAd{ - Config: cloudflare.F(zero_trust.IdentityProviderNewParamsAccessAzureAdConfig{ - ClientID: cloudflare.F(""), - ClientSecret: cloudflare.F(""), - Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), - EmailClaimName: cloudflare.F("custom_claim_name"), - ConditionalAccessEnabled: cloudflare.F(true), - DirectoryID: cloudflare.F(""), - Prompt: cloudflare.F(zero_trust.IdentityProviderNewParamsAccessAzureAdConfigPromptLogin), - SupportGroups: cloudflare.F(true), - }), - Name: cloudflare.F("Widget Corps IDP"), - Type: cloudflare.F(zero_trust.IdentityProviderNewParamsAccessAzureAdTypeOnetimepin), + _, err := client.ZeroTrust.IdentityProviders.New(context.TODO(), zero_trust.IdentityProviderNewParams{ + IdentityProvider: zero_trust.AzureADParam{ + Config: cloudflare.F(zero_trust.AzureADConfigParam{ + ClientID: cloudflare.F(""), + ClientSecret: cloudflare.F(""), + Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), + EmailClaimName: cloudflare.F("custom_claim_name"), + ConditionalAccessEnabled: cloudflare.F(true), + DirectoryID: cloudflare.F(""), + Prompt: cloudflare.F(zero_trust.AzureADConfigPromptLogin), + SupportGroups: cloudflare.F(true), + }), + Name: cloudflare.F("Widget Corps IDP"), + ScimConfig: cloudflare.F(zero_trust.ScimConfigParam{ + Enabled: cloudflare.F(true), + GroupMemberDeprovision: cloudflare.F(true), + SeatDeprovision: cloudflare.F(true), + Secret: cloudflare.F("string"), + UserDeprovision: cloudflare.F(true), + }), + Type: cloudflare.F(zero_trust.IdentityProviderTypeOnetimepin), + }, AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - ScimConfig: cloudflare.F(zero_trust.IdentityProviderNewParamsAccessAzureAdScimConfig{ - Enabled: cloudflare.F(true), - GroupMemberDeprovision: cloudflare.F(true), - SeatDeprovision: cloudflare.F(true), - Secret: cloudflare.F("string"), - UserDeprovision: cloudflare.F(true), - }), }) if err != nil { var apierr *cloudflare.Error @@ -77,28 +79,30 @@ func TestIdentityProviderUpdateWithOptionalParams(t *testing.T) { _, err := client.ZeroTrust.IdentityProviders.Update( context.TODO(), "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - zero_trust.IdentityProviderUpdateParamsAccessAzureAd{ - Config: cloudflare.F(zero_trust.IdentityProviderUpdateParamsAccessAzureAdConfig{ - ClientID: cloudflare.F(""), - ClientSecret: cloudflare.F(""), - Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), - EmailClaimName: cloudflare.F("custom_claim_name"), - ConditionalAccessEnabled: cloudflare.F(true), - DirectoryID: cloudflare.F(""), - Prompt: cloudflare.F(zero_trust.IdentityProviderUpdateParamsAccessAzureAdConfigPromptLogin), - SupportGroups: cloudflare.F(true), - }), - Name: cloudflare.F("Widget Corps IDP"), - Type: cloudflare.F(zero_trust.IdentityProviderUpdateParamsAccessAzureAdTypeOnetimepin), + zero_trust.IdentityProviderUpdateParams{ + IdentityProvider: zero_trust.AzureADParam{ + Config: cloudflare.F(zero_trust.AzureADConfigParam{ + ClientID: cloudflare.F(""), + ClientSecret: cloudflare.F(""), + Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), + EmailClaimName: cloudflare.F("custom_claim_name"), + ConditionalAccessEnabled: cloudflare.F(true), + DirectoryID: cloudflare.F(""), + Prompt: cloudflare.F(zero_trust.AzureADConfigPromptLogin), + SupportGroups: cloudflare.F(true), + }), + Name: cloudflare.F("Widget Corps IDP"), + ScimConfig: cloudflare.F(zero_trust.ScimConfigParam{ + Enabled: cloudflare.F(true), + GroupMemberDeprovision: cloudflare.F(true), + SeatDeprovision: cloudflare.F(true), + Secret: cloudflare.F("string"), + UserDeprovision: cloudflare.F(true), + }), + Type: cloudflare.F(zero_trust.IdentityProviderTypeOnetimepin), + }, AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - ScimConfig: cloudflare.F(zero_trust.IdentityProviderUpdateParamsAccessAzureAdScimConfig{ - Enabled: cloudflare.F(true), - GroupMemberDeprovision: cloudflare.F(true), - SeatDeprovision: cloudflare.F(true), - Secret: cloudflare.F("string"), - UserDeprovision: cloudflare.F(true), - }), }, ) if err != nil { diff --git a/zero_trust/networkroute.go b/zero_trust/networkroute.go index 5fbb9b6a8d1..0b05fba680d 100644 --- a/zero_trust/networkroute.go +++ b/zero_trust/networkroute.go @@ -14,6 +14,7 @@ import ( "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" ) @@ -40,7 +41,7 @@ func NewNetworkRouteService(opts ...option.RequestOption) (r *NetworkRouteServic } // Routes a private network through a Cloudflare Tunnel. -func (r *NetworkRouteService) New(ctx context.Context, params NetworkRouteNewParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { +func (r *NetworkRouteService) New(ctx context.Context, params NetworkRouteNewParams, opts ...option.RequestOption) (res *Route, err error) { opts = append(r.Options[:], opts...) var env NetworkRouteNewResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/routes", params.AccountID) @@ -53,7 +54,7 @@ func (r *NetworkRouteService) New(ctx context.Context, params NetworkRouteNewPar } // Lists and filters private network routes in an account. -func (r *NetworkRouteService) List(ctx context.Context, params NetworkRouteListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[TunnelTeamnet], err error) { +func (r *NetworkRouteService) List(ctx context.Context, params NetworkRouteListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Teamnet], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -71,12 +72,12 @@ func (r *NetworkRouteService) List(ctx context.Context, params NetworkRouteListP } // Lists and filters private network routes in an account. -func (r *NetworkRouteService) ListAutoPaging(ctx context.Context, params NetworkRouteListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[TunnelTeamnet] { +func (r *NetworkRouteService) ListAutoPaging(ctx context.Context, params NetworkRouteListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Teamnet] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } // Deletes a private network route from an account. -func (r *NetworkRouteService) Delete(ctx context.Context, routeID string, body NetworkRouteDeleteParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { +func (r *NetworkRouteService) Delete(ctx context.Context, routeID string, body NetworkRouteDeleteParams, opts ...option.RequestOption) (res *Route, err error) { opts = append(r.Options[:], opts...) var env NetworkRouteDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/routes/%s", body.AccountID, routeID) @@ -90,7 +91,7 @@ func (r *NetworkRouteService) Delete(ctx context.Context, routeID string, body N // Updates an existing private network route in an account. The fields that are // meant to be updated should be provided in the body of the request. -func (r *NetworkRouteService) Edit(ctx context.Context, routeID string, params NetworkRouteEditParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { +func (r *NetworkRouteService) Edit(ctx context.Context, routeID string, params NetworkRouteEditParams, opts ...option.RequestOption) (res *Route, err error) { opts = append(r.Options[:], opts...) var env NetworkRouteEditResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/routes/%s", params.AccountID, routeID) @@ -102,7 +103,7 @@ func (r *NetworkRouteService) Edit(ctx context.Context, routeID string, params N return } -type TunnelRoute struct { +type Route struct { // UUID of the route. ID string `json:"id"` // Optional remark describing the route. @@ -119,12 +120,12 @@ type TunnelRoute struct { // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks // are configured, the route is assigned to the default virtual network of the // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - JSON tunnelRouteJSON `json:"-"` + VirtualNetworkID interface{} `json:"virtual_network_id"` + JSON routeJSON `json:"-"` } -// tunnelRouteJSON contains the JSON metadata for the struct [TunnelRoute] -type tunnelRouteJSON struct { +// routeJSON contains the JSON metadata for the struct [Route] +type routeJSON struct { ID apijson.Field Comment apijson.Field CreatedAt apijson.Field @@ -136,15 +137,34 @@ type tunnelRouteJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelRoute) UnmarshalJSON(data []byte) (err error) { +func (r *Route) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tunnelRouteJSON) RawJSON() string { +func (r routeJSON) RawJSON() string { return r.raw } -type TunnelTeamnet struct { +type RouteParam struct { + // Optional remark describing the route. + Comment param.Field[string] `json:"comment"` + // Timestamp of when the route was created. + CreatedAt param.Field[interface{}] `json:"created_at"` + // The private IPv4 or IPv6 range connected by the route, in CIDR notation. + Network param.Field[string] `json:"network"` + // UUID of the Cloudflare Tunnel serving the route. + TunnelID param.Field[interface{}] `json:"tunnel_id"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID param.Field[interface{}] `json:"virtual_network_id"` +} + +func (r RouteParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Teamnet struct { // UUID of the route. ID string `json:"id"` // Optional remark describing the route. @@ -157,7 +177,7 @@ type TunnelTeamnet struct { // The private IPv4 or IPv6 range connected by the route, in CIDR notation. Network string `json:"network"` // The type of tunnel. - TunType TunnelTeamnetTunType `json:"tun_type"` + TunType TeamnetTunType `json:"tun_type"` // UUID of the Cloudflare Tunnel serving the route. TunnelID interface{} `json:"tunnel_id"` // The user-friendly name of the Cloudflare Tunnel serving the route. @@ -167,12 +187,12 @@ type TunnelTeamnet struct { // account. VirtualNetworkID interface{} `json:"virtual_network_id"` // A user-friendly name for the virtual network. - VirtualNetworkName string `json:"virtual_network_name"` - JSON tunnelTeamnetJSON `json:"-"` + VirtualNetworkName string `json:"virtual_network_name"` + JSON teamnetJSON `json:"-"` } -// tunnelTeamnetJSON contains the JSON metadata for the struct [TunnelTeamnet] -type tunnelTeamnetJSON struct { +// teamnetJSON contains the JSON metadata for the struct [Teamnet] +type teamnetJSON struct { ID apijson.Field Comment apijson.Field CreatedAt apijson.Field @@ -187,28 +207,28 @@ type tunnelTeamnetJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelTeamnet) UnmarshalJSON(data []byte) (err error) { +func (r *Teamnet) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tunnelTeamnetJSON) RawJSON() string { +func (r teamnetJSON) RawJSON() string { return r.raw } // The type of tunnel. -type TunnelTeamnetTunType string +type TeamnetTunType string const ( - TunnelTeamnetTunTypeCfdTunnel TunnelTeamnetTunType = "cfd_tunnel" - TunnelTeamnetTunTypeWARPConnector TunnelTeamnetTunType = "warp_connector" - TunnelTeamnetTunTypeIPSec TunnelTeamnetTunType = "ip_sec" - TunnelTeamnetTunTypeGRE TunnelTeamnetTunType = "gre" - TunnelTeamnetTunTypeCni TunnelTeamnetTunType = "cni" + TeamnetTunTypeCfdTunnel TeamnetTunType = "cfd_tunnel" + TeamnetTunTypeWARPConnector TeamnetTunType = "warp_connector" + TeamnetTunTypeIPSec TeamnetTunType = "ip_sec" + TeamnetTunTypeGRE TeamnetTunType = "gre" + TeamnetTunTypeCNI TeamnetTunType = "cni" ) -func (r TunnelTeamnetTunType) IsKnown() bool { +func (r TeamnetTunType) IsKnown() bool { switch r { - case TunnelTeamnetTunTypeCfdTunnel, TunnelTeamnetTunTypeWARPConnector, TunnelTeamnetTunTypeIPSec, TunnelTeamnetTunTypeGRE, TunnelTeamnetTunTypeCni: + case TeamnetTunTypeCfdTunnel, TeamnetTunTypeWARPConnector, TeamnetTunTypeIPSec, TeamnetTunTypeGRE, TeamnetTunTypeCNI: return true } return false @@ -232,9 +252,9 @@ func (r NetworkRouteNewParams) MarshalJSON() (data []byte, err error) { } type NetworkRouteNewResponseEnvelope struct { - Errors []NetworkRouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkRouteNewResponseEnvelopeMessages `json:"messages,required"` - Result TunnelRoute `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Route `json:"result,required"` // Whether the API call was successful Success NetworkRouteNewResponseEnvelopeSuccess `json:"success,required"` JSON networkRouteNewResponseEnvelopeJSON `json:"-"` @@ -259,52 +279,6 @@ func (r networkRouteNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkRouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkRouteNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NetworkRouteNewResponseEnvelopeErrors] -type networkRouteNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkRouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkRouteNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [NetworkRouteNewResponseEnvelopeMessages] -type networkRouteNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkRouteNewResponseEnvelopeSuccess bool @@ -339,6 +313,8 @@ type NetworkRouteListParams struct { Page param.Field[float64] `query:"page"` // Number of results to display. PerPage param.Field[float64] `query:"per_page"` + // UUID of the route. + RouteID param.Field[string] `query:"route_id"` // The types of tunnels to filter separated by a comma. TunTypes param.Field[string] `query:"tun_types"` // UUID of the Cloudflare Tunnel serving the route. @@ -352,7 +328,7 @@ type NetworkRouteListParams struct { // URLQuery serializes [NetworkRouteListParams]'s query parameters as `url.Values`. func (r NetworkRouteListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -363,9 +339,9 @@ type NetworkRouteDeleteParams struct { } type NetworkRouteDeleteResponseEnvelope struct { - Errors []NetworkRouteDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkRouteDeleteResponseEnvelopeMessages `json:"messages,required"` - Result TunnelRoute `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Route `json:"result,required"` // Whether the API call was successful Success NetworkRouteDeleteResponseEnvelopeSuccess `json:"success,required"` JSON networkRouteDeleteResponseEnvelopeJSON `json:"-"` @@ -390,52 +366,6 @@ func (r networkRouteDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkRouteDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkRouteDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NetworkRouteDeleteResponseEnvelopeErrors] -type networkRouteDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkRouteDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkRouteDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [NetworkRouteDeleteResponseEnvelopeMessages] -type networkRouteDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkRouteDeleteResponseEnvelopeSuccess bool @@ -480,21 +410,21 @@ const ( NetworkRouteEditParamsTunTypeWARPConnector NetworkRouteEditParamsTunType = "warp_connector" NetworkRouteEditParamsTunTypeIPSec NetworkRouteEditParamsTunType = "ip_sec" NetworkRouteEditParamsTunTypeGRE NetworkRouteEditParamsTunType = "gre" - NetworkRouteEditParamsTunTypeCni NetworkRouteEditParamsTunType = "cni" + NetworkRouteEditParamsTunTypeCNI NetworkRouteEditParamsTunType = "cni" ) func (r NetworkRouteEditParamsTunType) IsKnown() bool { switch r { - case NetworkRouteEditParamsTunTypeCfdTunnel, NetworkRouteEditParamsTunTypeWARPConnector, NetworkRouteEditParamsTunTypeIPSec, NetworkRouteEditParamsTunTypeGRE, NetworkRouteEditParamsTunTypeCni: + case NetworkRouteEditParamsTunTypeCfdTunnel, NetworkRouteEditParamsTunTypeWARPConnector, NetworkRouteEditParamsTunTypeIPSec, NetworkRouteEditParamsTunTypeGRE, NetworkRouteEditParamsTunTypeCNI: return true } return false } type NetworkRouteEditResponseEnvelope struct { - Errors []NetworkRouteEditResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkRouteEditResponseEnvelopeMessages `json:"messages,required"` - Result TunnelRoute `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Route `json:"result,required"` // Whether the API call was successful Success NetworkRouteEditResponseEnvelopeSuccess `json:"success,required"` JSON networkRouteEditResponseEnvelopeJSON `json:"-"` @@ -519,52 +449,6 @@ func (r networkRouteEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkRouteEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkRouteEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NetworkRouteEditResponseEnvelopeErrors] -type networkRouteEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkRouteEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkRouteEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [NetworkRouteEditResponseEnvelopeMessages] -type networkRouteEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkRouteEditResponseEnvelopeSuccess bool diff --git a/zero_trust/networkroute_test.go b/zero_trust/networkroute_test.go index 76d1c61260c..3c04502ea7f 100644 --- a/zero_trust/networkroute_test.go +++ b/zero_trust/networkroute_test.go @@ -66,6 +66,7 @@ func TestNetworkRouteListWithOptionalParams(t *testing.T) { NetworkSuperset: cloudflare.F[any](map[string]interface{}{}), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(1.000000), + RouteID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), TunTypes: cloudflare.F("cfd_tunnel,warp_connector"), TunnelID: cloudflare.F[any](map[string]interface{}{}), VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), diff --git a/zero_trust/networkrouteip.go b/zero_trust/networkrouteip.go index 82df8248e93..cc9d69f8a3a 100644 --- a/zero_trust/networkrouteip.go +++ b/zero_trust/networkrouteip.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -34,7 +35,7 @@ func NewNetworkRouteIPService(opts ...option.RequestOption) (r *NetworkRouteIPSe } // Fetches routes that contain the given IP address. -func (r *NetworkRouteIPService) Get(ctx context.Context, ip string, params NetworkRouteIPGetParams, opts ...option.RequestOption) (res *TunnelTeamnet, err error) { +func (r *NetworkRouteIPService) Get(ctx context.Context, ip string, params NetworkRouteIPGetParams, opts ...option.RequestOption) (res *Teamnet, err error) { opts = append(r.Options[:], opts...) var env NetworkRouteIPGetResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/routes/ip/%s", params.AccountID, ip) @@ -59,15 +60,15 @@ type NetworkRouteIPGetParams struct { // `url.Values`. func (r NetworkRouteIPGetParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type NetworkRouteIPGetResponseEnvelope struct { - Errors []NetworkRouteIPGetResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkRouteIPGetResponseEnvelopeMessages `json:"messages,required"` - Result TunnelTeamnet `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Teamnet `json:"result,required"` // Whether the API call was successful Success NetworkRouteIPGetResponseEnvelopeSuccess `json:"success,required"` JSON networkRouteIPGetResponseEnvelopeJSON `json:"-"` @@ -92,52 +93,6 @@ func (r networkRouteIPGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkRouteIPGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteIPGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkRouteIPGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [NetworkRouteIPGetResponseEnvelopeErrors] -type networkRouteIPGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteIPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteIPGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkRouteIPGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteIPGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkRouteIPGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [NetworkRouteIPGetResponseEnvelopeMessages] -type networkRouteIPGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteIPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteIPGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkRouteIPGetResponseEnvelopeSuccess bool diff --git a/zero_trust/networkroutenetwork.go b/zero_trust/networkroutenetwork.go index 527df647113..cbaf1aafbaf 100644 --- a/zero_trust/networkroutenetwork.go +++ b/zero_trust/networkroutenetwork.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -35,7 +36,7 @@ func NewNetworkRouteNetworkService(opts ...option.RequestOption) (r *NetworkRout // Routes a private network through a Cloudflare Tunnel. The CIDR in // `ip_network_encoded` must be written in URL-encoded format. -func (r *NetworkRouteNetworkService) New(ctx context.Context, ipNetworkEncoded string, params NetworkRouteNetworkNewParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { +func (r *NetworkRouteNetworkService) New(ctx context.Context, ipNetworkEncoded string, params NetworkRouteNetworkNewParams, opts ...option.RequestOption) (res *Route, err error) { opts = append(r.Options[:], opts...) var env NetworkRouteNetworkNewResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", params.AccountID, ipNetworkEncoded) @@ -54,7 +55,7 @@ func (r *NetworkRouteNetworkService) New(ctx context.Context, ipNetworkEncoded s // is missing it will assume Cloudflare Tunnel as default. If tunnel_id is provided // it will delete the route from that tunnel, otherwise it will delete the route // based on the vnet and tun_type. -func (r *NetworkRouteNetworkService) Delete(ctx context.Context, ipNetworkEncoded string, params NetworkRouteNetworkDeleteParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { +func (r *NetworkRouteNetworkService) Delete(ctx context.Context, ipNetworkEncoded string, params NetworkRouteNetworkDeleteParams, opts ...option.RequestOption) (res *Route, err error) { opts = append(r.Options[:], opts...) var env NetworkRouteNetworkDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", params.AccountID, ipNetworkEncoded) @@ -68,7 +69,7 @@ func (r *NetworkRouteNetworkService) Delete(ctx context.Context, ipNetworkEncode // Updates an existing private network route in an account. The CIDR in // `ip_network_encoded` must be written in URL-encoded format. -func (r *NetworkRouteNetworkService) Edit(ctx context.Context, ipNetworkEncoded string, body NetworkRouteNetworkEditParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { +func (r *NetworkRouteNetworkService) Edit(ctx context.Context, ipNetworkEncoded string, body NetworkRouteNetworkEditParams, opts ...option.RequestOption) (res *Route, err error) { opts = append(r.Options[:], opts...) var env NetworkRouteNetworkEditResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", body.AccountID, ipNetworkEncoded) @@ -96,9 +97,9 @@ func (r NetworkRouteNetworkNewParams) MarshalJSON() (data []byte, err error) { } type NetworkRouteNetworkNewResponseEnvelope struct { - Errors []NetworkRouteNetworkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkRouteNetworkNewResponseEnvelopeMessages `json:"messages,required"` - Result TunnelRoute `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Route `json:"result,required"` // Whether the API call was successful Success NetworkRouteNetworkNewResponseEnvelopeSuccess `json:"success,required"` JSON networkRouteNetworkNewResponseEnvelopeJSON `json:"-"` @@ -123,52 +124,6 @@ func (r networkRouteNetworkNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkRouteNetworkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNetworkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkRouteNetworkNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [NetworkRouteNetworkNewResponseEnvelopeErrors] -type networkRouteNetworkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkRouteNetworkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNetworkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkRouteNetworkNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [NetworkRouteNetworkNewResponseEnvelopeMessages] -type networkRouteNetworkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkRouteNetworkNewResponseEnvelopeSuccess bool @@ -189,13 +144,17 @@ type NetworkRouteNetworkDeleteParams struct { AccountID param.Field[string] `path:"account_id,required"` // The type of tunnel. TunType param.Field[NetworkRouteNetworkDeleteParamsTunType] `query:"tun_type"` + // UUID of the tunnel. + TunnelID param.Field[string] `query:"tunnel_id"` + // UUID of the virtual network. + VirtualNetworkID param.Field[string] `query:"virtual_network_id"` } // URLQuery serializes [NetworkRouteNetworkDeleteParams]'s query parameters as // `url.Values`. func (r NetworkRouteNetworkDeleteParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -208,21 +167,21 @@ const ( NetworkRouteNetworkDeleteParamsTunTypeWARPConnector NetworkRouteNetworkDeleteParamsTunType = "warp_connector" NetworkRouteNetworkDeleteParamsTunTypeIPSec NetworkRouteNetworkDeleteParamsTunType = "ip_sec" NetworkRouteNetworkDeleteParamsTunTypeGRE NetworkRouteNetworkDeleteParamsTunType = "gre" - NetworkRouteNetworkDeleteParamsTunTypeCni NetworkRouteNetworkDeleteParamsTunType = "cni" + NetworkRouteNetworkDeleteParamsTunTypeCNI NetworkRouteNetworkDeleteParamsTunType = "cni" ) func (r NetworkRouteNetworkDeleteParamsTunType) IsKnown() bool { switch r { - case NetworkRouteNetworkDeleteParamsTunTypeCfdTunnel, NetworkRouteNetworkDeleteParamsTunTypeWARPConnector, NetworkRouteNetworkDeleteParamsTunTypeIPSec, NetworkRouteNetworkDeleteParamsTunTypeGRE, NetworkRouteNetworkDeleteParamsTunTypeCni: + case NetworkRouteNetworkDeleteParamsTunTypeCfdTunnel, NetworkRouteNetworkDeleteParamsTunTypeWARPConnector, NetworkRouteNetworkDeleteParamsTunTypeIPSec, NetworkRouteNetworkDeleteParamsTunTypeGRE, NetworkRouteNetworkDeleteParamsTunTypeCNI: return true } return false } type NetworkRouteNetworkDeleteResponseEnvelope struct { - Errors []NetworkRouteNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkRouteNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result TunnelRoute `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Route `json:"result,required"` // Whether the API call was successful Success NetworkRouteNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` JSON networkRouteNetworkDeleteResponseEnvelopeJSON `json:"-"` @@ -247,52 +206,6 @@ func (r networkRouteNetworkDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkRouteNetworkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkRouteNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [NetworkRouteNetworkDeleteResponseEnvelopeErrors] -type networkRouteNetworkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkRouteNetworkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkRouteNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [NetworkRouteNetworkDeleteResponseEnvelopeMessages] -type networkRouteNetworkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkRouteNetworkDeleteResponseEnvelopeSuccess bool @@ -314,9 +227,9 @@ type NetworkRouteNetworkEditParams struct { } type NetworkRouteNetworkEditResponseEnvelope struct { - Errors []NetworkRouteNetworkEditResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkRouteNetworkEditResponseEnvelopeMessages `json:"messages,required"` - Result TunnelRoute `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Route `json:"result,required"` // Whether the API call was successful Success NetworkRouteNetworkEditResponseEnvelopeSuccess `json:"success,required"` JSON networkRouteNetworkEditResponseEnvelopeJSON `json:"-"` @@ -341,52 +254,6 @@ func (r networkRouteNetworkEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkRouteNetworkEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNetworkEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkRouteNetworkEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [NetworkRouteNetworkEditResponseEnvelopeErrors] -type networkRouteNetworkEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNetworkEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNetworkEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkRouteNetworkEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkRouteNetworkEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkRouteNetworkEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [NetworkRouteNetworkEditResponseEnvelopeMessages] -type networkRouteNetworkEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkRouteNetworkEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkRouteNetworkEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkRouteNetworkEditResponseEnvelopeSuccess bool diff --git a/zero_trust/networkroutenetwork_test.go b/zero_trust/networkroutenetwork_test.go index 7f7d06752f6..ef2a28f80bb 100644 --- a/zero_trust/networkroutenetwork_test.go +++ b/zero_trust/networkroutenetwork_test.go @@ -64,8 +64,10 @@ func TestNetworkRouteNetworkDeleteWithOptionalParams(t *testing.T) { context.TODO(), "172.16.0.0%2F16", zero_trust.NetworkRouteNetworkDeleteParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - TunType: cloudflare.F(zero_trust.NetworkRouteNetworkDeleteParamsTunTypeCfdTunnel), + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + TunType: cloudflare.F(zero_trust.NetworkRouteNetworkDeleteParamsTunTypeCfdTunnel), + TunnelID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), + VirtualNetworkID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), }, ) if err != nil { diff --git a/zero_trust/networkvirtualnetwork.go b/zero_trust/networkvirtualnetwork.go index 524ec10125d..ff73de83199 100644 --- a/zero_trust/networkvirtualnetwork.go +++ b/zero_trust/networkvirtualnetwork.go @@ -38,7 +38,7 @@ func NewNetworkVirtualNetworkService(opts ...option.RequestOption) (r *NetworkVi } // Adds a new virtual network to an account. -func (r *NetworkVirtualNetworkService) New(ctx context.Context, params NetworkVirtualNetworkNewParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkNewResponse, err error) { +func (r *NetworkVirtualNetworkService) New(ctx context.Context, params NetworkVirtualNetworkNewParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NetworkVirtualNetworkNewResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks", params.AccountID) @@ -51,7 +51,7 @@ func (r *NetworkVirtualNetworkService) New(ctx context.Context, params NetworkVi } // Lists and filters virtual networks in an account. -func (r *NetworkVirtualNetworkService) List(ctx context.Context, params NetworkVirtualNetworkListParams, opts ...option.RequestOption) (res *pagination.SinglePage[TunnelVirtualNetwork], err error) { +func (r *NetworkVirtualNetworkService) List(ctx context.Context, params NetworkVirtualNetworkListParams, opts ...option.RequestOption) (res *pagination.SinglePage[VirtualNetwork], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -69,15 +69,15 @@ func (r *NetworkVirtualNetworkService) List(ctx context.Context, params NetworkV } // Lists and filters virtual networks in an account. -func (r *NetworkVirtualNetworkService) ListAutoPaging(ctx context.Context, params NetworkVirtualNetworkListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[TunnelVirtualNetwork] { +func (r *NetworkVirtualNetworkService) ListAutoPaging(ctx context.Context, params NetworkVirtualNetworkListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[VirtualNetwork] { return pagination.NewSinglePageAutoPager(r.List(ctx, params, opts...)) } // Deletes an existing virtual network. -func (r *NetworkVirtualNetworkService) Delete(ctx context.Context, virtualNetworkID string, body NetworkVirtualNetworkDeleteParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkDeleteResponse, err error) { +func (r *NetworkVirtualNetworkService) Delete(ctx context.Context, virtualNetworkID string, params NetworkVirtualNetworkDeleteParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NetworkVirtualNetworkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks/%s", body.AccountID, virtualNetworkID) + path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks/%s", params.AccountID, virtualNetworkID) err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) if err != nil { return @@ -87,7 +87,7 @@ func (r *NetworkVirtualNetworkService) Delete(ctx context.Context, virtualNetwor } // Updates an existing virtual network. -func (r *NetworkVirtualNetworkService) Edit(ctx context.Context, virtualNetworkID string, params NetworkVirtualNetworkEditParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkEditResponse, err error) { +func (r *NetworkVirtualNetworkService) Edit(ctx context.Context, virtualNetworkID string, params NetworkVirtualNetworkEditParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkEditResponseUnion, err error) { opts = append(r.Options[:], opts...) var env NetworkVirtualNetworkEditResponseEnvelope path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks/%s", params.AccountID, virtualNetworkID) @@ -99,7 +99,7 @@ func (r *NetworkVirtualNetworkService) Edit(ctx context.Context, virtualNetworkI return } -type TunnelVirtualNetwork struct { +type VirtualNetwork struct { // UUID of the virtual network. ID string `json:"id,required"` // Optional remark describing the virtual network. @@ -112,13 +112,12 @@ type TunnelVirtualNetwork struct { Name string `json:"name,required"` // Timestamp of when the virtual network was deleted. If `null`, the virtual // network has not been deleted. - DeletedAt interface{} `json:"deleted_at"` - JSON tunnelVirtualNetworkJSON `json:"-"` + DeletedAt interface{} `json:"deleted_at"` + JSON virtualNetworkJSON `json:"-"` } -// tunnelVirtualNetworkJSON contains the JSON metadata for the struct -// [TunnelVirtualNetwork] -type tunnelVirtualNetworkJSON struct { +// virtualNetworkJSON contains the JSON metadata for the struct [VirtualNetwork] +type virtualNetworkJSON struct { ID apijson.Field Comment apijson.Field CreatedAt apijson.Field @@ -129,23 +128,23 @@ type tunnelVirtualNetworkJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelVirtualNetwork) UnmarshalJSON(data []byte) (err error) { +func (r *VirtualNetwork) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tunnelVirtualNetworkJSON) RawJSON() string { +func (r virtualNetworkJSON) RawJSON() string { return r.raw } // Union satisfied by [zero_trust.NetworkVirtualNetworkNewResponseUnknown], // [zero_trust.NetworkVirtualNetworkNewResponseArray] or [shared.UnionString]. -type NetworkVirtualNetworkNewResponse interface { - ImplementsZeroTrustNetworkVirtualNetworkNewResponse() +type NetworkVirtualNetworkNewResponseUnion interface { + ImplementsZeroTrustNetworkVirtualNetworkNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NetworkVirtualNetworkNewResponse)(nil)).Elem(), + reflect.TypeOf((*NetworkVirtualNetworkNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -160,18 +159,18 @@ func init() { type NetworkVirtualNetworkNewResponseArray []interface{} -func (r NetworkVirtualNetworkNewResponseArray) ImplementsZeroTrustNetworkVirtualNetworkNewResponse() { +func (r NetworkVirtualNetworkNewResponseArray) ImplementsZeroTrustNetworkVirtualNetworkNewResponseUnion() { } // Union satisfied by [zero_trust.NetworkVirtualNetworkDeleteResponseUnknown], // [zero_trust.NetworkVirtualNetworkDeleteResponseArray] or [shared.UnionString]. -type NetworkVirtualNetworkDeleteResponse interface { - ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() +type NetworkVirtualNetworkDeleteResponseUnion interface { + ImplementsZeroTrustNetworkVirtualNetworkDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NetworkVirtualNetworkDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*NetworkVirtualNetworkDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -186,18 +185,18 @@ func init() { type NetworkVirtualNetworkDeleteResponseArray []interface{} -func (r NetworkVirtualNetworkDeleteResponseArray) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() { +func (r NetworkVirtualNetworkDeleteResponseArray) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponseUnion() { } // Union satisfied by [zero_trust.NetworkVirtualNetworkEditResponseUnknown], // [zero_trust.NetworkVirtualNetworkEditResponseArray] or [shared.UnionString]. -type NetworkVirtualNetworkEditResponse interface { - ImplementsZeroTrustNetworkVirtualNetworkEditResponse() +type NetworkVirtualNetworkEditResponseUnion interface { + ImplementsZeroTrustNetworkVirtualNetworkEditResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*NetworkVirtualNetworkEditResponse)(nil)).Elem(), + reflect.TypeOf((*NetworkVirtualNetworkEditResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -212,7 +211,7 @@ func init() { type NetworkVirtualNetworkEditResponseArray []interface{} -func (r NetworkVirtualNetworkEditResponseArray) ImplementsZeroTrustNetworkVirtualNetworkEditResponse() { +func (r NetworkVirtualNetworkEditResponseArray) ImplementsZeroTrustNetworkVirtualNetworkEditResponseUnion() { } type NetworkVirtualNetworkNewParams struct { @@ -231,9 +230,9 @@ func (r NetworkVirtualNetworkNewParams) MarshalJSON() (data []byte, err error) { } type NetworkVirtualNetworkNewResponseEnvelope struct { - Errors []NetworkVirtualNetworkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkVirtualNetworkNewResponseEnvelopeMessages `json:"messages,required"` - Result NetworkVirtualNetworkNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NetworkVirtualNetworkNewResponseUnion `json:"result,required"` // Whether the API call was successful Success NetworkVirtualNetworkNewResponseEnvelopeSuccess `json:"success,required"` JSON networkVirtualNetworkNewResponseEnvelopeJSON `json:"-"` @@ -258,52 +257,6 @@ func (r networkVirtualNetworkNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkVirtualNetworkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkVirtualNetworkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkVirtualNetworkNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [NetworkVirtualNetworkNewResponseEnvelopeErrors] -type networkVirtualNetworkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkVirtualNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkVirtualNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkVirtualNetworkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkVirtualNetworkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkVirtualNetworkNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [NetworkVirtualNetworkNewResponseEnvelopeMessages] -type networkVirtualNetworkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkVirtualNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkVirtualNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkVirtualNetworkNewResponseEnvelopeSuccess bool @@ -330,6 +283,8 @@ type NetworkVirtualNetworkListParams struct { IsDeleted param.Field[interface{}] `query:"is_deleted"` // A user-friendly name for the virtual network. Name param.Field[string] `query:"name"` + // UUID of the virtual network. + VnetID param.Field[string] `query:"vnet_id"` // A user-friendly name for the virtual network. VnetName param.Field[string] `query:"vnet_name"` } @@ -338,7 +293,7 @@ type NetworkVirtualNetworkListParams struct { // `url.Values`. func (r NetworkVirtualNetworkListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -346,12 +301,17 @@ func (r NetworkVirtualNetworkListParams) URLQuery() (v url.Values) { type NetworkVirtualNetworkDeleteParams struct { // Cloudflare account ID AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` +} + +func (r NetworkVirtualNetworkDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) } type NetworkVirtualNetworkDeleteResponseEnvelope struct { - Errors []NetworkVirtualNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkVirtualNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result NetworkVirtualNetworkDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NetworkVirtualNetworkDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success NetworkVirtualNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` JSON networkVirtualNetworkDeleteResponseEnvelopeJSON `json:"-"` @@ -376,52 +336,6 @@ func (r networkVirtualNetworkDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkVirtualNetworkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [NetworkVirtualNetworkDeleteResponseEnvelopeErrors] -type networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkVirtualNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkVirtualNetworkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [NetworkVirtualNetworkDeleteResponseEnvelopeMessages] -type networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkVirtualNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkVirtualNetworkDeleteResponseEnvelopeSuccess bool @@ -453,9 +367,9 @@ func (r NetworkVirtualNetworkEditParams) MarshalJSON() (data []byte, err error) } type NetworkVirtualNetworkEditResponseEnvelope struct { - Errors []NetworkVirtualNetworkEditResponseEnvelopeErrors `json:"errors,required"` - Messages []NetworkVirtualNetworkEditResponseEnvelopeMessages `json:"messages,required"` - Result NetworkVirtualNetworkEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result NetworkVirtualNetworkEditResponseUnion `json:"result,required"` // Whether the API call was successful Success NetworkVirtualNetworkEditResponseEnvelopeSuccess `json:"success,required"` JSON networkVirtualNetworkEditResponseEnvelopeJSON `json:"-"` @@ -480,52 +394,6 @@ func (r networkVirtualNetworkEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type NetworkVirtualNetworkEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkVirtualNetworkEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// networkVirtualNetworkEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [NetworkVirtualNetworkEditResponseEnvelopeErrors] -type networkVirtualNetworkEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkVirtualNetworkEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkVirtualNetworkEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type NetworkVirtualNetworkEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON networkVirtualNetworkEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// networkVirtualNetworkEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [NetworkVirtualNetworkEditResponseEnvelopeMessages] -type networkVirtualNetworkEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NetworkVirtualNetworkEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r networkVirtualNetworkEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type NetworkVirtualNetworkEditResponseEnvelopeSuccess bool diff --git a/zero_trust/networkvirtualnetwork_test.go b/zero_trust/networkvirtualnetwork_test.go index b93b5413f08..66f6131296e 100644 --- a/zero_trust/networkvirtualnetwork_test.go +++ b/zero_trust/networkvirtualnetwork_test.go @@ -62,6 +62,7 @@ func TestNetworkVirtualNetworkListWithOptionalParams(t *testing.T) { IsDefault: cloudflare.F[any](map[string]interface{}{}), IsDeleted: cloudflare.F[any](map[string]interface{}{}), Name: cloudflare.F("us-east-1-vpc"), + VnetID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), VnetName: cloudflare.F("us-east-1-vpc"), }) if err != nil { @@ -92,6 +93,7 @@ func TestNetworkVirtualNetworkDelete(t *testing.T) { "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.NetworkVirtualNetworkDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/organization.go b/zero_trust/organization.go index 591d03d47e2..54132080501 100644 --- a/zero_trust/organization.go +++ b/zero_trust/organization.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewOrganizationService(opts ...option.RequestOption) (r *OrganizationServic } // Sets up a Zero Trust organization for your account or zone. -func (r *OrganizationService) New(ctx context.Context, params OrganizationNewParams, opts ...option.RequestOption) (res *ZeroTrustOrganizations, err error) { +func (r *OrganizationService) New(ctx context.Context, params OrganizationNewParams, opts ...option.RequestOption) (res *Organization, err error) { opts = append(r.Options[:], opts...) var env OrganizationNewResponseEnvelope var accountOrZone string @@ -55,7 +56,7 @@ func (r *OrganizationService) New(ctx context.Context, params OrganizationNewPar } // Updates the configuration for your Zero Trust organization. -func (r *OrganizationService) Update(ctx context.Context, params OrganizationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustOrganizations, err error) { +func (r *OrganizationService) Update(ctx context.Context, params OrganizationUpdateParams, opts ...option.RequestOption) (res *Organization, err error) { opts = append(r.Options[:], opts...) var env OrganizationUpdateResponseEnvelope var accountOrZone string @@ -77,7 +78,7 @@ func (r *OrganizationService) Update(ctx context.Context, params OrganizationUpd } // Returns the configuration for your Zero Trust organization. -func (r *OrganizationService) List(ctx context.Context, query OrganizationListParams, opts ...option.RequestOption) (res *ZeroTrustOrganizations, err error) { +func (r *OrganizationService) List(ctx context.Context, query OrganizationListParams, opts ...option.RequestOption) (res *Organization, err error) { opts = append(r.Options[:], opts...) var env OrganizationListResponseEnvelope var accountOrZone string @@ -120,7 +121,57 @@ func (r *OrganizationService) RevokeUsers(ctx context.Context, params Organizati return } -type ZeroTrustOrganizations struct { +type LoginDesign struct { + // The background color on your login page. + BackgroundColor string `json:"background_color"` + // The text at the bottom of your login page. + FooterText string `json:"footer_text"` + // The text at the top of your login page. + HeaderText string `json:"header_text"` + // The URL of the logo on your login page. + LogoPath string `json:"logo_path"` + // The text color on your login page. + TextColor string `json:"text_color"` + JSON loginDesignJSON `json:"-"` +} + +// loginDesignJSON contains the JSON metadata for the struct [LoginDesign] +type loginDesignJSON struct { + BackgroundColor apijson.Field + FooterText apijson.Field + HeaderText apijson.Field + LogoPath apijson.Field + TextColor apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoginDesign) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loginDesignJSON) RawJSON() string { + return r.raw +} + +type LoginDesignParam struct { + // The background color on your login page. + BackgroundColor param.Field[string] `json:"background_color"` + // The text at the bottom of your login page. + FooterText param.Field[string] `json:"footer_text"` + // The text at the top of your login page. + HeaderText param.Field[string] `json:"header_text"` + // The URL of the logo on your login page. + LogoPath param.Field[string] `json:"logo_path"` + // The text color on your login page. + TextColor param.Field[string] `json:"text_color"` +} + +func (r LoginDesignParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Organization struct { // When set to true, users can authenticate via WARP for any application in your // organization. Application settings will take precedence over this value. AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` @@ -128,13 +179,13 @@ type ZeroTrustOrganizations struct { AuthDomain string `json:"auth_domain"` // When set to `true`, users skip the identity provider selection step during // login. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomPages ZeroTrustOrganizationsCustomPages `json:"custom_pages"` + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + CustomPages OrganizationCustomPages `json:"custom_pages"` // Lock all settings as Read-Only in the Dashboard, regardless of user permission. // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly bool `json:"is_ui_read_only"` - LoginDesign ZeroTrustOrganizationsLoginDesign `json:"login_design"` + IsUiReadOnly bool `json:"is_ui_read_only"` + LoginDesign LoginDesign `json:"login_design"` // The name of your Zero Trust organization. Name string `json:"name"` // The amount of time that tokens issued for applications will be valid. Must be in @@ -151,13 +202,12 @@ type ZeroTrustOrganizations struct { UserSeatExpirationInactiveTime string `json:"user_seat_expiration_inactive_time"` // The amount of time that tokens issued for applications will be valid. Must be in // the format `30m` or `2h45m`. Valid time units are: m, h. - WARPAuthSessionDuration string `json:"warp_auth_session_duration"` - JSON zeroTrustOrganizationsJSON `json:"-"` + WARPAuthSessionDuration string `json:"warp_auth_session_duration"` + JSON organizationJSON `json:"-"` } -// zeroTrustOrganizationsJSON contains the JSON metadata for the struct -// [ZeroTrustOrganizations] -type zeroTrustOrganizationsJSON struct { +// organizationJSON contains the JSON metadata for the struct [Organization] +type organizationJSON struct { AllowAuthenticateViaWARP apijson.Field AuthDomain apijson.Field AutoRedirectToIdentity apijson.Field @@ -175,71 +225,37 @@ type zeroTrustOrganizationsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZeroTrustOrganizations) UnmarshalJSON(data []byte) (err error) { +func (r *Organization) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustOrganizationsJSON) RawJSON() string { +func (r organizationJSON) RawJSON() string { return r.raw } -type ZeroTrustOrganizationsCustomPages struct { +type OrganizationCustomPages struct { // The uid of the custom page to use when a user is denied access after failing a // non-identity rule. Forbidden string `json:"forbidden"` // The uid of the custom page to use when a user is denied access. - IdentityDenied string `json:"identity_denied"` - JSON zeroTrustOrganizationsCustomPagesJSON `json:"-"` + IdentityDenied string `json:"identity_denied"` + JSON organizationCustomPagesJSON `json:"-"` } -// zeroTrustOrganizationsCustomPagesJSON contains the JSON metadata for the struct -// [ZeroTrustOrganizationsCustomPages] -type zeroTrustOrganizationsCustomPagesJSON struct { +// organizationCustomPagesJSON contains the JSON metadata for the struct +// [OrganizationCustomPages] +type organizationCustomPagesJSON struct { Forbidden apijson.Field IdentityDenied apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustOrganizationsCustomPages) UnmarshalJSON(data []byte) (err error) { +func (r *OrganizationCustomPages) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustOrganizationsCustomPagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationsLoginDesign struct { - // The background color on your login page. - BackgroundColor string `json:"background_color"` - // The text at the bottom of your login page. - FooterText string `json:"footer_text"` - // The text at the top of your login page. - HeaderText string `json:"header_text"` - // The URL of the logo on your login page. - LogoPath string `json:"logo_path"` - // The text color on your login page. - TextColor string `json:"text_color"` - JSON zeroTrustOrganizationsLoginDesignJSON `json:"-"` -} - -// zeroTrustOrganizationsLoginDesignJSON contains the JSON metadata for the struct -// [ZeroTrustOrganizationsLoginDesign] -type zeroTrustOrganizationsLoginDesignJSON struct { - BackgroundColor apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - TextColor apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationsLoginDesign) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationsLoginDesignJSON) RawJSON() string { +func (r organizationCustomPagesJSON) RawJSON() string { return r.raw } @@ -275,8 +291,8 @@ type OrganizationNewParams struct { AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` // Lock all settings as Read-Only in the Dashboard, regardless of user permission. // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` - LoginDesign param.Field[OrganizationNewParamsLoginDesign] `json:"login_design"` + IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` + LoginDesign param.Field[LoginDesignParam] `json:"login_design"` // The amount of time that tokens issued for applications will be valid. Must be in // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, // h. @@ -297,27 +313,10 @@ func (r OrganizationNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type OrganizationNewParamsLoginDesign struct { - // The background color on your login page. - BackgroundColor param.Field[string] `json:"background_color"` - // The text at the bottom of your login page. - FooterText param.Field[string] `json:"footer_text"` - // The text at the top of your login page. - HeaderText param.Field[string] `json:"header_text"` - // The URL of the logo on your login page. - LogoPath param.Field[string] `json:"logo_path"` - // The text color on your login page. - TextColor param.Field[string] `json:"text_color"` -} - -func (r OrganizationNewParamsLoginDesign) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type OrganizationNewResponseEnvelope struct { - Errors []OrganizationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []OrganizationNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustOrganizations `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Organization `json:"result,required"` // Whether the API call was successful Success OrganizationNewResponseEnvelopeSuccess `json:"success,required"` JSON organizationNewResponseEnvelopeJSON `json:"-"` @@ -342,52 +341,6 @@ func (r organizationNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OrganizationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// organizationNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OrganizationNewResponseEnvelopeErrors] -type organizationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OrganizationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// organizationNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OrganizationNewResponseEnvelopeMessages] -type organizationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OrganizationNewResponseEnvelopeSuccess bool @@ -419,8 +372,8 @@ type OrganizationUpdateParams struct { CustomPages param.Field[OrganizationUpdateParamsCustomPages] `json:"custom_pages"` // Lock all settings as Read-Only in the Dashboard, regardless of user permission. // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` - LoginDesign param.Field[OrganizationUpdateParamsLoginDesign] `json:"login_design"` + IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` + LoginDesign param.Field[LoginDesignParam] `json:"login_design"` // The name of your Zero Trust organization. Name param.Field[string] `json:"name"` // The amount of time that tokens issued for applications will be valid. Must be in @@ -455,27 +408,10 @@ func (r OrganizationUpdateParamsCustomPages) MarshalJSON() (data []byte, err err return apijson.MarshalRoot(r) } -type OrganizationUpdateParamsLoginDesign struct { - // The background color on your login page. - BackgroundColor param.Field[string] `json:"background_color"` - // The text at the bottom of your login page. - FooterText param.Field[string] `json:"footer_text"` - // The text at the top of your login page. - HeaderText param.Field[string] `json:"header_text"` - // The URL of the logo on your login page. - LogoPath param.Field[string] `json:"logo_path"` - // The text color on your login page. - TextColor param.Field[string] `json:"text_color"` -} - -func (r OrganizationUpdateParamsLoginDesign) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type OrganizationUpdateResponseEnvelope struct { - Errors []OrganizationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []OrganizationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustOrganizations `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Organization `json:"result,required"` // Whether the API call was successful Success OrganizationUpdateResponseEnvelopeSuccess `json:"success,required"` JSON organizationUpdateResponseEnvelopeJSON `json:"-"` @@ -500,52 +436,6 @@ func (r organizationUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OrganizationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// organizationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OrganizationUpdateResponseEnvelopeErrors] -type organizationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OrganizationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// organizationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [OrganizationUpdateResponseEnvelopeMessages] -type organizationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OrganizationUpdateResponseEnvelopeSuccess bool @@ -569,9 +459,9 @@ type OrganizationListParams struct { } type OrganizationListResponseEnvelope struct { - Errors []OrganizationListResponseEnvelopeErrors `json:"errors,required"` - Messages []OrganizationListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustOrganizations `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result Organization `json:"result,required"` // Whether the API call was successful Success OrganizationListResponseEnvelopeSuccess `json:"success,required"` JSON organizationListResponseEnvelopeJSON `json:"-"` @@ -596,52 +486,6 @@ func (r organizationListResponseEnvelopeJSON) RawJSON() string { return r.raw } -type OrganizationListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationListResponseEnvelopeErrorsJSON `json:"-"` -} - -// organizationListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [OrganizationListResponseEnvelopeErrors] -type organizationListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OrganizationListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON organizationListResponseEnvelopeMessagesJSON `json:"-"` -} - -// organizationListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [OrganizationListResponseEnvelopeMessages] -type organizationListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OrganizationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r organizationListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type OrganizationListResponseEnvelopeSuccess bool diff --git a/zero_trust/organization_test.go b/zero_trust/organization_test.go index 2389377018c..e2a06440960 100644 --- a/zero_trust/organization_test.go +++ b/zero_trust/organization_test.go @@ -36,7 +36,7 @@ func TestOrganizationNewWithOptionalParams(t *testing.T) { AllowAuthenticateViaWARP: cloudflare.F(true), AutoRedirectToIdentity: cloudflare.F(true), IsUiReadOnly: cloudflare.F(true), - LoginDesign: cloudflare.F(zero_trust.OrganizationNewParamsLoginDesign{ + LoginDesign: cloudflare.F(zero_trust.LoginDesignParam{ BackgroundColor: cloudflare.F("#c5ed1b"), FooterText: cloudflare.F("This is an example description."), HeaderText: cloudflare.F("This is an example description."), @@ -82,7 +82,7 @@ func TestOrganizationUpdateWithOptionalParams(t *testing.T) { IdentityDenied: cloudflare.F("699d98642c564d2e855e9661899b7252"), }), IsUiReadOnly: cloudflare.F(true), - LoginDesign: cloudflare.F(zero_trust.OrganizationUpdateParamsLoginDesign{ + LoginDesign: cloudflare.F(zero_trust.LoginDesignParam{ BackgroundColor: cloudflare.F("#c5ed1b"), FooterText: cloudflare.F("This is an example description."), HeaderText: cloudflare.F("This is an example description."), diff --git a/zero_trust/seat.go b/zero_trust/seat.go index 3266669a6a7..f02b064de5f 100644 --- a/zero_trust/seat.go +++ b/zero_trust/seat.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSeatService(opts ...option.RequestOption) (r *SeatService) { // Removes a user from a Zero Trust seat when both `access_seat` and `gateway_seat` // are set to false. -func (r *SeatService) Edit(ctx context.Context, identifier string, body SeatEditParams, opts ...option.RequestOption) (res *[]ZeroTrustSeats, err error) { +func (r *SeatService) Edit(ctx context.Context, identifier string, body SeatEditParams, opts ...option.RequestOption) (res *[]Seat, err error) { opts = append(r.Options[:], opts...) var env SeatEditResponseEnvelope path := fmt.Sprintf("accounts/%s/access/seats", identifier) @@ -45,39 +46,39 @@ func (r *SeatService) Edit(ctx context.Context, identifier string, body SeatEdit return } -type ZeroTrustSeats struct { +type Seat struct { // True if the seat is part of Access. AccessSeat bool `json:"access_seat"` CreatedAt time.Time `json:"created_at" format:"date-time"` // True if the seat is part of Gateway. GatewaySeat bool `json:"gateway_seat"` // Identifier - SeatUid string `json:"seat_uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustSeatsJSON `json:"-"` + SeatUID string `json:"seat_uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON seatJSON `json:"-"` } -// zeroTrustSeatsJSON contains the JSON metadata for the struct [ZeroTrustSeats] -type zeroTrustSeatsJSON struct { +// seatJSON contains the JSON metadata for the struct [Seat] +type seatJSON struct { AccessSeat apijson.Field CreatedAt apijson.Field GatewaySeat apijson.Field - SeatUid apijson.Field + SeatUID apijson.Field UpdatedAt apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZeroTrustSeats) UnmarshalJSON(data []byte) (err error) { +func (r *Seat) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zeroTrustSeatsJSON) RawJSON() string { +func (r seatJSON) RawJSON() string { return r.raw } type SeatEditParams struct { - Body param.Field[[]SeatEditParamsBody] `json:"body,required"` + Body []SeatEditParamsBody `json:"body,required"` } func (r SeatEditParams) MarshalJSON() (data []byte, err error) { @@ -96,9 +97,9 @@ func (r SeatEditParamsBody) MarshalJSON() (data []byte, err error) { } type SeatEditResponseEnvelope struct { - Errors []SeatEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SeatEditResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustSeats `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Seat `json:"result,required,nullable"` // Whether the API call was successful Success SeatEditResponseEnvelopeSuccess `json:"success,required"` ResultInfo SeatEditResponseEnvelopeResultInfo `json:"result_info"` @@ -125,52 +126,6 @@ func (r seatEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SeatEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON seatEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// seatEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SeatEditResponseEnvelopeErrors] -type seatEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SeatEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r seatEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SeatEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON seatEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// seatEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SeatEditResponseEnvelopeMessages] -type seatEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SeatEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r seatEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SeatEditResponseEnvelopeSuccess bool diff --git a/zero_trust/seat_test.go b/zero_trust/seat_test.go index e05ab143ea2..b5ff38ff749 100644 --- a/zero_trust/seat_test.go +++ b/zero_trust/seat_test.go @@ -32,7 +32,7 @@ func TestSeatEdit(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", zero_trust.SeatEditParams{ - Body: cloudflare.F([]zero_trust.SeatEditParamsBody{{ + Body: []zero_trust.SeatEditParamsBody{{ AccessSeat: cloudflare.F(false), GatewaySeat: cloudflare.F(false), }, { @@ -41,7 +41,7 @@ func TestSeatEdit(t *testing.T) { }, { AccessSeat: cloudflare.F(false), GatewaySeat: cloudflare.F(false), - }}), + }}, }, ) if err != nil { diff --git a/zero_trust/tunnel.go b/zero_trust/tunnel.go index a3e3a4064a7..bd6ddb667fa 100644 --- a/zero_trust/tunnel.go +++ b/zero_trust/tunnel.go @@ -15,6 +15,7 @@ import ( "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" ) @@ -47,7 +48,7 @@ func NewTunnelService(opts ...option.RequestOption) (r *TunnelService) { } // Creates a new Argo Tunnel in an account. -func (r *TunnelService) New(ctx context.Context, params TunnelNewParams, opts ...option.RequestOption) (res *TunnelArgoTunnel, err error) { +func (r *TunnelService) New(ctx context.Context, params TunnelNewParams, opts ...option.RequestOption) (res *TunnelNewResponse, err error) { opts = append(r.Options[:], opts...) var env TunnelNewResponseEnvelope path := fmt.Sprintf("accounts/%s/tunnels", params.AccountID) @@ -83,7 +84,7 @@ func (r *TunnelService) ListAutoPaging(ctx context.Context, params TunnelListPar } // Deletes an Argo Tunnel from an account. -func (r *TunnelService) Delete(ctx context.Context, tunnelID string, params TunnelDeleteParams, opts ...option.RequestOption) (res *TunnelArgoTunnel, err error) { +func (r *TunnelService) Delete(ctx context.Context, tunnelID string, params TunnelDeleteParams, opts ...option.RequestOption) (res *TunnelDeleteResponse, err error) { opts = append(r.Options[:], opts...) var env TunnelDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/tunnels/%s", params.AccountID, tunnelID) @@ -109,7 +110,7 @@ func (r *TunnelService) Edit(ctx context.Context, tunnelID string, params Tunnel } // Fetches a single Argo Tunnel. -func (r *TunnelService) Get(ctx context.Context, tunnelID string, query TunnelGetParams, opts ...option.RequestOption) (res *TunnelArgoTunnel, err error) { +func (r *TunnelService) Get(ctx context.Context, tunnelID string, query TunnelGetParams, opts ...option.RequestOption) (res *TunnelGetResponse, err error) { opts = append(r.Options[:], opts...) var env TunnelGetResponseEnvelope path := fmt.Sprintf("accounts/%s/tunnels/%s", query.AccountID, tunnelID) @@ -121,42 +122,7 @@ func (r *TunnelService) Get(ctx context.Context, tunnelID string, query TunnelGe return } -type TunnelArgoTunnel struct { - // UUID of the tunnel. - ID string `json:"id,required"` - // The tunnel connections between your origin and Cloudflare's edge. - Connections []TunnelArgoTunnelConnection `json:"connections,required"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - // A user-friendly name for the tunnel. - Name string `json:"name,required"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - JSON tunnelArgoTunnelJSON `json:"-"` -} - -// tunnelArgoTunnelJSON contains the JSON metadata for the struct -// [TunnelArgoTunnel] -type tunnelArgoTunnelJSON struct { - ID apijson.Field - Connections apijson.Field - CreatedAt apijson.Field - Name apijson.Field - DeletedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelArgoTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelArgoTunnelJSON) RawJSON() string { - return r.raw -} - -type TunnelArgoTunnelConnection struct { +type Connection struct { // The Cloudflare data center used for this connection. ColoName string `json:"colo_name"` // Cloudflare continues to track connections for several minutes after they @@ -165,13 +131,12 @@ type TunnelArgoTunnelConnection struct { // tracked. If `false`, the connection is actively serving traffic. IsPendingReconnect bool `json:"is_pending_reconnect"` // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON tunnelArgoTunnelConnectionJSON `json:"-"` + UUID string `json:"uuid"` + JSON connectionJSON `json:"-"` } -// tunnelArgoTunnelConnectionJSON contains the JSON metadata for the struct -// [TunnelArgoTunnelConnection] -type tunnelArgoTunnelConnectionJSON struct { +// connectionJSON contains the JSON metadata for the struct [Connection] +type connectionJSON struct { ColoName apijson.Field IsPendingReconnect apijson.Field UUID apijson.Field @@ -179,45 +144,54 @@ type tunnelArgoTunnelConnectionJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelArgoTunnelConnection) UnmarshalJSON(data []byte) (err error) { +func (r *Connection) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tunnelArgoTunnelConnectionJSON) RawJSON() string { +func (r connectionJSON) RawJSON() string { return r.raw } -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [zero_trust.TunnelListResponseTunnelCfdTunnel] or -// [zero_trust.TunnelListResponseTunnelWARPConnectorTunnel]. -type TunnelListResponse interface { - implementsZeroTrustTunnelListResponse() +type TunnelNewResponse struct { + // UUID of the tunnel. + ID string `json:"id,required"` + // The tunnel connections between your origin and Cloudflare's edge. + Connections []Connection `json:"connections,required"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + // A user-friendly name for the tunnel. + Name string `json:"name,required"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + JSON tunnelNewResponseJSON `json:"-"` } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*TunnelListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(TunnelListResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(TunnelListResponseTunnelWARPConnectorTunnel{}), - }, - ) +// tunnelNewResponseJSON contains the JSON metadata for the struct +// [TunnelNewResponse] +type tunnelNewResponseJSON struct { + ID apijson.Field + Connections apijson.Field + CreatedAt apijson.Field + Name apijson.Field + DeletedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelNewResponseJSON) RawJSON() string { + return r.raw } // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type TunnelListResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` +type TunnelListResponse struct { // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []TunnelListResponseTunnelCfdTunnelConnection `json:"connections"` + AccountTag string `json:"account_tag"` + Connections interface{} `json:"connections,required"` // Timestamp of when the tunnel established at least one connection to Cloudflare's // edge. If `null`, the tunnel is inactive. ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` @@ -229,8 +203,9 @@ type TunnelListResponseTunnelCfdTunnel struct { // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been // deleted. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` + // UUID of the tunnel. + ID string `json:"id"` + Metadata interface{} `json:"metadata,required"` // A user-friendly name for the tunnel. Name string `json:"name"` // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. @@ -242,20 +217,21 @@ type TunnelListResponseTunnelCfdTunnel struct { // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). Status string `json:"status"` // The type of tunnel. - TunType TunnelListResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON tunnelListResponseTunnelCfdTunnelJSON `json:"-"` + TunType TunnelListResponseTunType `json:"tun_type"` + JSON tunnelListResponseJSON `json:"-"` + union TunnelListResponseUnion } -// tunnelListResponseTunnelCfdTunnelJSON contains the JSON metadata for the struct -// [TunnelListResponseTunnelCfdTunnel] -type tunnelListResponseTunnelCfdTunnelJSON struct { - ID apijson.Field +// tunnelListResponseJSON contains the JSON metadata for the struct +// [TunnelListResponse] +type tunnelListResponseJSON struct { AccountTag apijson.Field Connections apijson.Field ConnsActiveAt apijson.Field ConnsInactiveAt apijson.Field CreatedAt apijson.Field DeletedAt apijson.Field + ID apijson.Field Metadata apijson.Field Name apijson.Field RemoteConfig apijson.Field @@ -265,79 +241,43 @@ type tunnelListResponseTunnelCfdTunnelJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelListResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelListResponseTunnelCfdTunnelJSON) RawJSON() string { +func (r tunnelListResponseJSON) RawJSON() string { return r.raw } -func (r TunnelListResponseTunnelCfdTunnel) implementsZeroTrustTunnelListResponse() {} - -type TunnelListResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON tunnelListResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// tunnelListResponseTunnelCfdTunnelConnectionJSON contains the JSON metadata for -// the struct [TunnelListResponseTunnelCfdTunnelConnection] -type tunnelListResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r *TunnelListResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r *TunnelListResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r TunnelListResponse) AsUnion() TunnelListResponseUnion { + return r.union } -func (r tunnelListResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [shared.CloudflareTunnel] or +// [zero_trust.TunnelListResponseTunnelWARPConnectorTunnel]. +type TunnelListResponseUnion interface { + ImplementsZeroTrustTunnelListResponse() } -// The type of tunnel. -type TunnelListResponseTunnelCfdTunnelTunType string - -const ( - TunnelListResponseTunnelCfdTunnelTunTypeCfdTunnel TunnelListResponseTunnelCfdTunnelTunType = "cfd_tunnel" - TunnelListResponseTunnelCfdTunnelTunTypeWARPConnector TunnelListResponseTunnelCfdTunnelTunType = "warp_connector" - TunnelListResponseTunnelCfdTunnelTunTypeIPSec TunnelListResponseTunnelCfdTunnelTunType = "ip_sec" - TunnelListResponseTunnelCfdTunnelTunTypeGRE TunnelListResponseTunnelCfdTunnelTunType = "gre" - TunnelListResponseTunnelCfdTunnelTunTypeCni TunnelListResponseTunnelCfdTunnelTunType = "cni" -) - -func (r TunnelListResponseTunnelCfdTunnelTunType) IsKnown() bool { - switch r { - case TunnelListResponseTunnelCfdTunnelTunTypeCfdTunnel, TunnelListResponseTunnelCfdTunnelTunTypeWARPConnector, TunnelListResponseTunnelCfdTunnelTunTypeIPSec, TunnelListResponseTunnelCfdTunnelTunTypeGRE, TunnelListResponseTunnelCfdTunnelTunTypeCni: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelListResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.CloudflareTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelListResponseTunnelWARPConnectorTunnel{}), + }, + ) } // A Warp Connector Tunnel that connects your origin to Cloudflare's edge. @@ -399,7 +339,7 @@ func (r tunnelListResponseTunnelWARPConnectorTunnelJSON) RawJSON() string { return r.raw } -func (r TunnelListResponseTunnelWARPConnectorTunnel) implementsZeroTrustTunnelListResponse() {} +func (r TunnelListResponseTunnelWARPConnectorTunnel) ImplementsZeroTrustTunnelListResponse() {} type TunnelListResponseTunnelWARPConnectorTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -455,48 +395,76 @@ const ( TunnelListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector TunnelListResponseTunnelWARPConnectorTunnelTunType = "warp_connector" TunnelListResponseTunnelWARPConnectorTunnelTunTypeIPSec TunnelListResponseTunnelWARPConnectorTunnelTunType = "ip_sec" TunnelListResponseTunnelWARPConnectorTunnelTunTypeGRE TunnelListResponseTunnelWARPConnectorTunnelTunType = "gre" - TunnelListResponseTunnelWARPConnectorTunnelTunTypeCni TunnelListResponseTunnelWARPConnectorTunnelTunType = "cni" + TunnelListResponseTunnelWARPConnectorTunnelTunTypeCNI TunnelListResponseTunnelWARPConnectorTunnelTunType = "cni" ) func (r TunnelListResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool { switch r { - case TunnelListResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, TunnelListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, TunnelListResponseTunnelWARPConnectorTunnelTunTypeIPSec, TunnelListResponseTunnelWARPConnectorTunnelTunTypeGRE, TunnelListResponseTunnelWARPConnectorTunnelTunTypeCni: + case TunnelListResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, TunnelListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, TunnelListResponseTunnelWARPConnectorTunnelTunTypeIPSec, TunnelListResponseTunnelWARPConnectorTunnelTunTypeGRE, TunnelListResponseTunnelWARPConnectorTunnelTunTypeCNI: return true } return false } -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [zero_trust.TunnelEditResponseTunnelCfdTunnel] or -// [zero_trust.TunnelEditResponseTunnelWARPConnectorTunnel]. -type TunnelEditResponse interface { - implementsZeroTrustTunnelEditResponse() +// The type of tunnel. +type TunnelListResponseTunType string + +const ( + TunnelListResponseTunTypeCfdTunnel TunnelListResponseTunType = "cfd_tunnel" + TunnelListResponseTunTypeWARPConnector TunnelListResponseTunType = "warp_connector" + TunnelListResponseTunTypeIPSec TunnelListResponseTunType = "ip_sec" + TunnelListResponseTunTypeGRE TunnelListResponseTunType = "gre" + TunnelListResponseTunTypeCNI TunnelListResponseTunType = "cni" +) + +func (r TunnelListResponseTunType) IsKnown() bool { + switch r { + case TunnelListResponseTunTypeCfdTunnel, TunnelListResponseTunTypeWARPConnector, TunnelListResponseTunTypeIPSec, TunnelListResponseTunTypeGRE, TunnelListResponseTunTypeCNI: + return true + } + return false } -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*TunnelEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(TunnelEditResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(TunnelEditResponseTunnelWARPConnectorTunnel{}), - }, - ) +type TunnelDeleteResponse struct { + // UUID of the tunnel. + ID string `json:"id,required"` + // The tunnel connections between your origin and Cloudflare's edge. + Connections []Connection `json:"connections,required"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + // A user-friendly name for the tunnel. + Name string `json:"name,required"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + JSON tunnelDeleteResponseJSON `json:"-"` +} + +// tunnelDeleteResponseJSON contains the JSON metadata for the struct +// [TunnelDeleteResponse] +type tunnelDeleteResponseJSON struct { + ID apijson.Field + Connections apijson.Field + CreatedAt apijson.Field + Name apijson.Field + DeletedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelDeleteResponseJSON) RawJSON() string { + return r.raw } // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type TunnelEditResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` +type TunnelEditResponse struct { // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []TunnelEditResponseTunnelCfdTunnelConnection `json:"connections"` + AccountTag string `json:"account_tag"` + Connections interface{} `json:"connections,required"` // Timestamp of when the tunnel established at least one connection to Cloudflare's // edge. If `null`, the tunnel is inactive. ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` @@ -508,8 +476,9 @@ type TunnelEditResponseTunnelCfdTunnel struct { // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been // deleted. DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` + // UUID of the tunnel. + ID string `json:"id"` + Metadata interface{} `json:"metadata,required"` // A user-friendly name for the tunnel. Name string `json:"name"` // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. @@ -521,20 +490,21 @@ type TunnelEditResponseTunnelCfdTunnel struct { // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). Status string `json:"status"` // The type of tunnel. - TunType TunnelEditResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON tunnelEditResponseTunnelCfdTunnelJSON `json:"-"` + TunType TunnelEditResponseTunType `json:"tun_type"` + JSON tunnelEditResponseJSON `json:"-"` + union TunnelEditResponseUnion } -// tunnelEditResponseTunnelCfdTunnelJSON contains the JSON metadata for the struct -// [TunnelEditResponseTunnelCfdTunnel] -type tunnelEditResponseTunnelCfdTunnelJSON struct { - ID apijson.Field +// tunnelEditResponseJSON contains the JSON metadata for the struct +// [TunnelEditResponse] +type tunnelEditResponseJSON struct { AccountTag apijson.Field Connections apijson.Field ConnsActiveAt apijson.Field ConnsInactiveAt apijson.Field CreatedAt apijson.Field DeletedAt apijson.Field + ID apijson.Field Metadata apijson.Field Name apijson.Field RemoteConfig apijson.Field @@ -544,79 +514,43 @@ type tunnelEditResponseTunnelCfdTunnelJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelEditResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelEditResponseTunnelCfdTunnelJSON) RawJSON() string { +func (r tunnelEditResponseJSON) RawJSON() string { return r.raw } -func (r TunnelEditResponseTunnelCfdTunnel) implementsZeroTrustTunnelEditResponse() {} - -type TunnelEditResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON tunnelEditResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// tunnelEditResponseTunnelCfdTunnelConnectionJSON contains the JSON metadata for -// the struct [TunnelEditResponseTunnelCfdTunnelConnection] -type tunnelEditResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r *TunnelEditResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r *TunnelEditResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r TunnelEditResponse) AsUnion() TunnelEditResponseUnion { + return r.union } -func (r tunnelEditResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [shared.CloudflareTunnel] or +// [zero_trust.TunnelEditResponseTunnelWARPConnectorTunnel]. +type TunnelEditResponseUnion interface { + ImplementsZeroTrustTunnelEditResponse() } -// The type of tunnel. -type TunnelEditResponseTunnelCfdTunnelTunType string - -const ( - TunnelEditResponseTunnelCfdTunnelTunTypeCfdTunnel TunnelEditResponseTunnelCfdTunnelTunType = "cfd_tunnel" - TunnelEditResponseTunnelCfdTunnelTunTypeWARPConnector TunnelEditResponseTunnelCfdTunnelTunType = "warp_connector" - TunnelEditResponseTunnelCfdTunnelTunTypeIPSec TunnelEditResponseTunnelCfdTunnelTunType = "ip_sec" - TunnelEditResponseTunnelCfdTunnelTunTypeGRE TunnelEditResponseTunnelCfdTunnelTunType = "gre" - TunnelEditResponseTunnelCfdTunnelTunTypeCni TunnelEditResponseTunnelCfdTunnelTunType = "cni" -) - -func (r TunnelEditResponseTunnelCfdTunnelTunType) IsKnown() bool { - switch r { - case TunnelEditResponseTunnelCfdTunnelTunTypeCfdTunnel, TunnelEditResponseTunnelCfdTunnelTunTypeWARPConnector, TunnelEditResponseTunnelCfdTunnelTunTypeIPSec, TunnelEditResponseTunnelCfdTunnelTunTypeGRE, TunnelEditResponseTunnelCfdTunnelTunTypeCni: - return true - } - return false +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelEditResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.CloudflareTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelEditResponseTunnelWARPConnectorTunnel{}), + }, + ) } // A Warp Connector Tunnel that connects your origin to Cloudflare's edge. @@ -678,7 +612,7 @@ func (r tunnelEditResponseTunnelWARPConnectorTunnelJSON) RawJSON() string { return r.raw } -func (r TunnelEditResponseTunnelWARPConnectorTunnel) implementsZeroTrustTunnelEditResponse() {} +func (r TunnelEditResponseTunnelWARPConnectorTunnel) ImplementsZeroTrustTunnelEditResponse() {} type TunnelEditResponseTunnelWARPConnectorTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -734,17 +668,71 @@ const ( TunnelEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector TunnelEditResponseTunnelWARPConnectorTunnelTunType = "warp_connector" TunnelEditResponseTunnelWARPConnectorTunnelTunTypeIPSec TunnelEditResponseTunnelWARPConnectorTunnelTunType = "ip_sec" TunnelEditResponseTunnelWARPConnectorTunnelTunTypeGRE TunnelEditResponseTunnelWARPConnectorTunnelTunType = "gre" - TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCni TunnelEditResponseTunnelWARPConnectorTunnelTunType = "cni" + TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCNI TunnelEditResponseTunnelWARPConnectorTunnelTunType = "cni" ) func (r TunnelEditResponseTunnelWARPConnectorTunnelTunType) IsKnown() bool { switch r { - case TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeIPSec, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeGRE, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCni: + case TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeIPSec, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeGRE, TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCNI: + return true + } + return false +} + +// The type of tunnel. +type TunnelEditResponseTunType string + +const ( + TunnelEditResponseTunTypeCfdTunnel TunnelEditResponseTunType = "cfd_tunnel" + TunnelEditResponseTunTypeWARPConnector TunnelEditResponseTunType = "warp_connector" + TunnelEditResponseTunTypeIPSec TunnelEditResponseTunType = "ip_sec" + TunnelEditResponseTunTypeGRE TunnelEditResponseTunType = "gre" + TunnelEditResponseTunTypeCNI TunnelEditResponseTunType = "cni" +) + +func (r TunnelEditResponseTunType) IsKnown() bool { + switch r { + case TunnelEditResponseTunTypeCfdTunnel, TunnelEditResponseTunTypeWARPConnector, TunnelEditResponseTunTypeIPSec, TunnelEditResponseTunTypeGRE, TunnelEditResponseTunTypeCNI: return true } return false } +type TunnelGetResponse struct { + // UUID of the tunnel. + ID string `json:"id,required"` + // The tunnel connections between your origin and Cloudflare's edge. + Connections []Connection `json:"connections,required"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + // A user-friendly name for the tunnel. + Name string `json:"name,required"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + JSON tunnelGetResponseJSON `json:"-"` +} + +// tunnelGetResponseJSON contains the JSON metadata for the struct +// [TunnelGetResponse] +type tunnelGetResponseJSON struct { + ID apijson.Field + Connections apijson.Field + CreatedAt apijson.Field + Name apijson.Field + DeletedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelGetResponseJSON) RawJSON() string { + return r.raw +} + type TunnelNewParams struct { // Cloudflare account ID AccountID param.Field[string] `path:"account_id,required"` @@ -760,9 +748,9 @@ func (r TunnelNewParams) MarshalJSON() (data []byte, err error) { } type TunnelNewResponseEnvelope struct { - Errors []TunnelNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelNewResponseEnvelopeMessages `json:"messages,required"` - Result TunnelArgoTunnel `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelNewResponse `json:"result,required"` // Whether the API call was successful Success TunnelNewResponseEnvelopeSuccess `json:"success,required"` JSON tunnelNewResponseEnvelopeJSON `json:"-"` @@ -787,52 +775,6 @@ func (r tunnelNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TunnelNewResponseEnvelopeErrors] -type tunnelNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TunnelNewResponseEnvelopeMessages] -type tunnelNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelNewResponseEnvelopeSuccess bool @@ -866,7 +808,9 @@ type TunnelListParams struct { // Number of results to display. PerPage param.Field[float64] `query:"per_page"` // The types of tunnels to filter separated by a comma. - TunTypes param.Field[string] `query:"tun_types"` + TunTypes param.Field[string] `query:"tun_types"` + // UUID of the tunnel. + UUID param.Field[string] `query:"uuid"` WasActiveAt param.Field[time.Time] `query:"was_active_at" format:"date-time"` WasInactiveAt param.Field[time.Time] `query:"was_inactive_at" format:"date-time"` } @@ -874,15 +818,15 @@ type TunnelListParams struct { // URLQuery serializes [TunnelListParams]'s query parameters as `url.Values`. func (r TunnelListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type TunnelDeleteParams struct { // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r TunnelDeleteParams) MarshalJSON() (data []byte, err error) { @@ -890,9 +834,9 @@ func (r TunnelDeleteParams) MarshalJSON() (data []byte, err error) { } type TunnelDeleteResponseEnvelope struct { - Errors []TunnelDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelDeleteResponseEnvelopeMessages `json:"messages,required"` - Result TunnelArgoTunnel `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelDeleteResponse `json:"result,required"` // Whether the API call was successful Success TunnelDeleteResponseEnvelopeSuccess `json:"success,required"` JSON tunnelDeleteResponseEnvelopeJSON `json:"-"` @@ -917,52 +861,6 @@ func (r tunnelDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TunnelDeleteResponseEnvelopeErrors] -type tunnelDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TunnelDeleteResponseEnvelopeMessages] -type tunnelDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelDeleteResponseEnvelopeSuccess bool @@ -993,8 +891,8 @@ func (r TunnelEditParams) MarshalJSON() (data []byte, err error) { } type TunnelEditResponseEnvelope struct { - Errors []TunnelEditResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. Result TunnelEditResponse `json:"result,required"` // Whether the API call was successful @@ -1021,52 +919,6 @@ func (r tunnelEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TunnelEditResponseEnvelopeErrors] -type tunnelEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TunnelEditResponseEnvelopeMessages] -type tunnelEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelEditResponseEnvelopeSuccess bool @@ -1088,9 +940,9 @@ type TunnelGetParams struct { } type TunnelGetResponseEnvelope struct { - Errors []TunnelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelGetResponseEnvelopeMessages `json:"messages,required"` - Result TunnelArgoTunnel `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelGetResponse `json:"result,required"` // Whether the API call was successful Success TunnelGetResponseEnvelopeSuccess `json:"success,required"` JSON tunnelGetResponseEnvelopeJSON `json:"-"` @@ -1115,52 +967,6 @@ func (r tunnelGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [TunnelGetResponseEnvelopeErrors] -type tunnelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [TunnelGetResponseEnvelopeMessages] -type tunnelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelGetResponseEnvelopeSuccess bool diff --git a/zero_trust/tunnel_test.go b/zero_trust/tunnel_test.go index 907ce421bbf..83ca927fc19 100644 --- a/zero_trust/tunnel_test.go +++ b/zero_trust/tunnel_test.go @@ -67,6 +67,7 @@ func TestTunnelListWithOptionalParams(t *testing.T) { Page: cloudflare.F(1.000000), PerPage: cloudflare.F(1.000000), TunTypes: cloudflare.F("cfd_tunnel,warp_connector"), + UUID: cloudflare.F("f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"), WasActiveAt: cloudflare.F(time.Now()), WasInactiveAt: cloudflare.F(time.Now()), }) @@ -98,7 +99,7 @@ func TestTunnelDelete(t *testing.T) { "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/tunnelconfiguration.go b/zero_trust/tunnelconfiguration.go index a7601b47729..87207fa1bb4 100644 --- a/zero_trust/tunnelconfiguration.go +++ b/zero_trust/tunnelconfiguration.go @@ -35,7 +35,7 @@ func NewTunnelConfigurationService(opts ...option.RequestOption) (r *TunnelConfi } // Adds or updates the configuration for a remotely-managed tunnel. -func (r *TunnelConfigurationService) Update(ctx context.Context, tunnelID string, params TunnelConfigurationUpdateParams, opts ...option.RequestOption) (res *TunnelConfigurationUpdateResponse, err error) { +func (r *TunnelConfigurationService) Update(ctx context.Context, tunnelID string, params TunnelConfigurationUpdateParams, opts ...option.RequestOption) (res *TunnelConfigurationUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TunnelConfigurationUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/configurations", params.AccountID, tunnelID) @@ -48,7 +48,7 @@ func (r *TunnelConfigurationService) Update(ctx context.Context, tunnelID string } // Gets the configuration for a remotely-managed tunnel -func (r *TunnelConfigurationService) Get(ctx context.Context, tunnelID string, query TunnelConfigurationGetParams, opts ...option.RequestOption) (res *TunnelConfigurationGetResponse, err error) { +func (r *TunnelConfigurationService) Get(ctx context.Context, tunnelID string, query TunnelConfigurationGetParams, opts ...option.RequestOption) (res *TunnelConfigurationGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TunnelConfigurationGetResponseEnvelope path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/configurations", query.AccountID, tunnelID) @@ -62,13 +62,13 @@ func (r *TunnelConfigurationService) Get(ctx context.Context, tunnelID string, q // Union satisfied by [zero_trust.TunnelConfigurationUpdateResponseUnknown], // [zero_trust.TunnelConfigurationUpdateResponseArray] or [shared.UnionString]. -type TunnelConfigurationUpdateResponse interface { - ImplementsZeroTrustTunnelConfigurationUpdateResponse() +type TunnelConfigurationUpdateResponseUnion interface { + ImplementsZeroTrustTunnelConfigurationUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TunnelConfigurationUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*TunnelConfigurationUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -83,18 +83,18 @@ func init() { type TunnelConfigurationUpdateResponseArray []interface{} -func (r TunnelConfigurationUpdateResponseArray) ImplementsZeroTrustTunnelConfigurationUpdateResponse() { +func (r TunnelConfigurationUpdateResponseArray) ImplementsZeroTrustTunnelConfigurationUpdateResponseUnion() { } // Union satisfied by [zero_trust.TunnelConfigurationGetResponseUnknown], // [zero_trust.TunnelConfigurationGetResponseArray] or [shared.UnionString]. -type TunnelConfigurationGetResponse interface { - ImplementsZeroTrustTunnelConfigurationGetResponse() +type TunnelConfigurationGetResponseUnion interface { + ImplementsZeroTrustTunnelConfigurationGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TunnelConfigurationGetResponse)(nil)).Elem(), + reflect.TypeOf((*TunnelConfigurationGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -109,7 +109,8 @@ func init() { type TunnelConfigurationGetResponseArray []interface{} -func (r TunnelConfigurationGetResponseArray) ImplementsZeroTrustTunnelConfigurationGetResponse() {} +func (r TunnelConfigurationGetResponseArray) ImplementsZeroTrustTunnelConfigurationGetResponseUnion() { +} type TunnelConfigurationUpdateParams struct { // Identifier @@ -191,7 +192,7 @@ type TunnelConfigurationUpdateParamsConfigIngressOriginRequest struct { ProxyType param.Field[string] `json:"proxyType"` // The timeout after which a TCP keepalive packet is sent on a connection between // Tunnel and the origin server. - TcpKeepAlive param.Field[int64] `json:"tcpKeepAlive"` + TCPKeepAlive param.Field[int64] `json:"tcpKeepAlive"` // Timeout for completing a TLS handshake to your origin server, if you have chosen // to connect Tunnel to an HTTPS server. TLSTimeout param.Field[int64] `json:"tlsTimeout"` @@ -254,7 +255,7 @@ type TunnelConfigurationUpdateParamsConfigOriginRequest struct { ProxyType param.Field[string] `json:"proxyType"` // The timeout after which a TCP keepalive packet is sent on a connection between // Tunnel and the origin server. - TcpKeepAlive param.Field[int64] `json:"tcpKeepAlive"` + TCPKeepAlive param.Field[int64] `json:"tcpKeepAlive"` // Timeout for completing a TLS handshake to your origin server, if you have chosen // to connect Tunnel to an HTTPS server. TLSTimeout param.Field[int64] `json:"tlsTimeout"` @@ -290,9 +291,9 @@ func (r TunnelConfigurationUpdateParamsConfigWARPRouting) MarshalJSON() (data [] } type TunnelConfigurationUpdateResponseEnvelope struct { - Errors []TunnelConfigurationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelConfigurationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result TunnelConfigurationUpdateResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelConfigurationUpdateResponseUnion `json:"result,required"` // Whether the API call was successful Success TunnelConfigurationUpdateResponseEnvelopeSuccess `json:"success,required"` JSON tunnelConfigurationUpdateResponseEnvelopeJSON `json:"-"` @@ -317,52 +318,6 @@ func (r tunnelConfigurationUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelConfigurationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConfigurationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelConfigurationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [TunnelConfigurationUpdateResponseEnvelopeErrors] -type tunnelConfigurationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConfigurationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConfigurationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelConfigurationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConfigurationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelConfigurationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [TunnelConfigurationUpdateResponseEnvelopeMessages] -type tunnelConfigurationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConfigurationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConfigurationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelConfigurationUpdateResponseEnvelopeSuccess bool @@ -384,9 +339,9 @@ type TunnelConfigurationGetParams struct { } type TunnelConfigurationGetResponseEnvelope struct { - Errors []TunnelConfigurationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelConfigurationGetResponseEnvelopeMessages `json:"messages,required"` - Result TunnelConfigurationGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelConfigurationGetResponseUnion `json:"result,required"` // Whether the API call was successful Success TunnelConfigurationGetResponseEnvelopeSuccess `json:"success,required"` JSON tunnelConfigurationGetResponseEnvelopeJSON `json:"-"` @@ -411,52 +366,6 @@ func (r tunnelConfigurationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelConfigurationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConfigurationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelConfigurationGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [TunnelConfigurationGetResponseEnvelopeErrors] -type tunnelConfigurationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConfigurationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConfigurationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelConfigurationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConfigurationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelConfigurationGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [TunnelConfigurationGetResponseEnvelopeMessages] -type tunnelConfigurationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConfigurationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConfigurationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelConfigurationGetResponseEnvelopeSuccess bool diff --git a/zero_trust/tunnelconfiguration_test.go b/zero_trust/tunnelconfiguration_test.go index 9b856fca3f6..a1b917a0ff2 100644 --- a/zero_trust/tunnelconfiguration_test.go +++ b/zero_trust/tunnelconfiguration_test.go @@ -53,7 +53,7 @@ func TestTunnelConfigurationUpdateWithOptionalParams(t *testing.T) { NoTLSVerify: cloudflare.F(true), OriginServerName: cloudflare.F("string"), ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), + TCPKeepAlive: cloudflare.F(int64(0)), TLSTimeout: cloudflare.F(int64(0)), }), Path: cloudflare.F("subpath"), @@ -77,7 +77,7 @@ func TestTunnelConfigurationUpdateWithOptionalParams(t *testing.T) { NoTLSVerify: cloudflare.F(true), OriginServerName: cloudflare.F("string"), ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), + TCPKeepAlive: cloudflare.F(int64(0)), TLSTimeout: cloudflare.F(int64(0)), }), Path: cloudflare.F("subpath"), @@ -101,7 +101,7 @@ func TestTunnelConfigurationUpdateWithOptionalParams(t *testing.T) { NoTLSVerify: cloudflare.F(true), OriginServerName: cloudflare.F("string"), ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), + TCPKeepAlive: cloudflare.F(int64(0)), TLSTimeout: cloudflare.F(int64(0)), }), Path: cloudflare.F("subpath"), @@ -124,7 +124,7 @@ func TestTunnelConfigurationUpdateWithOptionalParams(t *testing.T) { NoTLSVerify: cloudflare.F(true), OriginServerName: cloudflare.F("string"), ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), + TCPKeepAlive: cloudflare.F(int64(0)), TLSTimeout: cloudflare.F(int64(0)), }), WARPRouting: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigWARPRouting{ diff --git a/zero_trust/tunnelconnection.go b/zero_trust/tunnelconnection.go index bc5c9d3f37f..fde63ebb808 100644 --- a/zero_trust/tunnelconnection.go +++ b/zero_trust/tunnelconnection.go @@ -37,7 +37,7 @@ func NewTunnelConnectionService(opts ...option.RequestOption) (r *TunnelConnecti // Removes connections that are in a disconnected or pending reconnect state. We // recommend running this command after shutting down a tunnel. -func (r *TunnelConnectionService) Delete(ctx context.Context, tunnelID string, params TunnelConnectionDeleteParams, opts ...option.RequestOption) (res *TunnelConnectionDeleteResponse, err error) { +func (r *TunnelConnectionService) Delete(ctx context.Context, tunnelID string, params TunnelConnectionDeleteParams, opts ...option.RequestOption) (res *TunnelConnectionDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TunnelConnectionDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/tunnels/%s/connections", params.AccountID, tunnelID) @@ -50,7 +50,7 @@ func (r *TunnelConnectionService) Delete(ctx context.Context, tunnelID string, p } // Fetches connection details for a Cloudflare Tunnel. -func (r *TunnelConnectionService) Get(ctx context.Context, tunnelID string, query TunnelConnectionGetParams, opts ...option.RequestOption) (res *[]TunnelTunnelClient, err error) { +func (r *TunnelConnectionService) Get(ctx context.Context, tunnelID string, query TunnelConnectionGetParams, opts ...option.RequestOption) (res *[]Client, err error) { opts = append(r.Options[:], opts...) var env TunnelConnectionGetResponseEnvelope path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/connections", query.AccountID, tunnelID) @@ -64,7 +64,7 @@ func (r *TunnelConnectionService) Get(ctx context.Context, tunnelID string, quer // A client (typically cloudflared) that maintains connections to a Cloudflare data // center. -type TunnelTunnelClient struct { +type Client struct { // UUID of the Cloudflare Tunnel connection. ID string `json:"id"` // The cloudflared OS architecture used to establish this connection. @@ -73,19 +73,18 @@ type TunnelTunnelClient struct { // cloudflared with the Zero Trust dashboard. ConfigVersion int64 `json:"config_version"` // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Conns []TunnelTunnelClientConn `json:"conns"` + Conns []ClientConn `json:"conns"` // Features enabled for the Cloudflare Tunnel. Features []string `json:"features"` // Timestamp of when the tunnel connection was started. RunAt time.Time `json:"run_at" format:"date-time"` // The cloudflared version used to establish this connection. - Version string `json:"version"` - JSON tunnelTunnelClientJSON `json:"-"` + Version string `json:"version"` + JSON clientJSON `json:"-"` } -// tunnelTunnelClientJSON contains the JSON metadata for the struct -// [TunnelTunnelClient] -type tunnelTunnelClientJSON struct { +// clientJSON contains the JSON metadata for the struct [Client] +type clientJSON struct { ID apijson.Field Arch apijson.Field ConfigVersion apijson.Field @@ -97,15 +96,15 @@ type tunnelTunnelClientJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelTunnelClient) UnmarshalJSON(data []byte) (err error) { +func (r *Client) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tunnelTunnelClientJSON) RawJSON() string { +func (r clientJSON) RawJSON() string { return r.raw } -type TunnelTunnelClientConn struct { +type ClientConn struct { // UUID of the Cloudflare Tunnel connection. ID string `json:"id"` // UUID of the cloudflared instance. @@ -124,13 +123,12 @@ type TunnelTunnelClientConn struct { // The public IP address of the host running cloudflared. OriginIP string `json:"origin_ip"` // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON tunnelTunnelClientConnJSON `json:"-"` + UUID string `json:"uuid"` + JSON clientConnJSON `json:"-"` } -// tunnelTunnelClientConnJSON contains the JSON metadata for the struct -// [TunnelTunnelClientConn] -type tunnelTunnelClientConnJSON struct { +// clientConnJSON contains the JSON metadata for the struct [ClientConn] +type clientConnJSON struct { ID apijson.Field ClientID apijson.Field ClientVersion apijson.Field @@ -143,23 +141,23 @@ type tunnelTunnelClientConnJSON struct { ExtraFields map[string]apijson.Field } -func (r *TunnelTunnelClientConn) UnmarshalJSON(data []byte) (err error) { +func (r *ClientConn) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r tunnelTunnelClientConnJSON) RawJSON() string { +func (r clientConnJSON) RawJSON() string { return r.raw } // Union satisfied by [zero_trust.TunnelConnectionDeleteResponseUnknown], // [zero_trust.TunnelConnectionDeleteResponseArray] or [shared.UnionString]. -type TunnelConnectionDeleteResponse interface { - ImplementsZeroTrustTunnelConnectionDeleteResponse() +type TunnelConnectionDeleteResponseUnion interface { + ImplementsZeroTrustTunnelConnectionDeleteResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TunnelConnectionDeleteResponse)(nil)).Elem(), + reflect.TypeOf((*TunnelConnectionDeleteResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -174,12 +172,13 @@ func init() { type TunnelConnectionDeleteResponseArray []interface{} -func (r TunnelConnectionDeleteResponseArray) ImplementsZeroTrustTunnelConnectionDeleteResponse() {} +func (r TunnelConnectionDeleteResponseArray) ImplementsZeroTrustTunnelConnectionDeleteResponseUnion() { +} type TunnelConnectionDeleteParams struct { // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` + AccountID param.Field[string] `path:"account_id,required"` + Body interface{} `json:"body,required"` } func (r TunnelConnectionDeleteParams) MarshalJSON() (data []byte, err error) { @@ -187,9 +186,9 @@ func (r TunnelConnectionDeleteParams) MarshalJSON() (data []byte, err error) { } type TunnelConnectionDeleteResponseEnvelope struct { - Errors []TunnelConnectionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelConnectionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result TunnelConnectionDeleteResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelConnectionDeleteResponseUnion `json:"result,required"` // Whether the API call was successful Success TunnelConnectionDeleteResponseEnvelopeSuccess `json:"success,required"` JSON tunnelConnectionDeleteResponseEnvelopeJSON `json:"-"` @@ -214,52 +213,6 @@ func (r tunnelConnectionDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelConnectionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConnectionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelConnectionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [TunnelConnectionDeleteResponseEnvelopeErrors] -type tunnelConnectionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConnectionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConnectionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelConnectionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConnectionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelConnectionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [TunnelConnectionDeleteResponseEnvelopeMessages] -type tunnelConnectionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConnectionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConnectionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelConnectionDeleteResponseEnvelopeSuccess bool @@ -281,9 +234,9 @@ type TunnelConnectionGetParams struct { } type TunnelConnectionGetResponseEnvelope struct { - Errors []TunnelConnectionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelConnectionGetResponseEnvelopeMessages `json:"messages,required"` - Result []TunnelTunnelClient `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result []Client `json:"result,required,nullable"` // Whether the API call was successful Success TunnelConnectionGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo TunnelConnectionGetResponseEnvelopeResultInfo `json:"result_info"` @@ -310,52 +263,6 @@ func (r tunnelConnectionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelConnectionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConnectionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelConnectionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TunnelConnectionGetResponseEnvelopeErrors] -type tunnelConnectionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConnectionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConnectionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelConnectionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConnectionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelConnectionGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [TunnelConnectionGetResponseEnvelopeMessages] -type tunnelConnectionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConnectionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConnectionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelConnectionGetResponseEnvelopeSuccess bool diff --git a/zero_trust/tunnelconnection_test.go b/zero_trust/tunnelconnection_test.go index 127942e2e83..bbb7625efa7 100644 --- a/zero_trust/tunnelconnection_test.go +++ b/zero_trust/tunnelconnection_test.go @@ -33,7 +33,7 @@ func TestTunnelConnectionDelete(t *testing.T) { "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", zero_trust.TunnelConnectionDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F[any](map[string]interface{}{}), + Body: map[string]interface{}{}, }, ) if err != nil { diff --git a/zero_trust/tunnelconnector.go b/zero_trust/tunnelconnector.go index 27623ac7f78..a4cc03469d4 100644 --- a/zero_trust/tunnelconnector.go +++ b/zero_trust/tunnelconnector.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -32,7 +33,7 @@ func NewTunnelConnectorService(opts ...option.RequestOption) (r *TunnelConnector } // Fetches connector and connection details for a Cloudflare Tunnel. -func (r *TunnelConnectorService) Get(ctx context.Context, tunnelID string, connectorID string, query TunnelConnectorGetParams, opts ...option.RequestOption) (res *TunnelTunnelClient, err error) { +func (r *TunnelConnectorService) Get(ctx context.Context, tunnelID string, connectorID string, query TunnelConnectorGetParams, opts ...option.RequestOption) (res *Client, err error) { opts = append(r.Options[:], opts...) var env TunnelConnectorGetResponseEnvelope path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/connectors/%s", query.AccountID, tunnelID, connectorID) @@ -50,11 +51,11 @@ type TunnelConnectorGetParams struct { } type TunnelConnectorGetResponseEnvelope struct { - Errors []TunnelConnectorGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelConnectorGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // A client (typically cloudflared) that maintains connections to a Cloudflare data // center. - Result TunnelTunnelClient `json:"result,required"` + Result Client `json:"result,required"` // Whether the API call was successful Success TunnelConnectorGetResponseEnvelopeSuccess `json:"success,required"` JSON tunnelConnectorGetResponseEnvelopeJSON `json:"-"` @@ -79,52 +80,6 @@ func (r tunnelConnectorGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelConnectorGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConnectorGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelConnectorGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TunnelConnectorGetResponseEnvelopeErrors] -type tunnelConnectorGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConnectorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConnectorGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelConnectorGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelConnectorGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelConnectorGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [TunnelConnectorGetResponseEnvelopeMessages] -type tunnelConnectorGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelConnectorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelConnectorGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelConnectorGetResponseEnvelopeSuccess bool diff --git a/zero_trust/tunnelmanagement.go b/zero_trust/tunnelmanagement.go index f75acc9e979..50ae5c622b4 100644 --- a/zero_trust/tunnelmanagement.go +++ b/zero_trust/tunnelmanagement.go @@ -36,7 +36,7 @@ func NewTunnelManagementService(opts ...option.RequestOption) (r *TunnelManageme // Gets a management token used to access the management resources (i.e. Streaming // Logs) of a tunnel. -func (r *TunnelManagementService) New(ctx context.Context, tunnelID string, params TunnelManagementNewParams, opts ...option.RequestOption) (res *TunnelManagementNewResponse, err error) { +func (r *TunnelManagementService) New(ctx context.Context, tunnelID string, params TunnelManagementNewParams, opts ...option.RequestOption) (res *TunnelManagementNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TunnelManagementNewResponseEnvelope path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/management", params.AccountID, tunnelID) @@ -50,13 +50,13 @@ func (r *TunnelManagementService) New(ctx context.Context, tunnelID string, para // Union satisfied by [zero_trust.TunnelManagementNewResponseUnknown], // [zero_trust.TunnelManagementNewResponseArray] or [shared.UnionString]. -type TunnelManagementNewResponse interface { - ImplementsZeroTrustTunnelManagementNewResponse() +type TunnelManagementNewResponseUnion interface { + ImplementsZeroTrustTunnelManagementNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TunnelManagementNewResponse)(nil)).Elem(), + reflect.TypeOf((*TunnelManagementNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -71,7 +71,7 @@ func init() { type TunnelManagementNewResponseArray []interface{} -func (r TunnelManagementNewResponseArray) ImplementsZeroTrustTunnelManagementNewResponse() {} +func (r TunnelManagementNewResponseArray) ImplementsZeroTrustTunnelManagementNewResponseUnion() {} type TunnelManagementNewParams struct { // Cloudflare account ID @@ -99,9 +99,9 @@ func (r TunnelManagementNewParamsResource) IsKnown() bool { } type TunnelManagementNewResponseEnvelope struct { - Errors []TunnelManagementNewResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelManagementNewResponseEnvelopeMessages `json:"messages,required"` - Result TunnelManagementNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelManagementNewResponseUnion `json:"result,required"` // Whether the API call was successful Success TunnelManagementNewResponseEnvelopeSuccess `json:"success,required"` JSON tunnelManagementNewResponseEnvelopeJSON `json:"-"` @@ -126,52 +126,6 @@ func (r tunnelManagementNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelManagementNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelManagementNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelManagementNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TunnelManagementNewResponseEnvelopeErrors] -type tunnelManagementNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelManagementNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelManagementNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelManagementNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelManagementNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelManagementNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [TunnelManagementNewResponseEnvelopeMessages] -type tunnelManagementNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelManagementNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelManagementNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelManagementNewResponseEnvelopeSuccess bool diff --git a/zero_trust/tunneltoken.go b/zero_trust/tunneltoken.go index 7f49366385c..9a04ee58219 100644 --- a/zero_trust/tunneltoken.go +++ b/zero_trust/tunneltoken.go @@ -35,7 +35,7 @@ func NewTunnelTokenService(opts ...option.RequestOption) (r *TunnelTokenService) } // Gets the token used to associate cloudflared with a specific tunnel. -func (r *TunnelTokenService) Get(ctx context.Context, tunnelID string, query TunnelTokenGetParams, opts ...option.RequestOption) (res *TunnelTokenGetResponse, err error) { +func (r *TunnelTokenService) Get(ctx context.Context, tunnelID string, query TunnelTokenGetParams, opts ...option.RequestOption) (res *TunnelTokenGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env TunnelTokenGetResponseEnvelope path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/token", query.AccountID, tunnelID) @@ -49,13 +49,13 @@ func (r *TunnelTokenService) Get(ctx context.Context, tunnelID string, query Tun // Union satisfied by [zero_trust.TunnelTokenGetResponseUnknown], // [zero_trust.TunnelTokenGetResponseArray] or [shared.UnionString]. -type TunnelTokenGetResponse interface { - ImplementsZeroTrustTunnelTokenGetResponse() +type TunnelTokenGetResponseUnion interface { + ImplementsZeroTrustTunnelTokenGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*TunnelTokenGetResponse)(nil)).Elem(), + reflect.TypeOf((*TunnelTokenGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -70,7 +70,7 @@ func init() { type TunnelTokenGetResponseArray []interface{} -func (r TunnelTokenGetResponseArray) ImplementsZeroTrustTunnelTokenGetResponse() {} +func (r TunnelTokenGetResponseArray) ImplementsZeroTrustTunnelTokenGetResponseUnion() {} type TunnelTokenGetParams struct { // Cloudflare account ID @@ -78,9 +78,9 @@ type TunnelTokenGetParams struct { } type TunnelTokenGetResponseEnvelope struct { - Errors []TunnelTokenGetResponseEnvelopeErrors `json:"errors,required"` - Messages []TunnelTokenGetResponseEnvelopeMessages `json:"messages,required"` - Result TunnelTokenGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result TunnelTokenGetResponseUnion `json:"result,required"` // Whether the API call was successful Success TunnelTokenGetResponseEnvelopeSuccess `json:"success,required"` JSON tunnelTokenGetResponseEnvelopeJSON `json:"-"` @@ -105,52 +105,6 @@ func (r tunnelTokenGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type TunnelTokenGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelTokenGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// tunnelTokenGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [TunnelTokenGetResponseEnvelopeErrors] -type tunnelTokenGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelTokenGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelTokenGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type TunnelTokenGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON tunnelTokenGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// tunnelTokenGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [TunnelTokenGetResponseEnvelopeMessages] -type tunnelTokenGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TunnelTokenGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r tunnelTokenGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type TunnelTokenGetResponseEnvelopeSuccess bool diff --git a/zones/activationcheck.go b/zones/activationcheck.go index d5df537937b..8384a08422e 100644 --- a/zones/activationcheck.go +++ b/zones/activationcheck.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -73,9 +74,9 @@ type ActivationCheckTriggerParams struct { } type ActivationCheckTriggerResponseEnvelope struct { - Errors []ActivationCheckTriggerResponseEnvelopeErrors `json:"errors,required"` - Messages []ActivationCheckTriggerResponseEnvelopeMessages `json:"messages,required"` - Result ActivationCheckTriggerResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ActivationCheckTriggerResponse `json:"result,required"` // Whether the API call was successful Success ActivationCheckTriggerResponseEnvelopeSuccess `json:"success,required"` JSON activationCheckTriggerResponseEnvelopeJSON `json:"-"` @@ -100,52 +101,6 @@ func (r activationCheckTriggerResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ActivationCheckTriggerResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON activationCheckTriggerResponseEnvelopeErrorsJSON `json:"-"` -} - -// activationCheckTriggerResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ActivationCheckTriggerResponseEnvelopeErrors] -type activationCheckTriggerResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ActivationCheckTriggerResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r activationCheckTriggerResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ActivationCheckTriggerResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON activationCheckTriggerResponseEnvelopeMessagesJSON `json:"-"` -} - -// activationCheckTriggerResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ActivationCheckTriggerResponseEnvelopeMessages] -type activationCheckTriggerResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ActivationCheckTriggerResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r activationCheckTriggerResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type ActivationCheckTriggerResponseEnvelopeSuccess bool diff --git a/zones/aliases.go b/zones/aliases.go index 51c4a9f8b00..aa2272aa21e 100644 --- a/zones/aliases.go +++ b/zones/aliases.go @@ -9,5 +9,101 @@ import ( type Error = apierror.Error +// This is an alias to an internal type. +type AuditLog = shared.AuditLog + +// This is an alias to an internal type. +type AuditLogAction = shared.AuditLogAction + +// This is an alias to an internal type. +type AuditLogActor = shared.AuditLogActor + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +// +// This is an alias to an internal type. +type AuditLogActorType = shared.AuditLogActorType + +// This is an alias to an internal value. +const AuditLogActorTypeUser = shared.AuditLogActorTypeUser + +// This is an alias to an internal value. +const AuditLogActorTypeAdmin = shared.AuditLogActorTypeAdmin + +// This is an alias to an internal value. +const AuditLogActorTypeCloudflare = shared.AuditLogActorTypeCloudflare + +// This is an alias to an internal type. +type AuditLogOwner = shared.AuditLogOwner + +// This is an alias to an internal type. +type AuditLogResource = shared.AuditLogResource + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// This is an alias to an internal type. +type CloudflareTunnel = shared.CloudflareTunnel + +// This is an alias to an internal type. +type CloudflareTunnelConnection = shared.CloudflareTunnelConnection + +// The type of tunnel. +// +// This is an alias to an internal type. +type CloudflareTunnelTunType = shared.CloudflareTunnelTunType + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCfdTunnel = shared.CloudflareTunnelTunTypeCfdTunnel + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeWARPConnector = shared.CloudflareTunnelTunTypeWARPConnector + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeIPSec = shared.CloudflareTunnelTunTypeIPSec + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeGRE = shared.CloudflareTunnelTunTypeGRE + +// This is an alias to an internal value. +const CloudflareTunnelTunTypeCNI = shared.CloudflareTunnelTunTypeCNI + // This is an alias to an internal type. type ErrorData = shared.ErrorData + +// This is an alias to an internal type. +type Permission = shared.Permission + +// This is an alias to an internal type. +type PermissionGrant = shared.PermissionGrant + +// This is an alias to an internal type. +type PermissionGrantParam = shared.PermissionGrantParam + +// This is an alias to an internal type. +type ResponseInfo = shared.ResponseInfo + +// This is an alias to an internal type. +type Role = shared.Role + +// This is an alias to an internal type. +type User = shared.User + +// This is an alias to an internal type. +type UserRole = shared.UserRole + +// This is an alias to an internal type. +type UserRolesPermissions = shared.UserRolesPermissions + +// This is an alias to an internal type. +type UserUser = shared.UserUser + +// This is an alias to an internal type. +type UserParam = shared.UserParam + +// This is an alias to an internal type. +type UserRoleParam = shared.UserRoleParam + +// This is an alias to an internal type. +type UserRolesPermissionsParam = shared.UserRolesPermissionsParam + +// This is an alias to an internal type. +type UserUserParam = shared.UserUserParam diff --git a/zones/customnameserver.go b/zones/customnameserver.go index 59ac3075d14..23509dbec0d 100644 --- a/zones/customnameserver.go +++ b/zones/customnameserver.go @@ -39,7 +39,7 @@ func NewCustomNameserverService(opts ...option.RequestOption) (r *CustomNameserv // If you would like new zones in the account to use account custom nameservers by // default, use PUT /accounts/:identifier to set the account setting // use_account_custom_ns_by_default to true. -func (r *CustomNameserverService) Update(ctx context.Context, params CustomNameserverUpdateParams, opts ...option.RequestOption) (res *CustomNameserverUpdateResponse, err error) { +func (r *CustomNameserverService) Update(ctx context.Context, params CustomNameserverUpdateParams, opts ...option.RequestOption) (res *CustomNameserverUpdateResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CustomNameserverUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/custom_ns", params.ZoneID) @@ -52,7 +52,7 @@ func (r *CustomNameserverService) Update(ctx context.Context, params CustomNames } // Get metadata for account-level custom nameservers on a zone. -func (r *CustomNameserverService) Get(ctx context.Context, query CustomNameserverGetParams, opts ...option.RequestOption) (res *CustomNameserverGetResponse, err error) { +func (r *CustomNameserverService) Get(ctx context.Context, query CustomNameserverGetParams, opts ...option.RequestOption) (res *CustomNameserverGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env CustomNameserverGetResponseEnvelope path := fmt.Sprintf("zones/%s/custom_ns", query.ZoneID) @@ -66,13 +66,13 @@ func (r *CustomNameserverService) Get(ctx context.Context, query CustomNameserve // Union satisfied by [zones.CustomNameserverUpdateResponseUnknown], // [zones.CustomNameserverUpdateResponseArray] or [shared.UnionString]. -type CustomNameserverUpdateResponse interface { - ImplementsZonesCustomNameserverUpdateResponse() +type CustomNameserverUpdateResponseUnion interface { + ImplementsZonesCustomNameserverUpdateResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CustomNameserverUpdateResponse)(nil)).Elem(), + reflect.TypeOf((*CustomNameserverUpdateResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -87,17 +87,17 @@ func init() { type CustomNameserverUpdateResponseArray []interface{} -func (r CustomNameserverUpdateResponseArray) ImplementsZonesCustomNameserverUpdateResponse() {} +func (r CustomNameserverUpdateResponseArray) ImplementsZonesCustomNameserverUpdateResponseUnion() {} // Union satisfied by [zones.CustomNameserverGetResponseUnknown], // [zones.CustomNameserverGetResponseArray] or [shared.UnionString]. -type CustomNameserverGetResponse interface { - ImplementsZonesCustomNameserverGetResponse() +type CustomNameserverGetResponseUnion interface { + ImplementsZonesCustomNameserverGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*CustomNameserverGetResponse)(nil)).Elem(), + reflect.TypeOf((*CustomNameserverGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -112,7 +112,7 @@ func init() { type CustomNameserverGetResponseArray []interface{} -func (r CustomNameserverGetResponseArray) ImplementsZonesCustomNameserverGetResponse() {} +func (r CustomNameserverGetResponseArray) ImplementsZonesCustomNameserverGetResponseUnion() {} type CustomNameserverUpdateParams struct { // Identifier @@ -128,9 +128,9 @@ func (r CustomNameserverUpdateParams) MarshalJSON() (data []byte, err error) { } type CustomNameserverUpdateResponseEnvelope struct { - Errors []CustomNameserverUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CustomNameserverUpdateResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomNameserverUpdateResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success CustomNameserverUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo CustomNameserverUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -157,52 +157,6 @@ func (r customNameserverUpdateResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomNameserverUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomNameserverUpdateResponseEnvelopeErrors] -type customNameserverUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CustomNameserverUpdateResponseEnvelopeMessages] -type customNameserverUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomNameserverUpdateResponseEnvelopeSuccess bool @@ -255,9 +209,9 @@ type CustomNameserverGetParams struct { } type CustomNameserverGetResponseEnvelope struct { - Errors []CustomNameserverGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverGetResponseEnvelopeMessages `json:"messages,required"` - Result CustomNameserverGetResponse `json:"result,required,nullable"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result CustomNameserverGetResponseUnion `json:"result,required,nullable"` // Whether the API call was successful Success CustomNameserverGetResponseEnvelopeSuccess `json:"success,required"` // Whether zone uses account-level custom nameservers. @@ -290,52 +244,6 @@ func (r customNameserverGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type CustomNameserverGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomNameserverGetResponseEnvelopeErrors] -type customNameserverGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomNameserverGetResponseEnvelopeMessages] -type customNameserverGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type CustomNameserverGetResponseEnvelopeSuccess bool diff --git a/zones/dnssetting.go b/zones/dnssetting.go index c7ffc054214..f496d2e0543 100644 --- a/zones/dnssetting.go +++ b/zones/dnssetting.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -31,7 +32,7 @@ func NewDNSSettingService(opts ...option.RequestOption) (r *DNSSettingService) { } // Update DNS settings for a zone -func (r *DNSSettingService) Edit(ctx context.Context, params DNSSettingEditParams, opts ...option.RequestOption) (res *DNSSettingEditResponse, err error) { +func (r *DNSSettingService) Edit(ctx context.Context, params DNSSettingEditParams, opts ...option.RequestOption) (res *DNSSetting, err error) { opts = append(r.Options[:], opts...) var env DNSSettingEditResponseEnvelope path := fmt.Sprintf("zones/%s/dns_settings", params.ZoneID) @@ -44,7 +45,7 @@ func (r *DNSSettingService) Edit(ctx context.Context, params DNSSettingEditParam } // Show DNS settings for a zone -func (r *DNSSettingService) Get(ctx context.Context, query DNSSettingGetParams, opts ...option.RequestOption) (res *DNSSettingGetResponse, err error) { +func (r *DNSSettingService) Get(ctx context.Context, query DNSSettingGetParams, opts ...option.RequestOption) (res *DNSSetting, err error) { opts = append(r.Options[:], opts...) var env DNSSettingGetResponseEnvelope path := fmt.Sprintf("zones/%s/dns_settings", query.ZoneID) @@ -56,169 +57,123 @@ func (r *DNSSettingService) Get(ctx context.Context, query DNSSettingGetParams, return } -type DNSSettingEditResponse struct { +type DNSSetting struct { + // Whether to enable Foundation DNS Advanced Nameservers on the zone. + FoundationDNS bool `json:"foundation_dns"` + // Whether to enable multi-provider DNS, which causes Cloudflare to activate the + // zone even when non-Cloudflare NS records exist, and to respect NS records at the + // zone apex during outbound zone transfers. + MultiProvider bool `json:"multi_provider"` // Settings determining the nameservers through which the zone should be available. - Nameservers DNSSettingEditResponseNameservers `json:"nameservers"` - JSON dnsSettingEditResponseJSON `json:"-"` + Nameservers Nameserver `json:"nameservers"` + // Allows a Secondary DNS zone to use (proxied) override records and CNAME + // flattening at the zone apex. + SecondaryOverrides bool `json:"secondary_overrides"` + JSON dnsSettingJSON `json:"-"` } -// dnsSettingEditResponseJSON contains the JSON metadata for the struct -// [DNSSettingEditResponse] -type dnsSettingEditResponseJSON struct { - Nameservers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -// Settings determining the nameservers through which the zone should be available. -type DNSSettingEditResponseNameservers struct { - // Nameserver type - Type DNSSettingEditResponseNameserversType `json:"type,required"` - JSON dnsSettingEditResponseNameserversJSON `json:"-"` -} - -// dnsSettingEditResponseNameserversJSON contains the JSON metadata for the struct -// [DNSSettingEditResponseNameservers] -type dnsSettingEditResponseNameserversJSON struct { - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field +// dnsSettingJSON contains the JSON metadata for the struct [DNSSetting] +type dnsSettingJSON struct { + FoundationDNS apijson.Field + MultiProvider apijson.Field + Nameservers apijson.Field + SecondaryOverrides apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *DNSSettingEditResponseNameservers) UnmarshalJSON(data []byte) (err error) { +func (r *DNSSetting) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsSettingEditResponseNameserversJSON) RawJSON() string { +func (r dnsSettingJSON) RawJSON() string { return r.raw } -// Nameserver type -type DNSSettingEditResponseNameserversType string - -const ( - DNSSettingEditResponseNameserversTypeCloudflareStandard DNSSettingEditResponseNameserversType = "cloudflare.standard" - DNSSettingEditResponseNameserversTypeCloudflareFoundationDNS DNSSettingEditResponseNameserversType = "cloudflare.foundation_dns" -) - -func (r DNSSettingEditResponseNameserversType) IsKnown() bool { - switch r { - case DNSSettingEditResponseNameserversTypeCloudflareStandard, DNSSettingEditResponseNameserversTypeCloudflareFoundationDNS: - return true - } - return false -} - -type DNSSettingGetResponse struct { +type DNSSettingParam struct { + // Whether to enable Foundation DNS Advanced Nameservers on the zone. + FoundationDNS param.Field[bool] `json:"foundation_dns"` + // Whether to enable multi-provider DNS, which causes Cloudflare to activate the + // zone even when non-Cloudflare NS records exist, and to respect NS records at the + // zone apex during outbound zone transfers. + MultiProvider param.Field[bool] `json:"multi_provider"` // Settings determining the nameservers through which the zone should be available. - Nameservers DNSSettingGetResponseNameservers `json:"nameservers"` - JSON dnsSettingGetResponseJSON `json:"-"` + Nameservers param.Field[NameserverParam] `json:"nameservers"` + // Allows a Secondary DNS zone to use (proxied) override records and CNAME + // flattening at the zone apex. + SecondaryOverrides param.Field[bool] `json:"secondary_overrides"` } -// dnsSettingGetResponseJSON contains the JSON metadata for the struct -// [DNSSettingGetResponse] -type dnsSettingGetResponseJSON struct { - Nameservers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsSettingGetResponseJSON) RawJSON() string { - return r.raw +func (r DNSSettingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Settings determining the nameservers through which the zone should be available. -type DNSSettingGetResponseNameservers struct { +type Nameserver struct { // Nameserver type - Type DNSSettingGetResponseNameserversType `json:"type,required"` - JSON dnsSettingGetResponseNameserversJSON `json:"-"` + Type NameserverType `json:"type,required"` + JSON nameserverJSON `json:"-"` } -// dnsSettingGetResponseNameserversJSON contains the JSON metadata for the struct -// [DNSSettingGetResponseNameservers] -type dnsSettingGetResponseNameserversJSON struct { +// nameserverJSON contains the JSON metadata for the struct [Nameserver] +type nameserverJSON struct { Type apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *DNSSettingGetResponseNameservers) UnmarshalJSON(data []byte) (err error) { +func (r *Nameserver) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnsSettingGetResponseNameserversJSON) RawJSON() string { +func (r nameserverJSON) RawJSON() string { return r.raw } // Nameserver type -type DNSSettingGetResponseNameserversType string +type NameserverType string const ( - DNSSettingGetResponseNameserversTypeCloudflareStandard DNSSettingGetResponseNameserversType = "cloudflare.standard" - DNSSettingGetResponseNameserversTypeCloudflareFoundationDNS DNSSettingGetResponseNameserversType = "cloudflare.foundation_dns" + NameserverTypeCloudflareStandard NameserverType = "cloudflare.standard" + NameserverTypeCloudflareFoundationDNS NameserverType = "cloudflare.foundation_dns" ) -func (r DNSSettingGetResponseNameserversType) IsKnown() bool { +func (r NameserverType) IsKnown() bool { switch r { - case DNSSettingGetResponseNameserversTypeCloudflareStandard, DNSSettingGetResponseNameserversTypeCloudflareFoundationDNS: + case NameserverTypeCloudflareStandard, NameserverTypeCloudflareFoundationDNS: return true } return false } -type DNSSettingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Settings determining the nameservers through which the zone should be available. - Nameservers param.Field[DNSSettingEditParamsNameservers] `json:"nameservers"` -} - -func (r DNSSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // Settings determining the nameservers through which the zone should be available. -type DNSSettingEditParamsNameservers struct { +type NameserverParam struct { // Nameserver type - Type param.Field[DNSSettingEditParamsNameserversType] `json:"type,required"` + Type param.Field[NameserverType] `json:"type,required"` } -func (r DNSSettingEditParamsNameservers) MarshalJSON() (data []byte, err error) { +func (r NameserverParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Nameserver type -type DNSSettingEditParamsNameserversType string - -const ( - DNSSettingEditParamsNameserversTypeCloudflareStandard DNSSettingEditParamsNameserversType = "cloudflare.standard" - DNSSettingEditParamsNameserversTypeCloudflareFoundationDNS DNSSettingEditParamsNameserversType = "cloudflare.foundation_dns" -) +type DNSSettingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + DNSSetting DNSSettingParam `json:"dns_setting,required"` +} -func (r DNSSettingEditParamsNameserversType) IsKnown() bool { - switch r { - case DNSSettingEditParamsNameserversTypeCloudflareStandard, DNSSettingEditParamsNameserversTypeCloudflareFoundationDNS: - return true - } - return false +func (r DNSSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.DNSSetting) } type DNSSettingEditResponseEnvelope struct { - Errors []DNSSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result DNSSettingEditResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + FoundationDNS interface{} `json:"foundation_dns,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + MultiProvider interface{} `json:"multi_provider,required"` + Nameservers interface{} `json:"nameservers,required"` + Result DNSSetting `json:"result,required"` + SecondaryOverrides interface{} `json:"secondary_overrides,required"` // Whether the API call was successful Success DNSSettingEditResponseEnvelopeSuccess `json:"success,required"` JSON dnsSettingEditResponseEnvelopeJSON `json:"-"` @@ -227,12 +182,16 @@ type DNSSettingEditResponseEnvelope struct { // dnsSettingEditResponseEnvelopeJSON contains the JSON metadata for the struct // [DNSSettingEditResponseEnvelope] type dnsSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field + Errors apijson.Field + FoundationDNS apijson.Field + Messages apijson.Field + MultiProvider apijson.Field + Nameservers apijson.Field + Result apijson.Field + SecondaryOverrides apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *DNSSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { @@ -243,52 +202,6 @@ func (r dnsSettingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DNSSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSSettingEditResponseEnvelopeErrors] -type dnsSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSSettingEditResponseEnvelopeMessages] -type dnsSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DNSSettingEditResponseEnvelopeSuccess bool @@ -310,9 +223,13 @@ type DNSSettingGetParams struct { } type DNSSettingGetResponseEnvelope struct { - Errors []DNSSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSSettingGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + FoundationDNS interface{} `json:"foundation_dns,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + MultiProvider interface{} `json:"multi_provider,required"` + Nameservers interface{} `json:"nameservers,required"` + Result DNSSetting `json:"result,required"` + SecondaryOverrides interface{} `json:"secondary_overrides,required"` // Whether the API call was successful Success DNSSettingGetResponseEnvelopeSuccess `json:"success,required"` JSON dnsSettingGetResponseEnvelopeJSON `json:"-"` @@ -321,12 +238,16 @@ type DNSSettingGetResponseEnvelope struct { // dnsSettingGetResponseEnvelopeJSON contains the JSON metadata for the struct // [DNSSettingGetResponseEnvelope] type dnsSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field + Errors apijson.Field + FoundationDNS apijson.Field + Messages apijson.Field + MultiProvider apijson.Field + Nameservers apijson.Field + Result apijson.Field + SecondaryOverrides apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *DNSSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { @@ -337,52 +258,6 @@ func (r dnsSettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type DNSSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSSettingGetResponseEnvelopeErrors] -type dnsSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSSettingGetResponseEnvelopeMessages] -type dnsSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type DNSSettingGetResponseEnvelopeSuccess bool diff --git a/zones/dnssetting_test.go b/zones/dnssetting_test.go index 5d0a8b9a939..a74202a89cf 100644 --- a/zones/dnssetting_test.go +++ b/zones/dnssetting_test.go @@ -30,9 +30,14 @@ func TestDNSSettingEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.DNSSettings.Edit(context.TODO(), zones.DNSSettingEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Nameservers: cloudflare.F(zones.DNSSettingEditParamsNameservers{ - Type: cloudflare.F(zones.DNSSettingEditParamsNameserversTypeCloudflareStandard), - }), + DNSSetting: zones.DNSSettingParam{ + FoundationDNS: cloudflare.F(false), + MultiProvider: cloudflare.F(false), + Nameservers: cloudflare.F(zones.NameserverParam{ + Type: cloudflare.F(zones.NameserverTypeCloudflareStandard), + }), + SecondaryOverrides: cloudflare.F(false), + }, }) if err != nil { var apierr *cloudflare.Error diff --git a/zones/hold.go b/zones/hold.go index 1beeca44e5e..87d8a219725 100644 --- a/zones/hold.go +++ b/zones/hold.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" "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" ) @@ -34,7 +35,7 @@ func NewHoldService(opts ...option.RequestOption) (r *HoldService) { // Enforce a zone hold on the zone, blocking the creation and activation of zones // with this zone's hostname. -func (r *HoldService) New(ctx context.Context, params HoldNewParams, opts ...option.RequestOption) (res *HoldNewResponse, err error) { +func (r *HoldService) New(ctx context.Context, params HoldNewParams, opts ...option.RequestOption) (res *ZoneHold, err error) { opts = append(r.Options[:], opts...) var env HoldNewResponseEnvelope path := fmt.Sprintf("zones/%s/hold", params.ZoneID) @@ -48,7 +49,7 @@ func (r *HoldService) New(ctx context.Context, params HoldNewParams, opts ...opt // Stop enforcement of a zone hold on the zone, permanently or temporarily, // allowing the creation and activation of zones with this zone's hostname. -func (r *HoldService) Delete(ctx context.Context, params HoldDeleteParams, opts ...option.RequestOption) (res *HoldDeleteResponse, err error) { +func (r *HoldService) Delete(ctx context.Context, params HoldDeleteParams, opts ...option.RequestOption) (res *ZoneHold, err error) { opts = append(r.Options[:], opts...) var env HoldDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/hold", params.ZoneID) @@ -62,7 +63,7 @@ func (r *HoldService) Delete(ctx context.Context, params HoldDeleteParams, opts // Retrieve whether the zone is subject to a zone hold, and metadata about the // hold. -func (r *HoldService) Get(ctx context.Context, query HoldGetParams, opts ...option.RequestOption) (res *HoldGetResponse, err error) { +func (r *HoldService) Get(ctx context.Context, query HoldGetParams, opts ...option.RequestOption) (res *ZoneHold, err error) { opts = append(r.Options[:], opts...) var env HoldGetResponseEnvelope path := fmt.Sprintf("zones/%s/hold", query.ZoneID) @@ -74,15 +75,15 @@ func (r *HoldService) Get(ctx context.Context, query HoldGetParams, opts ...opti return } -type HoldNewResponse struct { - Hold bool `json:"hold"` - HoldAfter string `json:"hold_after"` - IncludeSubdomains string `json:"include_subdomains"` - JSON holdNewResponseJSON `json:"-"` +type ZoneHold struct { + Hold bool `json:"hold"` + HoldAfter string `json:"hold_after"` + IncludeSubdomains string `json:"include_subdomains"` + JSON zoneHoldJSON `json:"-"` } -// holdNewResponseJSON contains the JSON metadata for the struct [HoldNewResponse] -type holdNewResponseJSON struct { +// zoneHoldJSON contains the JSON metadata for the struct [ZoneHold] +type zoneHoldJSON struct { Hold apijson.Field HoldAfter apijson.Field IncludeSubdomains apijson.Field @@ -90,60 +91,11 @@ type holdNewResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *HoldNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *ZoneHold) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r holdNewResponseJSON) RawJSON() string { - return r.raw -} - -type HoldDeleteResponse struct { - Hold bool `json:"hold"` - HoldAfter string `json:"hold_after"` - IncludeSubdomains string `json:"include_subdomains"` - JSON holdDeleteResponseJSON `json:"-"` -} - -// holdDeleteResponseJSON contains the JSON metadata for the struct -// [HoldDeleteResponse] -type holdDeleteResponseJSON struct { - Hold apijson.Field - HoldAfter apijson.Field - IncludeSubdomains apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HoldDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r holdDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type HoldGetResponse struct { - Hold bool `json:"hold"` - HoldAfter string `json:"hold_after"` - IncludeSubdomains string `json:"include_subdomains"` - JSON holdGetResponseJSON `json:"-"` -} - -// holdGetResponseJSON contains the JSON metadata for the struct [HoldGetResponse] -type holdGetResponseJSON struct { - Hold apijson.Field - HoldAfter apijson.Field - IncludeSubdomains apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HoldGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r holdGetResponseJSON) RawJSON() string { +func (r zoneHoldJSON) RawJSON() string { return r.raw } @@ -160,15 +112,15 @@ type HoldNewParams struct { // URLQuery serializes [HoldNewParams]'s query parameters as `url.Values`. func (r HoldNewParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type HoldNewResponseEnvelope struct { - Errors []HoldNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HoldNewResponseEnvelopeMessages `json:"messages,required"` - Result HoldNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ZoneHold `json:"result,required"` // Whether the API call was successful Success HoldNewResponseEnvelopeSuccess `json:"success,required"` JSON holdNewResponseEnvelopeJSON `json:"-"` @@ -193,52 +145,6 @@ func (r holdNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HoldNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON holdNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// holdNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [HoldNewResponseEnvelopeErrors] -type holdNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HoldNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r holdNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HoldNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON holdNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// holdNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [HoldNewResponseEnvelopeMessages] -type holdNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HoldNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r holdNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HoldNewResponseEnvelopeSuccess bool @@ -266,13 +172,13 @@ type HoldDeleteParams struct { // URLQuery serializes [HoldDeleteParams]'s query parameters as `url.Values`. func (r HoldDeleteParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } type HoldDeleteResponseEnvelope struct { - Result HoldDeleteResponse `json:"result"` + Result ZoneHold `json:"result"` JSON holdDeleteResponseEnvelopeJSON `json:"-"` } @@ -298,9 +204,9 @@ type HoldGetParams struct { } type HoldGetResponseEnvelope struct { - Errors []HoldGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HoldGetResponseEnvelopeMessages `json:"messages,required"` - Result HoldGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result ZoneHold `json:"result,required"` // Whether the API call was successful Success HoldGetResponseEnvelopeSuccess `json:"success,required"` JSON holdGetResponseEnvelopeJSON `json:"-"` @@ -325,52 +231,6 @@ func (r holdGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type HoldGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON holdGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// holdGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [HoldGetResponseEnvelopeErrors] -type holdGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HoldGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r holdGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HoldGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON holdGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// holdGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [HoldGetResponseEnvelopeMessages] -type holdGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HoldGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r holdGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type HoldGetResponseEnvelopeSuccess bool diff --git a/zones/setting.go b/zones/setting.go index b572f2d474f..1fae07e7c47 100644 --- a/zones/setting.go +++ b/zones/setting.go @@ -3,17 +3,7 @@ package zones import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/param" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/tidwall/gjson" ) // SettingService contains methods and other services that help with interacting @@ -134,2145 +124,3 @@ func NewSettingService(opts ...option.RequestOption) (r *SettingService) { r.FontSettings = NewSettingFontSettingService(opts...) return } - -// Edit settings for a zone. -func (r *SettingService) Edit(ctx context.Context, params SettingEditParams, opts ...option.RequestOption) (res *[]SettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env SettingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Available settings for your user in relation to a zone. -func (r *SettingService) Get(ctx context.Context, query SettingGetParams, opts ...option.RequestOption) (res *[]SettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SettingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// 0-RTT session resumption enabled for this zone. -// -// Union satisfied by [zones.ZoneSetting0rtt], [zones.ZoneSettingAdvancedDDoS], -// [zones.ZoneSettingAlwaysOnline], [zones.ZoneSettingAlwaysUseHTTPS], -// [zones.ZoneSettingAutomaticHTTPSRewrites], [zones.ZoneSettingBrotli], -// [zones.ZoneSettingBrowserCacheTTL], [zones.ZoneSettingBrowserCheck], -// [zones.ZoneSettingCacheLevel], [zones.ZoneSettingChallengeTTL], -// [zones.ZoneSettingCiphers], [zones.SettingEditResponseZonesCNAMEFlattening], -// [zones.ZoneSettingDevelopmentMode], [zones.ZoneSettingEarlyHints], -// [zones.SettingEditResponseZonesEdgeCacheTTL], -// [zones.ZoneSettingEmailObfuscation], [zones.ZoneSettingH2Prioritization], -// [zones.ZoneSettingHotlinkProtection], [zones.ZoneSettingHTTP2], -// [zones.ZoneSettingHTTP3], [zones.ZoneSettingImageResizing], -// [zones.ZoneSettingIPGeolocation], [zones.ZoneSettingIPV6], -// [zones.SettingEditResponseZonesMaxUpload], [zones.ZoneSettingMinTLSVersion], -// [zones.ZoneSettingMinify], [zones.ZoneSettingMirage], -// [zones.ZoneSettingMobileRedirect], [zones.ZoneSettingNEL], -// [zones.ZoneSettingOpportunisticEncryption], -// [zones.ZoneSettingOpportunisticOnion], [zones.ZoneSettingOrangeToOrange], -// [zones.ZoneSettingOriginErrorPagePassThru], [zones.ZoneSettingPolish], -// [zones.ZoneSettingPrefetchPreload], [zones.ZoneSettingProxyReadTimeout], -// [zones.ZoneSettingPseudoIPV4], [zones.ZoneSettingBuffering], -// [zones.ZoneSettingRocketLoader], -// [zones.SettingEditResponseZonesSchemasAutomaticPlatformOptimization], -// [zones.ZoneSettingSecurityHeader], [zones.ZoneSettingSecurityLevel], -// [zones.ZoneSettingServerSideExclude], -// [zones.SettingEditResponseZonesSha1Support], -// [zones.ZoneSettingSortQueryStringForCache], [zones.ZoneSettingSSL], -// [zones.ZoneSettingSSLRecommender], [zones.SettingEditResponseZonesTLS1_2Only], -// [zones.ZoneSettingTLS1_3], [zones.ZoneSettingTLSClientAuth], -// [zones.ZoneSettingTrueClientIPHeader], [zones.ZoneSettingWAF], -// [zones.ZoneSettingWebP] or [zones.ZoneSettingWebsockets]. -type SettingEditResponse interface { - implementsZonesSettingEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SettingEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSetting0rtt{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAdvancedDDoS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAlwaysOnline{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAlwaysUseHTTPS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAutomaticHTTPSRewrites{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBrotli{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBrowserCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBrowserCheck{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingCacheLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingChallengeTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingCiphers{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingEditResponseZonesCNAMEFlattening{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingDevelopmentMode{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEarlyHints{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingEditResponseZonesEdgeCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEmailObfuscation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingH2Prioritization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingHotlinkProtection{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingHTTP2{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingHTTP3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingImageResizing{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingIPGeolocation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingIPV6{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingEditResponseZonesMaxUpload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMinTLSVersion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMinify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMirage{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMobileRedirect{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingNEL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOpportunisticEncryption{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOpportunisticOnion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOrangeToOrange{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOriginErrorPagePassThru{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingPolish{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingPrefetchPreload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingProxyReadTimeout{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingPseudoIPV4{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBuffering{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingRocketLoader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingEditResponseZonesSchemasAutomaticPlatformOptimization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSecurityHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSecurityLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingServerSideExclude{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingEditResponseZonesSha1Support{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSortQueryStringForCache{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSSL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSSLRecommender{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingEditResponseZonesTLS1_2Only{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingTLS1_3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingTLSClientAuth{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingTrueClientIPHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingWAF{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingWebP{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingWebsockets{}), - }, - ) -} - -// Whether or not cname flattening is on. -type SettingEditResponseZonesCNAMEFlattening struct { - // How to flatten the cname destination. - ID SettingEditResponseZonesCNAMEFlatteningID `json:"id,required"` - // Current value of the zone setting. - Value SettingEditResponseZonesCNAMEFlatteningValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingEditResponseZonesCNAMEFlatteningEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingEditResponseZonesCNAMEFlatteningJSON `json:"-"` -} - -// settingEditResponseZonesCNAMEFlatteningJSON contains the JSON metadata for the -// struct [SettingEditResponseZonesCNAMEFlattening] -type settingEditResponseZonesCNAMEFlatteningJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseZonesCNAMEFlattening) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseZonesCNAMEFlatteningJSON) RawJSON() string { - return r.raw -} - -func (r SettingEditResponseZonesCNAMEFlattening) implementsZonesSettingEditResponse() {} - -// How to flatten the cname destination. -type SettingEditResponseZonesCNAMEFlatteningID string - -const ( - SettingEditResponseZonesCNAMEFlatteningIDCNAMEFlattening SettingEditResponseZonesCNAMEFlatteningID = "cname_flattening" -) - -func (r SettingEditResponseZonesCNAMEFlatteningID) IsKnown() bool { - switch r { - case SettingEditResponseZonesCNAMEFlatteningIDCNAMEFlattening: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditResponseZonesCNAMEFlatteningValue string - -const ( - SettingEditResponseZonesCNAMEFlatteningValueFlattenAtRoot SettingEditResponseZonesCNAMEFlatteningValue = "flatten_at_root" - SettingEditResponseZonesCNAMEFlatteningValueFlattenAll SettingEditResponseZonesCNAMEFlatteningValue = "flatten_all" -) - -func (r SettingEditResponseZonesCNAMEFlatteningValue) IsKnown() bool { - switch r { - case SettingEditResponseZonesCNAMEFlatteningValueFlattenAtRoot, SettingEditResponseZonesCNAMEFlatteningValueFlattenAll: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditResponseZonesCNAMEFlatteningEditable bool - -const ( - SettingEditResponseZonesCNAMEFlatteningEditableTrue SettingEditResponseZonesCNAMEFlatteningEditable = true - SettingEditResponseZonesCNAMEFlatteningEditableFalse SettingEditResponseZonesCNAMEFlatteningEditable = false -) - -func (r SettingEditResponseZonesCNAMEFlatteningEditable) IsKnown() bool { - switch r { - case SettingEditResponseZonesCNAMEFlatteningEditableTrue, SettingEditResponseZonesCNAMEFlatteningEditableFalse: - return true - } - return false -} - -// Time (in seconds) that a resource will be ensured to remain on Cloudflare's -// cache servers. -type SettingEditResponseZonesEdgeCacheTTL struct { - // ID of the zone setting. - ID SettingEditResponseZonesEdgeCacheTTLID `json:"id,required"` - // Current value of the zone setting. - Value SettingEditResponseZonesEdgeCacheTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingEditResponseZonesEdgeCacheTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingEditResponseZonesEdgeCacheTTLJSON `json:"-"` -} - -// settingEditResponseZonesEdgeCacheTTLJSON contains the JSON metadata for the -// struct [SettingEditResponseZonesEdgeCacheTTL] -type settingEditResponseZonesEdgeCacheTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseZonesEdgeCacheTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseZonesEdgeCacheTTLJSON) RawJSON() string { - return r.raw -} - -func (r SettingEditResponseZonesEdgeCacheTTL) implementsZonesSettingEditResponse() {} - -// ID of the zone setting. -type SettingEditResponseZonesEdgeCacheTTLID string - -const ( - SettingEditResponseZonesEdgeCacheTTLIDEdgeCacheTTL SettingEditResponseZonesEdgeCacheTTLID = "edge_cache_ttl" -) - -func (r SettingEditResponseZonesEdgeCacheTTLID) IsKnown() bool { - switch r { - case SettingEditResponseZonesEdgeCacheTTLIDEdgeCacheTTL: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditResponseZonesEdgeCacheTTLValue float64 - -const ( - SettingEditResponseZonesEdgeCacheTTLValue30 SettingEditResponseZonesEdgeCacheTTLValue = 30 - SettingEditResponseZonesEdgeCacheTTLValue60 SettingEditResponseZonesEdgeCacheTTLValue = 60 - SettingEditResponseZonesEdgeCacheTTLValue300 SettingEditResponseZonesEdgeCacheTTLValue = 300 - SettingEditResponseZonesEdgeCacheTTLValue1200 SettingEditResponseZonesEdgeCacheTTLValue = 1200 - SettingEditResponseZonesEdgeCacheTTLValue1800 SettingEditResponseZonesEdgeCacheTTLValue = 1800 - SettingEditResponseZonesEdgeCacheTTLValue3600 SettingEditResponseZonesEdgeCacheTTLValue = 3600 - SettingEditResponseZonesEdgeCacheTTLValue7200 SettingEditResponseZonesEdgeCacheTTLValue = 7200 - SettingEditResponseZonesEdgeCacheTTLValue10800 SettingEditResponseZonesEdgeCacheTTLValue = 10800 - SettingEditResponseZonesEdgeCacheTTLValue14400 SettingEditResponseZonesEdgeCacheTTLValue = 14400 - SettingEditResponseZonesEdgeCacheTTLValue18000 SettingEditResponseZonesEdgeCacheTTLValue = 18000 - SettingEditResponseZonesEdgeCacheTTLValue28800 SettingEditResponseZonesEdgeCacheTTLValue = 28800 - SettingEditResponseZonesEdgeCacheTTLValue43200 SettingEditResponseZonesEdgeCacheTTLValue = 43200 - SettingEditResponseZonesEdgeCacheTTLValue57600 SettingEditResponseZonesEdgeCacheTTLValue = 57600 - SettingEditResponseZonesEdgeCacheTTLValue72000 SettingEditResponseZonesEdgeCacheTTLValue = 72000 - SettingEditResponseZonesEdgeCacheTTLValue86400 SettingEditResponseZonesEdgeCacheTTLValue = 86400 - SettingEditResponseZonesEdgeCacheTTLValue172800 SettingEditResponseZonesEdgeCacheTTLValue = 172800 - SettingEditResponseZonesEdgeCacheTTLValue259200 SettingEditResponseZonesEdgeCacheTTLValue = 259200 - SettingEditResponseZonesEdgeCacheTTLValue345600 SettingEditResponseZonesEdgeCacheTTLValue = 345600 - SettingEditResponseZonesEdgeCacheTTLValue432000 SettingEditResponseZonesEdgeCacheTTLValue = 432000 - SettingEditResponseZonesEdgeCacheTTLValue518400 SettingEditResponseZonesEdgeCacheTTLValue = 518400 - SettingEditResponseZonesEdgeCacheTTLValue604800 SettingEditResponseZonesEdgeCacheTTLValue = 604800 -) - -func (r SettingEditResponseZonesEdgeCacheTTLValue) IsKnown() bool { - switch r { - case SettingEditResponseZonesEdgeCacheTTLValue30, SettingEditResponseZonesEdgeCacheTTLValue60, SettingEditResponseZonesEdgeCacheTTLValue300, SettingEditResponseZonesEdgeCacheTTLValue1200, SettingEditResponseZonesEdgeCacheTTLValue1800, SettingEditResponseZonesEdgeCacheTTLValue3600, SettingEditResponseZonesEdgeCacheTTLValue7200, SettingEditResponseZonesEdgeCacheTTLValue10800, SettingEditResponseZonesEdgeCacheTTLValue14400, SettingEditResponseZonesEdgeCacheTTLValue18000, SettingEditResponseZonesEdgeCacheTTLValue28800, SettingEditResponseZonesEdgeCacheTTLValue43200, SettingEditResponseZonesEdgeCacheTTLValue57600, SettingEditResponseZonesEdgeCacheTTLValue72000, SettingEditResponseZonesEdgeCacheTTLValue86400, SettingEditResponseZonesEdgeCacheTTLValue172800, SettingEditResponseZonesEdgeCacheTTLValue259200, SettingEditResponseZonesEdgeCacheTTLValue345600, SettingEditResponseZonesEdgeCacheTTLValue432000, SettingEditResponseZonesEdgeCacheTTLValue518400, SettingEditResponseZonesEdgeCacheTTLValue604800: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditResponseZonesEdgeCacheTTLEditable bool - -const ( - SettingEditResponseZonesEdgeCacheTTLEditableTrue SettingEditResponseZonesEdgeCacheTTLEditable = true - SettingEditResponseZonesEdgeCacheTTLEditableFalse SettingEditResponseZonesEdgeCacheTTLEditable = false -) - -func (r SettingEditResponseZonesEdgeCacheTTLEditable) IsKnown() bool { - switch r { - case SettingEditResponseZonesEdgeCacheTTLEditableTrue, SettingEditResponseZonesEdgeCacheTTLEditableFalse: - return true - } - return false -} - -// Maximum size of an allowable upload. -type SettingEditResponseZonesMaxUpload struct { - // identifier of the zone setting. - ID SettingEditResponseZonesMaxUploadID `json:"id,required"` - // Current value of the zone setting. - Value SettingEditResponseZonesMaxUploadValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingEditResponseZonesMaxUploadEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingEditResponseZonesMaxUploadJSON `json:"-"` -} - -// settingEditResponseZonesMaxUploadJSON contains the JSON metadata for the struct -// [SettingEditResponseZonesMaxUpload] -type settingEditResponseZonesMaxUploadJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseZonesMaxUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseZonesMaxUploadJSON) RawJSON() string { - return r.raw -} - -func (r SettingEditResponseZonesMaxUpload) implementsZonesSettingEditResponse() {} - -// identifier of the zone setting. -type SettingEditResponseZonesMaxUploadID string - -const ( - SettingEditResponseZonesMaxUploadIDMaxUpload SettingEditResponseZonesMaxUploadID = "max_upload" -) - -func (r SettingEditResponseZonesMaxUploadID) IsKnown() bool { - switch r { - case SettingEditResponseZonesMaxUploadIDMaxUpload: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditResponseZonesMaxUploadValue float64 - -const ( - SettingEditResponseZonesMaxUploadValue100 SettingEditResponseZonesMaxUploadValue = 100 - SettingEditResponseZonesMaxUploadValue200 SettingEditResponseZonesMaxUploadValue = 200 - SettingEditResponseZonesMaxUploadValue500 SettingEditResponseZonesMaxUploadValue = 500 -) - -func (r SettingEditResponseZonesMaxUploadValue) IsKnown() bool { - switch r { - case SettingEditResponseZonesMaxUploadValue100, SettingEditResponseZonesMaxUploadValue200, SettingEditResponseZonesMaxUploadValue500: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditResponseZonesMaxUploadEditable bool - -const ( - SettingEditResponseZonesMaxUploadEditableTrue SettingEditResponseZonesMaxUploadEditable = true - SettingEditResponseZonesMaxUploadEditableFalse SettingEditResponseZonesMaxUploadEditable = false -) - -func (r SettingEditResponseZonesMaxUploadEditable) IsKnown() bool { - switch r { - case SettingEditResponseZonesMaxUploadEditableTrue, SettingEditResponseZonesMaxUploadEditableFalse: - return true - } - return false -} - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -type SettingEditResponseZonesSchemasAutomaticPlatformOptimization struct { - // ID of the zone setting. - ID SettingEditResponseZonesSchemasAutomaticPlatformOptimizationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAutomaticPlatformOptimization `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON `json:"-"` -} - -// settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON contains the -// JSON metadata for the struct -// [SettingEditResponseZonesSchemasAutomaticPlatformOptimization] -type settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseZonesSchemasAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON) RawJSON() string { - return r.raw -} - -func (r SettingEditResponseZonesSchemasAutomaticPlatformOptimization) implementsZonesSettingEditResponse() { -} - -// ID of the zone setting. -type SettingEditResponseZonesSchemasAutomaticPlatformOptimizationID string - -const ( - SettingEditResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization SettingEditResponseZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" -) - -func (r SettingEditResponseZonesSchemasAutomaticPlatformOptimizationID) IsKnown() bool { - switch r { - case SettingEditResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable bool - -const ( - SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable = true - SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable = false -) - -func (r SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable) IsKnown() bool { - switch r { - case SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue, SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse: - return true - } - return false -} - -// Allow SHA1 support. -type SettingEditResponseZonesSha1Support struct { - // Zone setting identifier. - ID SettingEditResponseZonesSha1SupportID `json:"id,required"` - // Current value of the zone setting. - Value SettingEditResponseZonesSha1SupportValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingEditResponseZonesSha1SupportEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingEditResponseZonesSha1SupportJSON `json:"-"` -} - -// settingEditResponseZonesSha1SupportJSON contains the JSON metadata for the -// struct [SettingEditResponseZonesSha1Support] -type settingEditResponseZonesSha1SupportJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseZonesSha1Support) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseZonesSha1SupportJSON) RawJSON() string { - return r.raw -} - -func (r SettingEditResponseZonesSha1Support) implementsZonesSettingEditResponse() {} - -// Zone setting identifier. -type SettingEditResponseZonesSha1SupportID string - -const ( - SettingEditResponseZonesSha1SupportIDSha1Support SettingEditResponseZonesSha1SupportID = "sha1_support" -) - -func (r SettingEditResponseZonesSha1SupportID) IsKnown() bool { - switch r { - case SettingEditResponseZonesSha1SupportIDSha1Support: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditResponseZonesSha1SupportValue string - -const ( - SettingEditResponseZonesSha1SupportValueOff SettingEditResponseZonesSha1SupportValue = "off" - SettingEditResponseZonesSha1SupportValueOn SettingEditResponseZonesSha1SupportValue = "on" -) - -func (r SettingEditResponseZonesSha1SupportValue) IsKnown() bool { - switch r { - case SettingEditResponseZonesSha1SupportValueOff, SettingEditResponseZonesSha1SupportValueOn: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditResponseZonesSha1SupportEditable bool - -const ( - SettingEditResponseZonesSha1SupportEditableTrue SettingEditResponseZonesSha1SupportEditable = true - SettingEditResponseZonesSha1SupportEditableFalse SettingEditResponseZonesSha1SupportEditable = false -) - -func (r SettingEditResponseZonesSha1SupportEditable) IsKnown() bool { - switch r { - case SettingEditResponseZonesSha1SupportEditableTrue, SettingEditResponseZonesSha1SupportEditableFalse: - return true - } - return false -} - -// Only allows TLS1.2. -type SettingEditResponseZonesTLS1_2Only struct { - // Zone setting identifier. - ID SettingEditResponseZonesTLS1_2OnlyID `json:"id,required"` - // Current value of the zone setting. - Value SettingEditResponseZonesTLS1_2OnlyValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingEditResponseZonesTLS1_2OnlyEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingEditResponseZonesTls1_2OnlyJSON `json:"-"` -} - -// settingEditResponseZonesTls1_2OnlyJSON contains the JSON metadata for the struct -// [SettingEditResponseZonesTLS1_2Only] -type settingEditResponseZonesTls1_2OnlyJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseZonesTLS1_2Only) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseZonesTls1_2OnlyJSON) RawJSON() string { - return r.raw -} - -func (r SettingEditResponseZonesTLS1_2Only) implementsZonesSettingEditResponse() {} - -// Zone setting identifier. -type SettingEditResponseZonesTLS1_2OnlyID string - -const ( - SettingEditResponseZonesTLS1_2OnlyIDTLS1_2Only SettingEditResponseZonesTLS1_2OnlyID = "tls_1_2_only" -) - -func (r SettingEditResponseZonesTLS1_2OnlyID) IsKnown() bool { - switch r { - case SettingEditResponseZonesTLS1_2OnlyIDTLS1_2Only: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditResponseZonesTLS1_2OnlyValue string - -const ( - SettingEditResponseZonesTLS1_2OnlyValueOff SettingEditResponseZonesTLS1_2OnlyValue = "off" - SettingEditResponseZonesTLS1_2OnlyValueOn SettingEditResponseZonesTLS1_2OnlyValue = "on" -) - -func (r SettingEditResponseZonesTLS1_2OnlyValue) IsKnown() bool { - switch r { - case SettingEditResponseZonesTLS1_2OnlyValueOff, SettingEditResponseZonesTLS1_2OnlyValueOn: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditResponseZonesTLS1_2OnlyEditable bool - -const ( - SettingEditResponseZonesTLS1_2OnlyEditableTrue SettingEditResponseZonesTLS1_2OnlyEditable = true - SettingEditResponseZonesTLS1_2OnlyEditableFalse SettingEditResponseZonesTLS1_2OnlyEditable = false -) - -func (r SettingEditResponseZonesTLS1_2OnlyEditable) IsKnown() bool { - switch r { - case SettingEditResponseZonesTLS1_2OnlyEditableTrue, SettingEditResponseZonesTLS1_2OnlyEditableFalse: - return true - } - return false -} - -// 0-RTT session resumption enabled for this zone. -// -// Union satisfied by [zones.ZoneSetting0rtt], [zones.ZoneSettingAdvancedDDoS], -// [zones.ZoneSettingAlwaysOnline], [zones.ZoneSettingAlwaysUseHTTPS], -// [zones.ZoneSettingAutomaticHTTPSRewrites], [zones.ZoneSettingBrotli], -// [zones.ZoneSettingBrowserCacheTTL], [zones.ZoneSettingBrowserCheck], -// [zones.ZoneSettingCacheLevel], [zones.ZoneSettingChallengeTTL], -// [zones.ZoneSettingCiphers], [zones.SettingGetResponseZonesCNAMEFlattening], -// [zones.ZoneSettingDevelopmentMode], [zones.ZoneSettingEarlyHints], -// [zones.SettingGetResponseZonesEdgeCacheTTL], -// [zones.ZoneSettingEmailObfuscation], [zones.ZoneSettingH2Prioritization], -// [zones.ZoneSettingHotlinkProtection], [zones.ZoneSettingHTTP2], -// [zones.ZoneSettingHTTP3], [zones.ZoneSettingImageResizing], -// [zones.ZoneSettingIPGeolocation], [zones.ZoneSettingIPV6], -// [zones.SettingGetResponseZonesMaxUpload], [zones.ZoneSettingMinTLSVersion], -// [zones.ZoneSettingMinify], [zones.ZoneSettingMirage], -// [zones.ZoneSettingMobileRedirect], [zones.ZoneSettingNEL], -// [zones.ZoneSettingOpportunisticEncryption], -// [zones.ZoneSettingOpportunisticOnion], [zones.ZoneSettingOrangeToOrange], -// [zones.ZoneSettingOriginErrorPagePassThru], [zones.ZoneSettingPolish], -// [zones.ZoneSettingPrefetchPreload], [zones.ZoneSettingProxyReadTimeout], -// [zones.ZoneSettingPseudoIPV4], [zones.ZoneSettingBuffering], -// [zones.ZoneSettingRocketLoader], -// [zones.SettingGetResponseZonesSchemasAutomaticPlatformOptimization], -// [zones.ZoneSettingSecurityHeader], [zones.ZoneSettingSecurityLevel], -// [zones.ZoneSettingServerSideExclude], -// [zones.SettingGetResponseZonesSha1Support], -// [zones.ZoneSettingSortQueryStringForCache], [zones.ZoneSettingSSL], -// [zones.ZoneSettingSSLRecommender], [zones.SettingGetResponseZonesTLS1_2Only], -// [zones.ZoneSettingTLS1_3], [zones.ZoneSettingTLSClientAuth], -// [zones.ZoneSettingTrueClientIPHeader], [zones.ZoneSettingWAF], -// [zones.ZoneSettingWebP] or [zones.ZoneSettingWebsockets]. -type SettingGetResponse interface { - implementsZonesSettingGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SettingGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSetting0rtt{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAdvancedDDoS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAlwaysOnline{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAlwaysUseHTTPS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingAutomaticHTTPSRewrites{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBrotli{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBrowserCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBrowserCheck{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingCacheLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingChallengeTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingCiphers{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingGetResponseZonesCNAMEFlattening{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingDevelopmentMode{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEarlyHints{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingGetResponseZonesEdgeCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEmailObfuscation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingH2Prioritization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingHotlinkProtection{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingHTTP2{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingHTTP3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingImageResizing{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingIPGeolocation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingIPV6{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingGetResponseZonesMaxUpload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMinTLSVersion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMinify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMirage{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingMobileRedirect{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingNEL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOpportunisticEncryption{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOpportunisticOnion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOrangeToOrange{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingOriginErrorPagePassThru{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingPolish{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingPrefetchPreload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingProxyReadTimeout{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingPseudoIPV4{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingBuffering{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingRocketLoader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingGetResponseZonesSchemasAutomaticPlatformOptimization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSecurityHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSecurityLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingServerSideExclude{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingGetResponseZonesSha1Support{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSortQueryStringForCache{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSSL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingSSLRecommender{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SettingGetResponseZonesTLS1_2Only{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingTLS1_3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingTLSClientAuth{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingTrueClientIPHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingWAF{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingWebP{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingWebsockets{}), - }, - ) -} - -// Whether or not cname flattening is on. -type SettingGetResponseZonesCNAMEFlattening struct { - // How to flatten the cname destination. - ID SettingGetResponseZonesCNAMEFlatteningID `json:"id,required"` - // Current value of the zone setting. - Value SettingGetResponseZonesCNAMEFlatteningValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingGetResponseZonesCNAMEFlatteningEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingGetResponseZonesCNAMEFlatteningJSON `json:"-"` -} - -// settingGetResponseZonesCNAMEFlatteningJSON contains the JSON metadata for the -// struct [SettingGetResponseZonesCNAMEFlattening] -type settingGetResponseZonesCNAMEFlatteningJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseZonesCNAMEFlattening) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseZonesCNAMEFlatteningJSON) RawJSON() string { - return r.raw -} - -func (r SettingGetResponseZonesCNAMEFlattening) implementsZonesSettingGetResponse() {} - -// How to flatten the cname destination. -type SettingGetResponseZonesCNAMEFlatteningID string - -const ( - SettingGetResponseZonesCNAMEFlatteningIDCNAMEFlattening SettingGetResponseZonesCNAMEFlatteningID = "cname_flattening" -) - -func (r SettingGetResponseZonesCNAMEFlatteningID) IsKnown() bool { - switch r { - case SettingGetResponseZonesCNAMEFlatteningIDCNAMEFlattening: - return true - } - return false -} - -// Current value of the zone setting. -type SettingGetResponseZonesCNAMEFlatteningValue string - -const ( - SettingGetResponseZonesCNAMEFlatteningValueFlattenAtRoot SettingGetResponseZonesCNAMEFlatteningValue = "flatten_at_root" - SettingGetResponseZonesCNAMEFlatteningValueFlattenAll SettingGetResponseZonesCNAMEFlatteningValue = "flatten_all" -) - -func (r SettingGetResponseZonesCNAMEFlatteningValue) IsKnown() bool { - switch r { - case SettingGetResponseZonesCNAMEFlatteningValueFlattenAtRoot, SettingGetResponseZonesCNAMEFlatteningValueFlattenAll: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingGetResponseZonesCNAMEFlatteningEditable bool - -const ( - SettingGetResponseZonesCNAMEFlatteningEditableTrue SettingGetResponseZonesCNAMEFlatteningEditable = true - SettingGetResponseZonesCNAMEFlatteningEditableFalse SettingGetResponseZonesCNAMEFlatteningEditable = false -) - -func (r SettingGetResponseZonesCNAMEFlatteningEditable) IsKnown() bool { - switch r { - case SettingGetResponseZonesCNAMEFlatteningEditableTrue, SettingGetResponseZonesCNAMEFlatteningEditableFalse: - return true - } - return false -} - -// Time (in seconds) that a resource will be ensured to remain on Cloudflare's -// cache servers. -type SettingGetResponseZonesEdgeCacheTTL struct { - // ID of the zone setting. - ID SettingGetResponseZonesEdgeCacheTTLID `json:"id,required"` - // Current value of the zone setting. - Value SettingGetResponseZonesEdgeCacheTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingGetResponseZonesEdgeCacheTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingGetResponseZonesEdgeCacheTTLJSON `json:"-"` -} - -// settingGetResponseZonesEdgeCacheTTLJSON contains the JSON metadata for the -// struct [SettingGetResponseZonesEdgeCacheTTL] -type settingGetResponseZonesEdgeCacheTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseZonesEdgeCacheTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseZonesEdgeCacheTTLJSON) RawJSON() string { - return r.raw -} - -func (r SettingGetResponseZonesEdgeCacheTTL) implementsZonesSettingGetResponse() {} - -// ID of the zone setting. -type SettingGetResponseZonesEdgeCacheTTLID string - -const ( - SettingGetResponseZonesEdgeCacheTTLIDEdgeCacheTTL SettingGetResponseZonesEdgeCacheTTLID = "edge_cache_ttl" -) - -func (r SettingGetResponseZonesEdgeCacheTTLID) IsKnown() bool { - switch r { - case SettingGetResponseZonesEdgeCacheTTLIDEdgeCacheTTL: - return true - } - return false -} - -// Current value of the zone setting. -type SettingGetResponseZonesEdgeCacheTTLValue float64 - -const ( - SettingGetResponseZonesEdgeCacheTTLValue30 SettingGetResponseZonesEdgeCacheTTLValue = 30 - SettingGetResponseZonesEdgeCacheTTLValue60 SettingGetResponseZonesEdgeCacheTTLValue = 60 - SettingGetResponseZonesEdgeCacheTTLValue300 SettingGetResponseZonesEdgeCacheTTLValue = 300 - SettingGetResponseZonesEdgeCacheTTLValue1200 SettingGetResponseZonesEdgeCacheTTLValue = 1200 - SettingGetResponseZonesEdgeCacheTTLValue1800 SettingGetResponseZonesEdgeCacheTTLValue = 1800 - SettingGetResponseZonesEdgeCacheTTLValue3600 SettingGetResponseZonesEdgeCacheTTLValue = 3600 - SettingGetResponseZonesEdgeCacheTTLValue7200 SettingGetResponseZonesEdgeCacheTTLValue = 7200 - SettingGetResponseZonesEdgeCacheTTLValue10800 SettingGetResponseZonesEdgeCacheTTLValue = 10800 - SettingGetResponseZonesEdgeCacheTTLValue14400 SettingGetResponseZonesEdgeCacheTTLValue = 14400 - SettingGetResponseZonesEdgeCacheTTLValue18000 SettingGetResponseZonesEdgeCacheTTLValue = 18000 - SettingGetResponseZonesEdgeCacheTTLValue28800 SettingGetResponseZonesEdgeCacheTTLValue = 28800 - SettingGetResponseZonesEdgeCacheTTLValue43200 SettingGetResponseZonesEdgeCacheTTLValue = 43200 - SettingGetResponseZonesEdgeCacheTTLValue57600 SettingGetResponseZonesEdgeCacheTTLValue = 57600 - SettingGetResponseZonesEdgeCacheTTLValue72000 SettingGetResponseZonesEdgeCacheTTLValue = 72000 - SettingGetResponseZonesEdgeCacheTTLValue86400 SettingGetResponseZonesEdgeCacheTTLValue = 86400 - SettingGetResponseZonesEdgeCacheTTLValue172800 SettingGetResponseZonesEdgeCacheTTLValue = 172800 - SettingGetResponseZonesEdgeCacheTTLValue259200 SettingGetResponseZonesEdgeCacheTTLValue = 259200 - SettingGetResponseZonesEdgeCacheTTLValue345600 SettingGetResponseZonesEdgeCacheTTLValue = 345600 - SettingGetResponseZonesEdgeCacheTTLValue432000 SettingGetResponseZonesEdgeCacheTTLValue = 432000 - SettingGetResponseZonesEdgeCacheTTLValue518400 SettingGetResponseZonesEdgeCacheTTLValue = 518400 - SettingGetResponseZonesEdgeCacheTTLValue604800 SettingGetResponseZonesEdgeCacheTTLValue = 604800 -) - -func (r SettingGetResponseZonesEdgeCacheTTLValue) IsKnown() bool { - switch r { - case SettingGetResponseZonesEdgeCacheTTLValue30, SettingGetResponseZonesEdgeCacheTTLValue60, SettingGetResponseZonesEdgeCacheTTLValue300, SettingGetResponseZonesEdgeCacheTTLValue1200, SettingGetResponseZonesEdgeCacheTTLValue1800, SettingGetResponseZonesEdgeCacheTTLValue3600, SettingGetResponseZonesEdgeCacheTTLValue7200, SettingGetResponseZonesEdgeCacheTTLValue10800, SettingGetResponseZonesEdgeCacheTTLValue14400, SettingGetResponseZonesEdgeCacheTTLValue18000, SettingGetResponseZonesEdgeCacheTTLValue28800, SettingGetResponseZonesEdgeCacheTTLValue43200, SettingGetResponseZonesEdgeCacheTTLValue57600, SettingGetResponseZonesEdgeCacheTTLValue72000, SettingGetResponseZonesEdgeCacheTTLValue86400, SettingGetResponseZonesEdgeCacheTTLValue172800, SettingGetResponseZonesEdgeCacheTTLValue259200, SettingGetResponseZonesEdgeCacheTTLValue345600, SettingGetResponseZonesEdgeCacheTTLValue432000, SettingGetResponseZonesEdgeCacheTTLValue518400, SettingGetResponseZonesEdgeCacheTTLValue604800: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingGetResponseZonesEdgeCacheTTLEditable bool - -const ( - SettingGetResponseZonesEdgeCacheTTLEditableTrue SettingGetResponseZonesEdgeCacheTTLEditable = true - SettingGetResponseZonesEdgeCacheTTLEditableFalse SettingGetResponseZonesEdgeCacheTTLEditable = false -) - -func (r SettingGetResponseZonesEdgeCacheTTLEditable) IsKnown() bool { - switch r { - case SettingGetResponseZonesEdgeCacheTTLEditableTrue, SettingGetResponseZonesEdgeCacheTTLEditableFalse: - return true - } - return false -} - -// Maximum size of an allowable upload. -type SettingGetResponseZonesMaxUpload struct { - // identifier of the zone setting. - ID SettingGetResponseZonesMaxUploadID `json:"id,required"` - // Current value of the zone setting. - Value SettingGetResponseZonesMaxUploadValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingGetResponseZonesMaxUploadEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingGetResponseZonesMaxUploadJSON `json:"-"` -} - -// settingGetResponseZonesMaxUploadJSON contains the JSON metadata for the struct -// [SettingGetResponseZonesMaxUpload] -type settingGetResponseZonesMaxUploadJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseZonesMaxUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseZonesMaxUploadJSON) RawJSON() string { - return r.raw -} - -func (r SettingGetResponseZonesMaxUpload) implementsZonesSettingGetResponse() {} - -// identifier of the zone setting. -type SettingGetResponseZonesMaxUploadID string - -const ( - SettingGetResponseZonesMaxUploadIDMaxUpload SettingGetResponseZonesMaxUploadID = "max_upload" -) - -func (r SettingGetResponseZonesMaxUploadID) IsKnown() bool { - switch r { - case SettingGetResponseZonesMaxUploadIDMaxUpload: - return true - } - return false -} - -// Current value of the zone setting. -type SettingGetResponseZonesMaxUploadValue float64 - -const ( - SettingGetResponseZonesMaxUploadValue100 SettingGetResponseZonesMaxUploadValue = 100 - SettingGetResponseZonesMaxUploadValue200 SettingGetResponseZonesMaxUploadValue = 200 - SettingGetResponseZonesMaxUploadValue500 SettingGetResponseZonesMaxUploadValue = 500 -) - -func (r SettingGetResponseZonesMaxUploadValue) IsKnown() bool { - switch r { - case SettingGetResponseZonesMaxUploadValue100, SettingGetResponseZonesMaxUploadValue200, SettingGetResponseZonesMaxUploadValue500: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingGetResponseZonesMaxUploadEditable bool - -const ( - SettingGetResponseZonesMaxUploadEditableTrue SettingGetResponseZonesMaxUploadEditable = true - SettingGetResponseZonesMaxUploadEditableFalse SettingGetResponseZonesMaxUploadEditable = false -) - -func (r SettingGetResponseZonesMaxUploadEditable) IsKnown() bool { - switch r { - case SettingGetResponseZonesMaxUploadEditableTrue, SettingGetResponseZonesMaxUploadEditableFalse: - return true - } - return false -} - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -type SettingGetResponseZonesSchemasAutomaticPlatformOptimization struct { - // ID of the zone setting. - ID SettingGetResponseZonesSchemasAutomaticPlatformOptimizationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAutomaticPlatformOptimization `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON `json:"-"` -} - -// settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON contains the -// JSON metadata for the struct -// [SettingGetResponseZonesSchemasAutomaticPlatformOptimization] -type settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseZonesSchemasAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON) RawJSON() string { - return r.raw -} - -func (r SettingGetResponseZonesSchemasAutomaticPlatformOptimization) implementsZonesSettingGetResponse() { -} - -// ID of the zone setting. -type SettingGetResponseZonesSchemasAutomaticPlatformOptimizationID string - -const ( - SettingGetResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization SettingGetResponseZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" -) - -func (r SettingGetResponseZonesSchemasAutomaticPlatformOptimizationID) IsKnown() bool { - switch r { - case SettingGetResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable bool - -const ( - SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable = true - SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable = false -) - -func (r SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable) IsKnown() bool { - switch r { - case SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue, SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse: - return true - } - return false -} - -// Allow SHA1 support. -type SettingGetResponseZonesSha1Support struct { - // Zone setting identifier. - ID SettingGetResponseZonesSha1SupportID `json:"id,required"` - // Current value of the zone setting. - Value SettingGetResponseZonesSha1SupportValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingGetResponseZonesSha1SupportEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingGetResponseZonesSha1SupportJSON `json:"-"` -} - -// settingGetResponseZonesSha1SupportJSON contains the JSON metadata for the struct -// [SettingGetResponseZonesSha1Support] -type settingGetResponseZonesSha1SupportJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseZonesSha1Support) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseZonesSha1SupportJSON) RawJSON() string { - return r.raw -} - -func (r SettingGetResponseZonesSha1Support) implementsZonesSettingGetResponse() {} - -// Zone setting identifier. -type SettingGetResponseZonesSha1SupportID string - -const ( - SettingGetResponseZonesSha1SupportIDSha1Support SettingGetResponseZonesSha1SupportID = "sha1_support" -) - -func (r SettingGetResponseZonesSha1SupportID) IsKnown() bool { - switch r { - case SettingGetResponseZonesSha1SupportIDSha1Support: - return true - } - return false -} - -// Current value of the zone setting. -type SettingGetResponseZonesSha1SupportValue string - -const ( - SettingGetResponseZonesSha1SupportValueOff SettingGetResponseZonesSha1SupportValue = "off" - SettingGetResponseZonesSha1SupportValueOn SettingGetResponseZonesSha1SupportValue = "on" -) - -func (r SettingGetResponseZonesSha1SupportValue) IsKnown() bool { - switch r { - case SettingGetResponseZonesSha1SupportValueOff, SettingGetResponseZonesSha1SupportValueOn: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingGetResponseZonesSha1SupportEditable bool - -const ( - SettingGetResponseZonesSha1SupportEditableTrue SettingGetResponseZonesSha1SupportEditable = true - SettingGetResponseZonesSha1SupportEditableFalse SettingGetResponseZonesSha1SupportEditable = false -) - -func (r SettingGetResponseZonesSha1SupportEditable) IsKnown() bool { - switch r { - case SettingGetResponseZonesSha1SupportEditableTrue, SettingGetResponseZonesSha1SupportEditableFalse: - return true - } - return false -} - -// Only allows TLS1.2. -type SettingGetResponseZonesTLS1_2Only struct { - // Zone setting identifier. - ID SettingGetResponseZonesTLS1_2OnlyID `json:"id,required"` - // Current value of the zone setting. - Value SettingGetResponseZonesTLS1_2OnlyValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable SettingGetResponseZonesTLS1_2OnlyEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON settingGetResponseZonesTls1_2OnlyJSON `json:"-"` -} - -// settingGetResponseZonesTls1_2OnlyJSON contains the JSON metadata for the struct -// [SettingGetResponseZonesTLS1_2Only] -type settingGetResponseZonesTls1_2OnlyJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseZonesTLS1_2Only) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseZonesTls1_2OnlyJSON) RawJSON() string { - return r.raw -} - -func (r SettingGetResponseZonesTLS1_2Only) implementsZonesSettingGetResponse() {} - -// Zone setting identifier. -type SettingGetResponseZonesTLS1_2OnlyID string - -const ( - SettingGetResponseZonesTLS1_2OnlyIDTLS1_2Only SettingGetResponseZonesTLS1_2OnlyID = "tls_1_2_only" -) - -func (r SettingGetResponseZonesTLS1_2OnlyID) IsKnown() bool { - switch r { - case SettingGetResponseZonesTLS1_2OnlyIDTLS1_2Only: - return true - } - return false -} - -// Current value of the zone setting. -type SettingGetResponseZonesTLS1_2OnlyValue string - -const ( - SettingGetResponseZonesTLS1_2OnlyValueOff SettingGetResponseZonesTLS1_2OnlyValue = "off" - SettingGetResponseZonesTLS1_2OnlyValueOn SettingGetResponseZonesTLS1_2OnlyValue = "on" -) - -func (r SettingGetResponseZonesTLS1_2OnlyValue) IsKnown() bool { - switch r { - case SettingGetResponseZonesTLS1_2OnlyValueOff, SettingGetResponseZonesTLS1_2OnlyValueOn: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingGetResponseZonesTLS1_2OnlyEditable bool - -const ( - SettingGetResponseZonesTLS1_2OnlyEditableTrue SettingGetResponseZonesTLS1_2OnlyEditable = true - SettingGetResponseZonesTLS1_2OnlyEditableFalse SettingGetResponseZonesTLS1_2OnlyEditable = false -) - -func (r SettingGetResponseZonesTLS1_2OnlyEditable) IsKnown() bool { - switch r { - case SettingGetResponseZonesTLS1_2OnlyEditableTrue, SettingGetResponseZonesTLS1_2OnlyEditableFalse: - return true - } - return false -} - -type SettingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // One or more zone setting objects. Must contain an ID and a value. - Items param.Field[[]SettingEditParamsItem] `json:"items,required"` -} - -func (r SettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// 0-RTT session resumption enabled for this zone. -// -// Satisfied by [zones.ZoneSetting0rttParam], [zones.ZoneSettingAdvancedDDoSParam], -// [zones.ZoneSettingAlwaysOnlineParam], [zones.ZoneSettingAlwaysUseHTTPSParam], -// [zones.ZoneSettingAutomaticHTTPSRewritesParam], [zones.ZoneSettingBrotliParam], -// [zones.ZoneSettingBrowserCacheTTLParam], [zones.ZoneSettingBrowserCheckParam], -// [zones.ZoneSettingCacheLevelParam], [zones.ZoneSettingChallengeTTLParam], -// [zones.ZoneSettingCiphersParam], -// [zones.SettingEditParamsItemsZonesCNAMEFlattening], -// [zones.ZoneSettingDevelopmentModeParam], [zones.ZoneSettingEarlyHintsParam], -// [zones.SettingEditParamsItemsZonesEdgeCacheTTL], -// [zones.ZoneSettingEmailObfuscationParam], -// [zones.ZoneSettingH2PrioritizationParam], -// [zones.ZoneSettingHotlinkProtectionParam], [zones.ZoneSettingHTTP2Param], -// [zones.ZoneSettingHTTP3Param], [zones.ZoneSettingImageResizingParam], -// [zones.ZoneSettingIPGeolocationParam], [zones.ZoneSettingIPV6Param], -// [zones.SettingEditParamsItemsZonesMaxUpload], -// [zones.ZoneSettingMinTLSVersionParam], [zones.ZoneSettingMinifyParam], -// [zones.ZoneSettingMirageParam], [zones.ZoneSettingMobileRedirectParam], -// [zones.ZoneSettingNELParam], [zones.ZoneSettingOpportunisticEncryptionParam], -// [zones.ZoneSettingOpportunisticOnionParam], -// [zones.ZoneSettingOrangeToOrangeParam], -// [zones.ZoneSettingOriginErrorPagePassThruParam], [zones.ZoneSettingPolishParam], -// [zones.ZoneSettingPrefetchPreloadParam], -// [zones.ZoneSettingProxyReadTimeoutParam], [zones.ZoneSettingPseudoIPV4Param], -// [zones.ZoneSettingBufferingParam], [zones.ZoneSettingRocketLoaderParam], -// [zones.SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization], -// [zones.ZoneSettingSecurityHeaderParam], [zones.ZoneSettingSecurityLevelParam], -// [zones.ZoneSettingServerSideExcludeParam], -// [zones.SettingEditParamsItemsZonesSha1Support], -// [zones.ZoneSettingSortQueryStringForCacheParam], [zones.ZoneSettingSSLParam], -// [zones.ZoneSettingSSLRecommenderParam], -// [zones.SettingEditParamsItemsZonesTLS1_2Only], [zones.ZoneSettingTLS1_3Param], -// [zones.ZoneSettingTLSClientAuthParam], -// [zones.ZoneSettingTrueClientIPHeaderParam], [zones.ZoneSettingWAFParam], -// [zones.ZoneSettingWebPParam], [zones.ZoneSettingWebsocketsParam]. -type SettingEditParamsItem interface { - implementsZonesSettingEditParamsItem() -} - -// Whether or not cname flattening is on. -type SettingEditParamsItemsZonesCNAMEFlattening struct { - // How to flatten the cname destination. - ID param.Field[SettingEditParamsItemsZonesCNAMEFlatteningID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[SettingEditParamsItemsZonesCNAMEFlatteningValue] `json:"value,required"` -} - -func (r SettingEditParamsItemsZonesCNAMEFlattening) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SettingEditParamsItemsZonesCNAMEFlattening) implementsZonesSettingEditParamsItem() {} - -// How to flatten the cname destination. -type SettingEditParamsItemsZonesCNAMEFlatteningID string - -const ( - SettingEditParamsItemsZonesCNAMEFlatteningIDCNAMEFlattening SettingEditParamsItemsZonesCNAMEFlatteningID = "cname_flattening" -) - -func (r SettingEditParamsItemsZonesCNAMEFlatteningID) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesCNAMEFlatteningIDCNAMEFlattening: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditParamsItemsZonesCNAMEFlatteningValue string - -const ( - SettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAtRoot SettingEditParamsItemsZonesCNAMEFlatteningValue = "flatten_at_root" - SettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAll SettingEditParamsItemsZonesCNAMEFlatteningValue = "flatten_all" -) - -func (r SettingEditParamsItemsZonesCNAMEFlatteningValue) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAtRoot, SettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAll: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditParamsItemsZonesCNAMEFlatteningEditable bool - -const ( - SettingEditParamsItemsZonesCNAMEFlatteningEditableTrue SettingEditParamsItemsZonesCNAMEFlatteningEditable = true - SettingEditParamsItemsZonesCNAMEFlatteningEditableFalse SettingEditParamsItemsZonesCNAMEFlatteningEditable = false -) - -func (r SettingEditParamsItemsZonesCNAMEFlatteningEditable) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesCNAMEFlatteningEditableTrue, SettingEditParamsItemsZonesCNAMEFlatteningEditableFalse: - return true - } - return false -} - -// Time (in seconds) that a resource will be ensured to remain on Cloudflare's -// cache servers. -type SettingEditParamsItemsZonesEdgeCacheTTL struct { - // ID of the zone setting. - ID param.Field[SettingEditParamsItemsZonesEdgeCacheTTLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[SettingEditParamsItemsZonesEdgeCacheTTLValue] `json:"value,required"` -} - -func (r SettingEditParamsItemsZonesEdgeCacheTTL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SettingEditParamsItemsZonesEdgeCacheTTL) implementsZonesSettingEditParamsItem() {} - -// ID of the zone setting. -type SettingEditParamsItemsZonesEdgeCacheTTLID string - -const ( - SettingEditParamsItemsZonesEdgeCacheTTLIDEdgeCacheTTL SettingEditParamsItemsZonesEdgeCacheTTLID = "edge_cache_ttl" -) - -func (r SettingEditParamsItemsZonesEdgeCacheTTLID) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesEdgeCacheTTLIDEdgeCacheTTL: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditParamsItemsZonesEdgeCacheTTLValue float64 - -const ( - SettingEditParamsItemsZonesEdgeCacheTTLValue30 SettingEditParamsItemsZonesEdgeCacheTTLValue = 30 - SettingEditParamsItemsZonesEdgeCacheTTLValue60 SettingEditParamsItemsZonesEdgeCacheTTLValue = 60 - SettingEditParamsItemsZonesEdgeCacheTTLValue300 SettingEditParamsItemsZonesEdgeCacheTTLValue = 300 - SettingEditParamsItemsZonesEdgeCacheTTLValue1200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 1200 - SettingEditParamsItemsZonesEdgeCacheTTLValue1800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 1800 - SettingEditParamsItemsZonesEdgeCacheTTLValue3600 SettingEditParamsItemsZonesEdgeCacheTTLValue = 3600 - SettingEditParamsItemsZonesEdgeCacheTTLValue7200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 7200 - SettingEditParamsItemsZonesEdgeCacheTTLValue10800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 10800 - SettingEditParamsItemsZonesEdgeCacheTTLValue14400 SettingEditParamsItemsZonesEdgeCacheTTLValue = 14400 - SettingEditParamsItemsZonesEdgeCacheTTLValue18000 SettingEditParamsItemsZonesEdgeCacheTTLValue = 18000 - SettingEditParamsItemsZonesEdgeCacheTTLValue28800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 28800 - SettingEditParamsItemsZonesEdgeCacheTTLValue43200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 43200 - SettingEditParamsItemsZonesEdgeCacheTTLValue57600 SettingEditParamsItemsZonesEdgeCacheTTLValue = 57600 - SettingEditParamsItemsZonesEdgeCacheTTLValue72000 SettingEditParamsItemsZonesEdgeCacheTTLValue = 72000 - SettingEditParamsItemsZonesEdgeCacheTTLValue86400 SettingEditParamsItemsZonesEdgeCacheTTLValue = 86400 - SettingEditParamsItemsZonesEdgeCacheTTLValue172800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 172800 - SettingEditParamsItemsZonesEdgeCacheTTLValue259200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 259200 - SettingEditParamsItemsZonesEdgeCacheTTLValue345600 SettingEditParamsItemsZonesEdgeCacheTTLValue = 345600 - SettingEditParamsItemsZonesEdgeCacheTTLValue432000 SettingEditParamsItemsZonesEdgeCacheTTLValue = 432000 - SettingEditParamsItemsZonesEdgeCacheTTLValue518400 SettingEditParamsItemsZonesEdgeCacheTTLValue = 518400 - SettingEditParamsItemsZonesEdgeCacheTTLValue604800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 604800 -) - -func (r SettingEditParamsItemsZonesEdgeCacheTTLValue) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesEdgeCacheTTLValue30, SettingEditParamsItemsZonesEdgeCacheTTLValue60, SettingEditParamsItemsZonesEdgeCacheTTLValue300, SettingEditParamsItemsZonesEdgeCacheTTLValue1200, SettingEditParamsItemsZonesEdgeCacheTTLValue1800, SettingEditParamsItemsZonesEdgeCacheTTLValue3600, SettingEditParamsItemsZonesEdgeCacheTTLValue7200, SettingEditParamsItemsZonesEdgeCacheTTLValue10800, SettingEditParamsItemsZonesEdgeCacheTTLValue14400, SettingEditParamsItemsZonesEdgeCacheTTLValue18000, SettingEditParamsItemsZonesEdgeCacheTTLValue28800, SettingEditParamsItemsZonesEdgeCacheTTLValue43200, SettingEditParamsItemsZonesEdgeCacheTTLValue57600, SettingEditParamsItemsZonesEdgeCacheTTLValue72000, SettingEditParamsItemsZonesEdgeCacheTTLValue86400, SettingEditParamsItemsZonesEdgeCacheTTLValue172800, SettingEditParamsItemsZonesEdgeCacheTTLValue259200, SettingEditParamsItemsZonesEdgeCacheTTLValue345600, SettingEditParamsItemsZonesEdgeCacheTTLValue432000, SettingEditParamsItemsZonesEdgeCacheTTLValue518400, SettingEditParamsItemsZonesEdgeCacheTTLValue604800: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditParamsItemsZonesEdgeCacheTTLEditable bool - -const ( - SettingEditParamsItemsZonesEdgeCacheTTLEditableTrue SettingEditParamsItemsZonesEdgeCacheTTLEditable = true - SettingEditParamsItemsZonesEdgeCacheTTLEditableFalse SettingEditParamsItemsZonesEdgeCacheTTLEditable = false -) - -func (r SettingEditParamsItemsZonesEdgeCacheTTLEditable) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesEdgeCacheTTLEditableTrue, SettingEditParamsItemsZonesEdgeCacheTTLEditableFalse: - return true - } - return false -} - -// Maximum size of an allowable upload. -type SettingEditParamsItemsZonesMaxUpload struct { - // identifier of the zone setting. - ID param.Field[SettingEditParamsItemsZonesMaxUploadID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[SettingEditParamsItemsZonesMaxUploadValue] `json:"value,required"` -} - -func (r SettingEditParamsItemsZonesMaxUpload) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SettingEditParamsItemsZonesMaxUpload) implementsZonesSettingEditParamsItem() {} - -// identifier of the zone setting. -type SettingEditParamsItemsZonesMaxUploadID string - -const ( - SettingEditParamsItemsZonesMaxUploadIDMaxUpload SettingEditParamsItemsZonesMaxUploadID = "max_upload" -) - -func (r SettingEditParamsItemsZonesMaxUploadID) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesMaxUploadIDMaxUpload: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditParamsItemsZonesMaxUploadValue float64 - -const ( - SettingEditParamsItemsZonesMaxUploadValue100 SettingEditParamsItemsZonesMaxUploadValue = 100 - SettingEditParamsItemsZonesMaxUploadValue200 SettingEditParamsItemsZonesMaxUploadValue = 200 - SettingEditParamsItemsZonesMaxUploadValue500 SettingEditParamsItemsZonesMaxUploadValue = 500 -) - -func (r SettingEditParamsItemsZonesMaxUploadValue) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesMaxUploadValue100, SettingEditParamsItemsZonesMaxUploadValue200, SettingEditParamsItemsZonesMaxUploadValue500: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditParamsItemsZonesMaxUploadEditable bool - -const ( - SettingEditParamsItemsZonesMaxUploadEditableTrue SettingEditParamsItemsZonesMaxUploadEditable = true - SettingEditParamsItemsZonesMaxUploadEditableFalse SettingEditParamsItemsZonesMaxUploadEditable = false -) - -func (r SettingEditParamsItemsZonesMaxUploadEditable) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesMaxUploadEditableTrue, SettingEditParamsItemsZonesMaxUploadEditableFalse: - return true - } - return false -} - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -type SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization struct { - // ID of the zone setting. - ID param.Field[SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingAutomaticPlatformOptimizationParam] `json:"value,required"` -} - -func (r SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization) implementsZonesSettingEditParamsItem() { -} - -// ID of the zone setting. -type SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID string - -const ( - SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" -) - -func (r SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable bool - -const ( - SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableTrue SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable = true - SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableFalse SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable = false -) - -func (r SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableTrue, SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableFalse: - return true - } - return false -} - -// Allow SHA1 support. -type SettingEditParamsItemsZonesSha1Support struct { - // Zone setting identifier. - ID param.Field[SettingEditParamsItemsZonesSha1SupportID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[SettingEditParamsItemsZonesSha1SupportValue] `json:"value,required"` -} - -func (r SettingEditParamsItemsZonesSha1Support) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SettingEditParamsItemsZonesSha1Support) implementsZonesSettingEditParamsItem() {} - -// Zone setting identifier. -type SettingEditParamsItemsZonesSha1SupportID string - -const ( - SettingEditParamsItemsZonesSha1SupportIDSha1Support SettingEditParamsItemsZonesSha1SupportID = "sha1_support" -) - -func (r SettingEditParamsItemsZonesSha1SupportID) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesSha1SupportIDSha1Support: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditParamsItemsZonesSha1SupportValue string - -const ( - SettingEditParamsItemsZonesSha1SupportValueOff SettingEditParamsItemsZonesSha1SupportValue = "off" - SettingEditParamsItemsZonesSha1SupportValueOn SettingEditParamsItemsZonesSha1SupportValue = "on" -) - -func (r SettingEditParamsItemsZonesSha1SupportValue) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesSha1SupportValueOff, SettingEditParamsItemsZonesSha1SupportValueOn: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditParamsItemsZonesSha1SupportEditable bool - -const ( - SettingEditParamsItemsZonesSha1SupportEditableTrue SettingEditParamsItemsZonesSha1SupportEditable = true - SettingEditParamsItemsZonesSha1SupportEditableFalse SettingEditParamsItemsZonesSha1SupportEditable = false -) - -func (r SettingEditParamsItemsZonesSha1SupportEditable) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesSha1SupportEditableTrue, SettingEditParamsItemsZonesSha1SupportEditableFalse: - return true - } - return false -} - -// Only allows TLS1.2. -type SettingEditParamsItemsZonesTLS1_2Only struct { - // Zone setting identifier. - ID param.Field[SettingEditParamsItemsZonesTLS1_2OnlyID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[SettingEditParamsItemsZonesTLS1_2OnlyValue] `json:"value,required"` -} - -func (r SettingEditParamsItemsZonesTLS1_2Only) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SettingEditParamsItemsZonesTLS1_2Only) implementsZonesSettingEditParamsItem() {} - -// Zone setting identifier. -type SettingEditParamsItemsZonesTLS1_2OnlyID string - -const ( - SettingEditParamsItemsZonesTLS1_2OnlyIDTLS1_2Only SettingEditParamsItemsZonesTLS1_2OnlyID = "tls_1_2_only" -) - -func (r SettingEditParamsItemsZonesTLS1_2OnlyID) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesTLS1_2OnlyIDTLS1_2Only: - return true - } - return false -} - -// Current value of the zone setting. -type SettingEditParamsItemsZonesTLS1_2OnlyValue string - -const ( - SettingEditParamsItemsZonesTLS1_2OnlyValueOff SettingEditParamsItemsZonesTLS1_2OnlyValue = "off" - SettingEditParamsItemsZonesTLS1_2OnlyValueOn SettingEditParamsItemsZonesTLS1_2OnlyValue = "on" -) - -func (r SettingEditParamsItemsZonesTLS1_2OnlyValue) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesTLS1_2OnlyValueOff, SettingEditParamsItemsZonesTLS1_2OnlyValueOn: - return true - } - return false -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type SettingEditParamsItemsZonesTLS1_2OnlyEditable bool - -const ( - SettingEditParamsItemsZonesTLS1_2OnlyEditableTrue SettingEditParamsItemsZonesTLS1_2OnlyEditable = true - SettingEditParamsItemsZonesTLS1_2OnlyEditableFalse SettingEditParamsItemsZonesTLS1_2OnlyEditable = false -) - -func (r SettingEditParamsItemsZonesTLS1_2OnlyEditable) IsKnown() bool { - switch r { - case SettingEditParamsItemsZonesTLS1_2OnlyEditableTrue, SettingEditParamsItemsZonesTLS1_2OnlyEditableFalse: - return true - } - return false -} - -type SettingEditResponseEnvelope struct { - Errors []SettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - Result []SettingEditResponse `json:"result"` - JSON settingEditResponseEnvelopeJSON `json:"-"` -} - -// settingEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [SettingEditResponseEnvelope] -type settingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SettingEditResponseEnvelopeErrors] -type settingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingEditResponseEnvelopeMessages] -type settingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type SettingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SettingGetResponseEnvelope struct { - Errors []SettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - Result []SettingGetResponse `json:"result"` - JSON settingGetResponseEnvelopeJSON `json:"-"` -} - -// settingGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [SettingGetResponseEnvelope] -type settingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [SettingGetResponseEnvelopeErrors] -type settingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [SettingGetResponseEnvelopeMessages] -type settingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingadvancedddos.go b/zones/settingadvancedddos.go index d0906431266..5f27e945558 100644 --- a/zones/settingadvancedddos.go +++ b/zones/settingadvancedddos.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingAdvancedDDoSService(opts ...option.RequestOption) (r *SettingAdva // Advanced protection from Distributed Denial of Service (DDoS) attacks on your // website. This is an uneditable value that is 'on' in the case of Business and // Enterprise zones. -func (r *SettingAdvancedDDoSService) Get(ctx context.Context, query SettingAdvancedDDoSGetParams, opts ...option.RequestOption) (res *ZoneSettingAdvancedDDoS, err error) { +func (r *SettingAdvancedDDoSService) Get(ctx context.Context, query SettingAdvancedDDoSGetParams, opts ...option.RequestOption) (res *AdvancedDDoS, err error) { opts = append(r.Options[:], opts...) var env SettingAdvancedDDoSGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/advanced_ddos", query.ZoneID) @@ -50,22 +51,21 @@ func (r *SettingAdvancedDDoSService) Get(ctx context.Context, query SettingAdvan // Advanced protection from Distributed Denial of Service (DDoS) attacks on your // website. This is an uneditable value that is 'on' in the case of Business and // Enterprise zones. -type ZoneSettingAdvancedDDoS struct { +type AdvancedDDoS struct { // ID of the zone setting. - ID ZoneSettingAdvancedDDoSID `json:"id,required"` + ID AdvancedDDoSID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingAdvancedDDoSValue `json:"value,required"` + Value AdvancedDDoSValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingAdvancedDDoSEditable `json:"editable"` + Editable AdvancedDDoSEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAdvancedDDoSJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON advancedDDoSJSON `json:"-"` } -// zoneSettingAdvancedDDoSJSON contains the JSON metadata for the struct -// [ZoneSettingAdvancedDDoS] -type zoneSettingAdvancedDDoSJSON struct { +// advancedDDoSJSON contains the JSON metadata for the struct [AdvancedDDoS] +type advancedDDoSJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -74,44 +74,40 @@ type zoneSettingAdvancedDDoSJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingAdvancedDDoS) UnmarshalJSON(data []byte) (err error) { +func (r *AdvancedDDoS) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingAdvancedDDoSJSON) RawJSON() string { +func (r advancedDDoSJSON) RawJSON() string { return r.raw } -func (r ZoneSettingAdvancedDDoS) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingAdvancedDDoS) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingAdvancedDDoSID string +type AdvancedDDoSID string const ( - ZoneSettingAdvancedDDoSIDAdvancedDDoS ZoneSettingAdvancedDDoSID = "advanced_ddos" + AdvancedDDoSIDAdvancedDDoS AdvancedDDoSID = "advanced_ddos" ) -func (r ZoneSettingAdvancedDDoSID) IsKnown() bool { +func (r AdvancedDDoSID) IsKnown() bool { switch r { - case ZoneSettingAdvancedDDoSIDAdvancedDDoS: + case AdvancedDDoSIDAdvancedDDoS: return true } return false } // Current value of the zone setting. -type ZoneSettingAdvancedDDoSValue string +type AdvancedDDoSValue string const ( - ZoneSettingAdvancedDDoSValueOn ZoneSettingAdvancedDDoSValue = "on" - ZoneSettingAdvancedDDoSValueOff ZoneSettingAdvancedDDoSValue = "off" + AdvancedDDoSValueOn AdvancedDDoSValue = "on" + AdvancedDDoSValueOff AdvancedDDoSValue = "off" ) -func (r ZoneSettingAdvancedDDoSValue) IsKnown() bool { +func (r AdvancedDDoSValue) IsKnown() bool { switch r { - case ZoneSettingAdvancedDDoSValueOn, ZoneSettingAdvancedDDoSValueOff: + case AdvancedDDoSValueOn, AdvancedDDoSValueOff: return true } return false @@ -119,51 +115,35 @@ func (r ZoneSettingAdvancedDDoSValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingAdvancedDDoSEditable bool +type AdvancedDDoSEditable bool const ( - ZoneSettingAdvancedDDoSEditableTrue ZoneSettingAdvancedDDoSEditable = true - ZoneSettingAdvancedDDoSEditableFalse ZoneSettingAdvancedDDoSEditable = false + AdvancedDDoSEditableTrue AdvancedDDoSEditable = true + AdvancedDDoSEditableFalse AdvancedDDoSEditable = false ) -func (r ZoneSettingAdvancedDDoSEditable) IsKnown() bool { +func (r AdvancedDDoSEditable) IsKnown() bool { switch r { - case ZoneSettingAdvancedDDoSEditableTrue, ZoneSettingAdvancedDDoSEditableFalse: + case AdvancedDDoSEditableTrue, AdvancedDDoSEditableFalse: return true } return false } -// Advanced protection from Distributed Denial of Service (DDoS) attacks on your -// website. This is an uneditable value that is 'on' in the case of Business and -// Enterprise zones. -type ZoneSettingAdvancedDDoSParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingAdvancedDDoSID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingAdvancedDDoSValue] `json:"value,required"` -} - -func (r ZoneSettingAdvancedDDoSParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingAdvancedDDoSParam) implementsZonesSettingEditParamsItem() {} - type SettingAdvancedDDoSGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingAdvancedDDoSGetResponseEnvelope struct { - Errors []SettingAdvancedDDoSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAdvancedDDoSGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Advanced protection from Distributed Denial of Service (DDoS) attacks on your // website. This is an uneditable value that is 'on' in the case of Business and // Enterprise zones. - Result ZoneSettingAdvancedDDoS `json:"result"` + Result AdvancedDDoS `json:"result"` JSON settingAdvancedDDoSGetResponseEnvelopeJSON `json:"-"` } @@ -185,49 +165,3 @@ func (r *SettingAdvancedDDoSGetResponseEnvelope) UnmarshalJSON(data []byte) (err func (r settingAdvancedDDoSGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingAdvancedDDoSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAdvancedDDoSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAdvancedDDoSGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingAdvancedDDoSGetResponseEnvelopeErrors] -type settingAdvancedDDoSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAdvancedDDoSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAdvancedDDoSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAdvancedDDoSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAdvancedDDoSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAdvancedDDoSGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingAdvancedDDoSGetResponseEnvelopeMessages] -type settingAdvancedDDoSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAdvancedDDoSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAdvancedDDoSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingalwaysonline.go b/zones/settingalwaysonline.go index d3eff0862c3..f26dafa2028 100644 --- a/zones/settingalwaysonline.go +++ b/zones/settingalwaysonline.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -37,7 +38,7 @@ func NewSettingAlwaysOnlineService(opts ...option.RequestOption) (r *SettingAlwa // offline. Refer to // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for // more information. -func (r *SettingAlwaysOnlineService) Edit(ctx context.Context, params SettingAlwaysOnlineEditParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysOnline, err error) { +func (r *SettingAlwaysOnlineService) Edit(ctx context.Context, params SettingAlwaysOnlineEditParams, opts ...option.RequestOption) (res *AlwaysOnline, err error) { opts = append(r.Options[:], opts...) var env SettingAlwaysOnlineEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/always_online", params.ZoneID) @@ -54,7 +55,7 @@ func (r *SettingAlwaysOnlineService) Edit(ctx context.Context, params SettingAlw // offline. Refer to // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for // more information. -func (r *SettingAlwaysOnlineService) Get(ctx context.Context, query SettingAlwaysOnlineGetParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysOnline, err error) { +func (r *SettingAlwaysOnlineService) Get(ctx context.Context, query SettingAlwaysOnlineGetParams, opts ...option.RequestOption) (res *AlwaysOnline, err error) { opts = append(r.Options[:], opts...) var env SettingAlwaysOnlineGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/always_online", query.ZoneID) @@ -71,22 +72,21 @@ func (r *SettingAlwaysOnlineService) Get(ctx context.Context, query SettingAlway // offline. Refer to // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for // more information. -type ZoneSettingAlwaysOnline struct { +type AlwaysOnline struct { // ID of the zone setting. - ID ZoneSettingAlwaysOnlineID `json:"id,required"` + ID AlwaysOnlineID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingAlwaysOnlineValue `json:"value,required"` + Value AlwaysOnlineValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingAlwaysOnlineEditable `json:"editable"` + Editable AlwaysOnlineEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAlwaysOnlineJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON alwaysOnlineJSON `json:"-"` } -// zoneSettingAlwaysOnlineJSON contains the JSON metadata for the struct -// [ZoneSettingAlwaysOnline] -type zoneSettingAlwaysOnlineJSON struct { +// alwaysOnlineJSON contains the JSON metadata for the struct [AlwaysOnline] +type alwaysOnlineJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -95,44 +95,40 @@ type zoneSettingAlwaysOnlineJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingAlwaysOnline) UnmarshalJSON(data []byte) (err error) { +func (r *AlwaysOnline) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingAlwaysOnlineJSON) RawJSON() string { +func (r alwaysOnlineJSON) RawJSON() string { return r.raw } -func (r ZoneSettingAlwaysOnline) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingAlwaysOnline) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingAlwaysOnlineID string +type AlwaysOnlineID string const ( - ZoneSettingAlwaysOnlineIDAlwaysOnline ZoneSettingAlwaysOnlineID = "always_online" + AlwaysOnlineIDAlwaysOnline AlwaysOnlineID = "always_online" ) -func (r ZoneSettingAlwaysOnlineID) IsKnown() bool { +func (r AlwaysOnlineID) IsKnown() bool { switch r { - case ZoneSettingAlwaysOnlineIDAlwaysOnline: + case AlwaysOnlineIDAlwaysOnline: return true } return false } // Current value of the zone setting. -type ZoneSettingAlwaysOnlineValue string +type AlwaysOnlineValue string const ( - ZoneSettingAlwaysOnlineValueOn ZoneSettingAlwaysOnlineValue = "on" - ZoneSettingAlwaysOnlineValueOff ZoneSettingAlwaysOnlineValue = "off" + AlwaysOnlineValueOn AlwaysOnlineValue = "on" + AlwaysOnlineValueOff AlwaysOnlineValue = "off" ) -func (r ZoneSettingAlwaysOnlineValue) IsKnown() bool { +func (r AlwaysOnlineValue) IsKnown() bool { switch r { - case ZoneSettingAlwaysOnlineValueOn, ZoneSettingAlwaysOnlineValueOff: + case AlwaysOnlineValueOn, AlwaysOnlineValueOff: return true } return false @@ -140,39 +136,21 @@ func (r ZoneSettingAlwaysOnlineValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingAlwaysOnlineEditable bool +type AlwaysOnlineEditable bool const ( - ZoneSettingAlwaysOnlineEditableTrue ZoneSettingAlwaysOnlineEditable = true - ZoneSettingAlwaysOnlineEditableFalse ZoneSettingAlwaysOnlineEditable = false + AlwaysOnlineEditableTrue AlwaysOnlineEditable = true + AlwaysOnlineEditableFalse AlwaysOnlineEditable = false ) -func (r ZoneSettingAlwaysOnlineEditable) IsKnown() bool { +func (r AlwaysOnlineEditable) IsKnown() bool { switch r { - case ZoneSettingAlwaysOnlineEditableTrue, ZoneSettingAlwaysOnlineEditableFalse: + case AlwaysOnlineEditableTrue, AlwaysOnlineEditableFalse: return true } return false } -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -type ZoneSettingAlwaysOnlineParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingAlwaysOnlineID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingAlwaysOnlineValue] `json:"value,required"` -} - -func (r ZoneSettingAlwaysOnlineParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingAlwaysOnlineParam) implementsZonesSettingEditParamsItem() {} - type SettingAlwaysOnlineEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -201,8 +179,8 @@ func (r SettingAlwaysOnlineEditParamsValue) IsKnown() bool { } type SettingAlwaysOnlineEditResponseEnvelope struct { - Errors []SettingAlwaysOnlineEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAlwaysOnlineEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When enabled, Cloudflare serves limited copies of web pages available from the @@ -210,7 +188,7 @@ type SettingAlwaysOnlineEditResponseEnvelope struct { // offline. Refer to // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for // more information. - Result ZoneSettingAlwaysOnline `json:"result"` + Result AlwaysOnline `json:"result"` JSON settingAlwaysOnlineEditResponseEnvelopeJSON `json:"-"` } @@ -233,60 +211,14 @@ func (r settingAlwaysOnlineEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingAlwaysOnlineEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysOnlineEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAlwaysOnlineEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingAlwaysOnlineEditResponseEnvelopeErrors] -type settingAlwaysOnlineEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysOnlineEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysOnlineEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAlwaysOnlineEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysOnlineEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAlwaysOnlineEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingAlwaysOnlineEditResponseEnvelopeMessages] -type settingAlwaysOnlineEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysOnlineEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysOnlineEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingAlwaysOnlineGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingAlwaysOnlineGetResponseEnvelope struct { - Errors []SettingAlwaysOnlineGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAlwaysOnlineGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When enabled, Cloudflare serves limited copies of web pages available from the @@ -294,7 +226,7 @@ type SettingAlwaysOnlineGetResponseEnvelope struct { // offline. Refer to // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for // more information. - Result ZoneSettingAlwaysOnline `json:"result"` + Result AlwaysOnline `json:"result"` JSON settingAlwaysOnlineGetResponseEnvelopeJSON `json:"-"` } @@ -316,49 +248,3 @@ func (r *SettingAlwaysOnlineGetResponseEnvelope) UnmarshalJSON(data []byte) (err func (r settingAlwaysOnlineGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingAlwaysOnlineGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysOnlineGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAlwaysOnlineGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingAlwaysOnlineGetResponseEnvelopeErrors] -type settingAlwaysOnlineGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysOnlineGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysOnlineGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAlwaysOnlineGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysOnlineGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAlwaysOnlineGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingAlwaysOnlineGetResponseEnvelopeMessages] -type settingAlwaysOnlineGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysOnlineGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysOnlineGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingalwaysusehttps.go b/zones/settingalwaysusehttps.go index 46b3794b1f1..5424a5fcbc2 100644 --- a/zones/settingalwaysusehttps.go +++ b/zones/settingalwaysusehttps.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingAlwaysUseHTTPSService(opts ...option.RequestOption) (r *SettingAl // Reply to all requests for URLs that use "http" with a 301 redirect to the // equivalent "https" URL. If you only want to redirect for a subset of requests, // consider creating an "Always use HTTPS" page rule. -func (r *SettingAlwaysUseHTTPSService) Edit(ctx context.Context, params SettingAlwaysUseHTTPSEditParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysUseHTTPS, err error) { +func (r *SettingAlwaysUseHTTPSService) Edit(ctx context.Context, params SettingAlwaysUseHTTPSEditParams, opts ...option.RequestOption) (res *AlwaysUseHTTPS, err error) { opts = append(r.Options[:], opts...) var env SettingAlwaysUseHTTPSEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/always_use_https", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingAlwaysUseHTTPSService) Edit(ctx context.Context, params SettingA // Reply to all requests for URLs that use "http" with a 301 redirect to the // equivalent "https" URL. If you only want to redirect for a subset of requests, // consider creating an "Always use HTTPS" page rule. -func (r *SettingAlwaysUseHTTPSService) Get(ctx context.Context, query SettingAlwaysUseHTTPSGetParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysUseHTTPS, err error) { +func (r *SettingAlwaysUseHTTPSService) Get(ctx context.Context, query SettingAlwaysUseHTTPSGetParams, opts ...option.RequestOption) (res *AlwaysUseHTTPS, err error) { opts = append(r.Options[:], opts...) var env SettingAlwaysUseHTTPSGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/always_use_https", query.ZoneID) @@ -65,22 +66,21 @@ func (r *SettingAlwaysUseHTTPSService) Get(ctx context.Context, query SettingAlw // Reply to all requests for URLs that use "http" with a 301 redirect to the // equivalent "https" URL. If you only want to redirect for a subset of requests, // consider creating an "Always use HTTPS" page rule. -type ZoneSettingAlwaysUseHTTPS struct { +type AlwaysUseHTTPS struct { // ID of the zone setting. - ID ZoneSettingAlwaysUseHTTPSID `json:"id,required"` + ID AlwaysUseHTTPSID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingAlwaysUseHTTPSValue `json:"value,required"` + Value AlwaysUseHTTPSValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingAlwaysUseHTTPSEditable `json:"editable"` + Editable AlwaysUseHTTPSEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAlwaysUseHTTPSJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON alwaysUseHTTPSJSON `json:"-"` } -// zoneSettingAlwaysUseHTTPSJSON contains the JSON metadata for the struct -// [ZoneSettingAlwaysUseHTTPS] -type zoneSettingAlwaysUseHTTPSJSON struct { +// alwaysUseHTTPSJSON contains the JSON metadata for the struct [AlwaysUseHTTPS] +type alwaysUseHTTPSJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -89,44 +89,40 @@ type zoneSettingAlwaysUseHTTPSJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingAlwaysUseHTTPS) UnmarshalJSON(data []byte) (err error) { +func (r *AlwaysUseHTTPS) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingAlwaysUseHTTPSJSON) RawJSON() string { +func (r alwaysUseHTTPSJSON) RawJSON() string { return r.raw } -func (r ZoneSettingAlwaysUseHTTPS) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingAlwaysUseHTTPS) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingAlwaysUseHTTPSID string +type AlwaysUseHTTPSID string const ( - ZoneSettingAlwaysUseHTTPSIDAlwaysUseHTTPS ZoneSettingAlwaysUseHTTPSID = "always_use_https" + AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https" ) -func (r ZoneSettingAlwaysUseHTTPSID) IsKnown() bool { +func (r AlwaysUseHTTPSID) IsKnown() bool { switch r { - case ZoneSettingAlwaysUseHTTPSIDAlwaysUseHTTPS: + case AlwaysUseHTTPSIDAlwaysUseHTTPS: return true } return false } // Current value of the zone setting. -type ZoneSettingAlwaysUseHTTPSValue string +type AlwaysUseHTTPSValue string const ( - ZoneSettingAlwaysUseHTTPSValueOn ZoneSettingAlwaysUseHTTPSValue = "on" - ZoneSettingAlwaysUseHTTPSValueOff ZoneSettingAlwaysUseHTTPSValue = "off" + AlwaysUseHTTPSValueOn AlwaysUseHTTPSValue = "on" + AlwaysUseHTTPSValueOff AlwaysUseHTTPSValue = "off" ) -func (r ZoneSettingAlwaysUseHTTPSValue) IsKnown() bool { +func (r AlwaysUseHTTPSValue) IsKnown() bool { switch r { - case ZoneSettingAlwaysUseHTTPSValueOn, ZoneSettingAlwaysUseHTTPSValueOff: + case AlwaysUseHTTPSValueOn, AlwaysUseHTTPSValueOff: return true } return false @@ -134,37 +130,21 @@ func (r ZoneSettingAlwaysUseHTTPSValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingAlwaysUseHTTPSEditable bool +type AlwaysUseHTTPSEditable bool const ( - ZoneSettingAlwaysUseHTTPSEditableTrue ZoneSettingAlwaysUseHTTPSEditable = true - ZoneSettingAlwaysUseHTTPSEditableFalse ZoneSettingAlwaysUseHTTPSEditable = false + AlwaysUseHTTPSEditableTrue AlwaysUseHTTPSEditable = true + AlwaysUseHTTPSEditableFalse AlwaysUseHTTPSEditable = false ) -func (r ZoneSettingAlwaysUseHTTPSEditable) IsKnown() bool { +func (r AlwaysUseHTTPSEditable) IsKnown() bool { switch r { - case ZoneSettingAlwaysUseHTTPSEditableTrue, ZoneSettingAlwaysUseHTTPSEditableFalse: + case AlwaysUseHTTPSEditableTrue, AlwaysUseHTTPSEditableFalse: return true } return false } -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -type ZoneSettingAlwaysUseHTTPSParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingAlwaysUseHTTPSID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingAlwaysUseHTTPSValue] `json:"value,required"` -} - -func (r ZoneSettingAlwaysUseHTTPSParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingAlwaysUseHTTPSParam) implementsZonesSettingEditParamsItem() {} - type SettingAlwaysUseHTTPSEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -193,14 +173,14 @@ func (r SettingAlwaysUseHTTPSEditParamsValue) IsKnown() bool { } type SettingAlwaysUseHTTPSEditResponseEnvelope struct { - Errors []SettingAlwaysUseHTTPSEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAlwaysUseHTTPSEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Reply to all requests for URLs that use "http" with a 301 redirect to the // equivalent "https" URL. If you only want to redirect for a subset of requests, // consider creating an "Always use HTTPS" page rule. - Result ZoneSettingAlwaysUseHTTPS `json:"result"` + Result AlwaysUseHTTPS `json:"result"` JSON settingAlwaysUseHTTPSEditResponseEnvelopeJSON `json:"-"` } @@ -223,66 +203,20 @@ func (r settingAlwaysUseHTTPSEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingAlwaysUseHTTPSEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingAlwaysUseHTTPSEditResponseEnvelopeErrors] -type settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysUseHTTPSEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAlwaysUseHTTPSEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingAlwaysUseHTTPSEditResponseEnvelopeMessages] -type settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysUseHTTPSEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingAlwaysUseHTTPSGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingAlwaysUseHTTPSGetResponseEnvelope struct { - Errors []SettingAlwaysUseHTTPSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAlwaysUseHTTPSGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Reply to all requests for URLs that use "http" with a 301 redirect to the // equivalent "https" URL. If you only want to redirect for a subset of requests, // consider creating an "Always use HTTPS" page rule. - Result ZoneSettingAlwaysUseHTTPS `json:"result"` + Result AlwaysUseHTTPS `json:"result"` JSON settingAlwaysUseHTTPSGetResponseEnvelopeJSON `json:"-"` } @@ -304,49 +238,3 @@ func (r *SettingAlwaysUseHTTPSGetResponseEnvelope) UnmarshalJSON(data []byte) (e func (r settingAlwaysUseHTTPSGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingAlwaysUseHTTPSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingAlwaysUseHTTPSGetResponseEnvelopeErrors] -type settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysUseHTTPSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAlwaysUseHTTPSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingAlwaysUseHTTPSGetResponseEnvelopeMessages] -type settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAlwaysUseHTTPSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingautomatichttpsrewrite.go b/zones/settingautomatichttpsrewrite.go index a3dad9d73da..77a1ec64799 100644 --- a/zones/settingautomatichttpsrewrite.go +++ b/zones/settingautomatichttpsrewrite.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingAutomaticHTTPSRewriteService(opts ...option.RequestOption) (r *Se } // Enable the Automatic HTTPS Rewrites feature for this zone. -func (r *SettingAutomaticHTTPSRewriteService) Edit(ctx context.Context, params SettingAutomaticHTTPSRewriteEditParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticHTTPSRewrites, err error) { +func (r *SettingAutomaticHTTPSRewriteService) Edit(ctx context.Context, params SettingAutomaticHTTPSRewriteEditParams, opts ...option.RequestOption) (res *AutomaticHTTPSRewrites, err error) { opts = append(r.Options[:], opts...) var env SettingAutomaticHTTPSRewriteEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/automatic_https_rewrites", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingAutomaticHTTPSRewriteService) Edit(ctx context.Context, params S } // Enable the Automatic HTTPS Rewrites feature for this zone. -func (r *SettingAutomaticHTTPSRewriteService) Get(ctx context.Context, query SettingAutomaticHTTPSRewriteGetParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticHTTPSRewrites, err error) { +func (r *SettingAutomaticHTTPSRewriteService) Get(ctx context.Context, query SettingAutomaticHTTPSRewriteGetParams, opts ...option.RequestOption) (res *AutomaticHTTPSRewrites, err error) { opts = append(r.Options[:], opts...) var env SettingAutomaticHTTPSRewriteGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/automatic_https_rewrites", query.ZoneID) @@ -59,22 +60,22 @@ func (r *SettingAutomaticHTTPSRewriteService) Get(ctx context.Context, query Set } // Enable the Automatic HTTPS Rewrites feature for this zone. -type ZoneSettingAutomaticHTTPSRewrites struct { +type AutomaticHTTPSRewrites struct { // ID of the zone setting. - ID ZoneSettingAutomaticHTTPSRewritesID `json:"id,required"` + ID AutomaticHTTPSRewritesID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingAutomaticHTTPSRewritesValue `json:"value,required"` + Value AutomaticHTTPSRewritesValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingAutomaticHTTPSRewritesEditable `json:"editable"` + Editable AutomaticHTTPSRewritesEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAutomaticHTTPSRewritesJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON automaticHTTPSRewritesJSON `json:"-"` } -// zoneSettingAutomaticHTTPSRewritesJSON contains the JSON metadata for the struct -// [ZoneSettingAutomaticHTTPSRewrites] -type zoneSettingAutomaticHTTPSRewritesJSON struct { +// automaticHTTPSRewritesJSON contains the JSON metadata for the struct +// [AutomaticHTTPSRewrites] +type automaticHTTPSRewritesJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,44 +84,40 @@ type zoneSettingAutomaticHTTPSRewritesJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingAutomaticHTTPSRewrites) UnmarshalJSON(data []byte) (err error) { +func (r *AutomaticHTTPSRewrites) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingAutomaticHTTPSRewritesJSON) RawJSON() string { +func (r automaticHTTPSRewritesJSON) RawJSON() string { return r.raw } -func (r ZoneSettingAutomaticHTTPSRewrites) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingAutomaticHTTPSRewrites) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingAutomaticHTTPSRewritesID string +type AutomaticHTTPSRewritesID string const ( - ZoneSettingAutomaticHTTPSRewritesIDAutomaticHTTPSRewrites ZoneSettingAutomaticHTTPSRewritesID = "automatic_https_rewrites" + AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites" ) -func (r ZoneSettingAutomaticHTTPSRewritesID) IsKnown() bool { +func (r AutomaticHTTPSRewritesID) IsKnown() bool { switch r { - case ZoneSettingAutomaticHTTPSRewritesIDAutomaticHTTPSRewrites: + case AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites: return true } return false } // Current value of the zone setting. -type ZoneSettingAutomaticHTTPSRewritesValue string +type AutomaticHTTPSRewritesValue string const ( - ZoneSettingAutomaticHTTPSRewritesValueOn ZoneSettingAutomaticHTTPSRewritesValue = "on" - ZoneSettingAutomaticHTTPSRewritesValueOff ZoneSettingAutomaticHTTPSRewritesValue = "off" + AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on" + AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off" ) -func (r ZoneSettingAutomaticHTTPSRewritesValue) IsKnown() bool { +func (r AutomaticHTTPSRewritesValue) IsKnown() bool { switch r { - case ZoneSettingAutomaticHTTPSRewritesValueOn, ZoneSettingAutomaticHTTPSRewritesValueOff: + case AutomaticHTTPSRewritesValueOn, AutomaticHTTPSRewritesValueOff: return true } return false @@ -128,35 +125,21 @@ func (r ZoneSettingAutomaticHTTPSRewritesValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingAutomaticHTTPSRewritesEditable bool +type AutomaticHTTPSRewritesEditable bool const ( - ZoneSettingAutomaticHTTPSRewritesEditableTrue ZoneSettingAutomaticHTTPSRewritesEditable = true - ZoneSettingAutomaticHTTPSRewritesEditableFalse ZoneSettingAutomaticHTTPSRewritesEditable = false + AutomaticHTTPSRewritesEditableTrue AutomaticHTTPSRewritesEditable = true + AutomaticHTTPSRewritesEditableFalse AutomaticHTTPSRewritesEditable = false ) -func (r ZoneSettingAutomaticHTTPSRewritesEditable) IsKnown() bool { +func (r AutomaticHTTPSRewritesEditable) IsKnown() bool { switch r { - case ZoneSettingAutomaticHTTPSRewritesEditableTrue, ZoneSettingAutomaticHTTPSRewritesEditableFalse: + case AutomaticHTTPSRewritesEditableTrue, AutomaticHTTPSRewritesEditableFalse: return true } return false } -// Enable the Automatic HTTPS Rewrites feature for this zone. -type ZoneSettingAutomaticHTTPSRewritesParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingAutomaticHTTPSRewritesID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingAutomaticHTTPSRewritesValue] `json:"value,required"` -} - -func (r ZoneSettingAutomaticHTTPSRewritesParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingAutomaticHTTPSRewritesParam) implementsZonesSettingEditParamsItem() {} - type SettingAutomaticHTTPSRewriteEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -187,12 +170,12 @@ func (r SettingAutomaticHTTPSRewriteEditParamsValue) IsKnown() bool { } type SettingAutomaticHTTPSRewriteEditResponseEnvelope struct { - Errors []SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable the Automatic HTTPS Rewrites feature for this zone. - Result ZoneSettingAutomaticHTTPSRewrites `json:"result"` + Result AutomaticHTTPSRewrites `json:"result"` JSON settingAutomaticHTTPSRewriteEditResponseEnvelopeJSON `json:"-"` } @@ -215,65 +198,18 @@ func (r settingAutomaticHTTPSRewriteEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors] -type settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages] -type settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingAutomaticHTTPSRewriteGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingAutomaticHTTPSRewriteGetResponseEnvelope struct { - Errors []SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable the Automatic HTTPS Rewrites feature for this zone. - Result ZoneSettingAutomaticHTTPSRewrites `json:"result"` + Result AutomaticHTTPSRewrites `json:"result"` JSON settingAutomaticHTTPSRewriteGetResponseEnvelopeJSON `json:"-"` } @@ -295,50 +231,3 @@ func (r *SettingAutomaticHTTPSRewriteGetResponseEnvelope) UnmarshalJSON(data []b func (r settingAutomaticHTTPSRewriteGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors] -type settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages] -type settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingautomaticplatformoptimization.go b/zones/settingautomaticplatformoptimization.go index f10df2d08af..035347ea1b7 100644 --- a/zones/settingautomaticplatformoptimization.go +++ b/zones/settingautomaticplatformoptimization.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingAutomaticPlatformOptimizationService(opts ...option.RequestOption // [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) // serves your WordPress site from Cloudflare's edge network and caches third-party // fonts. -func (r *SettingAutomaticPlatformOptimizationService) Edit(ctx context.Context, params SettingAutomaticPlatformOptimizationEditParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticPlatformOptimization, err error) { +func (r *SettingAutomaticPlatformOptimizationService) Edit(ctx context.Context, params SettingAutomaticPlatformOptimizationEditParams, opts ...option.RequestOption) (res *AutomaticPlatformOptimization, err error) { opts = append(r.Options[:], opts...) var env SettingAutomaticPlatformOptimizationEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/automatic_platform_optimization", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingAutomaticPlatformOptimizationService) Edit(ctx context.Context, // [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) // serves your WordPress site from Cloudflare's edge network and caches third-party // fonts. -func (r *SettingAutomaticPlatformOptimizationService) Get(ctx context.Context, query SettingAutomaticPlatformOptimizationGetParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticPlatformOptimization, err error) { +func (r *SettingAutomaticPlatformOptimizationService) Get(ctx context.Context, query SettingAutomaticPlatformOptimizationGetParams, opts ...option.RequestOption) (res *AutomaticPlatformOptimization, err error) { opts = append(r.Options[:], opts...) var env SettingAutomaticPlatformOptimizationGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/automatic_platform_optimization", query.ZoneID) @@ -62,7 +63,7 @@ func (r *SettingAutomaticPlatformOptimizationService) Get(ctx context.Context, q return } -type ZoneSettingAutomaticPlatformOptimization struct { +type AutomaticPlatformOptimization struct { // Indicates whether or not // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) // is enabled. @@ -79,13 +80,13 @@ type ZoneSettingAutomaticPlatformOptimization struct { // Indicates whether or not // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is // installed. - WpPlugin bool `json:"wp_plugin,required"` - JSON zoneSettingAutomaticPlatformOptimizationJSON `json:"-"` + WpPlugin bool `json:"wp_plugin,required"` + JSON automaticPlatformOptimizationJSON `json:"-"` } -// zoneSettingAutomaticPlatformOptimizationJSON contains the JSON metadata for the -// struct [ZoneSettingAutomaticPlatformOptimization] -type zoneSettingAutomaticPlatformOptimizationJSON struct { +// automaticPlatformOptimizationJSON contains the JSON metadata for the struct +// [AutomaticPlatformOptimization] +type automaticPlatformOptimizationJSON struct { CacheByDeviceType apijson.Field Cf apijson.Field Enabled apijson.Field @@ -96,15 +97,15 @@ type zoneSettingAutomaticPlatformOptimizationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { +func (r *AutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingAutomaticPlatformOptimizationJSON) RawJSON() string { +func (r automaticPlatformOptimizationJSON) RawJSON() string { return r.raw } -type ZoneSettingAutomaticPlatformOptimizationParam struct { +type AutomaticPlatformOptimizationParam struct { // Indicates whether or not // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) // is enabled. @@ -124,14 +125,14 @@ type ZoneSettingAutomaticPlatformOptimizationParam struct { WpPlugin param.Field[bool] `json:"wp_plugin,required"` } -func (r ZoneSettingAutomaticPlatformOptimizationParam) MarshalJSON() (data []byte, err error) { +func (r AutomaticPlatformOptimizationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type SettingAutomaticPlatformOptimizationEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Value param.Field[ZoneSettingAutomaticPlatformOptimizationParam] `json:"value,required"` + ZoneID param.Field[string] `path:"zone_id,required"` + Value param.Field[AutomaticPlatformOptimizationParam] `json:"value,required"` } func (r SettingAutomaticPlatformOptimizationEditParams) MarshalJSON() (data []byte, err error) { @@ -139,11 +140,11 @@ func (r SettingAutomaticPlatformOptimizationEditParams) MarshalJSON() (data []by } type SettingAutomaticPlatformOptimizationEditResponseEnvelope struct { - Errors []SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` - Result ZoneSettingAutomaticPlatformOptimization `json:"result"` + Result AutomaticPlatformOptimization `json:"result"` JSON settingAutomaticPlatformOptimizationEditResponseEnvelopeJSON `json:"-"` } @@ -167,65 +168,17 @@ func (r settingAutomaticPlatformOptimizationEditResponseEnvelopeJSON) RawJSON() return r.raw } -type SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors] -type settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages] -type settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingAutomaticPlatformOptimizationGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingAutomaticPlatformOptimizationGetResponseEnvelope struct { - Errors []SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` - Result ZoneSettingAutomaticPlatformOptimization `json:"result"` + Result AutomaticPlatformOptimization `json:"result"` JSON settingAutomaticPlatformOptimizationGetResponseEnvelopeJSON `json:"-"` } @@ -248,51 +201,3 @@ func (r *SettingAutomaticPlatformOptimizationGetResponseEnvelope) UnmarshalJSON( func (r settingAutomaticPlatformOptimizationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors] -type settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages] -type settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingautomaticplatformoptimization_test.go b/zones/settingautomaticplatformoptimization_test.go index adfed42c435..5613e836463 100644 --- a/zones/settingautomaticplatformoptimization_test.go +++ b/zones/settingautomaticplatformoptimization_test.go @@ -30,7 +30,7 @@ func TestSettingAutomaticPlatformOptimizationEdit(t *testing.T) { ) _, err := client.Zones.Settings.AutomaticPlatformOptimization.Edit(context.TODO(), zones.SettingAutomaticPlatformOptimizationEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingAutomaticPlatformOptimizationParam{ + Value: cloudflare.F(zones.AutomaticPlatformOptimizationParam{ CacheByDeviceType: cloudflare.F(false), Cf: cloudflare.F(true), Enabled: cloudflare.F(true), diff --git a/zones/settingbrotli.go b/zones/settingbrotli.go index 077e4a5a4c5..52d31f5accb 100644 --- a/zones/settingbrotli.go +++ b/zones/settingbrotli.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingBrotliService(opts ...option.RequestOption) (r *SettingBrotliServ // When the client requesting an asset supports the Brotli compression algorithm, // Cloudflare will serve a Brotli compressed version of the asset. -func (r *SettingBrotliService) Edit(ctx context.Context, params SettingBrotliEditParams, opts ...option.RequestOption) (res *ZoneSettingBrotli, err error) { +func (r *SettingBrotliService) Edit(ctx context.Context, params SettingBrotliEditParams, opts ...option.RequestOption) (res *Brotli, err error) { opts = append(r.Options[:], opts...) var env SettingBrotliEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/brotli", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingBrotliService) Edit(ctx context.Context, params SettingBrotliEdi // When the client requesting an asset supports the Brotli compression algorithm, // Cloudflare will serve a Brotli compressed version of the asset. -func (r *SettingBrotliService) Get(ctx context.Context, query SettingBrotliGetParams, opts ...option.RequestOption) (res *ZoneSettingBrotli, err error) { +func (r *SettingBrotliService) Get(ctx context.Context, query SettingBrotliGetParams, opts ...option.RequestOption) (res *Brotli, err error) { opts = append(r.Options[:], opts...) var env SettingBrotliGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/brotli", query.ZoneID) @@ -62,22 +63,21 @@ func (r *SettingBrotliService) Get(ctx context.Context, query SettingBrotliGetPa // When the client requesting an asset supports the Brotli compression algorithm, // Cloudflare will serve a Brotli compressed version of the asset. -type ZoneSettingBrotli struct { +type Brotli struct { // ID of the zone setting. - ID ZoneSettingBrotliID `json:"id,required"` + ID BrotliID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingBrotliValue `json:"value,required"` + Value BrotliValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingBrotliEditable `json:"editable"` + Editable BrotliEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrotliJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON brotliJSON `json:"-"` } -// zoneSettingBrotliJSON contains the JSON metadata for the struct -// [ZoneSettingBrotli] -type zoneSettingBrotliJSON struct { +// brotliJSON contains the JSON metadata for the struct [Brotli] +type brotliJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -86,44 +86,40 @@ type zoneSettingBrotliJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingBrotli) UnmarshalJSON(data []byte) (err error) { +func (r *Brotli) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingBrotliJSON) RawJSON() string { +func (r brotliJSON) RawJSON() string { return r.raw } -func (r ZoneSettingBrotli) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingBrotli) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingBrotliID string +type BrotliID string const ( - ZoneSettingBrotliIDBrotli ZoneSettingBrotliID = "brotli" + BrotliIDBrotli BrotliID = "brotli" ) -func (r ZoneSettingBrotliID) IsKnown() bool { +func (r BrotliID) IsKnown() bool { switch r { - case ZoneSettingBrotliIDBrotli: + case BrotliIDBrotli: return true } return false } // Current value of the zone setting. -type ZoneSettingBrotliValue string +type BrotliValue string const ( - ZoneSettingBrotliValueOff ZoneSettingBrotliValue = "off" - ZoneSettingBrotliValueOn ZoneSettingBrotliValue = "on" + BrotliValueOff BrotliValue = "off" + BrotliValueOn BrotliValue = "on" ) -func (r ZoneSettingBrotliValue) IsKnown() bool { +func (r BrotliValue) IsKnown() bool { switch r { - case ZoneSettingBrotliValueOff, ZoneSettingBrotliValueOn: + case BrotliValueOff, BrotliValueOn: return true } return false @@ -131,36 +127,21 @@ func (r ZoneSettingBrotliValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingBrotliEditable bool +type BrotliEditable bool const ( - ZoneSettingBrotliEditableTrue ZoneSettingBrotliEditable = true - ZoneSettingBrotliEditableFalse ZoneSettingBrotliEditable = false + BrotliEditableTrue BrotliEditable = true + BrotliEditableFalse BrotliEditable = false ) -func (r ZoneSettingBrotliEditable) IsKnown() bool { +func (r BrotliEditable) IsKnown() bool { switch r { - case ZoneSettingBrotliEditableTrue, ZoneSettingBrotliEditableFalse: + case BrotliEditableTrue, BrotliEditableFalse: return true } return false } -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -type ZoneSettingBrotliParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingBrotliID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingBrotliValue] `json:"value,required"` -} - -func (r ZoneSettingBrotliParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingBrotliParam) implementsZonesSettingEditParamsItem() {} - type SettingBrotliEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -189,13 +170,13 @@ func (r SettingBrotliEditParamsValue) IsKnown() bool { } type SettingBrotliEditResponseEnvelope struct { - Errors []SettingBrotliEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingBrotliEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When the client requesting an asset supports the Brotli compression algorithm, // Cloudflare will serve a Brotli compressed version of the asset. - Result ZoneSettingBrotli `json:"result"` + Result Brotli `json:"result"` JSON settingBrotliEditResponseEnvelopeJSON `json:"-"` } @@ -218,65 +199,19 @@ func (r settingBrotliEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingBrotliEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrotliEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingBrotliEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingBrotliEditResponseEnvelopeErrors] -type settingBrotliEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrotliEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrotliEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingBrotliEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrotliEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingBrotliEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingBrotliEditResponseEnvelopeMessages] -type settingBrotliEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrotliEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrotliEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingBrotliGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingBrotliGetResponseEnvelope struct { - Errors []SettingBrotliGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingBrotliGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When the client requesting an asset supports the Brotli compression algorithm, // Cloudflare will serve a Brotli compressed version of the asset. - Result ZoneSettingBrotli `json:"result"` + Result Brotli `json:"result"` JSON settingBrotliGetResponseEnvelopeJSON `json:"-"` } @@ -298,49 +233,3 @@ func (r *SettingBrotliGetResponseEnvelope) UnmarshalJSON(data []byte) (err error func (r settingBrotliGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingBrotliGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrotliGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingBrotliGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingBrotliGetResponseEnvelopeErrors] -type settingBrotliGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrotliGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrotliGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingBrotliGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrotliGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingBrotliGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingBrotliGetResponseEnvelopeMessages] -type settingBrotliGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrotliGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrotliGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingbrowsercachettl.go b/zones/settingbrowsercachettl.go index f129d66b012..b87bf1500c1 100644 --- a/zones/settingbrowsercachettl.go +++ b/zones/settingbrowsercachettl.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewSettingBrowserCacheTTLService(opts ...option.RequestOption) (r *SettingB // will remain on your visitors' computers. Cloudflare will honor any larger times // specified by your server. // (https://support.cloudflare.com/hc/en-us/articles/200168276). -func (r *SettingBrowserCacheTTLService) Edit(ctx context.Context, params SettingBrowserCacheTTLEditParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCacheTTL, err error) { +func (r *SettingBrowserCacheTTLService) Edit(ctx context.Context, params SettingBrowserCacheTTLEditParams, opts ...option.RequestOption) (res *BrowserCacheTTL, err error) { opts = append(r.Options[:], opts...) var env SettingBrowserCacheTTLEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/browser_cache_ttl", params.ZoneID) @@ -52,7 +53,7 @@ func (r *SettingBrowserCacheTTLService) Edit(ctx context.Context, params Setting // will remain on your visitors' computers. Cloudflare will honor any larger times // specified by your server. // (https://support.cloudflare.com/hc/en-us/articles/200168276). -func (r *SettingBrowserCacheTTLService) Get(ctx context.Context, query SettingBrowserCacheTTLGetParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCacheTTL, err error) { +func (r *SettingBrowserCacheTTLService) Get(ctx context.Context, query SettingBrowserCacheTTLGetParams, opts ...option.RequestOption) (res *BrowserCacheTTL, err error) { opts = append(r.Options[:], opts...) var env SettingBrowserCacheTTLGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/browser_cache_ttl", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingBrowserCacheTTLService) Get(ctx context.Context, query SettingBr // will remain on your visitors' computers. Cloudflare will honor any larger times // specified by your server. // (https://support.cloudflare.com/hc/en-us/articles/200168276). -type ZoneSettingBrowserCacheTTL struct { +type BrowserCacheTTL struct { // ID of the zone setting. - ID ZoneSettingBrowserCacheTTLID `json:"id,required"` + ID BrowserCacheTTLID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingBrowserCacheTTLValue `json:"value,required"` + Value BrowserCacheTTLValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingBrowserCacheTTLEditable `json:"editable"` + Editable BrowserCacheTTLEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrowserCacheTTLJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON browserCacheTTLJSON `json:"-"` } -// zoneSettingBrowserCacheTTLJSON contains the JSON metadata for the struct -// [ZoneSettingBrowserCacheTTL] -type zoneSettingBrowserCacheTTLJSON struct { +// browserCacheTTLJSON contains the JSON metadata for the struct [BrowserCacheTTL] +type browserCacheTTLJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,70 +92,66 @@ type zoneSettingBrowserCacheTTLJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingBrowserCacheTTL) UnmarshalJSON(data []byte) (err error) { +func (r *BrowserCacheTTL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingBrowserCacheTTLJSON) RawJSON() string { +func (r browserCacheTTLJSON) RawJSON() string { return r.raw } -func (r ZoneSettingBrowserCacheTTL) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingBrowserCacheTTL) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingBrowserCacheTTLID string +type BrowserCacheTTLID string const ( - ZoneSettingBrowserCacheTTLIDBrowserCacheTTL ZoneSettingBrowserCacheTTLID = "browser_cache_ttl" + BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl" ) -func (r ZoneSettingBrowserCacheTTLID) IsKnown() bool { +func (r BrowserCacheTTLID) IsKnown() bool { switch r { - case ZoneSettingBrowserCacheTTLIDBrowserCacheTTL: + case BrowserCacheTTLIDBrowserCacheTTL: return true } return false } // Current value of the zone setting. -type ZoneSettingBrowserCacheTTLValue float64 +type BrowserCacheTTLValue float64 const ( - ZoneSettingBrowserCacheTTLValue0 ZoneSettingBrowserCacheTTLValue = 0 - ZoneSettingBrowserCacheTTLValue30 ZoneSettingBrowserCacheTTLValue = 30 - ZoneSettingBrowserCacheTTLValue60 ZoneSettingBrowserCacheTTLValue = 60 - ZoneSettingBrowserCacheTTLValue120 ZoneSettingBrowserCacheTTLValue = 120 - ZoneSettingBrowserCacheTTLValue300 ZoneSettingBrowserCacheTTLValue = 300 - ZoneSettingBrowserCacheTTLValue1200 ZoneSettingBrowserCacheTTLValue = 1200 - ZoneSettingBrowserCacheTTLValue1800 ZoneSettingBrowserCacheTTLValue = 1800 - ZoneSettingBrowserCacheTTLValue3600 ZoneSettingBrowserCacheTTLValue = 3600 - ZoneSettingBrowserCacheTTLValue7200 ZoneSettingBrowserCacheTTLValue = 7200 - ZoneSettingBrowserCacheTTLValue10800 ZoneSettingBrowserCacheTTLValue = 10800 - ZoneSettingBrowserCacheTTLValue14400 ZoneSettingBrowserCacheTTLValue = 14400 - ZoneSettingBrowserCacheTTLValue18000 ZoneSettingBrowserCacheTTLValue = 18000 - ZoneSettingBrowserCacheTTLValue28800 ZoneSettingBrowserCacheTTLValue = 28800 - ZoneSettingBrowserCacheTTLValue43200 ZoneSettingBrowserCacheTTLValue = 43200 - ZoneSettingBrowserCacheTTLValue57600 ZoneSettingBrowserCacheTTLValue = 57600 - ZoneSettingBrowserCacheTTLValue72000 ZoneSettingBrowserCacheTTLValue = 72000 - ZoneSettingBrowserCacheTTLValue86400 ZoneSettingBrowserCacheTTLValue = 86400 - ZoneSettingBrowserCacheTTLValue172800 ZoneSettingBrowserCacheTTLValue = 172800 - ZoneSettingBrowserCacheTTLValue259200 ZoneSettingBrowserCacheTTLValue = 259200 - ZoneSettingBrowserCacheTTLValue345600 ZoneSettingBrowserCacheTTLValue = 345600 - ZoneSettingBrowserCacheTTLValue432000 ZoneSettingBrowserCacheTTLValue = 432000 - ZoneSettingBrowserCacheTTLValue691200 ZoneSettingBrowserCacheTTLValue = 691200 - ZoneSettingBrowserCacheTTLValue1382400 ZoneSettingBrowserCacheTTLValue = 1382400 - ZoneSettingBrowserCacheTTLValue2073600 ZoneSettingBrowserCacheTTLValue = 2073600 - ZoneSettingBrowserCacheTTLValue2678400 ZoneSettingBrowserCacheTTLValue = 2678400 - ZoneSettingBrowserCacheTTLValue5356800 ZoneSettingBrowserCacheTTLValue = 5356800 - ZoneSettingBrowserCacheTTLValue16070400 ZoneSettingBrowserCacheTTLValue = 16070400 - ZoneSettingBrowserCacheTTLValue31536000 ZoneSettingBrowserCacheTTLValue = 31536000 + BrowserCacheTTLValue0 BrowserCacheTTLValue = 0 + BrowserCacheTTLValue30 BrowserCacheTTLValue = 30 + BrowserCacheTTLValue60 BrowserCacheTTLValue = 60 + BrowserCacheTTLValue120 BrowserCacheTTLValue = 120 + BrowserCacheTTLValue300 BrowserCacheTTLValue = 300 + BrowserCacheTTLValue1200 BrowserCacheTTLValue = 1200 + BrowserCacheTTLValue1800 BrowserCacheTTLValue = 1800 + BrowserCacheTTLValue3600 BrowserCacheTTLValue = 3600 + BrowserCacheTTLValue7200 BrowserCacheTTLValue = 7200 + BrowserCacheTTLValue10800 BrowserCacheTTLValue = 10800 + BrowserCacheTTLValue14400 BrowserCacheTTLValue = 14400 + BrowserCacheTTLValue18000 BrowserCacheTTLValue = 18000 + BrowserCacheTTLValue28800 BrowserCacheTTLValue = 28800 + BrowserCacheTTLValue43200 BrowserCacheTTLValue = 43200 + BrowserCacheTTLValue57600 BrowserCacheTTLValue = 57600 + BrowserCacheTTLValue72000 BrowserCacheTTLValue = 72000 + BrowserCacheTTLValue86400 BrowserCacheTTLValue = 86400 + BrowserCacheTTLValue172800 BrowserCacheTTLValue = 172800 + BrowserCacheTTLValue259200 BrowserCacheTTLValue = 259200 + BrowserCacheTTLValue345600 BrowserCacheTTLValue = 345600 + BrowserCacheTTLValue432000 BrowserCacheTTLValue = 432000 + BrowserCacheTTLValue691200 BrowserCacheTTLValue = 691200 + BrowserCacheTTLValue1382400 BrowserCacheTTLValue = 1382400 + BrowserCacheTTLValue2073600 BrowserCacheTTLValue = 2073600 + BrowserCacheTTLValue2678400 BrowserCacheTTLValue = 2678400 + BrowserCacheTTLValue5356800 BrowserCacheTTLValue = 5356800 + BrowserCacheTTLValue16070400 BrowserCacheTTLValue = 16070400 + BrowserCacheTTLValue31536000 BrowserCacheTTLValue = 31536000 ) -func (r ZoneSettingBrowserCacheTTLValue) IsKnown() bool { +func (r BrowserCacheTTLValue) IsKnown() bool { switch r { - case ZoneSettingBrowserCacheTTLValue0, ZoneSettingBrowserCacheTTLValue30, ZoneSettingBrowserCacheTTLValue60, ZoneSettingBrowserCacheTTLValue120, ZoneSettingBrowserCacheTTLValue300, ZoneSettingBrowserCacheTTLValue1200, ZoneSettingBrowserCacheTTLValue1800, ZoneSettingBrowserCacheTTLValue3600, ZoneSettingBrowserCacheTTLValue7200, ZoneSettingBrowserCacheTTLValue10800, ZoneSettingBrowserCacheTTLValue14400, ZoneSettingBrowserCacheTTLValue18000, ZoneSettingBrowserCacheTTLValue28800, ZoneSettingBrowserCacheTTLValue43200, ZoneSettingBrowserCacheTTLValue57600, ZoneSettingBrowserCacheTTLValue72000, ZoneSettingBrowserCacheTTLValue86400, ZoneSettingBrowserCacheTTLValue172800, ZoneSettingBrowserCacheTTLValue259200, ZoneSettingBrowserCacheTTLValue345600, ZoneSettingBrowserCacheTTLValue432000, ZoneSettingBrowserCacheTTLValue691200, ZoneSettingBrowserCacheTTLValue1382400, ZoneSettingBrowserCacheTTLValue2073600, ZoneSettingBrowserCacheTTLValue2678400, ZoneSettingBrowserCacheTTLValue5356800, ZoneSettingBrowserCacheTTLValue16070400, ZoneSettingBrowserCacheTTLValue31536000: + case BrowserCacheTTLValue0, BrowserCacheTTLValue30, BrowserCacheTTLValue60, BrowserCacheTTLValue120, BrowserCacheTTLValue300, BrowserCacheTTLValue1200, BrowserCacheTTLValue1800, BrowserCacheTTLValue3600, BrowserCacheTTLValue7200, BrowserCacheTTLValue10800, BrowserCacheTTLValue14400, BrowserCacheTTLValue18000, BrowserCacheTTLValue28800, BrowserCacheTTLValue43200, BrowserCacheTTLValue57600, BrowserCacheTTLValue72000, BrowserCacheTTLValue86400, BrowserCacheTTLValue172800, BrowserCacheTTLValue259200, BrowserCacheTTLValue345600, BrowserCacheTTLValue432000, BrowserCacheTTLValue691200, BrowserCacheTTLValue1382400, BrowserCacheTTLValue2073600, BrowserCacheTTLValue2678400, BrowserCacheTTLValue5356800, BrowserCacheTTLValue16070400, BrowserCacheTTLValue31536000: return true } return false @@ -163,38 +159,21 @@ func (r ZoneSettingBrowserCacheTTLValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingBrowserCacheTTLEditable bool +type BrowserCacheTTLEditable bool const ( - ZoneSettingBrowserCacheTTLEditableTrue ZoneSettingBrowserCacheTTLEditable = true - ZoneSettingBrowserCacheTTLEditableFalse ZoneSettingBrowserCacheTTLEditable = false + BrowserCacheTTLEditableTrue BrowserCacheTTLEditable = true + BrowserCacheTTLEditableFalse BrowserCacheTTLEditable = false ) -func (r ZoneSettingBrowserCacheTTLEditable) IsKnown() bool { +func (r BrowserCacheTTLEditable) IsKnown() bool { switch r { - case ZoneSettingBrowserCacheTTLEditableTrue, ZoneSettingBrowserCacheTTLEditableFalse: + case BrowserCacheTTLEditableTrue, BrowserCacheTTLEditableFalse: return true } return false } -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -type ZoneSettingBrowserCacheTTLParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingBrowserCacheTTLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingBrowserCacheTTLValue] `json:"value,required"` -} - -func (r ZoneSettingBrowserCacheTTLParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingBrowserCacheTTLParam) implementsZonesSettingEditParamsItem() {} - type SettingBrowserCacheTTLEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -251,15 +230,15 @@ func (r SettingBrowserCacheTTLEditParamsValue) IsKnown() bool { } type SettingBrowserCacheTTLEditResponseEnvelope struct { - Errors []SettingBrowserCacheTTLEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingBrowserCacheTTLEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources // will remain on your visitors' computers. Cloudflare will honor any larger times // specified by your server. // (https://support.cloudflare.com/hc/en-us/articles/200168276). - Result ZoneSettingBrowserCacheTTL `json:"result"` + Result BrowserCacheTTL `json:"result"` JSON settingBrowserCacheTTLEditResponseEnvelopeJSON `json:"-"` } @@ -282,67 +261,21 @@ func (r settingBrowserCacheTTLEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingBrowserCacheTTLEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingBrowserCacheTTLEditResponseEnvelopeErrors] -type settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCacheTTLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingBrowserCacheTTLEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingBrowserCacheTTLEditResponseEnvelopeMessages] -type settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCacheTTLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingBrowserCacheTTLGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingBrowserCacheTTLGetResponseEnvelope struct { - Errors []SettingBrowserCacheTTLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingBrowserCacheTTLGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources // will remain on your visitors' computers. Cloudflare will honor any larger times // specified by your server. // (https://support.cloudflare.com/hc/en-us/articles/200168276). - Result ZoneSettingBrowserCacheTTL `json:"result"` + Result BrowserCacheTTL `json:"result"` JSON settingBrowserCacheTTLGetResponseEnvelopeJSON `json:"-"` } @@ -364,49 +297,3 @@ func (r *SettingBrowserCacheTTLGetResponseEnvelope) UnmarshalJSON(data []byte) ( func (r settingBrowserCacheTTLGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingBrowserCacheTTLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingBrowserCacheTTLGetResponseEnvelopeErrors] -type settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCacheTTLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingBrowserCacheTTLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingBrowserCacheTTLGetResponseEnvelopeMessages] -type settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCacheTTLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingbrowsercheck.go b/zones/settingbrowsercheck.go index 6aebafca6bf..da21bb032ca 100644 --- a/zones/settingbrowsercheck.go +++ b/zones/settingbrowsercheck.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -37,7 +38,7 @@ func NewSettingBrowserCheckService(opts ...option.RequestOption) (r *SettingBrow // also challenge visitors that do not have a user agent or a non standard user // agent (also commonly used by abuse bots, crawlers or visitors). // (https://support.cloudflare.com/hc/en-us/articles/200170086). -func (r *SettingBrowserCheckService) Edit(ctx context.Context, params SettingBrowserCheckEditParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCheck, err error) { +func (r *SettingBrowserCheckService) Edit(ctx context.Context, params SettingBrowserCheckEditParams, opts ...option.RequestOption) (res *BrowserCheck, err error) { opts = append(r.Options[:], opts...) var env SettingBrowserCheckEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/browser_check", params.ZoneID) @@ -54,7 +55,7 @@ func (r *SettingBrowserCheckService) Edit(ctx context.Context, params SettingBro // also challenge visitors that do not have a user agent or a non standard user // agent (also commonly used by abuse bots, crawlers or visitors). // (https://support.cloudflare.com/hc/en-us/articles/200170086). -func (r *SettingBrowserCheckService) Get(ctx context.Context, query SettingBrowserCheckGetParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCheck, err error) { +func (r *SettingBrowserCheckService) Get(ctx context.Context, query SettingBrowserCheckGetParams, opts ...option.RequestOption) (res *BrowserCheck, err error) { opts = append(r.Options[:], opts...) var env SettingBrowserCheckGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/browser_check", query.ZoneID) @@ -71,22 +72,21 @@ func (r *SettingBrowserCheckService) Get(ctx context.Context, query SettingBrows // also challenge visitors that do not have a user agent or a non standard user // agent (also commonly used by abuse bots, crawlers or visitors). // (https://support.cloudflare.com/hc/en-us/articles/200170086). -type ZoneSettingBrowserCheck struct { +type BrowserCheck struct { // ID of the zone setting. - ID ZoneSettingBrowserCheckID `json:"id,required"` + ID BrowserCheckID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingBrowserCheckValue `json:"value,required"` + Value BrowserCheckValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingBrowserCheckEditable `json:"editable"` + Editable BrowserCheckEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrowserCheckJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON browserCheckJSON `json:"-"` } -// zoneSettingBrowserCheckJSON contains the JSON metadata for the struct -// [ZoneSettingBrowserCheck] -type zoneSettingBrowserCheckJSON struct { +// browserCheckJSON contains the JSON metadata for the struct [BrowserCheck] +type browserCheckJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -95,44 +95,40 @@ type zoneSettingBrowserCheckJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingBrowserCheck) UnmarshalJSON(data []byte) (err error) { +func (r *BrowserCheck) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingBrowserCheckJSON) RawJSON() string { +func (r browserCheckJSON) RawJSON() string { return r.raw } -func (r ZoneSettingBrowserCheck) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingBrowserCheck) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingBrowserCheckID string +type BrowserCheckID string const ( - ZoneSettingBrowserCheckIDBrowserCheck ZoneSettingBrowserCheckID = "browser_check" + BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check" ) -func (r ZoneSettingBrowserCheckID) IsKnown() bool { +func (r BrowserCheckID) IsKnown() bool { switch r { - case ZoneSettingBrowserCheckIDBrowserCheck: + case BrowserCheckIDBrowserCheck: return true } return false } // Current value of the zone setting. -type ZoneSettingBrowserCheckValue string +type BrowserCheckValue string const ( - ZoneSettingBrowserCheckValueOn ZoneSettingBrowserCheckValue = "on" - ZoneSettingBrowserCheckValueOff ZoneSettingBrowserCheckValue = "off" + BrowserCheckValueOn BrowserCheckValue = "on" + BrowserCheckValueOff BrowserCheckValue = "off" ) -func (r ZoneSettingBrowserCheckValue) IsKnown() bool { +func (r BrowserCheckValue) IsKnown() bool { switch r { - case ZoneSettingBrowserCheckValueOn, ZoneSettingBrowserCheckValueOff: + case BrowserCheckValueOn, BrowserCheckValueOff: return true } return false @@ -140,39 +136,21 @@ func (r ZoneSettingBrowserCheckValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingBrowserCheckEditable bool +type BrowserCheckEditable bool const ( - ZoneSettingBrowserCheckEditableTrue ZoneSettingBrowserCheckEditable = true - ZoneSettingBrowserCheckEditableFalse ZoneSettingBrowserCheckEditable = false + BrowserCheckEditableTrue BrowserCheckEditable = true + BrowserCheckEditableFalse BrowserCheckEditable = false ) -func (r ZoneSettingBrowserCheckEditable) IsKnown() bool { +func (r BrowserCheckEditable) IsKnown() bool { switch r { - case ZoneSettingBrowserCheckEditableTrue, ZoneSettingBrowserCheckEditableFalse: + case BrowserCheckEditableTrue, BrowserCheckEditableFalse: return true } return false } -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -type ZoneSettingBrowserCheckParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingBrowserCheckID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingBrowserCheckValue] `json:"value,required"` -} - -func (r ZoneSettingBrowserCheckParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingBrowserCheckParam) implementsZonesSettingEditParamsItem() {} - type SettingBrowserCheckEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -201,8 +179,8 @@ func (r SettingBrowserCheckEditParamsValue) IsKnown() bool { } type SettingBrowserCheckEditResponseEnvelope struct { - Errors []SettingBrowserCheckEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingBrowserCheckEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Browser Integrity Check is similar to Bad Behavior and looks for common HTTP @@ -210,7 +188,7 @@ type SettingBrowserCheckEditResponseEnvelope struct { // also challenge visitors that do not have a user agent or a non standard user // agent (also commonly used by abuse bots, crawlers or visitors). // (https://support.cloudflare.com/hc/en-us/articles/200170086). - Result ZoneSettingBrowserCheck `json:"result"` + Result BrowserCheck `json:"result"` JSON settingBrowserCheckEditResponseEnvelopeJSON `json:"-"` } @@ -233,60 +211,14 @@ func (r settingBrowserCheckEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingBrowserCheckEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCheckEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingBrowserCheckEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingBrowserCheckEditResponseEnvelopeErrors] -type settingBrowserCheckEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCheckEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCheckEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingBrowserCheckEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCheckEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingBrowserCheckEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingBrowserCheckEditResponseEnvelopeMessages] -type settingBrowserCheckEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCheckEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCheckEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingBrowserCheckGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingBrowserCheckGetResponseEnvelope struct { - Errors []SettingBrowserCheckGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingBrowserCheckGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Browser Integrity Check is similar to Bad Behavior and looks for common HTTP @@ -294,7 +226,7 @@ type SettingBrowserCheckGetResponseEnvelope struct { // also challenge visitors that do not have a user agent or a non standard user // agent (also commonly used by abuse bots, crawlers or visitors). // (https://support.cloudflare.com/hc/en-us/articles/200170086). - Result ZoneSettingBrowserCheck `json:"result"` + Result BrowserCheck `json:"result"` JSON settingBrowserCheckGetResponseEnvelopeJSON `json:"-"` } @@ -316,49 +248,3 @@ func (r *SettingBrowserCheckGetResponseEnvelope) UnmarshalJSON(data []byte) (err func (r settingBrowserCheckGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingBrowserCheckGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCheckGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingBrowserCheckGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingBrowserCheckGetResponseEnvelopeErrors] -type settingBrowserCheckGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCheckGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCheckGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingBrowserCheckGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingBrowserCheckGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingBrowserCheckGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingBrowserCheckGetResponseEnvelopeMessages] -type settingBrowserCheckGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingBrowserCheckGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingBrowserCheckGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingcachelevel.go b/zones/settingcachelevel.go index 1b4a0be926c..67e74300d5d 100644 --- a/zones/settingcachelevel.go +++ b/zones/settingcachelevel.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -37,7 +38,7 @@ func NewSettingCacheLevelService(opts ...option.RequestOption) (r *SettingCacheL // setting will ignore the query string when delivering a cached resource. The // aggressive setting will cache all static resources, including ones with a query // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -func (r *SettingCacheLevelService) Edit(ctx context.Context, params SettingCacheLevelEditParams, opts ...option.RequestOption) (res *ZoneSettingCacheLevel, err error) { +func (r *SettingCacheLevelService) Edit(ctx context.Context, params SettingCacheLevelEditParams, opts ...option.RequestOption) (res *CacheLevel, err error) { opts = append(r.Options[:], opts...) var env SettingCacheLevelEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/cache_level", params.ZoneID) @@ -54,7 +55,7 @@ func (r *SettingCacheLevelService) Edit(ctx context.Context, params SettingCache // setting will ignore the query string when delivering a cached resource. The // aggressive setting will cache all static resources, including ones with a query // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -func (r *SettingCacheLevelService) Get(ctx context.Context, query SettingCacheLevelGetParams, opts ...option.RequestOption) (res *ZoneSettingCacheLevel, err error) { +func (r *SettingCacheLevelService) Get(ctx context.Context, query SettingCacheLevelGetParams, opts ...option.RequestOption) (res *CacheLevel, err error) { opts = append(r.Options[:], opts...) var env SettingCacheLevelGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/cache_level", query.ZoneID) @@ -71,22 +72,21 @@ func (r *SettingCacheLevelService) Get(ctx context.Context, query SettingCacheLe // setting will ignore the query string when delivering a cached resource. The // aggressive setting will cache all static resources, including ones with a query // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -type ZoneSettingCacheLevel struct { +type CacheLevel struct { // ID of the zone setting. - ID ZoneSettingCacheLevelID `json:"id,required"` + ID CacheLevelID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingCacheLevelValue `json:"value,required"` + Value CacheLevelValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingCacheLevelEditable `json:"editable"` + Editable CacheLevelEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingCacheLevelJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON cacheLevelJSON `json:"-"` } -// zoneSettingCacheLevelJSON contains the JSON metadata for the struct -// [ZoneSettingCacheLevel] -type zoneSettingCacheLevelJSON struct { +// cacheLevelJSON contains the JSON metadata for the struct [CacheLevel] +type cacheLevelJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -95,45 +95,41 @@ type zoneSettingCacheLevelJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingCacheLevel) UnmarshalJSON(data []byte) (err error) { +func (r *CacheLevel) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingCacheLevelJSON) RawJSON() string { +func (r cacheLevelJSON) RawJSON() string { return r.raw } -func (r ZoneSettingCacheLevel) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingCacheLevel) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingCacheLevelID string +type CacheLevelID string const ( - ZoneSettingCacheLevelIDCacheLevel ZoneSettingCacheLevelID = "cache_level" + CacheLevelIDCacheLevel CacheLevelID = "cache_level" ) -func (r ZoneSettingCacheLevelID) IsKnown() bool { +func (r CacheLevelID) IsKnown() bool { switch r { - case ZoneSettingCacheLevelIDCacheLevel: + case CacheLevelIDCacheLevel: return true } return false } // Current value of the zone setting. -type ZoneSettingCacheLevelValue string +type CacheLevelValue string const ( - ZoneSettingCacheLevelValueAggressive ZoneSettingCacheLevelValue = "aggressive" - ZoneSettingCacheLevelValueBasic ZoneSettingCacheLevelValue = "basic" - ZoneSettingCacheLevelValueSimplified ZoneSettingCacheLevelValue = "simplified" + CacheLevelValueAggressive CacheLevelValue = "aggressive" + CacheLevelValueBasic CacheLevelValue = "basic" + CacheLevelValueSimplified CacheLevelValue = "simplified" ) -func (r ZoneSettingCacheLevelValue) IsKnown() bool { +func (r CacheLevelValue) IsKnown() bool { switch r { - case ZoneSettingCacheLevelValueAggressive, ZoneSettingCacheLevelValueBasic, ZoneSettingCacheLevelValueSimplified: + case CacheLevelValueAggressive, CacheLevelValueBasic, CacheLevelValueSimplified: return true } return false @@ -141,39 +137,21 @@ func (r ZoneSettingCacheLevelValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingCacheLevelEditable bool +type CacheLevelEditable bool const ( - ZoneSettingCacheLevelEditableTrue ZoneSettingCacheLevelEditable = true - ZoneSettingCacheLevelEditableFalse ZoneSettingCacheLevelEditable = false + CacheLevelEditableTrue CacheLevelEditable = true + CacheLevelEditableFalse CacheLevelEditable = false ) -func (r ZoneSettingCacheLevelEditable) IsKnown() bool { +func (r CacheLevelEditable) IsKnown() bool { switch r { - case ZoneSettingCacheLevelEditableTrue, ZoneSettingCacheLevelEditableFalse: + case CacheLevelEditableTrue, CacheLevelEditableFalse: return true } return false } -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -type ZoneSettingCacheLevelParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingCacheLevelID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingCacheLevelValue] `json:"value,required"` -} - -func (r ZoneSettingCacheLevelParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingCacheLevelParam) implementsZonesSettingEditParamsItem() {} - type SettingCacheLevelEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -203,8 +181,8 @@ func (r SettingCacheLevelEditParamsValue) IsKnown() bool { } type SettingCacheLevelEditResponseEnvelope struct { - Errors []SettingCacheLevelEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingCacheLevelEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cache Level functions based off the setting level. The basic setting will cache @@ -212,7 +190,7 @@ type SettingCacheLevelEditResponseEnvelope struct { // setting will ignore the query string when delivering a cached resource. The // aggressive setting will cache all static resources, including ones with a query // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). - Result ZoneSettingCacheLevel `json:"result"` + Result CacheLevel `json:"result"` JSON settingCacheLevelEditResponseEnvelopeJSON `json:"-"` } @@ -235,60 +213,14 @@ func (r settingCacheLevelEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingCacheLevelEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCacheLevelEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingCacheLevelEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingCacheLevelEditResponseEnvelopeErrors] -type settingCacheLevelEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCacheLevelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCacheLevelEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingCacheLevelEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCacheLevelEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingCacheLevelEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingCacheLevelEditResponseEnvelopeMessages] -type settingCacheLevelEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCacheLevelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCacheLevelEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingCacheLevelGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingCacheLevelGetResponseEnvelope struct { - Errors []SettingCacheLevelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingCacheLevelGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cache Level functions based off the setting level. The basic setting will cache @@ -296,7 +228,7 @@ type SettingCacheLevelGetResponseEnvelope struct { // setting will ignore the query string when delivering a cached resource. The // aggressive setting will cache all static resources, including ones with a query // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). - Result ZoneSettingCacheLevel `json:"result"` + Result CacheLevel `json:"result"` JSON settingCacheLevelGetResponseEnvelopeJSON `json:"-"` } @@ -318,49 +250,3 @@ func (r *SettingCacheLevelGetResponseEnvelope) UnmarshalJSON(data []byte) (err e func (r settingCacheLevelGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingCacheLevelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCacheLevelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingCacheLevelGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingCacheLevelGetResponseEnvelopeErrors] -type settingCacheLevelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCacheLevelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCacheLevelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingCacheLevelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCacheLevelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingCacheLevelGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingCacheLevelGetResponseEnvelopeMessages] -type settingCacheLevelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCacheLevelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCacheLevelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingchallengettl.go b/zones/settingchallengettl.go index 23055fc5afb..c8c0da23cbb 100644 --- a/zones/settingchallengettl.go +++ b/zones/settingchallengettl.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -37,7 +38,7 @@ func NewSettingChallengeTTLService(opts ...option.RequestOption) (r *SettingChal // visitor will have to complete a new challenge. We recommend a 15 - 45 minute // setting and will attempt to honor any setting above 45 minutes. // (https://support.cloudflare.com/hc/en-us/articles/200170136). -func (r *SettingChallengeTTLService) Edit(ctx context.Context, params SettingChallengeTTLEditParams, opts ...option.RequestOption) (res *ZoneSettingChallengeTTL, err error) { +func (r *SettingChallengeTTLService) Edit(ctx context.Context, params SettingChallengeTTLEditParams, opts ...option.RequestOption) (res *ChallengeTTL, err error) { opts = append(r.Options[:], opts...) var env SettingChallengeTTLEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/challenge_ttl", params.ZoneID) @@ -54,7 +55,7 @@ func (r *SettingChallengeTTLService) Edit(ctx context.Context, params SettingCha // visitor will have to complete a new challenge. We recommend a 15 - 45 minute // setting and will attempt to honor any setting above 45 minutes. // (https://support.cloudflare.com/hc/en-us/articles/200170136). -func (r *SettingChallengeTTLService) Get(ctx context.Context, query SettingChallengeTTLGetParams, opts ...option.RequestOption) (res *ZoneSettingChallengeTTL, err error) { +func (r *SettingChallengeTTLService) Get(ctx context.Context, query SettingChallengeTTLGetParams, opts ...option.RequestOption) (res *ChallengeTTL, err error) { opts = append(r.Options[:], opts...) var env SettingChallengeTTLGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/challenge_ttl", query.ZoneID) @@ -71,22 +72,21 @@ func (r *SettingChallengeTTLService) Get(ctx context.Context, query SettingChall // visitor will have to complete a new challenge. We recommend a 15 - 45 minute // setting and will attempt to honor any setting above 45 minutes. // (https://support.cloudflare.com/hc/en-us/articles/200170136). -type ZoneSettingChallengeTTL struct { +type ChallengeTTL struct { // ID of the zone setting. - ID ZoneSettingChallengeTTLID `json:"id,required"` + ID ChallengeTTLID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingChallengeTTLValue `json:"value,required"` + Value ChallengeTTLValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingChallengeTTLEditable `json:"editable"` + Editable ChallengeTTLEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingChallengeTTLJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON challengeTTLJSON `json:"-"` } -// zoneSettingChallengeTTLJSON contains the JSON metadata for the struct -// [ZoneSettingChallengeTTL] -type zoneSettingChallengeTTLJSON struct { +// challengeTTLJSON contains the JSON metadata for the struct [ChallengeTTL] +type challengeTTLJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -95,56 +95,52 @@ type zoneSettingChallengeTTLJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingChallengeTTL) UnmarshalJSON(data []byte) (err error) { +func (r *ChallengeTTL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingChallengeTTLJSON) RawJSON() string { +func (r challengeTTLJSON) RawJSON() string { return r.raw } -func (r ZoneSettingChallengeTTL) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingChallengeTTL) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingChallengeTTLID string +type ChallengeTTLID string const ( - ZoneSettingChallengeTTLIDChallengeTTL ZoneSettingChallengeTTLID = "challenge_ttl" + ChallengeTTLIDChallengeTTL ChallengeTTLID = "challenge_ttl" ) -func (r ZoneSettingChallengeTTLID) IsKnown() bool { +func (r ChallengeTTLID) IsKnown() bool { switch r { - case ZoneSettingChallengeTTLIDChallengeTTL: + case ChallengeTTLIDChallengeTTL: return true } return false } // Current value of the zone setting. -type ZoneSettingChallengeTTLValue float64 +type ChallengeTTLValue float64 const ( - ZoneSettingChallengeTTLValue300 ZoneSettingChallengeTTLValue = 300 - ZoneSettingChallengeTTLValue900 ZoneSettingChallengeTTLValue = 900 - ZoneSettingChallengeTTLValue1800 ZoneSettingChallengeTTLValue = 1800 - ZoneSettingChallengeTTLValue2700 ZoneSettingChallengeTTLValue = 2700 - ZoneSettingChallengeTTLValue3600 ZoneSettingChallengeTTLValue = 3600 - ZoneSettingChallengeTTLValue7200 ZoneSettingChallengeTTLValue = 7200 - ZoneSettingChallengeTTLValue10800 ZoneSettingChallengeTTLValue = 10800 - ZoneSettingChallengeTTLValue14400 ZoneSettingChallengeTTLValue = 14400 - ZoneSettingChallengeTTLValue28800 ZoneSettingChallengeTTLValue = 28800 - ZoneSettingChallengeTTLValue57600 ZoneSettingChallengeTTLValue = 57600 - ZoneSettingChallengeTTLValue86400 ZoneSettingChallengeTTLValue = 86400 - ZoneSettingChallengeTTLValue604800 ZoneSettingChallengeTTLValue = 604800 - ZoneSettingChallengeTTLValue2592000 ZoneSettingChallengeTTLValue = 2592000 - ZoneSettingChallengeTTLValue31536000 ZoneSettingChallengeTTLValue = 31536000 + ChallengeTTLValue300 ChallengeTTLValue = 300 + ChallengeTTLValue900 ChallengeTTLValue = 900 + ChallengeTTLValue1800 ChallengeTTLValue = 1800 + ChallengeTTLValue2700 ChallengeTTLValue = 2700 + ChallengeTTLValue3600 ChallengeTTLValue = 3600 + ChallengeTTLValue7200 ChallengeTTLValue = 7200 + ChallengeTTLValue10800 ChallengeTTLValue = 10800 + ChallengeTTLValue14400 ChallengeTTLValue = 14400 + ChallengeTTLValue28800 ChallengeTTLValue = 28800 + ChallengeTTLValue57600 ChallengeTTLValue = 57600 + ChallengeTTLValue86400 ChallengeTTLValue = 86400 + ChallengeTTLValue604800 ChallengeTTLValue = 604800 + ChallengeTTLValue2592000 ChallengeTTLValue = 2592000 + ChallengeTTLValue31536000 ChallengeTTLValue = 31536000 ) -func (r ZoneSettingChallengeTTLValue) IsKnown() bool { +func (r ChallengeTTLValue) IsKnown() bool { switch r { - case ZoneSettingChallengeTTLValue300, ZoneSettingChallengeTTLValue900, ZoneSettingChallengeTTLValue1800, ZoneSettingChallengeTTLValue2700, ZoneSettingChallengeTTLValue3600, ZoneSettingChallengeTTLValue7200, ZoneSettingChallengeTTLValue10800, ZoneSettingChallengeTTLValue14400, ZoneSettingChallengeTTLValue28800, ZoneSettingChallengeTTLValue57600, ZoneSettingChallengeTTLValue86400, ZoneSettingChallengeTTLValue604800, ZoneSettingChallengeTTLValue2592000, ZoneSettingChallengeTTLValue31536000: + case ChallengeTTLValue300, ChallengeTTLValue900, ChallengeTTLValue1800, ChallengeTTLValue2700, ChallengeTTLValue3600, ChallengeTTLValue7200, ChallengeTTLValue10800, ChallengeTTLValue14400, ChallengeTTLValue28800, ChallengeTTLValue57600, ChallengeTTLValue86400, ChallengeTTLValue604800, ChallengeTTLValue2592000, ChallengeTTLValue31536000: return true } return false @@ -152,39 +148,21 @@ func (r ZoneSettingChallengeTTLValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingChallengeTTLEditable bool +type ChallengeTTLEditable bool const ( - ZoneSettingChallengeTTLEditableTrue ZoneSettingChallengeTTLEditable = true - ZoneSettingChallengeTTLEditableFalse ZoneSettingChallengeTTLEditable = false + ChallengeTTLEditableTrue ChallengeTTLEditable = true + ChallengeTTLEditableFalse ChallengeTTLEditable = false ) -func (r ZoneSettingChallengeTTLEditable) IsKnown() bool { +func (r ChallengeTTLEditable) IsKnown() bool { switch r { - case ZoneSettingChallengeTTLEditableTrue, ZoneSettingChallengeTTLEditableFalse: + case ChallengeTTLEditableTrue, ChallengeTTLEditableFalse: return true } return false } -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -type ZoneSettingChallengeTTLParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingChallengeTTLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingChallengeTTLValue] `json:"value,required"` -} - -func (r ZoneSettingChallengeTTLParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingChallengeTTLParam) implementsZonesSettingEditParamsItem() {} - type SettingChallengeTTLEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -225,8 +203,8 @@ func (r SettingChallengeTTLEditParamsValue) IsKnown() bool { } type SettingChallengeTTLEditResponseEnvelope struct { - Errors []SettingChallengeTTLEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingChallengeTTLEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Specify how long a visitor is allowed access to your site after successfully @@ -234,7 +212,7 @@ type SettingChallengeTTLEditResponseEnvelope struct { // visitor will have to complete a new challenge. We recommend a 15 - 45 minute // setting and will attempt to honor any setting above 45 minutes. // (https://support.cloudflare.com/hc/en-us/articles/200170136). - Result ZoneSettingChallengeTTL `json:"result"` + Result ChallengeTTL `json:"result"` JSON settingChallengeTTLEditResponseEnvelopeJSON `json:"-"` } @@ -257,60 +235,14 @@ func (r settingChallengeTTLEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingChallengeTTLEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingChallengeTTLEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingChallengeTTLEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingChallengeTTLEditResponseEnvelopeErrors] -type settingChallengeTTLEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingChallengeTTLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingChallengeTTLEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingChallengeTTLEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingChallengeTTLEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingChallengeTTLEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingChallengeTTLEditResponseEnvelopeMessages] -type settingChallengeTTLEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingChallengeTTLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingChallengeTTLEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingChallengeTTLGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingChallengeTTLGetResponseEnvelope struct { - Errors []SettingChallengeTTLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingChallengeTTLGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Specify how long a visitor is allowed access to your site after successfully @@ -318,7 +250,7 @@ type SettingChallengeTTLGetResponseEnvelope struct { // visitor will have to complete a new challenge. We recommend a 15 - 45 minute // setting and will attempt to honor any setting above 45 minutes. // (https://support.cloudflare.com/hc/en-us/articles/200170136). - Result ZoneSettingChallengeTTL `json:"result"` + Result ChallengeTTL `json:"result"` JSON settingChallengeTTLGetResponseEnvelopeJSON `json:"-"` } @@ -340,49 +272,3 @@ func (r *SettingChallengeTTLGetResponseEnvelope) UnmarshalJSON(data []byte) (err func (r settingChallengeTTLGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingChallengeTTLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingChallengeTTLGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingChallengeTTLGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingChallengeTTLGetResponseEnvelopeErrors] -type settingChallengeTTLGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingChallengeTTLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingChallengeTTLGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingChallengeTTLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingChallengeTTLGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingChallengeTTLGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingChallengeTTLGetResponseEnvelopeMessages] -type settingChallengeTTLGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingChallengeTTLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingChallengeTTLGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingcipher.go b/zones/settingcipher.go index fa1e113dc07..bf82b30ea00 100644 --- a/zones/settingcipher.go +++ b/zones/settingcipher.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingCipherService(opts ...option.RequestOption) (r *SettingCipherServ } // Changes ciphers setting. -func (r *SettingCipherService) Edit(ctx context.Context, params SettingCipherEditParams, opts ...option.RequestOption) (res *ZoneSettingCiphers, err error) { +func (r *SettingCipherService) Edit(ctx context.Context, params SettingCipherEditParams, opts ...option.RequestOption) (res *Ciphers, err error) { opts = append(r.Options[:], opts...) var env SettingCipherEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ciphers", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingCipherService) Edit(ctx context.Context, params SettingCipherEdi } // Gets ciphers setting. -func (r *SettingCipherService) Get(ctx context.Context, query SettingCipherGetParams, opts ...option.RequestOption) (res *ZoneSettingCiphers, err error) { +func (r *SettingCipherService) Get(ctx context.Context, query SettingCipherGetParams, opts ...option.RequestOption) (res *Ciphers, err error) { opts = append(r.Options[:], opts...) var env SettingCipherGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ciphers", query.ZoneID) @@ -60,22 +61,21 @@ func (r *SettingCipherService) Get(ctx context.Context, query SettingCipherGetPa // An allowlist of ciphers for TLS termination. These ciphers must be in the // BoringSSL format. -type ZoneSettingCiphers struct { +type Ciphers struct { // ID of the zone setting. - ID ZoneSettingCiphersID `json:"id,required"` + ID CiphersID `json:"id,required"` // Current value of the zone setting. Value []string `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingCiphersEditable `json:"editable"` + Editable CiphersEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingCiphersJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON ciphersJSON `json:"-"` } -// zoneSettingCiphersJSON contains the JSON metadata for the struct -// [ZoneSettingCiphers] -type zoneSettingCiphersJSON struct { +// ciphersJSON contains the JSON metadata for the struct [Ciphers] +type ciphersJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -84,28 +84,24 @@ type zoneSettingCiphersJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingCiphers) UnmarshalJSON(data []byte) (err error) { +func (r *Ciphers) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingCiphersJSON) RawJSON() string { +func (r ciphersJSON) RawJSON() string { return r.raw } -func (r ZoneSettingCiphers) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingCiphers) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingCiphersID string +type CiphersID string const ( - ZoneSettingCiphersIDCiphers ZoneSettingCiphersID = "ciphers" + CiphersIDCiphers CiphersID = "ciphers" ) -func (r ZoneSettingCiphersID) IsKnown() bool { +func (r CiphersID) IsKnown() bool { switch r { - case ZoneSettingCiphersIDCiphers: + case CiphersIDCiphers: return true } return false @@ -113,36 +109,21 @@ func (r ZoneSettingCiphersID) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingCiphersEditable bool +type CiphersEditable bool const ( - ZoneSettingCiphersEditableTrue ZoneSettingCiphersEditable = true - ZoneSettingCiphersEditableFalse ZoneSettingCiphersEditable = false + CiphersEditableTrue CiphersEditable = true + CiphersEditableFalse CiphersEditable = false ) -func (r ZoneSettingCiphersEditable) IsKnown() bool { +func (r CiphersEditable) IsKnown() bool { switch r { - case ZoneSettingCiphersEditableTrue, ZoneSettingCiphersEditableFalse: + case CiphersEditableTrue, CiphersEditableFalse: return true } return false } -// An allowlist of ciphers for TLS termination. These ciphers must be in the -// BoringSSL format. -type ZoneSettingCiphersParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingCiphersID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[[]string] `json:"value,required"` -} - -func (r ZoneSettingCiphersParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingCiphersParam) implementsZonesSettingEditParamsItem() {} - type SettingCipherEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -155,13 +136,13 @@ func (r SettingCipherEditParams) MarshalJSON() (data []byte, err error) { } type SettingCipherEditResponseEnvelope struct { - Errors []SettingCipherEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingCipherEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // An allowlist of ciphers for TLS termination. These ciphers must be in the // BoringSSL format. - Result ZoneSettingCiphers `json:"result"` + Result Ciphers `json:"result"` JSON settingCipherEditResponseEnvelopeJSON `json:"-"` } @@ -184,65 +165,19 @@ func (r settingCipherEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingCipherEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCipherEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingCipherEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingCipherEditResponseEnvelopeErrors] -type settingCipherEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCipherEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCipherEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingCipherEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCipherEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingCipherEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingCipherEditResponseEnvelopeMessages] -type settingCipherEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCipherEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCipherEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingCipherGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingCipherGetResponseEnvelope struct { - Errors []SettingCipherGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingCipherGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // An allowlist of ciphers for TLS termination. These ciphers must be in the // BoringSSL format. - Result ZoneSettingCiphers `json:"result"` + Result Ciphers `json:"result"` JSON settingCipherGetResponseEnvelopeJSON `json:"-"` } @@ -264,49 +199,3 @@ func (r *SettingCipherGetResponseEnvelope) UnmarshalJSON(data []byte) (err error func (r settingCipherGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingCipherGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCipherGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingCipherGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingCipherGetResponseEnvelopeErrors] -type settingCipherGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCipherGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCipherGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingCipherGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingCipherGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingCipherGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingCipherGetResponseEnvelopeMessages] -type settingCipherGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingCipherGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingCipherGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingdevelopmentmode.go b/zones/settingdevelopmentmode.go index 3bcdd3e55c0..06cabcd39dd 100644 --- a/zones/settingdevelopmentmode.go +++ b/zones/settingdevelopmentmode.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -38,7 +39,7 @@ func NewSettingDevelopmentModeService(opts ...option.RequestOption) (r *SettingD // changes to cacheable content (like images, css, or JavaScript) and would like to // see those changes right away. Once entered, development mode will last for 3 // hours and then automatically toggle off. -func (r *SettingDevelopmentModeService) Edit(ctx context.Context, params SettingDevelopmentModeEditParams, opts ...option.RequestOption) (res *ZoneSettingDevelopmentMode, err error) { +func (r *SettingDevelopmentModeService) Edit(ctx context.Context, params SettingDevelopmentModeEditParams, opts ...option.RequestOption) (res *DevelopmentMode, err error) { opts = append(r.Options[:], opts...) var env SettingDevelopmentModeEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/development_mode", params.ZoneID) @@ -56,7 +57,7 @@ func (r *SettingDevelopmentModeService) Edit(ctx context.Context, params Setting // changes to cacheable content (like images, css, or JavaScript) and would like to // see those changes right away. Once entered, development mode will last for 3 // hours and then automatically toggle off. -func (r *SettingDevelopmentModeService) Get(ctx context.Context, query SettingDevelopmentModeGetParams, opts ...option.RequestOption) (res *ZoneSettingDevelopmentMode, err error) { +func (r *SettingDevelopmentModeService) Get(ctx context.Context, query SettingDevelopmentModeGetParams, opts ...option.RequestOption) (res *DevelopmentMode, err error) { opts = append(r.Options[:], opts...) var env SettingDevelopmentModeGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/development_mode", query.ZoneID) @@ -74,26 +75,25 @@ func (r *SettingDevelopmentModeService) Get(ctx context.Context, query SettingDe // changes to cacheable content (like images, css, or JavaScript) and would like to // see those changes right away. Once entered, development mode will last for 3 // hours and then automatically toggle off. -type ZoneSettingDevelopmentMode struct { +type DevelopmentMode struct { // ID of the zone setting. - ID ZoneSettingDevelopmentModeID `json:"id,required"` + ID DevelopmentModeID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingDevelopmentModeValue `json:"value,required"` + Value DevelopmentModeValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingDevelopmentModeEditable `json:"editable"` + Editable DevelopmentModeEditable `json:"editable"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` // Value of the zone setting. Notes: The interval (in seconds) from when // development mode expires (positive integer) or last expired (negative integer) // for the domain. If development mode has never been enabled, this value is false. - TimeRemaining float64 `json:"time_remaining"` - JSON zoneSettingDevelopmentModeJSON `json:"-"` + TimeRemaining float64 `json:"time_remaining"` + JSON developmentModeJSON `json:"-"` } -// zoneSettingDevelopmentModeJSON contains the JSON metadata for the struct -// [ZoneSettingDevelopmentMode] -type zoneSettingDevelopmentModeJSON struct { +// developmentModeJSON contains the JSON metadata for the struct [DevelopmentMode] +type developmentModeJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -103,44 +103,40 @@ type zoneSettingDevelopmentModeJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingDevelopmentMode) UnmarshalJSON(data []byte) (err error) { +func (r *DevelopmentMode) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingDevelopmentModeJSON) RawJSON() string { +func (r developmentModeJSON) RawJSON() string { return r.raw } -func (r ZoneSettingDevelopmentMode) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingDevelopmentMode) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingDevelopmentModeID string +type DevelopmentModeID string const ( - ZoneSettingDevelopmentModeIDDevelopmentMode ZoneSettingDevelopmentModeID = "development_mode" + DevelopmentModeIDDevelopmentMode DevelopmentModeID = "development_mode" ) -func (r ZoneSettingDevelopmentModeID) IsKnown() bool { +func (r DevelopmentModeID) IsKnown() bool { switch r { - case ZoneSettingDevelopmentModeIDDevelopmentMode: + case DevelopmentModeIDDevelopmentMode: return true } return false } // Current value of the zone setting. -type ZoneSettingDevelopmentModeValue string +type DevelopmentModeValue string const ( - ZoneSettingDevelopmentModeValueOn ZoneSettingDevelopmentModeValue = "on" - ZoneSettingDevelopmentModeValueOff ZoneSettingDevelopmentModeValue = "off" + DevelopmentModeValueOn DevelopmentModeValue = "on" + DevelopmentModeValueOff DevelopmentModeValue = "off" ) -func (r ZoneSettingDevelopmentModeValue) IsKnown() bool { +func (r DevelopmentModeValue) IsKnown() bool { switch r { - case ZoneSettingDevelopmentModeValueOn, ZoneSettingDevelopmentModeValueOff: + case DevelopmentModeValueOn, DevelopmentModeValueOff: return true } return false @@ -148,40 +144,21 @@ func (r ZoneSettingDevelopmentModeValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingDevelopmentModeEditable bool +type DevelopmentModeEditable bool const ( - ZoneSettingDevelopmentModeEditableTrue ZoneSettingDevelopmentModeEditable = true - ZoneSettingDevelopmentModeEditableFalse ZoneSettingDevelopmentModeEditable = false + DevelopmentModeEditableTrue DevelopmentModeEditable = true + DevelopmentModeEditableFalse DevelopmentModeEditable = false ) -func (r ZoneSettingDevelopmentModeEditable) IsKnown() bool { +func (r DevelopmentModeEditable) IsKnown() bool { switch r { - case ZoneSettingDevelopmentModeEditableTrue, ZoneSettingDevelopmentModeEditableFalse: + case DevelopmentModeEditableTrue, DevelopmentModeEditableFalse: return true } return false } -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -type ZoneSettingDevelopmentModeParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingDevelopmentModeID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingDevelopmentModeValue] `json:"value,required"` -} - -func (r ZoneSettingDevelopmentModeParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingDevelopmentModeParam) implementsZonesSettingEditParamsItem() {} - type SettingDevelopmentModeEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -210,8 +187,8 @@ func (r SettingDevelopmentModeEditParamsValue) IsKnown() bool { } type SettingDevelopmentModeEditResponseEnvelope struct { - Errors []SettingDevelopmentModeEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingDevelopmentModeEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Development Mode temporarily allows you to enter development mode for your @@ -220,7 +197,7 @@ type SettingDevelopmentModeEditResponseEnvelope struct { // changes to cacheable content (like images, css, or JavaScript) and would like to // see those changes right away. Once entered, development mode will last for 3 // hours and then automatically toggle off. - Result ZoneSettingDevelopmentMode `json:"result"` + Result DevelopmentMode `json:"result"` JSON settingDevelopmentModeEditResponseEnvelopeJSON `json:"-"` } @@ -243,60 +220,14 @@ func (r settingDevelopmentModeEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingDevelopmentModeEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingDevelopmentModeEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingDevelopmentModeEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingDevelopmentModeEditResponseEnvelopeErrors] -type settingDevelopmentModeEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingDevelopmentModeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingDevelopmentModeEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingDevelopmentModeEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingDevelopmentModeEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingDevelopmentModeEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingDevelopmentModeEditResponseEnvelopeMessages] -type settingDevelopmentModeEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingDevelopmentModeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingDevelopmentModeEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingDevelopmentModeGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingDevelopmentModeGetResponseEnvelope struct { - Errors []SettingDevelopmentModeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingDevelopmentModeGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Development Mode temporarily allows you to enter development mode for your @@ -305,7 +236,7 @@ type SettingDevelopmentModeGetResponseEnvelope struct { // changes to cacheable content (like images, css, or JavaScript) and would like to // see those changes right away. Once entered, development mode will last for 3 // hours and then automatically toggle off. - Result ZoneSettingDevelopmentMode `json:"result"` + Result DevelopmentMode `json:"result"` JSON settingDevelopmentModeGetResponseEnvelopeJSON `json:"-"` } @@ -327,49 +258,3 @@ func (r *SettingDevelopmentModeGetResponseEnvelope) UnmarshalJSON(data []byte) ( func (r settingDevelopmentModeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingDevelopmentModeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingDevelopmentModeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingDevelopmentModeGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingDevelopmentModeGetResponseEnvelopeErrors] -type settingDevelopmentModeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingDevelopmentModeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingDevelopmentModeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingDevelopmentModeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingDevelopmentModeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingDevelopmentModeGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingDevelopmentModeGetResponseEnvelopeMessages] -type settingDevelopmentModeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingDevelopmentModeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingDevelopmentModeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingearlyhint.go b/zones/settingearlyhint.go index 7e8981a8380..07b563de89e 100644 --- a/zones/settingearlyhint.go +++ b/zones/settingearlyhint.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewSettingEarlyHintService(opts ...option.RequestOption) (r *SettingEarlyHi // `103` responses with `Link` headers from the final response. Refer to // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for // more information. -func (r *SettingEarlyHintService) Edit(ctx context.Context, params SettingEarlyHintEditParams, opts ...option.RequestOption) (res *ZoneSettingEarlyHints, err error) { +func (r *SettingEarlyHintService) Edit(ctx context.Context, params SettingEarlyHintEditParams, opts ...option.RequestOption) (res *EarlyHints, err error) { opts = append(r.Options[:], opts...) var env SettingEarlyHintEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/early_hints", params.ZoneID) @@ -52,7 +53,7 @@ func (r *SettingEarlyHintService) Edit(ctx context.Context, params SettingEarlyH // `103` responses with `Link` headers from the final response. Refer to // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for // more information. -func (r *SettingEarlyHintService) Get(ctx context.Context, query SettingEarlyHintGetParams, opts ...option.RequestOption) (res *ZoneSettingEarlyHints, err error) { +func (r *SettingEarlyHintService) Get(ctx context.Context, query SettingEarlyHintGetParams, opts ...option.RequestOption) (res *EarlyHints, err error) { opts = append(r.Options[:], opts...) var env SettingEarlyHintGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/early_hints", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingEarlyHintService) Get(ctx context.Context, query SettingEarlyHin // `103` responses with `Link` headers from the final response. Refer to // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for // more information. -type ZoneSettingEarlyHints struct { +type EarlyHints struct { // ID of the zone setting. - ID ZoneSettingEarlyHintsID `json:"id,required"` + ID EarlyHintsID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingEarlyHintsValue `json:"value,required"` + Value EarlyHintsValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingEarlyHintsEditable `json:"editable"` + Editable EarlyHintsEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEarlyHintsJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON earlyHintsJSON `json:"-"` } -// zoneSettingEarlyHintsJSON contains the JSON metadata for the struct -// [ZoneSettingEarlyHints] -type zoneSettingEarlyHintsJSON struct { +// earlyHintsJSON contains the JSON metadata for the struct [EarlyHints] +type earlyHintsJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,44 +92,40 @@ type zoneSettingEarlyHintsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingEarlyHints) UnmarshalJSON(data []byte) (err error) { +func (r *EarlyHints) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingEarlyHintsJSON) RawJSON() string { +func (r earlyHintsJSON) RawJSON() string { return r.raw } -func (r ZoneSettingEarlyHints) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingEarlyHints) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingEarlyHintsID string +type EarlyHintsID string const ( - ZoneSettingEarlyHintsIDEarlyHints ZoneSettingEarlyHintsID = "early_hints" + EarlyHintsIDEarlyHints EarlyHintsID = "early_hints" ) -func (r ZoneSettingEarlyHintsID) IsKnown() bool { +func (r EarlyHintsID) IsKnown() bool { switch r { - case ZoneSettingEarlyHintsIDEarlyHints: + case EarlyHintsIDEarlyHints: return true } return false } // Current value of the zone setting. -type ZoneSettingEarlyHintsValue string +type EarlyHintsValue string const ( - ZoneSettingEarlyHintsValueOn ZoneSettingEarlyHintsValue = "on" - ZoneSettingEarlyHintsValueOff ZoneSettingEarlyHintsValue = "off" + EarlyHintsValueOn EarlyHintsValue = "on" + EarlyHintsValueOff EarlyHintsValue = "off" ) -func (r ZoneSettingEarlyHintsValue) IsKnown() bool { +func (r EarlyHintsValue) IsKnown() bool { switch r { - case ZoneSettingEarlyHintsValueOn, ZoneSettingEarlyHintsValueOff: + case EarlyHintsValueOn, EarlyHintsValueOff: return true } return false @@ -137,38 +133,21 @@ func (r ZoneSettingEarlyHintsValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingEarlyHintsEditable bool +type EarlyHintsEditable bool const ( - ZoneSettingEarlyHintsEditableTrue ZoneSettingEarlyHintsEditable = true - ZoneSettingEarlyHintsEditableFalse ZoneSettingEarlyHintsEditable = false + EarlyHintsEditableTrue EarlyHintsEditable = true + EarlyHintsEditableFalse EarlyHintsEditable = false ) -func (r ZoneSettingEarlyHintsEditable) IsKnown() bool { +func (r EarlyHintsEditable) IsKnown() bool { switch r { - case ZoneSettingEarlyHintsEditableTrue, ZoneSettingEarlyHintsEditableFalse: + case EarlyHintsEditableTrue, EarlyHintsEditableFalse: return true } return false } -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -type ZoneSettingEarlyHintsParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEarlyHintsID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEarlyHintsValue] `json:"value,required"` -} - -func (r ZoneSettingEarlyHintsParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEarlyHintsParam) implementsZonesSettingEditParamsItem() {} - type SettingEarlyHintEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -197,15 +176,15 @@ func (r SettingEarlyHintEditParamsValue) IsKnown() bool { } type SettingEarlyHintEditResponseEnvelope struct { - Errors []SettingEarlyHintEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingEarlyHintEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When enabled, Cloudflare will attempt to speed up overall page loads by serving // `103` responses with `Link` headers from the final response. Refer to // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for // more information. - Result ZoneSettingEarlyHints `json:"result"` + Result EarlyHints `json:"result"` JSON settingEarlyHintEditResponseEnvelopeJSON `json:"-"` } @@ -228,67 +207,21 @@ func (r settingEarlyHintEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingEarlyHintEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEarlyHintEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingEarlyHintEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingEarlyHintEditResponseEnvelopeErrors] -type settingEarlyHintEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEarlyHintEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEarlyHintEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingEarlyHintEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEarlyHintEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingEarlyHintEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingEarlyHintEditResponseEnvelopeMessages] -type settingEarlyHintEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEarlyHintEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEarlyHintEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingEarlyHintGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingEarlyHintGetResponseEnvelope struct { - Errors []SettingEarlyHintGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingEarlyHintGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When enabled, Cloudflare will attempt to speed up overall page loads by serving // `103` responses with `Link` headers from the final response. Refer to // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for // more information. - Result ZoneSettingEarlyHints `json:"result"` + Result EarlyHints `json:"result"` JSON settingEarlyHintGetResponseEnvelopeJSON `json:"-"` } @@ -310,49 +243,3 @@ func (r *SettingEarlyHintGetResponseEnvelope) UnmarshalJSON(data []byte) (err er func (r settingEarlyHintGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingEarlyHintGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEarlyHintGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingEarlyHintGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingEarlyHintGetResponseEnvelopeErrors] -type settingEarlyHintGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEarlyHintGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEarlyHintGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingEarlyHintGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEarlyHintGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingEarlyHintGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingEarlyHintGetResponseEnvelopeMessages] -type settingEarlyHintGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEarlyHintGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEarlyHintGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingemailobfuscation.go b/zones/settingemailobfuscation.go index 773ada5a2a1..9f1ef855598 100644 --- a/zones/settingemailobfuscation.go +++ b/zones/settingemailobfuscation.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingEmailObfuscationService(opts ...option.RequestOption) (r *Setting // Encrypt email adresses on your web page from bots, while keeping them visible to // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -func (r *SettingEmailObfuscationService) Edit(ctx context.Context, params SettingEmailObfuscationEditParams, opts ...option.RequestOption) (res *ZoneSettingEmailObfuscation, err error) { +func (r *SettingEmailObfuscationService) Edit(ctx context.Context, params SettingEmailObfuscationEditParams, opts ...option.RequestOption) (res *EmailObfuscation, err error) { opts = append(r.Options[:], opts...) var env SettingEmailObfuscationEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/email_obfuscation", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingEmailObfuscationService) Edit(ctx context.Context, params Settin // Encrypt email adresses on your web page from bots, while keeping them visible to // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -func (r *SettingEmailObfuscationService) Get(ctx context.Context, query SettingEmailObfuscationGetParams, opts ...option.RequestOption) (res *ZoneSettingEmailObfuscation, err error) { +func (r *SettingEmailObfuscationService) Get(ctx context.Context, query SettingEmailObfuscationGetParams, opts ...option.RequestOption) (res *EmailObfuscation, err error) { opts = append(r.Options[:], opts...) var env SettingEmailObfuscationGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/email_obfuscation", query.ZoneID) @@ -62,22 +63,22 @@ func (r *SettingEmailObfuscationService) Get(ctx context.Context, query SettingE // Encrypt email adresses on your web page from bots, while keeping them visible to // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -type ZoneSettingEmailObfuscation struct { +type EmailObfuscation struct { // ID of the zone setting. - ID ZoneSettingEmailObfuscationID `json:"id,required"` + ID EmailObfuscationID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingEmailObfuscationValue `json:"value,required"` + Value EmailObfuscationValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingEmailObfuscationEditable `json:"editable"` + Editable EmailObfuscationEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEmailObfuscationJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON emailObfuscationJSON `json:"-"` } -// zoneSettingEmailObfuscationJSON contains the JSON metadata for the struct -// [ZoneSettingEmailObfuscation] -type zoneSettingEmailObfuscationJSON struct { +// emailObfuscationJSON contains the JSON metadata for the struct +// [EmailObfuscation] +type emailObfuscationJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -86,44 +87,40 @@ type zoneSettingEmailObfuscationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingEmailObfuscation) UnmarshalJSON(data []byte) (err error) { +func (r *EmailObfuscation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingEmailObfuscationJSON) RawJSON() string { +func (r emailObfuscationJSON) RawJSON() string { return r.raw } -func (r ZoneSettingEmailObfuscation) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingEmailObfuscation) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingEmailObfuscationID string +type EmailObfuscationID string const ( - ZoneSettingEmailObfuscationIDEmailObfuscation ZoneSettingEmailObfuscationID = "email_obfuscation" + EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation" ) -func (r ZoneSettingEmailObfuscationID) IsKnown() bool { +func (r EmailObfuscationID) IsKnown() bool { switch r { - case ZoneSettingEmailObfuscationIDEmailObfuscation: + case EmailObfuscationIDEmailObfuscation: return true } return false } // Current value of the zone setting. -type ZoneSettingEmailObfuscationValue string +type EmailObfuscationValue string const ( - ZoneSettingEmailObfuscationValueOn ZoneSettingEmailObfuscationValue = "on" - ZoneSettingEmailObfuscationValueOff ZoneSettingEmailObfuscationValue = "off" + EmailObfuscationValueOn EmailObfuscationValue = "on" + EmailObfuscationValueOff EmailObfuscationValue = "off" ) -func (r ZoneSettingEmailObfuscationValue) IsKnown() bool { +func (r EmailObfuscationValue) IsKnown() bool { switch r { - case ZoneSettingEmailObfuscationValueOn, ZoneSettingEmailObfuscationValueOff: + case EmailObfuscationValueOn, EmailObfuscationValueOff: return true } return false @@ -131,36 +128,21 @@ func (r ZoneSettingEmailObfuscationValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingEmailObfuscationEditable bool +type EmailObfuscationEditable bool const ( - ZoneSettingEmailObfuscationEditableTrue ZoneSettingEmailObfuscationEditable = true - ZoneSettingEmailObfuscationEditableFalse ZoneSettingEmailObfuscationEditable = false + EmailObfuscationEditableTrue EmailObfuscationEditable = true + EmailObfuscationEditableFalse EmailObfuscationEditable = false ) -func (r ZoneSettingEmailObfuscationEditable) IsKnown() bool { +func (r EmailObfuscationEditable) IsKnown() bool { switch r { - case ZoneSettingEmailObfuscationEditableTrue, ZoneSettingEmailObfuscationEditableFalse: + case EmailObfuscationEditableTrue, EmailObfuscationEditableFalse: return true } return false } -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -type ZoneSettingEmailObfuscationParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEmailObfuscationID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEmailObfuscationValue] `json:"value,required"` -} - -func (r ZoneSettingEmailObfuscationParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEmailObfuscationParam) implementsZonesSettingEditParamsItem() {} - type SettingEmailObfuscationEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -189,13 +171,13 @@ func (r SettingEmailObfuscationEditParamsValue) IsKnown() bool { } type SettingEmailObfuscationEditResponseEnvelope struct { - Errors []SettingEmailObfuscationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingEmailObfuscationEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Encrypt email adresses on your web page from bots, while keeping them visible to // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). - Result ZoneSettingEmailObfuscation `json:"result"` + Result EmailObfuscation `json:"result"` JSON settingEmailObfuscationEditResponseEnvelopeJSON `json:"-"` } @@ -218,65 +200,19 @@ func (r settingEmailObfuscationEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingEmailObfuscationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEmailObfuscationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingEmailObfuscationEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingEmailObfuscationEditResponseEnvelopeErrors] -type settingEmailObfuscationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEmailObfuscationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEmailObfuscationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingEmailObfuscationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEmailObfuscationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingEmailObfuscationEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingEmailObfuscationEditResponseEnvelopeMessages] -type settingEmailObfuscationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEmailObfuscationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEmailObfuscationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingEmailObfuscationGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingEmailObfuscationGetResponseEnvelope struct { - Errors []SettingEmailObfuscationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingEmailObfuscationGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Encrypt email adresses on your web page from bots, while keeping them visible to // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). - Result ZoneSettingEmailObfuscation `json:"result"` + Result EmailObfuscation `json:"result"` JSON settingEmailObfuscationGetResponseEnvelopeJSON `json:"-"` } @@ -298,49 +234,3 @@ func (r *SettingEmailObfuscationGetResponseEnvelope) UnmarshalJSON(data []byte) func (r settingEmailObfuscationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingEmailObfuscationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEmailObfuscationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingEmailObfuscationGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingEmailObfuscationGetResponseEnvelopeErrors] -type settingEmailObfuscationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEmailObfuscationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEmailObfuscationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingEmailObfuscationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingEmailObfuscationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingEmailObfuscationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingEmailObfuscationGetResponseEnvelopeMessages] -type settingEmailObfuscationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingEmailObfuscationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingEmailObfuscationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingfontsetting.go b/zones/settingfontsetting.go index e3fc7295b32..4a1d659b853 100644 --- a/zones/settingfontsetting.go +++ b/zones/settingfontsetting.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingFontSettingService(opts ...option.RequestOption) (r *SettingFontS // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google // Hosted fonts from your own domain, boost performance, and enhance user privacy. // Refer to the Cloudflare Fonts documentation for more information. -func (r *SettingFontSettingService) Edit(ctx context.Context, params SettingFontSettingEditParams, opts ...option.RequestOption) (res *ZoneSettingFonts, err error) { +func (r *SettingFontSettingService) Edit(ctx context.Context, params SettingFontSettingEditParams, opts ...option.RequestOption) (res *FontSettings, err error) { opts = append(r.Options[:], opts...) var env SettingFontSettingEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/fonts", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingFontSettingService) Edit(ctx context.Context, params SettingFont // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google // Hosted fonts from your own domain, boost performance, and enhance user privacy. // Refer to the Cloudflare Fonts documentation for more information. -func (r *SettingFontSettingService) Get(ctx context.Context, query SettingFontSettingGetParams, opts ...option.RequestOption) (res *ZoneSettingFonts, err error) { +func (r *SettingFontSettingService) Get(ctx context.Context, query SettingFontSettingGetParams, opts ...option.RequestOption) (res *FontSettings, err error) { opts = append(r.Options[:], opts...) var env SettingFontSettingGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/fonts", query.ZoneID) @@ -65,22 +66,21 @@ func (r *SettingFontSettingService) Get(ctx context.Context, query SettingFontSe // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google // Hosted fonts from your own domain, boost performance, and enhance user privacy. // Refer to the Cloudflare Fonts documentation for more information. -type ZoneSettingFonts struct { +type FontSettings struct { // ID of the zone setting. - ID ZoneSettingFontsID `json:"id,required"` + ID FontSettingsID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingFontsValue `json:"value,required"` + Value FontSettingsValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingFontsEditable `json:"editable"` + Editable FontSettingsEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingFontsJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON fontSettingsJSON `json:"-"` } -// zoneSettingFontsJSON contains the JSON metadata for the struct -// [ZoneSettingFonts] -type zoneSettingFontsJSON struct { +// fontSettingsJSON contains the JSON metadata for the struct [FontSettings] +type fontSettingsJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -89,40 +89,40 @@ type zoneSettingFontsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingFonts) UnmarshalJSON(data []byte) (err error) { +func (r *FontSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingFontsJSON) RawJSON() string { +func (r fontSettingsJSON) RawJSON() string { return r.raw } // ID of the zone setting. -type ZoneSettingFontsID string +type FontSettingsID string const ( - ZoneSettingFontsIDFonts ZoneSettingFontsID = "fonts" + FontSettingsIDFonts FontSettingsID = "fonts" ) -func (r ZoneSettingFontsID) IsKnown() bool { +func (r FontSettingsID) IsKnown() bool { switch r { - case ZoneSettingFontsIDFonts: + case FontSettingsIDFonts: return true } return false } // Current value of the zone setting. -type ZoneSettingFontsValue string +type FontSettingsValue string const ( - ZoneSettingFontsValueOn ZoneSettingFontsValue = "on" - ZoneSettingFontsValueOff ZoneSettingFontsValue = "off" + FontSettingsValueOn FontSettingsValue = "on" + FontSettingsValueOff FontSettingsValue = "off" ) -func (r ZoneSettingFontsValue) IsKnown() bool { +func (r FontSettingsValue) IsKnown() bool { switch r { - case ZoneSettingFontsValueOn, ZoneSettingFontsValueOff: + case FontSettingsValueOn, FontSettingsValueOff: return true } return false @@ -130,16 +130,16 @@ func (r ZoneSettingFontsValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingFontsEditable bool +type FontSettingsEditable bool const ( - ZoneSettingFontsEditableTrue ZoneSettingFontsEditable = true - ZoneSettingFontsEditableFalse ZoneSettingFontsEditable = false + FontSettingsEditableTrue FontSettingsEditable = true + FontSettingsEditableFalse FontSettingsEditable = false ) -func (r ZoneSettingFontsEditable) IsKnown() bool { +func (r FontSettingsEditable) IsKnown() bool { switch r { - case ZoneSettingFontsEditableTrue, ZoneSettingFontsEditableFalse: + case FontSettingsEditableTrue, FontSettingsEditableFalse: return true } return false @@ -173,14 +173,14 @@ func (r SettingFontSettingEditParamsValue) IsKnown() bool { } type SettingFontSettingEditResponseEnvelope struct { - Errors []SettingFontSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingFontSettingEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google // Hosted fonts from your own domain, boost performance, and enhance user privacy. // Refer to the Cloudflare Fonts documentation for more information. - Result ZoneSettingFonts `json:"result"` + Result FontSettings `json:"result"` JSON settingFontSettingEditResponseEnvelopeJSON `json:"-"` } @@ -203,66 +203,20 @@ func (r settingFontSettingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingFontSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingFontSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingFontSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingFontSettingEditResponseEnvelopeErrors] -type settingFontSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingFontSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingFontSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingFontSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingFontSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingFontSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingFontSettingEditResponseEnvelopeMessages] -type settingFontSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingFontSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingFontSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingFontSettingGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingFontSettingGetResponseEnvelope struct { - Errors []SettingFontSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingFontSettingGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google // Hosted fonts from your own domain, boost performance, and enhance user privacy. // Refer to the Cloudflare Fonts documentation for more information. - Result ZoneSettingFonts `json:"result"` + Result FontSettings `json:"result"` JSON settingFontSettingGetResponseEnvelopeJSON `json:"-"` } @@ -284,49 +238,3 @@ func (r *SettingFontSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err func (r settingFontSettingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingFontSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingFontSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingFontSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingFontSettingGetResponseEnvelopeErrors] -type settingFontSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingFontSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingFontSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingFontSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingFontSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingFontSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingFontSettingGetResponseEnvelopeMessages] -type settingFontSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingFontSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingFontSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingh2prioritization.go b/zones/settingh2prioritization.go index b83f1d07ac3..016fe71a58c 100644 --- a/zones/settingh2prioritization.go +++ b/zones/settingh2prioritization.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingH2PrioritizationService(opts ...option.RequestOption) (r *Setting } // Gets HTTP/2 Edge Prioritization setting. -func (r *SettingH2PrioritizationService) Edit(ctx context.Context, params SettingH2PrioritizationEditParams, opts ...option.RequestOption) (res *ZoneSettingH2Prioritization, err error) { +func (r *SettingH2PrioritizationService) Edit(ctx context.Context, params SettingH2PrioritizationEditParams, opts ...option.RequestOption) (res *H2Prioritization, err error) { opts = append(r.Options[:], opts...) var env SettingH2PrioritizationEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/h2_prioritization", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingH2PrioritizationService) Edit(ctx context.Context, params Settin } // Gets HTTP/2 Edge Prioritization setting. -func (r *SettingH2PrioritizationService) Get(ctx context.Context, query SettingH2PrioritizationGetParams, opts ...option.RequestOption) (res *ZoneSettingH2Prioritization, err error) { +func (r *SettingH2PrioritizationService) Get(ctx context.Context, query SettingH2PrioritizationGetParams, opts ...option.RequestOption) (res *H2Prioritization, err error) { opts = append(r.Options[:], opts...) var env SettingH2PrioritizationGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/h2_prioritization", query.ZoneID) @@ -61,22 +62,22 @@ func (r *SettingH2PrioritizationService) Get(ctx context.Context, query SettingH // HTTP/2 Edge Prioritization optimises the delivery of resources served through // HTTP/2 to improve page load performance. It also supports fine control of // content delivery when used in conjunction with Workers. -type ZoneSettingH2Prioritization struct { +type H2Prioritization struct { // ID of the zone setting. - ID ZoneSettingH2PrioritizationID `json:"id,required"` + ID H2PrioritizationID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingH2PrioritizationValue `json:"value,required"` + Value H2PrioritizationValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingH2PrioritizationEditable `json:"editable"` + Editable H2PrioritizationEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingH2PrioritizationJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON h2PrioritizationJSON `json:"-"` } -// zoneSettingH2PrioritizationJSON contains the JSON metadata for the struct -// [ZoneSettingH2Prioritization] -type zoneSettingH2PrioritizationJSON struct { +// h2PrioritizationJSON contains the JSON metadata for the struct +// [H2Prioritization] +type h2PrioritizationJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -85,45 +86,41 @@ type zoneSettingH2PrioritizationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingH2Prioritization) UnmarshalJSON(data []byte) (err error) { +func (r *H2Prioritization) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingH2PrioritizationJSON) RawJSON() string { +func (r h2PrioritizationJSON) RawJSON() string { return r.raw } -func (r ZoneSettingH2Prioritization) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingH2Prioritization) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingH2PrioritizationID string +type H2PrioritizationID string const ( - ZoneSettingH2PrioritizationIDH2Prioritization ZoneSettingH2PrioritizationID = "h2_prioritization" + H2PrioritizationIDH2Prioritization H2PrioritizationID = "h2_prioritization" ) -func (r ZoneSettingH2PrioritizationID) IsKnown() bool { +func (r H2PrioritizationID) IsKnown() bool { switch r { - case ZoneSettingH2PrioritizationIDH2Prioritization: + case H2PrioritizationIDH2Prioritization: return true } return false } // Current value of the zone setting. -type ZoneSettingH2PrioritizationValue string +type H2PrioritizationValue string const ( - ZoneSettingH2PrioritizationValueOn ZoneSettingH2PrioritizationValue = "on" - ZoneSettingH2PrioritizationValueOff ZoneSettingH2PrioritizationValue = "off" - ZoneSettingH2PrioritizationValueCustom ZoneSettingH2PrioritizationValue = "custom" + H2PrioritizationValueOn H2PrioritizationValue = "on" + H2PrioritizationValueOff H2PrioritizationValue = "off" + H2PrioritizationValueCustom H2PrioritizationValue = "custom" ) -func (r ZoneSettingH2PrioritizationValue) IsKnown() bool { +func (r H2PrioritizationValue) IsKnown() bool { switch r { - case ZoneSettingH2PrioritizationValueOn, ZoneSettingH2PrioritizationValueOff, ZoneSettingH2PrioritizationValueCustom: + case H2PrioritizationValueOn, H2PrioritizationValueOff, H2PrioritizationValueCustom: return true } return false @@ -131,16 +128,16 @@ func (r ZoneSettingH2PrioritizationValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingH2PrioritizationEditable bool +type H2PrioritizationEditable bool const ( - ZoneSettingH2PrioritizationEditableTrue ZoneSettingH2PrioritizationEditable = true - ZoneSettingH2PrioritizationEditableFalse ZoneSettingH2PrioritizationEditable = false + H2PrioritizationEditableTrue H2PrioritizationEditable = true + H2PrioritizationEditableFalse H2PrioritizationEditable = false ) -func (r ZoneSettingH2PrioritizationEditable) IsKnown() bool { +func (r H2PrioritizationEditable) IsKnown() bool { switch r { - case ZoneSettingH2PrioritizationEditableTrue, ZoneSettingH2PrioritizationEditableFalse: + case H2PrioritizationEditableTrue, H2PrioritizationEditableFalse: return true } return false @@ -149,26 +146,24 @@ func (r ZoneSettingH2PrioritizationEditable) IsKnown() bool { // HTTP/2 Edge Prioritization optimises the delivery of resources served through // HTTP/2 to improve page load performance. It also supports fine control of // content delivery when used in conjunction with Workers. -type ZoneSettingH2PrioritizationParam struct { +type H2PrioritizationParam struct { // ID of the zone setting. - ID param.Field[ZoneSettingH2PrioritizationID] `json:"id,required"` + ID param.Field[H2PrioritizationID] `json:"id,required"` // Current value of the zone setting. - Value param.Field[ZoneSettingH2PrioritizationValue] `json:"value,required"` + Value param.Field[H2PrioritizationValue] `json:"value,required"` } -func (r ZoneSettingH2PrioritizationParam) MarshalJSON() (data []byte, err error) { +func (r H2PrioritizationParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingH2PrioritizationParam) implementsZonesSettingEditParamsItem() {} - type SettingH2PrioritizationEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // HTTP/2 Edge Prioritization optimises the delivery of resources served through // HTTP/2 to improve page load performance. It also supports fine control of // content delivery when used in conjunction with Workers. - Value param.Field[ZoneSettingH2PrioritizationParam] `json:"value,required"` + Value param.Field[H2PrioritizationParam] `json:"value,required"` } func (r SettingH2PrioritizationEditParams) MarshalJSON() (data []byte, err error) { @@ -176,14 +171,14 @@ func (r SettingH2PrioritizationEditParams) MarshalJSON() (data []byte, err error } type SettingH2PrioritizationEditResponseEnvelope struct { - Errors []SettingH2PrioritizationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingH2PrioritizationEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // HTTP/2 Edge Prioritization optimises the delivery of resources served through // HTTP/2 to improve page load performance. It also supports fine control of // content delivery when used in conjunction with Workers. - Result ZoneSettingH2Prioritization `json:"result"` + Result H2Prioritization `json:"result"` JSON settingH2PrioritizationEditResponseEnvelopeJSON `json:"-"` } @@ -206,66 +201,20 @@ func (r settingH2PrioritizationEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingH2PrioritizationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingH2PrioritizationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingH2PrioritizationEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingH2PrioritizationEditResponseEnvelopeErrors] -type settingH2PrioritizationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingH2PrioritizationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingH2PrioritizationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingH2PrioritizationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingH2PrioritizationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingH2PrioritizationEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingH2PrioritizationEditResponseEnvelopeMessages] -type settingH2PrioritizationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingH2PrioritizationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingH2PrioritizationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingH2PrioritizationGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingH2PrioritizationGetResponseEnvelope struct { - Errors []SettingH2PrioritizationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingH2PrioritizationGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // HTTP/2 Edge Prioritization optimises the delivery of resources served through // HTTP/2 to improve page load performance. It also supports fine control of // content delivery when used in conjunction with Workers. - Result ZoneSettingH2Prioritization `json:"result"` + Result H2Prioritization `json:"result"` JSON settingH2PrioritizationGetResponseEnvelopeJSON `json:"-"` } @@ -287,49 +236,3 @@ func (r *SettingH2PrioritizationGetResponseEnvelope) UnmarshalJSON(data []byte) func (r settingH2PrioritizationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingH2PrioritizationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingH2PrioritizationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingH2PrioritizationGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingH2PrioritizationGetResponseEnvelopeErrors] -type settingH2PrioritizationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingH2PrioritizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingH2PrioritizationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingH2PrioritizationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingH2PrioritizationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingH2PrioritizationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingH2PrioritizationGetResponseEnvelopeMessages] -type settingH2PrioritizationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingH2PrioritizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingH2PrioritizationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingh2prioritization_test.go b/zones/settingh2prioritization_test.go index ad06bee6d8d..4f31fcf190c 100644 --- a/zones/settingh2prioritization_test.go +++ b/zones/settingh2prioritization_test.go @@ -30,9 +30,9 @@ func TestSettingH2PrioritizationEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.H2Prioritization.Edit(context.TODO(), zones.SettingH2PrioritizationEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingH2PrioritizationParam{ - ID: cloudflare.F(zones.ZoneSettingH2PrioritizationIDH2Prioritization), - Value: cloudflare.F(zones.ZoneSettingH2PrioritizationValueOn), + Value: cloudflare.F(zones.H2PrioritizationParam{ + ID: cloudflare.F(zones.H2PrioritizationIDH2Prioritization), + Value: cloudflare.F(zones.H2PrioritizationValueOn), }), }) if err != nil { diff --git a/zones/settinghotlinkprotection.go b/zones/settinghotlinkprotection.go index 8414fcd5774..895c763212c 100644 --- a/zones/settinghotlinkprotection.go +++ b/zones/settinghotlinkprotection.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -39,7 +40,7 @@ func NewSettingHotlinkProtectionService(opts ...option.RequestOption) (r *Settin // view images from your page, but other sites won't be able to steal them for use // on their own pages. // (https://support.cloudflare.com/hc/en-us/articles/200170026). -func (r *SettingHotlinkProtectionService) Edit(ctx context.Context, params SettingHotlinkProtectionEditParams, opts ...option.RequestOption) (res *ZoneSettingHotlinkProtection, err error) { +func (r *SettingHotlinkProtectionService) Edit(ctx context.Context, params SettingHotlinkProtectionEditParams, opts ...option.RequestOption) (res *HotlinkProtection, err error) { opts = append(r.Options[:], opts...) var env SettingHotlinkProtectionEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/hotlink_protection", params.ZoneID) @@ -58,7 +59,7 @@ func (r *SettingHotlinkProtectionService) Edit(ctx context.Context, params Setti // view images from your page, but other sites won't be able to steal them for use // on their own pages. // (https://support.cloudflare.com/hc/en-us/articles/200170026). -func (r *SettingHotlinkProtectionService) Get(ctx context.Context, query SettingHotlinkProtectionGetParams, opts ...option.RequestOption) (res *ZoneSettingHotlinkProtection, err error) { +func (r *SettingHotlinkProtectionService) Get(ctx context.Context, query SettingHotlinkProtectionGetParams, opts ...option.RequestOption) (res *HotlinkProtection, err error) { opts = append(r.Options[:], opts...) var env SettingHotlinkProtectionGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/hotlink_protection", query.ZoneID) @@ -77,22 +78,22 @@ func (r *SettingHotlinkProtectionService) Get(ctx context.Context, query Setting // view images from your page, but other sites won't be able to steal them for use // on their own pages. // (https://support.cloudflare.com/hc/en-us/articles/200170026). -type ZoneSettingHotlinkProtection struct { +type HotlinkProtection struct { // ID of the zone setting. - ID ZoneSettingHotlinkProtectionID `json:"id,required"` + ID HotlinkProtectionID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingHotlinkProtectionValue `json:"value,required"` + Value HotlinkProtectionValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingHotlinkProtectionEditable `json:"editable"` + Editable HotlinkProtectionEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHotlinkProtectionJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON hotlinkProtectionJSON `json:"-"` } -// zoneSettingHotlinkProtectionJSON contains the JSON metadata for the struct -// [ZoneSettingHotlinkProtection] -type zoneSettingHotlinkProtectionJSON struct { +// hotlinkProtectionJSON contains the JSON metadata for the struct +// [HotlinkProtection] +type hotlinkProtectionJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -101,44 +102,40 @@ type zoneSettingHotlinkProtectionJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingHotlinkProtection) UnmarshalJSON(data []byte) (err error) { +func (r *HotlinkProtection) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingHotlinkProtectionJSON) RawJSON() string { +func (r hotlinkProtectionJSON) RawJSON() string { return r.raw } -func (r ZoneSettingHotlinkProtection) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingHotlinkProtection) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingHotlinkProtectionID string +type HotlinkProtectionID string const ( - ZoneSettingHotlinkProtectionIDHotlinkProtection ZoneSettingHotlinkProtectionID = "hotlink_protection" + HotlinkProtectionIDHotlinkProtection HotlinkProtectionID = "hotlink_protection" ) -func (r ZoneSettingHotlinkProtectionID) IsKnown() bool { +func (r HotlinkProtectionID) IsKnown() bool { switch r { - case ZoneSettingHotlinkProtectionIDHotlinkProtection: + case HotlinkProtectionIDHotlinkProtection: return true } return false } // Current value of the zone setting. -type ZoneSettingHotlinkProtectionValue string +type HotlinkProtectionValue string const ( - ZoneSettingHotlinkProtectionValueOn ZoneSettingHotlinkProtectionValue = "on" - ZoneSettingHotlinkProtectionValueOff ZoneSettingHotlinkProtectionValue = "off" + HotlinkProtectionValueOn HotlinkProtectionValue = "on" + HotlinkProtectionValueOff HotlinkProtectionValue = "off" ) -func (r ZoneSettingHotlinkProtectionValue) IsKnown() bool { +func (r HotlinkProtectionValue) IsKnown() bool { switch r { - case ZoneSettingHotlinkProtectionValueOn, ZoneSettingHotlinkProtectionValueOff: + case HotlinkProtectionValueOn, HotlinkProtectionValueOff: return true } return false @@ -146,41 +143,21 @@ func (r ZoneSettingHotlinkProtectionValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingHotlinkProtectionEditable bool +type HotlinkProtectionEditable bool const ( - ZoneSettingHotlinkProtectionEditableTrue ZoneSettingHotlinkProtectionEditable = true - ZoneSettingHotlinkProtectionEditableFalse ZoneSettingHotlinkProtectionEditable = false + HotlinkProtectionEditableTrue HotlinkProtectionEditable = true + HotlinkProtectionEditableFalse HotlinkProtectionEditable = false ) -func (r ZoneSettingHotlinkProtectionEditable) IsKnown() bool { +func (r HotlinkProtectionEditable) IsKnown() bool { switch r { - case ZoneSettingHotlinkProtectionEditableTrue, ZoneSettingHotlinkProtectionEditableFalse: + case HotlinkProtectionEditableTrue, HotlinkProtectionEditableFalse: return true } return false } -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -type ZoneSettingHotlinkProtectionParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingHotlinkProtectionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingHotlinkProtectionValue] `json:"value,required"` -} - -func (r ZoneSettingHotlinkProtectionParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingHotlinkProtectionParam) implementsZonesSettingEditParamsItem() {} - type SettingHotlinkProtectionEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -209,8 +186,8 @@ func (r SettingHotlinkProtectionEditParamsValue) IsKnown() bool { } type SettingHotlinkProtectionEditResponseEnvelope struct { - Errors []SettingHotlinkProtectionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingHotlinkProtectionEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When enabled, the Hotlink Protection option ensures that other sites cannot suck @@ -220,7 +197,7 @@ type SettingHotlinkProtectionEditResponseEnvelope struct { // view images from your page, but other sites won't be able to steal them for use // on their own pages. // (https://support.cloudflare.com/hc/en-us/articles/200170026). - Result ZoneSettingHotlinkProtection `json:"result"` + Result HotlinkProtection `json:"result"` JSON settingHotlinkProtectionEditResponseEnvelopeJSON `json:"-"` } @@ -243,60 +220,14 @@ func (r settingHotlinkProtectionEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingHotlinkProtectionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHotlinkProtectionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingHotlinkProtectionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingHotlinkProtectionEditResponseEnvelopeErrors] -type settingHotlinkProtectionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHotlinkProtectionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHotlinkProtectionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingHotlinkProtectionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHotlinkProtectionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingHotlinkProtectionEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingHotlinkProtectionEditResponseEnvelopeMessages] -type settingHotlinkProtectionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHotlinkProtectionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHotlinkProtectionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingHotlinkProtectionGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingHotlinkProtectionGetResponseEnvelope struct { - Errors []SettingHotlinkProtectionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingHotlinkProtectionGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When enabled, the Hotlink Protection option ensures that other sites cannot suck @@ -306,7 +237,7 @@ type SettingHotlinkProtectionGetResponseEnvelope struct { // view images from your page, but other sites won't be able to steal them for use // on their own pages. // (https://support.cloudflare.com/hc/en-us/articles/200170026). - Result ZoneSettingHotlinkProtection `json:"result"` + Result HotlinkProtection `json:"result"` JSON settingHotlinkProtectionGetResponseEnvelopeJSON `json:"-"` } @@ -328,49 +259,3 @@ func (r *SettingHotlinkProtectionGetResponseEnvelope) UnmarshalJSON(data []byte) func (r settingHotlinkProtectionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingHotlinkProtectionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHotlinkProtectionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingHotlinkProtectionGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingHotlinkProtectionGetResponseEnvelopeErrors] -type settingHotlinkProtectionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHotlinkProtectionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHotlinkProtectionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingHotlinkProtectionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHotlinkProtectionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingHotlinkProtectionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingHotlinkProtectionGetResponseEnvelopeMessages] -type settingHotlinkProtectionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHotlinkProtectionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHotlinkProtectionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settinghttp2.go b/zones/settinghttp2.go index bda9ea3af6f..d237f94828b 100644 --- a/zones/settinghttp2.go +++ b/zones/settinghttp2.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingHTTP2Service(opts ...option.RequestOption) (r *SettingHTTP2Servic } // Value of the HTTP2 setting. -func (r *SettingHTTP2Service) Edit(ctx context.Context, params SettingHTTP2EditParams, opts ...option.RequestOption) (res *ZoneSettingHTTP2, err error) { +func (r *SettingHTTP2Service) Edit(ctx context.Context, params SettingHTTP2EditParams, opts ...option.RequestOption) (res *HTTP2, err error) { opts = append(r.Options[:], opts...) var env SettingHTTP2EditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/http2", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingHTTP2Service) Edit(ctx context.Context, params SettingHTTP2EditP } // Value of the HTTP2 setting. -func (r *SettingHTTP2Service) Get(ctx context.Context, query SettingHTTP2GetParams, opts ...option.RequestOption) (res *ZoneSettingHTTP2, err error) { +func (r *SettingHTTP2Service) Get(ctx context.Context, query SettingHTTP2GetParams, opts ...option.RequestOption) (res *HTTP2, err error) { opts = append(r.Options[:], opts...) var env SettingHTTP2GetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/http2", query.ZoneID) @@ -59,22 +60,21 @@ func (r *SettingHTTP2Service) Get(ctx context.Context, query SettingHTTP2GetPara } // HTTP2 enabled for this zone. -type ZoneSettingHTTP2 struct { +type HTTP2 struct { // ID of the zone setting. - ID ZoneSettingHTTP2ID `json:"id,required"` + ID HTTP2ID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingHTTP2Value `json:"value,required"` + Value HTTP2Value `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingHTTP2Editable `json:"editable"` + Editable HTTP2Editable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHTTP2JSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON http2JSON `json:"-"` } -// zoneSettingHTTP2JSON contains the JSON metadata for the struct -// [ZoneSettingHTTP2] -type zoneSettingHTTP2JSON struct { +// http2JSON contains the JSON metadata for the struct [HTTP2] +type http2JSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,44 +83,40 @@ type zoneSettingHTTP2JSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingHTTP2) UnmarshalJSON(data []byte) (err error) { +func (r *HTTP2) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingHTTP2JSON) RawJSON() string { +func (r http2JSON) RawJSON() string { return r.raw } -func (r ZoneSettingHTTP2) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingHTTP2) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingHTTP2ID string +type HTTP2ID string const ( - ZoneSettingHTTP2IDHTTP2 ZoneSettingHTTP2ID = "http2" + HTTP2IDHTTP2 HTTP2ID = "http2" ) -func (r ZoneSettingHTTP2ID) IsKnown() bool { +func (r HTTP2ID) IsKnown() bool { switch r { - case ZoneSettingHTTP2IDHTTP2: + case HTTP2IDHTTP2: return true } return false } // Current value of the zone setting. -type ZoneSettingHTTP2Value string +type HTTP2Value string const ( - ZoneSettingHTTP2ValueOn ZoneSettingHTTP2Value = "on" - ZoneSettingHTTP2ValueOff ZoneSettingHTTP2Value = "off" + HTTP2ValueOn HTTP2Value = "on" + HTTP2ValueOff HTTP2Value = "off" ) -func (r ZoneSettingHTTP2Value) IsKnown() bool { +func (r HTTP2Value) IsKnown() bool { switch r { - case ZoneSettingHTTP2ValueOn, ZoneSettingHTTP2ValueOff: + case HTTP2ValueOn, HTTP2ValueOff: return true } return false @@ -128,35 +124,21 @@ func (r ZoneSettingHTTP2Value) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingHTTP2Editable bool +type HTTP2Editable bool const ( - ZoneSettingHTTP2EditableTrue ZoneSettingHTTP2Editable = true - ZoneSettingHTTP2EditableFalse ZoneSettingHTTP2Editable = false + HTTP2EditableTrue HTTP2Editable = true + HTTP2EditableFalse HTTP2Editable = false ) -func (r ZoneSettingHTTP2Editable) IsKnown() bool { +func (r HTTP2Editable) IsKnown() bool { switch r { - case ZoneSettingHTTP2EditableTrue, ZoneSettingHTTP2EditableFalse: + case HTTP2EditableTrue, HTTP2EditableFalse: return true } return false } -// HTTP2 enabled for this zone. -type ZoneSettingHTTP2Param struct { - // ID of the zone setting. - ID param.Field[ZoneSettingHTTP2ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingHTTP2Value] `json:"value,required"` -} - -func (r ZoneSettingHTTP2Param) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingHTTP2Param) implementsZonesSettingEditParamsItem() {} - type SettingHTTP2EditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -185,12 +167,12 @@ func (r SettingHTTP2EditParamsValue) IsKnown() bool { } type SettingHTTP2EditResponseEnvelope struct { - Errors []SettingHTTP2EditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingHTTP2EditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // HTTP2 enabled for this zone. - Result ZoneSettingHTTP2 `json:"result"` + Result HTTP2 `json:"result"` JSON settingHTTP2EditResponseEnvelopeJSON `json:"-"` } @@ -213,64 +195,18 @@ func (r settingHTTP2EditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingHTTP2EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP2EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingHTTP2EditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingHTTP2EditResponseEnvelopeErrors] -type settingHTTP2EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP2EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP2EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingHTTP2EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP2EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingHTTP2EditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingHTTP2EditResponseEnvelopeMessages] -type settingHTTP2EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP2EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP2EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingHTTP2GetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingHTTP2GetResponseEnvelope struct { - Errors []SettingHTTP2GetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingHTTP2GetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // HTTP2 enabled for this zone. - Result ZoneSettingHTTP2 `json:"result"` + Result HTTP2 `json:"result"` JSON settingHTTP2GetResponseEnvelopeJSON `json:"-"` } @@ -292,49 +228,3 @@ func (r *SettingHTTP2GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) func (r settingHTTP2GetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingHTTP2GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP2GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingHTTP2GetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingHTTP2GetResponseEnvelopeErrors] -type settingHTTP2GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP2GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP2GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingHTTP2GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP2GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingHTTP2GetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingHTTP2GetResponseEnvelopeMessages] -type settingHTTP2GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP2GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP2GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settinghttp3.go b/zones/settinghttp3.go index 143f10a0e68..386c22759f5 100644 --- a/zones/settinghttp3.go +++ b/zones/settinghttp3.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingHTTP3Service(opts ...option.RequestOption) (r *SettingHTTP3Servic } // Value of the HTTP3 setting. -func (r *SettingHTTP3Service) Edit(ctx context.Context, params SettingHTTP3EditParams, opts ...option.RequestOption) (res *ZoneSettingHTTP3, err error) { +func (r *SettingHTTP3Service) Edit(ctx context.Context, params SettingHTTP3EditParams, opts ...option.RequestOption) (res *HTTP3, err error) { opts = append(r.Options[:], opts...) var env SettingHTTP3EditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/http3", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingHTTP3Service) Edit(ctx context.Context, params SettingHTTP3EditP } // Value of the HTTP3 setting. -func (r *SettingHTTP3Service) Get(ctx context.Context, query SettingHTTP3GetParams, opts ...option.RequestOption) (res *ZoneSettingHTTP3, err error) { +func (r *SettingHTTP3Service) Get(ctx context.Context, query SettingHTTP3GetParams, opts ...option.RequestOption) (res *HTTP3, err error) { opts = append(r.Options[:], opts...) var env SettingHTTP3GetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/http3", query.ZoneID) @@ -59,22 +60,21 @@ func (r *SettingHTTP3Service) Get(ctx context.Context, query SettingHTTP3GetPara } // HTTP3 enabled for this zone. -type ZoneSettingHTTP3 struct { +type HTTP3 struct { // ID of the zone setting. - ID ZoneSettingHTTP3ID `json:"id,required"` + ID HTTP3ID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingHTTP3Value `json:"value,required"` + Value HTTP3Value `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingHTTP3Editable `json:"editable"` + Editable HTTP3Editable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHTTP3JSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON http3JSON `json:"-"` } -// zoneSettingHTTP3JSON contains the JSON metadata for the struct -// [ZoneSettingHTTP3] -type zoneSettingHTTP3JSON struct { +// http3JSON contains the JSON metadata for the struct [HTTP3] +type http3JSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,44 +83,40 @@ type zoneSettingHTTP3JSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingHTTP3) UnmarshalJSON(data []byte) (err error) { +func (r *HTTP3) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingHTTP3JSON) RawJSON() string { +func (r http3JSON) RawJSON() string { return r.raw } -func (r ZoneSettingHTTP3) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingHTTP3) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingHTTP3ID string +type HTTP3ID string const ( - ZoneSettingHTTP3IDHTTP3 ZoneSettingHTTP3ID = "http3" + HTTP3IDHTTP3 HTTP3ID = "http3" ) -func (r ZoneSettingHTTP3ID) IsKnown() bool { +func (r HTTP3ID) IsKnown() bool { switch r { - case ZoneSettingHTTP3IDHTTP3: + case HTTP3IDHTTP3: return true } return false } // Current value of the zone setting. -type ZoneSettingHTTP3Value string +type HTTP3Value string const ( - ZoneSettingHTTP3ValueOn ZoneSettingHTTP3Value = "on" - ZoneSettingHTTP3ValueOff ZoneSettingHTTP3Value = "off" + HTTP3ValueOn HTTP3Value = "on" + HTTP3ValueOff HTTP3Value = "off" ) -func (r ZoneSettingHTTP3Value) IsKnown() bool { +func (r HTTP3Value) IsKnown() bool { switch r { - case ZoneSettingHTTP3ValueOn, ZoneSettingHTTP3ValueOff: + case HTTP3ValueOn, HTTP3ValueOff: return true } return false @@ -128,35 +124,21 @@ func (r ZoneSettingHTTP3Value) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingHTTP3Editable bool +type HTTP3Editable bool const ( - ZoneSettingHTTP3EditableTrue ZoneSettingHTTP3Editable = true - ZoneSettingHTTP3EditableFalse ZoneSettingHTTP3Editable = false + HTTP3EditableTrue HTTP3Editable = true + HTTP3EditableFalse HTTP3Editable = false ) -func (r ZoneSettingHTTP3Editable) IsKnown() bool { +func (r HTTP3Editable) IsKnown() bool { switch r { - case ZoneSettingHTTP3EditableTrue, ZoneSettingHTTP3EditableFalse: + case HTTP3EditableTrue, HTTP3EditableFalse: return true } return false } -// HTTP3 enabled for this zone. -type ZoneSettingHTTP3Param struct { - // ID of the zone setting. - ID param.Field[ZoneSettingHTTP3ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingHTTP3Value] `json:"value,required"` -} - -func (r ZoneSettingHTTP3Param) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingHTTP3Param) implementsZonesSettingEditParamsItem() {} - type SettingHTTP3EditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -185,12 +167,12 @@ func (r SettingHTTP3EditParamsValue) IsKnown() bool { } type SettingHTTP3EditResponseEnvelope struct { - Errors []SettingHTTP3EditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingHTTP3EditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // HTTP3 enabled for this zone. - Result ZoneSettingHTTP3 `json:"result"` + Result HTTP3 `json:"result"` JSON settingHTTP3EditResponseEnvelopeJSON `json:"-"` } @@ -213,64 +195,18 @@ func (r settingHTTP3EditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingHTTP3EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP3EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingHTTP3EditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingHTTP3EditResponseEnvelopeErrors] -type settingHTTP3EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP3EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP3EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingHTTP3EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP3EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingHTTP3EditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingHTTP3EditResponseEnvelopeMessages] -type settingHTTP3EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP3EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP3EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingHTTP3GetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingHTTP3GetResponseEnvelope struct { - Errors []SettingHTTP3GetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingHTTP3GetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // HTTP3 enabled for this zone. - Result ZoneSettingHTTP3 `json:"result"` + Result HTTP3 `json:"result"` JSON settingHTTP3GetResponseEnvelopeJSON `json:"-"` } @@ -292,49 +228,3 @@ func (r *SettingHTTP3GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) func (r settingHTTP3GetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingHTTP3GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP3GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingHTTP3GetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingHTTP3GetResponseEnvelopeErrors] -type settingHTTP3GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP3GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP3GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingHTTP3GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingHTTP3GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingHTTP3GetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingHTTP3GetResponseEnvelopeMessages] -type settingHTTP3GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingHTTP3GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingHTTP3GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingimageresizing.go b/zones/settingimageresizing.go index 32b041305ef..e400db1185c 100644 --- a/zones/settingimageresizing.go +++ b/zones/settingimageresizing.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewSettingImageResizingService(opts ...option.RequestOption) (r *SettingIma // images served through Cloudflare's network. Refer to the // [Image Resizing documentation](https://developers.cloudflare.com/images/) for // more information. -func (r *SettingImageResizingService) Edit(ctx context.Context, params SettingImageResizingEditParams, opts ...option.RequestOption) (res *ZoneSettingImageResizing, err error) { +func (r *SettingImageResizingService) Edit(ctx context.Context, params SettingImageResizingEditParams, opts ...option.RequestOption) (res *ImageResizing, err error) { opts = append(r.Options[:], opts...) var env SettingImageResizingEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/image_resizing", params.ZoneID) @@ -52,7 +53,7 @@ func (r *SettingImageResizingService) Edit(ctx context.Context, params SettingIm // images served through Cloudflare's network. Refer to the // [Image Resizing documentation](https://developers.cloudflare.com/images/) for // more information. -func (r *SettingImageResizingService) Get(ctx context.Context, query SettingImageResizingGetParams, opts ...option.RequestOption) (res *ZoneSettingImageResizing, err error) { +func (r *SettingImageResizingService) Get(ctx context.Context, query SettingImageResizingGetParams, opts ...option.RequestOption) (res *ImageResizing, err error) { opts = append(r.Options[:], opts...) var env SettingImageResizingGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/image_resizing", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingImageResizingService) Get(ctx context.Context, query SettingImag // images served through Cloudflare's network. Refer to the // [Image Resizing documentation](https://developers.cloudflare.com/images/) for // more information. -type ZoneSettingImageResizing struct { +type ImageResizing struct { // ID of the zone setting. - ID ZoneSettingImageResizingID `json:"id,required"` + ID ImageResizingID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingImageResizingValue `json:"value,required"` + Value ImageResizingValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingImageResizingEditable `json:"editable"` + Editable ImageResizingEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingImageResizingJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON imageResizingJSON `json:"-"` } -// zoneSettingImageResizingJSON contains the JSON metadata for the struct -// [ZoneSettingImageResizing] -type zoneSettingImageResizingJSON struct { +// imageResizingJSON contains the JSON metadata for the struct [ImageResizing] +type imageResizingJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,45 +92,41 @@ type zoneSettingImageResizingJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingImageResizing) UnmarshalJSON(data []byte) (err error) { +func (r *ImageResizing) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingImageResizingJSON) RawJSON() string { +func (r imageResizingJSON) RawJSON() string { return r.raw } -func (r ZoneSettingImageResizing) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingImageResizing) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingImageResizingID string +type ImageResizingID string const ( - ZoneSettingImageResizingIDImageResizing ZoneSettingImageResizingID = "image_resizing" + ImageResizingIDImageResizing ImageResizingID = "image_resizing" ) -func (r ZoneSettingImageResizingID) IsKnown() bool { +func (r ImageResizingID) IsKnown() bool { switch r { - case ZoneSettingImageResizingIDImageResizing: + case ImageResizingIDImageResizing: return true } return false } // Current value of the zone setting. -type ZoneSettingImageResizingValue string +type ImageResizingValue string const ( - ZoneSettingImageResizingValueOn ZoneSettingImageResizingValue = "on" - ZoneSettingImageResizingValueOff ZoneSettingImageResizingValue = "off" - ZoneSettingImageResizingValueOpen ZoneSettingImageResizingValue = "open" + ImageResizingValueOn ImageResizingValue = "on" + ImageResizingValueOff ImageResizingValue = "off" + ImageResizingValueOpen ImageResizingValue = "open" ) -func (r ZoneSettingImageResizingValue) IsKnown() bool { +func (r ImageResizingValue) IsKnown() bool { switch r { - case ZoneSettingImageResizingValueOn, ZoneSettingImageResizingValueOff, ZoneSettingImageResizingValueOpen: + case ImageResizingValueOn, ImageResizingValueOff, ImageResizingValueOpen: return true } return false @@ -138,16 +134,16 @@ func (r ZoneSettingImageResizingValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingImageResizingEditable bool +type ImageResizingEditable bool const ( - ZoneSettingImageResizingEditableTrue ZoneSettingImageResizingEditable = true - ZoneSettingImageResizingEditableFalse ZoneSettingImageResizingEditable = false + ImageResizingEditableTrue ImageResizingEditable = true + ImageResizingEditableFalse ImageResizingEditable = false ) -func (r ZoneSettingImageResizingEditable) IsKnown() bool { +func (r ImageResizingEditable) IsKnown() bool { switch r { - case ZoneSettingImageResizingEditableTrue, ZoneSettingImageResizingEditableFalse: + case ImageResizingEditableTrue, ImageResizingEditableFalse: return true } return false @@ -157,19 +153,17 @@ func (r ZoneSettingImageResizingEditable) IsKnown() bool { // images served through Cloudflare's network. Refer to the // [Image Resizing documentation](https://developers.cloudflare.com/images/) for // more information. -type ZoneSettingImageResizingParam struct { +type ImageResizingParam struct { // ID of the zone setting. - ID param.Field[ZoneSettingImageResizingID] `json:"id,required"` + ID param.Field[ImageResizingID] `json:"id,required"` // Current value of the zone setting. - Value param.Field[ZoneSettingImageResizingValue] `json:"value,required"` + Value param.Field[ImageResizingValue] `json:"value,required"` } -func (r ZoneSettingImageResizingParam) MarshalJSON() (data []byte, err error) { +func (r ImageResizingParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingImageResizingParam) implementsZonesSettingEditParamsItem() {} - type SettingImageResizingEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -177,7 +171,7 @@ type SettingImageResizingEditParams struct { // images served through Cloudflare's network. Refer to the // [Image Resizing documentation](https://developers.cloudflare.com/images/) for // more information. - Value param.Field[ZoneSettingImageResizingParam] `json:"value,required"` + Value param.Field[ImageResizingParam] `json:"value,required"` } func (r SettingImageResizingEditParams) MarshalJSON() (data []byte, err error) { @@ -185,15 +179,15 @@ func (r SettingImageResizingEditParams) MarshalJSON() (data []byte, err error) { } type SettingImageResizingEditResponseEnvelope struct { - Errors []SettingImageResizingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingImageResizingEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Image Resizing provides on-demand resizing, conversion and optimisation for // images served through Cloudflare's network. Refer to the // [Image Resizing documentation](https://developers.cloudflare.com/images/) for // more information. - Result ZoneSettingImageResizing `json:"result"` + Result ImageResizing `json:"result"` JSON settingImageResizingEditResponseEnvelopeJSON `json:"-"` } @@ -216,67 +210,21 @@ func (r settingImageResizingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingImageResizingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingImageResizingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingImageResizingEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingImageResizingEditResponseEnvelopeErrors] -type settingImageResizingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingImageResizingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingImageResizingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingImageResizingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingImageResizingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingImageResizingEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingImageResizingEditResponseEnvelopeMessages] -type settingImageResizingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingImageResizingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingImageResizingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingImageResizingGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingImageResizingGetResponseEnvelope struct { - Errors []SettingImageResizingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingImageResizingGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Image Resizing provides on-demand resizing, conversion and optimisation for // images served through Cloudflare's network. Refer to the // [Image Resizing documentation](https://developers.cloudflare.com/images/) for // more information. - Result ZoneSettingImageResizing `json:"result"` + Result ImageResizing `json:"result"` JSON settingImageResizingGetResponseEnvelopeJSON `json:"-"` } @@ -298,49 +246,3 @@ func (r *SettingImageResizingGetResponseEnvelope) UnmarshalJSON(data []byte) (er func (r settingImageResizingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingImageResizingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingImageResizingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingImageResizingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingImageResizingGetResponseEnvelopeErrors] -type settingImageResizingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingImageResizingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingImageResizingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingImageResizingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingImageResizingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingImageResizingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingImageResizingGetResponseEnvelopeMessages] -type settingImageResizingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingImageResizingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingImageResizingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingimageresizing_test.go b/zones/settingimageresizing_test.go index 9a04ac0c72c..d3a8470bb9d 100644 --- a/zones/settingimageresizing_test.go +++ b/zones/settingimageresizing_test.go @@ -30,9 +30,9 @@ func TestSettingImageResizingEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.ImageResizing.Edit(context.TODO(), zones.SettingImageResizingEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingImageResizingParam{ - ID: cloudflare.F(zones.ZoneSettingImageResizingIDImageResizing), - Value: cloudflare.F(zones.ZoneSettingImageResizingValueOn), + Value: cloudflare.F(zones.ImageResizingParam{ + ID: cloudflare.F(zones.ImageResizingIDImageResizing), + Value: cloudflare.F(zones.ImageResizingValueOn), }), }) if err != nil { diff --git a/zones/settingipgeolocation.go b/zones/settingipgeolocation.go index c9cdfa5714e..848d34bcc80 100644 --- a/zones/settingipgeolocation.go +++ b/zones/settingipgeolocation.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingIPGeolocationService(opts ...option.RequestOption) (r *SettingIPG // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and // pass the country code to you. // (https://support.cloudflare.com/hc/en-us/articles/200168236). -func (r *SettingIPGeolocationService) Edit(ctx context.Context, params SettingIPGeolocationEditParams, opts ...option.RequestOption) (res *ZoneSettingIPGeolocation, err error) { +func (r *SettingIPGeolocationService) Edit(ctx context.Context, params SettingIPGeolocationEditParams, opts ...option.RequestOption) (res *IPGeolocation, err error) { opts = append(r.Options[:], opts...) var env SettingIPGeolocationEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ip_geolocation", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingIPGeolocationService) Edit(ctx context.Context, params SettingIP // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and // pass the country code to you. // (https://support.cloudflare.com/hc/en-us/articles/200168236). -func (r *SettingIPGeolocationService) Get(ctx context.Context, query SettingIPGeolocationGetParams, opts ...option.RequestOption) (res *ZoneSettingIPGeolocation, err error) { +func (r *SettingIPGeolocationService) Get(ctx context.Context, query SettingIPGeolocationGetParams, opts ...option.RequestOption) (res *IPGeolocation, err error) { opts = append(r.Options[:], opts...) var env SettingIPGeolocationGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ip_geolocation", query.ZoneID) @@ -65,22 +66,21 @@ func (r *SettingIPGeolocationService) Get(ctx context.Context, query SettingIPGe // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and // pass the country code to you. // (https://support.cloudflare.com/hc/en-us/articles/200168236). -type ZoneSettingIPGeolocation struct { +type IPGeolocation struct { // ID of the zone setting. - ID ZoneSettingIPGeolocationID `json:"id,required"` + ID IPGeolocationID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingIPGeolocationValue `json:"value,required"` + Value IPGeolocationValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingIPGeolocationEditable `json:"editable"` + Editable IPGeolocationEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingIPGeolocationJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON ipGeolocationJSON `json:"-"` } -// zoneSettingIPGeolocationJSON contains the JSON metadata for the struct -// [ZoneSettingIPGeolocation] -type zoneSettingIPGeolocationJSON struct { +// ipGeolocationJSON contains the JSON metadata for the struct [IPGeolocation] +type ipGeolocationJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -89,44 +89,40 @@ type zoneSettingIPGeolocationJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingIPGeolocation) UnmarshalJSON(data []byte) (err error) { +func (r *IPGeolocation) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingIPGeolocationJSON) RawJSON() string { +func (r ipGeolocationJSON) RawJSON() string { return r.raw } -func (r ZoneSettingIPGeolocation) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingIPGeolocation) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingIPGeolocationID string +type IPGeolocationID string const ( - ZoneSettingIPGeolocationIDIPGeolocation ZoneSettingIPGeolocationID = "ip_geolocation" + IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation" ) -func (r ZoneSettingIPGeolocationID) IsKnown() bool { +func (r IPGeolocationID) IsKnown() bool { switch r { - case ZoneSettingIPGeolocationIDIPGeolocation: + case IPGeolocationIDIPGeolocation: return true } return false } // Current value of the zone setting. -type ZoneSettingIPGeolocationValue string +type IPGeolocationValue string const ( - ZoneSettingIPGeolocationValueOn ZoneSettingIPGeolocationValue = "on" - ZoneSettingIPGeolocationValueOff ZoneSettingIPGeolocationValue = "off" + IPGeolocationValueOn IPGeolocationValue = "on" + IPGeolocationValueOff IPGeolocationValue = "off" ) -func (r ZoneSettingIPGeolocationValue) IsKnown() bool { +func (r IPGeolocationValue) IsKnown() bool { switch r { - case ZoneSettingIPGeolocationValueOn, ZoneSettingIPGeolocationValueOff: + case IPGeolocationValueOn, IPGeolocationValueOff: return true } return false @@ -134,37 +130,21 @@ func (r ZoneSettingIPGeolocationValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingIPGeolocationEditable bool +type IPGeolocationEditable bool const ( - ZoneSettingIPGeolocationEditableTrue ZoneSettingIPGeolocationEditable = true - ZoneSettingIPGeolocationEditableFalse ZoneSettingIPGeolocationEditable = false + IPGeolocationEditableTrue IPGeolocationEditable = true + IPGeolocationEditableFalse IPGeolocationEditable = false ) -func (r ZoneSettingIPGeolocationEditable) IsKnown() bool { +func (r IPGeolocationEditable) IsKnown() bool { switch r { - case ZoneSettingIPGeolocationEditableTrue, ZoneSettingIPGeolocationEditableFalse: + case IPGeolocationEditableTrue, IPGeolocationEditableFalse: return true } return false } -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -type ZoneSettingIPGeolocationParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingIPGeolocationID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingIPGeolocationValue] `json:"value,required"` -} - -func (r ZoneSettingIPGeolocationParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingIPGeolocationParam) implementsZonesSettingEditParamsItem() {} - type SettingIPGeolocationEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -193,14 +173,14 @@ func (r SettingIPGeolocationEditParamsValue) IsKnown() bool { } type SettingIPGeolocationEditResponseEnvelope struct { - Errors []SettingIPGeolocationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingIPGeolocationEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and // pass the country code to you. // (https://support.cloudflare.com/hc/en-us/articles/200168236). - Result ZoneSettingIPGeolocation `json:"result"` + Result IPGeolocation `json:"result"` JSON settingIPGeolocationEditResponseEnvelopeJSON `json:"-"` } @@ -223,66 +203,20 @@ func (r settingIPGeolocationEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingIPGeolocationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPGeolocationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingIPGeolocationEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingIPGeolocationEditResponseEnvelopeErrors] -type settingIPGeolocationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPGeolocationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPGeolocationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingIPGeolocationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPGeolocationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingIPGeolocationEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingIPGeolocationEditResponseEnvelopeMessages] -type settingIPGeolocationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPGeolocationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPGeolocationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingIPGeolocationGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingIPGeolocationGetResponseEnvelope struct { - Errors []SettingIPGeolocationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingIPGeolocationGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and // pass the country code to you. // (https://support.cloudflare.com/hc/en-us/articles/200168236). - Result ZoneSettingIPGeolocation `json:"result"` + Result IPGeolocation `json:"result"` JSON settingIPGeolocationGetResponseEnvelopeJSON `json:"-"` } @@ -304,49 +238,3 @@ func (r *SettingIPGeolocationGetResponseEnvelope) UnmarshalJSON(data []byte) (er func (r settingIPGeolocationGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingIPGeolocationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPGeolocationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingIPGeolocationGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingIPGeolocationGetResponseEnvelopeErrors] -type settingIPGeolocationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPGeolocationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPGeolocationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingIPGeolocationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPGeolocationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingIPGeolocationGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingIPGeolocationGetResponseEnvelopeMessages] -type settingIPGeolocationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPGeolocationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPGeolocationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingipv6.go b/zones/settingipv6.go index 5a0724f24c6..6e8457b5194 100644 --- a/zones/settingipv6.go +++ b/zones/settingipv6.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingIPV6Service(opts ...option.RequestOption) (r *SettingIPV6Service) // Enable IPv6 on all subdomains that are Cloudflare enabled. // (https://support.cloudflare.com/hc/en-us/articles/200168586). -func (r *SettingIPV6Service) Edit(ctx context.Context, params SettingIPV6EditParams, opts ...option.RequestOption) (res *ZoneSettingIPV6, err error) { +func (r *SettingIPV6Service) Edit(ctx context.Context, params SettingIPV6EditParams, opts ...option.RequestOption) (res *IPV6, err error) { opts = append(r.Options[:], opts...) var env SettingIPV6EditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ipv6", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingIPV6Service) Edit(ctx context.Context, params SettingIPV6EditPar // Enable IPv6 on all subdomains that are Cloudflare enabled. // (https://support.cloudflare.com/hc/en-us/articles/200168586). -func (r *SettingIPV6Service) Get(ctx context.Context, query SettingIPV6GetParams, opts ...option.RequestOption) (res *ZoneSettingIPV6, err error) { +func (r *SettingIPV6Service) Get(ctx context.Context, query SettingIPV6GetParams, opts ...option.RequestOption) (res *IPV6, err error) { opts = append(r.Options[:], opts...) var env SettingIPV6GetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ipv6", query.ZoneID) @@ -62,21 +63,21 @@ func (r *SettingIPV6Service) Get(ctx context.Context, query SettingIPV6GetParams // Enable IPv6 on all subdomains that are Cloudflare enabled. // (https://support.cloudflare.com/hc/en-us/articles/200168586). -type ZoneSettingIPV6 struct { +type IPV6 struct { // ID of the zone setting. - ID ZoneSettingIPV6ID `json:"id,required"` + ID IPV6ID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingIPV6Value `json:"value,required"` + Value IPV6Value `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingIPV6Editable `json:"editable"` + Editable IPV6Editable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingIPV6JSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON ipv6JSON `json:"-"` } -// zoneSettingIPV6JSON contains the JSON metadata for the struct [ZoneSettingIPV6] -type zoneSettingIPV6JSON struct { +// ipv6JSON contains the JSON metadata for the struct [IPV6] +type ipv6JSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -85,44 +86,40 @@ type zoneSettingIPV6JSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingIPV6) UnmarshalJSON(data []byte) (err error) { +func (r *IPV6) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingIPV6JSON) RawJSON() string { +func (r ipv6JSON) RawJSON() string { return r.raw } -func (r ZoneSettingIPV6) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingIPV6) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingIPV6ID string +type IPV6ID string const ( - ZoneSettingIPV6IDIPV6 ZoneSettingIPV6ID = "ipv6" + IPV6IDIPV6 IPV6ID = "ipv6" ) -func (r ZoneSettingIPV6ID) IsKnown() bool { +func (r IPV6ID) IsKnown() bool { switch r { - case ZoneSettingIPV6IDIPV6: + case IPV6IDIPV6: return true } return false } // Current value of the zone setting. -type ZoneSettingIPV6Value string +type IPV6Value string const ( - ZoneSettingIPV6ValueOff ZoneSettingIPV6Value = "off" - ZoneSettingIPV6ValueOn ZoneSettingIPV6Value = "on" + IPV6ValueOff IPV6Value = "off" + IPV6ValueOn IPV6Value = "on" ) -func (r ZoneSettingIPV6Value) IsKnown() bool { +func (r IPV6Value) IsKnown() bool { switch r { - case ZoneSettingIPV6ValueOff, ZoneSettingIPV6ValueOn: + case IPV6ValueOff, IPV6ValueOn: return true } return false @@ -130,36 +127,21 @@ func (r ZoneSettingIPV6Value) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingIPV6Editable bool +type IPV6Editable bool const ( - ZoneSettingIPV6EditableTrue ZoneSettingIPV6Editable = true - ZoneSettingIPV6EditableFalse ZoneSettingIPV6Editable = false + IPV6EditableTrue IPV6Editable = true + IPV6EditableFalse IPV6Editable = false ) -func (r ZoneSettingIPV6Editable) IsKnown() bool { +func (r IPV6Editable) IsKnown() bool { switch r { - case ZoneSettingIPV6EditableTrue, ZoneSettingIPV6EditableFalse: + case IPV6EditableTrue, IPV6EditableFalse: return true } return false } -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -type ZoneSettingIPV6Param struct { - // ID of the zone setting. - ID param.Field[ZoneSettingIPV6ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingIPV6Value] `json:"value,required"` -} - -func (r ZoneSettingIPV6Param) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingIPV6Param) implementsZonesSettingEditParamsItem() {} - type SettingIPV6EditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -188,13 +170,13 @@ func (r SettingIPV6EditParamsValue) IsKnown() bool { } type SettingIPV6EditResponseEnvelope struct { - Errors []SettingIPV6EditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingIPV6EditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable IPv6 on all subdomains that are Cloudflare enabled. // (https://support.cloudflare.com/hc/en-us/articles/200168586). - Result ZoneSettingIPV6 `json:"result"` + Result IPV6 `json:"result"` JSON settingIPV6EditResponseEnvelopeJSON `json:"-"` } @@ -217,65 +199,19 @@ func (r settingIPV6EditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingIPV6EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPV6EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingIPV6EditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingIPV6EditResponseEnvelopeErrors] -type settingIPV6EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPV6EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPV6EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingIPV6EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPV6EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingIPV6EditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingIPV6EditResponseEnvelopeMessages] -type settingIPV6EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPV6EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPV6EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingIPV6GetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingIPV6GetResponseEnvelope struct { - Errors []SettingIPV6GetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingIPV6GetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable IPv6 on all subdomains that are Cloudflare enabled. // (https://support.cloudflare.com/hc/en-us/articles/200168586). - Result ZoneSettingIPV6 `json:"result"` + Result IPV6 `json:"result"` JSON settingIPV6GetResponseEnvelopeJSON `json:"-"` } @@ -297,49 +233,3 @@ func (r *SettingIPV6GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) func (r settingIPV6GetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingIPV6GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPV6GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingIPV6GetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingIPV6GetResponseEnvelopeErrors] -type settingIPV6GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPV6GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPV6GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingIPV6GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingIPV6GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingIPV6GetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingIPV6GetResponseEnvelopeMessages] -type settingIPV6GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingIPV6GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingIPV6GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingminify.go b/zones/settingminify.go index 7e337fcbccb..444f491c30a 100644 --- a/zones/settingminify.go +++ b/zones/settingminify.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingMinifyService(opts ...option.RequestOption) (r *SettingMinifyServ // Automatically minify certain assets for your website. Refer to // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) // for more information. -func (r *SettingMinifyService) Edit(ctx context.Context, params SettingMinifyEditParams, opts ...option.RequestOption) (res *ZoneSettingMinify, err error) { +func (r *SettingMinifyService) Edit(ctx context.Context, params SettingMinifyEditParams, opts ...option.RequestOption) (res *Minify, err error) { opts = append(r.Options[:], opts...) var env SettingMinifyEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/minify", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingMinifyService) Edit(ctx context.Context, params SettingMinifyEdi // Automatically minify certain assets for your website. Refer to // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) // for more information. -func (r *SettingMinifyService) Get(ctx context.Context, query SettingMinifyGetParams, opts ...option.RequestOption) (res *ZoneSettingMinify, err error) { +func (r *SettingMinifyService) Get(ctx context.Context, query SettingMinifyGetParams, opts ...option.RequestOption) (res *Minify, err error) { opts = append(r.Options[:], opts...) var env SettingMinifyGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/minify", query.ZoneID) @@ -65,22 +66,21 @@ func (r *SettingMinifyService) Get(ctx context.Context, query SettingMinifyGetPa // Automatically minify certain assets for your website. Refer to // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) // for more information. -type ZoneSettingMinify struct { +type Minify struct { // Zone setting identifier. - ID ZoneSettingMinifyID `json:"id,required"` + ID MinifyID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingMinifyValue `json:"value,required"` + Value MinifyValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingMinifyEditable `json:"editable"` + Editable MinifyEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMinifyJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON minifyJSON `json:"-"` } -// zoneSettingMinifyJSON contains the JSON metadata for the struct -// [ZoneSettingMinify] -type zoneSettingMinifyJSON struct { +// minifyJSON contains the JSON metadata for the struct [Minify] +type minifyJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -89,105 +89,100 @@ type zoneSettingMinifyJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingMinify) UnmarshalJSON(data []byte) (err error) { +func (r *Minify) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingMinifyJSON) RawJSON() string { +func (r minifyJSON) RawJSON() string { return r.raw } -func (r ZoneSettingMinify) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingMinify) implementsZonesSettingGetResponse() {} - // Zone setting identifier. -type ZoneSettingMinifyID string +type MinifyID string const ( - ZoneSettingMinifyIDMinify ZoneSettingMinifyID = "minify" + MinifyIDMinify MinifyID = "minify" ) -func (r ZoneSettingMinifyID) IsKnown() bool { +func (r MinifyID) IsKnown() bool { switch r { - case ZoneSettingMinifyIDMinify: + case MinifyIDMinify: return true } return false } // Current value of the zone setting. -type ZoneSettingMinifyValue struct { +type MinifyValue struct { // Automatically minify all CSS files for your website. - Css ZoneSettingMinifyValueCss `json:"css"` + Css MinifyValueCss `json:"css"` // Automatically minify all HTML files for your website. - HTML ZoneSettingMinifyValueHTML `json:"html"` + HTML MinifyValueHTML `json:"html"` // Automatically minify all JavaScript files for your website. - Js ZoneSettingMinifyValueJs `json:"js"` - JSON zoneSettingMinifyValueJSON `json:"-"` + JS MinifyValueJS `json:"js"` + JSON minifyValueJSON `json:"-"` } -// zoneSettingMinifyValueJSON contains the JSON metadata for the struct -// [ZoneSettingMinifyValue] -type zoneSettingMinifyValueJSON struct { +// minifyValueJSON contains the JSON metadata for the struct [MinifyValue] +type minifyValueJSON struct { Css apijson.Field HTML apijson.Field - Js apijson.Field + JS apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZoneSettingMinifyValue) UnmarshalJSON(data []byte) (err error) { +func (r *MinifyValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingMinifyValueJSON) RawJSON() string { +func (r minifyValueJSON) RawJSON() string { return r.raw } // Automatically minify all CSS files for your website. -type ZoneSettingMinifyValueCss string +type MinifyValueCss string const ( - ZoneSettingMinifyValueCssOn ZoneSettingMinifyValueCss = "on" - ZoneSettingMinifyValueCssOff ZoneSettingMinifyValueCss = "off" + MinifyValueCssOn MinifyValueCss = "on" + MinifyValueCssOff MinifyValueCss = "off" ) -func (r ZoneSettingMinifyValueCss) IsKnown() bool { +func (r MinifyValueCss) IsKnown() bool { switch r { - case ZoneSettingMinifyValueCssOn, ZoneSettingMinifyValueCssOff: + case MinifyValueCssOn, MinifyValueCssOff: return true } return false } // Automatically minify all HTML files for your website. -type ZoneSettingMinifyValueHTML string +type MinifyValueHTML string const ( - ZoneSettingMinifyValueHTMLOn ZoneSettingMinifyValueHTML = "on" - ZoneSettingMinifyValueHTMLOff ZoneSettingMinifyValueHTML = "off" + MinifyValueHTMLOn MinifyValueHTML = "on" + MinifyValueHTMLOff MinifyValueHTML = "off" ) -func (r ZoneSettingMinifyValueHTML) IsKnown() bool { +func (r MinifyValueHTML) IsKnown() bool { switch r { - case ZoneSettingMinifyValueHTMLOn, ZoneSettingMinifyValueHTMLOff: + case MinifyValueHTMLOn, MinifyValueHTMLOff: return true } return false } // Automatically minify all JavaScript files for your website. -type ZoneSettingMinifyValueJs string +type MinifyValueJS string const ( - ZoneSettingMinifyValueJsOn ZoneSettingMinifyValueJs = "on" - ZoneSettingMinifyValueJsOff ZoneSettingMinifyValueJs = "off" + MinifyValueJSOn MinifyValueJS = "on" + MinifyValueJSOff MinifyValueJS = "off" ) -func (r ZoneSettingMinifyValueJs) IsKnown() bool { +func (r MinifyValueJS) IsKnown() bool { switch r { - case ZoneSettingMinifyValueJsOn, ZoneSettingMinifyValueJsOff: + case MinifyValueJSOn, MinifyValueJSOff: return true } return false @@ -195,51 +190,21 @@ func (r ZoneSettingMinifyValueJs) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingMinifyEditable bool +type MinifyEditable bool const ( - ZoneSettingMinifyEditableTrue ZoneSettingMinifyEditable = true - ZoneSettingMinifyEditableFalse ZoneSettingMinifyEditable = false + MinifyEditableTrue MinifyEditable = true + MinifyEditableFalse MinifyEditable = false ) -func (r ZoneSettingMinifyEditable) IsKnown() bool { +func (r MinifyEditable) IsKnown() bool { switch r { - case ZoneSettingMinifyEditableTrue, ZoneSettingMinifyEditableFalse: + case MinifyEditableTrue, MinifyEditableFalse: return true } return false } -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -type ZoneSettingMinifyParam struct { - // Zone setting identifier. - ID param.Field[ZoneSettingMinifyID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingMinifyValueParam] `json:"value,required"` -} - -func (r ZoneSettingMinifyParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingMinifyParam) implementsZonesSettingEditParamsItem() {} - -// Current value of the zone setting. -type ZoneSettingMinifyValueParam struct { - // Automatically minify all CSS files for your website. - Css param.Field[ZoneSettingMinifyValueCss] `json:"css"` - // Automatically minify all HTML files for your website. - HTML param.Field[ZoneSettingMinifyValueHTML] `json:"html"` - // Automatically minify all JavaScript files for your website. - Js param.Field[ZoneSettingMinifyValueJs] `json:"js"` -} - -func (r ZoneSettingMinifyValueParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SettingMinifyEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -258,7 +223,7 @@ type SettingMinifyEditParamsValue struct { // Automatically minify all HTML files for your website. HTML param.Field[SettingMinifyEditParamsValueHTML] `json:"html"` // Automatically minify all JavaScript files for your website. - Js param.Field[SettingMinifyEditParamsValueJs] `json:"js"` + JS param.Field[SettingMinifyEditParamsValueJS] `json:"js"` } func (r SettingMinifyEditParamsValue) MarshalJSON() (data []byte, err error) { @@ -298,30 +263,30 @@ func (r SettingMinifyEditParamsValueHTML) IsKnown() bool { } // Automatically minify all JavaScript files for your website. -type SettingMinifyEditParamsValueJs string +type SettingMinifyEditParamsValueJS string const ( - SettingMinifyEditParamsValueJsOn SettingMinifyEditParamsValueJs = "on" - SettingMinifyEditParamsValueJsOff SettingMinifyEditParamsValueJs = "off" + SettingMinifyEditParamsValueJSOn SettingMinifyEditParamsValueJS = "on" + SettingMinifyEditParamsValueJSOff SettingMinifyEditParamsValueJS = "off" ) -func (r SettingMinifyEditParamsValueJs) IsKnown() bool { +func (r SettingMinifyEditParamsValueJS) IsKnown() bool { switch r { - case SettingMinifyEditParamsValueJsOn, SettingMinifyEditParamsValueJsOff: + case SettingMinifyEditParamsValueJSOn, SettingMinifyEditParamsValueJSOff: return true } return false } type SettingMinifyEditResponseEnvelope struct { - Errors []SettingMinifyEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMinifyEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Automatically minify certain assets for your website. Refer to // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) // for more information. - Result ZoneSettingMinify `json:"result"` + Result Minify `json:"result"` JSON settingMinifyEditResponseEnvelopeJSON `json:"-"` } @@ -344,66 +309,20 @@ func (r settingMinifyEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingMinifyEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinifyEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMinifyEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingMinifyEditResponseEnvelopeErrors] -type settingMinifyEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinifyEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinifyEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMinifyEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinifyEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMinifyEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingMinifyEditResponseEnvelopeMessages] -type settingMinifyEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinifyEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinifyEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingMinifyGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingMinifyGetResponseEnvelope struct { - Errors []SettingMinifyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMinifyGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Automatically minify certain assets for your website. Refer to // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) // for more information. - Result ZoneSettingMinify `json:"result"` + Result Minify `json:"result"` JSON settingMinifyGetResponseEnvelopeJSON `json:"-"` } @@ -425,49 +344,3 @@ func (r *SettingMinifyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error func (r settingMinifyGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingMinifyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinifyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMinifyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingMinifyGetResponseEnvelopeErrors] -type settingMinifyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinifyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinifyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMinifyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinifyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMinifyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingMinifyGetResponseEnvelopeMessages] -type settingMinifyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinifyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinifyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingminify_test.go b/zones/settingminify_test.go index 28f2982ec2f..5443ea161d7 100644 --- a/zones/settingminify_test.go +++ b/zones/settingminify_test.go @@ -33,7 +33,7 @@ func TestSettingMinifyEditWithOptionalParams(t *testing.T) { Value: cloudflare.F(zones.SettingMinifyEditParamsValue{ Css: cloudflare.F(zones.SettingMinifyEditParamsValueCssOn), HTML: cloudflare.F(zones.SettingMinifyEditParamsValueHTMLOn), - Js: cloudflare.F(zones.SettingMinifyEditParamsValueJsOn), + JS: cloudflare.F(zones.SettingMinifyEditParamsValueJSOn), }), }) if err != nil { diff --git a/zones/settingmintlsversion.go b/zones/settingmintlsversion.go index 58ca0565fcd..09076d3eee4 100644 --- a/zones/settingmintlsversion.go +++ b/zones/settingmintlsversion.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingMinTLSVersionService(opts ...option.RequestOption) (r *SettingMin } // Changes Minimum TLS Version setting. -func (r *SettingMinTLSVersionService) Edit(ctx context.Context, params SettingMinTLSVersionEditParams, opts ...option.RequestOption) (res *ZoneSettingMinTLSVersion, err error) { +func (r *SettingMinTLSVersionService) Edit(ctx context.Context, params SettingMinTLSVersionEditParams, opts ...option.RequestOption) (res *MinTLSVersion, err error) { opts = append(r.Options[:], opts...) var env SettingMinTLSVersionEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/min_tls_version", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingMinTLSVersionService) Edit(ctx context.Context, params SettingMi } // Gets Minimum TLS Version setting. -func (r *SettingMinTLSVersionService) Get(ctx context.Context, query SettingMinTLSVersionGetParams, opts ...option.RequestOption) (res *ZoneSettingMinTLSVersion, err error) { +func (r *SettingMinTLSVersionService) Get(ctx context.Context, query SettingMinTLSVersionGetParams, opts ...option.RequestOption) (res *MinTLSVersion, err error) { opts = append(r.Options[:], opts...) var env SettingMinTLSVersionGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/min_tls_version", query.ZoneID) @@ -61,22 +62,21 @@ func (r *SettingMinTLSVersionService) Get(ctx context.Context, query SettingMinT // Only accepts HTTPS requests that use at least the TLS protocol version // specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be // rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. -type ZoneSettingMinTLSVersion struct { +type MinTLSVersion struct { // ID of the zone setting. - ID ZoneSettingMinTLSVersionID `json:"id,required"` + ID MinTLSVersionID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingMinTLSVersionValue `json:"value,required"` + Value MinTLSVersionValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingMinTLSVersionEditable `json:"editable"` + Editable MinTLSVersionEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMinTLSVersionJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON minTLSVersionJSON `json:"-"` } -// zoneSettingMinTLSVersionJSON contains the JSON metadata for the struct -// [ZoneSettingMinTLSVersion] -type zoneSettingMinTLSVersionJSON struct { +// minTLSVersionJSON contains the JSON metadata for the struct [MinTLSVersion] +type minTLSVersionJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -85,46 +85,42 @@ type zoneSettingMinTLSVersionJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingMinTLSVersion) UnmarshalJSON(data []byte) (err error) { +func (r *MinTLSVersion) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingMinTLSVersionJSON) RawJSON() string { +func (r minTLSVersionJSON) RawJSON() string { return r.raw } -func (r ZoneSettingMinTLSVersion) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingMinTLSVersion) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingMinTLSVersionID string +type MinTLSVersionID string const ( - ZoneSettingMinTLSVersionIDMinTLSVersion ZoneSettingMinTLSVersionID = "min_tls_version" + MinTLSVersionIDMinTLSVersion MinTLSVersionID = "min_tls_version" ) -func (r ZoneSettingMinTLSVersionID) IsKnown() bool { +func (r MinTLSVersionID) IsKnown() bool { switch r { - case ZoneSettingMinTLSVersionIDMinTLSVersion: + case MinTLSVersionIDMinTLSVersion: return true } return false } // Current value of the zone setting. -type ZoneSettingMinTLSVersionValue string +type MinTLSVersionValue string const ( - ZoneSettingMinTLSVersionValue1_0 ZoneSettingMinTLSVersionValue = "1.0" - ZoneSettingMinTLSVersionValue1_1 ZoneSettingMinTLSVersionValue = "1.1" - ZoneSettingMinTLSVersionValue1_2 ZoneSettingMinTLSVersionValue = "1.2" - ZoneSettingMinTLSVersionValue1_3 ZoneSettingMinTLSVersionValue = "1.3" + MinTLSVersionValue1_0 MinTLSVersionValue = "1.0" + MinTLSVersionValue1_1 MinTLSVersionValue = "1.1" + MinTLSVersionValue1_2 MinTLSVersionValue = "1.2" + MinTLSVersionValue1_3 MinTLSVersionValue = "1.3" ) -func (r ZoneSettingMinTLSVersionValue) IsKnown() bool { +func (r MinTLSVersionValue) IsKnown() bool { switch r { - case ZoneSettingMinTLSVersionValue1_0, ZoneSettingMinTLSVersionValue1_1, ZoneSettingMinTLSVersionValue1_2, ZoneSettingMinTLSVersionValue1_3: + case MinTLSVersionValue1_0, MinTLSVersionValue1_1, MinTLSVersionValue1_2, MinTLSVersionValue1_3: return true } return false @@ -132,37 +128,21 @@ func (r ZoneSettingMinTLSVersionValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingMinTLSVersionEditable bool +type MinTLSVersionEditable bool const ( - ZoneSettingMinTLSVersionEditableTrue ZoneSettingMinTLSVersionEditable = true - ZoneSettingMinTLSVersionEditableFalse ZoneSettingMinTLSVersionEditable = false + MinTLSVersionEditableTrue MinTLSVersionEditable = true + MinTLSVersionEditableFalse MinTLSVersionEditable = false ) -func (r ZoneSettingMinTLSVersionEditable) IsKnown() bool { +func (r MinTLSVersionEditable) IsKnown() bool { switch r { - case ZoneSettingMinTLSVersionEditableTrue, ZoneSettingMinTLSVersionEditableFalse: + case MinTLSVersionEditableTrue, MinTLSVersionEditableFalse: return true } return false } -// Only accepts HTTPS requests that use at least the TLS protocol version -// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be -// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. -type ZoneSettingMinTLSVersionParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingMinTLSVersionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingMinTLSVersionValue] `json:"value,required"` -} - -func (r ZoneSettingMinTLSVersionParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingMinTLSVersionParam) implementsZonesSettingEditParamsItem() {} - type SettingMinTLSVersionEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -193,14 +173,14 @@ func (r SettingMinTLSVersionEditParamsValue) IsKnown() bool { } type SettingMinTLSVersionEditResponseEnvelope struct { - Errors []SettingMinTLSVersionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMinTLSVersionEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Only accepts HTTPS requests that use at least the TLS protocol version // specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be // rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. - Result ZoneSettingMinTLSVersion `json:"result"` + Result MinTLSVersion `json:"result"` JSON settingMinTLSVersionEditResponseEnvelopeJSON `json:"-"` } @@ -223,66 +203,20 @@ func (r settingMinTLSVersionEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingMinTLSVersionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinTLSVersionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMinTLSVersionEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingMinTLSVersionEditResponseEnvelopeErrors] -type settingMinTLSVersionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinTLSVersionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinTLSVersionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMinTLSVersionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinTLSVersionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMinTLSVersionEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingMinTLSVersionEditResponseEnvelopeMessages] -type settingMinTLSVersionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinTLSVersionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinTLSVersionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingMinTLSVersionGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingMinTLSVersionGetResponseEnvelope struct { - Errors []SettingMinTLSVersionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMinTLSVersionGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Only accepts HTTPS requests that use at least the TLS protocol version // specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be // rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. - Result ZoneSettingMinTLSVersion `json:"result"` + Result MinTLSVersion `json:"result"` JSON settingMinTLSVersionGetResponseEnvelopeJSON `json:"-"` } @@ -304,49 +238,3 @@ func (r *SettingMinTLSVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (er func (r settingMinTLSVersionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingMinTLSVersionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinTLSVersionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMinTLSVersionGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingMinTLSVersionGetResponseEnvelopeErrors] -type settingMinTLSVersionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinTLSVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinTLSVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMinTLSVersionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMinTLSVersionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMinTLSVersionGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingMinTLSVersionGetResponseEnvelopeMessages] -type settingMinTLSVersionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMinTLSVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMinTLSVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingmirage.go b/zones/settingmirage.go index 014ff64f100..8e9997ae326 100644 --- a/zones/settingmirage.go +++ b/zones/settingmirage.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewSettingMirageService(opts ...option.RequestOption) (r *SettingMirageServ // Refer to our // [blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for more // information. -func (r *SettingMirageService) Edit(ctx context.Context, params SettingMirageEditParams, opts ...option.RequestOption) (res *ZoneSettingMirage, err error) { +func (r *SettingMirageService) Edit(ctx context.Context, params SettingMirageEditParams, opts ...option.RequestOption) (res *Mirage, err error) { opts = append(r.Options[:], opts...) var env SettingMirageEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/mirage", params.ZoneID) @@ -52,7 +53,7 @@ func (r *SettingMirageService) Edit(ctx context.Context, params SettingMirageEdi // Refer to our // [blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for more // information. -func (r *SettingMirageService) Get(ctx context.Context, query SettingMirageGetParams, opts ...option.RequestOption) (res *ZoneSettingMirage, err error) { +func (r *SettingMirageService) Get(ctx context.Context, query SettingMirageGetParams, opts ...option.RequestOption) (res *Mirage, err error) { opts = append(r.Options[:], opts...) var env SettingMirageGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/mirage", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingMirageService) Get(ctx context.Context, query SettingMirageGetPa // Refer to // [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for // more information. -type ZoneSettingMirage struct { +type Mirage struct { // ID of the zone setting. - ID ZoneSettingMirageID `json:"id,required"` + ID MirageID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingMirageValue `json:"value,required"` + Value MirageValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingMirageEditable `json:"editable"` + Editable MirageEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMirageJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON mirageJSON `json:"-"` } -// zoneSettingMirageJSON contains the JSON metadata for the struct -// [ZoneSettingMirage] -type zoneSettingMirageJSON struct { +// mirageJSON contains the JSON metadata for the struct [Mirage] +type mirageJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,44 +92,40 @@ type zoneSettingMirageJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingMirage) UnmarshalJSON(data []byte) (err error) { +func (r *Mirage) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingMirageJSON) RawJSON() string { +func (r mirageJSON) RawJSON() string { return r.raw } -func (r ZoneSettingMirage) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingMirage) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingMirageID string +type MirageID string const ( - ZoneSettingMirageIDMirage ZoneSettingMirageID = "mirage" + MirageIDMirage MirageID = "mirage" ) -func (r ZoneSettingMirageID) IsKnown() bool { +func (r MirageID) IsKnown() bool { switch r { - case ZoneSettingMirageIDMirage: + case MirageIDMirage: return true } return false } // Current value of the zone setting. -type ZoneSettingMirageValue string +type MirageValue string const ( - ZoneSettingMirageValueOn ZoneSettingMirageValue = "on" - ZoneSettingMirageValueOff ZoneSettingMirageValue = "off" + MirageValueOn MirageValue = "on" + MirageValueOff MirageValue = "off" ) -func (r ZoneSettingMirageValue) IsKnown() bool { +func (r MirageValue) IsKnown() bool { switch r { - case ZoneSettingMirageValueOn, ZoneSettingMirageValueOff: + case MirageValueOn, MirageValueOff: return true } return false @@ -137,38 +133,21 @@ func (r ZoneSettingMirageValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingMirageEditable bool +type MirageEditable bool const ( - ZoneSettingMirageEditableTrue ZoneSettingMirageEditable = true - ZoneSettingMirageEditableFalse ZoneSettingMirageEditable = false + MirageEditableTrue MirageEditable = true + MirageEditableFalse MirageEditable = false ) -func (r ZoneSettingMirageEditable) IsKnown() bool { +func (r MirageEditable) IsKnown() bool { switch r { - case ZoneSettingMirageEditableTrue, ZoneSettingMirageEditableFalse: + case MirageEditableTrue, MirageEditableFalse: return true } return false } -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to -// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for -// more information. -type ZoneSettingMirageParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingMirageID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingMirageValue] `json:"value,required"` -} - -func (r ZoneSettingMirageParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingMirageParam) implementsZonesSettingEditParamsItem() {} - type SettingMirageEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -197,15 +176,15 @@ func (r SettingMirageEditParamsValue) IsKnown() bool { } type SettingMirageEditResponseEnvelope struct { - Errors []SettingMirageEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMirageEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Automatically optimize image loading for website visitors on mobile devices. // Refer to // [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for // more information. - Result ZoneSettingMirage `json:"result"` + Result Mirage `json:"result"` JSON settingMirageEditResponseEnvelopeJSON `json:"-"` } @@ -228,67 +207,21 @@ func (r settingMirageEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingMirageEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMirageEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMirageEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingMirageEditResponseEnvelopeErrors] -type settingMirageEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMirageEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMirageEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMirageEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMirageEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMirageEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingMirageEditResponseEnvelopeMessages] -type settingMirageEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMirageEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMirageEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingMirageGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingMirageGetResponseEnvelope struct { - Errors []SettingMirageGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMirageGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Automatically optimize image loading for website visitors on mobile devices. // Refer to // [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for // more information. - Result ZoneSettingMirage `json:"result"` + Result Mirage `json:"result"` JSON settingMirageGetResponseEnvelopeJSON `json:"-"` } @@ -310,49 +243,3 @@ func (r *SettingMirageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error func (r settingMirageGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingMirageGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMirageGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMirageGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingMirageGetResponseEnvelopeErrors] -type settingMirageGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMirageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMirageGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMirageGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMirageGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMirageGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingMirageGetResponseEnvelopeMessages] -type settingMirageGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMirageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMirageGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingmobileredirect.go b/zones/settingmobileredirect.go index 46fe670740d..e6d1fbde6ef 100644 --- a/zones/settingmobileredirect.go +++ b/zones/settingmobileredirect.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewSettingMobileRedirectService(opts ...option.RequestOption) (r *SettingMo // subdomain. Refer to // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) // for more information. -func (r *SettingMobileRedirectService) Edit(ctx context.Context, params SettingMobileRedirectEditParams, opts ...option.RequestOption) (res *ZoneSettingMobileRedirect, err error) { +func (r *SettingMobileRedirectService) Edit(ctx context.Context, params SettingMobileRedirectEditParams, opts ...option.RequestOption) (res *MobileRedirect, err error) { opts = append(r.Options[:], opts...) var env SettingMobileRedirectEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/mobile_redirect", params.ZoneID) @@ -52,7 +53,7 @@ func (r *SettingMobileRedirectService) Edit(ctx context.Context, params SettingM // subdomain. Refer to // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) // for more information. -func (r *SettingMobileRedirectService) Get(ctx context.Context, query SettingMobileRedirectGetParams, opts ...option.RequestOption) (res *ZoneSettingMobileRedirect, err error) { +func (r *SettingMobileRedirectService) Get(ctx context.Context, query SettingMobileRedirectGetParams, opts ...option.RequestOption) (res *MobileRedirect, err error) { opts = append(r.Options[:], opts...) var env SettingMobileRedirectGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/mobile_redirect", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingMobileRedirectService) Get(ctx context.Context, query SettingMob // subdomain. Refer to // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) // for more information. -type ZoneSettingMobileRedirect struct { +type MobileRedirect struct { // Identifier of the zone setting. - ID ZoneSettingMobileRedirectID `json:"id,required"` + ID MobileRedirectID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingMobileRedirectValue `json:"value,required"` + Value MobileRedirectValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingMobileRedirectEditable `json:"editable"` + Editable MobileRedirectEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMobileRedirectJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON mobileRedirectJSON `json:"-"` } -// zoneSettingMobileRedirectJSON contains the JSON metadata for the struct -// [ZoneSettingMobileRedirect] -type zoneSettingMobileRedirectJSON struct { +// mobileRedirectJSON contains the JSON metadata for the struct [MobileRedirect] +type mobileRedirectJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,49 +92,45 @@ type zoneSettingMobileRedirectJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingMobileRedirect) UnmarshalJSON(data []byte) (err error) { +func (r *MobileRedirect) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingMobileRedirectJSON) RawJSON() string { +func (r mobileRedirectJSON) RawJSON() string { return r.raw } -func (r ZoneSettingMobileRedirect) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingMobileRedirect) implementsZonesSettingGetResponse() {} - // Identifier of the zone setting. -type ZoneSettingMobileRedirectID string +type MobileRedirectID string const ( - ZoneSettingMobileRedirectIDMobileRedirect ZoneSettingMobileRedirectID = "mobile_redirect" + MobileRedirectIDMobileRedirect MobileRedirectID = "mobile_redirect" ) -func (r ZoneSettingMobileRedirectID) IsKnown() bool { +func (r MobileRedirectID) IsKnown() bool { switch r { - case ZoneSettingMobileRedirectIDMobileRedirect: + case MobileRedirectIDMobileRedirect: return true } return false } // Current value of the zone setting. -type ZoneSettingMobileRedirectValue struct { +type MobileRedirectValue struct { // Which subdomain prefix you wish to redirect visitors on mobile devices to // (subdomain must already exist). MobileSubdomain string `json:"mobile_subdomain,nullable"` // Whether or not mobile redirect is enabled. - Status ZoneSettingMobileRedirectValueStatus `json:"status"` + Status MobileRedirectValueStatus `json:"status"` // Whether to drop the current page path and redirect to the mobile subdomain URL // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI bool `json:"strip_uri"` - JSON zoneSettingMobileRedirectValueJSON `json:"-"` + StripURI bool `json:"strip_uri"` + JSON mobileRedirectValueJSON `json:"-"` } -// zoneSettingMobileRedirectValueJSON contains the JSON metadata for the struct -// [ZoneSettingMobileRedirectValue] -type zoneSettingMobileRedirectValueJSON struct { +// mobileRedirectValueJSON contains the JSON metadata for the struct +// [MobileRedirectValue] +type mobileRedirectValueJSON struct { MobileSubdomain apijson.Field Status apijson.Field StripURI apijson.Field @@ -142,25 +138,25 @@ type zoneSettingMobileRedirectValueJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingMobileRedirectValue) UnmarshalJSON(data []byte) (err error) { +func (r *MobileRedirectValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingMobileRedirectValueJSON) RawJSON() string { +func (r mobileRedirectValueJSON) RawJSON() string { return r.raw } // Whether or not mobile redirect is enabled. -type ZoneSettingMobileRedirectValueStatus string +type MobileRedirectValueStatus string const ( - ZoneSettingMobileRedirectValueStatusOn ZoneSettingMobileRedirectValueStatus = "on" - ZoneSettingMobileRedirectValueStatusOff ZoneSettingMobileRedirectValueStatus = "off" + MobileRedirectValueStatusOn MobileRedirectValueStatus = "on" + MobileRedirectValueStatusOff MobileRedirectValueStatus = "off" ) -func (r ZoneSettingMobileRedirectValueStatus) IsKnown() bool { +func (r MobileRedirectValueStatus) IsKnown() bool { switch r { - case ZoneSettingMobileRedirectValueStatusOn, ZoneSettingMobileRedirectValueStatusOff: + case MobileRedirectValueStatusOn, MobileRedirectValueStatusOff: return true } return false @@ -168,54 +164,21 @@ func (r ZoneSettingMobileRedirectValueStatus) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingMobileRedirectEditable bool +type MobileRedirectEditable bool const ( - ZoneSettingMobileRedirectEditableTrue ZoneSettingMobileRedirectEditable = true - ZoneSettingMobileRedirectEditableFalse ZoneSettingMobileRedirectEditable = false + MobileRedirectEditableTrue MobileRedirectEditable = true + MobileRedirectEditableFalse MobileRedirectEditable = false ) -func (r ZoneSettingMobileRedirectEditable) IsKnown() bool { +func (r MobileRedirectEditable) IsKnown() bool { switch r { - case ZoneSettingMobileRedirectEditableTrue, ZoneSettingMobileRedirectEditableFalse: + case MobileRedirectEditableTrue, MobileRedirectEditableFalse: return true } return false } -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -type ZoneSettingMobileRedirectParam struct { - // Identifier of the zone setting. - ID param.Field[ZoneSettingMobileRedirectID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingMobileRedirectValueParam] `json:"value,required"` -} - -func (r ZoneSettingMobileRedirectParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingMobileRedirectParam) implementsZonesSettingEditParamsItem() {} - -// Current value of the zone setting. -type ZoneSettingMobileRedirectValueParam struct { - // Which subdomain prefix you wish to redirect visitors on mobile devices to - // (subdomain must already exist). - MobileSubdomain param.Field[string] `json:"mobile_subdomain"` - // Whether or not mobile redirect is enabled. - Status param.Field[ZoneSettingMobileRedirectValueStatus] `json:"status"` - // Whether to drop the current page path and redirect to the mobile subdomain URL - // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI param.Field[bool] `json:"strip_uri"` -} - -func (r ZoneSettingMobileRedirectValueParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SettingMobileRedirectEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -260,15 +223,15 @@ func (r SettingMobileRedirectEditParamsValueStatus) IsKnown() bool { } type SettingMobileRedirectEditResponseEnvelope struct { - Errors []SettingMobileRedirectEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMobileRedirectEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Automatically redirect visitors on mobile devices to a mobile-optimized // subdomain. Refer to // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) // for more information. - Result ZoneSettingMobileRedirect `json:"result"` + Result MobileRedirect `json:"result"` JSON settingMobileRedirectEditResponseEnvelopeJSON `json:"-"` } @@ -291,67 +254,21 @@ func (r settingMobileRedirectEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingMobileRedirectEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMobileRedirectEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMobileRedirectEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingMobileRedirectEditResponseEnvelopeErrors] -type settingMobileRedirectEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMobileRedirectEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMobileRedirectEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMobileRedirectEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMobileRedirectEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMobileRedirectEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingMobileRedirectEditResponseEnvelopeMessages] -type settingMobileRedirectEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMobileRedirectEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMobileRedirectEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingMobileRedirectGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingMobileRedirectGetResponseEnvelope struct { - Errors []SettingMobileRedirectGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingMobileRedirectGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Automatically redirect visitors on mobile devices to a mobile-optimized // subdomain. Refer to // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) // for more information. - Result ZoneSettingMobileRedirect `json:"result"` + Result MobileRedirect `json:"result"` JSON settingMobileRedirectGetResponseEnvelopeJSON `json:"-"` } @@ -373,49 +290,3 @@ func (r *SettingMobileRedirectGetResponseEnvelope) UnmarshalJSON(data []byte) (e func (r settingMobileRedirectGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingMobileRedirectGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMobileRedirectGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingMobileRedirectGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingMobileRedirectGetResponseEnvelopeErrors] -type settingMobileRedirectGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMobileRedirectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMobileRedirectGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingMobileRedirectGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingMobileRedirectGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingMobileRedirectGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingMobileRedirectGetResponseEnvelopeMessages] -type settingMobileRedirectGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingMobileRedirectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingMobileRedirectGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingnel.go b/zones/settingnel.go index f139b0904a0..0d26f0d7d60 100644 --- a/zones/settingnel.go +++ b/zones/settingnel.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingNELService(opts ...option.RequestOption) (r *SettingNELService) { // Automatically optimize image loading for website visitors on mobile devices. // Refer to our [blog post](http://blog.cloudflare.com/nel-solving-mobile-speed) // for more information. -func (r *SettingNELService) Edit(ctx context.Context, params SettingNELEditParams, opts ...option.RequestOption) (res *ZoneSettingNEL, err error) { +func (r *SettingNELService) Edit(ctx context.Context, params SettingNELEditParams, opts ...option.RequestOption) (res *NEL, err error) { opts = append(r.Options[:], opts...) var env SettingNELEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/nel", params.ZoneID) @@ -47,7 +48,7 @@ func (r *SettingNELService) Edit(ctx context.Context, params SettingNELEditParam } // Enable Network Error Logging reporting on your zone. (Beta) -func (r *SettingNELService) Get(ctx context.Context, query SettingNELGetParams, opts ...option.RequestOption) (res *ZoneSettingNEL, err error) { +func (r *SettingNELService) Get(ctx context.Context, query SettingNELGetParams, opts ...option.RequestOption) (res *NEL, err error) { opts = append(r.Options[:], opts...) var env SettingNELGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/nel", query.ZoneID) @@ -60,21 +61,21 @@ func (r *SettingNELService) Get(ctx context.Context, query SettingNELGetParams, } // Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingNEL struct { +type NEL struct { // Zone setting identifier. - ID ZoneSettingNELID `json:"id,required"` + ID NELID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingNELValue `json:"value,required"` + Value NELValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingNELEditable `json:"editable"` + Editable NELEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingNELJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON nelJSON `json:"-"` } -// zoneSettingNELJSON contains the JSON metadata for the struct [ZoneSettingNEL] -type zoneSettingNELJSON struct { +// nelJSON contains the JSON metadata for the struct [NEL] +type nelJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,92 +84,85 @@ type zoneSettingNELJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingNEL) UnmarshalJSON(data []byte) (err error) { +func (r *NEL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingNELJSON) RawJSON() string { +func (r nelJSON) RawJSON() string { return r.raw } -func (r ZoneSettingNEL) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingNEL) implementsZonesSettingGetResponse() {} - // Zone setting identifier. -type ZoneSettingNELID string +type NELID string const ( - ZoneSettingNELIDNEL ZoneSettingNELID = "nel" + NELIDNEL NELID = "nel" ) -func (r ZoneSettingNELID) IsKnown() bool { +func (r NELID) IsKnown() bool { switch r { - case ZoneSettingNELIDNEL: + case NELIDNEL: return true } return false } // Current value of the zone setting. -type ZoneSettingNELValue struct { - Enabled bool `json:"enabled"` - JSON zoneSettingNELValueJSON `json:"-"` +type NELValue struct { + Enabled bool `json:"enabled"` + JSON nelValueJSON `json:"-"` } -// zoneSettingNELValueJSON contains the JSON metadata for the struct -// [ZoneSettingNELValue] -type zoneSettingNELValueJSON struct { +// nelValueJSON contains the JSON metadata for the struct [NELValue] +type nelValueJSON struct { Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZoneSettingNELValue) UnmarshalJSON(data []byte) (err error) { +func (r *NELValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingNELValueJSON) RawJSON() string { +func (r nelValueJSON) RawJSON() string { return r.raw } // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingNELEditable bool +type NELEditable bool const ( - ZoneSettingNELEditableTrue ZoneSettingNELEditable = true - ZoneSettingNELEditableFalse ZoneSettingNELEditable = false + NELEditableTrue NELEditable = true + NELEditableFalse NELEditable = false ) -func (r ZoneSettingNELEditable) IsKnown() bool { +func (r NELEditable) IsKnown() bool { switch r { - case ZoneSettingNELEditableTrue, ZoneSettingNELEditableFalse: + case NELEditableTrue, NELEditableFalse: return true } return false } // Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingNELParam struct { +type NELParam struct { // Zone setting identifier. - ID param.Field[ZoneSettingNELID] `json:"id,required"` + ID param.Field[NELID] `json:"id,required"` // Current value of the zone setting. - Value param.Field[ZoneSettingNELValueParam] `json:"value,required"` + Value param.Field[NELValueParam] `json:"value,required"` } -func (r ZoneSettingNELParam) MarshalJSON() (data []byte, err error) { +func (r NELParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingNELParam) implementsZonesSettingEditParamsItem() {} - // Current value of the zone setting. -type ZoneSettingNELValueParam struct { +type NELValueParam struct { Enabled param.Field[bool] `json:"enabled"` } -func (r ZoneSettingNELValueParam) MarshalJSON() (data []byte, err error) { +func (r NELValueParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } @@ -176,7 +170,7 @@ type SettingNELEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Enable Network Error Logging reporting on your zone. (Beta) - Value param.Field[ZoneSettingNELParam] `json:"value,required"` + Value param.Field[NELParam] `json:"value,required"` } func (r SettingNELEditParams) MarshalJSON() (data []byte, err error) { @@ -184,12 +178,12 @@ func (r SettingNELEditParams) MarshalJSON() (data []byte, err error) { } type SettingNELEditResponseEnvelope struct { - Errors []SettingNELEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingNELEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable Network Error Logging reporting on your zone. (Beta) - Result ZoneSettingNEL `json:"result"` + Result NEL `json:"result"` JSON settingNELEditResponseEnvelopeJSON `json:"-"` } @@ -212,64 +206,18 @@ func (r settingNELEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingNELEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingNELEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingNELEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingNELEditResponseEnvelopeErrors] -type settingNELEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingNELEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingNELEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingNELEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingNELEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingNELEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingNELEditResponseEnvelopeMessages] -type settingNELEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingNELEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingNELEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingNELGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingNELGetResponseEnvelope struct { - Errors []SettingNELGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingNELGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enable Network Error Logging reporting on your zone. (Beta) - Result ZoneSettingNEL `json:"result"` + Result NEL `json:"result"` JSON settingNELGetResponseEnvelopeJSON `json:"-"` } @@ -291,49 +239,3 @@ func (r *SettingNELGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { func (r settingNELGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingNELGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingNELGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingNELGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingNELGetResponseEnvelopeErrors] -type settingNELGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingNELGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingNELGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingNELGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingNELGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingNELGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingNELGetResponseEnvelopeMessages] -type settingNELGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingNELGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingNELGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingnel_test.go b/zones/settingnel_test.go index 8c1e24fe5a9..e3187fd522a 100644 --- a/zones/settingnel_test.go +++ b/zones/settingnel_test.go @@ -30,9 +30,9 @@ func TestSettingNELEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.NEL.Edit(context.TODO(), zones.SettingNELEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingNELParam{ - ID: cloudflare.F(zones.ZoneSettingNELIDNEL), - Value: cloudflare.F(zones.ZoneSettingNELValueParam{ + Value: cloudflare.F(zones.NELParam{ + ID: cloudflare.F(zones.NELIDNEL), + Value: cloudflare.F(zones.NELValueParam{ Enabled: cloudflare.F(false), }), }), diff --git a/zones/settingopportunisticencryption.go b/zones/settingopportunisticencryption.go index 7e34d424ed1..aee10ccd03f 100644 --- a/zones/settingopportunisticencryption.go +++ b/zones/settingopportunisticencryption.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingOpportunisticEncryptionService(opts ...option.RequestOption) (r * } // Changes Opportunistic Encryption setting. -func (r *SettingOpportunisticEncryptionService) Edit(ctx context.Context, params SettingOpportunisticEncryptionEditParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticEncryption, err error) { +func (r *SettingOpportunisticEncryptionService) Edit(ctx context.Context, params SettingOpportunisticEncryptionEditParams, opts ...option.RequestOption) (res *OpportunisticEncryption, err error) { opts = append(r.Options[:], opts...) var env SettingOpportunisticEncryptionEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/opportunistic_encryption", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingOpportunisticEncryptionService) Edit(ctx context.Context, params } // Gets Opportunistic Encryption setting. -func (r *SettingOpportunisticEncryptionService) Get(ctx context.Context, query SettingOpportunisticEncryptionGetParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticEncryption, err error) { +func (r *SettingOpportunisticEncryptionService) Get(ctx context.Context, query SettingOpportunisticEncryptionGetParams, opts ...option.RequestOption) (res *OpportunisticEncryption, err error) { opts = append(r.Options[:], opts...) var env SettingOpportunisticEncryptionGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/opportunistic_encryption", query.ZoneID) @@ -59,22 +60,22 @@ func (r *SettingOpportunisticEncryptionService) Get(ctx context.Context, query S } // Enables the Opportunistic Encryption feature for a zone. -type ZoneSettingOpportunisticEncryption struct { +type OpportunisticEncryption struct { // ID of the zone setting. - ID ZoneSettingOpportunisticEncryptionID `json:"id,required"` + ID OpportunisticEncryptionID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingOpportunisticEncryptionValue `json:"value,required"` + Value OpportunisticEncryptionValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingOpportunisticEncryptionEditable `json:"editable"` + Editable OpportunisticEncryptionEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOpportunisticEncryptionJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON opportunisticEncryptionJSON `json:"-"` } -// zoneSettingOpportunisticEncryptionJSON contains the JSON metadata for the struct -// [ZoneSettingOpportunisticEncryption] -type zoneSettingOpportunisticEncryptionJSON struct { +// opportunisticEncryptionJSON contains the JSON metadata for the struct +// [OpportunisticEncryption] +type opportunisticEncryptionJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,44 +84,40 @@ type zoneSettingOpportunisticEncryptionJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingOpportunisticEncryption) UnmarshalJSON(data []byte) (err error) { +func (r *OpportunisticEncryption) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingOpportunisticEncryptionJSON) RawJSON() string { +func (r opportunisticEncryptionJSON) RawJSON() string { return r.raw } -func (r ZoneSettingOpportunisticEncryption) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingOpportunisticEncryption) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingOpportunisticEncryptionID string +type OpportunisticEncryptionID string const ( - ZoneSettingOpportunisticEncryptionIDOpportunisticEncryption ZoneSettingOpportunisticEncryptionID = "opportunistic_encryption" + OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption" ) -func (r ZoneSettingOpportunisticEncryptionID) IsKnown() bool { +func (r OpportunisticEncryptionID) IsKnown() bool { switch r { - case ZoneSettingOpportunisticEncryptionIDOpportunisticEncryption: + case OpportunisticEncryptionIDOpportunisticEncryption: return true } return false } // Current value of the zone setting. -type ZoneSettingOpportunisticEncryptionValue string +type OpportunisticEncryptionValue string const ( - ZoneSettingOpportunisticEncryptionValueOn ZoneSettingOpportunisticEncryptionValue = "on" - ZoneSettingOpportunisticEncryptionValueOff ZoneSettingOpportunisticEncryptionValue = "off" + OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on" + OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off" ) -func (r ZoneSettingOpportunisticEncryptionValue) IsKnown() bool { +func (r OpportunisticEncryptionValue) IsKnown() bool { switch r { - case ZoneSettingOpportunisticEncryptionValueOn, ZoneSettingOpportunisticEncryptionValueOff: + case OpportunisticEncryptionValueOn, OpportunisticEncryptionValueOff: return true } return false @@ -128,35 +125,21 @@ func (r ZoneSettingOpportunisticEncryptionValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingOpportunisticEncryptionEditable bool +type OpportunisticEncryptionEditable bool const ( - ZoneSettingOpportunisticEncryptionEditableTrue ZoneSettingOpportunisticEncryptionEditable = true - ZoneSettingOpportunisticEncryptionEditableFalse ZoneSettingOpportunisticEncryptionEditable = false + OpportunisticEncryptionEditableTrue OpportunisticEncryptionEditable = true + OpportunisticEncryptionEditableFalse OpportunisticEncryptionEditable = false ) -func (r ZoneSettingOpportunisticEncryptionEditable) IsKnown() bool { +func (r OpportunisticEncryptionEditable) IsKnown() bool { switch r { - case ZoneSettingOpportunisticEncryptionEditableTrue, ZoneSettingOpportunisticEncryptionEditableFalse: + case OpportunisticEncryptionEditableTrue, OpportunisticEncryptionEditableFalse: return true } return false } -// Enables the Opportunistic Encryption feature for a zone. -type ZoneSettingOpportunisticEncryptionParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingOpportunisticEncryptionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingOpportunisticEncryptionValue] `json:"value,required"` -} - -func (r ZoneSettingOpportunisticEncryptionParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingOpportunisticEncryptionParam) implementsZonesSettingEditParamsItem() {} - type SettingOpportunisticEncryptionEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -187,12 +170,12 @@ func (r SettingOpportunisticEncryptionEditParamsValue) IsKnown() bool { } type SettingOpportunisticEncryptionEditResponseEnvelope struct { - Errors []SettingOpportunisticEncryptionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOpportunisticEncryptionEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enables the Opportunistic Encryption feature for a zone. - Result ZoneSettingOpportunisticEncryption `json:"result"` + Result OpportunisticEncryption `json:"result"` JSON settingOpportunisticEncryptionEditResponseEnvelopeJSON `json:"-"` } @@ -215,66 +198,18 @@ func (r settingOpportunisticEncryptionEditResponseEnvelopeJSON) RawJSON() string return r.raw } -type SettingOpportunisticEncryptionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [SettingOpportunisticEncryptionEditResponseEnvelopeErrors] -type settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticEncryptionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOpportunisticEncryptionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingOpportunisticEncryptionEditResponseEnvelopeMessages] -type settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticEncryptionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingOpportunisticEncryptionGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingOpportunisticEncryptionGetResponseEnvelope struct { - Errors []SettingOpportunisticEncryptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOpportunisticEncryptionGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enables the Opportunistic Encryption feature for a zone. - Result ZoneSettingOpportunisticEncryption `json:"result"` + Result OpportunisticEncryption `json:"result"` JSON settingOpportunisticEncryptionGetResponseEnvelopeJSON `json:"-"` } @@ -296,51 +231,3 @@ func (r *SettingOpportunisticEncryptionGetResponseEnvelope) UnmarshalJSON(data [ func (r settingOpportunisticEncryptionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingOpportunisticEncryptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [SettingOpportunisticEncryptionGetResponseEnvelopeErrors] -type settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticEncryptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOpportunisticEncryptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingOpportunisticEncryptionGetResponseEnvelopeMessages] -type settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticEncryptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingopportunisticonion.go b/zones/settingopportunisticonion.go index 61598fc7cd9..62594310409 100644 --- a/zones/settingopportunisticonion.go +++ b/zones/settingopportunisticonion.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingOpportunisticOnionService(opts ...option.RequestOption) (r *Setti // Add an Alt-Svc header to all legitimate requests from Tor, allowing the // connection to use our onion services instead of exit nodes. -func (r *SettingOpportunisticOnionService) Edit(ctx context.Context, params SettingOpportunisticOnionEditParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticOnion, err error) { +func (r *SettingOpportunisticOnionService) Edit(ctx context.Context, params SettingOpportunisticOnionEditParams, opts ...option.RequestOption) (res *OpportunisticOnion, err error) { opts = append(r.Options[:], opts...) var env SettingOpportunisticOnionEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/opportunistic_onion", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingOpportunisticOnionService) Edit(ctx context.Context, params Sett // Add an Alt-Svc header to all legitimate requests from Tor, allowing the // connection to use our onion services instead of exit nodes. -func (r *SettingOpportunisticOnionService) Get(ctx context.Context, query SettingOpportunisticOnionGetParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticOnion, err error) { +func (r *SettingOpportunisticOnionService) Get(ctx context.Context, query SettingOpportunisticOnionGetParams, opts ...option.RequestOption) (res *OpportunisticOnion, err error) { opts = append(r.Options[:], opts...) var env SettingOpportunisticOnionGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/opportunistic_onion", query.ZoneID) @@ -62,22 +63,22 @@ func (r *SettingOpportunisticOnionService) Get(ctx context.Context, query Settin // Add an Alt-Svc header to all legitimate requests from Tor, allowing the // connection to use our onion services instead of exit nodes. -type ZoneSettingOpportunisticOnion struct { +type OpportunisticOnion struct { // ID of the zone setting. - ID ZoneSettingOpportunisticOnionID `json:"id,required"` + ID OpportunisticOnionID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingOpportunisticOnionValue `json:"value,required"` + Value OpportunisticOnionValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingOpportunisticOnionEditable `json:"editable"` + Editable OpportunisticOnionEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOpportunisticOnionJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON opportunisticOnionJSON `json:"-"` } -// zoneSettingOpportunisticOnionJSON contains the JSON metadata for the struct -// [ZoneSettingOpportunisticOnion] -type zoneSettingOpportunisticOnionJSON struct { +// opportunisticOnionJSON contains the JSON metadata for the struct +// [OpportunisticOnion] +type opportunisticOnionJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -86,44 +87,40 @@ type zoneSettingOpportunisticOnionJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingOpportunisticOnion) UnmarshalJSON(data []byte) (err error) { +func (r *OpportunisticOnion) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingOpportunisticOnionJSON) RawJSON() string { +func (r opportunisticOnionJSON) RawJSON() string { return r.raw } -func (r ZoneSettingOpportunisticOnion) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingOpportunisticOnion) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingOpportunisticOnionID string +type OpportunisticOnionID string const ( - ZoneSettingOpportunisticOnionIDOpportunisticOnion ZoneSettingOpportunisticOnionID = "opportunistic_onion" + OpportunisticOnionIDOpportunisticOnion OpportunisticOnionID = "opportunistic_onion" ) -func (r ZoneSettingOpportunisticOnionID) IsKnown() bool { +func (r OpportunisticOnionID) IsKnown() bool { switch r { - case ZoneSettingOpportunisticOnionIDOpportunisticOnion: + case OpportunisticOnionIDOpportunisticOnion: return true } return false } // Current value of the zone setting. -type ZoneSettingOpportunisticOnionValue string +type OpportunisticOnionValue string const ( - ZoneSettingOpportunisticOnionValueOn ZoneSettingOpportunisticOnionValue = "on" - ZoneSettingOpportunisticOnionValueOff ZoneSettingOpportunisticOnionValue = "off" + OpportunisticOnionValueOn OpportunisticOnionValue = "on" + OpportunisticOnionValueOff OpportunisticOnionValue = "off" ) -func (r ZoneSettingOpportunisticOnionValue) IsKnown() bool { +func (r OpportunisticOnionValue) IsKnown() bool { switch r { - case ZoneSettingOpportunisticOnionValueOn, ZoneSettingOpportunisticOnionValueOff: + case OpportunisticOnionValueOn, OpportunisticOnionValueOff: return true } return false @@ -131,36 +128,21 @@ func (r ZoneSettingOpportunisticOnionValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingOpportunisticOnionEditable bool +type OpportunisticOnionEditable bool const ( - ZoneSettingOpportunisticOnionEditableTrue ZoneSettingOpportunisticOnionEditable = true - ZoneSettingOpportunisticOnionEditableFalse ZoneSettingOpportunisticOnionEditable = false + OpportunisticOnionEditableTrue OpportunisticOnionEditable = true + OpportunisticOnionEditableFalse OpportunisticOnionEditable = false ) -func (r ZoneSettingOpportunisticOnionEditable) IsKnown() bool { +func (r OpportunisticOnionEditable) IsKnown() bool { switch r { - case ZoneSettingOpportunisticOnionEditableTrue, ZoneSettingOpportunisticOnionEditableFalse: + case OpportunisticOnionEditableTrue, OpportunisticOnionEditableFalse: return true } return false } -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -type ZoneSettingOpportunisticOnionParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingOpportunisticOnionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingOpportunisticOnionValue] `json:"value,required"` -} - -func (r ZoneSettingOpportunisticOnionParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingOpportunisticOnionParam) implementsZonesSettingEditParamsItem() {} - type SettingOpportunisticOnionEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -191,13 +173,13 @@ func (r SettingOpportunisticOnionEditParamsValue) IsKnown() bool { } type SettingOpportunisticOnionEditResponseEnvelope struct { - Errors []SettingOpportunisticOnionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOpportunisticOnionEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Add an Alt-Svc header to all legitimate requests from Tor, allowing the // connection to use our onion services instead of exit nodes. - Result ZoneSettingOpportunisticOnion `json:"result"` + Result OpportunisticOnion `json:"result"` JSON settingOpportunisticOnionEditResponseEnvelopeJSON `json:"-"` } @@ -220,65 +202,19 @@ func (r settingOpportunisticOnionEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingOpportunisticOnionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticOnionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOpportunisticOnionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingOpportunisticOnionEditResponseEnvelopeErrors] -type settingOpportunisticOnionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticOnionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticOnionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOpportunisticOnionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticOnionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOpportunisticOnionEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingOpportunisticOnionEditResponseEnvelopeMessages] -type settingOpportunisticOnionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticOnionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticOnionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingOpportunisticOnionGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingOpportunisticOnionGetResponseEnvelope struct { - Errors []SettingOpportunisticOnionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOpportunisticOnionGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Add an Alt-Svc header to all legitimate requests from Tor, allowing the // connection to use our onion services instead of exit nodes. - Result ZoneSettingOpportunisticOnion `json:"result"` + Result OpportunisticOnion `json:"result"` JSON settingOpportunisticOnionGetResponseEnvelopeJSON `json:"-"` } @@ -300,49 +236,3 @@ func (r *SettingOpportunisticOnionGetResponseEnvelope) UnmarshalJSON(data []byte func (r settingOpportunisticOnionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingOpportunisticOnionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticOnionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOpportunisticOnionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingOpportunisticOnionGetResponseEnvelopeErrors] -type settingOpportunisticOnionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticOnionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticOnionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOpportunisticOnionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOpportunisticOnionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOpportunisticOnionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingOpportunisticOnionGetResponseEnvelopeMessages] -type settingOpportunisticOnionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOpportunisticOnionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOpportunisticOnionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingorangetoorange.go b/zones/settingorangetoorange.go index 61fd06ad81c..56e1c6d18a8 100644 --- a/zones/settingorangetoorange.go +++ b/zones/settingorangetoorange.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingOrangeToOrangeService(opts ...option.RequestOption) (r *SettingOr // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also // on Cloudflare. -func (r *SettingOrangeToOrangeService) Edit(ctx context.Context, params SettingOrangeToOrangeEditParams, opts ...option.RequestOption) (res *ZoneSettingOrangeToOrange, err error) { +func (r *SettingOrangeToOrangeService) Edit(ctx context.Context, params SettingOrangeToOrangeEditParams, opts ...option.RequestOption) (res *OrangeToOrange, err error) { opts = append(r.Options[:], opts...) var env SettingOrangeToOrangeEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/orange_to_orange", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingOrangeToOrangeService) Edit(ctx context.Context, params SettingO // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also // on Cloudflare. -func (r *SettingOrangeToOrangeService) Get(ctx context.Context, query SettingOrangeToOrangeGetParams, opts ...option.RequestOption) (res *ZoneSettingOrangeToOrange, err error) { +func (r *SettingOrangeToOrangeService) Get(ctx context.Context, query SettingOrangeToOrangeGetParams, opts ...option.RequestOption) (res *OrangeToOrange, err error) { opts = append(r.Options[:], opts...) var env SettingOrangeToOrangeGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/orange_to_orange", query.ZoneID) @@ -62,22 +63,21 @@ func (r *SettingOrangeToOrangeService) Get(ctx context.Context, query SettingOra // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also // on Cloudflare. -type ZoneSettingOrangeToOrange struct { +type OrangeToOrange struct { // ID of the zone setting. - ID ZoneSettingOrangeToOrangeID `json:"id,required"` + ID OrangeToOrangeID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingOrangeToOrangeValue `json:"value,required"` + Value OrangeToOrangeValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingOrangeToOrangeEditable `json:"editable"` + Editable OrangeToOrangeEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOrangeToOrangeJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON orangeToOrangeJSON `json:"-"` } -// zoneSettingOrangeToOrangeJSON contains the JSON metadata for the struct -// [ZoneSettingOrangeToOrange] -type zoneSettingOrangeToOrangeJSON struct { +// orangeToOrangeJSON contains the JSON metadata for the struct [OrangeToOrange] +type orangeToOrangeJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -86,44 +86,40 @@ type zoneSettingOrangeToOrangeJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingOrangeToOrange) UnmarshalJSON(data []byte) (err error) { +func (r *OrangeToOrange) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingOrangeToOrangeJSON) RawJSON() string { +func (r orangeToOrangeJSON) RawJSON() string { return r.raw } -func (r ZoneSettingOrangeToOrange) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingOrangeToOrange) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingOrangeToOrangeID string +type OrangeToOrangeID string const ( - ZoneSettingOrangeToOrangeIDOrangeToOrange ZoneSettingOrangeToOrangeID = "orange_to_orange" + OrangeToOrangeIDOrangeToOrange OrangeToOrangeID = "orange_to_orange" ) -func (r ZoneSettingOrangeToOrangeID) IsKnown() bool { +func (r OrangeToOrangeID) IsKnown() bool { switch r { - case ZoneSettingOrangeToOrangeIDOrangeToOrange: + case OrangeToOrangeIDOrangeToOrange: return true } return false } // Current value of the zone setting. -type ZoneSettingOrangeToOrangeValue string +type OrangeToOrangeValue string const ( - ZoneSettingOrangeToOrangeValueOn ZoneSettingOrangeToOrangeValue = "on" - ZoneSettingOrangeToOrangeValueOff ZoneSettingOrangeToOrangeValue = "off" + OrangeToOrangeValueOn OrangeToOrangeValue = "on" + OrangeToOrangeValueOff OrangeToOrangeValue = "off" ) -func (r ZoneSettingOrangeToOrangeValue) IsKnown() bool { +func (r OrangeToOrangeValue) IsKnown() bool { switch r { - case ZoneSettingOrangeToOrangeValueOn, ZoneSettingOrangeToOrangeValueOff: + case OrangeToOrangeValueOn, OrangeToOrangeValueOff: return true } return false @@ -131,16 +127,16 @@ func (r ZoneSettingOrangeToOrangeValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingOrangeToOrangeEditable bool +type OrangeToOrangeEditable bool const ( - ZoneSettingOrangeToOrangeEditableTrue ZoneSettingOrangeToOrangeEditable = true - ZoneSettingOrangeToOrangeEditableFalse ZoneSettingOrangeToOrangeEditable = false + OrangeToOrangeEditableTrue OrangeToOrangeEditable = true + OrangeToOrangeEditableFalse OrangeToOrangeEditable = false ) -func (r ZoneSettingOrangeToOrangeEditable) IsKnown() bool { +func (r OrangeToOrangeEditable) IsKnown() bool { switch r { - case ZoneSettingOrangeToOrangeEditableTrue, ZoneSettingOrangeToOrangeEditableFalse: + case OrangeToOrangeEditableTrue, OrangeToOrangeEditableFalse: return true } return false @@ -148,25 +144,23 @@ func (r ZoneSettingOrangeToOrangeEditable) IsKnown() bool { // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also // on Cloudflare. -type ZoneSettingOrangeToOrangeParam struct { +type OrangeToOrangeParam struct { // ID of the zone setting. - ID param.Field[ZoneSettingOrangeToOrangeID] `json:"id,required"` + ID param.Field[OrangeToOrangeID] `json:"id,required"` // Current value of the zone setting. - Value param.Field[ZoneSettingOrangeToOrangeValue] `json:"value,required"` + Value param.Field[OrangeToOrangeValue] `json:"value,required"` } -func (r ZoneSettingOrangeToOrangeParam) MarshalJSON() (data []byte, err error) { +func (r OrangeToOrangeParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingOrangeToOrangeParam) implementsZonesSettingEditParamsItem() {} - type SettingOrangeToOrangeEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also // on Cloudflare. - Value param.Field[ZoneSettingOrangeToOrangeParam] `json:"value,required"` + Value param.Field[OrangeToOrangeParam] `json:"value,required"` } func (r SettingOrangeToOrangeEditParams) MarshalJSON() (data []byte, err error) { @@ -174,13 +168,13 @@ func (r SettingOrangeToOrangeEditParams) MarshalJSON() (data []byte, err error) } type SettingOrangeToOrangeEditResponseEnvelope struct { - Errors []SettingOrangeToOrangeEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOrangeToOrangeEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also // on Cloudflare. - Result ZoneSettingOrangeToOrange `json:"result"` + Result OrangeToOrange `json:"result"` JSON settingOrangeToOrangeEditResponseEnvelopeJSON `json:"-"` } @@ -203,65 +197,19 @@ func (r settingOrangeToOrangeEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingOrangeToOrangeEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOrangeToOrangeEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOrangeToOrangeEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingOrangeToOrangeEditResponseEnvelopeErrors] -type settingOrangeToOrangeEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOrangeToOrangeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOrangeToOrangeEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOrangeToOrangeEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOrangeToOrangeEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOrangeToOrangeEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingOrangeToOrangeEditResponseEnvelopeMessages] -type settingOrangeToOrangeEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOrangeToOrangeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOrangeToOrangeEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingOrangeToOrangeGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingOrangeToOrangeGetResponseEnvelope struct { - Errors []SettingOrangeToOrangeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOrangeToOrangeGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also // on Cloudflare. - Result ZoneSettingOrangeToOrange `json:"result"` + Result OrangeToOrange `json:"result"` JSON settingOrangeToOrangeGetResponseEnvelopeJSON `json:"-"` } @@ -283,49 +231,3 @@ func (r *SettingOrangeToOrangeGetResponseEnvelope) UnmarshalJSON(data []byte) (e func (r settingOrangeToOrangeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingOrangeToOrangeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOrangeToOrangeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOrangeToOrangeGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingOrangeToOrangeGetResponseEnvelopeErrors] -type settingOrangeToOrangeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOrangeToOrangeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOrangeToOrangeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOrangeToOrangeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOrangeToOrangeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOrangeToOrangeGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingOrangeToOrangeGetResponseEnvelopeMessages] -type settingOrangeToOrangeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOrangeToOrangeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOrangeToOrangeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingorangetoorange_test.go b/zones/settingorangetoorange_test.go index e2dbba4a226..dfed5834f13 100644 --- a/zones/settingorangetoorange_test.go +++ b/zones/settingorangetoorange_test.go @@ -30,9 +30,9 @@ func TestSettingOrangeToOrangeEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.OrangeToOrange.Edit(context.TODO(), zones.SettingOrangeToOrangeEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingOrangeToOrangeParam{ - ID: cloudflare.F(zones.ZoneSettingOrangeToOrangeIDOrangeToOrange), - Value: cloudflare.F(zones.ZoneSettingOrangeToOrangeValueOn), + Value: cloudflare.F(zones.OrangeToOrangeParam{ + ID: cloudflare.F(zones.OrangeToOrangeIDOrangeToOrange), + Value: cloudflare.F(zones.OrangeToOrangeValueOn), }), }) if err != nil { diff --git a/zones/settingoriginerrorpagepassthru.go b/zones/settingoriginerrorpagepassthru.go index a0e43e41853..cfad8d96a53 100644 --- a/zones/settingoriginerrorpagepassthru.go +++ b/zones/settingoriginerrorpagepassthru.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingOriginErrorPagePassThruService(opts ...option.RequestOption) (r * // Cloudflare will proxy customer error pages on any 502,504 errors on origin // server instead of showing a default Cloudflare error page. This does not apply // to 522 errors and is limited to Enterprise Zones. -func (r *SettingOriginErrorPagePassThruService) Edit(ctx context.Context, params SettingOriginErrorPagePassThruEditParams, opts ...option.RequestOption) (res *ZoneSettingOriginErrorPagePassThru, err error) { +func (r *SettingOriginErrorPagePassThruService) Edit(ctx context.Context, params SettingOriginErrorPagePassThruEditParams, opts ...option.RequestOption) (res *OriginErrorPagePassThru, err error) { opts = append(r.Options[:], opts...) var env SettingOriginErrorPagePassThruEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/origin_error_page_pass_thru", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingOriginErrorPagePassThruService) Edit(ctx context.Context, params // Cloudflare will proxy customer error pages on any 502,504 errors on origin // server instead of showing a default Cloudflare error page. This does not apply // to 522 errors and is limited to Enterprise Zones. -func (r *SettingOriginErrorPagePassThruService) Get(ctx context.Context, query SettingOriginErrorPagePassThruGetParams, opts ...option.RequestOption) (res *ZoneSettingOriginErrorPagePassThru, err error) { +func (r *SettingOriginErrorPagePassThruService) Get(ctx context.Context, query SettingOriginErrorPagePassThruGetParams, opts ...option.RequestOption) (res *OriginErrorPagePassThru, err error) { opts = append(r.Options[:], opts...) var env SettingOriginErrorPagePassThruGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/origin_error_page_pass_thru", query.ZoneID) @@ -65,22 +66,22 @@ func (r *SettingOriginErrorPagePassThruService) Get(ctx context.Context, query S // Cloudflare will proxy customer error pages on any 502,504 errors on origin // server instead of showing a default Cloudflare error page. This does not apply // to 522 errors and is limited to Enterprise Zones. -type ZoneSettingOriginErrorPagePassThru struct { +type OriginErrorPagePassThru struct { // ID of the zone setting. - ID ZoneSettingOriginErrorPagePassThruID `json:"id,required"` + ID OriginErrorPagePassThruID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingOriginErrorPagePassThruValue `json:"value,required"` + Value OriginErrorPagePassThruValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingOriginErrorPagePassThruEditable `json:"editable"` + Editable OriginErrorPagePassThruEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOriginErrorPagePassThruJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON originErrorPagePassThruJSON `json:"-"` } -// zoneSettingOriginErrorPagePassThruJSON contains the JSON metadata for the struct -// [ZoneSettingOriginErrorPagePassThru] -type zoneSettingOriginErrorPagePassThruJSON struct { +// originErrorPagePassThruJSON contains the JSON metadata for the struct +// [OriginErrorPagePassThru] +type originErrorPagePassThruJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -89,44 +90,40 @@ type zoneSettingOriginErrorPagePassThruJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingOriginErrorPagePassThru) UnmarshalJSON(data []byte) (err error) { +func (r *OriginErrorPagePassThru) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingOriginErrorPagePassThruJSON) RawJSON() string { +func (r originErrorPagePassThruJSON) RawJSON() string { return r.raw } -func (r ZoneSettingOriginErrorPagePassThru) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingOriginErrorPagePassThru) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingOriginErrorPagePassThruID string +type OriginErrorPagePassThruID string const ( - ZoneSettingOriginErrorPagePassThruIDOriginErrorPagePassThru ZoneSettingOriginErrorPagePassThruID = "origin_error_page_pass_thru" + OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru" ) -func (r ZoneSettingOriginErrorPagePassThruID) IsKnown() bool { +func (r OriginErrorPagePassThruID) IsKnown() bool { switch r { - case ZoneSettingOriginErrorPagePassThruIDOriginErrorPagePassThru: + case OriginErrorPagePassThruIDOriginErrorPagePassThru: return true } return false } // Current value of the zone setting. -type ZoneSettingOriginErrorPagePassThruValue string +type OriginErrorPagePassThruValue string const ( - ZoneSettingOriginErrorPagePassThruValueOn ZoneSettingOriginErrorPagePassThruValue = "on" - ZoneSettingOriginErrorPagePassThruValueOff ZoneSettingOriginErrorPagePassThruValue = "off" + OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on" + OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off" ) -func (r ZoneSettingOriginErrorPagePassThruValue) IsKnown() bool { +func (r OriginErrorPagePassThruValue) IsKnown() bool { switch r { - case ZoneSettingOriginErrorPagePassThruValueOn, ZoneSettingOriginErrorPagePassThruValueOff: + case OriginErrorPagePassThruValueOn, OriginErrorPagePassThruValueOff: return true } return false @@ -134,37 +131,21 @@ func (r ZoneSettingOriginErrorPagePassThruValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingOriginErrorPagePassThruEditable bool +type OriginErrorPagePassThruEditable bool const ( - ZoneSettingOriginErrorPagePassThruEditableTrue ZoneSettingOriginErrorPagePassThruEditable = true - ZoneSettingOriginErrorPagePassThruEditableFalse ZoneSettingOriginErrorPagePassThruEditable = false + OriginErrorPagePassThruEditableTrue OriginErrorPagePassThruEditable = true + OriginErrorPagePassThruEditableFalse OriginErrorPagePassThruEditable = false ) -func (r ZoneSettingOriginErrorPagePassThruEditable) IsKnown() bool { +func (r OriginErrorPagePassThruEditable) IsKnown() bool { switch r { - case ZoneSettingOriginErrorPagePassThruEditableTrue, ZoneSettingOriginErrorPagePassThruEditableFalse: + case OriginErrorPagePassThruEditableTrue, OriginErrorPagePassThruEditableFalse: return true } return false } -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -type ZoneSettingOriginErrorPagePassThruParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingOriginErrorPagePassThruID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingOriginErrorPagePassThruValue] `json:"value,required"` -} - -func (r ZoneSettingOriginErrorPagePassThruParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingOriginErrorPagePassThruParam) implementsZonesSettingEditParamsItem() {} - type SettingOriginErrorPagePassThruEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -193,14 +174,14 @@ func (r SettingOriginErrorPagePassThruEditParamsValue) IsKnown() bool { } type SettingOriginErrorPagePassThruEditResponseEnvelope struct { - Errors []SettingOriginErrorPagePassThruEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOriginErrorPagePassThruEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare will proxy customer error pages on any 502,504 errors on origin // server instead of showing a default Cloudflare error page. This does not apply // to 522 errors and is limited to Enterprise Zones. - Result ZoneSettingOriginErrorPagePassThru `json:"result"` + Result OriginErrorPagePassThru `json:"result"` JSON settingOriginErrorPagePassThruEditResponseEnvelopeJSON `json:"-"` } @@ -223,68 +204,20 @@ func (r settingOriginErrorPagePassThruEditResponseEnvelopeJSON) RawJSON() string return r.raw } -type SettingOriginErrorPagePassThruEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [SettingOriginErrorPagePassThruEditResponseEnvelopeErrors] -type settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginErrorPagePassThruEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOriginErrorPagePassThruEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingOriginErrorPagePassThruEditResponseEnvelopeMessages] -type settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginErrorPagePassThruEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingOriginErrorPagePassThruGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingOriginErrorPagePassThruGetResponseEnvelope struct { - Errors []SettingOriginErrorPagePassThruGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOriginErrorPagePassThruGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare will proxy customer error pages on any 502,504 errors on origin // server instead of showing a default Cloudflare error page. This does not apply // to 522 errors and is limited to Enterprise Zones. - Result ZoneSettingOriginErrorPagePassThru `json:"result"` + Result OriginErrorPagePassThru `json:"result"` JSON settingOriginErrorPagePassThruGetResponseEnvelopeJSON `json:"-"` } @@ -306,51 +239,3 @@ func (r *SettingOriginErrorPagePassThruGetResponseEnvelope) UnmarshalJSON(data [ func (r settingOriginErrorPagePassThruGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingOriginErrorPagePassThruGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [SettingOriginErrorPagePassThruGetResponseEnvelopeErrors] -type settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginErrorPagePassThruGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOriginErrorPagePassThruGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingOriginErrorPagePassThruGetResponseEnvelopeMessages] -type settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginErrorPagePassThruGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingoriginmaxhttpversion.go b/zones/settingoriginmaxhttpversion.go index 32d943516db..66242bf3ab2 100644 --- a/zones/settingoriginmaxhttpversion.go +++ b/zones/settingoriginmaxhttpversion.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -68,6 +69,21 @@ func (r *SettingOriginMaxHTTPVersionService) Get(ctx context.Context, query Sett return } +// Value of the zone setting. +type OriginMaxHTTPVersion string + +const ( + OriginMaxHTTPVersionOriginMaxHTTPVersion OriginMaxHTTPVersion = "origin_max_http_version" +) + +func (r OriginMaxHTTPVersion) IsKnown() bool { + switch r { + case OriginMaxHTTPVersionOriginMaxHTTPVersion: + return true + } + return false +} + // Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will // attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 // requests to your origin. (Refer to @@ -76,7 +92,7 @@ func (r *SettingOriginMaxHTTPVersionService) Get(ctx context.Context, query Sett // where it is "1" type SettingOriginMaxHTTPVersionEditResponse struct { // Value of the zone setting. - ID SettingOriginMaxHTTPVersionEditResponseID `json:"id,required"` + ID OriginMaxHTTPVersion `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the Origin Max HTTP Version Setting. @@ -102,21 +118,6 @@ func (r settingOriginMaxHTTPVersionEditResponseJSON) RawJSON() string { return r.raw } -// Value of the zone setting. -type SettingOriginMaxHTTPVersionEditResponseID string - -const ( - SettingOriginMaxHTTPVersionEditResponseIDOriginMaxHTTPVersion SettingOriginMaxHTTPVersionEditResponseID = "origin_max_http_version" -) - -func (r SettingOriginMaxHTTPVersionEditResponseID) IsKnown() bool { - switch r { - case SettingOriginMaxHTTPVersionEditResponseIDOriginMaxHTTPVersion: - return true - } - return false -} - // Value of the Origin Max HTTP Version Setting. type SettingOriginMaxHTTPVersionEditResponseValue string @@ -141,7 +142,7 @@ func (r SettingOriginMaxHTTPVersionEditResponseValue) IsKnown() bool { // where it is "1" type SettingOriginMaxHTTPVersionGetResponse struct { // Value of the zone setting. - ID SettingOriginMaxHTTPVersionGetResponseID `json:"id,required"` + ID OriginMaxHTTPVersion `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the Origin Max HTTP Version Setting. @@ -167,21 +168,6 @@ func (r settingOriginMaxHTTPVersionGetResponseJSON) RawJSON() string { return r.raw } -// Value of the zone setting. -type SettingOriginMaxHTTPVersionGetResponseID string - -const ( - SettingOriginMaxHTTPVersionGetResponseIDOriginMaxHTTPVersion SettingOriginMaxHTTPVersionGetResponseID = "origin_max_http_version" -) - -func (r SettingOriginMaxHTTPVersionGetResponseID) IsKnown() bool { - switch r { - case SettingOriginMaxHTTPVersionGetResponseIDOriginMaxHTTPVersion: - return true - } - return false -} - // Value of the Origin Max HTTP Version Setting. type SettingOriginMaxHTTPVersionGetResponseValue string @@ -226,8 +212,8 @@ func (r SettingOriginMaxHTTPVersionEditParamsValue) IsKnown() bool { } type SettingOriginMaxHTTPVersionEditResponseEnvelope struct { - Errors []SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will // attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 // requests to your origin. (Refer to @@ -259,53 +245,6 @@ func (r settingOriginMaxHTTPVersionEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors] -type settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages] -type settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingOriginMaxHTTPVersionEditResponseEnvelopeSuccess bool @@ -327,8 +266,8 @@ type SettingOriginMaxHTTPVersionGetParams struct { } type SettingOriginMaxHTTPVersionGetResponseEnvelope struct { - Errors []SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will // attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 // requests to your origin. (Refer to @@ -360,52 +299,6 @@ func (r settingOriginMaxHTTPVersionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors] -type settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages] -type settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SettingOriginMaxHTTPVersionGetResponseEnvelopeSuccess bool diff --git a/zones/settingpolish.go b/zones/settingpolish.go index fc0cef4506c..8952f4c2ff3 100644 --- a/zones/settingpolish.go +++ b/zones/settingpolish.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingPolishService(opts ...option.RequestOption) (r *SettingPolishServ // Automatically optimize image loading for website visitors on mobile devices. // Refer to our [blog post](http://blog.cloudflare.com/polish-solving-mobile-speed) // for more information. -func (r *SettingPolishService) Edit(ctx context.Context, params SettingPolishEditParams, opts ...option.RequestOption) (res *ZoneSettingPolish, err error) { +func (r *SettingPolishService) Edit(ctx context.Context, params SettingPolishEditParams, opts ...option.RequestOption) (res *Polish, err error) { opts = append(r.Options[:], opts...) var env SettingPolishEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/polish", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingPolishService) Edit(ctx context.Context, params SettingPolishEdi // Automatically optimize image loading for website visitors on mobile devices. // Refer to our [blog post](http://blog.cloudflare.com/polish-solving-mobile-speed) // for more information. -func (r *SettingPolishService) Get(ctx context.Context, query SettingPolishGetParams, opts ...option.RequestOption) (res *ZoneSettingPolish, err error) { +func (r *SettingPolishService) Get(ctx context.Context, query SettingPolishGetParams, opts ...option.RequestOption) (res *Polish, err error) { opts = append(r.Options[:], opts...) var env SettingPolishGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/polish", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingPolishService) Get(ctx context.Context, query SettingPolishGetPa // image loading. Larger JPEGs are converted to progressive images, loading a // lower-resolution image first and ending in a higher-resolution version. Not // recommended for hi-res photography sites. -type ZoneSettingPolish struct { +type Polish struct { // ID of the zone setting. - ID ZoneSettingPolishID `json:"id,required"` + ID PolishID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingPolishValue `json:"value,required"` + Value PolishValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingPolishEditable `json:"editable"` + Editable PolishEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPolishJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON polishJSON `json:"-"` } -// zoneSettingPolishJSON contains the JSON metadata for the struct -// [ZoneSettingPolish] -type zoneSettingPolishJSON struct { +// polishJSON contains the JSON metadata for the struct [Polish] +type polishJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,45 +92,41 @@ type zoneSettingPolishJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingPolish) UnmarshalJSON(data []byte) (err error) { +func (r *Polish) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingPolishJSON) RawJSON() string { +func (r polishJSON) RawJSON() string { return r.raw } -func (r ZoneSettingPolish) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingPolish) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingPolishID string +type PolishID string const ( - ZoneSettingPolishIDPolish ZoneSettingPolishID = "polish" + PolishIDPolish PolishID = "polish" ) -func (r ZoneSettingPolishID) IsKnown() bool { +func (r PolishID) IsKnown() bool { switch r { - case ZoneSettingPolishIDPolish: + case PolishIDPolish: return true } return false } // Current value of the zone setting. -type ZoneSettingPolishValue string +type PolishValue string const ( - ZoneSettingPolishValueOff ZoneSettingPolishValue = "off" - ZoneSettingPolishValueLossless ZoneSettingPolishValue = "lossless" - ZoneSettingPolishValueLossy ZoneSettingPolishValue = "lossy" + PolishValueOff PolishValue = "off" + PolishValueLossless PolishValue = "lossless" + PolishValueLossy PolishValue = "lossy" ) -func (r ZoneSettingPolishValue) IsKnown() bool { +func (r PolishValue) IsKnown() bool { switch r { - case ZoneSettingPolishValueOff, ZoneSettingPolishValueLossless, ZoneSettingPolishValueLossy: + case PolishValueOff, PolishValueLossless, PolishValueLossy: return true } return false @@ -138,16 +134,16 @@ func (r ZoneSettingPolishValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingPolishEditable bool +type PolishEditable bool const ( - ZoneSettingPolishEditableTrue ZoneSettingPolishEditable = true - ZoneSettingPolishEditableFalse ZoneSettingPolishEditable = false + PolishEditableTrue PolishEditable = true + PolishEditableFalse PolishEditable = false ) -func (r ZoneSettingPolishEditable) IsKnown() bool { +func (r PolishEditable) IsKnown() bool { switch r { - case ZoneSettingPolishEditableTrue, ZoneSettingPolishEditableFalse: + case PolishEditableTrue, PolishEditableFalse: return true } return false @@ -159,19 +155,17 @@ func (r ZoneSettingPolishEditable) IsKnown() bool { // image loading. Larger JPEGs are converted to progressive images, loading a // lower-resolution image first and ending in a higher-resolution version. Not // recommended for hi-res photography sites. -type ZoneSettingPolishParam struct { +type PolishParam struct { // ID of the zone setting. - ID param.Field[ZoneSettingPolishID] `json:"id,required"` + ID param.Field[PolishID] `json:"id,required"` // Current value of the zone setting. - Value param.Field[ZoneSettingPolishValue] `json:"value,required"` + Value param.Field[PolishValue] `json:"value,required"` } -func (r ZoneSettingPolishParam) MarshalJSON() (data []byte, err error) { +func (r PolishParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingPolishParam) implementsZonesSettingEditParamsItem() {} - type SettingPolishEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -181,7 +175,7 @@ type SettingPolishEditParams struct { // image loading. Larger JPEGs are converted to progressive images, loading a // lower-resolution image first and ending in a higher-resolution version. Not // recommended for hi-res photography sites. - Value param.Field[ZoneSettingPolishParam] `json:"value,required"` + Value param.Field[PolishParam] `json:"value,required"` } func (r SettingPolishEditParams) MarshalJSON() (data []byte, err error) { @@ -189,8 +183,8 @@ func (r SettingPolishEditParams) MarshalJSON() (data []byte, err error) { } type SettingPolishEditResponseEnvelope struct { - Errors []SettingPolishEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingPolishEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Removes metadata and compresses your images for faster page load times. Basic @@ -199,7 +193,7 @@ type SettingPolishEditResponseEnvelope struct { // image loading. Larger JPEGs are converted to progressive images, loading a // lower-resolution image first and ending in a higher-resolution version. Not // recommended for hi-res photography sites. - Result ZoneSettingPolish `json:"result"` + Result Polish `json:"result"` JSON settingPolishEditResponseEnvelopeJSON `json:"-"` } @@ -222,60 +216,14 @@ func (r settingPolishEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingPolishEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPolishEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingPolishEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingPolishEditResponseEnvelopeErrors] -type settingPolishEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPolishEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPolishEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingPolishEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPolishEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingPolishEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingPolishEditResponseEnvelopeMessages] -type settingPolishEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPolishEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPolishEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingPolishGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingPolishGetResponseEnvelope struct { - Errors []SettingPolishGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingPolishGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Removes metadata and compresses your images for faster page load times. Basic @@ -284,7 +232,7 @@ type SettingPolishGetResponseEnvelope struct { // image loading. Larger JPEGs are converted to progressive images, loading a // lower-resolution image first and ending in a higher-resolution version. Not // recommended for hi-res photography sites. - Result ZoneSettingPolish `json:"result"` + Result Polish `json:"result"` JSON settingPolishGetResponseEnvelopeJSON `json:"-"` } @@ -306,49 +254,3 @@ func (r *SettingPolishGetResponseEnvelope) UnmarshalJSON(data []byte) (err error func (r settingPolishGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingPolishGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPolishGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingPolishGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingPolishGetResponseEnvelopeErrors] -type settingPolishGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPolishGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPolishGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingPolishGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPolishGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingPolishGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingPolishGetResponseEnvelopeMessages] -type settingPolishGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPolishGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPolishGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingpolish_test.go b/zones/settingpolish_test.go index 762f56783f9..a43ad239246 100644 --- a/zones/settingpolish_test.go +++ b/zones/settingpolish_test.go @@ -30,9 +30,9 @@ func TestSettingPolishEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.Polish.Edit(context.TODO(), zones.SettingPolishEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingPolishParam{ - ID: cloudflare.F(zones.ZoneSettingPolishIDPolish), - Value: cloudflare.F(zones.ZoneSettingPolishValueOff), + Value: cloudflare.F(zones.PolishParam{ + ID: cloudflare.F(zones.PolishIDPolish), + Value: cloudflare.F(zones.PolishValueOff), }), }) if err != nil { diff --git a/zones/settingprefetchpreload.go b/zones/settingprefetchpreload.go index 7e9d1319741..a04e4601bde 100644 --- a/zones/settingprefetchpreload.go +++ b/zones/settingprefetchpreload.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingPrefetchPreloadService(opts ...option.RequestOption) (r *SettingP // Cloudflare will prefetch any URLs that are included in the response headers. // This is limited to Enterprise Zones. -func (r *SettingPrefetchPreloadService) Edit(ctx context.Context, params SettingPrefetchPreloadEditParams, opts ...option.RequestOption) (res *ZoneSettingPrefetchPreload, err error) { +func (r *SettingPrefetchPreloadService) Edit(ctx context.Context, params SettingPrefetchPreloadEditParams, opts ...option.RequestOption) (res *PrefetchPreload, err error) { opts = append(r.Options[:], opts...) var env SettingPrefetchPreloadEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/prefetch_preload", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingPrefetchPreloadService) Edit(ctx context.Context, params Setting // Cloudflare will prefetch any URLs that are included in the response headers. // This is limited to Enterprise Zones. -func (r *SettingPrefetchPreloadService) Get(ctx context.Context, query SettingPrefetchPreloadGetParams, opts ...option.RequestOption) (res *ZoneSettingPrefetchPreload, err error) { +func (r *SettingPrefetchPreloadService) Get(ctx context.Context, query SettingPrefetchPreloadGetParams, opts ...option.RequestOption) (res *PrefetchPreload, err error) { opts = append(r.Options[:], opts...) var env SettingPrefetchPreloadGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/prefetch_preload", query.ZoneID) @@ -62,22 +63,21 @@ func (r *SettingPrefetchPreloadService) Get(ctx context.Context, query SettingPr // Cloudflare will prefetch any URLs that are included in the response headers. // This is limited to Enterprise Zones. -type ZoneSettingPrefetchPreload struct { +type PrefetchPreload struct { // ID of the zone setting. - ID ZoneSettingPrefetchPreloadID `json:"id,required"` + ID PrefetchPreloadID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingPrefetchPreloadValue `json:"value,required"` + Value PrefetchPreloadValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingPrefetchPreloadEditable `json:"editable"` + Editable PrefetchPreloadEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPrefetchPreloadJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON prefetchPreloadJSON `json:"-"` } -// zoneSettingPrefetchPreloadJSON contains the JSON metadata for the struct -// [ZoneSettingPrefetchPreload] -type zoneSettingPrefetchPreloadJSON struct { +// prefetchPreloadJSON contains the JSON metadata for the struct [PrefetchPreload] +type prefetchPreloadJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -86,44 +86,40 @@ type zoneSettingPrefetchPreloadJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingPrefetchPreload) UnmarshalJSON(data []byte) (err error) { +func (r *PrefetchPreload) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingPrefetchPreloadJSON) RawJSON() string { +func (r prefetchPreloadJSON) RawJSON() string { return r.raw } -func (r ZoneSettingPrefetchPreload) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingPrefetchPreload) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingPrefetchPreloadID string +type PrefetchPreloadID string const ( - ZoneSettingPrefetchPreloadIDPrefetchPreload ZoneSettingPrefetchPreloadID = "prefetch_preload" + PrefetchPreloadIDPrefetchPreload PrefetchPreloadID = "prefetch_preload" ) -func (r ZoneSettingPrefetchPreloadID) IsKnown() bool { +func (r PrefetchPreloadID) IsKnown() bool { switch r { - case ZoneSettingPrefetchPreloadIDPrefetchPreload: + case PrefetchPreloadIDPrefetchPreload: return true } return false } // Current value of the zone setting. -type ZoneSettingPrefetchPreloadValue string +type PrefetchPreloadValue string const ( - ZoneSettingPrefetchPreloadValueOn ZoneSettingPrefetchPreloadValue = "on" - ZoneSettingPrefetchPreloadValueOff ZoneSettingPrefetchPreloadValue = "off" + PrefetchPreloadValueOn PrefetchPreloadValue = "on" + PrefetchPreloadValueOff PrefetchPreloadValue = "off" ) -func (r ZoneSettingPrefetchPreloadValue) IsKnown() bool { +func (r PrefetchPreloadValue) IsKnown() bool { switch r { - case ZoneSettingPrefetchPreloadValueOn, ZoneSettingPrefetchPreloadValueOff: + case PrefetchPreloadValueOn, PrefetchPreloadValueOff: return true } return false @@ -131,36 +127,21 @@ func (r ZoneSettingPrefetchPreloadValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingPrefetchPreloadEditable bool +type PrefetchPreloadEditable bool const ( - ZoneSettingPrefetchPreloadEditableTrue ZoneSettingPrefetchPreloadEditable = true - ZoneSettingPrefetchPreloadEditableFalse ZoneSettingPrefetchPreloadEditable = false + PrefetchPreloadEditableTrue PrefetchPreloadEditable = true + PrefetchPreloadEditableFalse PrefetchPreloadEditable = false ) -func (r ZoneSettingPrefetchPreloadEditable) IsKnown() bool { +func (r PrefetchPreloadEditable) IsKnown() bool { switch r { - case ZoneSettingPrefetchPreloadEditableTrue, ZoneSettingPrefetchPreloadEditableFalse: + case PrefetchPreloadEditableTrue, PrefetchPreloadEditableFalse: return true } return false } -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -type ZoneSettingPrefetchPreloadParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingPrefetchPreloadID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingPrefetchPreloadValue] `json:"value,required"` -} - -func (r ZoneSettingPrefetchPreloadParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingPrefetchPreloadParam) implementsZonesSettingEditParamsItem() {} - type SettingPrefetchPreloadEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -189,13 +170,13 @@ func (r SettingPrefetchPreloadEditParamsValue) IsKnown() bool { } type SettingPrefetchPreloadEditResponseEnvelope struct { - Errors []SettingPrefetchPreloadEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingPrefetchPreloadEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare will prefetch any URLs that are included in the response headers. // This is limited to Enterprise Zones. - Result ZoneSettingPrefetchPreload `json:"result"` + Result PrefetchPreload `json:"result"` JSON settingPrefetchPreloadEditResponseEnvelopeJSON `json:"-"` } @@ -218,65 +199,19 @@ func (r settingPrefetchPreloadEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingPrefetchPreloadEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPrefetchPreloadEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingPrefetchPreloadEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingPrefetchPreloadEditResponseEnvelopeErrors] -type settingPrefetchPreloadEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPrefetchPreloadEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPrefetchPreloadEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingPrefetchPreloadEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPrefetchPreloadEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingPrefetchPreloadEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingPrefetchPreloadEditResponseEnvelopeMessages] -type settingPrefetchPreloadEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPrefetchPreloadEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPrefetchPreloadEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingPrefetchPreloadGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingPrefetchPreloadGetResponseEnvelope struct { - Errors []SettingPrefetchPreloadGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingPrefetchPreloadGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare will prefetch any URLs that are included in the response headers. // This is limited to Enterprise Zones. - Result ZoneSettingPrefetchPreload `json:"result"` + Result PrefetchPreload `json:"result"` JSON settingPrefetchPreloadGetResponseEnvelopeJSON `json:"-"` } @@ -298,49 +233,3 @@ func (r *SettingPrefetchPreloadGetResponseEnvelope) UnmarshalJSON(data []byte) ( func (r settingPrefetchPreloadGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingPrefetchPreloadGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPrefetchPreloadGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingPrefetchPreloadGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingPrefetchPreloadGetResponseEnvelopeErrors] -type settingPrefetchPreloadGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPrefetchPreloadGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPrefetchPreloadGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingPrefetchPreloadGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPrefetchPreloadGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingPrefetchPreloadGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingPrefetchPreloadGetResponseEnvelopeMessages] -type settingPrefetchPreloadGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPrefetchPreloadGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPrefetchPreloadGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingproxyreadtimeout.go b/zones/settingproxyreadtimeout.go index 41653449d48..f224c58f92c 100644 --- a/zones/settingproxyreadtimeout.go +++ b/zones/settingproxyreadtimeout.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingProxyReadTimeoutService(opts ...option.RequestOption) (r *Setting } // Maximum time between two read operations from origin. -func (r *SettingProxyReadTimeoutService) Edit(ctx context.Context, params SettingProxyReadTimeoutEditParams, opts ...option.RequestOption) (res *ZoneSettingProxyReadTimeout, err error) { +func (r *SettingProxyReadTimeoutService) Edit(ctx context.Context, params SettingProxyReadTimeoutEditParams, opts ...option.RequestOption) (res *ProxyReadTimeout, err error) { opts = append(r.Options[:], opts...) var env SettingProxyReadTimeoutEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/proxy_read_timeout", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingProxyReadTimeoutService) Edit(ctx context.Context, params Settin } // Maximum time between two read operations from origin. -func (r *SettingProxyReadTimeoutService) Get(ctx context.Context, query SettingProxyReadTimeoutGetParams, opts ...option.RequestOption) (res *ZoneSettingProxyReadTimeout, err error) { +func (r *SettingProxyReadTimeoutService) Get(ctx context.Context, query SettingProxyReadTimeoutGetParams, opts ...option.RequestOption) (res *ProxyReadTimeout, err error) { opts = append(r.Options[:], opts...) var env SettingProxyReadTimeoutGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/proxy_read_timeout", query.ZoneID) @@ -59,22 +60,22 @@ func (r *SettingProxyReadTimeoutService) Get(ctx context.Context, query SettingP } // Maximum time between two read operations from origin. -type ZoneSettingProxyReadTimeout struct { +type ProxyReadTimeout struct { // ID of the zone setting. - ID ZoneSettingProxyReadTimeoutID `json:"id,required"` + ID ProxyReadTimeoutID `json:"id,required"` // Current value of the zone setting. Value float64 `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingProxyReadTimeoutEditable `json:"editable"` + Editable ProxyReadTimeoutEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingProxyReadTimeoutJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON proxyReadTimeoutJSON `json:"-"` } -// zoneSettingProxyReadTimeoutJSON contains the JSON metadata for the struct -// [ZoneSettingProxyReadTimeout] -type zoneSettingProxyReadTimeoutJSON struct { +// proxyReadTimeoutJSON contains the JSON metadata for the struct +// [ProxyReadTimeout] +type proxyReadTimeoutJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,28 +84,24 @@ type zoneSettingProxyReadTimeoutJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingProxyReadTimeout) UnmarshalJSON(data []byte) (err error) { +func (r *ProxyReadTimeout) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingProxyReadTimeoutJSON) RawJSON() string { +func (r proxyReadTimeoutJSON) RawJSON() string { return r.raw } -func (r ZoneSettingProxyReadTimeout) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingProxyReadTimeout) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingProxyReadTimeoutID string +type ProxyReadTimeoutID string const ( - ZoneSettingProxyReadTimeoutIDProxyReadTimeout ZoneSettingProxyReadTimeoutID = "proxy_read_timeout" + ProxyReadTimeoutIDProxyReadTimeout ProxyReadTimeoutID = "proxy_read_timeout" ) -func (r ZoneSettingProxyReadTimeoutID) IsKnown() bool { +func (r ProxyReadTimeoutID) IsKnown() bool { switch r { - case ZoneSettingProxyReadTimeoutIDProxyReadTimeout: + case ProxyReadTimeoutIDProxyReadTimeout: return true } return false @@ -112,40 +109,38 @@ func (r ZoneSettingProxyReadTimeoutID) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingProxyReadTimeoutEditable bool +type ProxyReadTimeoutEditable bool const ( - ZoneSettingProxyReadTimeoutEditableTrue ZoneSettingProxyReadTimeoutEditable = true - ZoneSettingProxyReadTimeoutEditableFalse ZoneSettingProxyReadTimeoutEditable = false + ProxyReadTimeoutEditableTrue ProxyReadTimeoutEditable = true + ProxyReadTimeoutEditableFalse ProxyReadTimeoutEditable = false ) -func (r ZoneSettingProxyReadTimeoutEditable) IsKnown() bool { +func (r ProxyReadTimeoutEditable) IsKnown() bool { switch r { - case ZoneSettingProxyReadTimeoutEditableTrue, ZoneSettingProxyReadTimeoutEditableFalse: + case ProxyReadTimeoutEditableTrue, ProxyReadTimeoutEditableFalse: return true } return false } // Maximum time between two read operations from origin. -type ZoneSettingProxyReadTimeoutParam struct { +type ProxyReadTimeoutParam struct { // ID of the zone setting. - ID param.Field[ZoneSettingProxyReadTimeoutID] `json:"id,required"` + ID param.Field[ProxyReadTimeoutID] `json:"id,required"` // Current value of the zone setting. Value param.Field[float64] `json:"value,required"` } -func (r ZoneSettingProxyReadTimeoutParam) MarshalJSON() (data []byte, err error) { +func (r ProxyReadTimeoutParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingProxyReadTimeoutParam) implementsZonesSettingEditParamsItem() {} - type SettingProxyReadTimeoutEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Maximum time between two read operations from origin. - Value param.Field[ZoneSettingProxyReadTimeoutParam] `json:"value,required"` + Value param.Field[ProxyReadTimeoutParam] `json:"value,required"` } func (r SettingProxyReadTimeoutEditParams) MarshalJSON() (data []byte, err error) { @@ -153,12 +148,12 @@ func (r SettingProxyReadTimeoutEditParams) MarshalJSON() (data []byte, err error } type SettingProxyReadTimeoutEditResponseEnvelope struct { - Errors []SettingProxyReadTimeoutEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingProxyReadTimeoutEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Maximum time between two read operations from origin. - Result ZoneSettingProxyReadTimeout `json:"result"` + Result ProxyReadTimeout `json:"result"` JSON settingProxyReadTimeoutEditResponseEnvelopeJSON `json:"-"` } @@ -181,64 +176,18 @@ func (r settingProxyReadTimeoutEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingProxyReadTimeoutEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingProxyReadTimeoutEditResponseEnvelopeErrors] -type settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingProxyReadTimeoutEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingProxyReadTimeoutEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingProxyReadTimeoutEditResponseEnvelopeMessages] -type settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingProxyReadTimeoutEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingProxyReadTimeoutGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingProxyReadTimeoutGetResponseEnvelope struct { - Errors []SettingProxyReadTimeoutGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingProxyReadTimeoutGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Maximum time between two read operations from origin. - Result ZoneSettingProxyReadTimeout `json:"result"` + Result ProxyReadTimeout `json:"result"` JSON settingProxyReadTimeoutGetResponseEnvelopeJSON `json:"-"` } @@ -260,49 +209,3 @@ func (r *SettingProxyReadTimeoutGetResponseEnvelope) UnmarshalJSON(data []byte) func (r settingProxyReadTimeoutGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingProxyReadTimeoutGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingProxyReadTimeoutGetResponseEnvelopeErrors] -type settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingProxyReadTimeoutGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingProxyReadTimeoutGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingProxyReadTimeoutGetResponseEnvelopeMessages] -type settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingProxyReadTimeoutGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingproxyreadtimeout_test.go b/zones/settingproxyreadtimeout_test.go index b75cb7eeb6a..aaf8688af73 100644 --- a/zones/settingproxyreadtimeout_test.go +++ b/zones/settingproxyreadtimeout_test.go @@ -30,8 +30,8 @@ func TestSettingProxyReadTimeoutEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.ProxyReadTimeout.Edit(context.TODO(), zones.SettingProxyReadTimeoutEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingProxyReadTimeoutParam{ - ID: cloudflare.F(zones.ZoneSettingProxyReadTimeoutIDProxyReadTimeout), + Value: cloudflare.F(zones.ProxyReadTimeoutParam{ + ID: cloudflare.F(zones.ProxyReadTimeoutIDProxyReadTimeout), Value: cloudflare.F(0.000000), }), }) diff --git a/zones/settingpseudoipv4.go b/zones/settingpseudoipv4.go index bd5b335b82e..3096f2f582c 100644 --- a/zones/settingpseudoipv4.go +++ b/zones/settingpseudoipv4.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingPseudoIPV4Service(opts ...option.RequestOption) (r *SettingPseudo } // Value of the Pseudo IPv4 setting. -func (r *SettingPseudoIPV4Service) Edit(ctx context.Context, params SettingPseudoIPV4EditParams, opts ...option.RequestOption) (res *ZoneSettingPseudoIPV4, err error) { +func (r *SettingPseudoIPV4Service) Edit(ctx context.Context, params SettingPseudoIPV4EditParams, opts ...option.RequestOption) (res *PseudoIPV4, err error) { opts = append(r.Options[:], opts...) var env SettingPseudoIPV4EditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/pseudo_ipv4", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingPseudoIPV4Service) Edit(ctx context.Context, params SettingPseud } // Value of the Pseudo IPv4 setting. -func (r *SettingPseudoIPV4Service) Get(ctx context.Context, query SettingPseudoIPV4GetParams, opts ...option.RequestOption) (res *ZoneSettingPseudoIPV4, err error) { +func (r *SettingPseudoIPV4Service) Get(ctx context.Context, query SettingPseudoIPV4GetParams, opts ...option.RequestOption) (res *PseudoIPV4, err error) { opts = append(r.Options[:], opts...) var env SettingPseudoIPV4GetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/pseudo_ipv4", query.ZoneID) @@ -59,22 +60,21 @@ func (r *SettingPseudoIPV4Service) Get(ctx context.Context, query SettingPseudoI } // The value set for the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4 struct { +type PseudoIPV4 struct { // Value of the Pseudo IPv4 setting. - ID ZoneSettingPseudoIPV4ID `json:"id,required"` + ID PseudoIPV4ID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingPseudoIPV4Value `json:"value,required"` + Value PseudoIPV4Value `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingPseudoIPV4Editable `json:"editable"` + Editable PseudoIPV4Editable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPseudoIPV4JSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON pseudoIPV4JSON `json:"-"` } -// zoneSettingPseudoIPV4JSON contains the JSON metadata for the struct -// [ZoneSettingPseudoIPV4] -type zoneSettingPseudoIPV4JSON struct { +// pseudoIPV4JSON contains the JSON metadata for the struct [PseudoIPV4] +type pseudoIPV4JSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,45 +83,41 @@ type zoneSettingPseudoIPV4JSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingPseudoIPV4) UnmarshalJSON(data []byte) (err error) { +func (r *PseudoIPV4) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingPseudoIPV4JSON) RawJSON() string { +func (r pseudoIPV4JSON) RawJSON() string { return r.raw } -func (r ZoneSettingPseudoIPV4) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingPseudoIPV4) implementsZonesSettingGetResponse() {} - // Value of the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4ID string +type PseudoIPV4ID string const ( - ZoneSettingPseudoIPV4IDPseudoIPV4 ZoneSettingPseudoIPV4ID = "pseudo_ipv4" + PseudoIPV4IDPseudoIPV4 PseudoIPV4ID = "pseudo_ipv4" ) -func (r ZoneSettingPseudoIPV4ID) IsKnown() bool { +func (r PseudoIPV4ID) IsKnown() bool { switch r { - case ZoneSettingPseudoIPV4IDPseudoIPV4: + case PseudoIPV4IDPseudoIPV4: return true } return false } // Current value of the zone setting. -type ZoneSettingPseudoIPV4Value string +type PseudoIPV4Value string const ( - ZoneSettingPseudoIPV4ValueOff ZoneSettingPseudoIPV4Value = "off" - ZoneSettingPseudoIPV4ValueAddHeader ZoneSettingPseudoIPV4Value = "add_header" - ZoneSettingPseudoIPV4ValueOverwriteHeader ZoneSettingPseudoIPV4Value = "overwrite_header" + PseudoIPV4ValueOff PseudoIPV4Value = "off" + PseudoIPV4ValueAddHeader PseudoIPV4Value = "add_header" + PseudoIPV4ValueOverwriteHeader PseudoIPV4Value = "overwrite_header" ) -func (r ZoneSettingPseudoIPV4Value) IsKnown() bool { +func (r PseudoIPV4Value) IsKnown() bool { switch r { - case ZoneSettingPseudoIPV4ValueOff, ZoneSettingPseudoIPV4ValueAddHeader, ZoneSettingPseudoIPV4ValueOverwriteHeader: + case PseudoIPV4ValueOff, PseudoIPV4ValueAddHeader, PseudoIPV4ValueOverwriteHeader: return true } return false @@ -129,35 +125,21 @@ func (r ZoneSettingPseudoIPV4Value) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingPseudoIPV4Editable bool +type PseudoIPV4Editable bool const ( - ZoneSettingPseudoIPV4EditableTrue ZoneSettingPseudoIPV4Editable = true - ZoneSettingPseudoIPV4EditableFalse ZoneSettingPseudoIPV4Editable = false + PseudoIPV4EditableTrue PseudoIPV4Editable = true + PseudoIPV4EditableFalse PseudoIPV4Editable = false ) -func (r ZoneSettingPseudoIPV4Editable) IsKnown() bool { +func (r PseudoIPV4Editable) IsKnown() bool { switch r { - case ZoneSettingPseudoIPV4EditableTrue, ZoneSettingPseudoIPV4EditableFalse: + case PseudoIPV4EditableTrue, PseudoIPV4EditableFalse: return true } return false } -// The value set for the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4Param struct { - // Value of the Pseudo IPv4 setting. - ID param.Field[ZoneSettingPseudoIPV4ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingPseudoIPV4Value] `json:"value,required"` -} - -func (r ZoneSettingPseudoIPV4Param) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingPseudoIPV4Param) implementsZonesSettingEditParamsItem() {} - type SettingPseudoIPV4EditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -187,12 +169,12 @@ func (r SettingPseudoIPV4EditParamsValue) IsKnown() bool { } type SettingPseudoIPV4EditResponseEnvelope struct { - Errors []SettingPseudoIPV4EditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingPseudoIPV4EditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // The value set for the Pseudo IPv4 setting. - Result ZoneSettingPseudoIPV4 `json:"result"` + Result PseudoIPV4 `json:"result"` JSON settingPseudoIPV4EditResponseEnvelopeJSON `json:"-"` } @@ -215,64 +197,18 @@ func (r settingPseudoIPV4EditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingPseudoIPV4EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPseudoIPV4EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingPseudoIPV4EditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingPseudoIPV4EditResponseEnvelopeErrors] -type settingPseudoIPV4EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPseudoIPV4EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPseudoIPV4EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingPseudoIPV4EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPseudoIPV4EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingPseudoIPV4EditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingPseudoIPV4EditResponseEnvelopeMessages] -type settingPseudoIPV4EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPseudoIPV4EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPseudoIPV4EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingPseudoIPV4GetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingPseudoIPV4GetResponseEnvelope struct { - Errors []SettingPseudoIPV4GetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingPseudoIPV4GetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // The value set for the Pseudo IPv4 setting. - Result ZoneSettingPseudoIPV4 `json:"result"` + Result PseudoIPV4 `json:"result"` JSON settingPseudoIPV4GetResponseEnvelopeJSON `json:"-"` } @@ -294,49 +230,3 @@ func (r *SettingPseudoIPV4GetResponseEnvelope) UnmarshalJSON(data []byte) (err e func (r settingPseudoIPV4GetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingPseudoIPV4GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPseudoIPV4GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingPseudoIPV4GetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingPseudoIPV4GetResponseEnvelopeErrors] -type settingPseudoIPV4GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPseudoIPV4GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPseudoIPV4GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingPseudoIPV4GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingPseudoIPV4GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingPseudoIPV4GetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingPseudoIPV4GetResponseEnvelopeMessages] -type settingPseudoIPV4GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingPseudoIPV4GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingPseudoIPV4GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingresponsebuffering.go b/zones/settingresponsebuffering.go index 84aa39c956e..4199ed956d2 100644 --- a/zones/settingresponsebuffering.go +++ b/zones/settingresponsebuffering.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewSettingResponseBufferingService(opts ...option.RequestOption) (r *Settin // may buffer the whole payload to deliver it at once to the client versus allowing // it to be delivered in chunks. By default, the proxied server streams directly // and is not buffered by Cloudflare. This is limited to Enterprise Zones. -func (r *SettingResponseBufferingService) Edit(ctx context.Context, params SettingResponseBufferingEditParams, opts ...option.RequestOption) (res *ZoneSettingBuffering, err error) { +func (r *SettingResponseBufferingService) Edit(ctx context.Context, params SettingResponseBufferingEditParams, opts ...option.RequestOption) (res *ResponseBuffering, err error) { opts = append(r.Options[:], opts...) var env SettingResponseBufferingEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/response_buffering", params.ZoneID) @@ -52,7 +53,7 @@ func (r *SettingResponseBufferingService) Edit(ctx context.Context, params Setti // may buffer the whole payload to deliver it at once to the client versus allowing // it to be delivered in chunks. By default, the proxied server streams directly // and is not buffered by Cloudflare. This is limited to Enterprise Zones. -func (r *SettingResponseBufferingService) Get(ctx context.Context, query SettingResponseBufferingGetParams, opts ...option.RequestOption) (res *ZoneSettingBuffering, err error) { +func (r *SettingResponseBufferingService) Get(ctx context.Context, query SettingResponseBufferingGetParams, opts ...option.RequestOption) (res *ResponseBuffering, err error) { opts = append(r.Options[:], opts...) var env SettingResponseBufferingGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/response_buffering", query.ZoneID) @@ -68,22 +69,22 @@ func (r *SettingResponseBufferingService) Get(ctx context.Context, query Setting // may buffer the whole payload to deliver it at once to the client versus allowing // it to be delivered in chunks. By default, the proxied server streams directly // and is not buffered by Cloudflare. This is limited to Enterprise Zones. -type ZoneSettingBuffering struct { +type ResponseBuffering struct { // ID of the zone setting. - ID ZoneSettingBufferingID `json:"id,required"` + ID ResponseBufferingID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingBufferingValue `json:"value,required"` + Value ResponseBufferingValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingBufferingEditable `json:"editable"` + Editable ResponseBufferingEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBufferingJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON responseBufferingJSON `json:"-"` } -// zoneSettingBufferingJSON contains the JSON metadata for the struct -// [ZoneSettingBuffering] -type zoneSettingBufferingJSON struct { +// responseBufferingJSON contains the JSON metadata for the struct +// [ResponseBuffering] +type responseBufferingJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,44 +93,40 @@ type zoneSettingBufferingJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingBuffering) UnmarshalJSON(data []byte) (err error) { +func (r *ResponseBuffering) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingBufferingJSON) RawJSON() string { +func (r responseBufferingJSON) RawJSON() string { return r.raw } -func (r ZoneSettingBuffering) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingBuffering) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingBufferingID string +type ResponseBufferingID string const ( - ZoneSettingBufferingIDResponseBuffering ZoneSettingBufferingID = "response_buffering" + ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering" ) -func (r ZoneSettingBufferingID) IsKnown() bool { +func (r ResponseBufferingID) IsKnown() bool { switch r { - case ZoneSettingBufferingIDResponseBuffering: + case ResponseBufferingIDResponseBuffering: return true } return false } // Current value of the zone setting. -type ZoneSettingBufferingValue string +type ResponseBufferingValue string const ( - ZoneSettingBufferingValueOn ZoneSettingBufferingValue = "on" - ZoneSettingBufferingValueOff ZoneSettingBufferingValue = "off" + ResponseBufferingValueOn ResponseBufferingValue = "on" + ResponseBufferingValueOff ResponseBufferingValue = "off" ) -func (r ZoneSettingBufferingValue) IsKnown() bool { +func (r ResponseBufferingValue) IsKnown() bool { switch r { - case ZoneSettingBufferingValueOn, ZoneSettingBufferingValueOff: + case ResponseBufferingValueOn, ResponseBufferingValueOff: return true } return false @@ -137,38 +134,21 @@ func (r ZoneSettingBufferingValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingBufferingEditable bool +type ResponseBufferingEditable bool const ( - ZoneSettingBufferingEditableTrue ZoneSettingBufferingEditable = true - ZoneSettingBufferingEditableFalse ZoneSettingBufferingEditable = false + ResponseBufferingEditableTrue ResponseBufferingEditable = true + ResponseBufferingEditableFalse ResponseBufferingEditable = false ) -func (r ZoneSettingBufferingEditable) IsKnown() bool { +func (r ResponseBufferingEditable) IsKnown() bool { switch r { - case ZoneSettingBufferingEditableTrue, ZoneSettingBufferingEditableFalse: + case ResponseBufferingEditableTrue, ResponseBufferingEditableFalse: return true } return false } -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -type ZoneSettingBufferingParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingBufferingID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingBufferingValue] `json:"value,required"` -} - -func (r ZoneSettingBufferingParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingBufferingParam) implementsZonesSettingEditParamsItem() {} - type SettingResponseBufferingEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -197,15 +177,15 @@ func (r SettingResponseBufferingEditParamsValue) IsKnown() bool { } type SettingResponseBufferingEditResponseEnvelope struct { - Errors []SettingResponseBufferingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingResponseBufferingEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enables or disables buffering of responses from the proxied server. Cloudflare // may buffer the whole payload to deliver it at once to the client versus allowing // it to be delivered in chunks. By default, the proxied server streams directly // and is not buffered by Cloudflare. This is limited to Enterprise Zones. - Result ZoneSettingBuffering `json:"result"` + Result ResponseBuffering `json:"result"` JSON settingResponseBufferingEditResponseEnvelopeJSON `json:"-"` } @@ -228,67 +208,21 @@ func (r settingResponseBufferingEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingResponseBufferingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingResponseBufferingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingResponseBufferingEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingResponseBufferingEditResponseEnvelopeErrors] -type settingResponseBufferingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingResponseBufferingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingResponseBufferingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingResponseBufferingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingResponseBufferingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingResponseBufferingEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingResponseBufferingEditResponseEnvelopeMessages] -type settingResponseBufferingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingResponseBufferingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingResponseBufferingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingResponseBufferingGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingResponseBufferingGetResponseEnvelope struct { - Errors []SettingResponseBufferingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingResponseBufferingGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enables or disables buffering of responses from the proxied server. Cloudflare // may buffer the whole payload to deliver it at once to the client versus allowing // it to be delivered in chunks. By default, the proxied server streams directly // and is not buffered by Cloudflare. This is limited to Enterprise Zones. - Result ZoneSettingBuffering `json:"result"` + Result ResponseBuffering `json:"result"` JSON settingResponseBufferingGetResponseEnvelopeJSON `json:"-"` } @@ -310,49 +244,3 @@ func (r *SettingResponseBufferingGetResponseEnvelope) UnmarshalJSON(data []byte) func (r settingResponseBufferingGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingResponseBufferingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingResponseBufferingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingResponseBufferingGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingResponseBufferingGetResponseEnvelopeErrors] -type settingResponseBufferingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingResponseBufferingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingResponseBufferingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingResponseBufferingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingResponseBufferingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingResponseBufferingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingResponseBufferingGetResponseEnvelopeMessages] -type settingResponseBufferingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingResponseBufferingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingResponseBufferingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingrocketloader.go b/zones/settingrocketloader.go index 54fe9b1865d..9aee7a9baac 100644 --- a/zones/settingrocketloader.go +++ b/zones/settingrocketloader.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -42,7 +43,7 @@ func NewSettingRocketLoaderService(opts ...option.RequestOption) (r *SettingRock // with no configuration required. Refer to // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) // for more information. -func (r *SettingRocketLoaderService) Edit(ctx context.Context, params SettingRocketLoaderEditParams, opts ...option.RequestOption) (res *ZoneSettingRocketLoader, err error) { +func (r *SettingRocketLoaderService) Edit(ctx context.Context, params SettingRocketLoaderEditParams, opts ...option.RequestOption) (res *RocketLoader, err error) { opts = append(r.Options[:], opts...) var env SettingRocketLoaderEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/rocket_loader", params.ZoneID) @@ -64,7 +65,7 @@ func (r *SettingRocketLoaderService) Edit(ctx context.Context, params SettingRoc // with no configuration required. Refer to // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) // for more information. -func (r *SettingRocketLoaderService) Get(ctx context.Context, query SettingRocketLoaderGetParams, opts ...option.RequestOption) (res *ZoneSettingRocketLoader, err error) { +func (r *SettingRocketLoaderService) Get(ctx context.Context, query SettingRocketLoaderGetParams, opts ...option.RequestOption) (res *RocketLoader, err error) { opts = append(r.Options[:], opts...) var env SettingRocketLoaderGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/rocket_loader", query.ZoneID) @@ -86,22 +87,21 @@ func (r *SettingRocketLoaderService) Get(ctx context.Context, query SettingRocke // with no configuration required. Refer to // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) // for more information. -type ZoneSettingRocketLoader struct { +type RocketLoader struct { // ID of the zone setting. - ID ZoneSettingRocketLoaderID `json:"id,required"` + ID RocketLoaderID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingRocketLoaderValue `json:"value,required"` + Value RocketLoaderValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingRocketLoaderEditable `json:"editable"` + Editable RocketLoaderEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingRocketLoaderJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON rocketLoaderJSON `json:"-"` } -// zoneSettingRocketLoaderJSON contains the JSON metadata for the struct -// [ZoneSettingRocketLoader] -type zoneSettingRocketLoaderJSON struct { +// rocketLoaderJSON contains the JSON metadata for the struct [RocketLoader] +type rocketLoaderJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -110,44 +110,40 @@ type zoneSettingRocketLoaderJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingRocketLoader) UnmarshalJSON(data []byte) (err error) { +func (r *RocketLoader) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingRocketLoaderJSON) RawJSON() string { +func (r rocketLoaderJSON) RawJSON() string { return r.raw } -func (r ZoneSettingRocketLoader) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingRocketLoader) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingRocketLoaderID string +type RocketLoaderID string const ( - ZoneSettingRocketLoaderIDRocketLoader ZoneSettingRocketLoaderID = "rocket_loader" + RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader" ) -func (r ZoneSettingRocketLoaderID) IsKnown() bool { +func (r RocketLoaderID) IsKnown() bool { switch r { - case ZoneSettingRocketLoaderIDRocketLoader: + case RocketLoaderIDRocketLoader: return true } return false } // Current value of the zone setting. -type ZoneSettingRocketLoaderValue string +type RocketLoaderValue string const ( - ZoneSettingRocketLoaderValueOn ZoneSettingRocketLoaderValue = "on" - ZoneSettingRocketLoaderValueOff ZoneSettingRocketLoaderValue = "off" + RocketLoaderValueOn RocketLoaderValue = "on" + RocketLoaderValueOff RocketLoaderValue = "off" ) -func (r ZoneSettingRocketLoaderValue) IsKnown() bool { +func (r RocketLoaderValue) IsKnown() bool { switch r { - case ZoneSettingRocketLoaderValueOn, ZoneSettingRocketLoaderValueOff: + case RocketLoaderValueOn, RocketLoaderValueOff: return true } return false @@ -155,16 +151,16 @@ func (r ZoneSettingRocketLoaderValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingRocketLoaderEditable bool +type RocketLoaderEditable bool const ( - ZoneSettingRocketLoaderEditableTrue ZoneSettingRocketLoaderEditable = true - ZoneSettingRocketLoaderEditableFalse ZoneSettingRocketLoaderEditable = false + RocketLoaderEditableTrue RocketLoaderEditable = true + RocketLoaderEditableFalse RocketLoaderEditable = false ) -func (r ZoneSettingRocketLoaderEditable) IsKnown() bool { +func (r RocketLoaderEditable) IsKnown() bool { switch r { - case ZoneSettingRocketLoaderEditableTrue, ZoneSettingRocketLoaderEditableFalse: + case RocketLoaderEditableTrue, RocketLoaderEditableFalse: return true } return false @@ -180,19 +176,17 @@ func (r ZoneSettingRocketLoaderEditable) IsKnown() bool { // with no configuration required. Refer to // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) // for more information. -type ZoneSettingRocketLoaderParam struct { +type RocketLoaderParam struct { // ID of the zone setting. - ID param.Field[ZoneSettingRocketLoaderID] `json:"id,required"` + ID param.Field[RocketLoaderID] `json:"id,required"` // Current value of the zone setting. - Value param.Field[ZoneSettingRocketLoaderValue] `json:"value,required"` + Value param.Field[RocketLoaderValue] `json:"value,required"` } -func (r ZoneSettingRocketLoaderParam) MarshalJSON() (data []byte, err error) { +func (r RocketLoaderParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingRocketLoaderParam) implementsZonesSettingEditParamsItem() {} - type SettingRocketLoaderEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -206,7 +200,7 @@ type SettingRocketLoaderEditParams struct { // with no configuration required. Refer to // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) // for more information. - Value param.Field[ZoneSettingRocketLoaderParam] `json:"value,required"` + Value param.Field[RocketLoaderParam] `json:"value,required"` } func (r SettingRocketLoaderEditParams) MarshalJSON() (data []byte, err error) { @@ -214,8 +208,8 @@ func (r SettingRocketLoaderEditParams) MarshalJSON() (data []byte, err error) { } type SettingRocketLoaderEditResponseEnvelope struct { - Errors []SettingRocketLoaderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingRocketLoaderEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that @@ -228,7 +222,7 @@ type SettingRocketLoaderEditResponseEnvelope struct { // with no configuration required. Refer to // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) // for more information. - Result ZoneSettingRocketLoader `json:"result"` + Result RocketLoader `json:"result"` JSON settingRocketLoaderEditResponseEnvelopeJSON `json:"-"` } @@ -251,60 +245,14 @@ func (r settingRocketLoaderEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingRocketLoaderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingRocketLoaderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingRocketLoaderEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingRocketLoaderEditResponseEnvelopeErrors] -type settingRocketLoaderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingRocketLoaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingRocketLoaderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingRocketLoaderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingRocketLoaderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingRocketLoaderEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingRocketLoaderEditResponseEnvelopeMessages] -type settingRocketLoaderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingRocketLoaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingRocketLoaderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingRocketLoaderGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingRocketLoaderGetResponseEnvelope struct { - Errors []SettingRocketLoaderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingRocketLoaderGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that @@ -317,7 +265,7 @@ type SettingRocketLoaderGetResponseEnvelope struct { // with no configuration required. Refer to // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) // for more information. - Result ZoneSettingRocketLoader `json:"result"` + Result RocketLoader `json:"result"` JSON settingRocketLoaderGetResponseEnvelopeJSON `json:"-"` } @@ -339,49 +287,3 @@ func (r *SettingRocketLoaderGetResponseEnvelope) UnmarshalJSON(data []byte) (err func (r settingRocketLoaderGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingRocketLoaderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingRocketLoaderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingRocketLoaderGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingRocketLoaderGetResponseEnvelopeErrors] -type settingRocketLoaderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingRocketLoaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingRocketLoaderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingRocketLoaderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingRocketLoaderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingRocketLoaderGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingRocketLoaderGetResponseEnvelopeMessages] -type settingRocketLoaderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingRocketLoaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingRocketLoaderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingrocketloader_test.go b/zones/settingrocketloader_test.go index da6f4416f1d..80aa014fa02 100644 --- a/zones/settingrocketloader_test.go +++ b/zones/settingrocketloader_test.go @@ -30,9 +30,9 @@ func TestSettingRocketLoaderEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.RocketLoader.Edit(context.TODO(), zones.SettingRocketLoaderEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingRocketLoaderParam{ - ID: cloudflare.F(zones.ZoneSettingRocketLoaderIDRocketLoader), - Value: cloudflare.F(zones.ZoneSettingRocketLoaderValueOn), + Value: cloudflare.F(zones.RocketLoaderParam{ + ID: cloudflare.F(zones.RocketLoaderIDRocketLoader), + Value: cloudflare.F(zones.RocketLoaderValueOn), }), }) if err != nil { diff --git a/zones/settingsecurityheader.go b/zones/settingsecurityheader.go index c9533e51d0e..52447c988b7 100644 --- a/zones/settingsecurityheader.go +++ b/zones/settingsecurityheader.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingSecurityHeaderService(opts ...option.RequestOption) (r *SettingSe } // Cloudflare security header for a zone. -func (r *SettingSecurityHeaderService) Edit(ctx context.Context, params SettingSecurityHeaderEditParams, opts ...option.RequestOption) (res *ZoneSettingSecurityHeader, err error) { +func (r *SettingSecurityHeaderService) Edit(ctx context.Context, params SettingSecurityHeaderEditParams, opts ...option.RequestOption) (res *SecurityHeaders, err error) { opts = append(r.Options[:], opts...) var env SettingSecurityHeaderEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/security_header", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingSecurityHeaderService) Edit(ctx context.Context, params SettingS } // Cloudflare security header for a zone. -func (r *SettingSecurityHeaderService) Get(ctx context.Context, query SettingSecurityHeaderGetParams, opts ...option.RequestOption) (res *ZoneSettingSecurityHeader, err error) { +func (r *SettingSecurityHeaderService) Get(ctx context.Context, query SettingSecurityHeaderGetParams, opts ...option.RequestOption) (res *SecurityHeaders, err error) { opts = append(r.Options[:], opts...) var env SettingSecurityHeaderGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/security_header", query.ZoneID) @@ -59,22 +60,21 @@ func (r *SettingSecurityHeaderService) Get(ctx context.Context, query SettingSec } // Cloudflare security header for a zone. -type ZoneSettingSecurityHeader struct { +type SecurityHeaders struct { // ID of the zone's security header. - ID ZoneSettingSecurityHeaderID `json:"id,required"` + ID SecurityHeadersID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingSecurityHeaderValue `json:"value,required"` + Value SecurityHeadersValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingSecurityHeaderEditable `json:"editable"` + Editable SecurityHeadersEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSecurityHeaderJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON securityHeadersJSON `json:"-"` } -// zoneSettingSecurityHeaderJSON contains the JSON metadata for the struct -// [ZoneSettingSecurityHeader] -type zoneSettingSecurityHeaderJSON struct { +// securityHeadersJSON contains the JSON metadata for the struct [SecurityHeaders] +type securityHeadersJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,58 +83,54 @@ type zoneSettingSecurityHeaderJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingSecurityHeader) UnmarshalJSON(data []byte) (err error) { +func (r *SecurityHeaders) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingSecurityHeaderJSON) RawJSON() string { +func (r securityHeadersJSON) RawJSON() string { return r.raw } -func (r ZoneSettingSecurityHeader) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingSecurityHeader) implementsZonesSettingGetResponse() {} - // ID of the zone's security header. -type ZoneSettingSecurityHeaderID string +type SecurityHeadersID string const ( - ZoneSettingSecurityHeaderIDSecurityHeader ZoneSettingSecurityHeaderID = "security_header" + SecurityHeadersIDSecurityHeader SecurityHeadersID = "security_header" ) -func (r ZoneSettingSecurityHeaderID) IsKnown() bool { +func (r SecurityHeadersID) IsKnown() bool { switch r { - case ZoneSettingSecurityHeaderIDSecurityHeader: + case SecurityHeadersIDSecurityHeader: return true } return false } // Current value of the zone setting. -type ZoneSettingSecurityHeaderValue struct { +type SecurityHeadersValue struct { // Strict Transport Security. - StrictTransportSecurity ZoneSettingSecurityHeaderValueStrictTransportSecurity `json:"strict_transport_security"` - JSON zoneSettingSecurityHeaderValueJSON `json:"-"` + StrictTransportSecurity SecurityHeadersValueStrictTransportSecurity `json:"strict_transport_security"` + JSON securityHeadersValueJSON `json:"-"` } -// zoneSettingSecurityHeaderValueJSON contains the JSON metadata for the struct -// [ZoneSettingSecurityHeaderValue] -type zoneSettingSecurityHeaderValueJSON struct { +// securityHeadersValueJSON contains the JSON metadata for the struct +// [SecurityHeadersValue] +type securityHeadersValueJSON struct { StrictTransportSecurity apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZoneSettingSecurityHeaderValue) UnmarshalJSON(data []byte) (err error) { +func (r *SecurityHeadersValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingSecurityHeaderValueJSON) RawJSON() string { +func (r securityHeadersValueJSON) RawJSON() string { return r.raw } // Strict Transport Security. -type ZoneSettingSecurityHeaderValueStrictTransportSecurity struct { +type SecurityHeadersValueStrictTransportSecurity struct { // Whether or not strict transport security is enabled. Enabled bool `json:"enabled"` // Include all subdomains for strict transport security. @@ -142,13 +138,13 @@ type ZoneSettingSecurityHeaderValueStrictTransportSecurity struct { // Max age in seconds of the strict transport security. MaxAge float64 `json:"max_age"` // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff bool `json:"nosniff"` - JSON zoneSettingSecurityHeaderValueStrictTransportSecurityJSON `json:"-"` + Nosniff bool `json:"nosniff"` + JSON securityHeadersValueStrictTransportSecurityJSON `json:"-"` } -// zoneSettingSecurityHeaderValueStrictTransportSecurityJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityHeaderValueStrictTransportSecurity] -type zoneSettingSecurityHeaderValueStrictTransportSecurityJSON struct { +// securityHeadersValueStrictTransportSecurityJSON contains the JSON metadata for +// the struct [SecurityHeadersValueStrictTransportSecurity] +type securityHeadersValueStrictTransportSecurityJSON struct { Enabled apijson.Field IncludeSubdomains apijson.Field MaxAge apijson.Field @@ -157,71 +153,31 @@ type zoneSettingSecurityHeaderValueStrictTransportSecurityJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingSecurityHeaderValueStrictTransportSecurity) UnmarshalJSON(data []byte) (err error) { +func (r *SecurityHeadersValueStrictTransportSecurity) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingSecurityHeaderValueStrictTransportSecurityJSON) RawJSON() string { +func (r securityHeadersValueStrictTransportSecurityJSON) RawJSON() string { return r.raw } // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingSecurityHeaderEditable bool +type SecurityHeadersEditable bool const ( - ZoneSettingSecurityHeaderEditableTrue ZoneSettingSecurityHeaderEditable = true - ZoneSettingSecurityHeaderEditableFalse ZoneSettingSecurityHeaderEditable = false + SecurityHeadersEditableTrue SecurityHeadersEditable = true + SecurityHeadersEditableFalse SecurityHeadersEditable = false ) -func (r ZoneSettingSecurityHeaderEditable) IsKnown() bool { +func (r SecurityHeadersEditable) IsKnown() bool { switch r { - case ZoneSettingSecurityHeaderEditableTrue, ZoneSettingSecurityHeaderEditableFalse: + case SecurityHeadersEditableTrue, SecurityHeadersEditableFalse: return true } return false } -// Cloudflare security header for a zone. -type ZoneSettingSecurityHeaderParam struct { - // ID of the zone's security header. - ID param.Field[ZoneSettingSecurityHeaderID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingSecurityHeaderValueParam] `json:"value,required"` -} - -func (r ZoneSettingSecurityHeaderParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingSecurityHeaderParam) implementsZonesSettingEditParamsItem() {} - -// Current value of the zone setting. -type ZoneSettingSecurityHeaderValueParam struct { - // Strict Transport Security. - StrictTransportSecurity param.Field[ZoneSettingSecurityHeaderValueStrictTransportSecurityParam] `json:"strict_transport_security"` -} - -func (r ZoneSettingSecurityHeaderValueParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Strict Transport Security. -type ZoneSettingSecurityHeaderValueStrictTransportSecurityParam struct { - // Whether or not strict transport security is enabled. - Enabled param.Field[bool] `json:"enabled"` - // Include all subdomains for strict transport security. - IncludeSubdomains param.Field[bool] `json:"include_subdomains"` - // Max age in seconds of the strict transport security. - MaxAge param.Field[float64] `json:"max_age"` - // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff param.Field[bool] `json:"nosniff"` -} - -func (r ZoneSettingSecurityHeaderValueStrictTransportSecurityParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SettingSecurityHeaderEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -258,12 +214,12 @@ func (r SettingSecurityHeaderEditParamsValueStrictTransportSecurity) MarshalJSON } type SettingSecurityHeaderEditResponseEnvelope struct { - Errors []SettingSecurityHeaderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSecurityHeaderEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare security header for a zone. - Result ZoneSettingSecurityHeader `json:"result"` + Result SecurityHeaders `json:"result"` JSON settingSecurityHeaderEditResponseEnvelopeJSON `json:"-"` } @@ -286,64 +242,18 @@ func (r settingSecurityHeaderEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingSecurityHeaderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityHeaderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSecurityHeaderEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingSecurityHeaderEditResponseEnvelopeErrors] -type settingSecurityHeaderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityHeaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityHeaderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSecurityHeaderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityHeaderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSecurityHeaderEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingSecurityHeaderEditResponseEnvelopeMessages] -type settingSecurityHeaderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityHeaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityHeaderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingSecurityHeaderGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingSecurityHeaderGetResponseEnvelope struct { - Errors []SettingSecurityHeaderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSecurityHeaderGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare security header for a zone. - Result ZoneSettingSecurityHeader `json:"result"` + Result SecurityHeaders `json:"result"` JSON settingSecurityHeaderGetResponseEnvelopeJSON `json:"-"` } @@ -365,49 +275,3 @@ func (r *SettingSecurityHeaderGetResponseEnvelope) UnmarshalJSON(data []byte) (e func (r settingSecurityHeaderGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingSecurityHeaderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityHeaderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSecurityHeaderGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingSecurityHeaderGetResponseEnvelopeErrors] -type settingSecurityHeaderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityHeaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityHeaderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSecurityHeaderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityHeaderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSecurityHeaderGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingSecurityHeaderGetResponseEnvelopeMessages] -type settingSecurityHeaderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityHeaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityHeaderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingsecuritylevel.go b/zones/settingsecuritylevel.go index 99cefc1883c..6242a6d3434 100644 --- a/zones/settingsecuritylevel.go +++ b/zones/settingsecuritylevel.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -36,7 +37,7 @@ func NewSettingSecurityLevelService(opts ...option.RequestOption) (r *SettingSec // automatically adjust each of the security settings. If you choose to customize // an individual security setting, the profile will become Custom. // (https://support.cloudflare.com/hc/en-us/articles/200170056). -func (r *SettingSecurityLevelService) Edit(ctx context.Context, params SettingSecurityLevelEditParams, opts ...option.RequestOption) (res *ZoneSettingSecurityLevel, err error) { +func (r *SettingSecurityLevelService) Edit(ctx context.Context, params SettingSecurityLevelEditParams, opts ...option.RequestOption) (res *SecurityLevel, err error) { opts = append(r.Options[:], opts...) var env SettingSecurityLevelEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/security_level", params.ZoneID) @@ -52,7 +53,7 @@ func (r *SettingSecurityLevelService) Edit(ctx context.Context, params SettingSe // automatically adjust each of the security settings. If you choose to customize // an individual security setting, the profile will become Custom. // (https://support.cloudflare.com/hc/en-us/articles/200170056). -func (r *SettingSecurityLevelService) Get(ctx context.Context, query SettingSecurityLevelGetParams, opts ...option.RequestOption) (res *ZoneSettingSecurityLevel, err error) { +func (r *SettingSecurityLevelService) Get(ctx context.Context, query SettingSecurityLevelGetParams, opts ...option.RequestOption) (res *SecurityLevel, err error) { opts = append(r.Options[:], opts...) var env SettingSecurityLevelGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/security_level", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingSecurityLevelService) Get(ctx context.Context, query SettingSecu // automatically adjust each of the security settings. If you choose to customize // an individual security setting, the profile will become Custom. // (https://support.cloudflare.com/hc/en-us/articles/200170056). -type ZoneSettingSecurityLevel struct { +type SecurityLevel struct { // ID of the zone setting. - ID ZoneSettingSecurityLevelID `json:"id,required"` + ID SecurityLevelID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingSecurityLevelValue `json:"value,required"` + Value SecurityLevelValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingSecurityLevelEditable `json:"editable"` + Editable SecurityLevelEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSecurityLevelJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON securityLevelJSON `json:"-"` } -// zoneSettingSecurityLevelJSON contains the JSON metadata for the struct -// [ZoneSettingSecurityLevel] -type zoneSettingSecurityLevelJSON struct { +// securityLevelJSON contains the JSON metadata for the struct [SecurityLevel] +type securityLevelJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,48 +92,44 @@ type zoneSettingSecurityLevelJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingSecurityLevel) UnmarshalJSON(data []byte) (err error) { +func (r *SecurityLevel) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingSecurityLevelJSON) RawJSON() string { +func (r securityLevelJSON) RawJSON() string { return r.raw } -func (r ZoneSettingSecurityLevel) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingSecurityLevel) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingSecurityLevelID string +type SecurityLevelID string const ( - ZoneSettingSecurityLevelIDSecurityLevel ZoneSettingSecurityLevelID = "security_level" + SecurityLevelIDSecurityLevel SecurityLevelID = "security_level" ) -func (r ZoneSettingSecurityLevelID) IsKnown() bool { +func (r SecurityLevelID) IsKnown() bool { switch r { - case ZoneSettingSecurityLevelIDSecurityLevel: + case SecurityLevelIDSecurityLevel: return true } return false } // Current value of the zone setting. -type ZoneSettingSecurityLevelValue string +type SecurityLevelValue string const ( - ZoneSettingSecurityLevelValueOff ZoneSettingSecurityLevelValue = "off" - ZoneSettingSecurityLevelValueEssentiallyOff ZoneSettingSecurityLevelValue = "essentially_off" - ZoneSettingSecurityLevelValueLow ZoneSettingSecurityLevelValue = "low" - ZoneSettingSecurityLevelValueMedium ZoneSettingSecurityLevelValue = "medium" - ZoneSettingSecurityLevelValueHigh ZoneSettingSecurityLevelValue = "high" - ZoneSettingSecurityLevelValueUnderAttack ZoneSettingSecurityLevelValue = "under_attack" + SecurityLevelValueOff SecurityLevelValue = "off" + SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off" + SecurityLevelValueLow SecurityLevelValue = "low" + SecurityLevelValueMedium SecurityLevelValue = "medium" + SecurityLevelValueHigh SecurityLevelValue = "high" + SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack" ) -func (r ZoneSettingSecurityLevelValue) IsKnown() bool { +func (r SecurityLevelValue) IsKnown() bool { switch r { - case ZoneSettingSecurityLevelValueOff, ZoneSettingSecurityLevelValueEssentiallyOff, ZoneSettingSecurityLevelValueLow, ZoneSettingSecurityLevelValueMedium, ZoneSettingSecurityLevelValueHigh, ZoneSettingSecurityLevelValueUnderAttack: + case SecurityLevelValueOff, SecurityLevelValueEssentiallyOff, SecurityLevelValueLow, SecurityLevelValueMedium, SecurityLevelValueHigh, SecurityLevelValueUnderAttack: return true } return false @@ -141,38 +137,21 @@ func (r ZoneSettingSecurityLevelValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingSecurityLevelEditable bool +type SecurityLevelEditable bool const ( - ZoneSettingSecurityLevelEditableTrue ZoneSettingSecurityLevelEditable = true - ZoneSettingSecurityLevelEditableFalse ZoneSettingSecurityLevelEditable = false + SecurityLevelEditableTrue SecurityLevelEditable = true + SecurityLevelEditableFalse SecurityLevelEditable = false ) -func (r ZoneSettingSecurityLevelEditable) IsKnown() bool { +func (r SecurityLevelEditable) IsKnown() bool { switch r { - case ZoneSettingSecurityLevelEditableTrue, ZoneSettingSecurityLevelEditableFalse: + case SecurityLevelEditableTrue, SecurityLevelEditableFalse: return true } return false } -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -type ZoneSettingSecurityLevelParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingSecurityLevelID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingSecurityLevelValue] `json:"value,required"` -} - -func (r ZoneSettingSecurityLevelParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingSecurityLevelParam) implementsZonesSettingEditParamsItem() {} - type SettingSecurityLevelEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -205,15 +184,15 @@ func (r SettingSecurityLevelEditParamsValue) IsKnown() bool { } type SettingSecurityLevelEditResponseEnvelope struct { - Errors []SettingSecurityLevelEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSecurityLevelEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Choose the appropriate security profile for your website, which will // automatically adjust each of the security settings. If you choose to customize // an individual security setting, the profile will become Custom. // (https://support.cloudflare.com/hc/en-us/articles/200170056). - Result ZoneSettingSecurityLevel `json:"result"` + Result SecurityLevel `json:"result"` JSON settingSecurityLevelEditResponseEnvelopeJSON `json:"-"` } @@ -236,67 +215,21 @@ func (r settingSecurityLevelEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingSecurityLevelEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityLevelEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSecurityLevelEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingSecurityLevelEditResponseEnvelopeErrors] -type settingSecurityLevelEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityLevelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityLevelEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSecurityLevelEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityLevelEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSecurityLevelEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingSecurityLevelEditResponseEnvelopeMessages] -type settingSecurityLevelEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityLevelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityLevelEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingSecurityLevelGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingSecurityLevelGetResponseEnvelope struct { - Errors []SettingSecurityLevelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSecurityLevelGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Choose the appropriate security profile for your website, which will // automatically adjust each of the security settings. If you choose to customize // an individual security setting, the profile will become Custom. // (https://support.cloudflare.com/hc/en-us/articles/200170056). - Result ZoneSettingSecurityLevel `json:"result"` + Result SecurityLevel `json:"result"` JSON settingSecurityLevelGetResponseEnvelopeJSON `json:"-"` } @@ -318,49 +251,3 @@ func (r *SettingSecurityLevelGetResponseEnvelope) UnmarshalJSON(data []byte) (er func (r settingSecurityLevelGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingSecurityLevelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityLevelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSecurityLevelGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingSecurityLevelGetResponseEnvelopeErrors] -type settingSecurityLevelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityLevelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityLevelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSecurityLevelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSecurityLevelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSecurityLevelGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingSecurityLevelGetResponseEnvelopeMessages] -type settingSecurityLevelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSecurityLevelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSecurityLevelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingserversideexclude.go b/zones/settingserversideexclude.go index 343855c0ff9..88a335e1225 100644 --- a/zones/settingserversideexclude.go +++ b/zones/settingserversideexclude.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -43,7 +44,7 @@ func NewSettingServerSideExcludeService(opts ...option.RequestOption) (r *Settin // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the // resource moves through our network to the visitor's computer. // (https://support.cloudflare.com/hc/en-us/articles/200170036). -func (r *SettingServerSideExcludeService) Edit(ctx context.Context, params SettingServerSideExcludeEditParams, opts ...option.RequestOption) (res *ZoneSettingServerSideExclude, err error) { +func (r *SettingServerSideExcludeService) Edit(ctx context.Context, params SettingServerSideExcludeEditParams, opts ...option.RequestOption) (res *ServerSideExcludes, err error) { opts = append(r.Options[:], opts...) var env SettingServerSideExcludeEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/server_side_exclude", params.ZoneID) @@ -66,7 +67,7 @@ func (r *SettingServerSideExcludeService) Edit(ctx context.Context, params Setti // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the // resource moves through our network to the visitor's computer. // (https://support.cloudflare.com/hc/en-us/articles/200170036). -func (r *SettingServerSideExcludeService) Get(ctx context.Context, query SettingServerSideExcludeGetParams, opts ...option.RequestOption) (res *ZoneSettingServerSideExclude, err error) { +func (r *SettingServerSideExcludeService) Get(ctx context.Context, query SettingServerSideExcludeGetParams, opts ...option.RequestOption) (res *ServerSideExcludes, err error) { opts = append(r.Options[:], opts...) var env SettingServerSideExcludeGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/server_side_exclude", query.ZoneID) @@ -89,22 +90,22 @@ func (r *SettingServerSideExcludeService) Get(ctx context.Context, query Setting // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the // resource moves through our network to the visitor's computer. // (https://support.cloudflare.com/hc/en-us/articles/200170036). -type ZoneSettingServerSideExclude struct { +type ServerSideExcludes struct { // ID of the zone setting. - ID ZoneSettingServerSideExcludeID `json:"id,required"` + ID ServerSideExcludesID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingServerSideExcludeValue `json:"value,required"` + Value ServerSideExcludesValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingServerSideExcludeEditable `json:"editable"` + Editable ServerSideExcludesEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingServerSideExcludeJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON serverSideExcludesJSON `json:"-"` } -// zoneSettingServerSideExcludeJSON contains the JSON metadata for the struct -// [ZoneSettingServerSideExclude] -type zoneSettingServerSideExcludeJSON struct { +// serverSideExcludesJSON contains the JSON metadata for the struct +// [ServerSideExcludes] +type serverSideExcludesJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -113,44 +114,40 @@ type zoneSettingServerSideExcludeJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingServerSideExclude) UnmarshalJSON(data []byte) (err error) { +func (r *ServerSideExcludes) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingServerSideExcludeJSON) RawJSON() string { +func (r serverSideExcludesJSON) RawJSON() string { return r.raw } -func (r ZoneSettingServerSideExclude) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingServerSideExclude) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingServerSideExcludeID string +type ServerSideExcludesID string const ( - ZoneSettingServerSideExcludeIDServerSideExclude ZoneSettingServerSideExcludeID = "server_side_exclude" + ServerSideExcludesIDServerSideExclude ServerSideExcludesID = "server_side_exclude" ) -func (r ZoneSettingServerSideExcludeID) IsKnown() bool { +func (r ServerSideExcludesID) IsKnown() bool { switch r { - case ZoneSettingServerSideExcludeIDServerSideExclude: + case ServerSideExcludesIDServerSideExclude: return true } return false } // Current value of the zone setting. -type ZoneSettingServerSideExcludeValue string +type ServerSideExcludesValue string const ( - ZoneSettingServerSideExcludeValueOn ZoneSettingServerSideExcludeValue = "on" - ZoneSettingServerSideExcludeValueOff ZoneSettingServerSideExcludeValue = "off" + ServerSideExcludesValueOn ServerSideExcludesValue = "on" + ServerSideExcludesValueOff ServerSideExcludesValue = "off" ) -func (r ZoneSettingServerSideExcludeValue) IsKnown() bool { +func (r ServerSideExcludesValue) IsKnown() bool { switch r { - case ZoneSettingServerSideExcludeValueOn, ZoneSettingServerSideExcludeValueOff: + case ServerSideExcludesValueOn, ServerSideExcludesValueOff: return true } return false @@ -158,45 +155,21 @@ func (r ZoneSettingServerSideExcludeValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingServerSideExcludeEditable bool +type ServerSideExcludesEditable bool const ( - ZoneSettingServerSideExcludeEditableTrue ZoneSettingServerSideExcludeEditable = true - ZoneSettingServerSideExcludeEditableFalse ZoneSettingServerSideExcludeEditable = false + ServerSideExcludesEditableTrue ServerSideExcludesEditable = true + ServerSideExcludesEditableFalse ServerSideExcludesEditable = false ) -func (r ZoneSettingServerSideExcludeEditable) IsKnown() bool { +func (r ServerSideExcludesEditable) IsKnown() bool { switch r { - case ZoneSettingServerSideExcludeEditableTrue, ZoneSettingServerSideExcludeEditableFalse: + case ServerSideExcludesEditableTrue, ServerSideExcludesEditableFalse: return true } return false } -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -type ZoneSettingServerSideExcludeParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingServerSideExcludeID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingServerSideExcludeValue] `json:"value,required"` -} - -func (r ZoneSettingServerSideExcludeParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingServerSideExcludeParam) implementsZonesSettingEditParamsItem() {} - type SettingServerSideExcludeEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -225,8 +198,8 @@ func (r SettingServerSideExcludeEditParamsValue) IsKnown() bool { } type SettingServerSideExcludeEditResponseEnvelope struct { - Errors []SettingServerSideExcludeEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingServerSideExcludeEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // If there is sensitive content on your website that you want visible to real @@ -240,7 +213,7 @@ type SettingServerSideExcludeEditResponseEnvelope struct { // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the // resource moves through our network to the visitor's computer. // (https://support.cloudflare.com/hc/en-us/articles/200170036). - Result ZoneSettingServerSideExclude `json:"result"` + Result ServerSideExcludes `json:"result"` JSON settingServerSideExcludeEditResponseEnvelopeJSON `json:"-"` } @@ -263,60 +236,14 @@ func (r settingServerSideExcludeEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingServerSideExcludeEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingServerSideExcludeEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingServerSideExcludeEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingServerSideExcludeEditResponseEnvelopeErrors] -type settingServerSideExcludeEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingServerSideExcludeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingServerSideExcludeEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingServerSideExcludeEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingServerSideExcludeEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingServerSideExcludeEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingServerSideExcludeEditResponseEnvelopeMessages] -type settingServerSideExcludeEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingServerSideExcludeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingServerSideExcludeEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingServerSideExcludeGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingServerSideExcludeGetResponseEnvelope struct { - Errors []SettingServerSideExcludeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingServerSideExcludeGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // If there is sensitive content on your website that you want visible to real @@ -330,7 +257,7 @@ type SettingServerSideExcludeGetResponseEnvelope struct { // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the // resource moves through our network to the visitor's computer. // (https://support.cloudflare.com/hc/en-us/articles/200170036). - Result ZoneSettingServerSideExclude `json:"result"` + Result ServerSideExcludes `json:"result"` JSON settingServerSideExcludeGetResponseEnvelopeJSON `json:"-"` } @@ -352,49 +279,3 @@ func (r *SettingServerSideExcludeGetResponseEnvelope) UnmarshalJSON(data []byte) func (r settingServerSideExcludeGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingServerSideExcludeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingServerSideExcludeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingServerSideExcludeGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingServerSideExcludeGetResponseEnvelopeErrors] -type settingServerSideExcludeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingServerSideExcludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingServerSideExcludeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingServerSideExcludeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingServerSideExcludeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingServerSideExcludeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingServerSideExcludeGetResponseEnvelopeMessages] -type settingServerSideExcludeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingServerSideExcludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingServerSideExcludeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingsortquerystringforcache.go b/zones/settingsortquerystringforcache.go index 2e64efb9550..05466ecd1f1 100644 --- a/zones/settingsortquerystringforcache.go +++ b/zones/settingsortquerystringforcache.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingSortQueryStringForCacheService(opts ...option.RequestOption) (r * // Cloudflare will treat files with the same query strings as the same file in // cache, regardless of the order of the query strings. This is limited to // Enterprise Zones. -func (r *SettingSortQueryStringForCacheService) Edit(ctx context.Context, params SettingSortQueryStringForCacheEditParams, opts ...option.RequestOption) (res *ZoneSettingSortQueryStringForCache, err error) { +func (r *SettingSortQueryStringForCacheService) Edit(ctx context.Context, params SettingSortQueryStringForCacheEditParams, opts ...option.RequestOption) (res *SortQueryStringForCache, err error) { opts = append(r.Options[:], opts...) var env SettingSortQueryStringForCacheEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/sort_query_string_for_cache", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingSortQueryStringForCacheService) Edit(ctx context.Context, params // Cloudflare will treat files with the same query strings as the same file in // cache, regardless of the order of the query strings. This is limited to // Enterprise Zones. -func (r *SettingSortQueryStringForCacheService) Get(ctx context.Context, query SettingSortQueryStringForCacheGetParams, opts ...option.RequestOption) (res *ZoneSettingSortQueryStringForCache, err error) { +func (r *SettingSortQueryStringForCacheService) Get(ctx context.Context, query SettingSortQueryStringForCacheGetParams, opts ...option.RequestOption) (res *SortQueryStringForCache, err error) { opts = append(r.Options[:], opts...) var env SettingSortQueryStringForCacheGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/sort_query_string_for_cache", query.ZoneID) @@ -65,22 +66,22 @@ func (r *SettingSortQueryStringForCacheService) Get(ctx context.Context, query S // Cloudflare will treat files with the same query strings as the same file in // cache, regardless of the order of the query strings. This is limited to // Enterprise Zones. -type ZoneSettingSortQueryStringForCache struct { +type SortQueryStringForCache struct { // ID of the zone setting. - ID ZoneSettingSortQueryStringForCacheID `json:"id,required"` + ID SortQueryStringForCacheID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingSortQueryStringForCacheValue `json:"value,required"` + Value SortQueryStringForCacheValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingSortQueryStringForCacheEditable `json:"editable"` + Editable SortQueryStringForCacheEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSortQueryStringForCacheJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON sortQueryStringForCacheJSON `json:"-"` } -// zoneSettingSortQueryStringForCacheJSON contains the JSON metadata for the struct -// [ZoneSettingSortQueryStringForCache] -type zoneSettingSortQueryStringForCacheJSON struct { +// sortQueryStringForCacheJSON contains the JSON metadata for the struct +// [SortQueryStringForCache] +type sortQueryStringForCacheJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -89,44 +90,40 @@ type zoneSettingSortQueryStringForCacheJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingSortQueryStringForCache) UnmarshalJSON(data []byte) (err error) { +func (r *SortQueryStringForCache) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingSortQueryStringForCacheJSON) RawJSON() string { +func (r sortQueryStringForCacheJSON) RawJSON() string { return r.raw } -func (r ZoneSettingSortQueryStringForCache) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingSortQueryStringForCache) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingSortQueryStringForCacheID string +type SortQueryStringForCacheID string const ( - ZoneSettingSortQueryStringForCacheIDSortQueryStringForCache ZoneSettingSortQueryStringForCacheID = "sort_query_string_for_cache" + SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache" ) -func (r ZoneSettingSortQueryStringForCacheID) IsKnown() bool { +func (r SortQueryStringForCacheID) IsKnown() bool { switch r { - case ZoneSettingSortQueryStringForCacheIDSortQueryStringForCache: + case SortQueryStringForCacheIDSortQueryStringForCache: return true } return false } // Current value of the zone setting. -type ZoneSettingSortQueryStringForCacheValue string +type SortQueryStringForCacheValue string const ( - ZoneSettingSortQueryStringForCacheValueOn ZoneSettingSortQueryStringForCacheValue = "on" - ZoneSettingSortQueryStringForCacheValueOff ZoneSettingSortQueryStringForCacheValue = "off" + SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on" + SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off" ) -func (r ZoneSettingSortQueryStringForCacheValue) IsKnown() bool { +func (r SortQueryStringForCacheValue) IsKnown() bool { switch r { - case ZoneSettingSortQueryStringForCacheValueOn, ZoneSettingSortQueryStringForCacheValueOff: + case SortQueryStringForCacheValueOn, SortQueryStringForCacheValueOff: return true } return false @@ -134,37 +131,21 @@ func (r ZoneSettingSortQueryStringForCacheValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingSortQueryStringForCacheEditable bool +type SortQueryStringForCacheEditable bool const ( - ZoneSettingSortQueryStringForCacheEditableTrue ZoneSettingSortQueryStringForCacheEditable = true - ZoneSettingSortQueryStringForCacheEditableFalse ZoneSettingSortQueryStringForCacheEditable = false + SortQueryStringForCacheEditableTrue SortQueryStringForCacheEditable = true + SortQueryStringForCacheEditableFalse SortQueryStringForCacheEditable = false ) -func (r ZoneSettingSortQueryStringForCacheEditable) IsKnown() bool { +func (r SortQueryStringForCacheEditable) IsKnown() bool { switch r { - case ZoneSettingSortQueryStringForCacheEditableTrue, ZoneSettingSortQueryStringForCacheEditableFalse: + case SortQueryStringForCacheEditableTrue, SortQueryStringForCacheEditableFalse: return true } return false } -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -type ZoneSettingSortQueryStringForCacheParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingSortQueryStringForCacheID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingSortQueryStringForCacheValue] `json:"value,required"` -} - -func (r ZoneSettingSortQueryStringForCacheParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingSortQueryStringForCacheParam) implementsZonesSettingEditParamsItem() {} - type SettingSortQueryStringForCacheEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -193,14 +174,14 @@ func (r SettingSortQueryStringForCacheEditParamsValue) IsKnown() bool { } type SettingSortQueryStringForCacheEditResponseEnvelope struct { - Errors []SettingSortQueryStringForCacheEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSortQueryStringForCacheEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare will treat files with the same query strings as the same file in // cache, regardless of the order of the query strings. This is limited to // Enterprise Zones. - Result ZoneSettingSortQueryStringForCache `json:"result"` + Result SortQueryStringForCache `json:"result"` JSON settingSortQueryStringForCacheEditResponseEnvelopeJSON `json:"-"` } @@ -223,68 +204,20 @@ func (r settingSortQueryStringForCacheEditResponseEnvelopeJSON) RawJSON() string return r.raw } -type SettingSortQueryStringForCacheEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [SettingSortQueryStringForCacheEditResponseEnvelopeErrors] -type settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSortQueryStringForCacheEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSortQueryStringForCacheEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingSortQueryStringForCacheEditResponseEnvelopeMessages] -type settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSortQueryStringForCacheEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingSortQueryStringForCacheGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingSortQueryStringForCacheGetResponseEnvelope struct { - Errors []SettingSortQueryStringForCacheGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSortQueryStringForCacheGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Cloudflare will treat files with the same query strings as the same file in // cache, regardless of the order of the query strings. This is limited to // Enterprise Zones. - Result ZoneSettingSortQueryStringForCache `json:"result"` + Result SortQueryStringForCache `json:"result"` JSON settingSortQueryStringForCacheGetResponseEnvelopeJSON `json:"-"` } @@ -306,51 +239,3 @@ func (r *SettingSortQueryStringForCacheGetResponseEnvelope) UnmarshalJSON(data [ func (r settingSortQueryStringForCacheGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingSortQueryStringForCacheGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [SettingSortQueryStringForCacheGetResponseEnvelopeErrors] -type settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSortQueryStringForCacheGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSortQueryStringForCacheGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SettingSortQueryStringForCacheGetResponseEnvelopeMessages] -type settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSortQueryStringForCacheGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingssl.go b/zones/settingssl.go index fbaef1693bc..911c6074e66 100644 --- a/zones/settingssl.go +++ b/zones/settingssl.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -47,7 +48,7 @@ func NewSettingSSLService(opts ...option.RequestOption) (r *SettingSSLService) { // web server. This certificate must be signed by a certificate authority, have an // expiration date in the future, and respond for the request domain name // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -func (r *SettingSSLService) Edit(ctx context.Context, params SettingSSLEditParams, opts ...option.RequestOption) (res *ZoneSettingSSL, err error) { +func (r *SettingSSLService) Edit(ctx context.Context, params SettingSSLEditParams, opts ...option.RequestOption) (res *SSL, err error) { opts = append(r.Options[:], opts...) var env SettingSSLEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ssl", params.ZoneID) @@ -75,7 +76,7 @@ func (r *SettingSSLService) Edit(ctx context.Context, params SettingSSLEditParam // web server. This certificate must be signed by a certificate authority, have an // expiration date in the future, and respond for the request domain name // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -func (r *SettingSSLService) Get(ctx context.Context, query SettingSSLGetParams, opts ...option.RequestOption) (res *ZoneSettingSSL, err error) { +func (r *SettingSSLService) Get(ctx context.Context, query SettingSSLGetParams, opts ...option.RequestOption) (res *SSL, err error) { opts = append(r.Options[:], opts...) var env SettingSSLGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ssl", query.ZoneID) @@ -103,21 +104,21 @@ func (r *SettingSSLService) Get(ctx context.Context, query SettingSSLGetParams, // web server. This certificate must be signed by a certificate authority, have an // expiration date in the future, and respond for the request domain name // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -type ZoneSettingSSL struct { +type SSL struct { // ID of the zone setting. - ID ZoneSettingSSLID `json:"id,required"` + ID SSLID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingSSLValue `json:"value,required"` + Value SSLValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingSSLEditable `json:"editable"` + Editable SSLEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSSLJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON sslJSON `json:"-"` } -// zoneSettingSSLJSON contains the JSON metadata for the struct [ZoneSettingSSL] -type zoneSettingSSLJSON struct { +// sslJSON contains the JSON metadata for the struct [SSL] +type sslJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -126,46 +127,42 @@ type zoneSettingSSLJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingSSL) UnmarshalJSON(data []byte) (err error) { +func (r *SSL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingSSLJSON) RawJSON() string { +func (r sslJSON) RawJSON() string { return r.raw } -func (r ZoneSettingSSL) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingSSL) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingSSLID string +type SSLID string const ( - ZoneSettingSSLIDSSL ZoneSettingSSLID = "ssl" + SSLIDSSL SSLID = "ssl" ) -func (r ZoneSettingSSLID) IsKnown() bool { +func (r SSLID) IsKnown() bool { switch r { - case ZoneSettingSSLIDSSL: + case SSLIDSSL: return true } return false } // Current value of the zone setting. -type ZoneSettingSSLValue string +type SSLValue string const ( - ZoneSettingSSLValueOff ZoneSettingSSLValue = "off" - ZoneSettingSSLValueFlexible ZoneSettingSSLValue = "flexible" - ZoneSettingSSLValueFull ZoneSettingSSLValue = "full" - ZoneSettingSSLValueStrict ZoneSettingSSLValue = "strict" + SSLValueOff SSLValue = "off" + SSLValueFlexible SSLValue = "flexible" + SSLValueFull SSLValue = "full" + SSLValueStrict SSLValue = "strict" ) -func (r ZoneSettingSSLValue) IsKnown() bool { +func (r SSLValue) IsKnown() bool { switch r { - case ZoneSettingSSLValueOff, ZoneSettingSSLValueFlexible, ZoneSettingSSLValueFull, ZoneSettingSSLValueStrict: + case SSLValueOff, SSLValueFlexible, SSLValueFull, SSLValueStrict: return true } return false @@ -173,50 +170,21 @@ func (r ZoneSettingSSLValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingSSLEditable bool +type SSLEditable bool const ( - ZoneSettingSSLEditableTrue ZoneSettingSSLEditable = true - ZoneSettingSSLEditableFalse ZoneSettingSSLEditable = false + SSLEditableTrue SSLEditable = true + SSLEditableFalse SSLEditable = false ) -func (r ZoneSettingSSLEditable) IsKnown() bool { +func (r SSLEditable) IsKnown() bool { switch r { - case ZoneSettingSSLEditableTrue, ZoneSettingSSLEditableFalse: + case SSLEditableTrue, SSLEditableFalse: return true } return false } -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -type ZoneSettingSSLParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingSSLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingSSLValue] `json:"value,required"` -} - -func (r ZoneSettingSSLParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingSSLParam) implementsZonesSettingEditParamsItem() {} - type SettingSSLEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -247,8 +215,8 @@ func (r SettingSSLEditParamsValue) IsKnown() bool { } type SettingSSLEditResponseEnvelope struct { - Errors []SettingSSLEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSSLEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // SSL encrypts your visitor's connection and safeguards credit card numbers and @@ -267,7 +235,7 @@ type SettingSSLEditResponseEnvelope struct { // web server. This certificate must be signed by a certificate authority, have an // expiration date in the future, and respond for the request domain name // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). - Result ZoneSettingSSL `json:"result"` + Result SSL `json:"result"` JSON settingSSLEditResponseEnvelopeJSON `json:"-"` } @@ -290,60 +258,14 @@ func (r settingSSLEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingSSLEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSSLEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingSSLEditResponseEnvelopeErrors] -type settingSSLEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSSLEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSSLEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingSSLEditResponseEnvelopeMessages] -type settingSSLEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingSSLGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingSSLGetResponseEnvelope struct { - Errors []SettingSSLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSSLGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // SSL encrypts your visitor's connection and safeguards credit card numbers and @@ -362,7 +284,7 @@ type SettingSSLGetResponseEnvelope struct { // web server. This certificate must be signed by a certificate authority, have an // expiration date in the future, and respond for the request domain name // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). - Result ZoneSettingSSL `json:"result"` + Result SSL `json:"result"` JSON settingSSLGetResponseEnvelopeJSON `json:"-"` } @@ -384,49 +306,3 @@ func (r *SettingSSLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { func (r settingSSLGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingSSLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSSLGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingSSLGetResponseEnvelopeErrors] -type settingSSLGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSSLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSSLGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingSSLGetResponseEnvelopeMessages] -type settingSSLGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingsslrecommender.go b/zones/settingsslrecommender.go index 0c5589f5661..b560cdcff0e 100644 --- a/zones/settingsslrecommender.go +++ b/zones/settingsslrecommender.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingSSLRecommenderService(opts ...option.RequestOption) (r *SettingSS // Enrollment in the SSL/TLS Recommender service which tries to detect and // recommend (by sending periodic emails) the most secure SSL/TLS setting your // origin servers support. -func (r *SettingSSLRecommenderService) Edit(ctx context.Context, params SettingSSLRecommenderEditParams, opts ...option.RequestOption) (res *ZoneSettingSSLRecommender, err error) { +func (r *SettingSSLRecommenderService) Edit(ctx context.Context, params SettingSSLRecommenderEditParams, opts ...option.RequestOption) (res *SSLRecommender, err error) { opts = append(r.Options[:], opts...) var env SettingSSLRecommenderEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ssl_recommender", params.ZoneID) @@ -49,7 +50,7 @@ func (r *SettingSSLRecommenderService) Edit(ctx context.Context, params SettingS // Enrollment in the SSL/TLS Recommender service which tries to detect and // recommend (by sending periodic emails) the most secure SSL/TLS setting your // origin servers support. -func (r *SettingSSLRecommenderService) Get(ctx context.Context, query SettingSSLRecommenderGetParams, opts ...option.RequestOption) (res *ZoneSettingSSLRecommender, err error) { +func (r *SettingSSLRecommenderService) Get(ctx context.Context, query SettingSSLRecommenderGetParams, opts ...option.RequestOption) (res *SSLRecommender, err error) { opts = append(r.Options[:], opts...) var env SettingSSLRecommenderGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/ssl_recommender", query.ZoneID) @@ -64,45 +65,40 @@ func (r *SettingSSLRecommenderService) Get(ctx context.Context, query SettingSSL // Enrollment in the SSL/TLS Recommender service which tries to detect and // recommend (by sending periodic emails) the most secure SSL/TLS setting your // origin servers support. -type ZoneSettingSSLRecommender struct { +type SSLRecommender struct { // Enrollment value for SSL/TLS Recommender. - ID ZoneSettingSSLRecommenderID `json:"id"` + ID SSLRecommenderID `json:"id"` // ssl-recommender enrollment setting. - Enabled bool `json:"enabled"` - JSON zoneSettingSSLRecommenderJSON `json:"-"` + Enabled bool `json:"enabled"` + JSON sslRecommenderJSON `json:"-"` } -// zoneSettingSSLRecommenderJSON contains the JSON metadata for the struct -// [ZoneSettingSSLRecommender] -type zoneSettingSSLRecommenderJSON struct { +// sslRecommenderJSON contains the JSON metadata for the struct [SSLRecommender] +type sslRecommenderJSON struct { ID apijson.Field Enabled apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ZoneSettingSSLRecommender) UnmarshalJSON(data []byte) (err error) { +func (r *SSLRecommender) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingSSLRecommenderJSON) RawJSON() string { +func (r sslRecommenderJSON) RawJSON() string { return r.raw } -func (r ZoneSettingSSLRecommender) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingSSLRecommender) implementsZonesSettingGetResponse() {} - // Enrollment value for SSL/TLS Recommender. -type ZoneSettingSSLRecommenderID string +type SSLRecommenderID string const ( - ZoneSettingSSLRecommenderIDSSLRecommender ZoneSettingSSLRecommenderID = "ssl_recommender" + SSLRecommenderIDSSLRecommender SSLRecommenderID = "ssl_recommender" ) -func (r ZoneSettingSSLRecommenderID) IsKnown() bool { +func (r SSLRecommenderID) IsKnown() bool { switch r { - case ZoneSettingSSLRecommenderIDSSLRecommender: + case SSLRecommenderIDSSLRecommender: return true } return false @@ -111,26 +107,24 @@ func (r ZoneSettingSSLRecommenderID) IsKnown() bool { // Enrollment in the SSL/TLS Recommender service which tries to detect and // recommend (by sending periodic emails) the most secure SSL/TLS setting your // origin servers support. -type ZoneSettingSSLRecommenderParam struct { +type SSLRecommenderParam struct { // Enrollment value for SSL/TLS Recommender. - ID param.Field[ZoneSettingSSLRecommenderID] `json:"id"` + ID param.Field[SSLRecommenderID] `json:"id"` // ssl-recommender enrollment setting. Enabled param.Field[bool] `json:"enabled"` } -func (r ZoneSettingSSLRecommenderParam) MarshalJSON() (data []byte, err error) { +func (r SSLRecommenderParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r ZoneSettingSSLRecommenderParam) implementsZonesSettingEditParamsItem() {} - type SettingSSLRecommenderEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Enrollment in the SSL/TLS Recommender service which tries to detect and // recommend (by sending periodic emails) the most secure SSL/TLS setting your // origin servers support. - Value param.Field[ZoneSettingSSLRecommenderParam] `json:"value,required"` + Value param.Field[SSLRecommenderParam] `json:"value,required"` } func (r SettingSSLRecommenderEditParams) MarshalJSON() (data []byte, err error) { @@ -138,14 +132,14 @@ func (r SettingSSLRecommenderEditParams) MarshalJSON() (data []byte, err error) } type SettingSSLRecommenderEditResponseEnvelope struct { - Errors []SettingSSLRecommenderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSSLRecommenderEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enrollment in the SSL/TLS Recommender service which tries to detect and // recommend (by sending periodic emails) the most secure SSL/TLS setting your // origin servers support. - Result ZoneSettingSSLRecommender `json:"result"` + Result SSLRecommender `json:"result"` JSON settingSSLRecommenderEditResponseEnvelopeJSON `json:"-"` } @@ -168,66 +162,20 @@ func (r settingSSLRecommenderEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingSSLRecommenderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLRecommenderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSSLRecommenderEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingSSLRecommenderEditResponseEnvelopeErrors] -type settingSSLRecommenderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLRecommenderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLRecommenderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSSLRecommenderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLRecommenderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSSLRecommenderEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingSSLRecommenderEditResponseEnvelopeMessages] -type settingSSLRecommenderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLRecommenderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLRecommenderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingSSLRecommenderGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingSSLRecommenderGetResponseEnvelope struct { - Errors []SettingSSLRecommenderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingSSLRecommenderGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enrollment in the SSL/TLS Recommender service which tries to detect and // recommend (by sending periodic emails) the most secure SSL/TLS setting your // origin servers support. - Result ZoneSettingSSLRecommender `json:"result"` + Result SSLRecommender `json:"result"` JSON settingSSLRecommenderGetResponseEnvelopeJSON `json:"-"` } @@ -249,49 +197,3 @@ func (r *SettingSSLRecommenderGetResponseEnvelope) UnmarshalJSON(data []byte) (e func (r settingSSLRecommenderGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingSSLRecommenderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLRecommenderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingSSLRecommenderGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingSSLRecommenderGetResponseEnvelopeErrors] -type settingSSLRecommenderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLRecommenderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLRecommenderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingSSLRecommenderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingSSLRecommenderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingSSLRecommenderGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingSSLRecommenderGetResponseEnvelopeMessages] -type settingSSLRecommenderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingSSLRecommenderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingSSLRecommenderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingsslrecommender_test.go b/zones/settingsslrecommender_test.go index 83b1f7401ce..e4ecc3a40ae 100644 --- a/zones/settingsslrecommender_test.go +++ b/zones/settingsslrecommender_test.go @@ -30,9 +30,9 @@ func TestSettingSSLRecommenderEditWithOptionalParams(t *testing.T) { ) _, err := client.Zones.Settings.SSLRecommender.Edit(context.TODO(), zones.SettingSSLRecommenderEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(zones.ZoneSettingSSLRecommenderParam{ + Value: cloudflare.F(zones.SSLRecommenderParam{ Enabled: cloudflare.F(true), - ID: cloudflare.F(zones.ZoneSettingSSLRecommenderIDSSLRecommender), + ID: cloudflare.F(zones.SSLRecommenderIDSSLRecommender), }), }) if err != nil { diff --git a/zones/settingtls13.go b/zones/settingtls13.go index 75b7e11ca80..ae4588277b7 100644 --- a/zones/settingtls13.go +++ b/zones/settingtls13.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingTLS1_3Service(opts ...option.RequestOption) (r *SettingTLS1_3Serv } // Changes TLS 1.3 setting. -func (r *SettingTLS1_3Service) Edit(ctx context.Context, params SettingTLS1_3EditParams, opts ...option.RequestOption) (res *ZoneSettingTLS1_3, err error) { +func (r *SettingTLS1_3Service) Edit(ctx context.Context, params SettingTLS1_3EditParams, opts ...option.RequestOption) (res *TLS1_3, err error) { opts = append(r.Options[:], opts...) var env SettingTls1_3EditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/tls_1_3", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingTLS1_3Service) Edit(ctx context.Context, params SettingTLS1_3Edi } // Gets TLS 1.3 setting enabled for a zone. -func (r *SettingTLS1_3Service) Get(ctx context.Context, query SettingTLS1_3GetParams, opts ...option.RequestOption) (res *ZoneSettingTLS1_3, err error) { +func (r *SettingTLS1_3Service) Get(ctx context.Context, query SettingTLS1_3GetParams, opts ...option.RequestOption) (res *TLS1_3, err error) { opts = append(r.Options[:], opts...) var env SettingTls1_3GetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/tls_1_3", query.ZoneID) @@ -59,22 +60,21 @@ func (r *SettingTLS1_3Service) Get(ctx context.Context, query SettingTLS1_3GetPa } // Enables Crypto TLS 1.3 feature for a zone. -type ZoneSettingTLS1_3 struct { +type TLS1_3 struct { // ID of the zone setting. - ID ZoneSettingTLS1_3ID `json:"id,required"` + ID TLS1_3ID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingTLS1_3Value `json:"value,required"` + Value TLS1_3Value `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingTLS1_3Editable `json:"editable"` + Editable TLS1_3Editable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTls1_3JSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON tls1_3JSON `json:"-"` } -// zoneSettingTls1_3JSON contains the JSON metadata for the struct -// [ZoneSettingTLS1_3] -type zoneSettingTls1_3JSON struct { +// tls1_3JSON contains the JSON metadata for the struct [TLS1_3] +type tls1_3JSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -83,45 +83,41 @@ type zoneSettingTls1_3JSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingTLS1_3) UnmarshalJSON(data []byte) (err error) { +func (r *TLS1_3) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingTls1_3JSON) RawJSON() string { +func (r tls1_3JSON) RawJSON() string { return r.raw } -func (r ZoneSettingTLS1_3) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingTLS1_3) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingTLS1_3ID string +type TLS1_3ID string const ( - ZoneSettingTLS1_3IDTLS1_3 ZoneSettingTLS1_3ID = "tls_1_3" + TLS1_3IDTLS1_3 TLS1_3ID = "tls_1_3" ) -func (r ZoneSettingTLS1_3ID) IsKnown() bool { +func (r TLS1_3ID) IsKnown() bool { switch r { - case ZoneSettingTLS1_3IDTLS1_3: + case TLS1_3IDTLS1_3: return true } return false } // Current value of the zone setting. -type ZoneSettingTLS1_3Value string +type TLS1_3Value string const ( - ZoneSettingTLS1_3ValueOn ZoneSettingTLS1_3Value = "on" - ZoneSettingTLS1_3ValueOff ZoneSettingTLS1_3Value = "off" - ZoneSettingTLS1_3ValueZrt ZoneSettingTLS1_3Value = "zrt" + TLS1_3ValueOn TLS1_3Value = "on" + TLS1_3ValueOff TLS1_3Value = "off" + TLS1_3ValueZrt TLS1_3Value = "zrt" ) -func (r ZoneSettingTLS1_3Value) IsKnown() bool { +func (r TLS1_3Value) IsKnown() bool { switch r { - case ZoneSettingTLS1_3ValueOn, ZoneSettingTLS1_3ValueOff, ZoneSettingTLS1_3ValueZrt: + case TLS1_3ValueOn, TLS1_3ValueOff, TLS1_3ValueZrt: return true } return false @@ -129,35 +125,21 @@ func (r ZoneSettingTLS1_3Value) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingTLS1_3Editable bool +type TLS1_3Editable bool const ( - ZoneSettingTLS1_3EditableTrue ZoneSettingTLS1_3Editable = true - ZoneSettingTLS1_3EditableFalse ZoneSettingTLS1_3Editable = false + TLS1_3EditableTrue TLS1_3Editable = true + TLS1_3EditableFalse TLS1_3Editable = false ) -func (r ZoneSettingTLS1_3Editable) IsKnown() bool { +func (r TLS1_3Editable) IsKnown() bool { switch r { - case ZoneSettingTLS1_3EditableTrue, ZoneSettingTLS1_3EditableFalse: + case TLS1_3EditableTrue, TLS1_3EditableFalse: return true } return false } -// Enables Crypto TLS 1.3 feature for a zone. -type ZoneSettingTLS1_3Param struct { - // ID of the zone setting. - ID param.Field[ZoneSettingTLS1_3ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingTLS1_3Value] `json:"value,required"` -} - -func (r ZoneSettingTLS1_3Param) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingTLS1_3Param) implementsZonesSettingEditParamsItem() {} - type SettingTLS1_3EditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -189,12 +171,12 @@ func (r SettingTls1_3EditParamsValue) IsKnown() bool { } type SettingTls1_3EditResponseEnvelope struct { - Errors []SettingTls1_3EditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTls1_3EditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enables Crypto TLS 1.3 feature for a zone. - Result ZoneSettingTLS1_3 `json:"result"` + Result TLS1_3 `json:"result"` JSON settingTls1_3EditResponseEnvelopeJSON `json:"-"` } @@ -217,64 +199,18 @@ func (r settingTls1_3EditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingTls1_3EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTls1_3EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTls1_3EditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingTls1_3EditResponseEnvelopeErrors] -type settingTls1_3EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTls1_3EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTls1_3EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTls1_3EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTls1_3EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTls1_3EditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingTls1_3EditResponseEnvelopeMessages] -type settingTls1_3EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTls1_3EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTls1_3EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingTLS1_3GetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingTls1_3GetResponseEnvelope struct { - Errors []SettingTls1_3GetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTls1_3GetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Enables Crypto TLS 1.3 feature for a zone. - Result ZoneSettingTLS1_3 `json:"result"` + Result TLS1_3 `json:"result"` JSON settingTls1_3GetResponseEnvelopeJSON `json:"-"` } @@ -296,49 +232,3 @@ func (r *SettingTls1_3GetResponseEnvelope) UnmarshalJSON(data []byte) (err error func (r settingTls1_3GetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingTls1_3GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTls1_3GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTls1_3GetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingTls1_3GetResponseEnvelopeErrors] -type settingTls1_3GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTls1_3GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTls1_3GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTls1_3GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTls1_3GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTls1_3GetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingTls1_3GetResponseEnvelopeMessages] -type settingTls1_3GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTls1_3GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTls1_3GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingtlsclientauth.go b/zones/settingtlsclientauth.go index 0d06485d672..dd664490187 100644 --- a/zones/settingtlsclientauth.go +++ b/zones/settingtlsclientauth.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingTLSClientAuthService(opts ...option.RequestOption) (r *SettingTLS // TLS Client Auth requires Cloudflare to connect to your origin server using a // client certificate (Enterprise Only). -func (r *SettingTLSClientAuthService) Edit(ctx context.Context, params SettingTLSClientAuthEditParams, opts ...option.RequestOption) (res *ZoneSettingTLSClientAuth, err error) { +func (r *SettingTLSClientAuthService) Edit(ctx context.Context, params SettingTLSClientAuthEditParams, opts ...option.RequestOption) (res *TLSClientAuth, err error) { opts = append(r.Options[:], opts...) var env SettingTLSClientAuthEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/tls_client_auth", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingTLSClientAuthService) Edit(ctx context.Context, params SettingTL // TLS Client Auth requires Cloudflare to connect to your origin server using a // client certificate (Enterprise Only). -func (r *SettingTLSClientAuthService) Get(ctx context.Context, query SettingTLSClientAuthGetParams, opts ...option.RequestOption) (res *ZoneSettingTLSClientAuth, err error) { +func (r *SettingTLSClientAuthService) Get(ctx context.Context, query SettingTLSClientAuthGetParams, opts ...option.RequestOption) (res *TLSClientAuth, err error) { opts = append(r.Options[:], opts...) var env SettingTLSClientAuthGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/tls_client_auth", query.ZoneID) @@ -62,22 +63,21 @@ func (r *SettingTLSClientAuthService) Get(ctx context.Context, query SettingTLSC // TLS Client Auth requires Cloudflare to connect to your origin server using a // client certificate (Enterprise Only). -type ZoneSettingTLSClientAuth struct { +type TLSClientAuth struct { // ID of the zone setting. - ID ZoneSettingTLSClientAuthID `json:"id,required"` + ID TLSClientAuthID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingTLSClientAuthValue `json:"value,required"` + Value TLSClientAuthValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingTLSClientAuthEditable `json:"editable"` + Editable TLSClientAuthEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTLSClientAuthJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON tlsClientAuthJSON `json:"-"` } -// zoneSettingTLSClientAuthJSON contains the JSON metadata for the struct -// [ZoneSettingTLSClientAuth] -type zoneSettingTLSClientAuthJSON struct { +// tlsClientAuthJSON contains the JSON metadata for the struct [TLSClientAuth] +type tlsClientAuthJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -86,44 +86,40 @@ type zoneSettingTLSClientAuthJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingTLSClientAuth) UnmarshalJSON(data []byte) (err error) { +func (r *TLSClientAuth) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingTLSClientAuthJSON) RawJSON() string { +func (r tlsClientAuthJSON) RawJSON() string { return r.raw } -func (r ZoneSettingTLSClientAuth) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingTLSClientAuth) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingTLSClientAuthID string +type TLSClientAuthID string const ( - ZoneSettingTLSClientAuthIDTLSClientAuth ZoneSettingTLSClientAuthID = "tls_client_auth" + TLSClientAuthIDTLSClientAuth TLSClientAuthID = "tls_client_auth" ) -func (r ZoneSettingTLSClientAuthID) IsKnown() bool { +func (r TLSClientAuthID) IsKnown() bool { switch r { - case ZoneSettingTLSClientAuthIDTLSClientAuth: + case TLSClientAuthIDTLSClientAuth: return true } return false } // Current value of the zone setting. -type ZoneSettingTLSClientAuthValue string +type TLSClientAuthValue string const ( - ZoneSettingTLSClientAuthValueOn ZoneSettingTLSClientAuthValue = "on" - ZoneSettingTLSClientAuthValueOff ZoneSettingTLSClientAuthValue = "off" + TLSClientAuthValueOn TLSClientAuthValue = "on" + TLSClientAuthValueOff TLSClientAuthValue = "off" ) -func (r ZoneSettingTLSClientAuthValue) IsKnown() bool { +func (r TLSClientAuthValue) IsKnown() bool { switch r { - case ZoneSettingTLSClientAuthValueOn, ZoneSettingTLSClientAuthValueOff: + case TLSClientAuthValueOn, TLSClientAuthValueOff: return true } return false @@ -131,36 +127,21 @@ func (r ZoneSettingTLSClientAuthValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingTLSClientAuthEditable bool +type TLSClientAuthEditable bool const ( - ZoneSettingTLSClientAuthEditableTrue ZoneSettingTLSClientAuthEditable = true - ZoneSettingTLSClientAuthEditableFalse ZoneSettingTLSClientAuthEditable = false + TLSClientAuthEditableTrue TLSClientAuthEditable = true + TLSClientAuthEditableFalse TLSClientAuthEditable = false ) -func (r ZoneSettingTLSClientAuthEditable) IsKnown() bool { +func (r TLSClientAuthEditable) IsKnown() bool { switch r { - case ZoneSettingTLSClientAuthEditableTrue, ZoneSettingTLSClientAuthEditableFalse: + case TLSClientAuthEditableTrue, TLSClientAuthEditableFalse: return true } return false } -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -type ZoneSettingTLSClientAuthParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingTLSClientAuthID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingTLSClientAuthValue] `json:"value,required"` -} - -func (r ZoneSettingTLSClientAuthParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingTLSClientAuthParam) implementsZonesSettingEditParamsItem() {} - type SettingTLSClientAuthEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -189,13 +170,13 @@ func (r SettingTLSClientAuthEditParamsValue) IsKnown() bool { } type SettingTLSClientAuthEditResponseEnvelope struct { - Errors []SettingTLSClientAuthEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTLSClientAuthEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // TLS Client Auth requires Cloudflare to connect to your origin server using a // client certificate (Enterprise Only). - Result ZoneSettingTLSClientAuth `json:"result"` + Result TLSClientAuth `json:"result"` JSON settingTLSClientAuthEditResponseEnvelopeJSON `json:"-"` } @@ -218,65 +199,19 @@ func (r settingTLSClientAuthEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingTLSClientAuthEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSClientAuthEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTLSClientAuthEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SettingTLSClientAuthEditResponseEnvelopeErrors] -type settingTLSClientAuthEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSClientAuthEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSClientAuthEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTLSClientAuthEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSClientAuthEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTLSClientAuthEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingTLSClientAuthEditResponseEnvelopeMessages] -type settingTLSClientAuthEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSClientAuthEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSClientAuthEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingTLSClientAuthGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingTLSClientAuthGetResponseEnvelope struct { - Errors []SettingTLSClientAuthGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTLSClientAuthGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // TLS Client Auth requires Cloudflare to connect to your origin server using a // client certificate (Enterprise Only). - Result ZoneSettingTLSClientAuth `json:"result"` + Result TLSClientAuth `json:"result"` JSON settingTLSClientAuthGetResponseEnvelopeJSON `json:"-"` } @@ -298,49 +233,3 @@ func (r *SettingTLSClientAuthGetResponseEnvelope) UnmarshalJSON(data []byte) (er func (r settingTLSClientAuthGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingTLSClientAuthGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSClientAuthGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTLSClientAuthGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingTLSClientAuthGetResponseEnvelopeErrors] -type settingTLSClientAuthGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSClientAuthGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSClientAuthGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTLSClientAuthGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTLSClientAuthGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTLSClientAuthGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SettingTLSClientAuthGetResponseEnvelopeMessages] -type settingTLSClientAuthGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTLSClientAuthGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTLSClientAuthGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingtrueclientipheader.go b/zones/settingtrueclientipheader.go index f6dde149fe7..10fae504b73 100644 --- a/zones/settingtrueclientipheader.go +++ b/zones/settingtrueclientipheader.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -34,7 +35,7 @@ func NewSettingTrueClientIPHeaderService(opts ...option.RequestOption) (r *Setti // Allows customer to continue to use True Client IP (Akamai feature) in the // headers we send to the origin. This is limited to Enterprise Zones. -func (r *SettingTrueClientIPHeaderService) Edit(ctx context.Context, params SettingTrueClientIPHeaderEditParams, opts ...option.RequestOption) (res *ZoneSettingTrueClientIPHeader, err error) { +func (r *SettingTrueClientIPHeaderService) Edit(ctx context.Context, params SettingTrueClientIPHeaderEditParams, opts ...option.RequestOption) (res *TrueClientIPHeader, err error) { opts = append(r.Options[:], opts...) var env SettingTrueClientIPHeaderEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/true_client_ip_header", params.ZoneID) @@ -48,7 +49,7 @@ func (r *SettingTrueClientIPHeaderService) Edit(ctx context.Context, params Sett // Allows customer to continue to use True Client IP (Akamai feature) in the // headers we send to the origin. This is limited to Enterprise Zones. -func (r *SettingTrueClientIPHeaderService) Get(ctx context.Context, query SettingTrueClientIPHeaderGetParams, opts ...option.RequestOption) (res *ZoneSettingTrueClientIPHeader, err error) { +func (r *SettingTrueClientIPHeaderService) Get(ctx context.Context, query SettingTrueClientIPHeaderGetParams, opts ...option.RequestOption) (res *TrueClientIPHeader, err error) { opts = append(r.Options[:], opts...) var env SettingTrueClientIPHeaderGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/true_client_ip_header", query.ZoneID) @@ -62,22 +63,22 @@ func (r *SettingTrueClientIPHeaderService) Get(ctx context.Context, query Settin // Allows customer to continue to use True Client IP (Akamai feature) in the // headers we send to the origin. This is limited to Enterprise Zones. -type ZoneSettingTrueClientIPHeader struct { +type TrueClientIPHeader struct { // ID of the zone setting. - ID ZoneSettingTrueClientIPHeaderID `json:"id,required"` + ID TrueClientIPHeaderID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingTrueClientIPHeaderValue `json:"value,required"` + Value TrueClientIPHeaderValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingTrueClientIPHeaderEditable `json:"editable"` + Editable TrueClientIPHeaderEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTrueClientIPHeaderJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON trueClientIPHeaderJSON `json:"-"` } -// zoneSettingTrueClientIPHeaderJSON contains the JSON metadata for the struct -// [ZoneSettingTrueClientIPHeader] -type zoneSettingTrueClientIPHeaderJSON struct { +// trueClientIPHeaderJSON contains the JSON metadata for the struct +// [TrueClientIPHeader] +type trueClientIPHeaderJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -86,44 +87,40 @@ type zoneSettingTrueClientIPHeaderJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingTrueClientIPHeader) UnmarshalJSON(data []byte) (err error) { +func (r *TrueClientIPHeader) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingTrueClientIPHeaderJSON) RawJSON() string { +func (r trueClientIPHeaderJSON) RawJSON() string { return r.raw } -func (r ZoneSettingTrueClientIPHeader) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingTrueClientIPHeader) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingTrueClientIPHeaderID string +type TrueClientIPHeaderID string const ( - ZoneSettingTrueClientIPHeaderIDTrueClientIPHeader ZoneSettingTrueClientIPHeaderID = "true_client_ip_header" + TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header" ) -func (r ZoneSettingTrueClientIPHeaderID) IsKnown() bool { +func (r TrueClientIPHeaderID) IsKnown() bool { switch r { - case ZoneSettingTrueClientIPHeaderIDTrueClientIPHeader: + case TrueClientIPHeaderIDTrueClientIPHeader: return true } return false } // Current value of the zone setting. -type ZoneSettingTrueClientIPHeaderValue string +type TrueClientIPHeaderValue string const ( - ZoneSettingTrueClientIPHeaderValueOn ZoneSettingTrueClientIPHeaderValue = "on" - ZoneSettingTrueClientIPHeaderValueOff ZoneSettingTrueClientIPHeaderValue = "off" + TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on" + TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off" ) -func (r ZoneSettingTrueClientIPHeaderValue) IsKnown() bool { +func (r TrueClientIPHeaderValue) IsKnown() bool { switch r { - case ZoneSettingTrueClientIPHeaderValueOn, ZoneSettingTrueClientIPHeaderValueOff: + case TrueClientIPHeaderValueOn, TrueClientIPHeaderValueOff: return true } return false @@ -131,36 +128,21 @@ func (r ZoneSettingTrueClientIPHeaderValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingTrueClientIPHeaderEditable bool +type TrueClientIPHeaderEditable bool const ( - ZoneSettingTrueClientIPHeaderEditableTrue ZoneSettingTrueClientIPHeaderEditable = true - ZoneSettingTrueClientIPHeaderEditableFalse ZoneSettingTrueClientIPHeaderEditable = false + TrueClientIPHeaderEditableTrue TrueClientIPHeaderEditable = true + TrueClientIPHeaderEditableFalse TrueClientIPHeaderEditable = false ) -func (r ZoneSettingTrueClientIPHeaderEditable) IsKnown() bool { +func (r TrueClientIPHeaderEditable) IsKnown() bool { switch r { - case ZoneSettingTrueClientIPHeaderEditableTrue, ZoneSettingTrueClientIPHeaderEditableFalse: + case TrueClientIPHeaderEditableTrue, TrueClientIPHeaderEditableFalse: return true } return false } -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -type ZoneSettingTrueClientIPHeaderParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingTrueClientIPHeaderID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingTrueClientIPHeaderValue] `json:"value,required"` -} - -func (r ZoneSettingTrueClientIPHeaderParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingTrueClientIPHeaderParam) implementsZonesSettingEditParamsItem() {} - type SettingTrueClientIPHeaderEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -189,13 +171,13 @@ func (r SettingTrueClientIPHeaderEditParamsValue) IsKnown() bool { } type SettingTrueClientIPHeaderEditResponseEnvelope struct { - Errors []SettingTrueClientIPHeaderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTrueClientIPHeaderEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Allows customer to continue to use True Client IP (Akamai feature) in the // headers we send to the origin. This is limited to Enterprise Zones. - Result ZoneSettingTrueClientIPHeader `json:"result"` + Result TrueClientIPHeader `json:"result"` JSON settingTrueClientIPHeaderEditResponseEnvelopeJSON `json:"-"` } @@ -218,65 +200,19 @@ func (r settingTrueClientIPHeaderEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingTrueClientIPHeaderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingTrueClientIPHeaderEditResponseEnvelopeErrors] -type settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTrueClientIPHeaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTrueClientIPHeaderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingTrueClientIPHeaderEditResponseEnvelopeMessages] -type settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTrueClientIPHeaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingTrueClientIPHeaderGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingTrueClientIPHeaderGetResponseEnvelope struct { - Errors []SettingTrueClientIPHeaderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingTrueClientIPHeaderGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // Allows customer to continue to use True Client IP (Akamai feature) in the // headers we send to the origin. This is limited to Enterprise Zones. - Result ZoneSettingTrueClientIPHeader `json:"result"` + Result TrueClientIPHeader `json:"result"` JSON settingTrueClientIPHeaderGetResponseEnvelopeJSON `json:"-"` } @@ -298,49 +234,3 @@ func (r *SettingTrueClientIPHeaderGetResponseEnvelope) UnmarshalJSON(data []byte func (r settingTrueClientIPHeaderGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingTrueClientIPHeaderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SettingTrueClientIPHeaderGetResponseEnvelopeErrors] -type settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTrueClientIPHeaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingTrueClientIPHeaderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SettingTrueClientIPHeaderGetResponseEnvelopeMessages] -type settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingTrueClientIPHeaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingwaf.go b/zones/settingwaf.go index f5644c7e685..04e7866b474 100644 --- a/zones/settingwaf.go +++ b/zones/settingwaf.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -41,7 +42,7 @@ func NewSettingWAFService(opts ...option.RequestOption) (r *SettingWAFService) { // Cloudflare's WAF will block any traffic identified as illegitimate before it // reaches your origin web server. // (https://support.cloudflare.com/hc/en-us/articles/200172016). -func (r *SettingWAFService) Edit(ctx context.Context, params SettingWAFEditParams, opts ...option.RequestOption) (res *ZoneSettingWAF, err error) { +func (r *SettingWAFService) Edit(ctx context.Context, params SettingWAFEditParams, opts ...option.RequestOption) (res *WAF, err error) { opts = append(r.Options[:], opts...) var env SettingWAFEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/waf", params.ZoneID) @@ -63,7 +64,7 @@ func (r *SettingWAFService) Edit(ctx context.Context, params SettingWAFEditParam // Cloudflare's WAF will block any traffic identified as illegitimate before it // reaches your origin web server. // (https://support.cloudflare.com/hc/en-us/articles/200172016). -func (r *SettingWAFService) Get(ctx context.Context, query SettingWAFGetParams, opts ...option.RequestOption) (res *ZoneSettingWAF, err error) { +func (r *SettingWAFService) Get(ctx context.Context, query SettingWAFGetParams, opts ...option.RequestOption) (res *WAF, err error) { opts = append(r.Options[:], opts...) var env SettingWAFGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/waf", query.ZoneID) @@ -85,21 +86,21 @@ func (r *SettingWAFService) Get(ctx context.Context, query SettingWAFGetParams, // Cloudflare's WAF will block any traffic identified as illegitimate before it // reaches your origin web server. // (https://support.cloudflare.com/hc/en-us/articles/200172016). -type ZoneSettingWAF struct { +type WAF struct { // ID of the zone setting. - ID ZoneSettingWAFID `json:"id,required"` + ID WAFID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingWAFValue `json:"value,required"` + Value WAFValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingWAFEditable `json:"editable"` + Editable WAFEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWAFJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON wafJSON `json:"-"` } -// zoneSettingWAFJSON contains the JSON metadata for the struct [ZoneSettingWAF] -type zoneSettingWAFJSON struct { +// wafJSON contains the JSON metadata for the struct [WAF] +type wafJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -108,44 +109,40 @@ type zoneSettingWAFJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingWAF) UnmarshalJSON(data []byte) (err error) { +func (r *WAF) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingWAFJSON) RawJSON() string { +func (r wafJSON) RawJSON() string { return r.raw } -func (r ZoneSettingWAF) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingWAF) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingWAFID string +type WAFID string const ( - ZoneSettingWAFIDWAF ZoneSettingWAFID = "waf" + WAFIDWAF WAFID = "waf" ) -func (r ZoneSettingWAFID) IsKnown() bool { +func (r WAFID) IsKnown() bool { switch r { - case ZoneSettingWAFIDWAF: + case WAFIDWAF: return true } return false } // Current value of the zone setting. -type ZoneSettingWAFValue string +type WAFValue string const ( - ZoneSettingWAFValueOn ZoneSettingWAFValue = "on" - ZoneSettingWAFValueOff ZoneSettingWAFValue = "off" + WAFValueOn WAFValue = "on" + WAFValueOff WAFValue = "off" ) -func (r ZoneSettingWAFValue) IsKnown() bool { +func (r WAFValue) IsKnown() bool { switch r { - case ZoneSettingWAFValueOn, ZoneSettingWAFValueOff: + case WAFValueOn, WAFValueOff: return true } return false @@ -153,44 +150,21 @@ func (r ZoneSettingWAFValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingWAFEditable bool +type WAFEditable bool const ( - ZoneSettingWAFEditableTrue ZoneSettingWAFEditable = true - ZoneSettingWAFEditableFalse ZoneSettingWAFEditable = false + WAFEditableTrue WAFEditable = true + WAFEditableFalse WAFEditable = false ) -func (r ZoneSettingWAFEditable) IsKnown() bool { +func (r WAFEditable) IsKnown() bool { switch r { - case ZoneSettingWAFEditableTrue, ZoneSettingWAFEditableFalse: + case WAFEditableTrue, WAFEditableFalse: return true } return false } -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -type ZoneSettingWAFParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingWAFID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingWAFValue] `json:"value,required"` -} - -func (r ZoneSettingWAFParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingWAFParam) implementsZonesSettingEditParamsItem() {} - type SettingWAFEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -219,8 +193,8 @@ func (r SettingWAFEditParamsValue) IsKnown() bool { } type SettingWAFEditResponseEnvelope struct { - Errors []SettingWAFEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingWAFEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // The WAF examines HTTP requests to your website. It inspects both GET and POST @@ -233,7 +207,7 @@ type SettingWAFEditResponseEnvelope struct { // Cloudflare's WAF will block any traffic identified as illegitimate before it // reaches your origin web server. // (https://support.cloudflare.com/hc/en-us/articles/200172016). - Result ZoneSettingWAF `json:"result"` + Result WAF `json:"result"` JSON settingWAFEditResponseEnvelopeJSON `json:"-"` } @@ -256,60 +230,14 @@ func (r settingWAFEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingWAFEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWAFEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingWAFEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingWAFEditResponseEnvelopeErrors] -type settingWAFEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWAFEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWAFEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingWAFEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWAFEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingWAFEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingWAFEditResponseEnvelopeMessages] -type settingWAFEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWAFEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWAFEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingWAFGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingWAFGetResponseEnvelope struct { - Errors []SettingWAFGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingWAFGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // The WAF examines HTTP requests to your website. It inspects both GET and POST @@ -322,7 +250,7 @@ type SettingWAFGetResponseEnvelope struct { // Cloudflare's WAF will block any traffic identified as illegitimate before it // reaches your origin web server. // (https://support.cloudflare.com/hc/en-us/articles/200172016). - Result ZoneSettingWAF `json:"result"` + Result WAF `json:"result"` JSON settingWAFGetResponseEnvelopeJSON `json:"-"` } @@ -344,49 +272,3 @@ func (r *SettingWAFGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { func (r settingWAFGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingWAFGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWAFGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingWAFGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingWAFGetResponseEnvelopeErrors] -type settingWAFGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWAFGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWAFGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingWAFGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWAFGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingWAFGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingWAFGetResponseEnvelopeMessages] -type settingWAFGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWAFGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWAFGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingwebp.go b/zones/settingwebp.go index aecae25e88c..4d7bb7ac507 100644 --- a/zones/settingwebp.go +++ b/zones/settingwebp.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingWebPService(opts ...option.RequestOption) (r *SettingWebPService) // When the client requesting the image supports the WebP image codec, and WebP // offers a performance advantage over the original image format, Cloudflare will // serve a WebP version of the original image. -func (r *SettingWebPService) Edit(ctx context.Context, params SettingWebPEditParams, opts ...option.RequestOption) (res *ZoneSettingWebP, err error) { +func (r *SettingWebPService) Edit(ctx context.Context, params SettingWebPEditParams, opts ...option.RequestOption) (res *WebP, err error) { opts = append(r.Options[:], opts...) var env SettingWebPEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/webp", params.ZoneID) @@ -50,7 +51,7 @@ func (r *SettingWebPService) Edit(ctx context.Context, params SettingWebPEditPar // When the client requesting the image supports the WebP image codec, and WebP // offers a performance advantage over the original image format, Cloudflare will // serve a WebP version of the original image. -func (r *SettingWebPService) Get(ctx context.Context, query SettingWebPGetParams, opts ...option.RequestOption) (res *ZoneSettingWebP, err error) { +func (r *SettingWebPService) Get(ctx context.Context, query SettingWebPGetParams, opts ...option.RequestOption) (res *WebP, err error) { opts = append(r.Options[:], opts...) var env SettingWebPGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/webp", query.ZoneID) @@ -65,21 +66,21 @@ func (r *SettingWebPService) Get(ctx context.Context, query SettingWebPGetParams // When the client requesting the image supports the WebP image codec, and WebP // offers a performance advantage over the original image format, Cloudflare will // serve a WebP version of the original image. -type ZoneSettingWebP struct { +type WebP struct { // ID of the zone setting. - ID ZoneSettingWebPID `json:"id,required"` + ID WebPID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingWebPValue `json:"value,required"` + Value WebPValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingWebPEditable `json:"editable"` + Editable WebPEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWebPJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON WebPJSON `json:"-"` } -// zoneSettingWebPJSON contains the JSON metadata for the struct [ZoneSettingWebP] -type zoneSettingWebPJSON struct { +// WebPJSON contains the JSON metadata for the struct [WebP] +type WebPJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -88,44 +89,40 @@ type zoneSettingWebPJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingWebP) UnmarshalJSON(data []byte) (err error) { +func (r *WebP) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingWebPJSON) RawJSON() string { +func (r WebPJSON) RawJSON() string { return r.raw } -func (r ZoneSettingWebP) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingWebP) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingWebPID string +type WebPID string const ( - ZoneSettingWebPIDWebP ZoneSettingWebPID = "webp" + WebPIDWebP WebPID = "webp" ) -func (r ZoneSettingWebPID) IsKnown() bool { +func (r WebPID) IsKnown() bool { switch r { - case ZoneSettingWebPIDWebP: + case WebPIDWebP: return true } return false } // Current value of the zone setting. -type ZoneSettingWebPValue string +type WebPValue string const ( - ZoneSettingWebPValueOff ZoneSettingWebPValue = "off" - ZoneSettingWebPValueOn ZoneSettingWebPValue = "on" + WebPValueOff WebPValue = "off" + WebPValueOn WebPValue = "on" ) -func (r ZoneSettingWebPValue) IsKnown() bool { +func (r WebPValue) IsKnown() bool { switch r { - case ZoneSettingWebPValueOff, ZoneSettingWebPValueOn: + case WebPValueOff, WebPValueOn: return true } return false @@ -133,37 +130,21 @@ func (r ZoneSettingWebPValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingWebPEditable bool +type WebPEditable bool const ( - ZoneSettingWebPEditableTrue ZoneSettingWebPEditable = true - ZoneSettingWebPEditableFalse ZoneSettingWebPEditable = false + WebPEditableTrue WebPEditable = true + WebPEditableFalse WebPEditable = false ) -func (r ZoneSettingWebPEditable) IsKnown() bool { +func (r WebPEditable) IsKnown() bool { switch r { - case ZoneSettingWebPEditableTrue, ZoneSettingWebPEditableFalse: + case WebPEditableTrue, WebPEditableFalse: return true } return false } -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -type ZoneSettingWebPParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingWebPID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingWebPValue] `json:"value,required"` -} - -func (r ZoneSettingWebPParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingWebPParam) implementsZonesSettingEditParamsItem() {} - type SettingWebPEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -192,14 +173,14 @@ func (r SettingWebPEditParamsValue) IsKnown() bool { } type SettingWebPEditResponseEnvelope struct { - Errors []SettingWebPEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingWebPEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When the client requesting the image supports the WebP image codec, and WebP // offers a performance advantage over the original image format, Cloudflare will // serve a WebP version of the original image. - Result ZoneSettingWebP `json:"result"` + Result WebP `json:"result"` JSON settingWebPEditResponseEnvelopeJSON `json:"-"` } @@ -222,66 +203,20 @@ func (r settingWebPEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingWebPEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebPEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingWebPEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingWebPEditResponseEnvelopeErrors] -type settingWebPEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebPEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebPEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingWebPEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebPEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingWebPEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingWebPEditResponseEnvelopeMessages] -type settingWebPEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebPEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebPEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingWebPGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingWebPGetResponseEnvelope struct { - Errors []SettingWebPGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingWebPGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // When the client requesting the image supports the WebP image codec, and WebP // offers a performance advantage over the original image format, Cloudflare will // serve a WebP version of the original image. - Result ZoneSettingWebP `json:"result"` + Result WebP `json:"result"` JSON settingWebPGetResponseEnvelopeJSON `json:"-"` } @@ -303,49 +238,3 @@ func (r *SettingWebPGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) func (r settingWebPGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingWebPGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebPGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingWebPGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingWebPGetResponseEnvelopeErrors] -type settingWebPGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebPGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingWebPGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebPGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingWebPGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingWebPGetResponseEnvelopeMessages] -type settingWebPGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebPGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingwebsocket.go b/zones/settingwebsocket.go index 97170f6b895..24b1f33c510 100644 --- a/zones/settingwebsocket.go +++ b/zones/settingwebsocket.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -35,7 +36,7 @@ func NewSettingWebsocketService(opts ...option.RequestOption) (r *SettingWebsock // Changes Websockets setting. For more information about Websockets, please refer // to // [Using Cloudflare with WebSockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Using-Cloudflare-with-WebSockets). -func (r *SettingWebsocketService) Edit(ctx context.Context, params SettingWebsocketEditParams, opts ...option.RequestOption) (res *ZoneSettingWebsockets, err error) { +func (r *SettingWebsocketService) Edit(ctx context.Context, params SettingWebsocketEditParams, opts ...option.RequestOption) (res *Websocket, err error) { opts = append(r.Options[:], opts...) var env SettingWebsocketEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/websockets", params.ZoneID) @@ -49,7 +50,7 @@ func (r *SettingWebsocketService) Edit(ctx context.Context, params SettingWebsoc // Gets Websockets setting. For more information about Websockets, please refer to // [Using Cloudflare with WebSockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Using-Cloudflare-with-WebSockets). -func (r *SettingWebsocketService) Get(ctx context.Context, query SettingWebsocketGetParams, opts ...option.RequestOption) (res *ZoneSettingWebsockets, err error) { +func (r *SettingWebsocketService) Get(ctx context.Context, query SettingWebsocketGetParams, opts ...option.RequestOption) (res *Websocket, err error) { opts = append(r.Options[:], opts...) var env SettingWebsocketGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/websockets", query.ZoneID) @@ -68,22 +69,21 @@ func (r *SettingWebsocketService) Get(ctx context.Context, query SettingWebsocke // real-time applications such as live chat and gaming. For more information refer // to // [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). -type ZoneSettingWebsockets struct { +type Websocket struct { // ID of the zone setting. - ID ZoneSettingWebsocketsID `json:"id,required"` + ID WebsocketID `json:"id,required"` // Current value of the zone setting. - Value ZoneSettingWebsocketsValue `json:"value,required"` + Value WebsocketValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSettingWebsocketsEditable `json:"editable"` + Editable WebsocketEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWebsocketsJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON websocketJSON `json:"-"` } -// zoneSettingWebsocketsJSON contains the JSON metadata for the struct -// [ZoneSettingWebsockets] -type zoneSettingWebsocketsJSON struct { +// websocketJSON contains the JSON metadata for the struct [Websocket] +type websocketJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -92,44 +92,40 @@ type zoneSettingWebsocketsJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSettingWebsockets) UnmarshalJSON(data []byte) (err error) { +func (r *Websocket) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSettingWebsocketsJSON) RawJSON() string { +func (r websocketJSON) RawJSON() string { return r.raw } -func (r ZoneSettingWebsockets) implementsZonesSettingEditResponse() {} - -func (r ZoneSettingWebsockets) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSettingWebsocketsID string +type WebsocketID string const ( - ZoneSettingWebsocketsIDWebsockets ZoneSettingWebsocketsID = "websockets" + WebsocketIDWebsockets WebsocketID = "websockets" ) -func (r ZoneSettingWebsocketsID) IsKnown() bool { +func (r WebsocketID) IsKnown() bool { switch r { - case ZoneSettingWebsocketsIDWebsockets: + case WebsocketIDWebsockets: return true } return false } // Current value of the zone setting. -type ZoneSettingWebsocketsValue string +type WebsocketValue string const ( - ZoneSettingWebsocketsValueOff ZoneSettingWebsocketsValue = "off" - ZoneSettingWebsocketsValueOn ZoneSettingWebsocketsValue = "on" + WebsocketValueOff WebsocketValue = "off" + WebsocketValueOn WebsocketValue = "on" ) -func (r ZoneSettingWebsocketsValue) IsKnown() bool { +func (r WebsocketValue) IsKnown() bool { switch r { - case ZoneSettingWebsocketsValueOff, ZoneSettingWebsocketsValueOn: + case WebsocketValueOff, WebsocketValueOn: return true } return false @@ -137,41 +133,21 @@ func (r ZoneSettingWebsocketsValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSettingWebsocketsEditable bool +type WebsocketEditable bool const ( - ZoneSettingWebsocketsEditableTrue ZoneSettingWebsocketsEditable = true - ZoneSettingWebsocketsEditableFalse ZoneSettingWebsocketsEditable = false + WebsocketEditableTrue WebsocketEditable = true + WebsocketEditableFalse WebsocketEditable = false ) -func (r ZoneSettingWebsocketsEditable) IsKnown() bool { +func (r WebsocketEditable) IsKnown() bool { switch r { - case ZoneSettingWebsocketsEditableTrue, ZoneSettingWebsocketsEditableFalse: + case WebsocketEditableTrue, WebsocketEditableFalse: return true } return false } -// WebSockets are open connections sustained between the client and the origin -// server. Inside a WebSockets connection, the client and the origin can pass data -// back and forth without having to reestablish sessions. This makes exchanging -// data within a WebSockets connection fast. WebSockets are often used for -// real-time applications such as live chat and gaming. For more information refer -// to -// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). -type ZoneSettingWebsocketsParam struct { - // ID of the zone setting. - ID param.Field[ZoneSettingWebsocketsID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingWebsocketsValue] `json:"value,required"` -} - -func (r ZoneSettingWebsocketsParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingWebsocketsParam) implementsZonesSettingEditParamsItem() {} - type SettingWebsocketEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -200,8 +176,8 @@ func (r SettingWebsocketEditParamsValue) IsKnown() bool { } type SettingWebsocketEditResponseEnvelope struct { - Errors []SettingWebsocketEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingWebsocketEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // WebSockets are open connections sustained between the client and the origin @@ -211,7 +187,7 @@ type SettingWebsocketEditResponseEnvelope struct { // real-time applications such as live chat and gaming. For more information refer // to // [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). - Result ZoneSettingWebsockets `json:"result"` + Result Websocket `json:"result"` JSON settingWebsocketEditResponseEnvelopeJSON `json:"-"` } @@ -234,60 +210,14 @@ func (r settingWebsocketEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingWebsocketEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebsocketEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingWebsocketEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SettingWebsocketEditResponseEnvelopeErrors] -type settingWebsocketEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebsocketEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebsocketEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingWebsocketEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebsocketEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingWebsocketEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingWebsocketEditResponseEnvelopeMessages] -type settingWebsocketEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebsocketEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebsocketEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingWebsocketGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingWebsocketGetResponseEnvelope struct { - Errors []SettingWebsocketGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingWebsocketGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // WebSockets are open connections sustained between the client and the origin @@ -297,7 +227,7 @@ type SettingWebsocketGetResponseEnvelope struct { // real-time applications such as live chat and gaming. For more information refer // to // [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). - Result ZoneSettingWebsockets `json:"result"` + Result Websocket `json:"result"` JSON settingWebsocketGetResponseEnvelopeJSON `json:"-"` } @@ -319,49 +249,3 @@ func (r *SettingWebsocketGetResponseEnvelope) UnmarshalJSON(data []byte) (err er func (r settingWebsocketGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingWebsocketGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebsocketGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingWebsocketGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingWebsocketGetResponseEnvelopeErrors] -type settingWebsocketGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebsocketGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebsocketGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingWebsocketGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingWebsocketGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingWebsocketGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingWebsocketGetResponseEnvelopeMessages] -type settingWebsocketGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingWebsocketGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingWebsocketGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/settingzerortt.go b/zones/settingzerortt.go index 9c0da06ebd7..50780504a4d 100644 --- a/zones/settingzerortt.go +++ b/zones/settingzerortt.go @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "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" ) @@ -33,7 +34,7 @@ func NewSettingZeroRTTService(opts ...option.RequestOption) (r *SettingZeroRTTSe } // Changes the 0-RTT session resumption setting. -func (r *SettingZeroRTTService) Edit(ctx context.Context, params SettingZeroRTTEditParams, opts ...option.RequestOption) (res *ZoneSetting0rtt, err error) { +func (r *SettingZeroRTTService) Edit(ctx context.Context, params SettingZeroRTTEditParams, opts ...option.RequestOption) (res *ZeroRTT, err error) { opts = append(r.Options[:], opts...) var env SettingZeroRTTEditResponseEnvelope path := fmt.Sprintf("zones/%s/settings/0rtt", params.ZoneID) @@ -46,7 +47,7 @@ func (r *SettingZeroRTTService) Edit(ctx context.Context, params SettingZeroRTTE } // Gets 0-RTT session resumption setting. -func (r *SettingZeroRTTService) Get(ctx context.Context, query SettingZeroRTTGetParams, opts ...option.RequestOption) (res *ZoneSetting0rtt, err error) { +func (r *SettingZeroRTTService) Get(ctx context.Context, query SettingZeroRTTGetParams, opts ...option.RequestOption) (res *ZeroRTT, err error) { opts = append(r.Options[:], opts...) var env SettingZeroRTTGetResponseEnvelope path := fmt.Sprintf("zones/%s/settings/0rtt", query.ZoneID) @@ -59,21 +60,21 @@ func (r *SettingZeroRTTService) Get(ctx context.Context, query SettingZeroRTTGet } // 0-RTT session resumption enabled for this zone. -type ZoneSetting0rtt struct { +type ZeroRTT struct { // ID of the zone setting. - ID ZoneSetting0rttID `json:"id,required"` + ID ZeroRTTID `json:"id,required"` // Current value of the zone setting. - Value ZoneSetting0rttValue `json:"value,required"` + Value ZeroRTTValue `json:"value,required"` // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). - Editable ZoneSetting0rttEditable `json:"editable"` + Editable ZeroRTTEditable `json:"editable"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSetting0rttJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zeroRTTJSON `json:"-"` } -// zoneSetting0rttJSON contains the JSON metadata for the struct [ZoneSetting0rtt] -type zoneSetting0rttJSON struct { +// zeroRTTJSON contains the JSON metadata for the struct [ZeroRTT] +type zeroRTTJSON struct { ID apijson.Field Value apijson.Field Editable apijson.Field @@ -82,44 +83,40 @@ type zoneSetting0rttJSON struct { ExtraFields map[string]apijson.Field } -func (r *ZoneSetting0rtt) UnmarshalJSON(data []byte) (err error) { +func (r *ZeroRTT) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r zoneSetting0rttJSON) RawJSON() string { +func (r zeroRTTJSON) RawJSON() string { return r.raw } -func (r ZoneSetting0rtt) implementsZonesSettingEditResponse() {} - -func (r ZoneSetting0rtt) implementsZonesSettingGetResponse() {} - // ID of the zone setting. -type ZoneSetting0rttID string +type ZeroRTTID string const ( - ZoneSetting0rttID0rtt ZoneSetting0rttID = "0rtt" + ZeroRTTID0rtt ZeroRTTID = "0rtt" ) -func (r ZoneSetting0rttID) IsKnown() bool { +func (r ZeroRTTID) IsKnown() bool { switch r { - case ZoneSetting0rttID0rtt: + case ZeroRTTID0rtt: return true } return false } // Current value of the zone setting. -type ZoneSetting0rttValue string +type ZeroRTTValue string const ( - ZoneSetting0rttValueOn ZoneSetting0rttValue = "on" - ZoneSetting0rttValueOff ZoneSetting0rttValue = "off" + ZeroRTTValueOn ZeroRTTValue = "on" + ZeroRTTValueOff ZeroRTTValue = "off" ) -func (r ZoneSetting0rttValue) IsKnown() bool { +func (r ZeroRTTValue) IsKnown() bool { switch r { - case ZoneSetting0rttValueOn, ZoneSetting0rttValueOff: + case ZeroRTTValueOn, ZeroRTTValueOff: return true } return false @@ -127,35 +124,21 @@ func (r ZoneSetting0rttValue) IsKnown() bool { // Whether or not this setting can be modified for this zone (based on your // Cloudflare plan level). -type ZoneSetting0rttEditable bool +type ZeroRTTEditable bool const ( - ZoneSetting0rttEditableTrue ZoneSetting0rttEditable = true - ZoneSetting0rttEditableFalse ZoneSetting0rttEditable = false + ZeroRTTEditableTrue ZeroRTTEditable = true + ZeroRTTEditableFalse ZeroRTTEditable = false ) -func (r ZoneSetting0rttEditable) IsKnown() bool { +func (r ZeroRTTEditable) IsKnown() bool { switch r { - case ZoneSetting0rttEditableTrue, ZoneSetting0rttEditableFalse: + case ZeroRTTEditableTrue, ZeroRTTEditableFalse: return true } return false } -// 0-RTT session resumption enabled for this zone. -type ZoneSetting0rttParam struct { - // ID of the zone setting. - ID param.Field[ZoneSetting0rttID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSetting0rttValue] `json:"value,required"` -} - -func (r ZoneSetting0rttParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSetting0rttParam) implementsZonesSettingEditParamsItem() {} - type SettingZeroRTTEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -184,12 +167,12 @@ func (r SettingZeroRTTEditParamsValue) IsKnown() bool { } type SettingZeroRTTEditResponseEnvelope struct { - Errors []SettingZeroRTTEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingZeroRTTEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // 0-RTT session resumption enabled for this zone. - Result ZoneSetting0rtt `json:"result"` + Result ZeroRTT `json:"result"` JSON settingZeroRTTEditResponseEnvelopeJSON `json:"-"` } @@ -212,64 +195,18 @@ func (r settingZeroRTTEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SettingZeroRTTEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingZeroRTTEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingZeroRTTEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingZeroRTTEditResponseEnvelopeErrors] -type settingZeroRTTEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingZeroRTTEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingZeroRTTEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingZeroRTTEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingZeroRTTEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingZeroRTTEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SettingZeroRTTEditResponseEnvelopeMessages] -type settingZeroRTTEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingZeroRTTEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingZeroRTTEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type SettingZeroRTTGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type SettingZeroRTTGetResponseEnvelope struct { - Errors []SettingZeroRTTGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SettingZeroRTTGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` // 0-RTT session resumption enabled for this zone. - Result ZoneSetting0rtt `json:"result"` + Result ZeroRTT `json:"result"` JSON settingZeroRTTGetResponseEnvelopeJSON `json:"-"` } @@ -291,49 +228,3 @@ func (r *SettingZeroRTTGetResponseEnvelope) UnmarshalJSON(data []byte) (err erro func (r settingZeroRTTGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type SettingZeroRTTGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingZeroRTTGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// settingZeroRTTGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SettingZeroRTTGetResponseEnvelopeErrors] -type settingZeroRTTGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingZeroRTTGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingZeroRTTGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SettingZeroRTTGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON settingZeroRTTGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// settingZeroRTTGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SettingZeroRTTGetResponseEnvelopeMessages] -type settingZeroRTTGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SettingZeroRTTGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r settingZeroRTTGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zones/subscription.go b/zones/subscription.go index e86ea6f78d2..d0a6ca15958 100644 --- a/zones/subscription.go +++ b/zones/subscription.go @@ -7,14 +7,13 @@ import ( "fmt" "net/http" "reflect" - "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" + "github.com/cloudflare/cloudflare-go/v2/user" "github.com/tidwall/gjson" ) @@ -37,7 +36,7 @@ func NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionServic } // Create a zone subscription, either plan or add-ons. -func (r *SubscriptionService) New(ctx context.Context, identifier string, body SubscriptionNewParams, opts ...option.RequestOption) (res *SubscriptionNewResponse, err error) { +func (r *SubscriptionService) New(ctx context.Context, identifier string, body SubscriptionNewParams, opts ...option.RequestOption) (res *SubscriptionNewResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SubscriptionNewResponseEnvelope path := fmt.Sprintf("zones/%s/subscription", identifier) @@ -50,7 +49,7 @@ func (r *SubscriptionService) New(ctx context.Context, identifier string, body S } // Lists all of an account's subscriptions. -func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[SubscriptionListResponse], err error) { +func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *pagination.SinglePage[user.Subscription], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -68,12 +67,12 @@ func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string } // Lists all of an account's subscriptions. -func (r *SubscriptionService) ListAutoPaging(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SubscriptionListResponse] { +func (r *SubscriptionService) ListAutoPaging(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) *pagination.SinglePageAutoPager[user.Subscription] { return pagination.NewSinglePageAutoPager(r.List(ctx, accountIdentifier, opts...)) } // Lists zone subscription details. -func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionGetResponse, err error) { +func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionGetResponseUnion, err error) { opts = append(r.Options[:], opts...) var env SubscriptionGetResponseEnvelope path := fmt.Sprintf("zones/%s/subscription", identifier) @@ -87,13 +86,13 @@ func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts . // Union satisfied by [zones.SubscriptionNewResponseUnknown] or // [shared.UnionString]. -type SubscriptionNewResponse interface { - ImplementsZonesSubscriptionNewResponse() +type SubscriptionNewResponseUnion interface { + ImplementsZonesSubscriptionNewResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionNewResponse)(nil)).Elem(), + reflect.TypeOf((*SubscriptionNewResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -102,227 +101,15 @@ func init() { ) } -type SubscriptionListResponse struct { - // Subscription identifier tag. - ID string `json:"id"` - App SubscriptionListResponseApp `json:"app"` - // The list of add-ons subscribed to. - ComponentValues []SubscriptionListResponseComponentValue `json:"component_values"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency"` - // The end of the current period and also when the next billing is due. - CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` - // When the current billing period started. May match initial_period_start if this - // is the first period. - CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` - // How often the subscription is renewed automatically. - Frequency SubscriptionListResponseFrequency `json:"frequency"` - // The price of the subscription that will be billed, in US dollars. - Price float64 `json:"price"` - // The rate plan applied to the subscription. - RatePlan SubscriptionListResponseRatePlan `json:"rate_plan"` - // The state that the subscription is in. - State SubscriptionListResponseState `json:"state"` - // A simple zone object. May have null properties if not a zone subscription. - Zone SubscriptionListResponseZone `json:"zone"` - JSON subscriptionListResponseJSON `json:"-"` -} - -// subscriptionListResponseJSON contains the JSON metadata for the struct -// [SubscriptionListResponse] -type subscriptionListResponseJSON struct { - ID apijson.Field - App apijson.Field - ComponentValues apijson.Field - Currency apijson.Field - CurrentPeriodEnd apijson.Field - CurrentPeriodStart apijson.Field - Frequency apijson.Field - Price apijson.Field - RatePlan apijson.Field - State apijson.Field - Zone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseJSON) RawJSON() string { - return r.raw -} - -type SubscriptionListResponseApp struct { - // app install id. - InstallID string `json:"install_id"` - JSON subscriptionListResponseAppJSON `json:"-"` -} - -// subscriptionListResponseAppJSON contains the JSON metadata for the struct -// [SubscriptionListResponseApp] -type subscriptionListResponseAppJSON struct { - InstallID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseAppJSON) RawJSON() string { - return r.raw -} - -// A component value for a subscription. -type SubscriptionListResponseComponentValue struct { - // The default amount assigned. - Default float64 `json:"default"` - // The name of the component value. - Name string `json:"name"` - // The unit price for the component value. - Price float64 `json:"price"` - // The amount of the component value assigned. - Value float64 `json:"value"` - JSON subscriptionListResponseComponentValueJSON `json:"-"` -} - -// subscriptionListResponseComponentValueJSON contains the JSON metadata for the -// struct [SubscriptionListResponseComponentValue] -type subscriptionListResponseComponentValueJSON struct { - Default apijson.Field - Name apijson.Field - Price apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseComponentValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseComponentValueJSON) RawJSON() string { - return r.raw -} - -// How often the subscription is renewed automatically. -type SubscriptionListResponseFrequency string - -const ( - SubscriptionListResponseFrequencyWeekly SubscriptionListResponseFrequency = "weekly" - SubscriptionListResponseFrequencyMonthly SubscriptionListResponseFrequency = "monthly" - SubscriptionListResponseFrequencyQuarterly SubscriptionListResponseFrequency = "quarterly" - SubscriptionListResponseFrequencyYearly SubscriptionListResponseFrequency = "yearly" -) - -func (r SubscriptionListResponseFrequency) IsKnown() bool { - switch r { - case SubscriptionListResponseFrequencyWeekly, SubscriptionListResponseFrequencyMonthly, SubscriptionListResponseFrequencyQuarterly, SubscriptionListResponseFrequencyYearly: - return true - } - return false -} - -// The rate plan applied to the subscription. -type SubscriptionListResponseRatePlan struct { - // The ID of the rate plan. - ID string `json:"id"` - // The currency applied to the rate plan subscription. - Currency string `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged bool `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract bool `json:"is_contract"` - // The full name of the rate plan. - PublicName string `json:"public_name"` - // The scope that this rate plan applies to. - Scope string `json:"scope"` - // The list of sets this rate plan applies to. - Sets []string `json:"sets"` - JSON subscriptionListResponseRatePlanJSON `json:"-"` -} - -// subscriptionListResponseRatePlanJSON contains the JSON metadata for the struct -// [SubscriptionListResponseRatePlan] -type subscriptionListResponseRatePlanJSON struct { - ID apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - IsContract apijson.Field - PublicName apijson.Field - Scope apijson.Field - Sets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseRatePlan) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseRatePlanJSON) RawJSON() string { - return r.raw -} - -// The state that the subscription is in. -type SubscriptionListResponseState string - -const ( - SubscriptionListResponseStateTrial SubscriptionListResponseState = "Trial" - SubscriptionListResponseStateProvisioned SubscriptionListResponseState = "Provisioned" - SubscriptionListResponseStatePaid SubscriptionListResponseState = "Paid" - SubscriptionListResponseStateAwaitingPayment SubscriptionListResponseState = "AwaitingPayment" - SubscriptionListResponseStateCancelled SubscriptionListResponseState = "Cancelled" - SubscriptionListResponseStateFailed SubscriptionListResponseState = "Failed" - SubscriptionListResponseStateExpired SubscriptionListResponseState = "Expired" -) - -func (r SubscriptionListResponseState) IsKnown() bool { - switch r { - case SubscriptionListResponseStateTrial, SubscriptionListResponseStateProvisioned, SubscriptionListResponseStatePaid, SubscriptionListResponseStateAwaitingPayment, SubscriptionListResponseStateCancelled, SubscriptionListResponseStateFailed, SubscriptionListResponseStateExpired: - return true - } - return false -} - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionListResponseZone struct { - // Identifier - ID string `json:"id"` - // The domain name - Name string `json:"name"` - JSON subscriptionListResponseZoneJSON `json:"-"` -} - -// subscriptionListResponseZoneJSON contains the JSON metadata for the struct -// [SubscriptionListResponseZone] -type subscriptionListResponseZoneJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseZone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseZoneJSON) RawJSON() string { - return r.raw -} - // Union satisfied by [zones.SubscriptionGetResponseUnknown] or // [shared.UnionString]. -type SubscriptionGetResponse interface { - ImplementsZonesSubscriptionGetResponse() +type SubscriptionGetResponseUnion interface { + ImplementsZonesSubscriptionGetResponseUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionGetResponse)(nil)).Elem(), + reflect.TypeOf((*SubscriptionGetResponseUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -332,98 +119,17 @@ func init() { } type SubscriptionNewParams struct { - App param.Field[SubscriptionNewParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]SubscriptionNewParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[SubscriptionNewParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[SubscriptionNewParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[SubscriptionNewParamsZone] `json:"zone"` + Subscription user.SubscriptionParam `json:"subscription,required"` } func (r SubscriptionNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SubscriptionNewParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r SubscriptionNewParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type SubscriptionNewParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r SubscriptionNewParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type SubscriptionNewParamsFrequency string - -const ( - SubscriptionNewParamsFrequencyWeekly SubscriptionNewParamsFrequency = "weekly" - SubscriptionNewParamsFrequencyMonthly SubscriptionNewParamsFrequency = "monthly" - SubscriptionNewParamsFrequencyQuarterly SubscriptionNewParamsFrequency = "quarterly" - SubscriptionNewParamsFrequencyYearly SubscriptionNewParamsFrequency = "yearly" -) - -func (r SubscriptionNewParamsFrequency) IsKnown() bool { - switch r { - case SubscriptionNewParamsFrequencyWeekly, SubscriptionNewParamsFrequencyMonthly, SubscriptionNewParamsFrequencyQuarterly, SubscriptionNewParamsFrequencyYearly: - return true - } - return false -} - -// The rate plan applied to the subscription. -type SubscriptionNewParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[string] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r SubscriptionNewParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionNewParamsZone struct { -} - -func (r SubscriptionNewParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) + return apijson.MarshalRoot(r.Subscription) } type SubscriptionNewResponseEnvelope struct { - Errors []SubscriptionNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionNewResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionNewResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionNewResponseUnion `json:"result,required"` // Whether the API call was successful Success SubscriptionNewResponseEnvelopeSuccess `json:"success,required"` JSON subscriptionNewResponseEnvelopeJSON `json:"-"` @@ -448,52 +154,6 @@ func (r subscriptionNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionNewResponseEnvelopeErrors] -type subscriptionNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionNewResponseEnvelopeMessages] -type subscriptionNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionNewResponseEnvelopeSuccess bool @@ -510,9 +170,9 @@ func (r SubscriptionNewResponseEnvelopeSuccess) IsKnown() bool { } type SubscriptionGetResponseEnvelope struct { - Errors []SubscriptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionGetResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionGetResponse `json:"result,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result SubscriptionGetResponseUnion `json:"result,required"` // Whether the API call was successful Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"` JSON subscriptionGetResponseEnvelopeJSON `json:"-"` @@ -537,52 +197,6 @@ func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string { return r.raw } -type SubscriptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeErrors] -type subscriptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeMessages] -type subscriptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - // Whether the API call was successful type SubscriptionGetResponseEnvelopeSuccess bool diff --git a/zones/subscription_test.go b/zones/subscription_test.go index ea255897079..36e8c6cc36c 100644 --- a/zones/subscription_test.go +++ b/zones/subscription_test.go @@ -11,6 +11,7 @@ import ( "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" "github.com/cloudflare/cloudflare-go/v2/zones" ) @@ -32,36 +33,38 @@ func TestSubscriptionNewWithOptionalParams(t *testing.T) { context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2", zones.SubscriptionNewParams{ - App: cloudflare.F(zones.SubscriptionNewParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]zones.SubscriptionNewParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(zones.SubscriptionNewParamsFrequencyMonthly), - RatePlan: cloudflare.F(zones.SubscriptionNewParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(zones.SubscriptionNewParamsZone{}), + Subscription: user.SubscriptionParam{ + App: cloudflare.F(user.SubscriptionAppParam{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]user.SubscriptionComponentParam{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(user.SubscriptionFrequencyMonthly), + RatePlan: cloudflare.F(user.RatePlanParam{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(user.SubscriptionZoneParam{}), + }, }, ) if err != nil { diff --git a/zones/worker.go b/zones/worker.go deleted file mode 100644 index 8f7997c8492..00000000000 --- a/zones/worker.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package zones - -import ( - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// WorkerService 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 [NewWorkerService] method instead. -type WorkerService struct { - Options []option.RequestOption - Script *WorkerScriptService -} - -// NewWorkerService 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 NewWorkerService(opts ...option.RequestOption) (r *WorkerService) { - r = &WorkerService{} - r.Options = opts - r.Script = NewWorkerScriptService(opts...) - return -} diff --git a/zones/workerscript.go b/zones/workerscript.go deleted file mode 100644 index 15db20c9b44..00000000000 --- a/zones/workerscript.go +++ /dev/null @@ -1,188 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package zones - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "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" -) - -// WorkerScriptService 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 [NewWorkerScriptService] method -// instead. -type WorkerScriptService struct { - Options []option.RequestOption -} - -// NewWorkerScriptService 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 NewWorkerScriptService(opts ...option.RequestOption) (r *WorkerScriptService) { - r = &WorkerScriptService{} - r.Options = opts - return -} - -// Upload a worker, or a new version of a worker. -func (r *WorkerScriptService) Update(ctx context.Context, body WorkerScriptUpdateParams, opts ...option.RequestOption) (res *WorkerScriptUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/script", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete your Worker. This call has no response body on a successful delete. -func (r *WorkerScriptService) Delete(ctx context.Context, body WorkerScriptDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("zones/%s/workers/script", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, nil, opts...) - return -} - -// Fetch raw script content for your worker. Note this is the original script -// content, not JSON encoded. -func (r *WorkerScriptService) Get(ctx context.Context, query WorkerScriptGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "undefined")}, opts...) - path := fmt.Sprintf("zones/%s/workers/script", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// Union satisfied by [zones.WorkerScriptUpdateResponseUnknown] or -// [shared.UnionString]. -type WorkerScriptUpdateResponse interface { - ImplementsZonesWorkerScriptUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerScriptUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type WorkerScriptUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerScriptUpdateResponseEnvelope struct { - Errors []WorkerScriptUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerScriptUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerScriptUpdateResponseEnvelope] -type workerScriptUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerScriptUpdateResponseEnvelopeErrors] -type workerScriptUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerScriptUpdateResponseEnvelopeMessages] -type workerScriptUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptUpdateResponseEnvelopeSuccess bool - -const ( - WorkerScriptUpdateResponseEnvelopeSuccessTrue WorkerScriptUpdateResponseEnvelopeSuccess = true -) - -func (r WorkerScriptUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case WorkerScriptUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type WorkerScriptDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerScriptGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} diff --git a/zones/zone.go b/zones/zone.go index 06cf7068390..4d1bc7e22d5 100644 --- a/zones/zone.go +++ b/zones/zone.go @@ -14,6 +14,7 @@ import ( "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" ) @@ -28,7 +29,6 @@ type ZoneService struct { Settings *SettingService CustomNameservers *CustomNameserverService Holds *HoldService - Workers *WorkerService Subscriptions *SubscriptionService } @@ -43,7 +43,6 @@ func NewZoneService(opts ...option.RequestOption) (r *ZoneService) { r.Settings = NewSettingService(opts...) r.CustomNameservers = NewCustomNameserverService(opts...) r.Holds = NewHoldService(opts...) - r.Workers = NewWorkerService(opts...) r.Subscriptions = NewSubscriptionService(opts...) return } @@ -339,8 +338,8 @@ func (r ZoneNewParamsType) IsKnown() bool { } type ZoneNewResponseEnvelope struct { - Errors []ZoneNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneNewResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` Result Zone `json:"result"` @@ -366,52 +365,6 @@ func (r zoneNewResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ZoneNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ZoneNewResponseEnvelopeErrors] -type zoneNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ZoneNewResponseEnvelopeMessages] -type zoneNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type ZoneListParams struct { Account param.Field[ZoneListParamsAccount] `query:"account"` // Direction to order zones. @@ -443,7 +396,7 @@ type ZoneListParams struct { // URLQuery serializes [ZoneListParams]'s query parameters as `url.Values`. func (r ZoneListParams) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -468,7 +421,7 @@ type ZoneListParamsAccount struct { // URLQuery serializes [ZoneListParamsAccount]'s query parameters as `url.Values`. func (r ZoneListParamsAccount) URLQuery() (v url.Values) { return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, + ArrayFormat: apiquery.ArrayQueryFormatRepeat, NestedFormat: apiquery.NestedQueryFormatBrackets, }) } @@ -547,8 +500,8 @@ type ZoneDeleteParams struct { } type ZoneDeleteResponseEnvelope struct { - Errors []ZoneDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneDeleteResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` Result ZoneDeleteResponse `json:"result,nullable"` @@ -574,52 +527,6 @@ func (r zoneDeleteResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ZoneDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ZoneDeleteResponseEnvelopeErrors] -type zoneDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ZoneDeleteResponseEnvelopeMessages] -type zoneDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type ZoneEditParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -674,8 +581,8 @@ func (r ZoneEditParamsType) IsKnown() bool { } type ZoneEditResponseEnvelope struct { - Errors []ZoneEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneEditResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` Result Zone `json:"result"` @@ -701,60 +608,14 @@ func (r zoneEditResponseEnvelopeJSON) RawJSON() string { return r.raw } -type ZoneEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ZoneEditResponseEnvelopeErrors] -type zoneEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ZoneEditResponseEnvelopeMessages] -type zoneEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - type ZoneGetParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` } type ZoneGetResponseEnvelope struct { - Errors []ZoneGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneGetResponseEnvelopeMessages `json:"messages,required"` + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success bool `json:"success,required"` Result Zone `json:"result"` @@ -779,49 +640,3 @@ func (r *ZoneGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { func (r zoneGetResponseEnvelopeJSON) RawJSON() string { return r.raw } - -type ZoneGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ZoneGetResponseEnvelopeErrors] -type zoneGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ZoneGetResponseEnvelopeMessages] -type zoneGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -}